From b61e4dac5b28ae7e3c28fba0ef76548b45ad55ce Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 25 Sep 2026 12:31:08 +0530 Subject: [PATCH] Added rules and font path in sticker pdf service --- app/Services/StickerPdfService.php | 75 ++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/app/Services/StickerPdfService.php b/app/Services/StickerPdfService.php index 2fb2a12..5e0c207 100644 --- a/app/Services/StickerPdfService.php +++ b/app/Services/StickerPdfService.php @@ -1108,23 +1108,88 @@ class StickerPdfService if ($row->characteristics_type == 'serial_number') { $textValue = '__SERIAL_NUMBER__'; } - if ($row->characteristics_type === 'plant_name') { + if ($row->characteristics_type == 'plant_name') { $textValue = $plantName; } - if ($row->characteristics_type === 'plant_address') { + if ($row->characteristics_type == 'plant_address') { $textValue = $plantAddress; } - if ($row->characteristics_type === 'current_date') { + if ($row->characteristics_type == 'current_date') { $textValue = date('M-y'); } - if ($row->characteristics_type === 'date_of_test') { + if ($row->characteristics_type == 'date_of_test') { $textValue = $dateOfTest; } - $font = $row->string_font ?? 'helvetica'; + // if ($row->characteristics_type == 'zmm_grwt_pump_dual') { + // $column = 'zmm_grwt_pump'; + // $textValue = $itemCharacteristic?->{$column} != null + // ? (float) $itemCharacteristic->{$column} * 2 + // : ''; + // } + // if ($row->characteristics_type == 'zmm_newt_pump_dual') { + // $column = 'zmm_newt_pump'; + // $textValue = $itemCharacteristic?->{$column} != null + // ? (float) $itemCharacteristic->{$column} * 2 + // : ''; + // } + if ($row->characteristics_type == 'zmm_grwt_pump_dual') { + $column = 'zmm_grwt_pump'; + + $textValue = $itemCharacteristic?->{$column} != null + ? number_format((float) $itemCharacteristic->{$column} * 2, 3, '.', '') + : ''; + } + + if ($row->characteristics_type == 'zmm_newt_pump_dual') { + $column = 'zmm_newt_pump'; + + $textValue = $itemCharacteristic?->{$column} != null + ? number_format((float) $itemCharacteristic->{$column} * 2, 3, '.', '') + : ''; + } + // if ($row->characteristics_type == 'mrp_dual') { + // $column = 'zmm_mrp'; + // $textValue = $itemCharacteristic?->{$column} != null + // ? (float) $itemCharacteristic->{$column} * 2 + // : ''; + // } + if ($row->characteristics_type == 'mrp_dual') { + $column = 'zmm_mrp'; + + $textValue = $itemCharacteristic?->{$column} != null + ? number_format((float) $itemCharacteristic->{$column} * 2, 2, '.', '') + : ''; + } + if (str_contains($row->string_value ?? '', '₹')) { $font = 'dejavusans'; } + // else{ + // $font = $row->string_font ?? 'helvetica'; + // } + else { + // $font = !empty($row->string_font) + // ? $row->string_font + // : 'helvetica'; + + if (!empty($row->string_font)) { + $fontFile = storage_path('app/private/fonts/' . $row->string_font . '.ttf'); + + if (file_exists($fontFile)) { + $font = TCPDF_FONTS::addTTFfont( + $fontFile, + 'TrueTypeUnicode', + '', + 32 + ); + } else { + $font = 'helvetica'; + } + } else { + $font = 'helvetica'; + } + } $templateElements[] = [