diff --git a/app/modules_app/invoices/export_excel.php b/app/modules_app/invoices/export_excel.php index 1744ab4..e96bc81 100644 --- a/app/modules_app/invoices/export_excel.php +++ b/app/modules_app/invoices/export_excel.php @@ -161,15 +161,20 @@ $summarySheet->setTitle('الملخص الإجمالي'); $summarySheet->setRightToLeft(true); // --- SUMMARY HEADER --- -$summarySheet->mergeCells("A1:J1"); -$summarySheet->setCellValue("A1", 'مُـصَـادَق — ملخص الفواتير الإجمالي'); -$summarySheet->getStyle("A1")->applyFromArray([ +// We use A1 for Logo, B1:I1 for Title, J1 for Link/QR to avoid merge issues in some viewers +$summarySheet->setCellValue("B1", 'مُـصَـادَق — ملخص الفواتير الإجمالي'); +$summarySheet->mergeCells("B1:I1"); +$summarySheet->getStyle("B1:I1")->applyFromArray([ 'font' => ['bold' => true, 'size' => 16, 'color' => ['argb' => 'FF' . $headerFont]], 'fill' => ['fillType' => Fill::FILL_SOLID, 'startColor' => ['argb' => 'FF' . $headerBg]], 'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER], ]); $summarySheet->getRowDimension(1)->setRowHeight(45); +// Style A1 and J1 background to match the header +$summarySheet->getStyle("A1")->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF' . $headerBg); +$summarySheet->getStyle("J1")->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF' . $headerBg); + // --- Add Logo --- try { if (file_exists($logoPath)) { @@ -178,7 +183,7 @@ try { $logoSummary->setPath($logoPath); $logoSummary->setHeight(38); $logoSummary->setCoordinates('A1'); - $logoSummary->setOffsetX(15); + $logoSummary->setOffsetX(5); $logoSummary->setOffsetY(5); $logoSummary->setWorksheet($summarySheet); } @@ -204,8 +209,8 @@ try { $drawingQr->setName('Musadaq QR'); $drawingQr->setPath($tmpQr); $drawingQr->setHeight(38); - $drawingQr->setCoordinates('I1'); - $drawingQr->setOffsetX(40); + $drawingQr->setCoordinates('J1'); + $drawingQr->setOffsetX(5); $drawingQr->setOffsetY(5); $drawingQr->setWorksheet($summarySheet); } @@ -323,15 +328,20 @@ foreach ($invoices as $invIdx => $inv) { $invRow = 1; // ── INVOICE HEADER ────────────────────────── - $sheet->mergeCells("A{$invRow}:I{$invRow}"); - $sheet->setCellValue("A{$invRow}", 'مُـصَـادَق — تقرير فاتورة مشتريات'); - $sheet->getStyle("A{$invRow}")->applyFromArray([ + // We use A for Logo, B:H for Title, I for QR to avoid merge issues + $sheet->setCellValue("B{$invRow}", 'مُـصَـادَق — تقرير فاتورة مشتريات'); + $sheet->mergeCells("B{$invRow}:H{$invRow}"); + $sheet->getStyle("B{$invRow}:H{$invRow}")->applyFromArray([ 'font' => ['bold' => true, 'size' => 16, 'color' => ['argb' => 'FF' . $headerFont]], 'fill' => ['fillType' => Fill::FILL_SOLID, 'startColor' => ['argb' => 'FF' . $headerBg]], 'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER], ]); $sheet->getRowDimension($invRow)->setRowHeight(45); + // Background color for side cells + $sheet->getStyle("A{$invRow}")->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF' . $headerBg); + $sheet->getStyle("I{$invRow}")->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setARGB('FF' . $headerBg); + // --- Add Logo --- try { if (file_exists($logoPath)) { @@ -340,18 +350,19 @@ foreach ($invoices as $invIdx => $inv) { $logoInv->setPath($logoPath); $logoInv->setHeight(38); $logoInv->setCoordinates('A' . $invRow); - $logoInv->setOffsetX(15); + $logoInv->setOffsetX(5); $logoInv->setOffsetY(5); $logoInv->setWorksheet($sheet); } } catch(\Exception $e) { error_log('Logo Invoice Error: ' . $e->getMessage()); } // --- Add Clickable Website Link --- + // We'll move the link slightly down or put it in I1 with the QR $sheet->setCellValue("I" . $invRow, 'musadaq.intaleqapp.com'); $sheet->getCell("I" . $invRow)->getHyperlink()->setUrl('https://musadaq.intaleqapp.com/'); $sheet->getStyle("I" . $invRow)->applyFromArray([ - 'font' => ['color' => ['argb' => 'FFFFFFFF'], 'underline' => true, 'size' => 9], - 'alignment' => ['horizontal' => Alignment::HORIZONTAL_LEFT, 'vertical' => Alignment::VERTICAL_CENTER], + 'font' => ['color' => ['argb' => 'FFFFFFFF'], 'underline' => true, 'size' => 8], + 'alignment' => ['horizontal' => Alignment::HORIZONTAL_LEFT, 'vertical' => Alignment::VERTICAL_TOP], ]); // --- Add Verification QR Code --- @@ -366,8 +377,8 @@ foreach ($invoices as $invIdx => $inv) { $drawingQr->setName('Verification QR'); $drawingQr->setPath($tmpQr); $drawingQr->setHeight(38); - $drawingQr->setCoordinates('H' . $invRow); - $drawingQr->setOffsetX(40); + $drawingQr->setCoordinates('I' . $invRow); + $drawingQr->setOffsetX(5); $drawingQr->setOffsetY(5); $drawingQr->setWorksheet($sheet); }