Added panel box alert mail logic in panel check list
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 4m28s
Laravel Larastan / larastan (pull_request) Failing after 6m9s

This commit is contained in:
dhanabalan
2026-09-04 14:54:58 +05:30
parent 172fa16813
commit f10a95e874

View File

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