Added line name and employee code for quality validation mail
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / review (pull_request) Failing after 24s
Laravel Pint / pint (pull_request) Successful in 2m25s
Laravel Larastan / larastan (pull_request) Failing after 3m6s

This commit is contained in:
dhanabalan
2025-12-03 10:35:18 +05:30
parent eb7910c119
commit 154b689daf
2 changed files with 77 additions and 19 deletions

View File

@@ -2250,9 +2250,15 @@ class QualityValidationResource extends Resource
$mPlantId = $get('plant_id'); $mPlantId = $get('plant_id');
$mlineId = $get('line_id');
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart1 = $plant?->code; $plantCodePart1 = $plant?->code;
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
$stickerMasterId = $get('sticker_master_id'); $stickerMasterId = $get('sticker_master_id');
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
@@ -2284,12 +2290,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber') new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber')
); );
} }
else else
@@ -2348,6 +2355,11 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart2 = $plant?->code; $plantCodePart2 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
$stickerMasterId = $get('sticker_master_id'); $stickerMasterId = $get('sticker_master_id');
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
@@ -2376,12 +2388,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber2') new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber2')
); );
} }
else else
@@ -2441,6 +2454,12 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart3 = $plant?->code; $plantCodePart3 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
} }
@@ -2469,12 +2488,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber3') new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber3')
); );
} }
else else
@@ -2532,6 +2552,11 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId); $plant = Plant::find($mPlantId);
$plantCodePart4 = $plant?->code; $plantCodePart4 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (!$stickerMasterId) { if (!$stickerMasterId) {
return; return;
} }
@@ -2560,12 +2585,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails)) if (!empty($emails))
{ {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber4') new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber4')
); );
} }
else else
@@ -2679,22 +2705,22 @@ class QualityValidationResource extends Resource
else else
{ {
$set('part_validation5_error', "Invalid input for part validation 5."); $set('part_validation5_error', "Invalid input for part validation 5.");
$mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId); // $mailData = \App\Filament\Resources\QualityValidationResource::getMailData($mPlantId);
$mPlantName = $mailData['plant_name']; // $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; // $emails = $mailData['emails'];
if (!empty($emails)) // if (!empty($emails))
{ // {
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); // //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( // Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5') // new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
); // );
} // }
else // else
{ // {
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial."); // \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
} // }
$set('part_validation5', null); $set('part_validation5', null);
return; return;
} }
@@ -2715,6 +2741,21 @@ class QualityValidationResource extends Resource
public static function getMailData($plantId) public static function getMailData($plantId)
{ {
$globalEmails = AlertMailRule::where('plant', 0)
->where('module', 'QualityValidation')
->where('rule_name', 'QualityMail')
->where(fn ($q) => $q->whereNull('schedule_type')->orWhere('schedule_type', ''))
->pluck('email')
->toArray();
if (!empty($globalEmails)) {
return [
'plant_id' => 0,
'plant_name' => 'All Plants',
'emails' => $globalEmails,
];
}
$mPlantName = Plant::where('id', $plantId)->value('name'); $mPlantName = Plant::where('id', $plantId)->value('name');
$emails = AlertMailRule::where('plant', $plantId) $emails = AlertMailRule::where('plant', $plantId)

View File

@@ -20,17 +20,24 @@ class InvalidQualityMail extends Mailable
public $invoiceNumber; public $invoiceNumber;
public $mplantName; public $mplantName;
public $mProdOrder; public $mProdOrder;
public $mUserName;
public $mPartNo; public $mPartNo;
public $mailType; public $mailType;
public $greeting; public $greeting;
public $subjectLine; public $subjectLine;
public $mLinePart;
public $itemCode; public $itemCode;
public function __construct($parNo, $mProdOrder, $mplantName, $mailType = 'InvalidPartNumber') public function __construct($parNo, $mProdOrder, $mplantName, $mLinePart, $mUserName, $mailType = 'InvalidPartNumber')
{ {
$this->mPartNo = $parNo; $this->mPartNo = $parNo;
$this->mProdOrder = $mProdOrder; $this->mProdOrder = $mProdOrder;
$this->mplantName = $mplantName; $this->mplantName = $mplantName;
$this->mLinePart = $mLinePart;
$this->mUserName = $mUserName;
$this->mailType = $mailType; $this->mailType = $mailType;
} }
@@ -70,8 +77,10 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 2:</b> {$this->mPartNo}<br> <b>Scanned Part Number 2:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber3': case 'InvalidPartNumber3':
@@ -79,8 +88,10 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 3:</b> {$this->mPartNo}<br> <b>Scanned Part Number 3:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber4': case 'InvalidPartNumber4':
@@ -88,8 +99,10 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 4:</b> {$this->mPartNo}<br> <b>Scanned Part Number 4:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber5': case 'InvalidPartNumber5':
@@ -97,8 +110,10 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 5:</b> {$this->mPartNo}<br> <b>Scanned Part Number 5:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'InvalidPartNumber': case 'InvalidPartNumber':
@@ -107,8 +122,10 @@ class InvalidQualityMail extends Mailable
Dear Sir/Madam,<br><br> Dear Sir/Madam,<br><br>
Please note that the scanned part number appears to be incorrect.<br> Please note that the scanned part number appears to be incorrect.<br>
<b>Plant:</b> {$this->mplantName}<br> <b>Plant:</b> {$this->mplantName}<br>
<b>Line Name:</b> {$this->mLinePart}<br>
<b>Production Order:</b> {$this->mProdOrder}<br> <b>Production Order:</b> {$this->mProdOrder}<br>
<b>Scanned Part Number 1:</b> {$this->mPartNo}<br> <b>Scanned Part Number 1:</b> {$this->mPartNo}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
} }