From 6f93f2bd926552a6e8a099412a631c80a79f9cbe Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 13 May 2026 17:41:22 +0530 Subject: [PATCH] Updated alignments and validation logics --- app/Console/Commands/SendInvoiceReport.php | 2 + app/Filament/Exports/ProcessOrderExporter.php | 1 - .../Pages/CreateProductionOrder.php | 1 - .../Controllers/PalletPrintController.php | 2 +- app/Mail/ProductionMail.php | 48 +++++-- database/seeders/PermissionSeeder.php | 13 ++ .../views/fields/camera-capture.blade.php | 128 +++++++++--------- .../pages/production-quantity.blade.php | 2 +- .../livewire/production-check-list.blade.php | 3 +- .../mail/invoice-in-transit-report.blade.php | 1 - 10 files changed, 119 insertions(+), 82 deletions(-) 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/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/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'] }}