1
0
forked from poc/pds

modified sticker reprint controller logic

This commit is contained in:
dhanabalan
2025-07-29 11:46:44 +05:30
parent 8c5f2b5b39
commit 48942307e1

View File

@@ -54,97 +54,87 @@ class ProductionStickerReprintController extends Controller
$sticker = StickerMaster::where('item_id', $itemId)->first(); $sticker = StickerMaster::where('item_id', $itemId)->first();
// Decide number of copies // Decide number of copies
$copies = 1; $copies = 1;
if ($sticker) { if ($sticker) {
if ($sticker->serial_number_motor == 1) { if ($sticker->serial_number_pump == 1) {
$copies = 1; // If pump is selected (regardless of motor), 2 copies
} elseif (is_null($sticker->serial_number_motor) && $sticker->serial_number_pump == 1) {
$copies = 2; $copies = 2;
} elseif ($sticker->serial_number_motor == 1) {
// Only motor selected, 1 copy
$copies = 1;
} }
} }
return ' return '
<html> <html>
<head> <head>
<style> <style>
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
width: 60mm; width: 60mm;
height: 14mm; height: 14mm;
font-size: 10pt; font-size: 10pt;
font-family: Arial Narrow, Arial, sans-serif; font-family: Arial Narrow, Arial, sans-serif;
} }
.sticker-table { .sticker-table {
width: 60mm; width: 60mm;
height: 14mm; height: 14mm;
border-collapse: collapse; border-collapse: collapse;
} }
.text-cell { .text-cell {
text-align: left; text-align: left;
vertical-align: middle; vertical-align: middle;
font-size: 10pt; font-size: 10pt;
padding: 2mm 2mm 0 0; padding: 2mm 2mm 0 0;
white-space: normal; white-space: normal;
font-weight: normal; font-weight: normal;
line-height: 0.3; line-height: 0.3;
} }
.text-row { .text-row {
align-items: center; align-items: center;
width: 100%; width: 100%;
font-weight: bold; font-weight: bold;
font-size: 9pt; font-size: 9pt;
} }
.serial { .serial {
text-align: left; text-align: left;
} }
.po-number { .po-number {
text-align: right; text-align: right;
white-space: nowrap; white-space: nowrap;
width: 1%; width: 1%;
} }
.desc-row { .desc-row {
font-weight: normal; font-weight: normal;
font-size: 7pt; font-size: 7pt;
} }
.qr-cell { .qr-cell {
width: 14mm; width: 14mm;
text-align: left; text-align: left;
vertical-align: middle; vertical-align: middle;
padding-left: 1mm; padding-left: 1mm;
padding-top: 0mm; padding-top: 0mm;
} }
img.qr { img.qr {
width: 13mm; width: 13mm;
height: 13mm; height: 13mm;
display: block; display: block;
} }
</style> </style>
</head> </head>
<body> <body>
<table class="sticker-table"> <div id="print-container"></div>
<tr>
<td class="qr-cell">
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
</td>
<td class="text-cell">
<div class="text-row"><pre><span class="serial">' . htmlspecialchars($serial) . '</span> <span class="po-number">' . htmlspecialchars($productionOrder) . '</span></pre>
</div>
<div class="desc-row">
' . htmlspecialchars($item->description) . '
</div>
</td>
</tr>
</table>
<div id="print-container"></div>
<script> <script>
const copies = ' . $copies . '; const copies = ' . $copies . ';
@@ -178,9 +168,10 @@ class ProductionStickerReprintController extends Controller
}, 500); }, 500);
}; };
</script> </script>
</body> </body>
</html> </html>
'; ';
// //Get sticker master data // //Get sticker master data
// $sticker = StickerMaster::where('item_id', $itemId)->first(); // $sticker = StickerMaster::where('item_id', $itemId)->first();