mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on adding totals to the report export
This commit is contained in:
parent
6a25d8af89
commit
f6d8ae4326
@ -149,11 +149,14 @@ class ReportController extends BaseController
|
|||||||
//Get labeled header
|
//Get labeled header
|
||||||
$columns_labeled = $report->tableHeaderArray();
|
$columns_labeled = $report->tableHeaderArray();
|
||||||
|
|
||||||
/*$summary = [];
|
$summary = [];
|
||||||
if(count(array_values($totals))) {
|
/*
|
||||||
|
if (count(array_values($totals))) {
|
||||||
$summary[] = array_merge([
|
$summary[] = array_merge([
|
||||||
trans("texts.totals")
|
trans("texts.totals")
|
||||||
], array_map(function ($key) {return trans("texts.{$key}");}, array_keys(array_values(array_values($totals)[0])[0])));
|
], array_map(function ($key) {
|
||||||
|
return trans("texts.{$key}");
|
||||||
|
}, array_keys(array_values(array_values($totals)[0])[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($totals as $currencyId => $each) {
|
foreach ($totals as $currencyId => $each) {
|
||||||
@ -161,30 +164,38 @@ class ReportController extends BaseController
|
|||||||
$tmp = [];
|
$tmp = [];
|
||||||
$tmp[] = Utils::getFromCache($currencyId, 'currencies')->name . (($dimension) ? ' - ' . $dimension : '');
|
$tmp[] = Utils::getFromCache($currencyId, 'currencies')->name . (($dimension) ? ' - ' . $dimension : '');
|
||||||
|
|
||||||
foreach ($val as $id => $field) $tmp[] = Utils::formatMoney($field, $currencyId);
|
foreach ($val as $id => $field) {
|
||||||
|
$tmp[] = Utils::formatMoney($field, $currencyId);
|
||||||
|
}
|
||||||
|
|
||||||
$summary[] = $tmp;
|
$summary[] = $tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
dd($summary);*/
|
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, $columns_labeled) {
|
|
||||||
$excel->sheet(trans("texts.$reportType"), function($sheet) use($report, $data, $format, $columns_labeled) {
|
|
||||||
|
|
||||||
$sheet->setOrientation('landscape');
|
$sheet->setOrientation('landscape');
|
||||||
$sheet->freezeFirstRow();
|
$sheet->freezeFirstRow();
|
||||||
|
|
||||||
//Add border on PDF
|
if ($format == 'pdf') {
|
||||||
if($format == 'pdf')
|
|
||||||
$sheet->setAllBorders('thin');
|
$sheet->setAllBorders('thin');
|
||||||
|
}
|
||||||
|
|
||||||
$sheet->rows(array_merge(
|
$sheet->rows(array_merge(
|
||||||
[array_map(function($col) {return $col['label'];}, $columns_labeled)],
|
[array_map(function($col) {return $col['label'];}, $columns_labeled)],
|
||||||
$data
|
$data
|
||||||
));
|
));
|
||||||
|
|
||||||
//Styling header
|
/*
|
||||||
|
$sheet->rows(array_merge(
|
||||||
|
[],
|
||||||
|
$summary
|
||||||
|
));
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Styling header
|
||||||
$sheet->cells('A1:'.Utils::num2alpha(count($columns_labeled)-1).'1', function($cells) {
|
$sheet->cells('A1:'.Utils::num2alpha(count($columns_labeled)-1).'1', function($cells) {
|
||||||
$cells->setBackground('#777777');
|
$cells->setBackground('#777777');
|
||||||
$cells->setFontColor('#FFFFFF');
|
$cells->setFontColor('#FFFFFF');
|
||||||
@ -193,7 +204,6 @@ class ReportController extends BaseController
|
|||||||
$cells->setFontWeight('bold');
|
$cells->setFontWeight('bold');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$sheet->setAutoSize(true);
|
$sheet->setAutoSize(true);
|
||||||
});
|
});
|
||||||
})->export($format);
|
})->export($format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user