diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 86357d6..968d834 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -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(); diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index bfc590d..0d56d04 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -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); } } diff --git a/resources/views/export/index.blade.php b/resources/views/export/index.blade.php index fdce7ff..651ea18 100644 --- a/resources/views/export/index.blade.php +++ b/resources/views/export/index.blade.php @@ -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);