Merge pull request 'Added pump and motor fg serial number regex pattern in sticker reprint' (#100) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Reviewed-on: #100
This commit was merged in pull request #100.
This commit is contained in:
@@ -976,7 +976,9 @@ class StickerReprint extends Page implements HasForms
|
||||
]);
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData)) {
|
||||
// if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData))
|
||||
// {
|
||||
if (!preg_match('/^[A-Za-z0-9]{6,}\|[1-9][A-Za-z0-9]{7,}(\/[A-Za-z0-9]*)?(\|)?$/', $formQRData)) {
|
||||
if (strpos($formQRData, '|') === false) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1004,7 +1006,14 @@ class StickerReprint extends Page implements HasForms
|
||||
{
|
||||
$splits = explode('|', $formQRData);
|
||||
$iCode = trim($splits[0]);
|
||||
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
$sNumberRaw = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
if ($sNumberRaw !== null) {
|
||||
$sNumber = preg_replace('/\/.*/', '', $sNumberRaw);
|
||||
$sNumber = trim($sNumber);
|
||||
} else {
|
||||
$sNumber = null;
|
||||
}
|
||||
|
||||
if (!ctype_alnum($iCode)) {
|
||||
$this->form->fill([
|
||||
@@ -1052,6 +1061,7 @@ class StickerReprint extends Page implements HasForms
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!ctype_alnum($sNumber)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1145,9 +1155,18 @@ class StickerReprint extends Page implements HasForms
|
||||
// Only search when all parent IDs are selected
|
||||
$parts = explode('|', $formQRData);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serialNumber = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// Remove slash and everything after it
|
||||
if ($serialNumberRaw != null) {
|
||||
$serialNumber = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$serialNumber = trim($serialNumber);
|
||||
} else {
|
||||
$serialNumber = null;
|
||||
}
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
|
||||
if (!$item) {
|
||||
// Handle unknown item code
|
||||
$this->form->fill([
|
||||
@@ -1364,6 +1383,15 @@ class StickerReprint extends Page implements HasForms
|
||||
$itemCode = trim($parts[0]);
|
||||
$this->sNoId = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
if ($this->sNoId != null) {
|
||||
$this->sNoId = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$this->sNoId = trim($this->sNoId);
|
||||
} else {
|
||||
$this->sNoId = null;
|
||||
}
|
||||
|
||||
$this->qrData = preg_replace('/\/.*/', '', $this->qrData);
|
||||
|
||||
ProductionQuantity::create([
|
||||
'plant_id'=> $this->pId,
|
||||
'shift_id'=> $this->sId,
|
||||
@@ -1418,11 +1446,16 @@ class StickerReprint extends Page implements HasForms
|
||||
// Save the form data to the database or perform other operations
|
||||
// For example:
|
||||
$model = ProductionQuantity::create($formValues);
|
||||
// $formValues['serial_number'] = $this->serialNumber;
|
||||
|
||||
// ProductionQuantity::create($formValues);
|
||||
|
||||
// dd('Production Updated Event Dispatched');
|
||||
|
||||
$this->dispatch('productionUpdated');
|
||||
|
||||
|
||||
|
||||
// // Optionally, you can emit an event or perform a redirect after saving
|
||||
// $this->emit('formSaved', $model->id);
|
||||
}
|
||||
|
||||
@@ -20,191 +20,18 @@ class ProductionStickerReprintController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
// public function downloadQrPdf($palletNo)
|
||||
// {
|
||||
|
||||
// $parts = explode('|', $palletNo);
|
||||
// $itemCode = trim($parts[0]);
|
||||
// $serial = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// // Retrieve the item record by item code
|
||||
// $item = Item::where('code', $itemCode)->first();
|
||||
|
||||
// if (!$item) {
|
||||
// abort(404, "Item with code {$itemCode} not found.");
|
||||
// }
|
||||
|
||||
// $itemId = $item->id;
|
||||
|
||||
// $production = ProductionQuantity::where('item_id', $itemId)
|
||||
// ->where('serial_number', $serial)
|
||||
// ->first();
|
||||
|
||||
// if (!$production) {
|
||||
// abort(404, "Production data for item code '{$itemCode}' with serial '{$serial}' not found.");
|
||||
// }
|
||||
|
||||
// $productionOrder = $production->production_order;
|
||||
|
||||
// $qrCode = new QrCode($palletNo);
|
||||
// $output = new Output\Png();
|
||||
// $qrBinary = $output->output($qrCode, 100);
|
||||
// $qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
// $sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// // Decide number of copies
|
||||
// $copies = 1;
|
||||
|
||||
// if ($sticker) {
|
||||
// if ($sticker->serial_number_pump == 1) {
|
||||
// // If pump is selected (regardless of motor), 2 copies
|
||||
// $copies = 2;
|
||||
// } elseif ($sticker->serial_number_motor == 1) {
|
||||
// // Only motor selected, 1 copy
|
||||
// $copies = 1;
|
||||
// }
|
||||
// }
|
||||
// return '
|
||||
// <html>
|
||||
// <head>
|
||||
// <style>
|
||||
// body {
|
||||
// margin: 0;
|
||||
// padding: 0;
|
||||
// width: 100mm;
|
||||
// height: 14mm;
|
||||
// font-size: 10pt;
|
||||
// font-family: Arial Narrow, Arial, sans-serif;
|
||||
// }
|
||||
|
||||
// .sticker-table {
|
||||
// width: 100mm;
|
||||
// height: 14mm;
|
||||
// }
|
||||
|
||||
// .text-cell {
|
||||
// margin: 0;
|
||||
// padding: 0;
|
||||
// text-align: left;
|
||||
// font-size: 14pt;
|
||||
// font-weight: normal;
|
||||
// line-height: 1.2;
|
||||
// }
|
||||
|
||||
// .text-row {
|
||||
// font-weight: bold;
|
||||
// font-size: 9pt;
|
||||
// }
|
||||
|
||||
// .serial {
|
||||
// text-align: left;
|
||||
// }
|
||||
|
||||
// .po-number {
|
||||
// text-align: right;
|
||||
// white-space: nowrap;
|
||||
// }
|
||||
|
||||
// .desc-row {
|
||||
// font-weight: normal;
|
||||
// font-size: 8pt;
|
||||
// }
|
||||
|
||||
// .qr-cell {
|
||||
// width: 14mm;
|
||||
// text-align: left;
|
||||
// padding-left: 0mm;
|
||||
// padding-top: 0mm;
|
||||
// }
|
||||
|
||||
// img.qr {
|
||||
// width: 20mm;
|
||||
// height: 20mm;
|
||||
// }
|
||||
// </style>
|
||||
// </head>
|
||||
// <body>
|
||||
// <div id="print-container"></div>
|
||||
// <script>
|
||||
// const copies = ' . $copies . ';
|
||||
// const htmlBlock = `
|
||||
// <table class="sticker-table">
|
||||
// <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>
|
||||
// `;
|
||||
|
||||
// const container = document.getElementById("print-container");
|
||||
// for (let i = 0; i < copies; i++) {
|
||||
// container.insertAdjacentHTML("beforeend", htmlBlock);
|
||||
// }
|
||||
|
||||
// window.onload = function () {
|
||||
// window.print();
|
||||
// setTimeout(function () {
|
||||
// window.close();
|
||||
// }, 500);
|
||||
// };
|
||||
// </script>
|
||||
// </body>
|
||||
// </html>
|
||||
// ';
|
||||
|
||||
|
||||
// //Get sticker master data
|
||||
// // $sticker = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
// // //Decide number of copies
|
||||
// // $copies = 1; // default
|
||||
// // if ($sticker) {
|
||||
// // if ($sticker->serial_number_motor == 1) {
|
||||
// // $copies = 1;
|
||||
// // } elseif (is_null($sticker->serial_number_motor) && $sticker->serial_number_pump == 1) {
|
||||
// // $copies = 2;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // $mpdf = new Mpdf([
|
||||
// // 'mode' => 'utf-8',
|
||||
// // 'format' => [60, 14],
|
||||
// // 'margin_left' => 0,
|
||||
// // 'margin_right' => 0,
|
||||
// // 'margin_top' => 0,
|
||||
// // 'margin_bottom' => 0,
|
||||
// // ]);
|
||||
|
||||
// // for ($i = 0; $i < $copies; $i++) {
|
||||
// // $mpdf->WriteHTML($html);
|
||||
// // if ($i < $copies - 1) {
|
||||
// // $mpdf->AddPage();
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // $mpdf->Output('qr-label.pdf', 'I');
|
||||
// // exit;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
$parts = explode('|', $palletNo);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serial = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
if ($serialNumberRaw != null) {
|
||||
$serial = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$serial = trim($serial);
|
||||
} else {
|
||||
$serial = null;
|
||||
}
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
$itemId= $item->id;
|
||||
|
||||
Reference in New Issue
Block a user