1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Remove $columns_labeled to use return

This commit is contained in:
Gilbert Paquin 2017-08-01 09:37:33 -04:00
parent 8ace6ad1ea
commit fe8f34fc33
2 changed files with 11 additions and 9 deletions

View File

@ -145,7 +145,7 @@ class ReportController extends BaseController
}
//Get labeled header
$report->tableHeaderArray();
$columns_labeled = $report->tableHeaderArray();
/*$summary = [];
if(count(array_values($totals))) {
@ -167,8 +167,8 @@ class ReportController extends BaseController
dd($summary);*/
return Excel::create($filename, function($excel) use($report, $data, $reportType, $format) {
$excel->sheet(trans("texts.$reportType"), function($sheet) use($report, $data, $format) {
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->freezeFirstRow();
@ -178,12 +178,12 @@ class ReportController extends BaseController
$sheet->setAllBorders('thin');
$sheet->rows(array_merge(
[array_map(function($col) {return $col['label'];}, $report->columns_labeled)],
[array_map(function($col) {return $col['label'];}, $columns_labeled)],
$data
));
//Styling header
$sheet->cells('A1:'.Utils::num2alpha(count($report->columns_labeled)-1).'1', function($cells) {
$sheet->cells('A1:'.Utils::num2alpha(count($columns_labeled)-1).'1', function($cells) {
$cells->setBackground('#777777');
$cells->setFontColor('#FFFFFF');
$cells->setFontSize(14);

View File

@ -14,7 +14,6 @@ class AbstractReport
public $totals = [];
public $columns = [];
public $data = [];
public $columns_labeled = [];
public function __construct($startDate, $endDate, $isExport, $options = false)
{
@ -54,6 +53,7 @@ class AbstractReport
}
public function tableHeaderArray() {
$columns_labeled = [];
foreach ($this->columns as $key => $val) {
if (is_array($val)) {
@ -75,16 +75,18 @@ class AbstractReport
$class = count($class) ? implode(' ', $class) : 'group-false';
$label = trans("texts.{$field}");
$this->columns_labeled[] = ['label' => $label, 'class' => $class, 'key' => $field];
$columns_labeled[] = ['label' => $label, 'class' => $class, 'key' => $field];
}
return $columns_labeled;
}
public function tableHeader()
{
$this->tableHeaderArray();
$columns_labeled = $this->tableHeaderArray();
$str = '';
foreach ($this->columns_labeled as $field => $attr)
foreach ($columns_labeled as $field => $attr)
$str .= "<th class=\"{$attr['class']}\">{$attr['label']}</th>";
return $str;