From 172fa16813aa90cf3228ce61aaaecdab3b024fe6 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 4 Sep 2026 14:50:34 +0530 Subject: [PATCH 1/2] Added panel box alert mail pages --- app/Mail/PanelBoxNotOkAlert.php | 70 ++++ .../mail/panel-box-not-ok-alert.blade.php | 310 ++++++++++++++++++ 2 files changed, 380 insertions(+) create mode 100644 app/Mail/PanelBoxNotOkAlert.php create mode 100644 resources/views/mail/panel-box-not-ok-alert.blade.php diff --git a/app/Mail/PanelBoxNotOkAlert.php b/app/Mail/PanelBoxNotOkAlert.php new file mode 100644 index 0000000..8e09e27 --- /dev/null +++ b/app/Mail/PanelBoxNotOkAlert.php @@ -0,0 +1,70 @@ +plant = $plant; + $this->itemCode = $itemCode; + $this->serialNumber = $serialNumber; + $this->supplier = $supplier; + $this->characteristics = $characteristics; + } + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: 'Panel Box Not Ok Alert', + ); + } + + /** + * Get the message content definition. + */ + public function content(): Content + { + $greeting = 'Dear Sir'; + return new Content( + view: 'mail.panel-box-not-ok-alert', + with: [ + 'company' => 'CRI Digital Manufacturing Solutions', + 'greeting' => $greeting, + 'wishes' => 'Thanks & Regards,
CRI Digital Manufacturing Solutions', + ], + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/resources/views/mail/panel-box-not-ok-alert.blade.php b/resources/views/mail/panel-box-not-ok-alert.blade.php new file mode 100644 index 0000000..d57bf94 --- /dev/null +++ b/resources/views/mail/panel-box-not-ok-alert.blade.php @@ -0,0 +1,310 @@ + + + + + + +Panel Box Not OK Alert + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ Panel Box Inspection Alert +
+ +
+ Inspection result: NOT OK +
+
+ ⚠ +
+ +
+ +
+ A panel box inspection has been marked as + Not OK. + Please review the inspection details below. +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Inspection Details +
+ Plant + + {{ $plant }} +
+ Panel Box Code + + {{ $itemCode }} +
+ Serial Number + + {{ $serialNumber }} +
+ Supplier Number + + {{ $supplier }} +
+ +
+ +
+ Characteristics +
+ + + + + + + + + + + + + + + + + + @foreach(($characteristics ?? []) as $index => $characteristic) + + + + + + + + + + + + + @endforeach + + + +
+ S.No + + Characteristic Name + + Spec Value + + Observed Value +
+ {{ $index + 1 }} + + {{ $characteristic['characteristic_name'] }} + + {{ $characteristic['lower'] }} + - + {{ $characteristic['upper'] }} + + {{ $characteristic['observed_value'] }} +
+ +
+ + + + + + + +
+ + Action Required: + Please review the above inspection results + and take the necessary corrective action. + +
+ +
+ +
+ This is an automated notification from the + Panel Box Inspection System. +
+ +
+ Please do not reply to this email. +
+ +
+ +
+ + + -- 2.49.1 From f10a95e8744f2bf5a8f50ef66c1111a2259863c3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 4 Sep 2026 14:54:58 +0530 Subject: [PATCH 2/2] Added panel box alert mail logic in panel check list --- app/Livewire/PanelCheckList.php | 52 ++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/app/Livewire/PanelCheckList.php b/app/Livewire/PanelCheckList.php index 42ea3db..99e6eb7 100644 --- a/app/Livewire/PanelCheckList.php +++ b/app/Livewire/PanelCheckList.php @@ -2,6 +2,7 @@ namespace App\Livewire; +use App\Mail\PanelBoxNotOkAlert; use App\Models\AlertMailRule; use App\Models\Item; use App\Models\Line; @@ -9,6 +10,7 @@ use App\Models\PanelBoxValidation; use App\Models\Plant; use App\Models\ProductCharacteristicsMaster; use App\Models\ProductionCharacteristic; +use App\Models\StickerMaster; use Filament\Facades\Filament; use Livewire\Component; use Filament\Notifications\Notification; @@ -322,6 +324,8 @@ public $records = []; if($this->selectForNotOk){ + $notOkCharacteristics = []; + foreach ($this->records as $record) { $characteristicId = $record['id']; @@ -336,6 +340,13 @@ public $records = []; ->where('item_id', $itemId) ->first(); + $specVal = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id']) + ->where('item_id', $itemId) + ->where('line_id', $this->data['line_id']) + ->where('machine_id', $characteristic?->machine_id) + ->where('name', $characteristic?->name) + ->first(); + if (($itemCharacteristic?->inspection_type ?? null) === 'Value') { if ($value == null || $value == '') { $status = null; @@ -366,6 +377,46 @@ public $records = []; 'created_by' => $this->data['created_by'] ?? null, 'updated_by' => $this->data['updated_by'] ?? null, ]); + + $notOkCharacteristics[] = [ + 'characteristic_name' => $characteristic?->name ?? null, + 'observed_value' => $value ?? null, + 'lower' => $specVal?->lower, + 'upper' => $specVal?->upper, + 'status' => $status, + ]; + } + + $plant = Plant::find($this->data['plant_id']); + + $plantName = $plant?->name; + + $code = $itemAgaPlant->code; + + $mailRule = AlertMailRule::where('plant', $plant->id)->where('module', 'PanelBoxAlert') + ->where('rule_name', 'PanelBoxAlertMail') + ->where(fn ($q) => $q->whereNull('schedule_type')->orWhere('schedule_type', '')) + ->first(); + + if ($mailRule && !empty($mailRule->email)) { + + $mail = Mail::to($mailRule->email); + + if (!empty($mailRule->cc_emails)) { + $ccEmails = array_filter( + array_map('trim', explode(',', $mailRule->cc_emails)) + ); + + $mail->cc($ccEmails); + } + + $mail->send(new PanelBoxNotOkAlert( + $plantName, + $code ?? null, + $this->data['serial_number'] ?? null, + $this->data['panel_box_supplier'] ?? null, + $notOkCharacteristics + )); } } else { @@ -373,7 +424,6 @@ public $records = []; //All validations Passed foreach ($this->checklist as $characteristicId => $value) { - $characteristic = ProductCharacteristicsMaster::find($characteristicId); $itemCharacteristic = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id']) -- 2.49.1