<?php
 namespace App\ClientCollection\Corporate\Document; class ExtendedXlsx extends DefaultXlsx { protected $attachmentFileName = 'Invoices list reminder.xlsx'; protected $sheetName = 'Invoices'; protected $columns = [ 'status' => 'status', 'extSystReservationId' => 'default', 'confirmationNumber' => 'default', 'orderNumber' => 'default', 'invoiceNumber' => 'numeric', 'invoiceDate' => 'date', 'invoiceDueDate' => 'date', 'noOfDelayedDays' => 'numeric', 'valueInvCurr' => 'price', 'invoiceCurr' => 'default', 'alreadyPaidInvCurr' => 'price', 'amountToBePaidInvCurr' => 'price', 'paymentsList' => 'default', ]; protected $rowStyle = 'default'; protected function loadLang(): void { \App\Loader_Lang::getInstance()->loadAppFile('_customLoad/corporateCollection/document/extendedXlsx.lang.php'); \App\Loader_Lang::getInstance()->loadAppFile('_customLoad/corporateCollection/document/defaultXlsx.lang.php'); } protected function addInvoiceDetailsRow(int $idInvoice, array $invoiceDetails) : array { $row = parent::addInvoiceDetailsRow($idInvoice, $invoiceDetails); $clientInvoiceRowsObj = new \App\ReportsData\EntityList\ClientInvoiceRows(); $clientInvoiceRowsObj->setColumns(['row.idService']); $clientInvoiceRowsObj->setFilter('row.idInvoice', '=', $idInvoice); $rowServicesList = $clientInvoiceRowsObj->exportRecords(); $serviceIdsList = array_unique(array_column($rowServicesList, 'idService')); $confirmationNoList = []; $extSystReservationIdList = []; $orderNoList = []; if ($serviceIdsList) { $servicesListObj = new \App\ReportsData\EntityList\Services(); $servicesListObj->setColumns(['off.confirmationNumber', 'off.externalSystemReservationId', 'ord.orderNumber']); $servicesListObj->setFilter('serv.id', 'IN', $serviceIdsList); $servicesList = $servicesListObj->exportRecords(); foreach ($servicesList as $serviceDetails) { $extSystReservationIdList[] = $serviceDetails['externalSystemReservationId']; $confirmationNoList[] = $serviceDetails['confirmationNumber']; $orderNoList[] = $serviceDetails['orderNumber']; } } $row['extSystReservationId'] = implode(', ', array_filter($extSystReservationIdList)); $row['confirmationNumber'] = implode(', ', array_filter($confirmationNoList)); $row['orderNumber'] = implode(', ', array_unique($orderNoList)); return $row; } protected function addTotalRow(float $total, float $cashedTotal, string $currency) : array { $row = parent::addTotalRow($total, $cashedTotal, $currency); $row['extSystReservationId'] = ""; $row['confirmationNumber'] = ""; $row['orderNumber'] = ""; return $row; } protected function getColumnName($columnCode): string { $_LANG = \App\Loader_Lang::getInstance()->getGlobal(); return $_LANG['CorporateCollection']['Document']['ExtendedXlsx']['header'][$columnCode]; } }