Update: 2026-05-15 15:02:14

This commit is contained in:
Hamza-Ayed
2026-05-15 15:02:14 +03:00
parent 54a4acdcab
commit 7ee897ff3d
6 changed files with 277 additions and 45 deletions

View File

@@ -20,6 +20,7 @@ use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
// Enable error reporting for debugging
ini_set('display_errors', '1');
@@ -148,7 +149,25 @@ $summarySheet->getStyle("A1")->applyFromArray([
'fill' => ['fillType' => Fill::FILL_SOLID, 'startColor' => ['argb' => 'FF' . $headerBg]],
'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER],
]);
$summarySheet->getRowDimension(1)->setRowHeight(40);
$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);
// --- Add Clickable Website Link ---
$summarySheet->setCellValue("J1", 'musadaq.intaleqapp.com');
$summarySheet->getCell("J1")->getHyperlink()->setUrl('https://musadaq.intaleqapp.com/');
$summarySheet->getStyle("J1")->applyFromArray([
'font' => ['color' => ['argb' => 'FFFFFFFF'], 'underline' => true, 'size' => 9],
'alignment' => ['horizontal' => Alignment::HORIZONTAL_LEFT, 'vertical' => Alignment::VERTICAL_CENTER],
]);
// Summary Meta Info
$companyNameFilter = 'جميع الشركات';
@@ -269,7 +288,41 @@ foreach ($invoices as $invIdx => $inv) {
'fill' => ['fillType' => Fill::FILL_SOLID, 'startColor' => ['argb' => 'FF' . $headerBg]],
'alignment' => ['horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER],
]);
$sheet->getRowDimension($invRow)->setRowHeight(40);
$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);
// --- Add Clickable Website Link ---
$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],
]);
// --- Add Verification QR Code ---
$verifyUrl = "https://musadaq.intaleqapp.com/index.php?route=v1/verify&id=" . $inv['id'];
$qrApiUrl = "https://api.qrserver.com/v1/create-qr-code/?size=100x100&data=" . urlencode($verifyUrl);
// Download QR to temp file
$tmpQr = tempnam(sys_get_temp_dir(), 'qr_');
file_put_contents($tmpQr, file_get_contents($qrApiUrl));
$drawingQr = new Drawing();
$drawingQr->setName('Verification QR');
$drawingQr->setPath($tmpQr);
$drawingQr->setHeight(70);
$drawingQr->setCoordinates('H' . ($invRow + 2)); // Place below the headers area
$drawingQr->setWorksheet($sheet);
$invRow++;
// Invoice meta data