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
|
// Only search when all parent IDs are selected
|
||||||
$parts = explode('|', $formQRData);
|
$parts = explode('|', $formQRData);
|
||||||
$itemCode = trim($parts[0]);
|
$itemCode = trim($parts[0]);
|
||||||
|
|
||||||
|
|
||||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
$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) {
|
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);
|
$serialNumber = trim($serialNumber);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$serialNumber = null;
|
$serialNumber = null;
|
||||||
}
|
}
|
||||||
@@ -1383,6 +1398,33 @@ class StickerReprint extends Page implements HasForms
|
|||||||
$itemCode = trim($parts[0]);
|
$itemCode = trim($parts[0]);
|
||||||
$this->sNoId = isset($parts[1]) ? trim($parts[1]) : null;
|
$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) {
|
if ($this->sNoId != null) {
|
||||||
$this->sNoId = preg_replace('/\/.*/', '', $serialNumberRaw);
|
$this->sNoId = preg_replace('/\/.*/', '', $serialNumberRaw);
|
||||||
$this->sNoId = trim($this->sNoId);
|
$this->sNoId = trim($this->sNoId);
|
||||||
@@ -1390,7 +1432,7 @@ class StickerReprint extends Page implements HasForms
|
|||||||
$this->sNoId = null;
|
$this->sNoId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->qrData = preg_replace('/\/.*/', '', $this->qrData);
|
//$this->qrData = preg_replace('/\/.*/', '', $this->qrData);
|
||||||
|
|
||||||
ProductionQuantity::create([
|
ProductionQuantity::create([
|
||||||
'plant_id'=> $this->pId,
|
'plant_id'=> $this->pId,
|
||||||
@@ -1406,7 +1448,6 @@ class StickerReprint extends Page implements HasForms
|
|||||||
|
|
||||||
// after success insertion
|
// after success insertion
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
|
|
||||||
'plant_id'=> $this->pId,
|
'plant_id'=> $this->pId,
|
||||||
'block_name'=> $this->bId,
|
'block_name'=> $this->bId,
|
||||||
'shift_id'=> $this->sId,
|
'shift_id'=> $this->sId,
|
||||||
@@ -1429,7 +1470,7 @@ class StickerReprint extends Page implements HasForms
|
|||||||
->duration(1000)
|
->duration(1000)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
$url = route('download-qr1-pdf', ['palletNo' => $this->qrData]);
|
$url = route('download-qr1-pdf', ['palletNo' => urlencode($originalQR)]);
|
||||||
$this->js(<<<JS
|
$this->js(<<<JS
|
||||||
window.dispatchEvent(new CustomEvent('open-pdf', {
|
window.dispatchEvent(new CustomEvent('open-pdf', {
|
||||||
detail: {
|
detail: {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class ProductionStickerReprintController extends Controller
|
|||||||
|
|
||||||
public function downloadQrPdf($palletNo)
|
public function downloadQrPdf($palletNo)
|
||||||
{
|
{
|
||||||
|
$palletNo = urldecode($palletNo);
|
||||||
|
|
||||||
$parts = explode('|', $palletNo);
|
$parts = explode('|', $palletNo);
|
||||||
$itemCode = trim($parts[0]);
|
$itemCode = trim($parts[0]);
|
||||||
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
||||||
@@ -50,14 +52,30 @@ class ProductionStickerReprintController extends Controller
|
|||||||
|
|
||||||
$productionOrder = $production->production_order ?? '';
|
$productionOrder = $production->production_order ?? '';
|
||||||
|
|
||||||
if ($item->category == 'Submersible Motor')
|
if(!preg_match('/\//', $palletNo)){
|
||||||
{
|
if ($item->category == 'Submersible Motor')
|
||||||
$copies = 1;
|
{
|
||||||
|
$copies = 1;
|
||||||
|
}
|
||||||
|
elseif ($item->category == 'Submersible Pump')
|
||||||
|
{
|
||||||
|
$copies = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($item->category == 'Submersible Pump')
|
else
|
||||||
{
|
{
|
||||||
$copies = 2;
|
if ($item->category == 'Submersible Motor')
|
||||||
|
{
|
||||||
|
$copies = 1;
|
||||||
|
}
|
||||||
|
elseif ($item->category == 'Submersible Pump')
|
||||||
|
{
|
||||||
|
$copies = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$palletNo = preg_replace('/\/.*/', '', $palletNo);
|
||||||
|
|
||||||
// 5. Generate QR Code (base64)
|
// 5. Generate QR Code (base64)
|
||||||
$qrCode = new QrCode($palletNo);
|
$qrCode = new QrCode($palletNo);
|
||||||
$output = new Output\Png();
|
$output = new Output\Png();
|
||||||
|
|||||||
Reference in New Issue
Block a user