Merge pull request 'Added panel box alert mail pages' (#977) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

Reviewed-on: #977
This commit was merged in pull request #977.
This commit is contained in:
2026-09-04 09:25:12 +00:00
3 changed files with 431 additions and 1 deletions

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

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Mail;
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;
class PanelBoxNotOkAlert extends Mailable
{
use Queueable, SerializesModels;
public $plant;
public $itemCode;
public $serialNumber;
public $characteristics;
public $supplier;
/**
* Create a new message instance.
*/
public function __construct($plant,$itemCode,$serialNumber,$supplier, $characteristics)
{
$this->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 = '<b>Dear Sir</b>';
return new Content(
view: 'mail.panel-box-not-ok-alert',
with: [
'company' => 'CRI Digital Manufacturing Solutions',
'greeting' => $greeting,
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

View File

@@ -0,0 +1,310 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Panel Box Not OK Alert</title>
</head>
<body style="margin:0; padding:0; background-color:#f4f6f8; font-family:Arial, Helvetica, sans-serif;">
<table width="100%" cellpadding="0" cellspacing="0" border="0"
style="background-color:#f4f6f8; padding:30px 0;">
<tr>
<td align="center">
<!-- Main Container -->
<table width="700" cellpadding="0" cellspacing="0" border="0"
style="background-color:#ffffff; border-radius:8px; overflow:hidden;">
<!-- Header -->
<tr>
<td style="background-color:#b42318; padding:22px 30px;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="font-size:24px; font-weight:bold; color:#ffffff;">
Panel Box Inspection Alert
</div>
<div style="font-size:14px; color:#ffe4e1; margin-top:6px;">
Inspection result: NOT OK
</div>
</td>
<td align="right" style="font-size:28px; color:#ffffff;">
</td>
</tr>
</table>
</td>
</tr>
<!-- Introduction -->
<tr>
<td style="padding:25px 30px 10px 30px;">
<div style="font-size:16px; color:#333333; line-height:1.6;">
A panel box inspection has been marked as
<strong style="color:#b42318;">Not OK</strong>.
Please review the inspection details below.
</div>
</td>
</tr>
<!-- Basic Information -->
<tr>
<td style="padding:15px 30px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0"
style="border:1px solid #e1e5e9; border-radius:6px;">
<tr>
<td colspan="2"
style="background-color:#f8f9fa; padding:12px 15px;
font-size:16px; font-weight:bold; color:#333333;
border-bottom:1px solid #e1e5e9;">
Inspection Details
</td>
</tr>
<tr>
<td width="35%"
style="padding:12px 15px; font-size:14px;
color:#666666; border-bottom:1px solid #eeeeee;">
Plant
</td>
<td
style="padding:12px 15px; font-size:14px;
font-weight:bold; color:#222222;
border-bottom:1px solid #eeeeee;">
{{ $plant }}
</td>
</tr>
<tr>
<td
style="padding:12px 15px; font-size:14px;
color:#666666; border-bottom:1px solid #eeeeee;">
Panel Box Code
</td>
<td
style="padding:12px 15px; font-size:14px;
font-weight:bold; color:#222222;
border-bottom:1px solid #eeeeee;">
{{ $itemCode }}
</td>
</tr>
<tr>
<td
style="padding:12px 15px; font-size:14px;
color:#666666;">
Serial Number
</td>
<td
style="padding:12px 15px; font-size:14px;
font-weight:bold; color:#222222;">
{{ $serialNumber }}
</td>
</tr>
<tr>
<td
style="padding:12px 15px; font-size:14px;
color:#666666;">
Supplier Number
</td>
<td
style="padding:12px 15px; font-size:14px;
font-weight:bold; color:#222222;">
{{ $supplier }}
</td>
</tr>
</table>
</td>
</tr>
<!-- Failed Characteristics -->
<tr>
<td style="padding:15px 30px 25px 30px;">
<div style="font-size:16px; font-weight:bold;
color:#333333; margin-bottom:12px;">
Characteristics
</div>
<table width="100%" cellpadding="0" cellspacing="0" border="0"
style="border-collapse:collapse;">
<thead>
<tr>
<th align="left"
style="background-color:#f8f9fa;
border:1px solid #e1e5e9;
padding:12px;
font-size:13px;
color:#555555;">
S.No
</th>
<th align="left"
style="background-color:#f8f9fa;
border:1px solid #e1e5e9;
padding:12px;
font-size:13px;
color:#555555;">
Characteristic Name
</th>
<th align="left"
style="background-color:#f8f9fa;
border:1px solid #e1e5e9;
padding:12px;
font-size:13px;
color:#555555;">
Spec Value
</th>
<th align="left"
style="background-color:#f8f9fa;
border:1px solid #e1e5e9;
padding:12px;
font-size:13px;
color:#555555;">
Observed Value
</th>
</tr>
</thead>
<tbody>
@foreach(($characteristics ?? []) as $index => $characteristic)
<tr>
<td
style="border:1px solid #e1e5e9;
padding:12px;
font-size:14px;
color:#333333;">
{{ $index + 1 }}
</td>
<td
style="border:1px solid #e1e5e9;
padding:12px;
font-size:14px;
font-weight:bold;
color:#333333;">
{{ $characteristic['characteristic_name'] }}
</td>
<td style="border:1px solid #e1e5e9;
padding:12px;
font-size:14px;
color:#333333;
white-space:nowrap;">
{{ $characteristic['lower'] }}
-
{{ $characteristic['upper'] }}
</td>
<td style="border:1px solid #e1e5e9;
padding:12px;
font-size:14px;
font-weight:bold;
white-space:nowrap;
color:
@if($characteristic['status'] == 'Ok')
#008000
@elseif($characteristic['status'] == 'NotOk')
#b42318
@else
#333333
@endif
;">
{{ $characteristic['observed_value'] }}
</td>
</tr>
@endforeach
</tbody>
</table>
</td>
</tr>
<!-- Alert Message -->
<tr>
<td style="padding:0 30px 25px 30px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0"
style="background-color:#fff4f2;
border-left:4px solid #b42318;">
<tr>
<td style="padding:14px 16px;
font-size:14px;
color:#7a271a;
line-height:1.5;">
<strong>Action Required:</strong>
Please review the above inspection results
and take the necessary corrective action.
</td>
</tr>
</table>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="background-color:#f8f9fa;
padding:18px 30px;
border-top:1px solid #e1e5e9;
text-align:center;">
<div style="font-size:12px; color:#777777;">
This is an automated notification from the
Panel Box Inspection System.
</div>
<div style="font-size:12px; color:#999999; margin-top:5px;">
Please do not reply to this email.
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>