70 lines
No EOL
2.3 KiB
PHP
70 lines
No EOL
2.3 KiB
PHP
@extends('layouts.main')
|
|
|
|
@section('content')
|
|
<h2><i class="fas fa-file-export"></i> Export des données coupons</h2>
|
|
<div class="selector-export">
|
|
<h4>Période :</h4>
|
|
<input type="date" name="startdate" id="startdate" value="{{ $startdate }}">
|
|
<input type="date" name="enddate" id="enddate" value="{{ $enddate }}">
|
|
<input type="hidden" name="csrf" id="csrf" value="<?php echo csrf_token(); ?>">
|
|
<a href="#" class="add-button export-data"><i class="fas fa-file-export"></i> Exporter les données</a>
|
|
</div>
|
|
@foreach ($sites as $site)
|
|
|
|
<h4>{{ $site->site_nom }} ({{ $site->site_id }})</h4>
|
|
@if (isset($site->coupons) && $site->coupons->count()>0)
|
|
@foreach ($site->coupons as $coupon)
|
|
<div class="inputGroup-export">
|
|
<input id="coupon[{{$coupon->coupon_id}}]" name="coupon[{{$coupon->coupon_id}}]" type="checkbox" value="{{$coupon->coupon_id}}"/>
|
|
<label for="coupon[{{$coupon->coupon_id}}]">{{$coupon->coupon_name}}</label>
|
|
</div>
|
|
@endforeach
|
|
@endif
|
|
|
|
@endforeach
|
|
<div class="export-btn">
|
|
<a href="#" class="add-button export-data"><i class="fas fa-file-export"></i> Exporter les données</a>
|
|
<a href="" download class="dl-pdf"></a>
|
|
</div>
|
|
|
|
@endsection
|
|
|
|
@section('scripts')
|
|
<script>
|
|
$('.export-data').on('click', function(event){
|
|
event.preventDefault();
|
|
let ids = [];
|
|
$('.inputGroup-export input').each(function(event){
|
|
if($(this).is(':checked')){
|
|
ids.push($(this).val());
|
|
}
|
|
|
|
})
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('#csrf').val()
|
|
}
|
|
});
|
|
$.ajax({
|
|
url: '/exportCoupon',
|
|
type: 'POST',
|
|
data: {
|
|
ids: ids,
|
|
startdate: $('#startdate').val(),
|
|
enddate: $('#enddate').val(),
|
|
},
|
|
dataType: 'JSON',
|
|
success: function (response) {
|
|
$.each(response, function(index, element){
|
|
$('.dl-pdf').attr("href", '/'+element);
|
|
$('.dl-pdf').get(0).click();
|
|
})
|
|
},
|
|
error: function (e) {
|
|
console.log(e.responseText);
|
|
}
|
|
});
|
|
})
|
|
|
|
</script>
|
|
@endsection |