Added line name and employee code for quality validation mail #63

Merged
jothi merged 1 commits from ranjith-dev into master 2025-12-03 05:05:30 +00:00
2 changed files with 77 additions and 19 deletions

View File

@@ -2250,9 +2250,15 @@ class QualityValidationResource extends Resource
$mPlantId = $get('plant_id');
$mlineId = $get('line_id');
$plant = Plant::find($mPlantId);
$plantCodePart1 = $plant?->code;
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
$stickerMasterId = $get('sticker_master_id');
if (!$stickerMasterId) {
return;
@@ -2284,12 +2290,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails))
{
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber')
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber')
);
}
else
@@ -2348,6 +2355,11 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId);
$plantCodePart2 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
$stickerMasterId = $get('sticker_master_id');
if (!$stickerMasterId) {
return;
@@ -2376,12 +2388,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails))
{
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber2')
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber2')
);
}
else
@@ -2441,6 +2454,12 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId);
$plantCodePart3 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (!$stickerMasterId) {
return;
}
@@ -2469,12 +2488,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails))
{
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber3')
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber3')
);
}
else
@@ -2532,6 +2552,11 @@ class QualityValidationResource extends Resource
$plant = Plant::find($mPlantId);
$plantCodePart4 = $plant?->code;
$mlineId = $get('line_id');
$mLine = Line::find($mlineId);
$mLinePart = $mLine?->name;
if (!$stickerMasterId) {
return;
}
@@ -2560,12 +2585,13 @@ class QualityValidationResource extends Resource
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (!empty($emails))
{
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber4')
new InvalidQualityMail($state, $mPorder, $mPlantName,$mLinePart, $mUserName, 'InvalidPartNumber4')
);
}
else
@@ -2679,22 +2705,22 @@ class QualityValidationResource extends Resource
else
{
$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'];
$emails = $mailData['emails'];
// $mPlantName = $mailData['plant_name'];
// $emails = $mailData['emails'];
if (!empty($emails))
{
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
);
}
else
{
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
}
// if (!empty($emails))
// {
// //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
// Mail::to($emails)->send(
// new InvalidQualityMail($state, $mPorder, $mPlantName, 'InvalidPartNumber5')
// );
// }
// else
// {
// \Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
// }
$set('part_validation5', null);
return;
}
@@ -2715,6 +2741,21 @@ class QualityValidationResource extends Resource
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');
$emails = AlertMailRule::where('plant', $plantId)

View File

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