Compare commits
87 Commits
renovate/l
...
e45c166345
| Author | SHA1 | Date | |
|---|---|---|---|
| e45c166345 | |||
|
|
b66216bb90 | ||
| d53d3dedbb | |||
|
|
397bddf8d5 | ||
| 18e74f4a52 | |||
|
|
34465a4adf | ||
| 16c525773b | |||
|
|
cd4028abd3 | ||
| 501cd541b9 | |||
|
|
21e625e740 | ||
| 62e14fb3c3 | |||
|
|
922e76448c | ||
| 78f4929e27 | |||
|
|
755f4e5962 | ||
| b674966886 | |||
|
|
c42d822dc4 | ||
| 103515a387 | |||
|
|
36eea799ce | ||
| dd182c6504 | |||
|
|
8846df986a | ||
| 1fed559feb | |||
|
|
52ac6157bc | ||
| 312de66a1c | |||
|
|
2e2c3f6f18 | ||
| 7d8a891f95 | |||
|
|
814decda50 | ||
| 557c367f4c | |||
|
|
a8261cf0e6 | ||
| cef3e17dc7 | |||
|
|
1817876af5 | ||
| f89ad49eff | |||
|
|
29a0e480f4 | ||
| c9006ee0a1 | |||
|
|
05436f278b | ||
| 2fa58b587e | |||
|
|
3b709c1dc6 | ||
| bb0a684366 | |||
|
|
0b45d970b6 | ||
| 16b1802412 | |||
|
|
cd29fd51b7 | ||
| 079ed2eba6 | |||
|
|
8aacff18be | ||
| f1f6b596a4 | |||
|
|
e971ec102f | ||
| b2aa572994 | |||
|
|
4c9f507d50 | ||
| 44bdcba615 | |||
|
|
d286b5e40d | ||
| 76a5379c02 | |||
|
|
d04e118bf6 | ||
| eeeec722ee | |||
|
|
58191aada6 | ||
| d8a4ddf6e9 | |||
|
|
7e96c3cdbf | ||
| 9493bf5edf | |||
|
|
98cafeb5af | ||
| feab063017 | |||
|
|
d9319b1ec6 | ||
| b2f5194ef9 | |||
|
|
8cb5f5c251 | ||
| 3a3322ccc4 | |||
|
|
ad143d723a | ||
| 7a9dac239d | |||
|
|
d41371a32d | ||
| 77d98b16fb | |||
|
|
9c23fb3aca | ||
| a2554fb4a9 | |||
|
|
6a13a79610 | ||
| 353774b184 | |||
|
|
8e1238e719 | ||
| 29fecaea3d | |||
|
|
88346b9ad8 | ||
| a35185e4b1 | |||
|
|
e4b39c5b52 | ||
| f07ba9dd00 | |||
|
|
771e9351db | ||
| 2a7f48cc75 | |||
|
|
8032d5e549 | ||
| c7f4f49669 | |||
|
|
cf7e0294c4 | ||
| 2e9a52a890 | |||
|
|
76afd15b3b | ||
| 3c34495048 | |||
|
|
3788f4cd18 | ||
| b70907cb9f | |||
|
|
7dd9f43940 | ||
|
|
b089ddd75c |
@@ -39,6 +39,8 @@ class Scheduler extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// $this->call('approval:trigger-mails');
|
||||||
|
|
||||||
// --- Production Rules ---
|
// --- Production Rules ---
|
||||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
->where('rule_name', 'ProductionMail')
|
->where('rule_name', 'ProductionMail')
|
||||||
@@ -74,7 +76,6 @@ class Scheduler extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --- Invoice Validation Rules ---
|
// --- Invoice Validation Rules ---
|
||||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||||
->where('rule_name', 'InvoiceMail')
|
->where('rule_name', 'InvoiceMail')
|
||||||
@@ -174,7 +175,7 @@ class Scheduler extends Command
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Daily':
|
case 'Daily':
|
||||||
if (now()->format('H:i') == '10:00') {
|
if (now()->format('H:i') == '11:30') {
|
||||||
\Artisan::call('send:invoice-data-report', [
|
\Artisan::call('send:invoice-data-report', [
|
||||||
'schedule_type' => $rule->schedule_type,
|
'schedule_type' => $rule->schedule_type,
|
||||||
'plant' => $rule->plant,
|
'plant' => $rule->plant,
|
||||||
@@ -209,11 +210,25 @@ class Scheduler extends Command
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Daily':
|
case 'Daily':
|
||||||
if (now()->format('H:i') == '10:00') {
|
if (now()->format('H:i') == '10:45') {
|
||||||
\Artisan::call('send:invoice-transit-report', [
|
try {
|
||||||
'schedule_type' => $rule->schedule_type,
|
\Artisan::call('send:invoice-transit-report', [
|
||||||
'plant' => $rule->plant,
|
'schedule_type' => $rule->schedule_type,
|
||||||
]);
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Log::info('Invoice Transit executed', [
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
'type' => $rule->schedule_type,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (\Throwable $e) {
|
||||||
|
Log::error('Invoice Transit FAILED', [
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,8 @@ use App\Mail\InvoiceDataMail;
|
|||||||
use App\Models\AlertMailRule;
|
use App\Models\AlertMailRule;
|
||||||
use App\Models\InvoiceDataValidation;
|
use App\Models\InvoiceDataValidation;
|
||||||
use App\Models\InvoiceOutValidation;
|
use App\Models\InvoiceOutValidation;
|
||||||
use App\Models\Line;
|
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionPlan;
|
|
||||||
use App\Models\ProductionQuantity;
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
|
|
||||||
class SendInvoiceDataReport extends Command
|
class SendInvoiceDataReport extends Command
|
||||||
{
|
{
|
||||||
@@ -49,7 +45,7 @@ class SendInvoiceDataReport extends Command
|
|||||||
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
|
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
|
||||||
|
|
||||||
if ($plants->isEmpty()) {
|
if ($plants->isEmpty()) {
|
||||||
$this->error("No valid plant(s) found.");
|
$this->error('No valid plant(s) found.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +101,7 @@ class SendInvoiceDataReport extends Command
|
|||||||
->where('distribution_channel_desc', $selectedDistribution)
|
->where('distribution_channel_desc', $selectedDistribution)
|
||||||
->whereBetween('document_date', [$startDate, $endDate])
|
->whereBetween('document_date', [$startDate, $endDate])
|
||||||
->orderBy('document_date', 'asc')
|
->orderBy('document_date', 'asc')
|
||||||
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location')
|
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location', 'remark')
|
||||||
->get()
|
->get()
|
||||||
->unique('document_number')
|
->unique('document_number')
|
||||||
->values();
|
->values();
|
||||||
@@ -114,7 +110,6 @@ class SendInvoiceDataReport extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter invoices directly — exclude ones with '-' in document_number
|
|
||||||
$invoices = $invoices->filter(function ($inv) {
|
$invoices = $invoices->filter(function ($inv) {
|
||||||
return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
|
return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
|
||||||
});
|
});
|
||||||
@@ -134,7 +129,6 @@ class SendInvoiceDataReport extends Command
|
|||||||
->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n)))
|
->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n)))
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
//where('plant_id', $plant->id)
|
|
||||||
$wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
$wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||||
//->whereBetween('scanned_at', [$startDate, $endDate])
|
//->whereBetween('scanned_at', [$startDate, $endDate])
|
||||||
->distinct('qr_code')
|
->distinct('qr_code')
|
||||||
@@ -164,7 +158,6 @@ class SendInvoiceDataReport extends Command
|
|||||||
return !in_array($doc, $wentOutInvoices, true);
|
return !in_array($doc, $wentOutInvoices, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if ($pendingInvoices->isEmpty()) {
|
if ($pendingInvoices->isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -182,7 +175,7 @@ class SendInvoiceDataReport extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$tableData[] = [
|
$tableData[] = [
|
||||||
//'no' => $no++,
|
// 'no' => $no++,
|
||||||
'plant' => $plant->name,
|
'plant' => $plant->name,
|
||||||
// 'distribution_type' => $selectedDistribution,
|
// 'distribution_type' => $selectedDistribution,
|
||||||
'customer_code' => $inv->customer_code,
|
'customer_code' => $inv->customer_code,
|
||||||
@@ -194,6 +187,7 @@ class SendInvoiceDataReport extends Command
|
|||||||
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
|
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
|
||||||
'status' => 'Pending',
|
'status' => 'Pending',
|
||||||
'status_class' => $statusColor,
|
'status_class' => $statusColor,
|
||||||
|
'remark' => $inv->remark,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,6 +197,7 @@ class SendInvoiceDataReport extends Command
|
|||||||
->values()
|
->values()
|
||||||
->map(function ($item, $index) {
|
->map(function ($item, $index) {
|
||||||
$item['no'] = $index + 1;
|
$item['no'] = $index + 1;
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
@@ -214,7 +209,7 @@ class SendInvoiceDataReport extends Command
|
|||||||
|
|
||||||
$this->info($contentVars['greeting'] ?? 'Invoice Data Report');
|
$this->info($contentVars['greeting'] ?? 'Invoice Data Report');
|
||||||
$this->table(
|
$this->table(
|
||||||
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status'],//'Distribution Type'
|
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status', 'Remark'],// 'Distribution Type'
|
||||||
$tableData
|
$tableData
|
||||||
);
|
);
|
||||||
$this->info($contentVars['wishes'] ?? '');
|
$this->info($contentVars['wishes'] ?? '');
|
||||||
@@ -236,13 +231,13 @@ class SendInvoiceDataReport extends Command
|
|||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
if (empty($toEmails)) {
|
if (empty($toEmails)) {
|
||||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
$this->info("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||||
|
|
||||||
$this->info("Mail sent for rule ID {$rule->id} → To: " . implode(', ', $toEmails) . ($ccEmails ? " | CC: " . implode(', ', $ccEmails) : ''));
|
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class SendInvoiceReport extends Command
|
|||||||
$scannedSerialCount = InvoiceValidation::select('invoice_number')
|
$scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->whereNull('quantity')
|
->whereNull('quantity')
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||||
->count();
|
->count();
|
||||||
@@ -86,7 +86,7 @@ class SendInvoiceReport extends Command
|
|||||||
$query->whereNull('quantity')
|
$query->whereNull('quantity')
|
||||||
->orWhere('quantity', 0);
|
->orWhere('quantity', 0);
|
||||||
})
|
})
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$serialTableData[] = [
|
$serialTableData[] = [
|
||||||
@@ -108,7 +108,7 @@ class SendInvoiceReport extends Command
|
|||||||
$scannedMatCount = InvoiceValidation::select('invoice_number')
|
$scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->where('quantity', 1)
|
->where('quantity', 1)
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||||
->count();
|
->count();
|
||||||
@@ -122,7 +122,7 @@ class SendInvoiceReport extends Command
|
|||||||
->where('quantity', 1)
|
->where('quantity', 1)
|
||||||
->whereNotNull('serial_number')
|
->whereNotNull('serial_number')
|
||||||
->where('serial_number', '!=', '')
|
->where('serial_number', '!=', '')
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$materialTableData[] = [
|
$materialTableData[] = [
|
||||||
@@ -144,7 +144,7 @@ class SendInvoiceReport extends Command
|
|||||||
$scannedBundleCount = InvoiceValidation::select('invoice_number')
|
$scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->where('quantity', '>', 1)
|
->where('quantity', '>', 1)
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||||
->count();
|
->count();
|
||||||
@@ -158,7 +158,7 @@ class SendInvoiceReport extends Command
|
|||||||
->where('quantity', '>', 1)
|
->where('quantity', '>', 1)
|
||||||
->whereNotNull('serial_number')
|
->whereNotNull('serial_number')
|
||||||
->where('serial_number', '!=', '')
|
->where('serial_number', '!=', '')
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$bundleTableData[] = [
|
$bundleTableData[] = [
|
||||||
@@ -180,25 +180,104 @@ class SendInvoiceReport extends Command
|
|||||||
|
|
||||||
// Send to SerialInvoiceMail recipients
|
// Send to SerialInvoiceMail recipients
|
||||||
if ($mailRules->has('SerialInvoiceMail')) {
|
if ($mailRules->has('SerialInvoiceMail')) {
|
||||||
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||||
foreach ($emails as $email) {
|
// foreach ($emails as $email) {
|
||||||
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
// Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
||||||
|
// }
|
||||||
|
foreach ($mailRules->get('SerialInvoiceMail') as $rule) {
|
||||||
|
|
||||||
|
$toEmails = collect(explode(',', $rule->email))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
if (empty($toEmails)) {
|
||||||
|
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
||||||
|
|
||||||
|
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||||
foreach ($emails as $email) {
|
// foreach ($emails as $email) {
|
||||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||||
|
// }
|
||||||
|
foreach ($mailRules->get('MaterialInvoiceMail') as $rule) {
|
||||||
|
|
||||||
|
$toEmails = collect(explode(',', $rule->email))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
if (empty($toEmails)) {
|
||||||
|
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
\Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||||
|
|
||||||
|
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send to InvoiceMail recipients (all three tables)
|
// Send to InvoiceMail recipients (all three tables)
|
||||||
if ($mailRules->has('InvoiceMail')) {
|
if ($mailRules->has('InvoiceMail')) {
|
||||||
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
//$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||||
foreach ($emails as $email) {
|
// foreach ($emails as $email) {
|
||||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||||
|
// $this->info("✅ Sent InvoiceMail to: {$email}");
|
||||||
|
// }
|
||||||
|
foreach ($mailRules->get('InvoiceMail') as $rule) {
|
||||||
|
|
||||||
|
$toEmails = collect(explode(',', $rule->email))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||||
|
->map(fn ($e) => trim($e))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
if (empty($toEmails)) {
|
||||||
|
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||||
|
|
||||||
|
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,5 +292,6 @@ class SendInvoiceReport extends Command
|
|||||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||||
|
|
||||||
$this->info($contentVars['wishes'] ?? '');
|
$this->info($contentVars['wishes'] ?? '');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
48
app/Exports/InvoicePendingReasonExport.php
Normal file
48
app/Exports/InvoicePendingReasonExport.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromArray;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class InvoicePendingReasonExport implements FromArray, WithHeadings, WithMapping
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Support\Collection
|
||||||
|
*/
|
||||||
|
protected array $data;
|
||||||
|
|
||||||
|
public function __construct(array $data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function array(): array
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Plant Code',
|
||||||
|
'Document Number',
|
||||||
|
'Remark',
|
||||||
|
'Customer Trade Name',
|
||||||
|
'Location',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row['plant_id'] ?? '',
|
||||||
|
$row['document_number'] ?? '',
|
||||||
|
$row['remark'] ?? '',
|
||||||
|
$row['customer_trade_name'] ?? '',
|
||||||
|
$row['location'] ?? '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
231
app/Filament/Pages/InvoicePendingReason.php
Normal file
231
app/Filament/Pages/InvoicePendingReason.php
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use App\Models\InvoiceDataValidation;
|
||||||
|
use App\Models\InvoiceOutValidation;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Filament\Pages\Page;
|
||||||
|
use Filament\Forms\Contracts\HasForms;
|
||||||
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class InvoicePendingReason extends Page
|
||||||
|
{
|
||||||
|
use HasFiltersForm;
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||||
|
|
||||||
|
protected static string $view = 'filament.pages.invoice-pending-reason';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
$this->filtersForm->fill([
|
||||||
|
'plant_id' => null,
|
||||||
|
'document_number' => null,
|
||||||
|
'remark' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function filtersForm(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->statePath('filters')
|
||||||
|
->schema([
|
||||||
|
|
||||||
|
Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
|
->reactive()
|
||||||
|
->required()
|
||||||
|
->columnSpan(1)
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, $set, callable $get,$livewire) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$set('document_number', null);
|
||||||
|
$set('customer_trade_name', null);
|
||||||
|
$set('location', null);
|
||||||
|
})
|
||||||
|
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
|
|
||||||
|
Select::make('document_number')
|
||||||
|
->label('Document Number')
|
||||||
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->columnSpan(1)
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$distributions = InvoiceDataValidation::whereNotNull('distribution_channel_desc')
|
||||||
|
->distinct()
|
||||||
|
->pluck('distribution_channel_desc')
|
||||||
|
->filter(fn ($v) => trim($v) !== '')
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$distributions[] = '';
|
||||||
|
|
||||||
|
$pendingInvoices = collect();
|
||||||
|
|
||||||
|
foreach ($distributions as $distribution) {
|
||||||
|
|
||||||
|
$invoices = InvoiceDataValidation::where('plant_id', $plantId)
|
||||||
|
->where('distribution_channel_desc', $distribution)
|
||||||
|
->select('id', 'document_number')
|
||||||
|
->get()
|
||||||
|
->unique('document_number')
|
||||||
|
->filter(fn ($inv) =>
|
||||||
|
! empty($inv->document_number) &&
|
||||||
|
! str_contains($inv->document_number, '-')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (trim($distribution) == '') {
|
||||||
|
$invoices = $invoices->filter(fn ($inv) =>
|
||||||
|
str_starts_with($inv->document_number, '7')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($invoices->isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoiceNumbers = $invoices->pluck('document_number')
|
||||||
|
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$wentOut = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||||
|
->distinct()
|
||||||
|
->pluck('qr_code')
|
||||||
|
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$pending = $invoices->filter(function ($inv) use ($wentOut) {
|
||||||
|
$doc = preg_replace('/\s+/', '', strtoupper($inv->document_number));
|
||||||
|
return ! in_array($doc, $wentOut, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
$pendingInvoices = $pendingInvoices->merge($pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pendingInvoices
|
||||||
|
->unique('document_number')
|
||||||
|
->pluck('document_number', 'document_number')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$documentNumber = $get('document_number');
|
||||||
|
|
||||||
|
$customers = InvoiceDataValidation::where('plant_id', $plantId)
|
||||||
|
->where('document_number', $documentNumber)
|
||||||
|
->value('customer_trade_name');
|
||||||
|
|
||||||
|
$location = InvoiceDataValidation::where('plant_id', $plantId)
|
||||||
|
->where('document_number', $documentNumber)
|
||||||
|
->value('location');
|
||||||
|
|
||||||
|
$set('customer_trade_name', $customers);
|
||||||
|
$set('location', $location);
|
||||||
|
})
|
||||||
|
->extraAttributes(fn ($get) => [
|
||||||
|
'class' => $get('pqBlockError') ? 'border-red-500' : '',
|
||||||
|
])
|
||||||
|
->hint(fn ($get) => $get('pqBlockError') ? $get('pqBlockError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
|
TextInput::make('customer_trade_name')
|
||||||
|
->label('Customer Trade Name')
|
||||||
|
->required()
|
||||||
|
->readOnly()
|
||||||
|
->reactive()
|
||||||
|
->columnSpan(1),
|
||||||
|
TextInput::make('location')
|
||||||
|
->label('Location')
|
||||||
|
->required()
|
||||||
|
->readOnly()
|
||||||
|
->reactive()
|
||||||
|
->columnSpan(1),
|
||||||
|
TextInput::make('remark')
|
||||||
|
->label('Remark')
|
||||||
|
->reactive()
|
||||||
|
->maxLength(40)
|
||||||
|
->helperText('Max 40 characters allowed.')
|
||||||
|
->extraAttributes([
|
||||||
|
'wire:keydown.enter.prevent' => 'addRemark($event.target.value)',
|
||||||
|
])
|
||||||
|
->autofocus()
|
||||||
|
->required(),
|
||||||
|
])
|
||||||
|
->columns(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRemark(){
|
||||||
|
$plantId = $this->filters['plant_id'] ?? null;
|
||||||
|
$documentNumber = $this->filters['document_number'] ?? null;
|
||||||
|
$remark = $this->filters['remark'] ?? null;
|
||||||
|
|
||||||
|
if (! $plantId) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Plant')
|
||||||
|
->body("please select plant first..!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (! $documentNumber) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Document Number')
|
||||||
|
->body("please select document number..!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($remark == '') {
|
||||||
|
Notification::make()
|
||||||
|
->title('Remark')
|
||||||
|
->body("Remark can't be empty..!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InvoiceDataValidation::where('plant_id', $plantId)
|
||||||
|
->where('document_number', $documentNumber)
|
||||||
|
->update([
|
||||||
|
'remark' => $remark,
|
||||||
|
'updated_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->filtersForm->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'document_number' => $documentNumber,
|
||||||
|
'remark' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('Remark updated successfully')
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canAccess(): bool
|
||||||
|
{
|
||||||
|
return Auth::check() && Auth::user()->can('view invoice pending reason');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,8 @@ class InvoiceDataValidationResource extends Resource
|
|||||||
Forms\Components\TextInput::make('location')
|
Forms\Components\TextInput::make('location')
|
||||||
->label('Location')
|
->label('Location')
|
||||||
->required(),
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('remark')
|
||||||
|
->label('Remark'),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->label('Created By')
|
->label('Created By')
|
||||||
->default(Filament::auth()->user()?->name),
|
->default(Filament::auth()->user()?->name),
|
||||||
@@ -123,6 +125,11 @@ class InvoiceDataValidationResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('remark')
|
||||||
|
->label('Remark')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
@@ -398,122 +398,104 @@ class InvoiceOutValidationResource extends Resource
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
$successCount = 0;
|
$successCount = 0;
|
||||||
|
$updateCount = 0;
|
||||||
|
$insertCount = 0;
|
||||||
$failedRecords = [];
|
$failedRecords = [];
|
||||||
|
|
||||||
DB::beginTransaction();
|
foreach ($rows as $index => $row)
|
||||||
|
{
|
||||||
try {
|
if ($index == 0) {
|
||||||
foreach ($rows as $index => $row) {
|
continue;
|
||||||
if ($index == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rowNumber = $index + 1;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$qrcode = trim($row[1]);
|
|
||||||
$plantCode = trim($row[2]);
|
|
||||||
$scannedAt = trim($row[3]);
|
|
||||||
$scannedBy = trim($row[4]);
|
|
||||||
|
|
||||||
if (empty($qrcode)) {
|
|
||||||
throw new \Exception("Row '{$rowNumber}' Missing QR Code");
|
|
||||||
}
|
|
||||||
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
|
||||||
if (! $plant) {
|
|
||||||
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
$formattedDate = null;
|
|
||||||
if (! empty($scannedAt)) {
|
|
||||||
try {
|
|
||||||
// $formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
|
||||||
// ->format('Y-m-d H:i:s');
|
|
||||||
if (is_numeric($scannedAt)) {
|
|
||||||
$formattedDate = ExcelDate::excelToDateTimeObject($scannedAt)
|
|
||||||
->format('Y-m-d H:i:s');
|
|
||||||
} else {
|
|
||||||
// Or handle as manual string date (d-m-Y H:i:s)
|
|
||||||
$formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
|
||||||
->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
throw new \Exception("Invalid date format : '{$scannedAt}'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$record = InvoiceOutValidation::where('plant_id', $plant->id)
|
|
||||||
->where('qr_code', $qrcode)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$curStat = $record ? 'Updation' : 'Insertion';
|
|
||||||
|
|
||||||
if ($record) {
|
|
||||||
$record->update([
|
|
||||||
'scanned_at' => $formattedDate,
|
|
||||||
'scanned_by' => $scannedBy,
|
|
||||||
'updated_by' => $operatorName,
|
|
||||||
]);
|
|
||||||
$inserted = $record;
|
|
||||||
} else {
|
|
||||||
// Record does not exist, create with 'created_by'
|
|
||||||
$inserted = InvoiceOutValidation::create([
|
|
||||||
'plant_id' => $plant->id,
|
|
||||||
'qr_code' => $qrcode,
|
|
||||||
'scanned_at' => $formattedDate,
|
|
||||||
'scanned_by' => $scannedBy,
|
|
||||||
'created_by' => $operatorName,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
// $inserted = InvoiceOutValidation::create([
|
|
||||||
// 'plant_id' => $plant->id,
|
|
||||||
// 'qr_code' => $qrcode,
|
|
||||||
// 'scanned_at' => $formattedDate,
|
|
||||||
// 'scanned_by' => $scannedBy,
|
|
||||||
// 'created_by' => $operatorName
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
if (! $inserted) {
|
|
||||||
throw new \Exception("{$curStat} failed for QR : {$qrcode}");
|
|
||||||
}
|
|
||||||
|
|
||||||
$successCount++;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$failedRecords[] = [
|
|
||||||
'row' => $rowNumber,
|
|
||||||
'qrcode' => $qrcode ?? null,
|
|
||||||
'error' => $e->getMessage(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::commit();
|
$rowNumber = $index + 1;
|
||||||
|
|
||||||
if (count($failedRecords) > 0) {
|
try {
|
||||||
|
$qrcode = trim($row[1]);
|
||||||
|
$plantCode = trim($row[2]);
|
||||||
|
$scannedAt = trim($row[3]);
|
||||||
|
$scannedBy = trim($row[4]);
|
||||||
|
|
||||||
|
if (empty($qrcode)) {
|
||||||
|
throw new \Exception("Row '{$rowNumber}' Missing QR Code");
|
||||||
|
}
|
||||||
|
|
||||||
|
$plant = Plant::where('code', $plantCode)->first();
|
||||||
|
if (! $plant) {
|
||||||
|
throw new \Exception("Invalid plant code : '{$plantCode}'");
|
||||||
|
}
|
||||||
|
|
||||||
|
$formattedDate = null;
|
||||||
|
if (! empty($scannedAt)) {
|
||||||
|
try {
|
||||||
|
// $formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
||||||
|
// ->format('Y-m-d H:i:s');
|
||||||
|
if (is_numeric($scannedAt)) {
|
||||||
|
$formattedDate = ExcelDate::excelToDateTimeObject($scannedAt)
|
||||||
|
->format('Y-m-d H:i:s');
|
||||||
|
} else {
|
||||||
|
// Or handle as manual string date (d-m-Y H:i:s)
|
||||||
|
$formattedDate = Carbon::createFromFormat('d-m-Y H:i:s', $scannedAt)
|
||||||
|
->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new \Exception("Invalid date format : '{$scannedAt}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$exists = InvoiceOutValidation::where('plant_id', $plant->id)
|
||||||
|
->where('qr_code', $qrcode)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
InvoiceOutValidation::updateOrCreate(
|
||||||
|
[
|
||||||
|
'plant_id' => $plant->id,
|
||||||
|
'qr_code' => $qrcode,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'scanned_at' => $formattedDate,
|
||||||
|
'scanned_by' => $scannedBy,
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$exists ? $updateCount++ : $insertCount++;
|
||||||
|
$successCount++;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
$failedRecords[] = [
|
||||||
|
'row' => $rowNumber,
|
||||||
|
'qrcode' => $qrcode ?? null,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($failedRecords) > 0) {
|
||||||
$failedSummary = collect($failedRecords)
|
$failedSummary = collect($failedRecords)
|
||||||
->map(fn ($f) => "Row {$f['row']} ({$f['qrcode']}) : {$f['error']}")
|
->map(fn ($f) => "Row {$f['row']} ({$f['qrcode']}) : {$f['error']}")
|
||||||
->take(5) // limit preview to first 5 errors
|
->take(5)
|
||||||
->implode("\n");
|
->implode("\n");
|
||||||
|
Notification::make()
|
||||||
Notification::make()
|
->title('Partial Import Warning')
|
||||||
->title('Partial Import Warning')
|
->body(
|
||||||
->body("'{$successCount}' records inserted. ".count($failedRecords)." failed.\n\n{$failedSummary}")
|
"Total Success: {$successCount}\n" .
|
||||||
->warning()
|
"Inserted: {$insertCount}\n" .
|
||||||
->send();
|
"Updated: {$updateCount}\n" .
|
||||||
} else {
|
"Failed: " . count($failedRecords) . "\n\n" .
|
||||||
Notification::make()
|
$failedSummary
|
||||||
->title('Import Success')
|
)
|
||||||
->body("Successfully imported '{$successCount}' records.")
|
->warning()
|
||||||
->success()
|
->send();
|
||||||
->send();
|
}
|
||||||
}
|
else
|
||||||
} catch (\Exception $e) {
|
{
|
||||||
DB::rollBack();
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Import Failed')
|
->title('Import Success')
|
||||||
->body("No records were inserted. Error : {$e->getMessage()}")
|
->body("Successfully imported '{$successCount}' records.")
|
||||||
->danger()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ use Filament\Resources\Pages\CreateRecord;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Str;
|
use Str;
|
||||||
use Livewire\Attributes\On;
|
|
||||||
|
|
||||||
class CreateInvoiceValidation extends CreateRecord
|
class CreateInvoiceValidation extends CreateRecord
|
||||||
{
|
{
|
||||||
@@ -53,6 +53,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
public bool $showCapacitorInput = false;
|
public bool $showCapacitorInput = false;
|
||||||
|
|
||||||
public $excel_file;
|
public $excel_file;
|
||||||
|
|
||||||
public $mInvoiceNo;
|
public $mInvoiceNo;
|
||||||
|
|
||||||
public function getFormActions(): array
|
public function getFormActions(): array
|
||||||
@@ -121,8 +122,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
// ..GET SERIAL INVOICE API
|
// ..GET SERIAL INVOICE API
|
||||||
|
|
||||||
if(strlen($invoiceNumber) > 15)
|
if (strlen($invoiceNumber) > 15) {
|
||||||
{
|
|
||||||
|
|
||||||
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
|
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
|
||||||
|
|
||||||
@@ -132,41 +132,44 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(1)
|
->seconds(1)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$payload = json_decode($payloadJson, true);
|
$payload = json_decode($payloadJson, true);
|
||||||
|
|
||||||
|
if (! isset($payload['data'])) {
|
||||||
if (!isset($payload['data'])) {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid payload for scanned qr code.')
|
->title('Invalid payload for scanned qr code.')
|
||||||
->info()
|
->info()
|
||||||
->seconds(1)
|
->seconds(1)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$documentData = $payload['data'];
|
$documentData = $payload['data'];
|
||||||
|
|
||||||
if($documentData == '' || $documentData == ''){
|
if ($documentData == '' || $documentData == '') {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid payload for scanned qr code.')
|
->title('Invalid payload for scanned qr code.')
|
||||||
->info()
|
->info()
|
||||||
->seconds(1)
|
->seconds(1)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract DocNo
|
// Extract DocNo
|
||||||
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
|
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
|
||||||
|
|
||||||
if (!isset($matches[1])) {
|
if (! isset($matches[1])) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invoice number not found.')
|
->title('Invoice number not found.')
|
||||||
->info()
|
->info()
|
||||||
->seconds(1)
|
->seconds(1)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +178,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//dd($invoiceNumber);
|
// dd($invoiceNumber);
|
||||||
|
|
||||||
// ..
|
// ..
|
||||||
|
|
||||||
@@ -1427,6 +1430,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$missingCodes = [];
|
||||||
foreach ($rows as $index => $row) {
|
foreach ($rows as $index => $row) {
|
||||||
if ($index == 0) {
|
if ($index == 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1438,8 +1442,8 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
if (Str::length($materialCode) < 6) {
|
if (Str::length($materialCode) < 6) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) {
|
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($plantId, $materialCode) {
|
||||||
$query->where('plant_id', $this->plantId)->where('code', $materialCode); // Check if item.code matches Excel's materialCode
|
$query->where('plant_id', $plantId)->where('code', $materialCode); // $this->plantId >> Check if item.code matches Excel's materialCode
|
||||||
});
|
});
|
||||||
if ($sticker->exists()) {
|
if ($sticker->exists()) {
|
||||||
if ($sticker->first()->material_type && ! empty($sticker->first()->material_type)) {
|
if ($sticker->first()->material_type && ! empty($sticker->first()->material_type)) {
|
||||||
@@ -1450,6 +1454,8 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$missingCodes[] = $materialCode;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1458,7 +1464,26 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($invoiceType == 'M') {
|
$uniqueCodes = array_unique($missingCodes);
|
||||||
|
|
||||||
|
if (! empty($uniqueCodes)) {
|
||||||
|
$missingCount = count($uniqueCodes);
|
||||||
|
|
||||||
|
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:<br>'.implode(', ', $uniqueCodes);
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('Unknown: Item Codes')
|
||||||
|
->body($message)
|
||||||
|
->danger()
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
|
// if ($disk->exists($filePath)) {
|
||||||
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
|
return;
|
||||||
|
} elseif ($invoiceType == 'M') {
|
||||||
$invalidMatCodes = [];
|
$invalidMatCodes = [];
|
||||||
$materialCodes = [];
|
$materialCodes = [];
|
||||||
$missingQuantities = [];
|
$missingQuantities = [];
|
||||||
@@ -3195,7 +3220,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
if (! empty($emails)) {
|
if (! empty($emails)) {
|
||||||
Mail::to($emails)->send(
|
Mail::to($emails)->send(
|
||||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,$mUserName,'NotFoundInvoice')
|
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, $mUserName, 'NotFoundInvoice')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ class ItemResource extends Resource
|
|||||||
->searchable(),
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('category')
|
Tables\Columns\TextColumn::make('category')
|
||||||
->label('Category')
|
->label('Category')
|
||||||
|
->default('-')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
@@ -217,6 +218,7 @@ class ItemResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('uom')
|
Tables\Columns\TextColumn::make('uom')
|
||||||
->label('Unit of Measure')
|
->label('Unit of Measure')
|
||||||
|
->default('-')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
@@ -237,6 +239,7 @@ class ItemResource extends Resource
|
|||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
|
->searchPlaceholder('Search Item Code')
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
Filter::make('advanced_filters')
|
Filter::make('advanced_filters')
|
||||||
@@ -256,7 +259,7 @@ class ItemResource extends Resource
|
|||||||
$set('operator_id', null);
|
$set('operator_id', null);
|
||||||
}),
|
}),
|
||||||
Select::make('code')
|
Select::make('code')
|
||||||
->label('Search by Item Code')
|
->label('Search by Code')
|
||||||
->nullable()
|
->nullable()
|
||||||
// ->options(function (callable $get) {
|
// ->options(function (callable $get) {
|
||||||
// $plantId = $get('Plant');
|
// $plantId = $get('Plant');
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ use Filament\Tables\Table;
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
// use Illuminate\Validation\Rule;
|
// use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
@@ -93,21 +94,33 @@ class StickerMasterResource extends Resource
|
|||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
if (! $get('plant_id')) {
|
if (! $get('plant_id')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return \App\Models\Item::where('plant_id', $get('plant_id'))
|
if (! $get('id')) {
|
||||||
->pluck('code', 'id')
|
// whereHas
|
||||||
->toArray();
|
return Item::where('plant_id', $plantId)->whereDoesntHave('stickerMasters')->pluck('code', 'id');
|
||||||
|
} else {
|
||||||
|
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
|
||||||
|
|
||||||
|
return Item::where('plant_id', $plantId)
|
||||||
|
->where(function ($query) use ($itemId) {
|
||||||
|
$query->whereDoesntHave('stickerMasters')
|
||||||
|
->orWhere('id', $itemId);
|
||||||
|
})
|
||||||
|
->pluck('code', 'id');
|
||||||
|
}
|
||||||
|
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->rule(function (callable $get) {
|
||||||
|
return Rule::unique('sticker_masters', 'item_id')
|
||||||
|
->where('plant_id', $get('plant_id'))
|
||||||
|
->ignore($get('id')); // Ignore current record during updates
|
||||||
})
|
})
|
||||||
// ->rule(function (callable $get) {
|
|
||||||
// return Rule::unique('items', 'code')
|
|
||||||
// ->where('plant_id', $get('plant_id'))
|
|
||||||
// ->ignore($get('id')); // Ignore current record during updates
|
|
||||||
// })
|
|
||||||
->required()
|
->required()
|
||||||
->nullable()
|
// ->nullable()
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive()
|
->reactive()
|
||||||
// ->disabled(fn (Get $get) => !empty($get('id')))
|
// ->disabled(fn (Get $get) => !empty($get('id')))
|
||||||
@@ -132,7 +145,7 @@ class StickerMasterResource extends Resource
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
|
$availableItems = Item::where('plant_id', $plantId)->exists();
|
||||||
if (! $availableItems) {
|
if (! $availableItems) {
|
||||||
$set('item_error', null);
|
$set('item_error', null);
|
||||||
|
|
||||||
@@ -147,7 +160,7 @@ class StickerMasterResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if item exists for the selected plant
|
// Check if item exists for the selected plant
|
||||||
$item = \App\Models\Item::where('plant_id', $plantId)
|
$item = Item::where('plant_id', $plantId)
|
||||||
->where('id', $itemId)
|
->where('id', $itemId)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@@ -161,7 +174,8 @@ class StickerMasterResource extends Resource
|
|||||||
->where('item_id', $itemId)
|
->where('item_id', $itemId)
|
||||||
->exists();
|
->exists();
|
||||||
if (! $get('id')) {
|
if (! $get('id')) {
|
||||||
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
|
// $set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
|
||||||
|
$set('item_error', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
@@ -177,7 +191,7 @@ class StickerMasterResource extends Resource
|
|||||||
if ($get('id')) {
|
if ($get('id')) {
|
||||||
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
|
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
|
||||||
if ($itemId) {
|
if ($itemId) {
|
||||||
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
|
$item = Item::where('id', $itemId)->first()?->description;
|
||||||
if ($item) {
|
if ($item) {
|
||||||
$set('item_description', $item);
|
$set('item_description', $item);
|
||||||
} else {
|
} else {
|
||||||
@@ -525,27 +539,35 @@ class StickerMasterResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('part_validation1')
|
Tables\Columns\TextColumn::make('part_validation1')
|
||||||
->label('Part Validation 1')
|
->label('Part Validation 1')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('part_validation2')
|
Tables\Columns\TextColumn::make('part_validation2')
|
||||||
->label('Part Validation 2')
|
->label('Part Validation 2')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('part_validation3')
|
Tables\Columns\TextColumn::make('part_validation3')
|
||||||
->label('Part Validation 3')
|
->label('Part Validation 3')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('part_validation4')
|
Tables\Columns\TextColumn::make('part_validation4')
|
||||||
->label('Part Validation 4')
|
->label('Part Validation 4')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('part_validation5')
|
Tables\Columns\TextColumn::make('part_validation5')
|
||||||
->label('Part Validation 5')
|
->label('Part Validation 5')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('laser_part_validation1')
|
Tables\Columns\TextColumn::make('laser_part_validation1')
|
||||||
->label('Laser Part Validation 1')
|
->label('Laser Part Validation 1')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('laser_part_validation2')
|
Tables\Columns\TextColumn::make('laser_part_validation2')
|
||||||
->label('Laser Part Validation 2')
|
->label('Laser Part Validation 2')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('panel_box_code')
|
Tables\Columns\TextColumn::make('panel_box_code')
|
||||||
->label('Panel Box Code')
|
->label('Panel Box Code')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('load_rate')
|
Tables\Columns\TextColumn::make('load_rate')
|
||||||
->label('Load Rate')
|
->label('Load Rate')
|
||||||
@@ -553,20 +575,22 @@ class StickerMasterResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('bundle_quantity')
|
Tables\Columns\TextColumn::make('bundle_quantity')
|
||||||
->label('Bundle Quantity')
|
->label('Bundle Quantity')
|
||||||
|
->default('-')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('material_type')
|
Tables\Columns\TextColumn::make('material_type')
|
||||||
->label('Material Type')
|
->label('Material Type')
|
||||||
|
->default('-')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->formatStateUsing(function ($state) {
|
->formatStateUsing(function ($state) {
|
||||||
if (is_null($state) || $state === '') {
|
if (is_null($state) || $state == '') {
|
||||||
return '';
|
return '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
return match ($state) {
|
return match ($state) {
|
||||||
1 => 'Individual',
|
1 => 'Individual',
|
||||||
2 => 'Bundle',
|
2 => 'Bundle',
|
||||||
3 => 'Quantity',
|
3 => 'Quantity',
|
||||||
default => '',
|
default => '-',
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
@@ -587,9 +611,7 @@ class StickerMasterResource extends Resource
|
|||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
// ->filters([
|
->searchPlaceholder('Search Item Code')
|
||||||
// Tables\Filters\TrashedFilter::make(),
|
|
||||||
// ])
|
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
Filter::make('advanced_filters')
|
Filter::make('advanced_filters')
|
||||||
@@ -635,7 +657,7 @@ class StickerMasterResource extends Resource
|
|||||||
->searchable()
|
->searchable()
|
||||||
->reactive(),
|
->reactive(),
|
||||||
Select::make('material_type')
|
Select::make('material_type')
|
||||||
->label('Material Type')
|
->label('Select Material Type')
|
||||||
->options([
|
->options([
|
||||||
1 => 'Individual',
|
1 => 'Individual',
|
||||||
2 => 'Bundle',
|
2 => 'Bundle',
|
||||||
@@ -644,7 +666,7 @@ class StickerMasterResource extends Resource
|
|||||||
->reactive(),
|
->reactive(),
|
||||||
|
|
||||||
TextInput::make('panel_box_code')
|
TextInput::make('panel_box_code')
|
||||||
->label('Panel Box Code')
|
->label('Search by Panel Box Code')
|
||||||
->placeholder(placeholder: 'Enter Panel Box Code'),
|
->placeholder(placeholder: 'Enter Panel Box Code'),
|
||||||
DateTimePicker::make(name: 'created_from')
|
DateTimePicker::make(name: 'created_from')
|
||||||
->label('Created From')
|
->label('Created From')
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||||
->where('plant_id', $selectedPlant)
|
->where('plant_id', $selectedPlant)
|
||||||
->whereNull('quantity')
|
->whereNull('quantity')
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw(
|
->havingRaw(
|
||||||
"COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
"COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||||
@@ -99,7 +99,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||||
->where('plant_id', $selectedPlant)
|
->where('plant_id', $selectedPlant)
|
||||||
->where('quantity', '>', 1)
|
->where('quantity', '>', 1)
|
||||||
->whereBetween('updated_at', [$startDate, $endDate])
|
->whereBetween('created_at', [$startDate, $endDate])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw(
|
->havingRaw(
|
||||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||||
@@ -142,7 +142,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
$query->where('quantity', 1)->whereBetween('created_at', [$dayStart, $dayEnd]);
|
$query->where('quantity', 1)->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||||
|
|
||||||
$completedQuery->where('quantity', 1)
|
$completedQuery->where('quantity', 1)
|
||||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw(
|
->havingRaw(
|
||||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||||
@@ -153,7 +153,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
$query->whereNull('quantity')->whereBetween('created_at', [$dayStart, $dayEnd]);
|
$query->whereNull('quantity')->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||||
|
|
||||||
$completedQuery->whereNull('quantity')
|
$completedQuery->whereNull('quantity')
|
||||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw(
|
->havingRaw(
|
||||||
"COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
"COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||||
@@ -164,7 +164,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
$query->where('quantity', '>', 1)->whereBetween('created_at', [$dayStart, $dayEnd]);
|
$query->where('quantity', '>', 1)->whereBetween('created_at', [$dayStart, $dayEnd]);
|
||||||
|
|
||||||
$completedQuery->where('quantity', '>', 1)
|
$completedQuery->where('quantity', '>', 1)
|
||||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||||
->groupBy('invoice_number')
|
->groupBy('invoice_number')
|
||||||
->havingRaw(
|
->havingRaw(
|
||||||
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
"COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||||
@@ -193,22 +193,31 @@ class InvoiceChart extends ChartWidget
|
|||||||
}
|
}
|
||||||
elseif ($activeFilter == 'this_month') {
|
elseif ($activeFilter == 'this_month') {
|
||||||
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
||||||
$endOfMonth = now()->endOfMonth()->addDay()->setTime(8, 0, 0); // include full last day
|
$endOfMonth = now()->endOfMonth()->addDay()->setTime(23, 59, 59); // include full last day
|
||||||
$monthName = $startOfMonth->format('M');
|
$monthName = $startOfMonth->format('M');
|
||||||
|
|
||||||
// Prepare weekly labels like "May(1-7)", "May(8-14)", etc.
|
|
||||||
$labels = [];
|
$labels = [];
|
||||||
$weekStart = $startOfMonth->copy();
|
$weekStart = $startOfMonth->copy();
|
||||||
$importedInvoicesPerWeek = [];
|
$importedInvoicesPerWeek = [];
|
||||||
$completedInvoicesPerWeek = [];
|
$completedInvoicesPerWeek = [];
|
||||||
|
|
||||||
$weekIndex = 0;
|
$weekIndex = 0;
|
||||||
while ($weekStart < $endOfMonth) {
|
while ($weekStart <= $endOfMonth) {
|
||||||
$weekEnd = $weekStart->copy()->addDays(7);
|
// $weekEnd = $weekStart->copy()->addDays(6);
|
||||||
|
$weekEnd = $weekStart->copy()->addDays(6)->endOfDay();
|
||||||
|
|
||||||
|
// If week end exceeds end of month, limit it
|
||||||
|
if ($weekEnd->greaterThan($endOfMonth)) {
|
||||||
|
$weekEnd = $endOfMonth->copy()->endOfDay();
|
||||||
|
}
|
||||||
|
|
||||||
$startDay = $weekStart->format('j');
|
$startDay = $weekStart->format('j');
|
||||||
$weekEndLimit = $weekEnd->copy()->subDay();
|
$endDay = $weekEnd->format('j');
|
||||||
$actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
|
|
||||||
$endDay = $actualEnd->format('j');
|
// $startDay = $weekStart->format('j');
|
||||||
|
// $weekEndLimit = $weekEnd->copy()->subDay();
|
||||||
|
// $actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
|
||||||
|
// $endDay = $actualEnd->format('j');
|
||||||
|
|
||||||
$labels[] = "{$monthName}({$startDay}-{$endDay})";
|
$labels[] = "{$monthName}({$startDay}-{$endDay})";
|
||||||
|
|
||||||
@@ -233,7 +242,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
// --- Completed ---
|
// --- Completed ---
|
||||||
$queryCompleted = InvoiceValidation::select('invoice_number')
|
$queryCompleted = InvoiceValidation::select('invoice_number')
|
||||||
->where('plant_id', $selectedPlant)
|
->where('plant_id', $selectedPlant)
|
||||||
->whereBetween('updated_at', [$weekStart, $weekEnd]);
|
->whereBetween('created_at', [$weekStart, $weekEnd]);
|
||||||
|
|
||||||
if ($selectedInvoice == 'individual_material') {
|
if ($selectedInvoice == 'individual_material') {
|
||||||
$queryCompleted->where('quantity', 1)
|
$queryCompleted->where('quantity', 1)
|
||||||
@@ -252,7 +261,8 @@ class InvoiceChart extends ChartWidget
|
|||||||
$completedInvoicesPerWeek[$weekIndex] = $queryCompleted->count();
|
$completedInvoicesPerWeek[$weekIndex] = $queryCompleted->count();
|
||||||
|
|
||||||
// Move to next week
|
// Move to next week
|
||||||
$weekStart = $weekEnd;
|
// $weekStart = $weekEnd;
|
||||||
|
$weekStart = $weekEnd->copy()->addDay(1);
|
||||||
$weekIndex++;
|
$weekIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,6 +308,7 @@ class InvoiceChart extends ChartWidget
|
|||||||
{
|
{
|
||||||
return 'bar';
|
return 'bar';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDefaultName(): string
|
public static function getDefaultName(): string
|
||||||
{
|
{
|
||||||
return 'invoice-chart';
|
return 'invoice-chart';
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ class ProductionStickerReprintController extends Controller
|
|||||||
{
|
{
|
||||||
$copies = 2;
|
$copies = 2;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$copies = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
133
app/Imports/InvoicePendingReasonImport.php
Normal file
133
app/Imports/InvoicePendingReasonImport.php
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Imports;
|
||||||
|
|
||||||
|
use App\Models\InvoiceDataValidation;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
|
||||||
|
class InvoicePendingReasonImport implements ToCollection
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Collection $collection
|
||||||
|
*/
|
||||||
|
|
||||||
|
public array $errors = [];
|
||||||
|
|
||||||
|
public array $missingPlantCodes = [];
|
||||||
|
public array $missingDocNo = [];
|
||||||
|
public array $plantCodeEmpty = [];
|
||||||
|
public array $docNoEmpty = [];
|
||||||
|
public array $remarkEmpty = [];
|
||||||
|
|
||||||
|
public array $duplicateExcelDocs = [];
|
||||||
|
|
||||||
|
private array $seenExcelKeys = [];
|
||||||
|
|
||||||
|
public array $validRows = [];
|
||||||
|
|
||||||
|
public function collection(Collection $collection)
|
||||||
|
{
|
||||||
|
$rows = $collection;
|
||||||
|
// foreach ($rows->skip(1) as $row) {
|
||||||
|
|
||||||
|
// $plantCode = trim($row[0] ?? '');
|
||||||
|
// $documentNumber = trim($row[1] ?? '');
|
||||||
|
// $remark = trim($row[2] ?? '');
|
||||||
|
|
||||||
|
// if (! $plantCode || ! $documentNumber || ! $remark) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $plantId = Plant::where('code', $plantCode)->value('id');
|
||||||
|
|
||||||
|
// InvoiceDataValidation::where('plant_id', $plantId)
|
||||||
|
// ->where('document_number', $documentNumber)
|
||||||
|
// ->update([
|
||||||
|
// 'remark' => $remark,
|
||||||
|
// 'updated_at' => now(),
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
foreach ($rows->skip(1) as $index => $row) {
|
||||||
|
|
||||||
|
$rowNo = $index + 2;
|
||||||
|
|
||||||
|
$plantCode = trim($row[0] ?? '');
|
||||||
|
$documentNumber = trim($row[1] ?? '');
|
||||||
|
$remark = trim($row[2] ?? '');
|
||||||
|
|
||||||
|
if (! $plantCode) {
|
||||||
|
$this->plantCodeEmpty[] = [
|
||||||
|
'row' => $rowNo,
|
||||||
|
'reason' => "Plant Code can't be empty!",
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (! $documentNumber) {
|
||||||
|
$this->docNoEmpty[] = [
|
||||||
|
'row' => $rowNo,
|
||||||
|
'reason' => "Document number can't be empty!",
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (! $remark) {
|
||||||
|
$this->remarkEmpty[] = [
|
||||||
|
'row' => $rowNo,
|
||||||
|
'reason' => "Remark can't be empty!",
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Excel-level duplicate check
|
||||||
|
$key = $plantCode . '|' . $documentNumber;
|
||||||
|
|
||||||
|
if (isset($this->seenExcelKeys[$key])) {
|
||||||
|
$this->duplicateExcelDocs[$key][] = $rowNo;
|
||||||
|
|
||||||
|
$this->errors[] = [
|
||||||
|
'row' => $rowNo,
|
||||||
|
'reason' => "Duplicate Document Number in Excel ({$plantCode} - {$documentNumber})",
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->seenExcelKeys[$key] = true;
|
||||||
|
|
||||||
|
$plantId = Plant::where('code', $plantCode)->value('id');
|
||||||
|
|
||||||
|
if (! $plantId) {
|
||||||
|
$this->missingPlantCodes[$plantCode] = true;
|
||||||
|
|
||||||
|
$this->errors[] = [
|
||||||
|
'row' => $rowNo,
|
||||||
|
'reason' => "Plant code not found: {$plantCode}",
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoiceExists = InvoiceDataValidation::where('plant_id', $plantId)
|
||||||
|
->where('document_number', $documentNumber)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $invoiceExists) {
|
||||||
|
$this->missingDocNo[$documentNumber] = true;
|
||||||
|
|
||||||
|
$this->errors[] = [
|
||||||
|
'row' => $rowNo,
|
||||||
|
'reason' => "Document number not found: {$documentNumber}",
|
||||||
|
];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->validRows[] = [
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'document_number' => $documentNumber,
|
||||||
|
'remark' => $remark,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
125
app/Livewire/InvoicePending.php
Normal file
125
app/Livewire/InvoicePending.php
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\InvoiceDataValidation;
|
||||||
|
use App\Models\InvoiceOutValidation;
|
||||||
|
use App\Models\PalletValidation;
|
||||||
|
use Livewire\Component;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use App\Exports\InvoicePendingReasonExport;
|
||||||
|
use App\Models\Plant;
|
||||||
|
|
||||||
|
class InvoicePending extends Component
|
||||||
|
{
|
||||||
|
|
||||||
|
public $plantId;
|
||||||
|
|
||||||
|
public $invoicePending = [];
|
||||||
|
|
||||||
|
protected $listeners = [
|
||||||
|
'loadData' => 'loadInvoiceData',
|
||||||
|
'emptyData' => 'loadInvoiceEmptyData',
|
||||||
|
'loadData1' => 'exportPendingReason',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function loadInvoiceEmptyData()
|
||||||
|
{
|
||||||
|
$this->invoicePending = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadInvoiceData($plantId)
|
||||||
|
{
|
||||||
|
$this->plantId = $plantId;
|
||||||
|
|
||||||
|
$distributions = InvoiceDataValidation::whereNotNull('distribution_channel_desc')
|
||||||
|
->distinct()
|
||||||
|
->pluck('distribution_channel_desc')
|
||||||
|
->filter(fn ($v) => trim($v) != '')
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$distributions[] = '';
|
||||||
|
|
||||||
|
$pendingInvoices = collect();
|
||||||
|
|
||||||
|
foreach ($distributions as $distribution) {
|
||||||
|
|
||||||
|
$invoices = InvoiceDataValidation::where('plant_id', $plantId)
|
||||||
|
->where('distribution_channel_desc', $distribution)
|
||||||
|
->select(
|
||||||
|
'id',
|
||||||
|
'document_number',
|
||||||
|
'customer_trade_name',
|
||||||
|
'location',
|
||||||
|
'remark',
|
||||||
|
'created_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_at',
|
||||||
|
'updated_by'
|
||||||
|
)
|
||||||
|
->get()
|
||||||
|
->unique('document_number')
|
||||||
|
->filter(fn ($inv) =>
|
||||||
|
!empty($inv->document_number) &&
|
||||||
|
!str_contains($inv->document_number, '-')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (trim($distribution) == '') {
|
||||||
|
$invoices = $invoices->filter(fn ($inv) =>
|
||||||
|
str_starts_with($inv->document_number, '7')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($invoices->isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoiceNumbers = $invoices->pluck('document_number')
|
||||||
|
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$wentOut = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||||
|
->distinct()
|
||||||
|
->pluck('qr_code')
|
||||||
|
->map(fn ($n) => preg_replace('/\s+/', '', strtoupper($n)))
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$pending = $invoices->filter(function ($inv) use ($wentOut) {
|
||||||
|
$doc = preg_replace('/\s+/', '', strtoupper($inv->document_number));
|
||||||
|
return !in_array($doc, $wentOut, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
$pendingInvoices = $pendingInvoices->merge($pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
$plantCode = Plant::find($this->plantId)->code ?? '';
|
||||||
|
|
||||||
|
$this->invoicePending = $pendingInvoices
|
||||||
|
->unique('document_number')
|
||||||
|
->map(function ($record) use ($plantCode) {
|
||||||
|
return [
|
||||||
|
'plant_id' => $plantCode ?? '',
|
||||||
|
'document_number' => $record->document_number ?? '',
|
||||||
|
'customer_trade_name' => $record->customer_trade_name ?? '',
|
||||||
|
'location' => $record->location ?? '',
|
||||||
|
'remark' => $record->remark ?? '',
|
||||||
|
];
|
||||||
|
})
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exportPendingReason()
|
||||||
|
{
|
||||||
|
return Excel::download(
|
||||||
|
new InvoicePendingReasonExport($this->invoicePending),
|
||||||
|
'invoice_pending_reason.xlsx'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.invoice-pending');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$sql1 = <<<'SQL'
|
||||||
|
ALTER TABLE invoice_data_validations
|
||||||
|
ADD COLUMN remark TEXT DEFAULT NULL
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Schema::table('invoice_data_validations', function (Blueprint $table) {
|
||||||
|
// //
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -161,6 +161,9 @@ class PermissionSeeder extends Seeder
|
|||||||
Permission::updateOrCreate(['name' => 'view production data send to sap']);
|
Permission::updateOrCreate(['name' => 'view production data send to sap']);
|
||||||
Permission::updateOrCreate(['name' => 'create production sticker reject reason page']);
|
Permission::updateOrCreate(['name' => 'create production sticker reject reason page']);
|
||||||
Permission::updateOrCreate(['name' => 'create web capture page']);
|
Permission::updateOrCreate(['name' => 'create web capture page']);
|
||||||
|
|
||||||
|
Permission::updateOrCreate(['name' => 'view invoice pending reason']);
|
||||||
|
|
||||||
Permission::updateOrCreate(['name' => 'view import invoice out validation']);
|
Permission::updateOrCreate(['name' => 'view import invoice out validation']);
|
||||||
Permission::updateOrCreate(['name' => 'view export invoice out validation']);
|
Permission::updateOrCreate(['name' => 'view export invoice out validation']);
|
||||||
Permission::updateOrCreate(['name' => 'view import invoice data validation']);
|
Permission::updateOrCreate(['name' => 'view import invoice data validation']);
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<x-filament-panels::page>
|
||||||
|
<div class="space-y-4">
|
||||||
|
{{-- {{ $this->filtersForm($this->form) }} --}}
|
||||||
|
{{ $this->filtersForm($this->form) }}
|
||||||
|
</div>
|
||||||
|
<div class="flex-row gap-2 mt-4">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="addRemark"
|
||||||
|
class="px-3 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</x-filament-panels::page>
|
||||||
45
resources/views/livewire/invoice-pending.blade.php
Normal file
45
resources/views/livewire/invoice-pending.blade.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<div class="p-4">
|
||||||
|
<h2 class="text-lg font-bold mb-4 text-gray-700 uppercase tracking-wider">
|
||||||
|
PENDING INVOICE DATA TABLE:
|
||||||
|
</h2>
|
||||||
|
<div class="overflow-x-auto rounded-lg shadow">
|
||||||
|
<table class="w-full divide-y divide-gray-200 text-sm text-center">
|
||||||
|
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
|
||||||
|
<tr>
|
||||||
|
<th class="border px-4 py-2">No</th>
|
||||||
|
<th class="border px-4 py-2">Plant Code</th>
|
||||||
|
<th class="border px-4 py-2">Document Number</th>
|
||||||
|
<th class="border px-4 py-2">Customer Trade Location</th>
|
||||||
|
<th class="border px-4 py-2">Location</th>
|
||||||
|
<th class="border px-4 py-2">Remark</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-100">
|
||||||
|
@if (empty($invoicePending))
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="px-4 py-4 text-center text-gray-500">
|
||||||
|
Please select plant to load pending invoice.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@else
|
||||||
|
@forelse ($invoicePending as $index => $locator)
|
||||||
|
<tr class="hover:bg-gray-50">
|
||||||
|
<td class="border px-4 py-2">{{ $index + 1 }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['plant_id'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['document_number'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2">{{ $locator['customer_trade_name'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['location'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $locator['remark'] ?? '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="9" class="px-4 py-4 text-center text-gray-500">
|
||||||
|
No invoice pending records found.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
@endif
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -88,6 +88,7 @@
|
|||||||
<th>Location</th>
|
<th>Location</th>
|
||||||
<th>Pending Days</th>
|
<th>Pending Days</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
<th>Remark</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -117,6 +118,7 @@
|
|||||||
<td class="{{ $row['status_class'] ?? '' }}">
|
<td class="{{ $row['status_class'] ?? '' }}">
|
||||||
{{ $row['status'] }}
|
{{ $row['status'] }}
|
||||||
</td>
|
</td>
|
||||||
|
<td>{{ $row['remark'] ?? '-'}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user