95 lines
3.5 KiB
Twig
95 lines
3.5 KiB
Twig
{% extends 'base.html.twig' %}
|
|
|
|
{% block body %}
|
|
<!-- BEGIN: Subheader -->
|
|
<div class="m-subheader">
|
|
<div class="d-flex align-items-center">
|
|
<div class="mr-auto">
|
|
<h3 class="m-subheader__title">
|
|
Warranty Upload
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END: Subheader -->
|
|
<div class="m-content">
|
|
<!--Begin::Section-->
|
|
<div class="row">
|
|
<div class="col-xl-6">
|
|
<div class="m-portlet m-portlet--mobile">
|
|
<div class="m-portlet__head">
|
|
<div class="m-portlet__head-caption">
|
|
<div class="m-portlet__head-title">
|
|
<span class="m-portlet__head-icon">
|
|
<i class="fa fa-upload"></i>
|
|
</span>
|
|
<h3 class="m-portlet__head-text">
|
|
Upload Warranty CSV File
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<form id="upload-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ url('warranty_upload_submit') }}" enctype="multipart/form-data">
|
|
<div class="m-portlet__body">
|
|
<div class="form-group m-form__group row">
|
|
<input type="file" id="csv_file" name="csv_file" >
|
|
</div>
|
|
<div class="m-portlet__foot m-portlet__foot--fit">
|
|
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<button type="submit" class="btn btn-success">Upload</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
$(function() {
|
|
$("#upload-form").submit(function(e) {
|
|
var form = $(this);
|
|
|
|
e.preventDefault();
|
|
|
|
$.ajax({
|
|
method: "POST",
|
|
url: form.prop('action'),
|
|
data: new FormData(this),
|
|
processData: false,
|
|
contentType: false,
|
|
cache: false,
|
|
}).done(function(response, status, xhr) {
|
|
if (xhr.getResponseHeader('Content-Type') == "text/html; charset=UTF-8") {
|
|
swal({
|
|
title: 'Done!',
|
|
text: 'All warranties uploaded!',
|
|
type: 'success',
|
|
});
|
|
} else {
|
|
console.log('csv');
|
|
var blob = new Blob([response], {type: "text/csv" });
|
|
var link = document.createElement('a');
|
|
link.href = window.URL.createObjectURL(blob);
|
|
link.download = "invalid_warranties.csv";
|
|
|
|
document.body.appendChild(link);
|
|
|
|
link.click();
|
|
|
|
document.body.removeChild(link);
|
|
|
|
}
|
|
}).fail(function(response) {
|
|
});
|
|
})
|
|
});
|
|
</script>
|
|
{% endblock %}
|