Added panel box regex pattern in create invoice validation page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Failing after 22s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 19s
Laravel Larastan / larastan (pull_request) Failing after 48s
Laravel Pint / pint (pull_request) Successful in 2m50s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Failing after 22s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 19s
Laravel Larastan / larastan (pull_request) Failing after 48s
Laravel Pint / pint (pull_request) Successful in 2m50s
This commit is contained in:
@@ -4030,7 +4030,136 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
// TN01/BOX22/SERIAL999 >> PANEL BOX QR
|
// TN01/BOX22/SERIAL999 >> PANEL BOX QR
|
||||||
// /^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/
|
// /^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/
|
||||||
if (! preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $serNo, $matches)) {
|
|
||||||
|
if (preg_match('/^(\d+)\/(\d+)\/(\d+)\/(\d+)$/', $serNo, $matches)) {
|
||||||
|
|
||||||
|
$itemCode = $matches[2];
|
||||||
|
$serialNumber = $matches[1] . $matches[3] . $matches[4];
|
||||||
|
|
||||||
|
$supplierNo = $matches[1];
|
||||||
|
$supplierSNo = implode('/', array_slice($matches, 3));
|
||||||
|
$panelBoxCode = $matches[2];
|
||||||
|
|
||||||
|
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
|
if (! $record) {
|
||||||
|
Notification::make()
|
||||||
|
->title('<b><span style="color:red;">Serial Number Not Found<br>Serial \''.$serialNumber.'\' not found in database for choosed plant.</span></b>')
|
||||||
|
// ->body("Serial '$serialNumber' not found in database for choosed plant.")..........
|
||||||
|
->danger()
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('play-warn-sound');
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scanSQuan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$record1 = InvoiceValidation::where('serial_number', $serialNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->whereHas('stickerMasterRelation.item', function ($query) use ($itemCode) {
|
||||||
|
$query->where('plant_id', $this->plantId)->where('code', $itemCode);
|
||||||
|
})
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $record1) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Unknown: Item Code')
|
||||||
|
->body("Item code '$itemCode' with serial number '$serialNumber' not found.")
|
||||||
|
->danger()
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scanSQuan,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoiceUpdate = InvoiceValidation::where('plant_id', $plantId)
|
||||||
|
->where('invoice_number', $invoiceNumber)
|
||||||
|
->where('sticker_master_id', $record1->sticker_master_id)
|
||||||
|
->where('serial_number', $serialNumber)
|
||||||
|
->update([
|
||||||
|
'scanned_status' => 'Scanned',
|
||||||
|
'panel_box_supplier' => $supplierNo,
|
||||||
|
'panel_box_serial_number' => $supplierSNo,
|
||||||
|
'panel_box_code' => $panelBoxCode,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||||
|
|
||||||
|
if($totQuan == $scannedQuantity){
|
||||||
|
Notification::make()
|
||||||
|
->title('Completed: Panel Box Invoice')
|
||||||
|
->body("Panel Box invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Panel Box Invoice' to proceed!")
|
||||||
|
->warning()
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('playNotificationSound');
|
||||||
|
|
||||||
|
$filename = $invoiceNumber.'.xlsx';
|
||||||
|
$directory = "uploads/temp/{$plantCode}";
|
||||||
|
$disk = Storage::disk('local');
|
||||||
|
$filePath = $directory.'/'.$filename;
|
||||||
|
// $fullPath = null;
|
||||||
|
if ($disk->exists($filePath)) {
|
||||||
|
// $fullPath = $disk->path($filePath);
|
||||||
|
$disk->delete($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => null,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => 0,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => 0,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($invoiceUpdate){
|
||||||
|
Notification::make()
|
||||||
|
->title("Panel Box Success")
|
||||||
|
->body("Panel Box Serial '$serialNumber' updated successfully.")
|
||||||
|
->success()
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'invoice_number' => $invoiceNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'total_quantity' => $totQuan,
|
||||||
|
'update_invoice' => false,
|
||||||
|
'scanned_quantity' => $scannedQuantity,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (! preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $serNo, $matches)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Serial QR Format')
|
->title('Invalid Serial QR Format')
|
||||||
|
|||||||
Reference in New Issue
Block a user