From 4eb316cf34500c2ab6bdda99be0611626c4ce10a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sun, 4 Oct 2026 15:26:32 +0530 Subject: [PATCH] Changed logic in sticker pdf service of current date --- app/Services/StickerPdfService.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Services/StickerPdfService.php b/app/Services/StickerPdfService.php index 77f29da7..3642c44e 100644 --- a/app/Services/StickerPdfService.php +++ b/app/Services/StickerPdfService.php @@ -1054,7 +1054,7 @@ class StickerPdfService $plantName = $itemCharacteristic?->plant?->name ?? ''; $plantAddress = $itemCharacteristic?->plant?->address ?? ''; $dateOfTest = $itemCharacteristic?->created_at?->format('d.m.Y') ?? ''; - $currentDate = $itemCharacteristic?->created_at?->format('M-y') ?? ''; + // $currentDate = $itemCharacteristic?->created_at?->format('M-y') ?? ''; foreach ($dynamicElements as $element) { @@ -1116,8 +1116,11 @@ class StickerPdfService if ($row->characteristics_type == 'plant_address') { $textValue = $plantAddress; } + // if ($row->characteristics_type == 'current_date') { + // $textValue = $currentDate; + // } if ($row->characteristics_type == 'current_date') { - $textValue = $currentDate; + $textValue = '__CURRENT_DATE__'; } if ($row->characteristics_type == 'date_of_test') { $textValue = $dateOfTest; @@ -1462,7 +1465,6 @@ class StickerPdfService public function generateBulkFromTemplate(array $template,$fromSerial,$toSerial,string $itemCode) { - Log::info('PDF DEBUG: ENTERED generateBulkFromTemplate'); $stickerWidth = (float) $template['width']; $stickerHeight = (float) $template['height']; $stickerId = $template['sticker_id'] ?? null; @@ -1643,6 +1645,8 @@ class StickerPdfService $pdf->AddPage(); + $serialString = (string) $serial; + $firstSerial = $serial; $secondSerial = $serial + 1; @@ -1664,12 +1668,17 @@ class StickerPdfService $textValue = ''; } } + if (strlen($serialString) >= 4) { + $year = substr($serialString, 0, 2); + $month = substr($serialString, 2, 2); - Log::info('PDF FONT DEBUG', [ - 'font' => $element['font'], - 'size' => $element['size'], - 'text' => $textValue, - ]); + if ((int) $month >= 1 && (int) $month <= 12) { + $textValue = \Carbon\Carbon::createFromFormat( + 'y-m', + $year . '-' . $month + )->format('M-y'); + } + } $pdf->SetFont( $element['font'],