From b17f675f73f46ae25d5e4812d4ef4830803d48e7 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 15:59:20 +0530 Subject: [PATCH 01/14] Added line type options for process order report --- app/Filament/Resources/LineResource.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Filament/Resources/LineResource.php b/app/Filament/Resources/LineResource.php index f94fd0c..6705de1 100644 --- a/app/Filament/Resources/LineResource.php +++ b/app/Filament/Resources/LineResource.php @@ -156,6 +156,9 @@ class LineResource extends Resource 'Base FG Line' => 'Base FG Line', 'SFG Line' => 'SFG Line', 'FG Line' => 'FG Line', + 'Process Base FG Line' => 'Process Base FG Line', + 'Process SFG Line' => 'Process SFG Line', + 'Process FG Line' => 'Process FG Line', 'Machining Cell' => 'Machining Cell', 'Blanking Cell' => 'Blanking Cell', 'Forming Cell' => 'Forming Cell', -- 2.49.1 From c738195cd4c38311a2834ea9ee02a420f75f9b91 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:01:57 +0530 Subject: [PATCH 02/14] Commented unused code --- .../InvoiceValidationController.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/Http/Controllers/InvoiceValidationController.php b/app/Http/Controllers/InvoiceValidationController.php index 5f84992..30ab9bd 100644 --- a/app/Http/Controllers/InvoiceValidationController.php +++ b/app/Http/Controllers/InvoiceValidationController.php @@ -808,4 +808,29 @@ class InvoiceValidationController extends Controller { // } + + // public function handle(Request $request) + // { + // $invoice = InvoiceValidation::withCount([ + // 'serialNumbers as scanned_count' => function ($q) { + // $q->where('is_scanned', 1); + // } + // ])->find($request->invoice_id); + + // if (!$invoice) { + // return response()->json(['error' => 'Invoice not found'], 404); + // } + + // if ($invoice->scanned_count < $invoice->total_serials) { + + // Mail::to('alerts@example.com')->send( + // new \App\Mail\IncompleteInvoiceMail( + // $invoice, + // $invoice->scanned_count, + // $invoice->total_serials + // ) + // ); + // } + // return response()->json(['status' => 'ok']); + // } } -- 2.49.1 From 3531bfe250a68ce322f37f23ef4932b6c62e24c4 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:03:28 +0530 Subject: [PATCH 03/14] Updated capacitor qr within page and improve scanning speed --- .../Pages/CreateSerialValidation.php | 391 +++++++++++++++++- 1 file changed, 375 insertions(+), 16 deletions(-) diff --git a/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php b/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php index 312b0af..8a2f3eb 100644 --- a/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php +++ b/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php @@ -15,6 +15,9 @@ use Storage; use Maatwebsite\Excel\Facades\Excel; use Livewire\Livewire; use Str; +use Livewire\Attributes\On; +use App\Services\SmbService; +use Illuminate\Support\Facades\Log; class CreateSerialValidation extends CreateRecord { @@ -61,10 +64,13 @@ class CreateSerialValidation extends CreateRecord return $this->getResource()::getUrl('create'); } + public function processInvoice($invoiceNumber) { $invoiceNumber = trim($invoiceNumber); + $fileName = $invoiceNumber . '.txt'; + $this->showCapacitorInput = false; $user = Filament::auth()->user(); @@ -88,6 +94,187 @@ class CreateSerialValidation extends CreateRecord //..GET SERIAL INVOICE API + $content = SmbService::readTextFile($fileName); + + if ($content == '') { + Notification::make() + ->title('File Not Found') + ->body("Unable to locate file: {$fileName}") + ->danger() + ->send(); + + return; + } + + $lines = preg_split("/\r\n|\n|\r/", trim($content)); + + $insertData = []; + $missingItemCodes = []; + $InvalidLenSno = []; + $InvalidSno = []; + $InvalidLenItem = []; + $InvalidItem = []; + + foreach ($lines as $line) + { + $line = trim($line); + if ($line == '') { + continue; + } + + $parts = array_map('trim', explode(',', $line)); + + if (count($parts) != 2) { + Notification::make() + ->title("Invalid data found inside the file.") + ->danger() + ->seconds(1) + ->send(); + return; + } + + [$itemCode, $serialNumber] = $parts; + + $sticker = StickerMaster::where('plant_id', $plantId) + ->whereHas('item', function ($query) use ($itemCode, $plantId) { + $query->where('plant_id', $plantId) + ->where('code', $itemCode); + }) + ->first(); + + if (Str::length($itemCode) < 6) + { + $InvalidLenItem [] = $itemCode; + continue; + } + else if(!is_numeric($itemCode)){ + $InvalidItem [] = $itemCode; + continue; + } + if (Str::length($serialNumber) < 9) + { + $InvalidLenSno [] = $serialNumber; + continue; + } + else if(!ctype_alnum($serialNumber)){ + $InvalidSno [] = $serialNumber; + continue; + } + + if (!$sticker) { + $missingItemCodes[] = $itemCode; + continue; + } + + $insertData[] = [ + 'plant_id' => $plantId, + 'sticker_master_id' => $sticker->id, + 'invoice_number' => $invoiceNumber, + 'serial_number' => $serialNumber, + 'created_at' => now(), + 'operator_id' => $operatorName, + 'updated_at' => now(), + ]; + } + + if (!empty($InvalidLenItem)) + { + $count = count($InvalidLenItem); + + if ($count <= 10) { + $body = 'Item Code should contain minimum 6 digits: ' . implode(', ', $InvalidLenItem); + } else { + $body = "{$count} item codes contain minimum 6 digits."; + } + Notification::make() + ->title("Invalid Item Code.") + ->body("$body") + ->danger() + ->seconds(1) + ->send(); + return; + } + else if (!empty($InvalidItem)) + { + $count = count($InvalidItem); + + if ($count <= 10) { + $body = 'Item code must be in numeric values: ' . implode(', ', $InvalidSno); + } else { + $body = "{$count} item codes must be in numeric values."; + } + Notification::make() + ->title("Invalid Item Code.") + ->body("$body") + ->danger() + ->seconds(1) + ->send(); + return; + } + else if (!empty($InvalidLenSno)) + { + $count = count($InvalidLenSno); + + if ($count <= 10) { + $body = 'Serial number should be minimum 9 digits: ' . implode(', ', $InvalidLenSno); + } else { + $body = "{$count} serial number should be minimum 9 digits."; + } + Notification::make() + ->title("Invalid Serial Number.") + ->body("$body") + ->danger() + ->seconds(1) + ->send(); + return; + } + else if (!empty($InvalidSno)) + { + $count = count($InvalidSno); + + if ($count <= 10) { + $body = 'Serial number should be conatin alpha numeric values: ' . implode(', ', $InvalidSno); + } else { + $body = "{$count} serial number should be conatin alpha numeric values."; + } + Notification::make() + ->title("Invalid Serial Number.") + ->body("$body") + ->danger() + ->seconds(1) + ->send(); + return; + } + else if (!empty($missingItemCodes)) + { + $count = count($missingItemCodes); + + if ($count <= 10) { + $body = 'Item codes not found in sticker master: ' . implode(', ', $missingItemCodes); + } else { + $body = "{$count} item codes not found in sticker master table."; + } + Notification::make() + ->title("Unknown Item Code.") + ->body("$body") + ->danger() + ->seconds(1) + ->send(); + return; + } + + if (!empty($insertData)) { + SerialValidation::insert($insertData); + } + else{ + Notification::make() + ->title("Insert Failed.") + ->body("Data insertion failed") + ->danger() + ->seconds(1) + ->send(); + return; + } //.. @@ -2311,8 +2498,9 @@ class CreateSerialValidation extends CreateRecord } } - public function processSerialNumber($serNo) + public function processSer($serNo) { + $serNo = trim($serNo); $user = Filament::auth()->user(); $operatorName = $user->name; @@ -2795,24 +2983,28 @@ class CreateSerialValidation extends CreateRecord return; } - $this->dispatch('openCapacitorModal', itemCode: $itemCode, serialNumber: $serialNumber, plantId: $plantId); + // $this->dispatch('openCapacitorModal', itemCode: $itemCode, serialNumber: $serialNumber, plantId: $plantId); + //$this->dispatch('focusCapacitor', invoiceNumber: $invoiceNumber, plantId: $plantId); - $scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); + $this->dispatch('focusCapacitor', itemCode: $itemCode); - $totQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count(); - $scanSQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); - $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') - $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - $this->form->fill([ - 'plant_id' => $plantId, - 'invoice_number' => $invoiceNumber, - 'serial_number' => null, - 'total_quantity' => $totQuan, - 'update_invoice' => false, - 'scanned_quantity'=> $scannedQuantity, - ]); - $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); + //$scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); + + // $totQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count(); + // $scanSQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); + // $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') + // $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); + + // $this->form->fill([ + // 'plant_id' => $plantId, + // 'invoice_number' => $invoiceNumber, + // 'serial_number' => $serNo, + // 'total_quantity' => $totQuan, + // 'update_invoice' => false, + // 'scanned_quantity'=> $scanSQuan, + // ]); + // $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); return; } else if ($isMarkPs) @@ -2958,6 +3150,173 @@ class CreateSerialValidation extends CreateRecord } } + #[On('process-scan')] + public function processSerial($serial) + { + $this->processSer($serial); + } + + public function processCapacitor($serial, $itemCode) + { + $user = Filament::auth()->user(); + $operatorName = $user->name; + + $this->currentItemCode = $itemCode; + + if (!$serial) { + return; + } + + if (!preg_match('/^[^\/]+\/[^\/]+\/.+$/', $serial)) { + Notification::make() + ->title('Invalid Panel Box QR Format:') + ->body('Scan the valid panel box QR code to proceed!') + ->danger() + // ->duration(3000) + ->seconds(2) + ->send(); + return; + } + + $parts = explode('/', $serial); + + $supplier = $parts[0]; + $itemCode = $parts[1]; + $serialNumber = implode('/', array_slice($parts, 2)); // Keep rest of the string + + $existsInStickerMaster = StickerMaster::where('panel_box_code', $itemCode)->where('plant_id', $this->plantId)->whereHas('item', function ($query) { + $query->where('code', $this->currentItemCode); + }) + ->exists(); + + if (!$existsInStickerMaster) { + Notification::make() + ->title('Unknown: Panel Box Code') + ->body("Unknown panel box code: $itemCode found for item code: $this->currentItemCode") + ->danger() + // ->duration(4000) + ->seconds(2) + ->send(); + return; + } + + foreach ($this->invoiceData as &$row) { + if ( + ($row['code'] ?? '') === $this->currentItemCode && + ($row['serial_number'] ?? '') === $this->currentSerialNumber + ) { + $row['panel_box_supplier'] = $supplier; + $row['panel_box_item_code'] = $itemCode; + $row['panel_box_serial_number'] = $serialNumber; + $row['capacitor_scanned_status'] = 1; + // $row['scanned_status_set'] = true; + + $matchingValidation = SerialValidation::with('stickerMaster.item') + ->where('serial_number', $this->currentSerialNumber) + ->where('plant_id', $this->plantId) + ->get() + ->first(function ($validation) { + return $validation->stickerMaster?->item?->code === $this->currentItemCode; + }); + + if ($matchingValidation) { + $hasMotorQr = $matchingValidation->stickerMasterRelation->tube_sticker_motor ?? null; + $hasPumpQr = $matchingValidation->stickerMasterRelation->tube_sticker_pump ?? null; + $hasPumpSetQr = $matchingValidation->stickerMasterRelation->tube_sticker_pumpset ?? null; + // $hasCapacitorQr = $matchingValidation->stickerMasterRelation->panel_box_code ?? null; + + $hadMotorQr = $matchingValidation->motor_scanned_status ?? null; + $hadPumpQr = $matchingValidation->pump_scanned_status ?? null; + $hadPumpSetQr = $matchingValidation->scanned_status_set ?? null; + // $hadCapacitorQr = $matchingValidation->capacitor_scanned_status ?? null; + + $packCnt = 1; + $scanCnt = 1; + // if($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr) + if($hasMotorQr || $hasPumpQr || $hasPumpSetQr) + { + $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; + $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt; + $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt; + + $scanCnt = $hadMotorQr ? $scanCnt + 1: $scanCnt; + $scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt; + $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt; + + if($packCnt === $scanCnt) + { + $matchingValidation->update([ + 'panel_box_supplier' => $supplier, + 'panel_box_item_code' => $itemCode, + 'panel_box_serial_number' => $serialNumber, + 'capacitor_scanned_status' => 1, + 'scanned_status' => 'Scanned', + 'operator_id'=> $operatorName, + ]); + } + else + { + $matchingValidation->update([ + 'panel_box_supplier' => $supplier, + 'panel_box_item_code' => $itemCode, + 'panel_box_serial_number' => $serialNumber, + 'capacitor_scanned_status' => 1, + 'operator_id'=> $operatorName, + ]); + } + } + else + { + $matchingValidation->update([ + 'panel_box_supplier' => $supplier, + 'panel_box_item_code' => $itemCode, + 'panel_box_serial_number' => $serialNumber, + 'capacitor_scanned_status' => 1, + 'scanned_status' => 'Scanned', + 'operator_id'=> $operatorName, + ]); + } + + // Notification::make() + // ->title('Success: Capacitor QR') + // // ->title("Panel box code scanned: $itemCode") + // ->body("'Capacitor' QR scanned status updated, Scan next QR.") + // ->success() // commented + // ->seconds(2) + // ->send(); + + $totalQuantity = SerialValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count(); + $scannedQuantity = SerialValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->where('scanned_status', 'Scanned')->count(); + // $this->form->fill([ + // 'plant_id' => $matchingValidation->plant_id, + // 'invoice_number' => $matchingValidation->invoice_number, + // 'serial_number' => null, + // 'total_quantity' => $totalQuantity, + // 'scanned_quantity'=> $scannedQuantity, + // ]); + + if($totalQuantity === $scannedQuantity) + { + Notification::make() + ->title('Completed: Serial Invoice') + ->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!") + ->success() + ->seconds(2) + ->send(); + $this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id, true); + } + else + { + $this->loadData($matchingValidation->invoice_number, $matchingValidation->plant_id); + } + } + break; + } + } + $this->showCapacitorInput = false; + $this->dispatch('focus-serial-number'); + } + public function getHeading(): string { return 'Scan Serial Validation'; -- 2.49.1 From d74e1d73c9d5d1bd15897a0f48c4448c29e70629 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:05:37 +0530 Subject: [PATCH 04/14] Added reprint process order qr --- app/Http/Controllers/PalletController.php | 165 ++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/app/Http/Controllers/PalletController.php b/app/Http/Controllers/PalletController.php index 3126fb8..3cce913 100644 --- a/app/Http/Controllers/PalletController.php +++ b/app/Http/Controllers/PalletController.php @@ -2,7 +2,10 @@ namespace App\Http\Controllers; +use Filament\Facades\Filament; +use Filament\Notifications\Notification; use Illuminate\Http\Request; + use Mpdf\Mpdf; use Mpdf\QrCode\Output; use Mpdf\QrCode\QrCode; @@ -73,6 +76,168 @@ class PalletController extends Controller // $mpdf->Output('qr-label.pdf', 'I'); } + + public function downloadReprintProcess($plant,$item,$process_order,$coil_number,$name) + { + // dd($plant,$item,$process_order,$coil_number); + + $processOrder = \App\Models\ProcessOrder::where('plant_id', $plant) + ->where('item_id', $item) + ->where('process_order', $process_order) + ->where('coil_number', $coil_number) + ->first(); + + if (!$processOrder) { + return response()->json(['error' => 'Process order not found'], 404); + } + + $receivedQuantity = $processOrder->received_quantity; + $machineName = $processOrder->machine_name; + $user = $processOrder->created_by; + + $icode = \App\Models\Item::find($item); + + $pCode = \App\Models\Plant::find($plant); + + $plCode = $pCode->code; + + if (!$plCode) { + Notification::make() + ->title('Unknown Plant') + ->body('Plant not found.') + ->warning() + ->send(); + } + + if (!$icode) { + Notification::make() + ->title('Unknown Item') + ->body('Item not found.') + ->warning() + ->send(); + } + + $itCode = $icode->code; + + $itemAgaPlant = \App\Models\Item::where('code', $itCode) + ->where('plant_id', $plant) + ->first(); + + + if (!$itemAgaPlant) { + Notification::make() + ->title('Unknown Item') + ->body("Item not found against plant code $plCode.") + ->warning() + ->send(); + } + else + { + $itemDescription = $itemAgaPlant->description; + } + + $nowDT = now()->format('d-m-Y H:i:s'); + + // Build QR content + $qrContent = "{$receivedQuantity}|{$itCode}|{$process_order}-{$coil_number}"; + + $qrCode = new QrCode($qrContent); + $output = new Output\Png(); + $qrBinary = $output->output($qrCode, 100); + $qrBase64 = base64_encode($qrBinary); + + return ' + + + + + + + + + + +
+ D/T: ' . htmlspecialchars($nowDT) . '
+ OP ID: ' . htmlspecialchars($user) . '
+ PO NO: ' . htmlspecialchars($process_order) . '
+ M/C: ' . htmlspecialchars($itCode) . '
+ DES: ' . htmlspecialchars($itemDescription) . '
+ WGT: ' . htmlspecialchars($receivedQuantity) . ' KGS
+ MAC: ' . htmlspecialchars($machineName) . ' +
+ QR +
+ + + + + '; + } + public function downloadQrPdf($palletNo) { $qrCode = new QrCode($palletNo); -- 2.49.1 From eb343f1d0ce84b7de5860c246e4b41664a350b92 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:07:33 +0530 Subject: [PATCH 05/14] Updated alignment for controller --- app/Http/Controllers/MachineController.php | 89 +++++++++------------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/app/Http/Controllers/MachineController.php b/app/Http/Controllers/MachineController.php index a7a2b63..69d0fa9 100644 --- a/app/Http/Controllers/MachineController.php +++ b/app/Http/Controllers/MachineController.php @@ -33,29 +33,28 @@ class MachineController extends Controller public function get_all_data(Request $request) { $expectedUser = env('API_AUTH_USER'); - $expectedPw = env('API_AUTH_PW'); - $header_auth = $request->header('Authorization'); - $expectedToken = $expectedUser . ':' . $expectedPw; + $expectedPw = env('API_AUTH_PW'); + $header_auth = $request->header('Authorization'); + $expectedToken = $expectedUser.':'.$expectedPw; - if ("Bearer " . $expectedToken != $header_auth) - { + if ('Bearer '.$expectedToken != $header_auth) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Invalid authorization token!' + 'status_description' => 'Invalid authorization token!', ], 403); } $machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get(); - $machinesData = $machines->map(function($machine) { + $machinesData = $machines->map(function ($machine) { return [ - 'plant_code' => $machine->plant ? (String)$machine->plant->code : "", - 'group_work_center' => $machine->workGroupMaster ? (String)$machine->workGroupMaster->name : "", - 'work_center' => $machine->work_center ?? "", + 'plant_code' => $machine->plant ? (string) $machine->plant->code : '', + 'group_work_center' => $machine->workGroupMaster ? (string) $machine->workGroupMaster->name : '', + 'work_center' => $machine->work_center ?? '', ]; }); return response()->json([ - 'machines' => $machinesData + 'machines' => $machinesData, ]); } @@ -65,80 +64,70 @@ class MachineController extends Controller public function get_data(Request $request) { $expectedUser = env('API_AUTH_USER'); - $expectedPw = env('API_AUTH_PW'); - $header_auth = $request->header('Authorization'); - $expectedToken = $expectedUser . ':' . $expectedPw; + $expectedPw = env('API_AUTH_PW'); + $header_auth = $request->header('Authorization'); + $expectedToken = $expectedUser.':'.$expectedPw; - if ("Bearer " . $expectedToken != $header_auth) - { + if ('Bearer '.$expectedToken != $header_auth) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Invalid authorization token!' + 'status_description' => 'Invalid authorization token!', ], 403); } $plantCode = $request->header('plant-code'); $lineName = $request->header('line-name'); - if ($plantCode == null || $plantCode == '') - { + if ($plantCode == null || $plantCode == '') { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Plant code can't be empty!" + 'status_description' => "Plant code can't be empty!", ], 400); - } - else if (Str::length($plantCode) < 4 || !is_numeric($plantCode) || !preg_match('/^[1-9]\d{3,}$/', $plantCode)) - { + } elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Invalid plant code found!" + 'status_description' => 'Invalid plant code found!', ], 400); - } - else if ($lineName == null || $lineName == '' || Str::length($lineName) <= 0) - { + } elseif ($lineName == null || $lineName == '' || Str::length($lineName) <= 0) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Line name can't be empty!" + 'status_description' => "Line name can't be empty!", ], 400); } $plant = Plant::where('code', $plantCode)->first(); - if (!$plant) - { + if (! $plant) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Plant Code '{$plantCode}' not found!" + 'status_description' => "Plant Code '{$plantCode}' not found!", ], 400); } $plantId = $plant->id; $line = Line::where('name', $lineName)->first(); - if (!$line) - { + if (! $line) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Line Name '{$lineName}' not found!" + 'status_description' => "Line Name '{$lineName}' not found!", ], 400); } $line = Line::where('name', $lineName)->where('plant_id', $plantId)->first(); - if (!$line) - { + if (! $line) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Line Name '{$lineName}' not found for the plant!" + 'status_description' => "Line Name '{$lineName}' not found for the plant!", ], 400); } - $lineId = $line->id;//no_of_operation + $lineId = $line->id; // no_of_operation $lineWorkGroup1Id = $line->work_group1_id; $lineWorkGroup2Id = $line->work_group2_id; - if ($line->no_of_operation == null || $line->no_of_operation == '' || $line->no_of_operation == 0 || !is_numeric($line->no_of_operation)) - { + if ($line->no_of_operation == null || $line->no_of_operation == '' || $line->no_of_operation == 0 || ! is_numeric($line->no_of_operation)) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Group work center not found for the plant & line!" + 'status_description' => 'Group work center not found for the plant & line!', ], 400); } @@ -146,26 +135,22 @@ class MachineController extends Controller $lineWorkGroupIds = []; for ($i = 1; $i <= $line->no_of_operation; $i++) { $curWorkGroupId = $line->{"work_group{$i}_id"}; - if (in_array($curWorkGroupId, $lineWorkGroupIds)) - { + if (in_array($curWorkGroupId, $lineWorkGroupIds)) { continue; - } - else - { + } else { $lineWorkGroupIds[] = $curWorkGroupId; } $test[] = [ - 'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? "", - 'operation_number' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->operation_number ?? "", - 'work_centers' => Machine::where('plant_id', $plantId)->where('work_group_master_id', $curWorkGroupId)->orderBy('work_center')->pluck('work_center')->toArray() ?? [], + 'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? '', + 'operation_number' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->operation_number ?? '', + 'work_centers' => Machine::where('plant_id', $plantId)->where('work_group_master_id', $curWorkGroupId)->orderBy('work_center')->pluck('work_center')->toArray() ?? [], ]; } - if($lineWorkGroupIds) - { + if ($lineWorkGroupIds) { return response()->json([ - 'machines' => $test + 'machines' => $test, ]); } // $machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get(); -- 2.49.1 From d33b1c7ccbb9000f5496f67b44b0f082c7a58324 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:09:10 +0530 Subject: [PATCH 06/14] Updated alignment for controller --- app/Http/Controllers/UserController.php | 57 +++++++++++-------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 80916a3..371261d 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers; use App\Models\Plant; use App\Models\User; -//use Carbon\Carbon; +// use Carbon\Carbon; use Hash; use Illuminate\Http\Request; @@ -29,72 +29,65 @@ class UserController extends Controller /** * Display the specified resource. */ - //show(string $id) + // show(string $id) public function get_testing_data(Request $request) { $expectedUser = env('API_AUTH_USER'); - $expectedPw = env('API_AUTH_PW'); - $header_auth = $request->header('Authorization'); - $header_user = $request->header('User-Name'); - $header_pass = $request->header('User-Pass'); - $expectedToken = $expectedUser . ':' . $expectedPw; + $expectedPw = env('API_AUTH_PW'); + $header_auth = $request->header('Authorization'); + $header_user = $request->header('User-Name'); + $header_pass = $request->header('User-Pass'); + $expectedToken = $expectedUser.':'.$expectedPw; - if ("Bearer " . $expectedToken != $header_auth) - { + if ('Bearer '.$expectedToken != $header_auth) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Invalid authorization token!' + 'status_description' => 'Invalid authorization token!', ], 403); } - if (!$header_user) - { + if (! $header_user) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Invalid user name found!' + 'status_description' => 'Invalid user name found!', ], 400); - } - else if (!$header_pass) - { + } elseif (! $header_pass) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Invalid password found!' + 'status_description' => 'Invalid password found!', ], 400); } $existUser = User::where('name', $header_user)->first(); - $existPlant = "All Plants"; + $existPlant = 'All Plants'; - if (!$existUser) - { + if (! $existUser) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Unknown user name found!' + 'status_description' => 'Unknown user name found!', ], 400); - } - else { + } else { $codeExist = Plant::where('id', $existUser->plant_id)->first(); if ($codeExist) { $existPlant = $codeExist->code; } } - // Retrieve the user by email - //$user = User::where('email', $email)->first(); + // $user = User::where('email', $email)->first(); if (Hash::check($header_pass, $existUser->password)) { return response()->json([ - 'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? "", - 'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s') ?? "", - 'requested_at' => now()->format('Y-m-d H:i:s') ?? "", //Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s') ?? "", - 'plant' => (String)$existPlant ?? "", - 'email' => $existUser->email ?? "", - 'roles' => $existUser->roles()->pluck('name')->toArray() + 'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? '', + 'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s') ?? '', + 'requested_at' => now()->format('Y-m-d H:i:s') ?? '', // Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s') ?? "", + 'plant' => (string) $existPlant ?? '', + 'email' => $existUser->email ?? '', + 'roles' => $existUser->roles()->pluck('name')->toArray(), ], 200); } else { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Password does not match!' + 'status_description' => 'Password does not match!', ], 400); } -- 2.49.1 From ee9d8247b2ce9c4841496abe2fb669feb4a2760a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:11:19 +0530 Subject: [PATCH 07/14] Added store logic for controller --- app/Http/Controllers/SapFileController.php | 57 +++++++--------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/app/Http/Controllers/SapFileController.php b/app/Http/Controllers/SapFileController.php index 3454292..26014e1 100644 --- a/app/Http/Controllers/SapFileController.php +++ b/app/Http/Controllers/SapFileController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use App\Models\DriverMaster; +use App\Models\VehicleMaster; use Illuminate\Http\Request; use Str; use Illuminate\Support\Facades\Schema; @@ -19,10 +21,21 @@ class SapFileController extends Controller /** * Store a newly created resource in storage. */ - // public function store(Request $request) - // { - // // - // } + public function store(Request $request) + { + $request->validate([ + 'name' => 'required|string', + 'identification1' => 'nullable|string', + 'identification2' => 'nullable|string', + 'identification3' => 'nullable|string', + 'contact_number' => 'nullable|string', + 'alternate_number' => 'nullable|string', + ]); + + DriverMaster::create($request->all()); + + return response()->json(['success' => true]); + } public function getSapData(Request $request) { @@ -145,40 +158,6 @@ class SapFileController extends Controller ], 500); } - // $table = 'class_characteristics'; - // $columns = Schema::getColumnListing($table); // returns lowercase column names - - // $rows = []; - // foreach ($lines as $line) { - // $values = str_getcsv($line); // split by comma - - // $row = []; - // foreach ($columns as $index => $column) { - // $value = $values[$index] ?? null; // if missing, set null - // if ($value === '') $value = null; // empty string -> null - // $row[$column] = $value; - // } - - // $rows[] = $row; - // } - - // return response()->json([ - // 'status' => 'DEBUG_ROWS', - // 'rows_sample' => array_slice($rows, 0, 5), - // ]); - - - // Insert into database - // foreach ($rows as $row) { - // \App\Models\ClassCharacteristic::create($row); - // } - - // return response()->json([ - // 'status' => 'SUCCESS', - // 'rows_imported' => count($rows), - // ]); - - // Prepare arrays // $serialNumbers = []; // $remainingRows = []; @@ -251,7 +230,7 @@ class SapFileController extends Controller if (!empty($invalidSerials)) { return response()->json([ 'status' => 'ERROR', - 'status_description' => 'Some serial numbers are invalid (less than 13 characters)', + 'status_description' => 'serial numbers are invalid (less than 13 characters)', 'invalid_serials' => $invalidSerials ], 400); } -- 2.49.1 From 896e2f5fb216a509381b2d5353c2d0d507b17cc3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:12:10 +0530 Subject: [PATCH 08/14] Commented dd(arg) statement on import --- app/Imports/InvoicePendingReasonImport.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Imports/InvoicePendingReasonImport.php b/app/Imports/InvoicePendingReasonImport.php index 93972b1..76630c8 100644 --- a/app/Imports/InvoicePendingReasonImport.php +++ b/app/Imports/InvoicePendingReasonImport.php @@ -114,6 +114,7 @@ class InvoicePendingReasonImport implements ToCollection continue; } + // dd($row['document_number'], bin2hex($row['document_number'])); $this->validRows[] = [ 'plant_id' => $plantId, -- 2.49.1 From 2d3fda57b7a3a9bc073a1df3dded547a5cf4900d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:14:30 +0530 Subject: [PATCH 09/14] Added characteristic approval function for testing purpose --- app/Jobs/SendApprover1MailJob.php | 51 +++++++++++++++++++++++++++ app/Jobs/SendApprover2MailJob.php | 58 +++++++++++++++++++++++++++++++ app/Jobs/SendApprover3MailJob.php | 56 +++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 app/Jobs/SendApprover1MailJob.php create mode 100644 app/Jobs/SendApprover2MailJob.php create mode 100644 app/Jobs/SendApprover3MailJob.php diff --git a/app/Jobs/SendApprover1MailJob.php b/app/Jobs/SendApprover1MailJob.php new file mode 100644 index 0000000..c42136b --- /dev/null +++ b/app/Jobs/SendApprover1MailJob.php @@ -0,0 +1,51 @@ +request->approver_status1)) return; + + if ($this->request->approver1_mail_sent) return; + + $approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id) + ->where('machine_id', $this->request->machine_id) + ->first(); + + if (! $approver || ! $approver->mail1) return; + + Mail::to($approver->mail1) + ->queue(new CharacteristicApprovalMail( + $this->request, + $approver->name1, + 1 + )); + + $this->request->update(['approver1_mail_sent' => 1]); + + SendApprover2MailJob::dispatch($this->request) + ->delay(now()->addMinutes(5)); + } +} diff --git a/app/Jobs/SendApprover2MailJob.php b/app/Jobs/SendApprover2MailJob.php new file mode 100644 index 0000000..744bdeb --- /dev/null +++ b/app/Jobs/SendApprover2MailJob.php @@ -0,0 +1,58 @@ +request->approver_status1)) return; + + // If approver-2 already approved → STOP + if (!is_null($this->request->approver_status2)) return; + + if ($this->request->approver2_mail_sent) return; + + $approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id) + ->where('machine_id', $this->request->machine_id) + ->first(); + + if (! $approver || ! $approver->mail2) return; + + Mail::to($approver->mail2) + ->queue(new CharacteristicApprovalMail( + $this->request, + $approver->name2, + 2 + )); + + $this->request->update(['approver2_mail_sent' => 1]); + + // Schedule Approver-3 after 5 minutes + SendApprover3MailJob::dispatch($this->request) + ->delay(now()->addMinutes(5)); + } +} diff --git a/app/Jobs/SendApprover3MailJob.php b/app/Jobs/SendApprover3MailJob.php new file mode 100644 index 0000000..9113a85 --- /dev/null +++ b/app/Jobs/SendApprover3MailJob.php @@ -0,0 +1,56 @@ +request->approver_status1) || + !is_null($this->request->approver_status2) || + !is_null($this->request->approver_status3) + ) { + return; + } + + if ($this->request->approver3_mail_sent) return; + + $approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id) + ->where('machine_id', $this->request->machine_id) + ->first(); + + if (! $approver || ! $approver->mail3) return; + + Mail::to($approver->mail3) + ->queue(new CharacteristicApprovalMail( + $this->request, + $approver->name3, + 3 + )); + + $this->request->update(['approver3_mail_sent' => 1]); + } +} -- 2.49.1 From b1cdab2900d017250d0a3f8deb5cd628be202326 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 28 Jan 2026 16:16:11 +0530 Subject: [PATCH 10/14] Updated alignment on controller --- app/Http/Controllers/PalletController.php | 112 ++++++++++------------ 1 file changed, 52 insertions(+), 60 deletions(-) diff --git a/app/Http/Controllers/PalletController.php b/app/Http/Controllers/PalletController.php index 3cce913..ceaffc1 100644 --- a/app/Http/Controllers/PalletController.php +++ b/app/Http/Controllers/PalletController.php @@ -2,10 +2,8 @@ namespace App\Http\Controllers; -use Filament\Facades\Filament; use Filament\Notifications\Notification; use Illuminate\Http\Request; - use Mpdf\Mpdf; use Mpdf\QrCode\Output; use Mpdf\QrCode\QrCode; @@ -23,11 +21,11 @@ class PalletController extends Controller public function downloadReprintQrPdf($palletNo) { $qrCode = new QrCode($palletNo); - $output = new Output\Png(); + $output = new Output\Png; $qrBinary = $output->output($qrCode, 100); $qrBase64 = base64_encode($qrBinary); - return ' + return ' @@ -213,16 +204,16 @@ class PalletController extends Controller
- D/T: ' . htmlspecialchars($nowDT) . '
- OP ID: ' . htmlspecialchars($user) . '
- PO NO: ' . htmlspecialchars($process_order) . '
- M/C: ' . htmlspecialchars($itCode) . '
- DES: ' . htmlspecialchars($itemDescription) . '
- WGT: ' . htmlspecialchars($receivedQuantity) . ' KGS
- MAC: ' . htmlspecialchars($machineName) . ' + D/T: '.htmlspecialchars($nowDT).'
+ OP ID: '.htmlspecialchars($user).'
+ PO NO: '.htmlspecialchars($process_order).'
+ M/C: '.htmlspecialchars($itCode).'
+ DES: '.htmlspecialchars($itemDescription).'
+ WGT: '.htmlspecialchars($receivedQuantity).' KGS
+ MAC: '.htmlspecialchars($machineName).'
- QR + QR
@@ -236,28 +227,29 @@ class PalletController extends Controller '; + } public function downloadQrPdf($palletNo) { $qrCode = new QrCode($palletNo); - $output = new Output\Png(); + $output = new Output\Png; $qrBinary = $output->output($qrCode, 100); $qrBase64 = base64_encode($qrBinary); - $htmlBlock = ' + $htmlBlock = '
- QR + QR - ' . htmlspecialchars($palletNo) . ' + '.htmlspecialchars($palletNo).'
'; - return ' + return ' - ' . $htmlBlock . $htmlBlock . ' + '.$htmlBlock.$htmlBlock.'