Merge pull request 'chnaged logic in sticker reprint logic' (#106) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #106
This commit was merged in pull request #106.
This commit is contained in:
@@ -1155,12 +1155,27 @@ class StickerReprint extends Page implements HasForms
|
||||
// Only search when all parent IDs are selected
|
||||
$parts = explode('|', $formQRData);
|
||||
$itemCode = trim($parts[0]);
|
||||
|
||||
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// Remove slash and everything after it
|
||||
// // Remove slash and everything after it
|
||||
// if ($serialNumberRaw != null) {
|
||||
// $serialNumber = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
// $serialNumber = trim($serialNumber);
|
||||
// } else {
|
||||
// $serialNumber = null;
|
||||
// }
|
||||
if ($serialNumberRaw != null) {
|
||||
$serialNumber = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
if (strpos($serialNumberRaw, '/') !== false) {
|
||||
$serialNumber = strstr($serialNumberRaw, '/', true); // gets text before slash
|
||||
} else {
|
||||
$serialNumber = $serialNumberRaw; // keep original
|
||||
|
||||
}
|
||||
|
||||
$serialNumber = trim($serialNumber);
|
||||
|
||||
} else {
|
||||
$serialNumber = null;
|
||||
}
|
||||
@@ -1383,6 +1398,33 @@ class StickerReprint extends Page implements HasForms
|
||||
$itemCode = trim($parts[0]);
|
||||
$this->sNoId = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
$originalQR = $this->qrData;
|
||||
|
||||
if (strpos($originalQR, '/') != false)
|
||||
{
|
||||
// Allowed endings
|
||||
$allowed = ['/m', '/M', '/p', '/P'];
|
||||
|
||||
$foundValidEnding = false;
|
||||
|
||||
foreach ($allowed as $end) {
|
||||
if (str_ends_with($originalQR, $end)) {
|
||||
$foundValidEnding = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$foundValidEnding) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Code')
|
||||
->body("Invalid QR format: '$originalQR'")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->sNoId != null) {
|
||||
$this->sNoId = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||
$this->sNoId = trim($this->sNoId);
|
||||
@@ -1390,7 +1432,7 @@ class StickerReprint extends Page implements HasForms
|
||||
$this->sNoId = null;
|
||||
}
|
||||
|
||||
$this->qrData = preg_replace('/\/.*/', '', $this->qrData);
|
||||
//$this->qrData = preg_replace('/\/.*/', '', $this->qrData);
|
||||
|
||||
ProductionQuantity::create([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -1406,7 +1448,6 @@ class StickerReprint extends Page implements HasForms
|
||||
|
||||
// after success insertion
|
||||
$this->form->fill([
|
||||
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
@@ -1429,7 +1470,7 @@ class StickerReprint extends Page implements HasForms
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
$url = route('download-qr1-pdf', ['palletNo' => $this->qrData]);
|
||||
$url = route('download-qr1-pdf', ['palletNo' => urlencode($originalQR)]);
|
||||
$this->js(<<<JS
|
||||
window.dispatchEvent(new CustomEvent('open-pdf', {
|
||||
detail: {
|
||||
|
||||
@@ -22,6 +22,8 @@ class ProductionStickerReprintController extends Controller
|
||||
|
||||
public function downloadQrPdf($palletNo)
|
||||
{
|
||||
$palletNo = urldecode($palletNo);
|
||||
|
||||
$parts = explode('|', $palletNo);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
@@ -50,6 +52,7 @@ class ProductionStickerReprintController extends Controller
|
||||
|
||||
$productionOrder = $production->production_order ?? '';
|
||||
|
||||
if(!preg_match('/\//', $palletNo)){
|
||||
if ($item->category == 'Submersible Motor')
|
||||
{
|
||||
$copies = 1;
|
||||
@@ -58,6 +61,21 @@ class ProductionStickerReprintController extends Controller
|
||||
{
|
||||
$copies = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($item->category == 'Submersible Motor')
|
||||
{
|
||||
$copies = 1;
|
||||
}
|
||||
elseif ($item->category == 'Submersible Pump')
|
||||
{
|
||||
$copies = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$palletNo = preg_replace('/\/.*/', '', $palletNo);
|
||||
|
||||
// 5. Generate QR Code (base64)
|
||||
$qrCode = new QrCode($palletNo);
|
||||
$output = new Output\Png();
|
||||
|
||||
Reference in New Issue
Block a user