Merge pull request 'Added jwt qr code scanning functionality for invoice number' (#105) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Reviewed-on: #105
This commit was merged in pull request #105.
This commit is contained in:
@@ -53,6 +53,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
public $excel_file;
|
||||
public $mInvoiceNo;
|
||||
|
||||
public function getFormActions(): array
|
||||
{
|
||||
@@ -103,6 +104,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
$invoiceNumber = trim($invoiceNumber);
|
||||
|
||||
$parts = explode('.', $invoiceNumber);
|
||||
|
||||
$this->showCapacitorInput = false;
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
@@ -118,6 +121,62 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// ..GET SERIAL INVOICE API
|
||||
|
||||
if(strlen($invoiceNumber) > 15)
|
||||
{
|
||||
|
||||
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
|
||||
|
||||
if (empty($payloadJson)) {
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$payload = json_decode($payloadJson, true);
|
||||
|
||||
|
||||
if (!isset($payload['data'])) {
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$documentData = $payload['data'];
|
||||
|
||||
if($documentData == '' || $documentData == ''){
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract DocNo
|
||||
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
|
||||
|
||||
if (!isset($matches[1])) {
|
||||
Notification::make()
|
||||
->title('Invoice number not found.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($matches[1])) {
|
||||
$invoiceNumber = $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
//dd($invoiceNumber);
|
||||
|
||||
// ..
|
||||
|
||||
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
||||
@@ -2742,19 +2801,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$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([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2784,19 +2830,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$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([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2825,19 +2858,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$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([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3381,19 +3401,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$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';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
@@ -3511,20 +3518,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$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';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
@@ -3584,22 +3577,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// $mInvoiceType = 'Serial';
|
||||
// $mailData = $this->getMail();
|
||||
// $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 InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, $mUserName, 'DuplicateCapacitorQR')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
|
||||
Reference in New Issue
Block a user