Merge pull request 'ranjith-dev' (#268) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

Reviewed-on: #268
This commit was merged in pull request #268.
This commit is contained in:
2026-01-28 11:38:45 +00:00
15 changed files with 938 additions and 272 deletions

View File

@@ -39,7 +39,7 @@ class Scheduler extends Command
public function handle() public function handle()
{ {
// $this->call('approval:trigger-mails'); $this->call('approval:trigger-mails');
// --- Production Rules --- // --- Production Rules ---
$productionRules = AlertMailRule::where('module', 'ProductionQuantities') $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
@@ -112,6 +112,7 @@ class Scheduler extends Command
break; break;
} }
} }
// foreach ($invoiceRules as $rule) { // foreach ($invoiceRules as $rule) {
// switch ($rule->schedule_type) { // switch ($rule->schedule_type) {

View File

@@ -156,6 +156,9 @@ class LineResource extends Resource
'Base FG Line' => 'Base FG Line', 'Base FG Line' => 'Base FG Line',
'SFG Line' => 'SFG Line', 'SFG Line' => 'SFG Line',
'FG Line' => 'FG 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', 'Machining Cell' => 'Machining Cell',
'Blanking Cell' => 'Blanking Cell', 'Blanking Cell' => 'Blanking Cell',
'Forming Cell' => 'Forming Cell', 'Forming Cell' => 'Forming Cell',

View File

@@ -15,6 +15,9 @@ use Storage;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Livewire\Livewire; use Livewire\Livewire;
use Str; use Str;
use Livewire\Attributes\On;
use App\Services\SmbService;
use Illuminate\Support\Facades\Log;
class CreateSerialValidation extends CreateRecord class CreateSerialValidation extends CreateRecord
{ {
@@ -61,10 +64,13 @@ class CreateSerialValidation extends CreateRecord
return $this->getResource()::getUrl('create'); return $this->getResource()::getUrl('create');
} }
public function processInvoice($invoiceNumber) public function processInvoice($invoiceNumber)
{ {
$invoiceNumber = trim($invoiceNumber); $invoiceNumber = trim($invoiceNumber);
$fileName = $invoiceNumber . '.txt';
$this->showCapacitorInput = false; $this->showCapacitorInput = false;
$user = Filament::auth()->user(); $user = Filament::auth()->user();
@@ -88,6 +94,187 @@ class CreateSerialValidation extends CreateRecord
//..GET SERIAL INVOICE API //..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); $serNo = trim($serNo);
$user = Filament::auth()->user(); $user = Filament::auth()->user();
$operatorName = $user->name; $operatorName = $user->name;
@@ -2795,24 +2983,28 @@ class CreateSerialValidation extends CreateRecord
return; 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([ //$scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber, // $totQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
'serial_number' => null, // $scanSQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
'total_quantity' => $totQuan, // $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '')
'update_invoice' => false, // $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
'scanned_quantity'=> $scannedQuantity,
]); // $this->form->fill([
$this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); // '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; return;
} }
else if ($isMarkPs) 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.<br>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 public function getHeading(): string
{ {
return 'Scan Serial Validation'; return 'Scan Serial Validation';

View File

@@ -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']);
// }
} }

View File

