diff --git a/app/Console/Commands/SendInvoiceReport.php b/app/Console/Commands/SendInvoiceReport.php index 6b08157..bee61c9 100644 --- a/app/Console/Commands/SendInvoiceReport.php +++ b/app/Console/Commands/SendInvoiceReport.php @@ -34,6 +34,8 @@ class SendInvoiceReport extends Command // $scheduleType = $this->argument('scheduleType'); $plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants + // $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name'); + $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name'); // $startDate = now()->setTime(8, 0, 0); diff --git a/app/Filament/Exports/ProcessOrderExporter.php b/app/Filament/Exports/ProcessOrderExporter.php index ace26f5..e2da8b6 100644 --- a/app/Filament/Exports/ProcessOrderExporter.php +++ b/app/Filament/Exports/ProcessOrderExporter.php @@ -59,7 +59,6 @@ class ProcessOrderExporter extends Exporter ExportColumn::make('deleted_at') ->enabledByDefault(false) ->label('DELETED AT'), - ]; } diff --git a/app/Filament/Imports/InvoiceValidationImporter.php b/app/Filament/Imports/InvoiceValidationImporter.php index 4f20ae5..7c786ec 100644 --- a/app/Filament/Imports/InvoiceValidationImporter.php +++ b/app/Filament/Imports/InvoiceValidationImporter.php @@ -110,7 +110,7 @@ class InvoiceValidationImporter extends Importer ImportColumn::make('operator_id') ->requiredMapping() ->exampleHeader('OPERATOR ID') - ->example('USER1') + ->example('USER00001') ->label('OPERATOR ID') ->rules(['required']), ImportColumn::make('created_at') @@ -122,19 +122,19 @@ class InvoiceValidationImporter extends Importer ImportColumn::make('created_by') ->requiredMapping() ->exampleHeader('CREATED BY') - ->example('USER1') + ->example('USER00001') ->label('CREATED BY') ->rules(['required']), ImportColumn::make('updated_at') ->requiredMapping() ->exampleHeader('UPDATED AT') - ->example('USER1') + ->example('') ->label('UPDATED AT') ->rules(['required']), ImportColumn::make('updated_by') ->requiredMapping() ->exampleHeader('UPDATED BY') - ->example('') + ->example('USER00001') ->label('UPDATED BY') ->rules(['required']), ]; diff --git a/app/Filament/Imports/ProductionCharacteristicImporter.php b/app/Filament/Imports/ProductionCharacteristicImporter.php index 6814510..cedc038 100644 --- a/app/Filament/Imports/ProductionCharacteristicImporter.php +++ b/app/Filament/Imports/ProductionCharacteristicImporter.php @@ -2,10 +2,17 @@ namespace App\Filament\Imports; +use App\Models\Item; +use App\Models\Line; +use App\Models\Machine; +use App\Models\Plant; use App\Models\ProductionCharacteristic; +use Filament\Actions\Imports\Exceptions\RowImportFailedException; use Filament\Actions\Imports\ImportColumn; use Filament\Actions\Imports\Importer; use Filament\Actions\Imports\Models\Import; +use Filament\Facades\Filament; +use Str; class ProductionCharacteristicImporter extends Importer { @@ -16,40 +23,170 @@ class ProductionCharacteristicImporter extends Importer return [ ImportColumn::make('plant') ->requiredMapping() - ->relationship() + ->exampleHeader('PLANT CODE') + ->example('1200') + ->label('PLANT CODE') + ->relationship(resolveUsing: 'code') ->rules(['required']), ImportColumn::make('line') - ->requiredMapping() - ->relationship() - ->rules(['required']), + ->exampleHeader('LINE NAME') + ->example('Poly Wrapped Wire SFG') + ->label('LINE NAME') + ->relationship(resolveUsing: 'name'), ImportColumn::make('item') ->requiredMapping() - ->relationship() + ->exampleHeader('ITEM CODE') + ->example('123456') + ->label('ITEM CODE') + ->relationship(resolveUsing: 'code') ->rules(['required']), - ImportColumn::make('machine') + ImportColumn::make('machine_name') ->requiredMapping() - ->relationship() + ->exampleHeader('MACHINE NAME') + ->example('RMI001234') + ->label('MACHINE NAME') + // ->relationship(resolveUsing: 'work_center') ->rules(['required']), - ImportColumn::make('production_order'), - ImportColumn::make('serial_number'), - ImportColumn::make('characteristic_name'), - ImportColumn::make('observed_value'), - ImportColumn::make('status'), - ImportColumn::make('inspection_status'), - ImportColumn::make('remark'), - ImportColumn::make('created_by'), - ImportColumn::make('updated_by'), + ImportColumn::make('production_order') + ->requiredMapping() + ->exampleHeader('PRODUCTION ORDER') + ->example('1880231') + ->label('PRODUCTION ORDER') + ->rules(['required']), + ImportColumn::make('serial_number') + ->requiredMapping() + ->exampleHeader('SERIAL NUMBER') + ->example('20001202121') + ->label('SERIAL NUMBER') + ->rules(['required']), + ImportColumn::make('characteristic_name') + ->requiredMapping() + ->exampleHeader('CHARACTERISTIC NAME') + ->example('Voltage') + ->label('CHARACTERISTIC NAME'), + ImportColumn::make('observed_value') + ->exampleHeader('OBSERVED VALUE') + ->example('0') + ->label('OBSERVED VALUE'), + ImportColumn::make('status') + ->exampleHeader('STATUS') + ->example('Ok') + ->label('STATUS'), + ImportColumn::make('remark') + ->exampleHeader('REMARK') + ->example('Issue') + ->label('REMARK'), ]; } public function resolveRecord(): ?ProductionCharacteristic { - // return ProductionCharacteristic::firstOrNew([ - // // Update existing records, matching them by `$this->data['column_name']` - // 'email' => $this->data['email'], - // ]); - return new ProductionCharacteristic(); + $warnMsg = []; + $plant = null; + $plantCod = trim($this->data['plant']) ?? ''; + $plantId = null; + $iCode = trim($this->data['item']) ?? ''; + $itemId = null; + $lineNam = trim($this->data['line']) ?? ''; + $lineId = null; + $machineName = trim($this->data['machine_name'] ?? ''); + $pOrder = trim($this->data['production_order'] ?? ''); + $sNo = trim($this->data['serial_number'] ?? ''); + $charName = trim($this->data['characteristic_name'] ?? ''); + $obsValue = trim($this->data['observed_value'] ?? ''); + $status = trim($this->data['status'] ?? ''); + $remark = trim($this->data['remark'] ?? ''); + + if ($plantCod == null || $plantCod == '') { + $warnMsg[] = "Plant code can't be empty!"; + } elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) { + $warnMsg[] = 'Invalid plant code found'; + } + if ($iCode == null || $iCode == '') { + $warnMsg[] = "Item code can't be empty!"; + } elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) { + $warnMsg[] = 'Invalid item code found!'; + } + if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) { + $warnMsg[] = 'Invalid machine name found!'; + } + + $plant = Plant::where('code', $plantCod)->first(); + if (! $plant) { + $warnMsg[] = 'Plant not found!'; + } else { + $plantId = $plant->id; + } + + $itemCode = Item::where('code', $iCode)->first(); + if (! $itemCode) { + $warnMsg[] = 'Item code not found!'; + } else { + if ($plantId) { + $itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first(); + if (! $itemCode) { + $warnMsg[] = 'Item code not found for the given plant!'; + } else { + $itemId = $itemCode->id; + } + } + } + + $lineExists = Line::where('name', $lineNam)->first(); + if (! $lineExists) { + $warnMsg[] = 'Line name not found!'; + } else { + if ($plantId) { + $lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first(); + if (! $lineAgainstPlant) { + $warnMsg[] = 'Line name not found for the given plant!'; + } else { + $lineId = $lineAgainstPlant->id; + } + } + } + + $machineExists = Machine::where('work_center', $machineName)->first(); + if (! $machineExists) { + $warnMsg[] = 'Machine not found!'; + } else { + if ($plantId) { + $machineAgainstPlant = Machine::where('work_center', $machineName)->where('plant_id', $plantId)->first(); + if (! $machineAgainstPlant) { + $warnMsg[] = 'Machine not found for the given plant!'; + } else { + $machineId = $machineAgainstPlant->id; + } + } + } + + if (! empty($warnMsg)) { + throw new RowImportFailedException(implode(', ', $warnMsg)); + } + + ProductionCharacteristic::Create( + [ + 'plant_id' => $plantId, + 'line_id' => $lineId, + 'item_id' => $itemId, + 'machine_id' => $machineId, + 'production_order' => $pOrder, + 'serial_number' => $sNo, + 'characteristic_name' => $charName, + 'observed_value' => $obsValue, + 'status' => $status, + 'remark' => $remark, + 'created_at' => now(), + 'updated_at' => now(), + 'created_by' => Filament::auth()->user()->name, + 'updated_by' => Filament::auth()->user()->name, + ] + ); + + return null; + + // return new ProductionCharacteristic(); } public static function getCompletedNotificationBody(Import $import): string diff --git a/app/Filament/Pages/ProductionQuantityPage.php b/app/Filament/Pages/ProductionQuantityPage.php index 997027a..99e0898 100644 --- a/app/Filament/Pages/ProductionQuantityPage.php +++ b/app/Filament/Pages/ProductionQuantityPage.php @@ -291,7 +291,6 @@ class ProductionQuantityPage extends Page implements HasForms $machineId = $get('machine_id'); $this->mNam = $machineId; - }) ->extraAttributes(fn ($get) => [ // 'class' => $get('pqLineError') ? 'border-red-500' : '', diff --git a/app/Filament/Resources/ImportTransitResource.php b/app/Filament/Resources/ImportTransitResource.php index 9a9292c..ea54062 100644 --- a/app/Filament/Resources/ImportTransitResource.php +++ b/app/Filament/Resources/ImportTransitResource.php @@ -22,6 +22,7 @@ use Filament\Notifications\Notification; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; use Maatwebsite\Excel\Facades\Excel; +// use PhpOffice\PhpSpreadsheet\IOFactory; class ImportTransitResource extends Resource { @@ -446,6 +447,20 @@ class ImportTransitResource extends Resource } + // $spreadsheet = IOFactory::load($fullPath); + + // foreach ($spreadsheet->getAllSheets() as $sheet) { + // $state = $sheet->getSheetState(); + // if ($state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN || + // $state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VERYHIDDEN) { + // Notification::make() + // ->title('Import Failed') + // ->body("Hidden sheet found: \"{$sheet->getTitle()}\". Please remove all hidden sheets and try again.") + // ->danger() + // ->send(); + // return; + // } + // } try { diff --git a/app/Filament/Resources/ProductionCharacteristicResource.php b/app/Filament/Resources/ProductionCharacteristicResource.php index 9740e09..38abd32 100644 --- a/app/Filament/Resources/ProductionCharacteristicResource.php +++ b/app/Filament/Resources/ProductionCharacteristicResource.php @@ -339,8 +339,9 @@ class ProductionCharacteristicResource extends Resource // return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); }) ->afterStateUpdated(function ($state, callable $set, callable $get) { - $set('Item', null); $set('Line', null); + $set('Item', null); + $set('Machine', null); }), Select::make('Line') ->label('Search by Line Name') @@ -361,7 +362,7 @@ class ProductionCharacteristicResource extends Resource })->pluck('name', 'id'); }) ->afterStateUpdated(function ($state, callable $set, callable $get) { - $set('process_order', null); + $set('Machine', null); }), Select::make('Item') ->label('Search by Item Code') diff --git a/app/Filament/Resources/ProductionOrderResource.php b/app/Filament/Resources/ProductionOrderResource.php index 585ddea..232c263 100644 --- a/app/Filament/Resources/ProductionOrderResource.php +++ b/app/Filament/Resources/ProductionOrderResource.php @@ -203,7 +203,6 @@ class ProductionOrderResource extends Resource ->label('Production Order') ->readOnly() ->visible(fn ($get) => $get('quantity') > 0), - // ->visible(fn ($get) => $get('show_extra_fields')), Forms\Components\TextInput::make('from_serial_number') ->label('From Serial Number') ->readOnly() diff --git a/app/Filament/Resources/ProductionOrderResource/Pages/CreateProductionOrder.php b/app/Filament/Resources/ProductionOrderResource/Pages/CreateProductionOrder.php index 581535d..e0e20cd 100644 --- a/app/Filament/Resources/ProductionOrderResource/Pages/CreateProductionOrder.php +++ b/app/Filament/Resources/ProductionOrderResource/Pages/CreateProductionOrder.php @@ -245,7 +245,6 @@ class CreateProductionOrder extends CreateRecord } else { return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]); } - } protected function getFormActions(): array diff --git a/app/Filament/Resources/QualityValidationResource.php b/app/Filament/Resources/QualityValidationResource.php index 99a8937..34806b6 100644 --- a/app/Filament/Resources/QualityValidationResource.php +++ b/app/Filament/Resources/QualityValidationResource.php @@ -94,7 +94,7 @@ class QualityValidationResource extends Resource Forms\Components\Hidden::make('plant') ->default(fn () => session('last_selected_plant_id')) ->afterStateHydrated(function ($state, $set) { - if (!$state && request()->has('plant_id')) { + if (! $state && request()->has('plant_id')) { $set('plant_id', request()->get('plant_id')); } }), @@ -136,7 +136,7 @@ class QualityValidationResource extends Resource Forms\Components\Hidden::make('line') ->default(fn () => session('last_selected_line')) ->afterStateHydrated(function ($state, $set) { - if (!$state && request()->has('line_id')) { + if (! $state && request()->has('line_id')) { $set('line_id', request()->get('line_id')); } }), @@ -178,7 +178,7 @@ class QualityValidationResource extends Resource Forms\Components\Hidden::make('production') ->default(fn () => session('last_selected_production')) ->afterStateHydrated(function ($state, $set) { - if (!$state && request()->has('production_order')) { + if (! $state && request()->has('production_order')) { $set('production_order', request()->get('production_order')); } }), @@ -2423,7 +2423,6 @@ class QualityValidationResource extends Resource $emails = $mailData['emails']; $mUserName = Filament::auth()->user()->name; - if (! empty($emails)) { // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); Mail::to($emails)->send( @@ -2519,7 +2518,6 @@ class QualityValidationResource extends Resource $emails = $mailData['emails']; $mUserName = Filament::auth()->user()->name; - if (! empty($emails)) { // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); Mail::to($emails)->send( @@ -2711,7 +2709,6 @@ class QualityValidationResource extends Resource $emails = $mailData['emails']; $mUserName = Filament::auth()->user()->name; - if (! empty($emails)) { // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); Mail::to($emails)->send( @@ -2864,16 +2861,6 @@ class QualityValidationResource extends Resource 'showChecklist' => $livewire->showChecklist, ]), - // Forms\Components\View::make('components.production-checklist-wrapper') - // ->statePath('checklist') - // ->key('checklist-view') - // ->viewData(fn ($livewire) => [ - // 'existingRecords' => is_array($livewire->existingRecords) - // ? $livewire->existingRecords - // : $livewire->existingRecords->toArray(), - // 'showChecklist' => $livewire->showChecklist, - // ]), - ]); } @@ -3066,7 +3053,6 @@ class QualityValidationResource extends Resource ]) ->filters([ - Tables\Filters\TrashedFilter::make(), Filter::make('advanced_filters') ->label('Advanced Filters') diff --git a/app/Filament/Resources/TestingPanelReadingResource.php b/app/Filament/Resources/TestingPanelReadingResource.php index 08a6480..fe17e0e 100644 --- a/app/Filament/Resources/TestingPanelReadingResource.php +++ b/app/Filament/Resources/TestingPanelReadingResource.php @@ -630,7 +630,7 @@ class TestingPanelReadingResource extends Resource ->options(function () { // return Plant::pluck('name', 'id'); $userHas = Filament::auth()->user()->plant_id; - + if ($userHas && strlen($userHas) > 0) { return Plant::where('id', $userHas)->pluck('name', 'id')->toArray(); } else { diff --git a/app/Http/Controllers/CharacteristicsController.php b/app/Http/Controllers/CharacteristicsController.php index abb4221..e91eb5c 100644 --- a/app/Http/Controllers/CharacteristicsController.php +++ b/app/Http/Controllers/CharacteristicsController.php @@ -520,9 +520,9 @@ class CharacteristicsController extends Controller if (Str::contains($modelHeading, 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP', 'NAME_PLATE']; - } elseif (Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMPS', ignoreCase: true) || Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP']; - } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPS', ignoreCase: true)) { $typesToCreate = ['PUMP']; } elseif (Str::contains($modelHeading, 'MOTOR', ignoreCase: true)) { $typesToCreate = ['MOTOR']; @@ -649,7 +649,7 @@ class CharacteristicsController extends Controller 'status_code' => 'ERROR', 'status_description' => "Serial number '{$serialNumber}' doesn't have name plate model to proceed!", ], 404); - } elseif (Str::contains($curHead, 'PUMP', ignoreCase: true) && ! Str::contains($curHead, 'PUMP SET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($curHead, 'PUMP', ignoreCase: true) && ! Str::contains($curHead, 'PUMP SET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPS', ignoreCase: true)) { if ($modelType == 'MOTOR') { return response()->json([ 'status_code' => 'ERROR', @@ -673,7 +673,7 @@ class CharacteristicsController extends Controller // 'status_description' => "Serial number '{$serialNumber}' doesn't have pumpset model to proceed!", // ], 404); } - } elseif (! Str::contains($curHead, 'PUMPSET', ignoreCase: true)) { + } elseif (! Str::contains($curHead, 'PUMPS', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true)) { return response()->json([ 'status_code' => 'ERROR', 'status_description' => "Serial number '{$serialNumber}' doesn't have valid model type to proceed!", @@ -1040,7 +1040,7 @@ class CharacteristicsController extends Controller if ($curMotorMarkStat == 'Marked' && $curPumpMarkStat == 'Marked') { $curMarkStat = 'Marked'; - } elseif (Str::contains($curHead, 'PUMP', ignoreCase: true) && ! Str::contains($curHead, 'PUMP SET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($curHead, 'PUMP', ignoreCase: true) && ! Str::contains($curHead, 'PUMP SET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPS', ignoreCase: true)) { if ($modelType == 'PUMP' && $pumPhysiCnt >= $mvhsCnt) { $curMarkStat = 'Marked'; } @@ -1543,9 +1543,9 @@ class CharacteristicsController extends Controller if (Str::contains($modelHeading, 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP', 'NAME_PLATE']; - } elseif (Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMPS', ignoreCase: true) || Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP']; - } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPS', ignoreCase: true)) { $typesToCreate = ['PUMP']; } elseif (Str::contains($modelHeading, 'MOTOR', ignoreCase: true)) { $typesToCreate = ['MOTOR']; @@ -1922,9 +1922,9 @@ class CharacteristicsController extends Controller if (Str::contains($modelHeading, 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP', 'NAME_PLATE']; - } elseif (Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMPS', ignoreCase: true) || Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP']; - } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPS', ignoreCase: true)) { $typesToCreate = ['PUMP']; } elseif (Str::contains($modelHeading, 'MOTOR', ignoreCase: true)) { $typesToCreate = ['MOTOR']; @@ -2356,7 +2356,7 @@ class CharacteristicsController extends Controller 'status_code' => 'ERROR', 'status_description' => "Serial number '{$serialNumber}' doesn't have name plate model to proceed!", ], 404); - } elseif (Str::contains($curHead, 'PUMP', ignoreCase: true) && ! Str::contains($curHead, 'PUMP SET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($curHead, 'PUMP', ignoreCase: true) && ! Str::contains($curHead, 'PUMP SET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true) && ! Str::contains($curHead, 'PUMPS', ignoreCase: true)) { if ($modelType == 'MOTOR') { return response()->json([ 'status_code' => 'ERROR', @@ -2380,7 +2380,7 @@ class CharacteristicsController extends Controller // 'status_description' => "Serial number '{$serialNumber}' doesn't have pumpset model to proceed!", // ], 404); } - } elseif (! Str::contains($curHead, 'PUMPSET', ignoreCase: true)) { + } elseif (! Str::contains($curHead, 'PUMPS', ignoreCase: true) && ! Str::contains($curHead, 'PUMPSET', ignoreCase: true)) { return response()->json([ 'status_code' => 'ERROR', 'status_description' => "Serial number '{$serialNumber}' doesn't have valid model type to proceed!", @@ -3647,9 +3647,9 @@ class CharacteristicsController extends Controller if (Str::contains($modelHeading, 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP', 'NAME_PLATE']; - } elseif (Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMPS', ignoreCase: true) || Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP']; - } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPS', ignoreCase: true)) { $typesToCreate = ['PUMP']; } elseif (Str::contains($modelHeading, 'MOTOR', ignoreCase: true)) { $typesToCreate = ['MOTOR']; @@ -4682,9 +4682,9 @@ class CharacteristicsController extends Controller if (Str::contains($modelHeading, 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP', 'NAME_PLATE']; - } elseif (Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMPS', ignoreCase: true) || Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { $typesToCreate = ['MOTOR', 'PUMP']; - } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true)) { + } elseif (Str::contains($modelHeading, 'PUMP', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMP SET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPSET', ignoreCase: true) && ! Str::contains($modelHeading, 'PUMPS', ignoreCase: true)) { $typesToCreate = ['PUMP']; } elseif (Str::contains($modelHeading, 'MOTOR', ignoreCase: true)) { $typesToCreate = ['MOTOR']; diff --git a/app/Http/Controllers/PalletPrintController.php b/app/Http/Controllers/PalletPrintController.php index bde69fa..75532d8 100644 --- a/app/Http/Controllers/PalletPrintController.php +++ b/app/Http/Controllers/PalletPrintController.php @@ -107,7 +107,7 @@ class PalletPrintController extends Controller $index = $completedPallets->search($pallet); - $currentPalletNo = ($index != false) ? $index + 1 : 0; + $currentPalletNo = ($index !== false) ? $index + 1 : 0; $boxLabel = $currentPalletNo.'/'.$totalBoxes; diff --git a/app/Mail/ProductionMail.php b/app/Mail/ProductionMail.php index 83e8be5..3bdf782 100644 --- a/app/Mail/ProductionMail.php +++ b/app/Mail/ProductionMail.php @@ -4,28 +4,42 @@ namespace App\Mail; use DateTime; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Illuminate\Queue\SerializesModels; +// use App\Exports\ProductionExport; +// use Illuminate\Mail\Mailables\Attachment; +// use Maatwebsite\Excel\Facades\Excel; + class ProductionMail extends Mailable { use Queueable, SerializesModels; public $tableData; + public $scheduleType; + // public $excelData; + // public $dates; /** * Create a new message instance. */ - public function __construct($scheduleType,$tableData = []) + public function __construct($scheduleType, $tableData = []) { - $this->scheduleType = $scheduleType; - $this->tableData = $tableData ?? []; + $this->scheduleType = $scheduleType; + $this->tableData = $tableData ?? []; } + // public function __construct($scheduleType,$tableData = [],$excelData = [],$dates = []) + // { + // $this->scheduleType = $scheduleType; + // $this->tableData = $tableData; + // $this->excelData = $excelData; + // $this->dates = $dates; + // } + /** * Get the message envelope. */ @@ -52,13 +66,14 @@ class ProductionMail extends Mailable // ], // ); // } + public function content(): Content { $greeting = "Dear Sir/Madam,

Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,"; if ($this->scheduleType == 'Daily') { - $fromDate = (new DateTime('yesterday 08:00'))->format('d/m/Y H:i') . ':000'; - $toDate = (new DateTime('today 07:59'))->format('d/m/Y H:i') . ':999'; + $fromDate = (new DateTime('yesterday 08:00'))->format('d/m/Y H:i').':000'; + $toDate = (new DateTime('today 07:59'))->format('d/m/Y H:i').':999'; $reportPeriod = "The following report presents results from: $fromDate to $toDate."; $greeting .= $reportPeriod; } @@ -74,22 +89,21 @@ class ProductionMail extends Mailable if ($this->scheduleType == 'Live') { $now = now(); $fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s'); - $toMinute = $now->format('d/m/Y H:i:s'); + $toMinute = $now->format('d/m/Y H:i:s'); $greeting .= "The following report presents results from: $fromMinute to $toMinute."; } return new Content( view: 'mail.production_report', with: [ - 'company' => "CRI Digital Manufacturing Solutions", + 'company' => 'CRI Digital Manufacturing Solutions', 'greeting' => $greeting, 'tableData' => $this->tableData, - 'wishes' => "Thanks & Regards,
CRI Digital Manufacturing Solutions" + 'wishes' => 'Thanks & Regards,
CRI Digital Manufacturing Solutions', ], ); } - /** * Get the attachments for the message. * @@ -98,5 +112,19 @@ class ProductionMail extends Mailable public function attachments(): array { return []; + // return [ + // Attachment::fromData( + // fn () => Excel::raw( + // new ProductionExport( + // $this->excelData, + // $this->dates + // ), + // \Maatwebsite\Excel\Excel::XLSX + // ), + // 'production_plan_data.xlsx' + // )->withMime( + // 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + // ), + // ]; } } diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index 8a2a636..152df60 100644 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -210,7 +210,20 @@ class PermissionSeeder extends Seeder Permission::updateOrCreate(['name' => 'view import temp class characteristic']); Permission::updateOrCreate(['name' => 'view export temp class characteristic']); + Permission::updateOrCreate(['name' => 'view import production temp']); + Permission::updateOrCreate(['name' => 'view export production temp']); + Permission::updateOrCreate(['name' => 'view import production orders']); + Permission::updateOrCreate(['name' => 'view export production orders']); + Permission::updateOrCreate(['name' => 'view import transit']); + Permission::updateOrCreate(['name' => 'view export import transit']); + + Permission::updateOrCreate(['name' => 'view reprint production order']); + Permission::updateOrCreate(['name' => 'create osp production sticker reprint page']); + + Permission::updateOrCreate(['name' => 'view print production order button']); + Permission::updateOrCreate(['name' => 'view save production order button']); + Permission::updateOrCreate(['name' => 'view print panel production order button']); } } diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index 4f0eb9a..23e25a6 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -948,84 +948,80 @@ function cameraCapture() { async verifyPhoto() { - if (!this.capturedPhoto) { - alert("Please capture a photo first!"); - return; - } + if (!this.capturedPhoto) { + alert("Please capture a photo first!"); + return; + } - if (!this.isWorkerReady) { - alert("OCR worker not ready yet!"); - return; - } + if (!this.isWorkerReady) { + alert("OCR worker not ready yet!"); + return; + } - try { - const img = new Image(); - img.src = this.capturedPhoto; + try { + const img = new Image(); + img.src = this.capturedPhoto; - img.onload = async () => { + img.onload = async () => { - // Reuse the same temp canvas (no memory leak) - this.tempCanvas.width = img.width; - this.tempCanvas.height = img.height; - this.tempCtx.drawImage(img, 0, 0); + // Reuse the same temp canvas (no memory leak) + this.tempCanvas.width = img.width; + this.tempCanvas.height = img.height; + this.tempCtx.drawImage(img, 0, 0); - // Worker OCR — much faster - const result = await this.ocrWorker.recognize(this.tempCanvas); + // Worker OCR — much faster + const result = await this.ocrWorker.recognize(this.tempCanvas); - const detectedText = result.data.text.trim(); - console.log("Detected Text:", detectedText); + const detectedText = result.data.text.trim(); + console.log("Detected Text:", detectedText); - // ------------------------------------------------------- - // SERIAL EXTRACTION LOGIC — SAME AS YOUR ORIGINAL - // ------------------------------------------------------- - const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i; - const match = detectedText.match(serialWithLabelRegex); + const serialWithLabelRegex = /Serial\s*No[:\-]?\s*([A-Za-z0-9]+)/i; + const match = detectedText.match(serialWithLabelRegex); - if (match && match[1]) { - // "Serial No: XXXXX" - this.serialNumbers = [match[1].trim()]; - console.log("Serial with Label:", this.serialNumbers[0]); - } else { - // Extract first 4 alphanumeric sequences of 4+ chars - const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || []; - this.serialNumbers = generalNums.slice(0, 4); + if (match && match[1]) { + this.serialNumbers = [match[1].trim()]; + console.log("Serial with Label:", this.serialNumbers[0]); + } + else + { + const generalNums = detectedText.match(/[A-Za-z0-9]{4,}/g) || []; + this.serialNumbers = generalNums.slice(0, 4); - if (this.serialNumbers.length === 0) { - alert("No serial numbers detected!"); - return; + if (this.serialNumbers.length == 0) { + alert("No serial numbers detected!"); + return; + } + + console.log("Serial Numbers List:", this.serialNumbers); } - console.log("Serial Numbers List:", this.serialNumbers); + // Save into hidden input (your original logic) + this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers); + + alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value); + + fetch('/save-serials-to-session', { + method: 'POST', + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content, + }, + body: JSON.stringify({ + serial_numbers: this.serialNumbers, + }), + }) + .then(response => response.json()) + .then(data => { + console.log("Session Updated:", data); + alert("✅ Serial numbers saved to session!"); + }); + }; + } catch (err) { + console.error("OCR verify error:", err); + alert("OCR verify failed:\n" + (err.message || err)); } - - // Save into hidden input (your original logic) - this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers); - - alert("Serial numbers:\n" + this.$refs.hiddenInputSerials.value); - - fetch('/save-serials-to-session', { - method: 'POST', - credentials: 'same-origin', - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content, - }, - body: JSON.stringify({ - serial_numbers: this.serialNumbers, - }), - }) - .then(response => response.json()) - .then(data => { - console.log("Session Updated:", data); - alert("✅ Serial numbers saved to session!"); - }); - }; - - } catch (err) { - console.error("OCR verify error:", err); - alert("OCR verify failed:\n" + (err.message || err)); - } -}, + }, startDetection() { if (this.textDetectionInterval) { diff --git a/resources/views/filament/pages/production-quantity.blade.php b/resources/views/filament/pages/production-quantity.blade.php index 99a5a25..0297e33 100644 --- a/resources/views/filament/pages/production-quantity.blade.php +++ b/resources/views/filament/pages/production-quantity.blade.php @@ -101,7 +101,7 @@ if (!scanInput) return; scanInput.addEventListener('keydown', function (event) { - if (event.key === 'Enter') { + if (event.key == 'Enter') { event.preventDefault(); const value = scanInput.value.trim(); diff --git a/resources/views/livewire/production-check-list.blade.php b/resources/views/livewire/production-check-list.blade.php index 44f016e..d405a43 100644 --- a/resources/views/livewire/production-check-list.blade.php +++ b/resources/views/livewire/production-check-list.blade.php @@ -3,7 +3,8 @@
- @if($records && $records->count()) + {{-- @if($records && $records->count()) --}} + @if(!empty($records) && count($records))
{{-- --}} diff --git a/resources/views/mail/invoice-in-transit-report.blade.php b/resources/views/mail/invoice-in-transit-report.blade.php index 14b011b..c629726 100644 --- a/resources/views/mail/invoice-in-transit-report.blade.php +++ b/resources/views/mail/invoice-in-transit-report.blade.php @@ -106,7 +106,6 @@ - @endif - {{-- --}}
{{ $row['lr_bl_aw_date'] }}{{ $row['transit_days'] }} {{ $row['status'] }}