Add email notification for invalid serial numbers in processSerialNumber method
This commit is contained in:
@@ -20,6 +20,10 @@ use Illuminate\Support\Collection;
|
|||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
use Str;
|
use Str;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use App\Mail\InvalidSerialMail;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Models\AlertMailRule;
|
||||||
|
|
||||||
class CreateInvoiceValidation extends CreateRecord
|
class CreateInvoiceValidation extends CreateRecord
|
||||||
{
|
{
|
||||||
@@ -2300,9 +2304,34 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processSerialNumber($serNo)
|
public function getMail(){
|
||||||
{
|
$plantId = $this->form->getState()['plant_id'];
|
||||||
|
$this->plantId = $plantId;
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mPlantName = Plant::where('id', $plantId)->value('name');
|
||||||
|
$emails = AlertMailRule::where('plant', $plantId)
|
||||||
|
//->where('plant', $plantName)
|
||||||
|
->where('module', 'InvoiceValidation')
|
||||||
|
->where('rule_name', 'InvoiceMail')
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->whereNull('schedule_type')
|
||||||
|
->orWhere('schedule_type', '');
|
||||||
|
})
|
||||||
|
->pluck('email')
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'plant_name' => $mPlantName,
|
||||||
|
'invoice_type' => $mInvoiceType,
|
||||||
|
'emails' => $emails,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processSerialNumber($serNo)
|
||||||
|
{
|
||||||
$serNo = trim($serNo);
|
$serNo = trim($serNo);
|
||||||
|
$mSerNo = $serNo;
|
||||||
$user = Filament::auth()->user();
|
$user = Filament::auth()->user();
|
||||||
$operatorName = $user->name;
|
$operatorName = $user->name;
|
||||||
|
|
||||||
@@ -2412,6 +2441,24 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
//.Mail
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2432,6 +2479,26 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
|
||||||
|
//.Mail
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2452,6 +2519,26 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
|
||||||
|
//.Mail
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
//Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2478,6 +2565,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
//.Mail
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
@@ -2499,6 +2603,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2526,6 +2646,24 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
//.Mail
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2545,6 +2683,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
//.Mail
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
@@ -2556,7 +2711,8 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$itemCode = null;
|
$itemCode = null;
|
||||||
$this->currentItemCode = '';
|
$this->currentItemCode = '';
|
||||||
$batchNumber = null;
|
$batchNumber = null;
|
||||||
@@ -2572,6 +2728,25 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
|
||||||
|
//.Mail
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2597,6 +2772,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFound')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2621,6 +2812,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFoundDB')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2644,6 +2851,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotValidMaterialType')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2671,6 +2894,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotInvoice')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2698,6 +2938,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
$mInvoiceType = 'Material';
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'Item')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -2958,7 +3214,8 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?$/', $serNo, $matches)) {
|
///^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/
|
||||||
|
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $serNo, $matches)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Invalid Serial QR Format')
|
->title('Invalid Serial QR Format')
|
||||||
@@ -2966,7 +3223,27 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
//..Mail
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, 'InvalidFormat')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
@@ -2980,7 +3257,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
//'/^([a-zA-Z0-9]+)\|([a-zA-Z0-9]+(?:\/[MmPpCc]?)?)$/'
|
//'/^([a-zA-Z0-9]+)\|([a-zA-Z0-9]+(?:\/[MmPpCc]?)?)$/'
|
||||||
if (preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?$/', $serNo, $matches))
|
if (preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $serNo, $matches))
|
||||||
{
|
{
|
||||||
$itemCode = $matches[1];
|
$itemCode = $matches[1];
|
||||||
$serialNumber = $matches[2];
|
$serialNumber = $matches[2];
|
||||||
@@ -2989,9 +3266,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
// $isMarkM = preg_match('/\/[Mm]$/', $serialNumber);
|
// $isMarkM = preg_match('/\/[Mm]$/', $serialNumber);
|
||||||
// $isMarkP = preg_match('/\/[Pp]$/', $serialNumber);
|
// $isMarkP = preg_match('/\/[Pp]$/', $serialNumber);
|
||||||
// $isMarkC = preg_match('/\/[Cc]$/', $serialNumber);
|
// $isMarkC = preg_match('/\/[Cc]$/', $serialNumber);
|
||||||
$isMarkM = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Mm]?$/', $serNo) ? true : false;
|
$isMarkM = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Mm]?\|?$/', $serNo) ? true : false;
|
||||||
$isMarkP = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Pp]?$/', $serNo) ? true : false;
|
$isMarkP = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Pp]?\|?$/', $serNo) ? true : false;
|
||||||
$isMarkC = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Cc]?$/', $serNo) ? true : false;
|
$isMarkC = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Cc]?\|?$/', $serNo) ? true : false;
|
||||||
$isMarkPs = (!$isMarkM && !$isMarkP && !$isMarkC) ? true : false;
|
$isMarkPs = (!$isMarkM && !$isMarkP && !$isMarkC) ? true : false;
|
||||||
//dd($serialNumber, $isMarkM, $isMarkP, $isMarkC, $isMarkPs);
|
//dd($serialNumber, $isMarkM, $isMarkP, $isMarkC, $isMarkPs);
|
||||||
|
|
||||||
@@ -3009,6 +3286,26 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('play-warn-sound');
|
$this->dispatch('play-warn-sound');
|
||||||
|
|
||||||
|
//..Mail
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFound')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//..
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3033,6 +3330,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
//.Mail
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundInvoice')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3061,6 +3375,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotFoundItemS')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3100,6 +3430,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotValidPackage')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3121,7 +3467,21 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotMotorQR')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
@@ -3144,6 +3504,24 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
//..Mail
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateMotorQR')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3208,6 +3586,22 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playNotificationSound');
|
$this->dispatch('playNotificationSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$mPlantName = $mailData['plant_name'];
|
||||||
|
$emails = $mailData['emails'];
|
||||||
|
|
||||||
|
if (!empty($emails))
|
||||||
|
{
|
||||||
|
Mail::to($emails)->send(
|
||||||
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'CompletedSerialInvoice')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$filename = $invoiceNumber . '.xlsx';
|
$filename = $invoiceNumber . '.xlsx';
|
||||||
$directory = 'uploads/temp';
|
$directory = 'uploads/temp';
|
||||||
@@ -3239,6 +3633,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotPumpQR')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3259,6 +3670,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'DuplicatePumpQR')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3324,6 +3752,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playNotificationSound');
|
$this->dispatch('playNotificationSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'CSerialInvoice')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$filename = $invoiceNumber . '.xlsx';
|
$filename = $invoiceNumber . '.xlsx';
|
||||||
$directory = 'uploads/temp';
|
$directory = 'uploads/temp';
|
||||||
$disk = Storage::disk('local');
|
$disk = Storage::disk('local');
|
||||||
@@ -3356,6 +3801,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'MissingPanelBox')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3377,6 +3839,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'DuplicateCapacitorQR')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3419,6 +3898,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'UnknownPumpsetQR')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3440,6 +3936,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'DuplicatePumpsetQR')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'invoice_number' => $invoiceNumber,
|
'invoice_number' => $invoiceNumber,
|
||||||
@@ -3505,6 +4018,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playNotificationSound');
|
$this->dispatch('playNotificationSound');
|
||||||
|
|
||||||
|
$mInvoiceType = 'Serial';
|
||||||
|
$mailData = $this->getMail();
|
||||||
|
$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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'ComSerInv')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
}
|
||||||
|
|
||||||
$filename = $invoiceNumber . '.xlsx';
|
$filename = $invoiceNumber . '.xlsx';
|
||||||
$directory = 'uploads/temp';
|
$directory = 'uploads/temp';
|
||||||
$disk = Storage::disk('local');
|
$disk = Storage::disk('local');
|
||||||
|
|||||||
Reference in New Issue
Block a user