Files
pds/app/Mail/InvalidSerialMail.php
dhanabalan 1905359179
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / review (pull_request) Failing after 30s
Laravel Pint / pint (pull_request) Successful in 2m0s
Laravel Larastan / larastan (pull_request) Failing after 13m13s
removed unwanted mail trigger for invoice validation error mail
2025-12-06 10:08:18 +05:30

172 lines
5.2 KiB
PHP

<?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 InvalidSerialMail extends Mailable
// {
// use Queueable, SerializesModels;
// /**
// * Create a new message instance.
// */
// public $serial;
// public $invoiceNumber;
// public $plantName;
// public $invoiceType;
// public $greetings;
// public function __construct($serial, $invoiceNumber, $plantName, $invoiceType)
// {
// $this->serial = $serial;
// $this->invoiceNumber = $invoiceNumber;
// $this->plantName = $plantName;
// $this->invoiceType = $invoiceType;
// }
// /**
// * Get the message envelope.
// */
// public function envelope(): Envelope
// {
// return new Envelope(
// subject: 'Invalid Serial Mail',
// );
// }
// /**
// * Get the message content definition.
// */
// public function content(): Content
// {
// $greeting = "Dear Sir/Madam,<br><br>Please note that the scanned serial number format appears to be incorrect.";
// return new Content(
// view: 'mail.invalid-serial',
// 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 [];
// }
// }
class InvalidSerialMail extends Mailable
{
use Queueable, SerializesModels;
public $serial;
public $invoiceNumber;
public $mplantName;
public $mInvoiceType;
public $mailType; // new
public $greeting;
public $subjectLine;
public $itemCode;
/**
* Create a new message instance.
*/
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mailType = 'InvalidFormat')
{
$this->serial = $serial;
$this->invoiceNumber = $invoiceNumber;
$this->mplantName = $mplantName;
$this->mInvoiceType = $mInvoiceType;
$this->mailType = $mailType;
$this->itemCode = $itemCode;
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
// dynamic subject based on mail type
switch ($this->mailType) {
case 'NotFoundInvoice':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
case 'DuplicateCapacitorQR':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
case 'ComSerInv':
$this->subjectLine = "Completed Serial Invoice ({$this->mplantName})";
break;
}
return new Envelope(
subject: $this->subjectLine,
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
// dynamic greeting/message body
switch ($this->mailType) {
case 'NotFoundInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
The scanned serial number could not be found in the given invoice.<br><br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'DuplicateCapacitorQR':
$this->greeting = "
Dear Sir/Madam,<br><br>
The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ComSerInv':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
}
return new Content(
view: 'mail.invalid-serial',
with: [
'company' => "CRI Digital Manufacturing Solutions",
'greeting' => $this->greeting,
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions",
],
);
}
}