Changed logic in sticker pdf service of current date #1163

Merged
jothi merged 1 commits from ranjith-dev into master 2026-10-04 09:56:43 +00:00

View File

@@ -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'],