mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Include totals in exported report
This commit is contained in:
parent
002665b2db
commit
715838d401
@ -147,10 +147,16 @@ class ReportController extends BaseController
|
||||
}
|
||||
|
||||
//Get labeled header
|
||||
$columns_labeled = $report->tableHeaderArray();
|
||||
$data = array_merge(
|
||||
[
|
||||
array_map(function($col) {
|
||||
return $col['label'];
|
||||
}, $report->tableHeaderArray())
|
||||
],
|
||||
$data
|
||||
);
|
||||
|
||||
$summary = [];
|
||||
/*
|
||||
if (count(array_values($totals))) {
|
||||
$summary[] = array_merge([
|
||||
trans("texts.totals")
|
||||
@ -163,49 +169,59 @@ class ReportController extends BaseController
|
||||
foreach ($each as $dimension => $val) {
|
||||
$tmp = [];
|
||||
$tmp[] = Utils::getFromCache($currencyId, 'currencies')->name . (($dimension) ? ' - ' . $dimension : '');
|
||||
|
||||
foreach ($val as $id => $field) {
|
||||
$tmp[] = Utils::formatMoney($field, $currencyId);
|
||||
}
|
||||
|
||||
$summary[] = $tmp;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return Excel::create($filename, function($excel) use($report, $data, $reportType, $format, $columns_labeled, $summary) {
|
||||
$excel->sheet(trans("texts.$reportType"), function($sheet) use($report, $data, $format, $columns_labeled, $summary) {
|
||||
return Excel::create($filename, function($excel) use($report, $data, $reportType, $format, $summary) {
|
||||
|
||||
$excel->sheet(trans("texts.$reportType"), function($sheet) use($report, $data, $format, $summary) {
|
||||
$sheet->setOrientation('landscape');
|
||||
$sheet->freezeFirstRow();
|
||||
|
||||
if ($format == 'pdf') {
|
||||
$sheet->setAllBorders('thin');
|
||||
}
|
||||
|
||||
$sheet->rows(array_merge(
|
||||
[array_map(function($col) {return $col['label'];}, $columns_labeled)],
|
||||
$data
|
||||
));
|
||||
|
||||
/*
|
||||
$sheet->rows(array_merge(
|
||||
[],
|
||||
$summary
|
||||
));
|
||||
*/
|
||||
if ($format == 'csv') {
|
||||
$sheet->rows(array_merge($data, [[]], $summary));
|
||||
} else {
|
||||
$sheet->rows($data);
|
||||
}
|
||||
|
||||
// Styling header
|
||||
$sheet->cells('A1:'.Utils::num2alpha(count($columns_labeled)-1).'1', function($cells) {
|
||||
$sheet->cells('A1:'.Utils::num2alpha(count($data[0])-1).'1', function($cells) {
|
||||
$cells->setBackground('#777777');
|
||||
$cells->setFontColor('#FFFFFF');
|
||||
$cells->setFontSize(13);
|
||||
$cells->setFontFamily('Calibri');
|
||||
$cells->setFontWeight('bold');
|
||||
});
|
||||
|
||||
$sheet->setAutoSize(true);
|
||||
});
|
||||
|
||||
$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);
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
})->export($format);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user