diff --git a/app/Filament/Resources/BlockResource.php b/app/Filament/Resources/BlockResource.php index c6260c1..e652958 100644 --- a/app/Filament/Resources/BlockResource.php +++ b/app/Filament/Resources/BlockResource.php @@ -164,11 +164,15 @@ class BlockResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Blocks') + ->color('warning') ->importer(BlockImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import block'); }), ExportAction::make() + ->label('Export Blocks') + ->color('warning') ->exporter(BlockExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export block'); diff --git a/app/Filament/Resources/CheckPointNameResource.php b/app/Filament/Resources/CheckPointNameResource.php index 7c80f21..8f66982 100644 --- a/app/Filament/Resources/CheckPointNameResource.php +++ b/app/Filament/Resources/CheckPointNameResource.php @@ -153,11 +153,15 @@ class CheckPointNameResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Check Point Names') + ->color('warning') ->importer(CheckPointNameImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import check point name'); }), ExportAction::make() + ->label('Export Check Point Names') + ->color('warning') ->exporter(CheckPointNameExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export check point name'); diff --git a/app/Filament/Resources/CheckPointTimeResource.php b/app/Filament/Resources/CheckPointTimeResource.php index 2afee60..c32c815 100644 --- a/app/Filament/Resources/CheckPointTimeResource.php +++ b/app/Filament/Resources/CheckPointTimeResource.php @@ -384,11 +384,15 @@ class CheckPointTimeResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Check Point Times') + ->color('warning') ->importer(CheckPointTimeImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import check point time'); }), ExportAction::make() + ->label('Export Check Point Times') + ->color('warning') ->exporter(CheckPointTimeExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export check point time'); diff --git a/app/Filament/Resources/CompanyResource.php b/app/Filament/Resources/CompanyResource.php index 3a58ce2..3586715 100644 --- a/app/Filament/Resources/CompanyResource.php +++ b/app/Filament/Resources/CompanyResource.php @@ -121,11 +121,15 @@ class CompanyResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Companies') + ->color('warning') ->importer(CompanyImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import company'); }), ExportAction::make() + ->label('Export Companies') + ->color('warning') ->exporter(CompanyExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export company'); diff --git a/app/Filament/Resources/ConfigurationResource.php b/app/Filament/Resources/ConfigurationResource.php index f1178c1..984371f 100644 --- a/app/Filament/Resources/ConfigurationResource.php +++ b/app/Filament/Resources/ConfigurationResource.php @@ -183,11 +183,15 @@ class ConfigurationResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Configurations') + ->color('warning') ->importer(ConfigurationImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import configuration'); }), ExportAction::make() + ->label('Export Configurations') + ->color('warning') ->exporter(ConfigurationExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export configuration'); diff --git a/app/Filament/Resources/DeviceMasterResource.php b/app/Filament/Resources/DeviceMasterResource.php index 589c850..070d156 100644 --- a/app/Filament/Resources/DeviceMasterResource.php +++ b/app/Filament/Resources/DeviceMasterResource.php @@ -117,11 +117,15 @@ class DeviceMasterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Device Masters') + ->color('warning') ->importer(DeviceMasterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import device master'); }), ExportAction::make() + ->label('Export Device Masters') + ->color('warning') ->exporter(DeviceMasterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export device master'); diff --git a/app/Filament/Resources/EbReadingResource.php b/app/Filament/Resources/EbReadingResource.php index b97e43a..4ed9256 100644 --- a/app/Filament/Resources/EbReadingResource.php +++ b/app/Filament/Resources/EbReadingResource.php @@ -412,11 +412,15 @@ class EbReadingResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import EB Readings') + ->color('warning') ->importer(EbReadingImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import eb reading'); }), ExportAction::make() + ->label('Export EB Readings') + ->color('warning') ->exporter(EbReadingExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export eb reading'); diff --git a/app/Filament/Resources/EquipmentMasterResource.php b/app/Filament/Resources/EquipmentMasterResource.php index b0011ed..6080a50 100644 --- a/app/Filament/Resources/EquipmentMasterResource.php +++ b/app/Filament/Resources/EquipmentMasterResource.php @@ -446,11 +446,15 @@ class EquipmentMasterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Equipment Masters') + ->color('warning') ->importer(EquipmentMasterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import equipment master'); }), ExportAction::make() + ->label('Export Equipment Masters') + ->color('warning') ->exporter(EquipmentMasterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export equipment master'); diff --git a/app/Filament/Resources/GrMasterResource.php b/app/Filament/Resources/GrMasterResource.php index f3a1626..7a9aa3f 100644 --- a/app/Filament/Resources/GrMasterResource.php +++ b/app/Filament/Resources/GrMasterResource.php @@ -25,6 +25,13 @@ use Livewire\Features\SupportFileUploads\TemporaryUploadedFile; use Filament\Tables\Actions\ImportAction; use Filament\Tables\Actions\ExportAction; use Illuminate\Validation\Rule; +use thiagoalessio\TesseractOCR\TesseractOCR; +use setasign\Fpdi\Fpdi; +use setasign\Fpdi\PdfReader; +use SimpleSoftwareIO\QrCode\Facades\QrCode; + + + class GrMasterResource extends Resource { @@ -210,6 +217,176 @@ class GrMasterResource extends Resource return; } }), + // Action::make('uploadNow1') + // ->label('Upload OCR') + // ->action(function ($get, callable $set) { + // $uploadedFiles = $get('photo'); + + // if (is_array($uploadedFiles) && count($uploadedFiles) > 0) + // { + // $uploaded = reset($uploadedFiles); + + // if ($uploaded instanceof TemporaryUploadedFile) { + // $grNumber = $get('gr_number'); + // $safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber); + // // $originalName = $uploaded->getClientOriginalName(); + // // $path = 'uploads/GRNumber/' . $originalName; + // $finalFileName = $safeName . '.jpg'; + // $finalPath = 'uploads/OCR/' . $finalFileName; + + // // if (Storage::disk('local')->exists($finalPath)) { + // // Notification::make() + // // ->title('Duplicate File') + // // ->body("The file '{$finalFileName}' already exists in uploads/GRNumber.") + // // ->warning() + // // ->send(); + // // return; // Stop here + // // } + + // $storedPath = $uploaded->storeAs( + // 'uploads/OCR', + // $finalFileName, + // 'local' + // ); + + // // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local'); + // // $fullPath = storage_path('app/' . $storedPath); + // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local'); + + // $fullPath = storage_path('app/private/' . $storedPath); + + // $text = (new TesseractOCR($fullPath))->lang('eng')->run(); + + // $rawText = $text; + + // preg_match_all('/\d+/', $rawText, $matches); + + // $serialNumbers = $matches[0]; + + // $serialNumbers = array_slice($serialNumbers, 0, 4); + + // //dd($serialNumbers); + + // $processOrder = $get('gr_number'); + + // $itemId = $get('item_id'); + + // $plant = $get('plant_id'); + + // $item = Item::find($itemId); + + // $plant = Plant::find($plant); + + // $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf'); + + // $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf'); + + // $storedPath = $uploaded->storeAs( + // 'uploads/GRNumber', + // $finalFileName, + // 'local' + // ); + + // $pdf = new Fpdi('P', 'mm', [90, 90]); + + // $templateId = $pdf->setSourceFile($templatePath); + // $templatePage = $pdf->importPage(1); + + // $pdf->AddPage(); + // $pdf->useTemplate($templatePage, 0, 0, 90, 90); + + // $pdf->SetFont('Helvetica', '', 10); + // $pdf->SetTextColor(0, 0, 0); + + // $slots = [ + // ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial + // ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial + // ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial + // ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial + // ]; + + // $qrSlots = [ + // ['x' => 17.3, 'y' => 29.2, 'size' => 11.4], + // ['x' => 61.5, 'y' => 29, 'size' => 11.5], + // ['x' => 17.7, 'y' => 46.7, 'size' => 11.4], + // ['x' => 61.7, 'y' => 46.7, 'size' => 11.4], + // ]; + + // // foreach ($serialNumbers as $i => $serial) { + // // if (isset($slots[$i])) { + // // $pdf->SetFillColor(255, 255, 255); // erase old serial + // // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F'); + // // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']); + // // // $pdf->Write(0, $serial); + // // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L'); + // // } + // // } + + // // $pdf->Output('F', $outputPath); + // // return response()->download($outputPath); + + // // + + // // foreach ($serialNumbers as $i => $serial) { + // // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue; + + // // //Generate QR code PNG temporarily + // // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png"); + // // QrCode::format('png')->size(100)->generate($serial, $qrPath); + + // // //Place QR code above serial + // // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']); + + // // //Erase old serial + // // $pdf->SetFillColor(255, 255, 255); + // // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F'); + + // // //Write new serial number + // // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']); + // // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L'); + // // } + + // foreach ($serialNumbers as $i => $serial) { + // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue; + + // // Erase old QR completely (slightly larger) + // $pdf->SetFillColor(255, 255, 255); + // $pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F'); + + // // Generate new QR code + // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png"); + // $qrDir = storage_path('app/private/uploads/QR'); + // if (!file_exists($qrDir)) mkdir($qrDir, 0777, true); + // QrCode::format('png')->size(100)->generate($serial, $qrPath); + + // // Place QR code + // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']); + + // // Erase old serial + // $pdf->SetFillColor(255, 255, 255); + // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F'); + + // // Write new serial + // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']); + // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L'); + // } + + // // Save the final PDF + // $pdf->Output('F', $outputPath); + + // // Download + // return response()->download($outputPath); + // } + // } + // else + // { + // Notification::make() + // ->title('No file selected to upload') + // ->warning() + // ->send(); + // return; + // } + // }), Action::make('downloadAttachment') ->label('Download PDF') @@ -326,11 +503,15 @@ class GrMasterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import GR Masters') + ->color('warning') ->importer(GrMasterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import gr master'); }), ExportAction::make() + ->label('Export GR Masters') + ->color('warning') ->exporter(GrMasterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export gr master'); diff --git a/app/Filament/Resources/GuardNameResource.php b/app/Filament/Resources/GuardNameResource.php index 6b9c8b2..048cc4a 100644 --- a/app/Filament/Resources/GuardNameResource.php +++ b/app/Filament/Resources/GuardNameResource.php @@ -166,11 +166,15 @@ class GuardNameResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Guard Names') + ->color('warning') ->importer(GuardNameImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import guard name'); }), ExportAction::make() + ->label('Export Guard Names') + ->color('warning') ->exporter(GuardNameExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export guard name'); diff --git a/app/Filament/Resources/InvoiceDataValidationResource.php b/app/Filament/Resources/InvoiceDataValidationResource.php index 8f0f71c..1954573 100644 --- a/app/Filament/Resources/InvoiceDataValidationResource.php +++ b/app/Filament/Resources/InvoiceDataValidationResource.php @@ -568,6 +568,8 @@ class InvoiceDataValidationResource extends Resource return Filament::auth()->user()->can('view import invoice data validation'); }), ExportAction::make() + ->label('Export Invoice Data') + ->color('warning') ->exporter(InvoiceDataValidationExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export invoice data validation'); diff --git a/app/Filament/Resources/InvoiceOutValidationResource.php b/app/Filament/Resources/InvoiceOutValidationResource.php index 3b67d71..0977fb2 100644 --- a/app/Filament/Resources/InvoiceOutValidationResource.php +++ b/app/Filament/Resources/InvoiceOutValidationResource.php @@ -501,6 +501,8 @@ class InvoiceOutValidationResource extends Resource return Filament::auth()->user()->can('view import invoice out validation'); }), ExportAction::make() + ->label('Export Invoice Out Data') + ->color('warning') ->exporter(InvoiceOutValidationExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export invoice out validation'); diff --git a/app/Filament/Resources/ItemResource.php b/app/Filament/Resources/ItemResource.php index 5e2269a..ec4d96d 100644 --- a/app/Filament/Resources/ItemResource.php +++ b/app/Filament/Resources/ItemResource.php @@ -5,11 +5,14 @@ namespace App\Filament\Resources; use App\Filament\Exports\ItemExporter; use App\Filament\Imports\ItemImporter; use App\Filament\Resources\ItemResource\Pages; +use App\Models\InvoiceValidation; use App\Models\Item; use App\Models\Plant; +use App\Models\StickerMaster; use Filament\Actions\Exports\Enums\ExportFormat; use Filament\Facades\Filament; use Filament\Forms; +use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Forms\Get; @@ -21,7 +24,12 @@ use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; use Filament\Forms\Components\Section; +use Filament\Forms\Components\Select; +use Filament\Notifications\Notification; use Illuminate\Validation\Rule; +use Maatwebsite\Excel\Facades\Excel; +use Storage; +use Str; class ItemResource extends Resource { @@ -243,7 +251,237 @@ class ItemResource extends Resource ]), ]) ->headerActions([ + + // Tables\Actions\Action::make('Import Items') + // ->label('Import Items') + // ->form([ + // Select::make('plant_id') + // // ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs + // ->options(function (callable $get) { + // $userHas = Filament::auth()->user()->plant_id; + // return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray(); + // }) + // ->label('Select Plant') + // ->required() + // // ->default(function () { + // // return optional(InvoiceValidation::latest()->first())->plant_id; + // // }) + // ->afterStateUpdated(function ($state, callable $set, callable $get) { + // $set('item_code_file', null); + // }) + // ->reactive(), + + // FileUpload::make('item_code_file') + // ->label('Master Item Code') + // // ->required() + // ->preserveFilenames() // <- this keeps the original filename + // ->storeFiles(false) // prevent auto-storing, we will store manually + // ->reactive() + // ->required() + // ->disk('local') //'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app. + // ->visible(fn (Get $get) => !empty($get('plant_id'))) + // ->directory('uploads/temp'), + // ]) + // ->action(function (array $data) { + // $uploadedFile = $data['item_code_file']; + + // $disk = Storage::disk('local'); + + // $plantId = $data['plant_id']; + + // // Get original filename + // $originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx + + // $originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME); + + // // Store manually using storeAs to keep original name + // $path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path + + // $fullPath = Storage::disk('local')->path($path); + + // if ($fullPath && file_exists($fullPath)) + // { + // $rows = Excel::toArray(null, $fullPath)[0]; + + // if ((count($rows) - 1) <= 0) + // { + // Notification::make() + // ->title('Records Not Found') + // ->body("Import the valid 'Serial Invoice' file to proceed..!") + // ->danger() + // ->send(); + + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + + // $invalidCategory = []; + // $materialCodes = []; + // $description = []; + // $invalidHourlyQuantity = []; + // $invalidUOM = []; + // $invalidPlantName = []; + // $seenItems = []; + // $uniqueInvalidCodes = []; + // $uniqueDesc = []; + + // foreach ($rows as $index => $row) + // { + // if ($index == 0) continue; // Skip header + + // $category = trim($row[0]); + // $materialCode = trim($row[1]); + // $desc = trim($row[2]); + // $hourlyQuantity = trim($row[3]); + // $uom = trim($row[4]); + // $plantName = trim($row[5]); + + // if (strlen($materialCode) < 6) { + // $uniqueInvalidCodes[] = $materialCode; + // } + // else if (strlen($desc) < 7) { + // $uniqueDesc[] = $desc; + // } + + // $key = $plantName . '|' . $materialCode; + + // if (isset($seenItems[$key])) + // { + // $materialCodes[] = $materialCode; + // } + // else + // { + // $seenItems[$key] = true; + // } + // } + + // if (!empty($uniqueInvalidCodes)) { + // Notification::make() + // ->title('Invalid Item Codes') + // ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + // ->danger() + // ->send(); + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + // else if (!empty($uniqueMissingSerials)) { + // Notification::make() + // ->title('Missing Serial Numbers') + // ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) + // ->danger() + // ->send(); + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + // else if (!empty($uniqueSerialCodes)) { + // Notification::make() + // ->title('Invalid Serial Number') + // ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueSerialCodes)) + // ->danger() + // ->send(); + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + // else if (!empty($duplicateSerialCodes)) { + // Notification::make() + // ->title('Duplicate Serial Numbers') + // ->body('The following serial numbers are already exist in imported excel:
' . implode(', ', $duplicateSerialCodes)) + // ->danger() + // ->send(); + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + + + // $uniqueCodes = array_unique($materialCodes); + + // $matchedItems = StickerMaster::with('item') + // ->whereHas('item', function ($query) use ($uniqueCodes) { + // $query->whereIn('code', $uniqueCodes); + // }) + // ->get(); + + // $matchedCodes = $matchedItems->pluck('item.code')->toArray(); + + // $missingCodes = array_diff($uniqueCodes, $matchedCodes); + + // if (!empty($missingCodes)) + // { + // $missingCount = count($missingCodes); + + // $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
' . implode(', ', $missingCodes); + + // Notification::make() + // ->title('Unknown Item Codes') + // ->body($message) + // ->danger() + // ->send(); + + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + + // // Check which codes have a material_type set (not null) + // $invalidCodes = $matchedItems + // ->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid + // ->pluck('item.code') + // ->toArray(); + + // if (count($invalidCodes) > 10) + // { + // Notification::make() + // ->title('Invalid item codes found') + // ->body('' . count($invalidCodes) . 'item codes found have material type.') + // ->danger() + // ->send(); + + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + // else if (count($invalidCodes) > 0) + // { + // Notification::make() + // ->title('Invalid item codes found') + // ->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes)) + // ->danger() + // ->send(); + + // if ($disk->exists($path)) { + // $disk->delete($path); + // } + // return; + // } + // else + // { + // // Save full file path to session + // session(['uploaded_invoice_path' => $fullPath]); + // Notification::make() + // ->title('Serial invoice imported successfully.') + // ->success() + // ->send(); + // } + // } + // }) + // ->visible(function() { + // return Filament::auth()->user()->can('view import serial invoice'); + // }), ImportAction::make() + ->label('Import Items') + ->color('warning') ->importer(ItemImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import item'); @@ -251,7 +489,8 @@ class ItemResource extends Resource // ->maxRows(100000), ExportAction::make() // ->columnMapping(true) - // ->label('Export') + ->label('Import Items') + ->color('warning') // ->fileName("Items Report " . date('Y-m-d H:i:s')) ->exporter(ItemExporter::class) ->visible(function() { diff --git a/app/Filament/Resources/LineResource.php b/app/Filament/Resources/LineResource.php index 740c470..824654b 100644 --- a/app/Filament/Resources/LineResource.php +++ b/app/Filament/Resources/LineResource.php @@ -1119,11 +1119,15 @@ class LineResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Lines') + ->color('warning') ->importer(LineImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import line'); }), ExportAction::make() + ->label('Export Lines') + ->color('warning') ->exporter(LineExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export line'); diff --git a/app/Filament/Resources/LineStopResource.php b/app/Filament/Resources/LineStopResource.php index 1c8818a..89c0620 100644 --- a/app/Filament/Resources/LineStopResource.php +++ b/app/Filament/Resources/LineStopResource.php @@ -157,11 +157,15 @@ class LineStopResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Line Stops') + ->color('warning') ->importer(LineStopImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import line stop'); }), ExportAction::make() + ->label('Export Line Stops') + ->color('warning') ->exporter(LineStopExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export line stop'); diff --git a/app/Filament/Resources/LocatorResource.php b/app/Filament/Resources/LocatorResource.php index 09ec035..68f16d8 100644 --- a/app/Filament/Resources/LocatorResource.php +++ b/app/Filament/Resources/LocatorResource.php @@ -342,11 +342,15 @@ class LocatorResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Locators') + ->color('warning') ->importer(LocatorImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import locator'); }), ExportAction::make() + ->label('Export Locators') + ->color('warning') ->exporter(LocatorExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export locator'); diff --git a/app/Filament/Resources/MachineResource.php b/app/Filament/Resources/MachineResource.php index e0c4655..fb08409 100644 --- a/app/Filament/Resources/MachineResource.php +++ b/app/Filament/Resources/MachineResource.php @@ -249,11 +249,15 @@ class MachineResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Machines') + ->color('warning') ->importer(MachineImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import machine'); }), ExportAction::make() + ->label('Export Machines') + ->color('warning') ->exporter(MachineExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export machine'); diff --git a/app/Filament/Resources/MfmMeterResource.php b/app/Filament/Resources/MfmMeterResource.php index e9a4258..9a294d6 100644 --- a/app/Filament/Resources/MfmMeterResource.php +++ b/app/Filament/Resources/MfmMeterResource.php @@ -123,11 +123,15 @@ class MfmMeterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import MFM Meters') + ->color('warning') ->importer(MfmMeterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import mfm meter'); }), ExportAction::make() + ->label('Export MFM Meters') + ->color('warning') ->exporter(MfmMeterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export mfm meter'); diff --git a/app/Filament/Resources/MfmParameterResource.php b/app/Filament/Resources/MfmParameterResource.php index 3027582..07dd55d 100644 --- a/app/Filament/Resources/MfmParameterResource.php +++ b/app/Filament/Resources/MfmParameterResource.php @@ -154,11 +154,15 @@ class MfmParameterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import MFM Parameters') + ->color('warning') ->importer(MfmParameterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import mfm parameter'); }), ExportAction::make() + ->label('Export MFM Parameters') + ->color('warning') ->exporter(MfmParameterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export mfm parameter'); diff --git a/app/Filament/Resources/MotorTestingMasterResource.php b/app/Filament/Resources/MotorTestingMasterResource.php index f705ed4..1c4de36 100644 --- a/app/Filament/Resources/MotorTestingMasterResource.php +++ b/app/Filament/Resources/MotorTestingMasterResource.php @@ -761,11 +761,15 @@ class MotorTestingMasterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Motor Testing Masters') + ->color('warning') ->importer(MotorTestingMasterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import motor testing master'); }), ExportAction::make() + ->label('Export Motor Testing Masters') + ->color('warning') ->exporter(MotorTestingMasterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export motor testing master'); diff --git a/app/Filament/Resources/PlantResource.php b/app/Filament/Resources/PlantResource.php index f157cc0..17412a0 100644 --- a/app/Filament/Resources/PlantResource.php +++ b/app/Filament/Resources/PlantResource.php @@ -222,11 +222,15 @@ class PlantResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Plants') + ->color('warning') ->importer(PlantImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import plant'); }), ExportAction::make() + ->label('Export Plants') + ->color('warning') ->exporter(PlantExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export plant'); diff --git a/app/Filament/Resources/ProductionLineStopResource.php b/app/Filament/Resources/ProductionLineStopResource.php index 9af43e0..d064fd1 100644 --- a/app/Filament/Resources/ProductionLineStopResource.php +++ b/app/Filament/Resources/ProductionLineStopResource.php @@ -616,11 +616,15 @@ class ProductionLineStopResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Production Line Stops') + ->color('warning') ->importer(ProductionLineStopImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import production line stop'); }), ExportAction::make() + ->label('Export Production Line Stops') + ->color('warning') ->exporter(ProductionLineStopExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export production line stop'); diff --git a/app/Filament/Resources/ProductionPlanResource.php b/app/Filament/Resources/ProductionPlanResource.php index d492a85..f1e45f7 100644 --- a/app/Filament/Resources/ProductionPlanResource.php +++ b/app/Filament/Resources/ProductionPlanResource.php @@ -731,11 +731,15 @@ class ProductionPlanResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Production Plans') + ->color('warning') ->importer(ProductionPlanImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import production plan'); }), ExportAction::make() + ->label('Export Production Plans') + ->color('warning') ->exporter(ProductionPlanExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export production plan'); diff --git a/app/Filament/Resources/ProductionQuantityResource.php b/app/Filament/Resources/ProductionQuantityResource.php index fb3c3cd..2da4d1b 100644 --- a/app/Filament/Resources/ProductionQuantityResource.php +++ b/app/Filament/Resources/ProductionQuantityResource.php @@ -1316,6 +1316,8 @@ class ProductionQuantityResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Production Quantities') + ->color('warning') ->importer(ProductionQuantityImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import production quantities'); @@ -1323,6 +1325,8 @@ class ProductionQuantityResource extends Resource // ->chunkSize(250), // ->maxRows(100000), ExportAction::make() + ->label('Export Production Quantities') + ->color('warning') ->exporter(ProductionQuantityExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export production quantities'); diff --git a/app/Filament/Resources/QualityValidationResource.php b/app/Filament/Resources/QualityValidationResource.php index 0323a0e..1f85792 100644 --- a/app/Filament/Resources/QualityValidationResource.php +++ b/app/Filament/Resources/QualityValidationResource.php @@ -2419,125 +2419,129 @@ class QualityValidationResource extends Resource ->placeholder(placeholder: 'Select To DateTime') ->reactive() ->native(false), - ]) - ->query(function ($query, array $data) { - // Hide all records initially if no filters are applied - if (empty($data['Plant']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['sticker_master_id'])) { - return $query->whereRaw('1 = 0'); - } - - if (!empty($data['Plant'])) { - $query->where('plant_id', $data['Plant']); - } - - if (!empty($data['Line'])) { - $query->where('line_id', $data['Line']); - } - - if (!empty($data['production_order'])) { - $query->where('production_order', $data['production_order']); - } - - if (!empty($data['serial_number'])) { - $query->where('serial_number', $data['serial_number']); - } - - if (!empty($data['sap_msg_status'])) { - $query->where('sap_msg_status', $data['sap_msg_status']); - } - - if (!empty($data['created_from'])) { - $query->where('created_at', '>=', $data['created_from']); - } - - if (!empty($data['created_to'])) { - $query->where('created_at', '<=', $data['created_to']); - } - - if (!empty($data['operator_id'])) { - $query->where('operator_id', $data['operator_id']); - } - - if (!empty($data['sticker_master_id'])) { - $stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id']) - ->pluck('id') - ->toArray(); - - if (!empty($stickerMasterIds)) { - $query->whereIn('sticker_master_id', $stickerMasterIds); + ]) + ->query(function ($query, array $data) { + // Hide all records initially if no filters are applied + if (empty($data['Plant']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['sticker_master_id'])) { + return $query->whereRaw('1 = 0'); } - } - //$query->orderBy('created_at', 'asc'); - }) - ->indicateUsing(function (array $data) { - $indicators = []; + if (!empty($data['Plant'])) { + $query->where('plant_id', $data['Plant']); + } - if (!empty($data['Plant'])) { - $indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name'); - } + if (!empty($data['Line'])) { + $query->where('line_id', $data['Line']); + } - if (!empty($data['Line'])) { - $indicators[] = 'Line: ' . Line::where('id', $data['Line'])->value('name'); - } + if (!empty($data['production_order'])) { + $query->where('production_order', $data['production_order']); + } - if (!empty($data['production_order'])) { - $indicators[] = 'Production Order: ' . $data['production_order']; - } + if (!empty($data['serial_number'])) { + $query->where('serial_number', $data['serial_number']); + } - if (!empty($data['serial_number'])) { - $indicators[] = 'Serial Number: ' . $data['serial_number']; - } + if (!empty($data['sap_msg_status'])) { + $query->where('sap_msg_status', $data['sap_msg_status']); + } - if (!empty($data['sticker_master_id'])) { - $itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown'; - $indicators[] = 'Item Codes: ' . $itemCode; - } + if (!empty($data['created_from'])) { + $query->where('created_at', '>=', $data['created_from']); + } - if (!empty($data['sap_msg_status'])) { - $indicators[] = 'SAP Message Status: ' . $data['sap_msg_status']; - } + if (!empty($data['created_to'])) { + $query->where('created_at', '<=', $data['created_to']); + } - if (!empty($data['operator_id'])) { - $indicators[] = 'Created By: ' . $data['operator_id']; - } + if (!empty($data['operator_id'])) { + $query->where('operator_id', $data['operator_id']); + } - if (!empty($data['created_from'])) { - $indicators[] = 'From: ' . $data['created_from']; - } + if (!empty($data['sticker_master_id'])) { + $stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id']) + ->pluck('id') + ->toArray(); - if (!empty($data['created_to'])) { - $indicators[] = 'To: ' . $data['created_to']; - } + if (!empty($stickerMasterIds)) { + $query->whereIn('sticker_master_id', $stickerMasterIds); + } + } - return $indicators; - }) - ]) - ->filtersFormMaxHeight('280px') - ->actions([ - Tables\Actions\ViewAction::make(), - Tables\Actions\EditAction::make(), - ]) + //$query->orderBy('created_at', 'asc'); + }) + ->indicateUsing(function (array $data) { + $indicators = []; - ->bulkActions([ - Tables\Actions\BulkActionGroup::make([ - Tables\Actions\DeleteBulkAction::make(), - Tables\Actions\ForceDeleteBulkAction::make(), - Tables\Actions\RestoreBulkAction::make(), - ]), - ]) - ->headerActions([ - ImportAction::make() - ->importer(QualityValidationImporter::class) - ->visible(function() { - return Filament::auth()->user()->can('view import quality validation'); - }), - ExportAction::make() - ->exporter(QualityValidationExporter::class) - ->visible(function() { - return Filament::auth()->user()->can('view export quality validation'); - }), - ]); + if (!empty($data['Plant'])) { + $indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name'); + } + + if (!empty($data['Line'])) { + $indicators[] = 'Line: ' . Line::where('id', $data['Line'])->value('name'); + } + + if (!empty($data['production_order'])) { + $indicators[] = 'Production Order: ' . $data['production_order']; + } + + if (!empty($data['serial_number'])) { + $indicators[] = 'Serial Number: ' . $data['serial_number']; + } + + if (!empty($data['sticker_master_id'])) { + $itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown'; + $indicators[] = 'Item Codes: ' . $itemCode; + } + + if (!empty($data['sap_msg_status'])) { + $indicators[] = 'SAP Message Status: ' . $data['sap_msg_status']; + } + + if (!empty($data['operator_id'])) { + $indicators[] = 'Created By: ' . $data['operator_id']; + } + + if (!empty($data['created_from'])) { + $indicators[] = 'From: ' . $data['created_from']; + } + + if (!empty($data['created_to'])) { + $indicators[] = 'To: ' . $data['created_to']; + } + + return $indicators; + }) + ]) + ->filtersFormMaxHeight('280px') + ->actions([ + Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), + ]) + + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + Tables\Actions\ForceDeleteBulkAction::make(), + Tables\Actions\RestoreBulkAction::make(), + ]), + ]) + ->headerActions([ + ImportAction::make() + ->label('Import Quality Validations') + ->color('warning') + ->importer(QualityValidationImporter::class) + ->visible(function() { + return Filament::auth()->user()->can('view import quality validation'); + }), + ExportAction::make() + ->label('Export Quality Validations') + ->color('warning') + ->exporter(QualityValidationExporter::class) + ->visible(function() { + return Filament::auth()->user()->can('view export quality validation'); + }), + ]); } diff --git a/app/Filament/Resources/SerialValidationResource.php b/app/Filament/Resources/SerialValidationResource.php index 4878196..5e782a8 100644 --- a/app/Filament/Resources/SerialValidationResource.php +++ b/app/Filament/Resources/SerialValidationResource.php @@ -982,7 +982,7 @@ class SerialValidationResource extends Resource // return Filament::auth()->user()->can('view import material invoice'); // }), ExportAction::make() - ->label('Export Invoices') + ->label('Export Serial Invoices') ->color('warning') ->exporter(SerialValidationExporter::class) ->visible(function() { diff --git a/app/Filament/Resources/ShiftResource.php b/app/Filament/Resources/ShiftResource.php index d0f6ca2..511b7ca 100644 --- a/app/Filament/Resources/ShiftResource.php +++ b/app/Filament/Resources/ShiftResource.php @@ -344,11 +344,15 @@ class ShiftResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Shifts') + ->color('warning') ->importer(ShiftImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import shift'); }), ExportAction::make() + ->label('Export Shifts') + ->color('warning') ->exporter(ShiftExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export shift'); diff --git a/app/Filament/Resources/StickerMasterResource.php b/app/Filament/Resources/StickerMasterResource.php index 0596fd6..1209504 100644 --- a/app/Filament/Resources/StickerMasterResource.php +++ b/app/Filament/Resources/StickerMasterResource.php @@ -609,11 +609,15 @@ class StickerMasterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Sticker Masters') + ->color('warning') ->importer(StickerMasterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import sticker master'); }), ExportAction::make() + ->label('Export Sticker Masters') + ->color('warning') ->exporter(StickerMasterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export sticker master'); diff --git a/app/Filament/Resources/UserResource.php b/app/Filament/Resources/UserResource.php index 504c590..f6b97b9 100644 --- a/app/Filament/Resources/UserResource.php +++ b/app/Filament/Resources/UserResource.php @@ -161,11 +161,15 @@ class UserResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Users') + ->color('warning') ->importer(UserImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import user'); }), ExportAction::make() + ->label('Export Users') + ->color('warning') ->exporter(UserExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export user'); diff --git a/app/Filament/Resources/WorkGroupMasterResource.php b/app/Filament/Resources/WorkGroupMasterResource.php index 14dde77..dd416a3 100644 --- a/app/Filament/Resources/WorkGroupMasterResource.php +++ b/app/Filament/Resources/WorkGroupMasterResource.php @@ -172,11 +172,15 @@ class WorkGroupMasterResource extends Resource ]) ->headerActions([ ImportAction::make() + ->label('Import Work Group Masters') + ->color('warning') ->importer(WorkGroupMasterImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import work group master'); }), ExportAction::make() + ->label('Export Work Group Masters') + ->color('warning') ->exporter(WorkGroupMasterExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export work group master'); diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index 52b69ee..d63441e 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -993,6 +993,15 @@ function cameraCapture() { this.$refs.snapshot.classList.add('hidden'); this.$refs.video.classList.remove('hidden'); await this.initCamera(); + await new Promise(resolve => { + this.$refs.video.onloadedmetadata = resolve; + }); + + // ✅ Sync overlay canvas size with video size + const video = this.$refs.video; + const overlay = this.$refs.overlay; + overlay.width = video.videoWidth; + overlay.height = video.videoHeight; this.startDetection(); },