From c7cb72546f2bdaaa81873077d8c2d1bcb7e4c7a6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 11 Dec 2017 13:03:28 +0200 Subject: [PATCH] Merge fix for reports --- app/Http/Controllers/ReportController.php | 34 ++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 0a48bd6fcdfd..5e6112aed181 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -202,25 +202,27 @@ class ReportController extends BaseController $sheet->setAutoSize(true); }); - $excel->sheet(trans("texts.totals"), function($sheet) use($report, $summary, $format) { - $sheet->setOrientation('landscape'); - $sheet->freezeFirstRow(); + if (count($summary)) { + $excel->sheet(trans("texts.totals"), function($sheet) use($report, $summary, $format) { + $sheet->setOrientation('landscape'); + $sheet->freezeFirstRow(); - if ($format == 'pdf') { - $sheet->setAllBorders('thin'); - } - $sheet->rows($summary); + if ($format == 'pdf') { + $sheet->setAllBorders('thin'); + } + $sheet->rows($summary); - // Styling header - $sheet->cells('A1:'.Utils::num2alpha(count($summary[0])-1).'1', function($cells) { - $cells->setBackground('#777777'); - $cells->setFontColor('#FFFFFF'); - $cells->setFontSize(13); - $cells->setFontFamily('Calibri'); - $cells->setFontWeight('bold'); + // Styling header + $sheet->cells('A1:'.Utils::num2alpha(count($summary[0])-1).'1', function($cells) { + $cells->setBackground('#777777'); + $cells->setFontColor('#FFFFFF'); + $cells->setFontSize(13); + $cells->setFontFamily('Calibri'); + $cells->setFontWeight('bold'); + }); + $sheet->setAutoSize(true); }); - $sheet->setAutoSize(true); - }); + } })->export($format); }