diff --git a/Admin/Install/Interfaces/ListExchanger/CsvListExporter/defaultCsvExporter.csv.php b/Admin/Install/Interfaces/ListExchanger/CsvListExporter/defaultCsvExporter.csv.php index 3fb74ec..39d7275 100644 --- a/Admin/Install/Interfaces/ListExchanger/CsvListExporter/defaultCsvExporter.csv.php +++ b/Admin/Install/Interfaces/ListExchanger/CsvListExporter/defaultCsvExporter.csv.php @@ -12,10 +12,19 @@ */ declare(strict_types=1); +use Modules\Exchange\Models\NullReport; + /** @var \phpOMS\Views\View $this */ -/** @var array $data */ -$report = $this->data['report'] ?? []; -$headlines = \array_keys(\reset($report->data)); + +/** @var \Modules\Exchange\Models\Report $report */ +$report = $this->data['report'] ?? new NullReport(); + +$first = \reset($report->data); +if ($first === false) { + $first = []; +} + +$headlines = \array_keys($first); $out = \fopen('php://output', 'w'); if ($out !== false) { diff --git a/Admin/Install/Interfaces/ListExchanger/ExcelListExporter/defaultExcelExporter.xls.php b/Admin/Install/Interfaces/ListExchanger/ExcelListExporter/defaultExcelExporter.xls.php index 133a1c5..1c95e8b 100644 --- a/Admin/Install/Interfaces/ListExchanger/ExcelListExporter/defaultExcelExporter.xls.php +++ b/Admin/Install/Interfaces/ListExchanger/ExcelListExporter/defaultExcelExporter.xls.php @@ -12,24 +12,34 @@ */ declare(strict_types=1); +use Modules\Exchange\Models\NullReport; +use Modules\Media\Models\NullCollection; use PhpOffice\PhpSpreadsheet\IOFactory; use phpOMS\Utils\StringUtils; /** @var \phpOMS\Views\View $this */ -/** @var array $data */ -$report = $this->data['report'] ?? []; +/** @var \Modules\Exchange\Models\Report $report */ +$report = $this->data['report'] ?? new NullReport(); -include $this->data['defaultTemplates']->findFile('.xls.php')->getAbsolutePath(); +/** @var \Modules\Media\Models\Collection $collection */ +$collection = $this->data['defaultTemplates'] ?? new NullCollection(); + +include $collection->findFile('.xls.php')->getAbsolutePath(); $spreadsheet = new DefaultExcel(); -$headlines = \array_keys(\reset($report->data)); +$first = \reset($report->data); +if ($first === false) { + $first = []; +} + +$headlines = \array_keys($first); foreach ($headlines as $j => $headline) { $spreadsheet->getActiveSheet()->setCellValue(StringUtils::intToAlphabet($j + 1) . 1, $headline); } -foreach ($data as $i => $row) { +foreach ($report->data as $i => $row) { foreach ($row as $j => $cell) { $spreadsheet->getActiveSheet()->setCellValue(StringUtils::intToAlphabet($j + 1) . ($i + 2), $cell); } diff --git a/Admin/Install/Interfaces/ListExchanger/PdfListExporter/defaultPdfListExporter.pdf.php b/Admin/Install/Interfaces/ListExchanger/PdfListExporter/defaultPdfListExporter.pdf.php index b754ecb..dfbf7c4 100644 --- a/Admin/Install/Interfaces/ListExchanger/PdfListExporter/defaultPdfListExporter.pdf.php +++ b/Admin/Install/Interfaces/ListExchanger/PdfListExporter/defaultPdfListExporter.pdf.php @@ -12,12 +12,18 @@ */ declare(strict_types=1); +use Modules\Exchange\Models\NullReport; +use Modules\Media\Models\NullCollection; + /** @var \phpOMS\Views\View $this */ -/** @var array $data */ -$report = $this->data['report'] ?? []; +/** @var \Modules\Exchange\Models\Report $report */ +$report = $this->data['report'] ?? new NullReport(); -require_once $this->data['defaultTemplates']->findFile('.pdf.php')->getAbsolutePath(); +/** @var \Modules\Media\Models\Collection $collection */ +$collection = $this->data['defaultTemplates'] ?? new NullCollection(); + +require_once $collection->findFile('.pdf.php')->getAbsolutePath(); /** @phpstan-import-type DefaultPdf from ../../../../Admin/Install/Media/PdfDefaultTemplate/pdfTemplate.pdf.php */ $pdf = new DefaultPdf(); @@ -27,7 +33,12 @@ $topPos = $pdf->getY(); $tbl = ''; // headline -$headlines = \array_keys(\reset($report->data)); +$first = \reset($report->data); +if ($first === false) { + $first = []; +} + +$headlines = \array_keys($first); $tbl .= ''; foreach ($headlines as $headline) { $tbl .= ''; diff --git a/Models/NullReport.php b/Models/NullReport.php new file mode 100644 index 0000000..54e8872 --- /dev/null +++ b/Models/NullReport.php @@ -0,0 +1,27 @@ +
' . $headline . '