Fix multiple export & no stats on cron when 0

This commit is contained in:
Thibault Richy 2019-03-20 12:22:03 +01:00
parent 9fe5ad3539
commit 31dba136d9
3 changed files with 15 additions and 11 deletions

View file

@ -133,12 +133,14 @@ class Kernel extends ConsoleKernel
}
}
// ---- Insertion en base de stats
$stat = new Statistique();
$stat->stat_campId = $campagne->camp_id;
$stat->stat_couponId = $coupon->coupon_id;
$stat->stat_couponPrinted = $count;
if($count > 0){
$stat = new Statistique();
$stat->stat_campId = $campagne->camp_id;
$stat->stat_couponId = $coupon->coupon_id;
$stat->stat_couponPrinted = $count;
$stat->save();
$stat->save();
}
}
}
})->everyFifteenMinutes();

View file

@ -43,7 +43,7 @@ class ExportController extends Controller
$labels = $this->getLabelsForStats($startdate, $enddate);
$paths = array();
foreach ($coupons as $coupon) {
$cpName = str_replace(' ', '', $coupon->coupon_name);
@ -80,8 +80,9 @@ class ExportController extends Controller
$pdf->loadHTML($view);
$pdf->save($full_path);
array_push($paths, $fullpath);
}
return json_encode($full_path);
return json_encode($paths);
}
}

View file

@ -54,10 +54,11 @@
enddate: $('#enddate').val(),
},
dataType: 'JSON',
success: function (response) {
$('.dl-pdf').attr("href", '/'+response);
$('.dl-pdf').get(0).click();
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);