@@ -33,29 +33,28 @@ class MachineController extends Controller
public function get_all_data(Request $request) public function get_all_data(Request $request)
{ {
$expectedUser = env('API_AUTH_USER'); $expectedUser = env('API_AUTH_USER');
$expectedPw = env('API_AUTH_PW'); $expectedPw = env('API_AUTH_PW');
$header_auth = $request->header('Authorization'); $header_auth = $request->header('Authorization');
$expectedToken = $expectedUser . ':' . $expectedPw; $expectedToken = $expectedUser.':'.$expectedPw;
if ("Bearer " . $expectedToken != $header_auth) if ('Bearer '.$expectedToken != $header_auth) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token!' 'status_description' => 'Invalid authorization token!',
], 403); ], 403);
} }
$machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get(); $machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();
$machinesData = $machines->map(function($machine) { $machinesData = $machines->map(function ($machine) {
return [ return [
'plant_code' => $machine->plant ? (String)$machine->plant->code : "", 'plant_code' => $machine->plant ? (string) $machine->plant->code : '',
'group_work_center' => $machine->workGroupMaster ? (String)$machine->workGroupMaster->name : "", 'group_work_center' => $machine->workGroupMaster ? (string) $machine->workGroupMaster->name : '',
'work_center' => $machine->work_center ?? "", 'work_center' => $machine->work_center ?? '',
]; ];
}); });
return response()->json([ return response()->json([
'machines' => $machinesData 'machines' => $machinesData,
]); ]);
} }
@@ -65,80 +64,70 @@ class MachineController extends Controller
public function get_data(Request $request) public function get_data(Request $request)
{ {
$expectedUser = env('API_AUTH_USER'); $expectedUser = env('API_AUTH_USER');
$expectedPw = env('API_AUTH_PW'); $expectedPw = env('API_AUTH_PW');
$header_auth = $request->header('Authorization'); $header_auth = $request->header('Authorization');
$expectedToken = $expectedUser . ':' . $expectedPw; $expectedToken = $expectedUser.':'.$expectedPw;
if ("Bearer " . $expectedToken != $header_auth) if ('Bearer '.$expectedToken != $header_auth) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token!' 'status_description' => 'Invalid authorization token!',
], 403); ], 403);
} }
$plantCode = $request->header('plant-code'); $plantCode = $request->header('plant-code');
$lineName = $request->header('line-name'); $lineName = $request->header('line-name');
if ($plantCode == null || $plantCode == '') if ($plantCode == null || $plantCode == '') {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Plant code can't be empty!" 'status_description' => "Plant code can't be empty!",
], 400); ], 400);
} } elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
else if (Str::length($plantCode) < 4 || !is_numeric($plantCode) || !preg_match('/^[1-9]\d{3,}$/', $plantCode))
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Invalid plant code found!" 'status_description' => 'Invalid plant code found!',
], 400); ], 400);
} } elseif ($lineName == null || $lineName == '' || Str::length($lineName) <= 0) {
else if ($lineName == null || $lineName == '' || Str::length($lineName) <= 0)
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Line name can't be empty!" 'status_description' => "Line name can't be empty!",
], 400); ], 400);
} }
$plant = Plant::where('code', $plantCode)->first(); $plant = Plant::where('code', $plantCode)->first();
if (!$plant) if (! $plant) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Plant Code '{$plantCode}' not found!" 'status_description' => "Plant Code '{$plantCode}' not found!",
], 400); ], 400);
} }
$plantId = $plant->id; $plantId = $plant->id;
$line = Line::where('name', $lineName)->first(); $line = Line::where('name', $lineName)->first();
if (!$line) if (! $line) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Line Name '{$lineName}' not found!" 'status_description' => "Line Name '{$lineName}' not found!",
], 400); ], 400);
} }
$line = Line::where('name', $lineName)->where('plant_id', $plantId)->first(); $line = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
if (!$line) if (! $line) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "Line Name '{$lineName}' not found for the plant!" 'status_description' => "Line Name '{$lineName}' not found for the plant!",
], 400); ], 400);
} }
$lineId = $line->id;//no_of_operation $lineId = $line->id; // no_of_operation
$lineWorkGroup1Id = $line->work_group1_id; $lineWorkGroup1Id = $line->work_group1_id;
$lineWorkGroup2Id = $line->work_group2_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([ return response()->json([
'status_code' => 'ERROR', '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); ], 400);
} }
@@ -146,26 +135,22 @@ class MachineController extends Controller
$lineWorkGroupIds = []; $lineWorkGroupIds = [];
for ($i = 1; $i <= $line->no_of_operation; $i++) { for ($i = 1; $i <= $line->no_of_operation; $i++) {
$curWorkGroupId = $line->{"work_group{$i}_id"}; $curWorkGroupId = $line->{"work_group{$i}_id"};
if (in_array($curWorkGroupId, $lineWorkGroupIds)) if (in_array($curWorkGroupId, $lineWorkGroupIds)) {
{
continue; continue;
} } else {
else
{
$lineWorkGroupIds[] = $curWorkGroupId; $lineWorkGroupIds[] = $curWorkGroupId;
} }
$test[] = [ $test[] = [
'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? "", 'group_work_center' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->name ?? '',
'operation_number' => WorkGroupMaster::where('id', $curWorkGroupId)->first()->operation_number ?? "", '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() ?? [], '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([ return response()->json([
'machines' => $test 'machines' => $test,
]); ]);
} }
// $machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get(); // $machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Filament\Notifications\Notification;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Mpdf\Mpdf; use Mpdf\Mpdf;
use Mpdf\QrCode\Output; use Mpdf\QrCode\Output;
@@ -20,11 +21,11 @@ class PalletController extends Controller
public function downloadReprintQrPdf($palletNo) public function downloadReprintQrPdf($palletNo)
{ {
$qrCode = new QrCode($palletNo); $qrCode = new QrCode($palletNo);
$output = new Output\Png(); $output = new Output\Png;
$qrBinary = $output->output($qrCode, 100); $qrBinary = $output->output($qrCode, 100);
$qrBase64 = base64_encode($qrBinary); $qrBase64 = base64_encode($qrBinary);
return ' return '
<html> <html>
<head> <head>
<style> <style>
@@ -39,10 +40,10 @@ class PalletController extends Controller
<table class="sticker-table"> <table class="sticker-table">
<tr> <tr>
<td class="qr-cell"> <td class="qr-cell">
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" /> <img class="qr" src="data:image/png;base64,'.$qrBase64.'" alt="QR" />
</td> </td>
<td class="text-cell"> <td class="text-cell">
' . htmlspecialchars($palletNo) . ' '.htmlspecialchars($palletNo).'
</td> </td>
</tr> </tr>
</table> </table>
@@ -73,26 +74,182 @@ class PalletController extends Controller
// $mpdf->Output('qr-label.pdf', 'I'); // $mpdf->Output('qr-label.pdf', 'I');
} }
public function downloadQrPdf($palletNo) public function downloadReprintProcess($plant, $item, $process_order, $coil_number, $name)
{ {
$qrCode = new QrCode($palletNo); // dd($plant,$item,$process_order,$coil_number);
$output = new Output\Png();
$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); $qrBinary = $output->output($qrCode, 100);
$qrBase64 = base64_encode($qrBinary); $qrBase64 = base64_encode($qrBinary);
$htmlBlock = ' return '
<html>
<head>
<style>
@page {
size: 60mm 30mm;
margin: 0;
}
body {
margin: 0;
padding: 0;
width: 60mm;
font-size: 9pt;
font-family: "DejaVu Sans Condensed", "FreeSans", sans-serif;
}
.sticker-table {
width: 60mm;
border-collapse: collapse;
page-break-inside: avoid;
}
.text-cell {
text-align: left;
vertical-align: top;
font-size: 9pt;
padding-left: 2mm;
padding-top: 2mm; /* was 6mm ❌ */
font-weight: bold;
line-height: 1.1; /* IMPORTANT */
white-space: nowrap;
width: 40mm;
}
.qr-cell {
width: 20mm;
text-align: center;
vertical-align: middle;
}
.lbl {
display: inline-block;
width: 11mm;
font-weight: bold;
}
.text-cell b {
font-size: 10pt; /* was 12pt ❌ */
font-weight: bold;
}
img.qr {
width: 12mm;
height: 12mm;
display: block;
margin: auto;
}
</style>
</head>
<body>
<table class="sticker-table">
<tr>
<td class="text-cell">
<span class="lbl">D/T</span>: '.htmlspecialchars($nowDT).'<br>
<span class="lbl">OP ID</span>: '.htmlspecialchars($user).'<br>
<span class="lbl">PO NO</span>: '.htmlspecialchars($process_order).'<br>
<span class="lbl">M/C</span>: '.htmlspecialchars($itCode).'<br>
<span class="lbl">DES</span>: '.htmlspecialchars($itemDescription).'<br>
<span class="lbl">WGT</span>: <b>'.htmlspecialchars($receivedQuantity).' KGS</b><br>
<span class="lbl">MAC</span>: '.htmlspecialchars($machineName).'
</td>
<td class="qr-cell">
<img class="qr" src="data:image/png;base64,'.$qrBase64.'" alt="QR" />
</td>
</tr>
</table>
<script>
window.onload = function () {
window.print();
setTimeout(function () { window.close(); }, 500);
};
</script>
</body>
</html>
';
}
public function downloadQrPdf($palletNo)
{
$qrCode = new QrCode($palletNo);
$output = new Output\Png;
$qrBinary = $output->output($qrCode, 100);
$qrBase64 = base64_encode($qrBinary);
$htmlBlock = '
<table class="sticker-table"> <table class="sticker-table">
<tr> <tr>
<td class="qr-cell"> <td class="qr-cell">
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" /> <img class="qr" src="data:image/png;base64,'.$qrBase64.'" alt="QR" />
</td> </td>
<td class="text-cell"> <td class="text-cell">
' . htmlspecialchars($palletNo) . ' '.htmlspecialchars($palletNo).'
</td> </td>
</tr> </tr>
</table>'; </table>';
return ' return '
<html> <html>
<head> <head>
<style> <style>
@@ -104,7 +261,7 @@ class PalletController extends Controller
</style> </style>
</head> </head>
<body> <body>
' . $htmlBlock . $htmlBlock . ' '.$htmlBlock.$htmlBlock.'
<script> <script>
window.onload = function () { window.onload = function () {
window.print(); window.print();

View File

@@ -2,6 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\DriverMaster;
use App\Models\VehicleMaster;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Str; use Str;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -19,10 +21,21 @@ class SapFileController extends Controller
/** /**
* Store a newly created resource in storage. * 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) public function getSapData(Request $request)
{ {
@@ -145,40 +158,6 @@ class SapFileController extends Controller
], 500); ], 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 // Prepare arrays
// $serialNumbers = []; // $serialNumbers = [];
// $remainingRows = []; // $remainingRows = [];
@@ -251,7 +230,7 @@ class SapFileController extends Controller
if (!empty($invalidSerials)) { if (!empty($invalidSerials)) {
return response()->json([ return response()->json([
'status' => 'ERROR', '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 'invalid_serials' => $invalidSerials
], 400); ], 400);
} }

View File

@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Plant; use App\Models\Plant;
use App\Models\User; use App\Models\User;
//use Carbon\Carbon; // use Carbon\Carbon;
use Hash; use Hash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -29,72 +29,65 @@ class UserController extends Controller
/** /**
* Display the specified resource. * Display the specified resource.
*/ */
//show(string $id) // show(string $id)
public function get_testing_data(Request $request) public function get_testing_data(Request $request)
{ {
$expectedUser = env('API_AUTH_USER'); $expectedUser = env('API_AUTH_USER');
$expectedPw = env('API_AUTH_PW'); $expectedPw = env('API_AUTH_PW');
$header_auth = $request->header('Authorization'); $header_auth = $request->header('Authorization');
$header_user = $request->header('User-Name'); $header_user = $request->header('User-Name');
$header_pass = $request->header('User-Pass'); $header_pass = $request->header('User-Pass');
$expectedToken = $expectedUser . ':' . $expectedPw; $expectedToken = $expectedUser.':'.$expectedPw;
if ("Bearer " . $expectedToken != $header_auth) if ('Bearer '.$expectedToken != $header_auth) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token!' 'status_description' => 'Invalid authorization token!',
], 403); ], 403);
} }
if (!$header_user) if (! $header_user) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'Invalid user name found!' 'status_description' => 'Invalid user name found!',
], 400); ], 400);
} } elseif (! $header_pass) {
else if (!$header_pass)
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'Invalid password found!' 'status_description' => 'Invalid password found!',
], 400); ], 400);
} }
$existUser = User::where('name', $header_user)->first(); $existUser = User::where('name', $header_user)->first();
$existPlant = "All Plants"; $existPlant = 'All Plants';
if (!$existUser) if (! $existUser) {
{
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'Unknown user name found!' 'status_description' => 'Unknown user name found!',
], 400); ], 400);
} } else {
else {
$codeExist = Plant::where('id', $existUser->plant_id)->first(); $codeExist = Plant::where('id', $existUser->plant_id)->first();
if ($codeExist) { if ($codeExist) {
$existPlant = $codeExist->code; $existPlant = $codeExist->code;
} }
} }
// Retrieve the user by email // Retrieve the user by email
//$user = User::where('email', $email)->first(); // $user = User::where('email', $email)->first();
if (Hash::check($header_pass, $existUser->password)) { if (Hash::check($header_pass, $existUser->password)) {
return response()->json([ return response()->json([
'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? "", 'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? '',
'updated_at' => $existUser->updated_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') ?? "", '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 ?? "", 'plant' => (string) $existPlant ?? '',
'email' => $existUser->email ?? "", 'email' => $existUser->email ?? '',
'roles' => $existUser->roles()->pluck('name')->toArray() 'roles' => $existUser->roles()->pluck('name')->toArray(),
], 200); ], 200);
} else { } else {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'Password does not match!' 'status_description' => 'Password does not match!',
], 400); ], 400);
} }

