From 3eecb2f6025d75b30cdcd593640e6fe7bbdef781 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 15 May 2026 15:18:25 +0300 Subject: [PATCH] fix: wrap logo/QR Drawing in try-catch, use $logoPath var, add cURL fallback for QR download --- app/modules_app/invoices/export_excel.php | 40 ++++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/app/modules_app/invoices/export_excel.php b/app/modules_app/invoices/export_excel.php index 62600cd..1744ab4 100644 --- a/app/modules_app/invoices/export_excel.php +++ b/app/modules_app/invoices/export_excel.php @@ -171,14 +171,18 @@ $summarySheet->getStyle("A1")->applyFromArray([ $summarySheet->getRowDimension(1)->setRowHeight(45); // --- Add Logo --- -$logoSummary = new Drawing(); -$logoSummary->setName('Musadaq Logo'); -$logoSummary->setPath(ROOT_PATH . '/public/assets/img/logo.jpg'); -$logoSummary->setHeight(38); -$logoSummary->setCoordinates('A1'); -$logoSummary->setOffsetX(15); -$logoSummary->setOffsetY(5); -$logoSummary->setWorksheet($summarySheet); +try { + if (file_exists($logoPath)) { + $logoSummary = new Drawing(); + $logoSummary->setName('Musadaq Logo'); + $logoSummary->setPath($logoPath); + $logoSummary->setHeight(38); + $logoSummary->setCoordinates('A1'); + $logoSummary->setOffsetX(15); + $logoSummary->setOffsetY(5); + $logoSummary->setWorksheet($summarySheet); + } +} catch(\Exception $e) { error_log('Logo Summary Error: ' . $e->getMessage()); } // --- Add Clickable Website Link --- $summarySheet->setCellValue("J1", 'musadaq.intaleqapp.com'); @@ -329,14 +333,18 @@ foreach ($invoices as $invIdx => $inv) { $sheet->getRowDimension($invRow)->setRowHeight(45); // --- Add Logo --- - $logoInv = new Drawing(); - $logoInv->setName('Musadaq Logo'); - $logoInv->setPath(ROOT_PATH . '/public/assets/img/logo.jpg'); - $logoInv->setHeight(38); - $logoInv->setCoordinates('A' . $invRow); - $logoInv->setOffsetX(15); - $logoInv->setOffsetY(5); - $logoInv->setWorksheet($sheet); + try { + if (file_exists($logoPath)) { + $logoInv = new Drawing(); + $logoInv->setName('Musadaq Logo'); + $logoInv->setPath($logoPath); + $logoInv->setHeight(38); + $logoInv->setCoordinates('A' . $invRow); + $logoInv->setOffsetX(15); + $logoInv->setOffsetY(5); + $logoInv->setWorksheet($sheet); + } + } catch(\Exception $e) { error_log('Logo Invoice Error: ' . $e->getMessage()); } // --- Add Clickable Website Link --- $sheet->setCellValue("I" . $invRow, 'musadaq.intaleqapp.com');