View File

@@ -114,6 +114,7 @@ class InvoicePendingReasonImport implements ToCollection
continue; continue;
} }
// dd($row['document_number'], bin2hex($row['document_number']));
$this->validRows[] = [ $this->validRows[] = [
'plant_id' => $plantId, 'plant_id' => $plantId,

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Jobs;
use App\Mail\CharacteristicApprovalMail;
use App\Models\CharacteristicApproverMaster;
use App\Models\RequestCharacteristic;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Mail;
class SendApprover1MailJob implements ShouldQueue
{
use Queueable;
/**
* Create a new job instance.
*/
public function __construct(public RequestCharacteristic $request) {
}
/**
* Execute the job.
*/
public function handle()
{
// Already approved? stop
if (!is_null($this->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));
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Jobs;
use App\Mail\CharacteristicApprovalMail;
use App\Models\CharacteristicApproverMaster;
use App\Models\RequestCharacteristic;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Mail;
class SendApprover2MailJob implements ShouldQueue
{
use Queueable;
/**
* Create a new job instance.
*/
// public function __construct()
// {
// //
// }
/**
* Execute the job.
*/
public function __construct(public RequestCharacteristic $request) {}
public function handle()
{
// If approver-1 approved → STOP
if (!is_null($this->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));
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Jobs;
use App\Mail\CharacteristicApprovalMail;
use App\Models\CharacteristicApproverMaster;
use App\Models\RequestCharacteristic;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Mail;
class SendApprover3MailJob implements ShouldQueue
{
use Queueable;
/**
* Create a new job instance.
*/
// public function __construct()
// {
// //
// }
/**
* Execute the job.
*/
public function __construct(public RequestCharacteristic $request) {}
public function handle()
{
if (
!is_null($this->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]);
}
}

View File

@@ -13,23 +13,41 @@ class GuardPatrolEntryDataTable extends Component
// public $date; // public $date;
public $newNameFound; public $newNameFound;
public $guardName; public $guardName;
public $checkPointName; public $checkPointName;
public $startTime; public $startTime;
public $endTime; public $endTime;
public $start; public $start;
public $finish; public $finish;
public $begin; public $begin;
public $end; public $end;
public $labTime; public $labTime;
public $minDiff; public $minDiff;
public $seqNoCnt = 0; public $seqNoCnt = 0;
public $seqNo = 0; public $seqNo = 0;
public $isSequenced = true; public $isSequenced = true;
public $sequences = []; public $sequences = [];
public $seqTime; public $seqTime;
public $seqTimes = []; public $seqTimes = [];
public $startSeqCheckPoints = []; public $startSeqCheckPoints = [];
public $records = []; public $records = [];
protected $listeners = [ protected $listeners = [
@@ -61,9 +79,9 @@ class GuardPatrolEntryDataTable extends Component
$this->seqTimes = []; $this->seqTimes = [];
$this->startSeqCheckPoints = []; $this->startSeqCheckPoints = [];
if (!$plantId || !$date) if (! $plantId || ! $date) {
{
$this->records = []; $this->records = [];
return; return;
} }
@@ -73,20 +91,19 @@ class GuardPatrolEntryDataTable extends Component
$this->startSeqCheckPoints[$i] = CheckPointTime::with('checkPointNames1')->with('checkPointNames2')->where('sequence_number', $i)->where('plant_id', $plantId)->first(); $this->startSeqCheckPoints[$i] = CheckPointTime::with('checkPointNames1')->with('checkPointNames2')->where('sequence_number', $i)->where('plant_id', $plantId)->first();
} }
$this->sequences = array_fill(1, $this->seqNoCnt, "X"); $this->sequences = array_fill(1, $this->seqNoCnt, 'X');
$this->seqTimes = array_fill(1, $this->seqNoCnt, null); $this->seqTimes = array_fill(1, $this->seqNoCnt, null);
$hasSingleGuard = GuardPatrolEntry::whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get(); $hasSingleGuard = GuardPatrolEntry::whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get();
$checking = 0; $checking = 0;
$records = GuardPatrolEntry::with('guardNames')->with('checkPointNames')->whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get(); //desc Carbon::parse($record->patrol_time)->toTimeString() $records = GuardPatrolEntry::with('guardNames')->with('checkPointNames')->whereDate('patrol_time', $date)->where('plant_id', $plantId)->orderBy('patrol_time', 'asc')->get(); // desc Carbon::parse($record->patrol_time)->toTimeString()
foreach ($records as $index => $record) { //foreach ($startSeqCheckPoints as $seq => $checkpoint) foreach ($records as $index => $record) { // foreach ($startSeqCheckPoints as $seq => $checkpoint)
$checking++; $checking++;
$guardName = $record->guardNames ? $record->guardNames->name : null; $guardName = $record->guardNames ? $record->guardNames->name : null;
$checkPointName = $record->checkPointNames ? $record->checkPointNames->name : null; $checkPointName = $record->checkPointNames ? $record->checkPointNames->name : null;
if ($this->guardName != $guardName || $this->newNameFound) {//if ($this->newNameFound) { if ($this->guardName != $guardName || $this->newNameFound) {// if ($this->newNameFound) {
if ($this->guardName) if ($this->guardName) {
{
$recordData = [ $recordData = [
'guard_name' => $this->guardName, 'guard_name' => $this->guardName,
'start_time' => $this->startTime, 'start_time' => $this->startTime,
@@ -105,27 +122,25 @@ class GuardPatrolEntryDataTable extends Component
$this->seqTimes = array_fill(1, $this->seqNoCnt, null); $this->seqTimes = array_fill(1, $this->seqNoCnt, null);
$this->guardName = $guardName; $this->guardName = $guardName;
$this->startTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12" $this->startTime = Carbon::parse($record->patrol_time)->toTimeString(); // "2025-06-01 00:07:12"
$this->start = Carbon::parse($record->patrol_time); $this->start = Carbon::parse($record->patrol_time);
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12" $this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); // "2025-06-01 00:07:12"
$this->finish = Carbon::parse($record->patrol_time); $this->finish = Carbon::parse($record->patrol_time);
$this->begin = Carbon::parse($record->patrol_time); $this->begin = Carbon::parse($record->patrol_time);
$this->end = Carbon::parse($record->patrol_time); $this->end = Carbon::parse($record->patrol_time);
$this->labTime = (int)$this->start->diffInMinutes($this->finish); $this->labTime = (int) $this->start->diffInMinutes($this->finish);
$this->minDiff = (int)$this->begin->diffInMinutes($this->end); $this->minDiff = (int) $this->begin->diffInMinutes($this->end);
$this->seqTime = $this->begin->toTimeString(). " - " . $this->end->toTimeString(); $this->seqTime = $this->begin->toTimeString().' - '.$this->end->toTimeString();
$this->seqNo = 0; $this->seqNo = 0;
$this->newNameFound = false; $this->newNameFound = false;
$this->isSequenced = true; $this->isSequenced = true;
} } elseif ($this->guardName == $guardName && $this->start && $this->begin) {
else if ($this->guardName == $guardName && $this->start && $this->begin) $this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); // "2025-06-01 00:07:12"
{
$this->endTime = Carbon::parse($record->patrol_time)->toTimeString(); //"2025-06-01 00:07:12"
$this->finish = Carbon::parse($record->patrol_time); $this->finish = Carbon::parse($record->patrol_time);
$this->end = Carbon::parse($record->patrol_time); $this->end = Carbon::parse($record->patrol_time);
$this->labTime = (int)$this->start->diffInMinutes($this->finish); $this->labTime = (int) $this->start->diffInMinutes($this->finish);
$this->minDiff = (int)$this->begin->diffInMinutes($this->end); $this->minDiff = (int) $this->begin->diffInMinutes($this->end);
$this->seqTime = $this->begin->toTimeString(). " - " . $this->end->toTimeString(); $this->seqTime = $this->begin->toTimeString().' - '.$this->end->toTimeString();
$this->begin = Carbon::parse($record->patrol_time); $this->begin = Carbon::parse($record->patrol_time);
// $this->seqNo = 0; // $this->seqNo = 0;
} }
@@ -133,19 +148,16 @@ class GuardPatrolEntryDataTable extends Component
$this->seqNo++; $this->seqNo++;
if ($this->seqNo == 1) { if ($this->seqNo == 1) {
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {//"STP BACKSIDE" if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {// "STP BACKSIDE"
$this->isSequenced = true; $this->isSequenced = true;
$this->sequences = array_fill(1, $this->seqNoCnt, "X"); $this->sequences = array_fill(1, $this->seqNoCnt, 'X');
} } else {
else {
$this->isSequenced = false; $this->isSequenced = false;
$this->sequences = array_fill(1, $this->seqNoCnt, "X"); $this->sequences = array_fill(1, $this->seqNoCnt, 'X');
} }
if (($index+1) == count($hasSingleGuard)) if (($index + 1) == count($hasSingleGuard)) {
{ if ($this->guardName) {
if ($this->guardName)
{
$recordData = [ $recordData = [
'guard_name' => $this->guardName, 'guard_name' => $this->guardName,
'start_time' => $this->startTime, 'start_time' => $this->startTime,
@@ -161,26 +173,37 @@ class GuardPatrolEntryDataTable extends Component
$this->records[] = $recordData; $this->records[] = $recordData;
} }
} }
} } elseif ($this->seqNo >= ($this->seqNoCnt + 1)) {
else if ($this->seqNo >= ($this->seqNoCnt+1)) { $this->seqTimes[$this->seqNo - 1] = $this->seqTime;
$this->seqTimes[$this->seqNo-1] = $this->seqTime; if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo - 1]->checkPointNames2->name) {// "D 72 END"
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo-1]->checkPointNames2->name) {//"D 72 END"
if ($this->isSequenced) { if ($this->isSequenced) {
$this->sequences[$this->seqNo-1] = $this->minDiff; $this->sequences[$this->seqNo - 1] = $this->minDiff;
} }
} } else {
else {
$this->isSequenced = false; $this->isSequenced = false;
} }
$this->newNameFound = true; $this->newNameFound = true;
if ($hasSingleGuard->unique('guard_name_id')->count() == 1) if ($hasSingleGuard->unique('guard_name_id')->count() == 1) {
{ if (($this->seqNoCnt + 1) == count($hasSingleGuard)) {
if (($this->seqNoCnt+1) == count($hasSingleGuard)) // dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
{ if ($this->guardName) {
//dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present"); $recordData = [
if ($this->guardName) 'guard_name' => $this->guardName,
{ 'start_time' => $this->startTime,
'end_time' => $this->endTime,
'lap_time' => $this->labTime,
];
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
$recordData["Sequence_$i"] = $this->sequences[$i];
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
}
$this->records[] = $recordData;
}
} elseif (($index + 1) == count($hasSingleGuard)) {
if ($this->guardName) {
$recordData = [ $recordData = [
'guard_name' => $this->guardName, 'guard_name' => $this->guardName,
'start_time' => $this->startTime, 'start_time' => $this->startTime,
@@ -196,30 +219,8 @@ class GuardPatrolEntryDataTable extends Component
$this->records[] = $recordData; $this->records[] = $recordData;
} }
} }
else if (($index+1) == count($hasSingleGuard)) } elseif (($index + 1) == count($hasSingleGuard)) {
{ if ($this->guardName) {
if ($this->guardName)
{
$recordData = [
'guard_name' => $this->guardName,
'start_time' => $this->startTime,
'end_time' => $this->endTime,
'lap_time' => $this->labTime,
];
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
$recordData["Sequence_$i"] = $this->sequences[$i];
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
}
$this->records[] = $recordData;
}
}
}
else if (($index+1) == count($hasSingleGuard))
{
if ($this->guardName)
{
$recordData = [ $recordData = [
'guard_name' => $this->guardName, 'guard_name' => $this->guardName,
'start_time' => $this->startTime, 'start_time' => $this->startTime,
@@ -235,26 +236,36 @@ class GuardPatrolEntryDataTable extends Component
$this->records[] = $recordData; $this->records[] = $recordData;
} }
} }
} } else { // if ($this->seqNo >= 2) {
else // if ($this->seqNo >= 2) { $this->seqTimes[$this->seqNo - 1] = $this->seqTime;
{ if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {// "CANTEEN"
$this->seqTimes[$this->seqNo-1] = $this->seqTime;
if ($checkPointName == $this->startSeqCheckPoints[$this->seqNo]->checkPointNames1->name) {//"CANTEEN"
if ($this->isSequenced) { if ($this->isSequenced) {
$this->sequences[$this->seqNo-1] = $this->minDiff; $this->sequences[$this->seqNo - 1] = $this->minDiff;
} }
} } else {
else {
$this->isSequenced = false; $this->isSequenced = false;
} }
if ($hasSingleGuard->unique('guard_name_id')->count() == 1) if ($hasSingleGuard->unique('guard_name_id')->count() == 1) {
{ if ($this->seqNo == count($hasSingleGuard)) {
if ($this->seqNo == count($hasSingleGuard)) // dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present");
{ if ($this->guardName) {
//dd("Has 1 Guard and single patrol round (".($this->seqNoCnt+1).") is present"); $recordData = [
if ($this->guardName) 'guard_name' => $this->guardName,
{ 'start_time' => $this->startTime,
'end_time' => $this->endTime,
'lap_time' => $this->labTime,
];
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
$recordData["Sequence_$i"] = $this->sequences[$i];
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
}
$this->records[] = $recordData;
}
} elseif (($index + 1) == count($hasSingleGuard)) {
if ($this->guardName) {
$recordData = [ $recordData = [
'guard_name' => $this->guardName, 'guard_name' => $this->guardName,
'start_time' => $this->startTime, 'start_time' => $this->startTime,
@@ -270,30 +281,8 @@ class GuardPatrolEntryDataTable extends Component
$this->records[] = $recordData; $this->records[] = $recordData;
} }
} }
else if (($index+1) == count($hasSingleGuard)) } elseif (($index + 1) == count($hasSingleGuard)) {
{ if ($this->guardName) {
if ($this->guardName)
{
$recordData = [
'guard_name' => $this->guardName,
'start_time' => $this->startTime,
'end_time' => $this->endTime,
'lap_time' => $this->labTime,
];
for ($i = 1; $i <= $this->seqNoCnt; $i++) {
$recordData["Sequence_$i"] = $this->sequences[$i];
$recordData["Sequence_Time_$i"] = $this->seqTimes[$i];
}
$this->records[] = $recordData;
}
}
}
else if (($index+1) == count($hasSingleGuard))
{
if ($this->guardName)
{
$recordData = [ $recordData = [
'guard_name' => $this->guardName, 'guard_name' => $this->guardName,
'start_time' => $this->startTime, 'start_time' => $this->startTime,

View File

@@ -37,7 +37,8 @@ class SerialValidationData extends Component
'refreshEmptyInvoice' => 'loadEmptyData', 'refreshEmptyInvoice' => 'loadEmptyData',
'refreshInvoiceData' => 'loadData', 'refreshInvoiceData' => 'loadData',
'refreshMaterialInvoiceData' => 'loadMaterialData', 'refreshMaterialInvoiceData' => 'loadMaterialData',
'openCapacitorModal' => 'showCapacitorInputBox', 'focusCapacitor' => 'focusCapacitorInput'
//'openCapacitorModal' => 'showCapacitorInputBox',
]; ];
public $capacitorInput = ''; public $capacitorInput = '';
@@ -48,6 +49,8 @@ class SerialValidationData extends Component
public $panel_box_serial_number; public $panel_box_serial_number;
public $itemcode;
public string $currentItemCode = ''; public string $currentItemCode = '';
public string $currentSerialNumber = ''; public string $currentSerialNumber = '';
@@ -64,6 +67,11 @@ class SerialValidationData extends Component
// // $this->showCapacitorInput = false; // // $this->showCapacitorInput = false;
// } // }
public function focusCapacitorInput($itemCode)
{
$this->dispatch('focus-capacitor-input', itemCode: $itemCode);
}
public function loadCompletedData($invoiceNumber, $plantId, $isSerial) public function loadCompletedData($invoiceNumber, $plantId, $isSerial)
{ {

View File

@@ -9,26 +9,27 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class InvoiceDataValidation extends Model class InvoiceDataValidation extends Model
{ {
use SoftDeletes; use SoftDeletes;
protected $dates = ['deleted_at']; protected $dates = ['deleted_at'];
protected $fillable = [ protected $fillable = [
"plant_id", 'plant_id',
"distribution_channel_desc", 'distribution_channel_desc',
"customer_code", 'customer_code',
"document_number", 'document_number',
"document_date", 'document_date',
"customer_trade_name", 'customer_trade_name',
"customer_location", 'customer_location',
"location", 'location',
"created_at", 'remark',
"created_by", 'created_at',
"updated_by", 'created_by',
"updated_at" 'updated_by',
'updated_at',
]; ];
public function plant(): BelongsTo public function plant(): BelongsTo
{ {
return $this->belongsTo(Plant::class); return $this->belongsTo(Plant::class);
} }
} }