Compare commits
132 Commits
785be70629
...
renovate/b
| Author | SHA1 | Date | |
|---|---|---|---|
| 52f61551a3 | |||
| f3389399eb | |||
|
|
775396ace6 | ||
| c18a07853e | |||
|
|
a21ff06dcc | ||
| 555f810c0f | |||
|
|
b036cc57e6 | ||
| 2e5d185be1 | |||
|
|
68446902db | ||
| 0ece1d0dd6 | |||
|
|
aa7d1802c8 | ||
| e145560920 | |||
|
|
4365f30075 | ||
| e02052e536 | |||
|
|
578e147740 | ||
| 39e40e011f | |||
|
|
6601ee48d9 | ||
| 7184eda58c | |||
|
|
002b6550de | ||
| 3c4b419078 | |||
|
|
247c671fc3 | ||
| 7ba5375386 | |||
|
|
bfdc5c85ab | ||
| c3324caa08 | |||
|
|
bd2269d2b0 | ||
| ace14124f3 | |||
|
|
e8a1e97bd6 | ||
| c68a45ef8d | |||
|
|
d4319f6399 | ||
| 3edd8fafc6 | |||
|
|
da26035e84 | ||
| 2c66f2e6bd | |||
|
|
f5cea208a1 | ||
| e791176500 | |||
|
|
24e2327439 | ||
| 1eddecc660 | |||
|
|
0161e76330 | ||
| 379e8fc8f9 | |||
|
|
fff610bc2e | ||
| b018ef48d7 | |||
|
|
2e6f27824c | ||
| 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 | ||
| 9ee4fe5c7e | |||
|
|
a7dee59f75 | ||
| 6f06319752 | |||
|
|
c10c256ec9 |
@@ -39,6 +39,8 @@ class Scheduler extends Command
|
||||
public function handle()
|
||||
{
|
||||
|
||||
// $this->call('approval:trigger-mails');
|
||||
|
||||
// --- Production Rules ---
|
||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
@@ -74,7 +76,6 @@ class Scheduler extends Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Invoice Validation Rules ---
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'InvoiceMail')
|
||||
@@ -174,7 +175,7 @@ class Scheduler extends Command
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '10:00') {
|
||||
if (now()->format('H:i') == '11:30') {
|
||||
\Artisan::call('send:invoice-data-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
@@ -209,11 +210,25 @@ class Scheduler extends Command
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '10:00') {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
if (now()->format('H:i') == '10:45') {
|
||||
try {
|
||||
\Artisan::call('send:invoice-transit-report', [
|
||||
'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;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,8 @@ use App\Mail\InvoiceDataMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\InvoiceOutValidation;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendInvoiceDataReport extends Command
|
||||
{
|
||||
@@ -49,7 +45,7 @@ class SendInvoiceDataReport extends Command
|
||||
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error("No valid plant(s) found.");
|
||||
$this->error('No valid plant(s) found.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,7 +101,7 @@ class SendInvoiceDataReport extends Command
|
||||
->where('distribution_channel_desc', $selectedDistribution)
|
||||
->whereBetween('document_date', [$startDate, $endDate])
|
||||
->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()
|
||||
->unique('document_number')
|
||||
->values();
|
||||
@@ -114,7 +110,6 @@ class SendInvoiceDataReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter invoices directly — exclude ones with '-' in document_number
|
||||
$invoices = $invoices->filter(function ($inv) {
|
||||
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)))
|
||||
->toArray();
|
||||
|
||||
//where('plant_id', $plant->id)
|
||||
$wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
|
||||
//->whereBetween('scanned_at', [$startDate, $endDate])
|
||||
->distinct('qr_code')
|
||||
@@ -164,7 +158,6 @@ class SendInvoiceDataReport extends Command
|
||||
return !in_array($doc, $wentOutInvoices, true);
|
||||
});
|
||||
|
||||
|
||||
if ($pendingInvoices->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -182,7 +175,7 @@ class SendInvoiceDataReport extends Command
|
||||
}
|
||||
|
||||
$tableData[] = [
|
||||
//'no' => $no++,
|
||||
// 'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
// 'distribution_type' => $selectedDistribution,
|
||||
'customer_code' => $inv->customer_code,
|
||||
@@ -194,6 +187,7 @@ class SendInvoiceDataReport extends Command
|
||||
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
|
||||
'status' => 'Pending',
|
||||
'status_class' => $statusColor,
|
||||
'remark' => $inv->remark,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -203,6 +197,7 @@ class SendInvoiceDataReport extends Command
|
||||
->values()
|
||||
->map(function ($item, $index) {
|
||||
$item['no'] = $index + 1;
|
||||
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
@@ -214,7 +209,7 @@ class SendInvoiceDataReport extends Command
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Invoice Data Report');
|
||||
$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
|
||||
);
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
@@ -236,13 +231,13 @@ class SendInvoiceDataReport extends Command
|
||||
->toArray();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
\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')
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -86,7 +86,7 @@ class SendInvoiceReport extends Command
|
||||
$query->whereNull('quantity')
|
||||
->orWhere('quantity', 0);
|
||||
})
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$serialTableData[] = [
|
||||
@@ -108,7 +108,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -122,7 +122,7 @@ class SendInvoiceReport extends Command
|
||||
->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$materialTableData[] = [
|
||||
@@ -144,7 +144,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
@@ -158,7 +158,7 @@ class SendInvoiceReport extends Command
|
||||
->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$bundleTableData[] = [
|
||||
@@ -180,25 +180,104 @@ class SendInvoiceReport extends Command
|
||||
|
||||
// Send to SerialInvoiceMail recipients
|
||||
if ($mailRules->has('SerialInvoiceMail')) {
|
||||
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
||||
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// 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)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// 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)
|
||||
if ($mailRules->has('InvoiceMail')) {
|
||||
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
//$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// 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->info($contentVars['wishes'] ?? '');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,13 +68,21 @@ class SendInvoiceTransitReport extends Command
|
||||
'im.transport_name',
|
||||
DB::raw('CAST(im.transit_days AS INTEGER) as transit_days'),
|
||||
// DB::raw('(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE)) as delayed_days')
|
||||
DB::raw('
|
||||
// DB::raw('
|
||||
// GREATEST(
|
||||
// 0,
|
||||
// (CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE) - 1)
|
||||
// - CAST(im.transit_days AS INTEGER)
|
||||
// ) AS delayed_days
|
||||
// ')
|
||||
DB::raw('
|
||||
GREATEST(
|
||||
0,
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE) - 1)
|
||||
1,
|
||||
(CURRENT_DATE - CAST(it.lr_bl_aw_date AS DATE))
|
||||
- CAST(im.transit_days AS INTEGER)
|
||||
) AS delayed_days
|
||||
')
|
||||
|
||||
)
|
||||
->when($plantId != 0, fn($q) => $q->where('it.plant_id', $plantId))
|
||||
->whereNotNull('it.lr_bl_aw_date')
|
||||
|
||||
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'] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
472
app/Filament/Pages/InvoicePendingReason.php
Normal file
472
app/Filament/Pages/InvoicePendingReason.php
Normal file
@@ -0,0 +1,472 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Imports\InvoicePendingReasonImport;
|
||||
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\FileUpload;
|
||||
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;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Storage;
|
||||
|
||||
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 ?string $file = null;
|
||||
|
||||
public array $importErrors = [];
|
||||
|
||||
public array $invoicePending = [];
|
||||
|
||||
|
||||
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');
|
||||
|
||||
if($plantId){
|
||||
$this->dispatch('loadData' ,$plantId);
|
||||
}
|
||||
else{
|
||||
$this->dispatch('emptyData');
|
||||
}
|
||||
|
||||
$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(),
|
||||
FileUpload::make('file')
|
||||
->label('Upload Excel File')
|
||||
->required()
|
||||
->disk('local')
|
||||
->multiple(false)
|
||||
->directory('invoice-pending')
|
||||
->dehydrated(false)
|
||||
//->preserveFilenames()
|
||||
//->storeFiles()
|
||||
//storeFileNamesIn('original_name')
|
||||
// ->visibility('private')
|
||||
->acceptedFileTypes([
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.ms-excel',
|
||||
'text/csv',
|
||||
])
|
||||
->rules(['mimes:xlsx,xls,csv'])
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state instanceof \Livewire\Features\SupportFileUploads\TemporaryUploadedFile) {
|
||||
$set('file', $state->store('invoice-pending'));
|
||||
}
|
||||
}),
|
||||
])
|
||||
->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 function importPendingReason()
|
||||
// {
|
||||
|
||||
// $file = $this->filters['file'] ?? null;
|
||||
|
||||
// $absolutePath = Storage::disk('local')->path($file);
|
||||
|
||||
// Excel::import(new InvoicePendingReasonImport, $absolutePath);
|
||||
|
||||
// $this->reset('filters.file');
|
||||
|
||||
// Notification::make()
|
||||
// ->title('File processed and database updated successfully')
|
||||
// ->success()
|
||||
// ->send();
|
||||
// }
|
||||
|
||||
public function importPendingReason()
|
||||
{
|
||||
$file = $this->filters['file'] ?? null;
|
||||
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
|
||||
if (empty($file)) {
|
||||
Notification::make()
|
||||
->title('Please upload a file')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// if (
|
||||
// empty($fileFilter) ||
|
||||
// !is_array($fileFilter) ||
|
||||
// empty($fileFilter[0])
|
||||
// ) {
|
||||
// Notification::make()
|
||||
// ->title('Please upload a file')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// $filePath = $fileFilter[0];
|
||||
|
||||
// if (!is_string($filePath)) {
|
||||
// Notification::make()
|
||||
// ->title('Invalid file upload')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
$absolutePath = Storage::disk('local')->path($file);
|
||||
|
||||
$import = new InvoicePendingReasonImport();
|
||||
|
||||
try {
|
||||
|
||||
Excel::import(
|
||||
$import,
|
||||
$absolutePath
|
||||
);
|
||||
|
||||
if(!empty($import->plantCodeEmpty)) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Plant code can't be empty")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->docNoEmpty)) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Document number can't be empty")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
// else if(!empty($import->remarkEmpty)) {
|
||||
|
||||
// Notification::make()
|
||||
// ->title('Import failed')
|
||||
// ->body("Remark can't be empty")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// $this->filtersForm->fill([
|
||||
// 'file' => null,
|
||||
// ]);
|
||||
// return;
|
||||
// }
|
||||
else if (! empty($import->duplicateExcelDocs)) {
|
||||
|
||||
$duplicates = collect($import->duplicateExcelDocs)
|
||||
->map(function ($rows, $key) {
|
||||
[$plant, $doc] = explode('|', $key);
|
||||
return "{$plant}-{$doc}";
|
||||
})
|
||||
->implode(', ');
|
||||
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Duplicate Document Numbers found in Excel: {$duplicates}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->missingPlantCodes)) {
|
||||
$codes = implode(', ', array_keys($import->missingPlantCodes));
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Plant codes not found: {$codes}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if(!empty($import->missingDocNo)) {
|
||||
$docNo = implode(', ', array_keys($import->missingDocNo));
|
||||
Notification::make()
|
||||
->title('Import failed')
|
||||
->body("Document numbers not found: {$docNo}")
|
||||
->danger()
|
||||
->send();
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($import->validRows as $row) {
|
||||
InvoiceDataValidation::where('plant_id', $row['plant_id'])
|
||||
->where('document_number', $row['document_number'])
|
||||
->update([
|
||||
'remark' => $row['remark'],
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Import successful')
|
||||
->body('All records updated successfully.')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData' ,$plantId);
|
||||
|
||||
$this->filtersForm->fill([
|
||||
'file' => null,
|
||||
'plant_id' => $plantId,
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
Notification::make()
|
||||
->title('Import error')
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public function exportPendingReason()
|
||||
{
|
||||
$plantId = $this->filters['plant_id'] ?? null;
|
||||
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Plant')
|
||||
->body("please select plant to export data..!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dispatch('loadData1' ,$plantId);
|
||||
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice pending reason');
|
||||
}
|
||||
}
|
||||
25
app/Filament/Pages/Welcome.php
Normal file
25
app/Filament/Pages/Welcome.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// public static function canAccess(): bool
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view welcome page');
|
||||
// }
|
||||
}
|
||||
201
app/Filament/Resources/CharacteristicApproverMasterResource.php
Normal file
201
app/Filament/Resources/CharacteristicApproverMasterResource.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Machine;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class CharacteristicApproverMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CharacteristicApproverMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('machine', 'name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('characteristic_field')
|
||||
->label('Characteristic Field'),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine Name'),
|
||||
Forms\Components\TextInput::make('name1')
|
||||
->label('Name-1'),
|
||||
Forms\Components\TextInput::make('mail1')
|
||||
->label('Mail-1'),
|
||||
Forms\Components\TextInput::make('duration1')
|
||||
->label('Duration-1 (Hour.Minute)'),
|
||||
Forms\Components\TextInput::make('name2')
|
||||
->label('Name-2'),
|
||||
Forms\Components\TextInput::make('mail2')
|
||||
->label('Mail-2'),
|
||||
Forms\Components\TextInput::make('duration2')
|
||||
->label('Duration-2 (Hour.Minute)'),
|
||||
Forms\Components\TextInput::make('name3')
|
||||
->label('Name-3'),
|
||||
Forms\Components\TextInput::make('mail3')
|
||||
->label('Mail-3'),
|
||||
Forms\Components\TextInput::make('duration3')
|
||||
->label('Duration-3 (Hour.Minute)'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_field')
|
||||
->label('Characteristic Field')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name1')
|
||||
->label('Approver Name 1')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail1')
|
||||
->label('Mail 1')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration1')
|
||||
->label('Duration 1 (Hour.Minute)')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name2')
|
||||
->label('Approver Name 2')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail2')
|
||||
->label('Mail 2')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration2')
|
||||
->label('Duration 2 (Hour.Minute)')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name3')
|
||||
->label('Approver Name 3')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail3')
|
||||
->label('Mail 3')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration3')
|
||||
->label('Duration 3 (Hour.Minute)')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCharacteristicApproverMasters::route('/'),
|
||||
'create' => Pages\CreateCharacteristicApproverMaster::route('/create'),
|
||||
'view' => Pages\ViewCharacteristicApproverMaster::route('/{record}'),
|
||||
'edit' => Pages\EditCharacteristicApproverMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCharacteristicApproverMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCharacteristicApproverMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCharacteristicApproverMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewCharacteristicApproverMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = CharacteristicApproverMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
1054
app/Filament/Resources/ClassCharacteristicResource.php
Normal file
1054
app/Filament/Resources/ClassCharacteristicResource.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateClassCharacteristic extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditClassCharacteristic extends EditRecord
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListClassCharacteristics extends ListRecords
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ClassCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ClassCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewClassCharacteristic extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ClassCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,8 @@ class InvoiceDataValidationResource extends Resource
|
||||
Forms\Components\TextInput::make('location')
|
||||
->label('Location')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('remark')
|
||||
->label('Remark'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
@@ -123,6 +125,11 @@ class InvoiceDataValidationResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('remark')
|
||||
->label('Remark')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
|
||||
@@ -398,122 +398,104 @@ class InvoiceOutValidationResource extends Resource
|
||||
// }
|
||||
|
||||
$successCount = 0;
|
||||
$updateCount = 0;
|
||||
$insertCount = 0;
|
||||
$failedRecords = [];
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
foreach ($rows as $index => $row) {
|
||||
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(),
|
||||
];
|
||||
}
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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)
|
||||
->map(fn ($f) => "Row {$f['row']} ({$f['qrcode']}) : {$f['error']}")
|
||||
->take(5) // limit preview to first 5 errors
|
||||
->take(5)
|
||||
->implode("\n");
|
||||
|
||||
Notification::make()
|
||||
->title('Partial Import Warning')
|
||||
->body("'{$successCount}' records inserted. ".count($failedRecords)." failed.\n\n{$failedSummary}")
|
||||
->warning()
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Import Success')
|
||||
->body("Successfully imported '{$successCount}' records.")
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
Notification::make()
|
||||
->title('Partial Import Warning')
|
||||
->body(
|
||||
"Total Success: {$successCount}\n" .
|
||||
"Inserted: {$insertCount}\n" .
|
||||
"Updated: {$updateCount}\n" .
|
||||
"Failed: " . count($failedRecords) . "\n\n" .
|
||||
$failedSummary
|
||||
)
|
||||
->warning()
|
||||
->send();
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Import Failed')
|
||||
->body("No records were inserted. Error : {$e->getMessage()}")
|
||||
->danger()
|
||||
->title('Import Success')
|
||||
->body("Successfully imported '{$successCount}' records.")
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Attributes\On;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Str;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
@@ -53,6 +53,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
public bool $showCapacitorInput = false;
|
||||
|
||||
public $excel_file;
|
||||
|
||||
public $mInvoiceNo;
|
||||
|
||||
public function getFormActions(): array
|
||||
@@ -121,8 +122,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
// ..GET SERIAL INVOICE API
|
||||
|
||||
if(strlen($invoiceNumber) > 15)
|
||||
{
|
||||
if (strlen($invoiceNumber) > 15) {
|
||||
|
||||
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
|
||||
|
||||
@@ -132,41 +132,44 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$payload = json_decode($payloadJson, true);
|
||||
|
||||
|
||||
if (!isset($payload['data'])) {
|
||||
if (! isset($payload['data'])) {
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$documentData = $payload['data'];
|
||||
|
||||
if($documentData == '' || $documentData == ''){
|
||||
if ($documentData == '' || $documentData == '') {
|
||||
Notification::make()
|
||||
->title('Invalid payload for scanned qr code.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract DocNo
|
||||
// Extract DocNo
|
||||
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
|
||||
|
||||
if (!isset($matches[1])) {
|
||||
if (! isset($matches[1])) {
|
||||
Notification::make()
|
||||
->title('Invoice number not found.')
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,7 +178,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
//dd($invoiceNumber);
|
||||
// dd($invoiceNumber);
|
||||
|
||||
// ..
|
||||
|
||||
@@ -1427,6 +1430,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$missingCodes = [];
|
||||
foreach ($rows as $index => $row) {
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
@@ -1438,8 +1442,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if (Str::length($materialCode) < 6) {
|
||||
continue;
|
||||
} else {
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) {
|
||||
$query->where('plant_id', $this->plantId)->where('code', $materialCode); // Check if item.code matches Excel's materialCode
|
||||
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($plantId, $materialCode) {
|
||||
$query->where('plant_id', $plantId)->where('code', $materialCode); // $this->plantId >> Check if item.code matches Excel's materialCode
|
||||
});
|
||||
if ($sticker->exists()) {
|
||||
if ($sticker->first()->material_type && ! empty($sticker->first()->material_type)) {
|
||||
@@ -1450,6 +1454,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$missingCodes[] = $materialCode;
|
||||
|
||||
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 = [];
|
||||
$materialCodes = [];
|
||||
$missingQuantities = [];
|
||||
@@ -3195,7 +3220,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
if (! empty($emails)) {
|
||||
Mail::to($emails)->send(
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,$mUserName,'NotFoundInvoice')
|
||||
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, $mUserName, 'NotFoundInvoice')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
|
||||
@@ -197,6 +197,7 @@ class ItemResource extends Resource
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('category')
|
||||
->label('Category')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -217,6 +218,7 @@ class ItemResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
@@ -237,6 +239,7 @@ class ItemResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Item Code')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
@@ -256,7 +259,7 @@ class ItemResource extends Resource
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
Select::make('code')
|
||||
->label('Search by Item Code')
|
||||
->label('Search by Code')
|
||||
->nullable()
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('Plant');
|
||||
|
||||
573
app/Filament/Resources/RequestCharacteristicResource.php
Normal file
573
app/Filament/Resources/RequestCharacteristicResource.php
Normal file
@@ -0,0 +1,573 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RequestCharacteristicResource extends Resource
|
||||
{
|
||||
protected static ?string $model = RequestCharacteristic::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Laser Marking';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
// $disableField = function ($get) {
|
||||
// $currentUser = Filament::auth()->user();
|
||||
// $approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
// if (!$approverId) return true; // disable if no approver selected
|
||||
|
||||
// $approver = CharacteristicApproverMaster::find($approverId);
|
||||
// if (!$approver) return true;
|
||||
|
||||
// // Enable if Super Admin
|
||||
// if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
// return false; // not disabled
|
||||
// }
|
||||
|
||||
// // Enable only if current user is one of the approvers
|
||||
// $userName = $currentUser?->name;
|
||||
|
||||
// return !in_array($userName, [
|
||||
// $approver->name1,
|
||||
// $approver->name2,
|
||||
// $approver->name3,
|
||||
// ]);
|
||||
// };
|
||||
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
// ->relationship('machine', 'name')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->required()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('request_characteristics', 'work_flow_id')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id'));
|
||||
// }),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item')
|
||||
// ->relationship('item', 'id')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->required()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\Select::make('characteristic_approver_master_id')
|
||||
->label('Characteristic Approver')
|
||||
// ->relationship('characteristicApproverMaster', 'id')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
$machineId = $get('machine_id');
|
||||
|
||||
if (! $plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$approvers = CharacteristicApproverMaster::where('plant_id', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->get();
|
||||
|
||||
$options = [];
|
||||
|
||||
foreach ($approvers as $approver) {
|
||||
if ($approver->name1) {
|
||||
$options[$approver->id.'_name1'] = $approver->name1;
|
||||
}
|
||||
if ($approver->name2) {
|
||||
$options[$approver->id.'_name2'] = $approver->name2;
|
||||
}
|
||||
if ($approver->name3) {
|
||||
$options[$approver->id.'_name3'] = $approver->name3;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
})
|
||||
->dehydrateStateUsing(function ($state, callable $set) {
|
||||
|
||||
if (empty($state) || ! str_contains($state, '_')) {
|
||||
return $state;
|
||||
}
|
||||
|
||||
$parts = explode('_', $state);
|
||||
|
||||
if (count($parts) != 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[$id, $level] = $parts;
|
||||
|
||||
$set('approver_level', $level);
|
||||
|
||||
return (int) $id;
|
||||
})
|
||||
->required()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('aufnr')
|
||||
->label('Aufnr')
|
||||
->reactive()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('characteristic_name')
|
||||
->label('Characteristic Name')
|
||||
->reactive()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('current_value')
|
||||
->label('Current Value')
|
||||
->reactive()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('update_value')
|
||||
->label('Update Value')
|
||||
->reactive()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\Select::make('approver_status1')
|
||||
->label('Approver Status 1')
|
||||
->reactive()
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user();
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Super Admin can edit any
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false; // field enabled
|
||||
}
|
||||
|
||||
// Otherwise, enable only if the user's name matches
|
||||
return $approver->name1 != $currentUser?->name;
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark1')
|
||||
->label('Approver Remark 1')
|
||||
->reactive(),
|
||||
Forms\Components\DateTimePicker::make('approved1_at')
|
||||
->label('Approved At 1')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // logged-in user
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $approver->name1 != $currentUser?->name;
|
||||
}),
|
||||
Forms\Components\Select::make('approver_status2')
|
||||
->label('Approver Status 2')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($state && empty($get('approved2_at'))) {
|
||||
$set('approved2_at', now());
|
||||
}
|
||||
})
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // get the User object
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Super Admin can always edit
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false; // ENABLE field
|
||||
}
|
||||
|
||||
// Otherwise, enable only if the user's name matches
|
||||
return $approver->name2 != $currentUser?->name;
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark2')
|
||||
->label('Approver Remark 2')
|
||||
->reactive(),
|
||||
Forms\Components\DateTimePicker::make('approved2_at')
|
||||
->label('Approverd At 2')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // logged-in user
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $approver->name2 != $currentUser?->name;
|
||||
})
|
||||
->dehydrated(true),
|
||||
Forms\Components\Select::make('approver_status3')
|
||||
->label('Approver Status 3')
|
||||
->reactive()
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user();
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
} else {
|
||||
return $approver->name3 != $currentUser?->name;
|
||||
}
|
||||
|
||||
}),
|
||||
Forms\Components\TextInput::make('approver_remark3')
|
||||
->label('Approver Remark 3')
|
||||
->reactive(),
|
||||
Forms\Components\DateTimePicker::make('approved3_at')
|
||||
->label('Approverd At 3')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
$currentUser = Filament::auth()->user(); // logged-in user
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return true;
|
||||
}
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $approver->name3 != $currentUser?->name;
|
||||
}),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected static function isFieldDisabled($get): bool
|
||||
{
|
||||
$currentUser = Filament::auth()->user();
|
||||
$approverId = $get('characteristic_approver_master_id');
|
||||
|
||||
if (! $approverId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (str_contains($approverId, '_')) {
|
||||
[$approverId, $level] = explode('_', $approverId);
|
||||
}
|
||||
|
||||
$approver = CharacteristicApproverMaster::find($approverId);
|
||||
if (! $approver) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($currentUser && $currentUser->hasRole('Super Admin')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$userName = $currentUser?->name;
|
||||
|
||||
return in_array($userName, [
|
||||
$approver->name1,
|
||||
$approver->name2,
|
||||
$approver->name3,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->alignCenter()
|
||||
->searchable(), // isIndividual: true
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('aufnr')
|
||||
->label('Aufnr')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_name')
|
||||
->label('Characteristic Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_value')
|
||||
->label('Current Value')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('update_value')
|
||||
->label('Update Value')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.name1')
|
||||
->label('Approver Name 1')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_status1')
|
||||
->label('Approver Status 1')
|
||||
// ->color('success')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved1_at')
|
||||
->label('Approver At 1')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.name2')
|
||||
->label('Approver Name 2')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_status2')
|
||||
->label('Approver Status 2')
|
||||
// ->color('danger')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved2_at')
|
||||
->label('Approver At 2')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.name3')
|
||||
->label('Approver Name 3')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_status3')
|
||||
->label('Approver Status 3')
|
||||
// ->color('primary')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved3_at')
|
||||
->label('Approver At 3')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Work Flow ID')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRequestCharacteristics::route('/'),
|
||||
'create' => Pages\CreateRequestCharacteristic::route('/create'),
|
||||
'view' => Pages\ViewRequestCharacteristic::route('/{record}'),
|
||||
'edit' => Pages\EditRequestCharacteristic::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRequestCharacteristic extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditRequestCharacteristic extends EditRecord
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRequestCharacteristics extends ListRecords
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RequestCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewRequestCharacteristic extends ViewRecord
|
||||
{
|
||||
protected static string $resource = RequestCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
// use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -93,21 +94,33 @@ class StickerMasterResource extends Resource
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return \App\Models\Item::where('plant_id', $get('plant_id'))
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
if (! $get('id')) {
|
||||
// whereHas
|
||||
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()
|
||||
->nullable()
|
||||
// ->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->disabled(fn (Get $get) => !empty($get('id')))
|
||||
@@ -132,7 +145,7 @@ class StickerMasterResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
|
||||
$availableItems = Item::where('plant_id', $plantId)->exists();
|
||||
if (! $availableItems) {
|
||||
$set('item_error', null);
|
||||
|
||||
@@ -147,7 +160,7 @@ class StickerMasterResource extends Resource
|
||||
}
|
||||
|
||||
// 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)
|
||||
->first();
|
||||
|
||||
@@ -161,7 +174,8 @@ class StickerMasterResource extends Resource
|
||||
->where('item_id', $itemId)
|
||||
->exists();
|
||||
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) => [
|
||||
@@ -177,7 +191,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('id')) {
|
||||
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
|
||||
if ($itemId) {
|
||||
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
|
||||
$item = Item::where('id', $itemId)->first()?->description;
|
||||
if ($item) {
|
||||
$set('item_description', $item);
|
||||
} else {
|
||||
@@ -525,27 +539,35 @@ class StickerMasterResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation1')
|
||||
->label('Part Validation 1')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation2')
|
||||
->label('Part Validation 2')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation3')
|
||||
->label('Part Validation 3')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation4')
|
||||
->label('Part Validation 4')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('part_validation5')
|
||||
->label('Part Validation 5')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('laser_part_validation1')
|
||||
->label('Laser Part Validation 1')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('laser_part_validation2')
|
||||
->label('Laser Part Validation 2')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('load_rate')
|
||||
->label('Load Rate')
|
||||
@@ -553,20 +575,22 @@ class StickerMasterResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bundle_quantity')
|
||||
->label('Bundle Quantity')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('material_type')
|
||||
->label('Material Type')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->formatStateUsing(function ($state) {
|
||||
if (is_null($state) || $state === '') {
|
||||
return '';
|
||||
if (is_null($state) || $state == '') {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return match ($state) {
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
default => '',
|
||||
default => '-',
|
||||
};
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
@@ -587,9 +611,7 @@ class StickerMasterResource extends Resource
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->searchPlaceholder('Search Item Code')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
@@ -635,7 +657,7 @@ class StickerMasterResource extends Resource
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('material_type')
|
||||
->label('Material Type')
|
||||
->label('Select Material Type')
|
||||
->options([
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
@@ -644,7 +666,7 @@ class StickerMasterResource extends Resource
|
||||
->reactive(),
|
||||
|
||||
TextInput::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->label('Search by Panel Box Code')
|
||||
->placeholder(placeholder: 'Enter Panel Box Code'),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
|
||||
@@ -80,7 +80,7 @@ class InvoiceChart extends ChartWidget
|
||||
$completedInvoicesCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"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')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"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]);
|
||||
|
||||
$completedQuery->where('quantity', 1)
|
||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
||||
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"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]);
|
||||
|
||||
$completedQuery->whereNull('quantity')
|
||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
||||
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"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]);
|
||||
|
||||
$completedQuery->where('quantity', '>', 1)
|
||||
->whereBetween('updated_at', [$dayStart, $dayEnd])
|
||||
->whereBetween('created_at', [$dayStart, $dayEnd])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw(
|
||||
"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') {
|
||||
$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');
|
||||
|
||||
// Prepare weekly labels like "May(1-7)", "May(8-14)", etc.
|
||||
$labels = [];
|
||||
$weekStart = $startOfMonth->copy();
|
||||
$importedInvoicesPerWeek = [];
|
||||
$completedInvoicesPerWeek = [];
|
||||
|
||||
$weekIndex = 0;
|
||||
while ($weekStart < $endOfMonth) {
|
||||
$weekEnd = $weekStart->copy()->addDays(7);
|
||||
while ($weekStart <= $endOfMonth) {
|
||||
// $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');
|
||||
$weekEndLimit = $weekEnd->copy()->subDay();
|
||||
$actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
|
||||
$endDay = $actualEnd->format('j');
|
||||
$endDay = $weekEnd->format('j');
|
||||
|
||||
// $startDay = $weekStart->format('j');
|
||||
// $weekEndLimit = $weekEnd->copy()->subDay();
|
||||
// $actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
|
||||
// $endDay = $actualEnd->format('j');
|
||||
|
||||
$labels[] = "{$monthName}({$startDay}-{$endDay})";
|
||||
|
||||
@@ -233,7 +242,7 @@ class InvoiceChart extends ChartWidget
|
||||
// --- Completed ---
|
||||
$queryCompleted = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $selectedPlant)
|
||||
->whereBetween('updated_at', [$weekStart, $weekEnd]);
|
||||
->whereBetween('created_at', [$weekStart, $weekEnd]);
|
||||
|
||||
if ($selectedInvoice == 'individual_material') {
|
||||
$queryCompleted->where('quantity', 1)
|
||||
@@ -252,7 +261,8 @@ class InvoiceChart extends ChartWidget
|
||||
$completedInvoicesPerWeek[$weekIndex] = $queryCompleted->count();
|
||||
|
||||
// Move to next week
|
||||
$weekStart = $weekEnd;
|
||||
// $weekStart = $weekEnd;
|
||||
$weekStart = $weekEnd->copy()->addDay(1);
|
||||
$weekIndex++;
|
||||
}
|
||||
|
||||
@@ -298,6 +308,7 @@ class InvoiceChart extends ChartWidget
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
|
||||
public static function getDefaultName(): string
|
||||
{
|
||||
return 'invoice-chart';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -70,6 +70,10 @@ class ProductionStickerReprintController extends Controller
|
||||
{
|
||||
$copies = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$copies = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
126
app/Imports/InvoicePendingReasonImport.php
Normal file
126
app/Imports/InvoicePendingReasonImport.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
//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');
|
||||
}
|
||||
}
|
||||
43
app/Models/CharacteristicApproverMaster.php
Normal file
43
app/Models/CharacteristicApproverMaster.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CharacteristicApproverMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'machine_id',
|
||||
'machine_name',
|
||||
'name1',
|
||||
'mail1',
|
||||
'name2',
|
||||
'mail2',
|
||||
'name3',
|
||||
'mail3',
|
||||
'duration1',
|
||||
'duration2',
|
||||
'duration3',
|
||||
'characteristic_field',
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
}
|
||||
182
app/Models/ClassCharacteristic.php
Normal file
182
app/Models/ClassCharacteristic.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ClassCharacteristic extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'item_id',
|
||||
'machine_id',
|
||||
'aufnr',
|
||||
'class',
|
||||
'arbid',
|
||||
'gamng',
|
||||
'lmnga',
|
||||
'gernr',
|
||||
'zz1_cn_bill_ord',
|
||||
'zmm_amps',
|
||||
'zmm_brand',
|
||||
'zmm_degreeofprotection',
|
||||
'zmm_delivery',
|
||||
'zmm_dir_rot',
|
||||
'zmm_discharge',
|
||||
'zmm_discharge_max',
|
||||
'zmm_discharge_min',
|
||||
'zmm_duty',
|
||||
'zmm_eff_motor',
|
||||
'zmm_eff_pump',
|
||||
'zmm_frequency',
|
||||
'zmm_head',
|
||||
'zmm_heading',
|
||||
'zmm_head_max',
|
||||
'zmm_head_minimum',
|
||||
'zmm_idx_eff_mtr',
|
||||
'zmm_idx_eff_pump',
|
||||
'zmm_kvacode',
|
||||
'zmm_maxambtemp',
|
||||
'zmm_mincoolingflow',
|
||||
'zmm_motorseries',
|
||||
'zmm_motor_model',
|
||||
'zmm_outlet',
|
||||
'zmm_phase',
|
||||
'zmm_pressure',
|
||||
'zmm_pumpflowtype',
|
||||
'zmm_pumpseries',
|
||||
'zmm_pump_model',
|
||||
'zmm_ratedpower',
|
||||
'zmm_region',
|
||||
'zmm_servicefactor',
|
||||
'zmm_servicefactormaximumamps',
|
||||
'zmm_speed',
|
||||
'zmm_suction',
|
||||
'zmm_suctionxdelivery',
|
||||
'zmm_supplysource',
|
||||
'zmm_temperature',
|
||||
'zmm_thrustload',
|
||||
'zmm_volts',
|
||||
'zmm_wire',
|
||||
'zmm_package',
|
||||
'zmm_pvarrayrating',
|
||||
'zmm_isi',
|
||||
'zmm_isimotor',
|
||||
'zmm_isipump',
|
||||
'zmm_isipumpset',
|
||||
'zmm_pumpset_model',
|
||||
'zmm_stages',
|
||||
'zmm_headrange',
|
||||
'zmm_overall_efficiency',
|
||||
'zmm_connection',
|
||||
'zmm_min_bore_size',
|
||||
'zmm_isireference',
|
||||
'zmm_category',
|
||||
'zmm_submergence',
|
||||
'zmm_capacitorstart',
|
||||
'zmm_capacitorrun',
|
||||
'zmm_inch',
|
||||
'zmm_motor_type',
|
||||
'zmm_dismantle_direction',
|
||||
'zmm_eff_ovrall',
|
||||
'zmm_bodymoc',
|
||||
'zmm_rotormoc',
|
||||
'zmm_dlwl',
|
||||
'zmm_inputpower',
|
||||
'zmm_imp_od',
|
||||
'zmm_ambtemp',
|
||||
'zmm_de',
|
||||
'zmm_dischargerange',
|
||||
'zmm_efficiency_class',
|
||||
'zmm_framesize',
|
||||
'zmm_impellerdiameter',
|
||||
'zmm_insulationclass',
|
||||
'zmm_maxflow',
|
||||
'zmm_minhead',
|
||||
'zmm_mtrlofconst',
|
||||
'zmm_nde',
|
||||
'zmm_powerfactor',
|
||||
'zmm_tagno',
|
||||
'zmm_year',
|
||||
'zmm_laser_name',
|
||||
'zmm_beenote',
|
||||
'zmm_beenumber',
|
||||
'zmm_beestar',
|
||||
'zmm_codeclass',
|
||||
'zmm_colour',
|
||||
'zmm_logo_cp',
|
||||
'zmm_logo_ce',
|
||||
'zmm_logo_nsf',
|
||||
'zmm_grade',
|
||||
'zmm_grwt_pset',
|
||||
'zmm_grwt_cable',
|
||||
'zmm_grwt_motor',
|
||||
'zmm_grwt_pf',
|
||||
'zmm_grwt_pump',
|
||||
'zmm_isivalve',
|
||||
'zmm_isi_wc',
|
||||
'zmm_labelperiod',
|
||||
'zmm_length',
|
||||
'zmm_license_cml_no',
|
||||
'zmm_mfgmonyr',
|
||||
'zmm_modelyear',
|
||||
'zmm_motoridentification',
|
||||
'zmm_newt_pset',
|
||||
'zmm_newt_cable',
|
||||
'zmm_newt_motor',
|
||||
'zmm_newt_pf',
|
||||
'zmm_newt_pump',
|
||||
'zmm_packtype',
|
||||
'zmm_panel',
|
||||
'zmm_performance_factor',
|
||||
'zmm_pumpidentification',
|
||||
'zmm_psettype',
|
||||
'zmm_size',
|
||||
'zmm_eff_ttl',
|
||||
'zmm_type',
|
||||
'zmm_usp',
|
||||
'mark_status',
|
||||
'marked_datetime',
|
||||
'marked_by',
|
||||
'man_marked_status',
|
||||
'man_marked_datetime',
|
||||
'man_marked_by',
|
||||
'motor_marked_status',
|
||||
'motor_marked_by',
|
||||
'pump_marked_status',
|
||||
'pump_marked_by',
|
||||
'motor_pump_pumpset_status',
|
||||
'motor_machine_name',
|
||||
'pump_machine_name',
|
||||
'pumpset_machine_name',
|
||||
'part_validation_1',
|
||||
'part_validation_2',
|
||||
'samlight_logged_name',
|
||||
'pending_released_status',
|
||||
'motor_expected_time',
|
||||
'pump_expected_time',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
}
|
||||
99
app/Models/RequestCharacteristic.php
Normal file
99
app/Models/RequestCharacteristic.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RequestCharacteristic extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'machine_id',
|
||||
'item_id',
|
||||
'characteristic_approver_master_id',
|
||||
'aufnr',
|
||||
'characteristic_name',
|
||||
'current_value',
|
||||
'update_value',
|
||||
'approver_status1',
|
||||
'approver_status2',
|
||||
'approver_status3',
|
||||
'approver_remark1',
|
||||
'approver_remark2',
|
||||
'approver_remark3',
|
||||
'approved1_at',
|
||||
'approved2_at',
|
||||
'approved3_at',
|
||||
'mail_status',
|
||||
'trigger_at',
|
||||
'work_flow_id',
|
||||
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
|
||||
public function characteristicApproverMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CharacteristicApproverMaster::class);
|
||||
}
|
||||
|
||||
// public function approverName1()
|
||||
// {
|
||||
// return $this->belongsTo(
|
||||
// CharacteristicApproverMaster::class,
|
||||
// 'characteristic_approver_master_id'
|
||||
// );
|
||||
// }
|
||||
|
||||
// public function approverName2()
|
||||
// {
|
||||
// return $this->belongsTo(
|
||||
// CharacteristicApproverMaster::class,
|
||||
// 'characteristic_approver_master_id'
|
||||
// );
|
||||
// }
|
||||
|
||||
// public function approverName3()
|
||||
// {
|
||||
// return $this->belongsTo(
|
||||
// CharacteristicApproverMaster::class,
|
||||
// 'characteristic_approver_master_id'
|
||||
// );
|
||||
// }
|
||||
|
||||
public function approver()
|
||||
{
|
||||
return $this->belongsTo(
|
||||
CharacteristicApproverMaster::class,
|
||||
'characteristic_approver_master_id'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
106
app/Policies/CharacteristicApproverMasterPolicy.php
Normal file
106
app/Policies/CharacteristicApproverMasterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\User;
|
||||
|
||||
class CharacteristicApproverMasterPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, CharacteristicApproverMaster $characteristicapprovermaster): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete CharacteristicApproverMaster');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any CharacteristicApproverMaster');
|
||||
}
|
||||
}
|
||||
106
app/Policies/ClassCharacteristicPolicy.php
Normal file
106
app/Policies/ClassCharacteristicPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\User;
|
||||
|
||||
class ClassCharacteristicPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ClassCharacteristic $classcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ClassCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ClassCharacteristic');
|
||||
}
|
||||
}
|
||||
106
app/Policies/RequestCharacteristicPolicy.php
Normal file
106
app/Policies/RequestCharacteristicPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use App\Models\User;
|
||||
|
||||
class RequestCharacteristicPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, RequestCharacteristic $requestcharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete RequestCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any RequestCharacteristic');
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
"tpetry/laravel-postgresql-enhanced": "^2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.15",
|
||||
"barryvdh/laravel-debugbar": "^4.0",
|
||||
"barryvdh/laravel-ide-helper": "^3.5",
|
||||
"beyondcode/laravel-dump-server": "^2.1",
|
||||
"fakerphp/faker": "^1.23",
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE class_characteristics (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
item_id BIGINT NOT NULL,
|
||||
aufnr TEXT DEFAULT NULL,
|
||||
class TEXT DEFAULT NULL,
|
||||
arbid TEXT DEFAULT NULL,
|
||||
gamng TEXT DEFAULT NULL,
|
||||
lmnga TEXT DEFAULT NULL,
|
||||
gernr TEXT DEFAULT NULL,
|
||||
zz1_cn_bill_ord TEXT DEFAULT NULL,
|
||||
zmm_amps TEXT DEFAULT NULL,
|
||||
zmm_brand TEXT DEFAULT NULL,
|
||||
zmm_degreeofprotection TEXT DEFAULT NULL,
|
||||
zmm_delivery TEXT DEFAULT NULL,
|
||||
zmm_dir_rot TEXT DEFAULT NULL,
|
||||
zmm_discharge TEXT DEFAULT NULL,
|
||||
zmm_discharge_max TEXT DEFAULT NULL,
|
||||
zmm_discharge_min TEXT DEFAULT NULL,
|
||||
zmm_duty TEXT DEFAULT NULL,
|
||||
zmm_eff_motor TEXT DEFAULT NULL,
|
||||
zmm_eff_pump TEXT DEFAULT NULL,
|
||||
zmm_frequency TEXT DEFAULT NULL,
|
||||
zmm_head TEXT DEFAULT NULL,
|
||||
zmm_heading TEXT DEFAULT NULL,
|
||||
zmm_head_max TEXT DEFAULT NULL,
|
||||
zmm_head_minimum TEXT DEFAULT NULL,
|
||||
zmm_idx_eff_mtr TEXT DEFAULT NULL,
|
||||
zmm_idx_eff_pump TEXT DEFAULT NULL,
|
||||
zmm_kvacode TEXT DEFAULT NULL,
|
||||
zmm_maxambtemp TEXT DEFAULT NULL,
|
||||
zmm_mincoolingflow TEXT DEFAULT NULL,
|
||||
zmm_motorseries TEXT DEFAULT NULL,
|
||||
zmm_motor_model TEXT DEFAULT NULL,
|
||||
zmm_outlet TEXT DEFAULT NULL,
|
||||
zmm_phase TEXT DEFAULT NULL,
|
||||
zmm_pressure TEXT DEFAULT NULL,
|
||||
zmm_pumpflowtype TEXT DEFAULT NULL,
|
||||
zmm_pumpseries TEXT DEFAULT NULL,
|
||||
zmm_pump_model TEXT DEFAULT NULL,
|
||||
zmm_ratedpower TEXT DEFAULT NULL,
|
||||
zmm_region TEXT DEFAULT NULL,
|
||||
zmm_servicefactor TEXT DEFAULT NULL,
|
||||
zmm_servicefactormaximumamps TEXT DEFAULT NULL,
|
||||
zmm_speed TEXT DEFAULT NULL,
|
||||
zmm_suction TEXT DEFAULT NULL,
|
||||
zmm_suctionxdelivery TEXT DEFAULT NULL,
|
||||
zmm_supplysource TEXT DEFAULT NULL,
|
||||
zmm_temperature TEXT DEFAULT NULL,
|
||||
zmm_thrustload TEXT DEFAULT NULL,
|
||||
zmm_volts TEXT DEFAULT NULL,
|
||||
zmm_wire TEXT DEFAULT NULL,
|
||||
zmm_package TEXT DEFAULT NULL,
|
||||
zmm_pvarrayrating TEXT DEFAULT NULL,
|
||||
zmm_isi TEXT DEFAULT NULL,
|
||||
zmm_isimotor TEXT DEFAULT NULL,
|
||||
zmm_isipump TEXT DEFAULT NULL,
|
||||
zmm_isipumpset TEXT DEFAULT NULL,
|
||||
zmm_pumpset_model TEXT DEFAULT NULL,
|
||||
zmm_stages TEXT DEFAULT NULL,
|
||||
zmm_headrange TEXT DEFAULT NULL,
|
||||
zmm_overall_efficiency TEXT DEFAULT NULL,
|
||||
zmm_connection TEXT DEFAULT NULL,
|
||||
zmm_min_bore_size TEXT DEFAULT NULL,
|
||||
zmm_isireference TEXT DEFAULT NULL,
|
||||
zmm_category TEXT DEFAULT NULL,
|
||||
zmm_submergence TEXT DEFAULT NULL,
|
||||
zmm_capacitorstart TEXT DEFAULT NULL,
|
||||
zmm_capacitorrun TEXT DEFAULT NULL,
|
||||
zmm_inch TEXT DEFAULT NULL,
|
||||
zmm_motor_type TEXT DEFAULT NULL,
|
||||
zmm_dismantle_direction TEXT DEFAULT NULL,
|
||||
zmm_eff_ovrall TEXT DEFAULT NULL,
|
||||
zmm_bodymoc TEXT DEFAULT NULL,
|
||||
zmm_rotormoc TEXT DEFAULT NULL,
|
||||
zmm_dlwl TEXT DEFAULT NULL,
|
||||
zmm_inputpower TEXT DEFAULT NULL,
|
||||
zmm_imp_od TEXT DEFAULT NULL,
|
||||
zmm_ambtemp TEXT DEFAULT NULL,
|
||||
zmm_de TEXT DEFAULT NULL,
|
||||
zmm_dischargerange TEXT DEFAULT NULL,
|
||||
zmm_efficiency_class TEXT DEFAULT NULL,
|
||||
zmm_framesize TEXT DEFAULT NULL,
|
||||
zmm_impellerdiameter TEXT DEFAULT NULL,
|
||||
zmm_insulationclass TEXT DEFAULT NULL,
|
||||
zmm_maxflow TEXT DEFAULT NULL,
|
||||
zmm_minhead TEXT DEFAULT NULL,
|
||||
zmm_mtrlofconst TEXT DEFAULT NULL,
|
||||
zmm_nde TEXT DEFAULT NULL,
|
||||
zmm_powerfactor TEXT DEFAULT NULL,
|
||||
zmm_tagno TEXT DEFAULT NULL,
|
||||
zmm_year TEXT DEFAULT NULL,
|
||||
zmm_laser_name TEXT DEFAULT NULL,
|
||||
zmm_beenote TEXT DEFAULT NULL,
|
||||
zmm_beenumber TEXT DEFAULT NULL,
|
||||
zmm_beestar TEXT DEFAULT NULL,
|
||||
zmm_codeclass TEXT DEFAULT NULL,
|
||||
zmm_colour TEXT DEFAULT NULL,
|
||||
zmm_grade TEXT DEFAULT NULL,
|
||||
zmm_grwt_pset TEXT DEFAULT NULL,
|
||||
zmm_grwt_cable TEXT DEFAULT NULL,
|
||||
zmm_grwt_motor TEXT DEFAULT NULL,
|
||||
zmm_grwt_pf TEXT DEFAULT NULL,
|
||||
zmm_grwt_pump TEXT DEFAULT NULL,
|
||||
zmm_isivalve TEXT DEFAULT NULL,
|
||||
zmm_isi_wc TEXT DEFAULT NULL,
|
||||
zmm_labelperiod TEXT DEFAULT NULL,
|
||||
zmm_length TEXT DEFAULT NULL,
|
||||
zmm_license_cml_no TEXT DEFAULT NULL,
|
||||
zmm_mfgmonyr TEXT DEFAULT NULL,
|
||||
zmm_modelyear TEXT DEFAULT NULL,
|
||||
zmm_motoridentification TEXT DEFAULT NULL,
|
||||
zmm_newt_pset TEXT DEFAULT NULL,
|
||||
zmm_newt_cable TEXT DEFAULT NULL,
|
||||
zmm_newt_motor TEXT DEFAULT NULL,
|
||||
zmm_newt_pf TEXT DEFAULT NULL,
|
||||
zmm_newt_pump TEXT DEFAULT NULL,
|
||||
zmm_logo_cp TEXT DEFAULT NULL,
|
||||
zmm_logo_ce TEXT DEFAULT NULL,
|
||||
zmm_logo_nsf TEXT DEFAULT NULL,
|
||||
zmm_packtype TEXT DEFAULT NULL,
|
||||
zmm_panel TEXT DEFAULT NULL,
|
||||
zmm_performance_factor TEXT DEFAULT NULL,
|
||||
zmm_pumpidentification TEXT DEFAULT NULL,
|
||||
zmm_psettype TEXT DEFAULT NULL,
|
||||
zmm_size TEXT DEFAULT NULL,
|
||||
zmm_eff_ttl TEXT DEFAULT NULL,
|
||||
zmm_type TEXT DEFAULT NULL,
|
||||
zmm_usp TEXT DEFAULT NULL,
|
||||
mark_status TEXT DEFAULT NULL,
|
||||
marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
marked_by TEXT DEFAULT NULL,
|
||||
man_marked_status TEXT DEFAULT '0',
|
||||
man_marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
man_marked_by TEXT DEFAULT NULL,
|
||||
motor_marked_status TEXT DEFAULT NULL,
|
||||
motor_marked_by TEXT DEFAULT NULL,
|
||||
pump_marked_status TEXT DEFAULT NULL,
|
||||
pump_marked_by TEXT DEFAULT NULL,
|
||||
motor_pump_pumpset_status TEXT DEFAULT NULL,
|
||||
motor_machine_name TEXT DEFAULT NULL,
|
||||
pump_machine_name TEXT DEFAULT NULL,
|
||||
pumpset_machine_name TEXT DEFAULT NULL,
|
||||
part_validation_1 TEXT DEFAULT NULL,
|
||||
part_validation_2 TEXT DEFAULT NULL,
|
||||
samlight_logged_name TEXT DEFAULT NULL,
|
||||
pending_released_status INTEGER DEFAULT 0,
|
||||
motor_expected_time TEXT DEFAULT '0',
|
||||
pump_expected_time TEXT DEFAULT '0',
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (machine_id) REFERENCES machines (id),
|
||||
FOREIGN KEY (item_id) REFERENCES items (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('class_characteristics');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE request_characteristics (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
item_id BIGINT NOT NULL,
|
||||
characteristic_approver_master_id BIGINT NOT NULL,
|
||||
aufnr TEXT DEFAULT NULL,
|
||||
characteristic_name TEXT DEFAULT NULL,
|
||||
current_value TEXT DEFAULT NULL,
|
||||
update_value TEXT DEFAULT NULL,
|
||||
|
||||
approver_status1 TEXT DEFAULT NULL,
|
||||
approver_status2 TEXT DEFAULT NULL,
|
||||
approver_status3 TEXT DEFAULT NULL,
|
||||
|
||||
approver_remark1 TEXT DEFAULT NULL,
|
||||
approver_remark2 TEXT DEFAULT NULL,
|
||||
approver_remark3 TEXT DEFAULT NULL,
|
||||
|
||||
work_flow_id TEXT DEFAULT NULL,
|
||||
mail_status TEXT DEFAULT NULL,
|
||||
trigger_at TIMESTAMP,
|
||||
|
||||
approved1_at TIMESTAMP,
|
||||
approved2_at TIMESTAMP,
|
||||
approved3_at TIMESTAMP,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants(id),
|
||||
FOREIGN KEY (machine_id) REFERENCES machines(id),
|
||||
FOREIGN KEY (item_id) REFERENCES items(id),
|
||||
FOREIGN KEY (characteristic_approver_master_id) REFERENCES characteristic_approver_masters(id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('request_characteristics');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE characteristic_approver_masters (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
|
||||
plant_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
machine_name TEXT DEFAULT NULL,
|
||||
characteristic_field TEXT DEFAULT NULL,
|
||||
name1 TEXT DEFAULT NULL,
|
||||
mail1 TEXT DEFAULT NULL,
|
||||
name2 TEXT DEFAULT NULL,
|
||||
mail2 TEXT DEFAULT NULL,
|
||||
name3 TEXT DEFAULT NULL,
|
||||
mail3 TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants(id),
|
||||
FOREIGN KEY (machine_id) REFERENCES machines(id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('characteristic_approver_masters');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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 characteristic_approver_masters
|
||||
ADD COLUMN duration1 NUMERIC(4, 2) DEFAULT 0
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
|
||||
$sql2 = <<<'SQL'
|
||||
ALTER TABLE characteristic_approver_masters
|
||||
ADD COLUMN duration2 NUMERIC(4, 2) DEFAULT 0
|
||||
SQL;
|
||||
|
||||
DB::statement($sql2);
|
||||
|
||||
$sql3 = <<<'SQL'
|
||||
ALTER TABLE characteristic_approver_masters
|
||||
ADD COLUMN duration3 NUMERIC(4, 2) DEFAULT 0
|
||||
SQL;
|
||||
|
||||
DB::statement($sql3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('characteristic_approver_masters', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -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' => 'create production sticker reject reason 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 export invoice out validation']);
|
||||
Permission::updateOrCreate(['name' => 'view import invoice data validation']);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
</div>
|
||||
<div class="flex-row gap-2 mt-4">
|
||||
<x-filament::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" --}}
|
||||
wire:click="addRemark"
|
||||
color="primary"
|
||||
class="mt-4"
|
||||
>
|
||||
Save
|
||||
</x-filament::button>
|
||||
|
||||
<x-filament::button
|
||||
wire:click="importPendingReason"
|
||||
color="primary"
|
||||
class="mt-4"
|
||||
>
|
||||
Import
|
||||
</x-filament::button>
|
||||
<x-filament::button
|
||||
wire:click="exportPendingReason"
|
||||
color="primary"
|
||||
class="mt-4"
|
||||
>
|
||||
Export
|
||||
</x-filament::button>
|
||||
<div class="bg-white shadow rounded-xl p-4 mt-6">
|
||||
<livewire:invoice-pending />
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
19
resources/views/filament/pages/welcome.blade.php
Normal file
19
resources/views/filament/pages/welcome.blade.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<h1 class="text-3xl font-bold mb-6">Welcome to CRI Digital Manufacturing IIOT</h1>
|
||||
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-64 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<p class="text-lg text-gray-600 mb-6">
|
||||
This dashboard provides real-time visibility into your manufacturing operations,
|
||||
enabling you to monitor production, track performance, and make data-driven decisions
|
||||
across plants and lines—all from one centralized platform.
|
||||
</p>
|
||||
|
||||
</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>
|
||||
@@ -86,7 +86,7 @@
|
||||
<th>LR Number</th>
|
||||
<th>LR Date</th>
|
||||
<th>Transit Days</th>
|
||||
<th>Pending Days</th>
|
||||
<th>Overdue Days</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<th>Location</th>
|
||||
<th>Pending Days</th>
|
||||
<th>Status</th>
|
||||
<th>Remark</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -117,6 +118,7 @@
|
||||
<td class="{{ $row['status_class'] ?? '' }}">
|
||||
{{ $row['status'] }}
|
||||
</td>
|
||||
<td>{{ $row['remark'] ?? '-'}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\CharacteristicApprovalController;
|
||||
use App\Http\Controllers\CharacteristicsController;
|
||||
use App\Http\Controllers\EquipmentMasterController;
|
||||
use App\Http\Controllers\InvoiceValidationController;
|
||||
@@ -45,7 +46,6 @@ use Illuminate\Support\Facades\Route;
|
||||
|
||||
// Route::post('/user/update', function (Request $request) {
|
||||
// // Return the request data as JSON
|
||||
|
||||
// // dd($request);
|
||||
// return response()->json([
|
||||
// 'message' => 'User updated successfully',
|
||||
@@ -77,7 +77,7 @@ Route::get('/download-reprint-qr-pdf/{palletNo}', [PalletController::class, 'dow
|
||||
|
||||
// Route::get('/download-reprint-process-pdf/{plant}/{item}/{process_order}/{coil_number}/{name}', [PalletController::class, 'downloadReprintProcess'])->name('download-reprint-process-pdf');
|
||||
|
||||
//Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->where('palletNo', '.*')->name('download-qr1-pdf');
|
||||
// Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->where('palletNo', '.*')->name('download-qr1-pdf');
|
||||
Route::get('/download-qr1-pdf', [ProductionStickerReprintController::class, 'downloadQrPdf'])
|
||||
->name('download-qr1-pdf');
|
||||
|
||||
@@ -155,29 +155,37 @@ Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
|
||||
|
||||
Route::get('sap/files', [SapFileController::class, 'readFiles']);
|
||||
|
||||
// ..Laser Marking - Characteristics
|
||||
|
||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||
|
||||
Route::post('laser/route/data', [CharacteristicsController::class, 'test']); // ->withoutMiddleware(VerifyCsrfToken::class)
|
||||
Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||
|
||||
// ..Part Validation - Characteristics
|
||||
|
||||
// Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||
|
||||
// ..Serial or job
|
||||
// ..Laser Route to SAP
|
||||
|
||||
// Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
|
||||
Route::post('laser/route/data', [CharacteristicsController::class, 'test']); // ->withoutMiddleware(VerifyCsrfToken::class)
|
||||
|
||||
// Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
|
||||
// ..Job or Serial - Characteristics
|
||||
|
||||
Route::get('laser/characteristics/get', [CharacteristicsController::class, 'getClassChar']);
|
||||
|
||||
Route::get('laser/characteristics/check', [CharacteristicsController::class, 'checkClassChar']);
|
||||
|
||||
// ..Job or Master - Characteristics
|
||||
|
||||
// Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
|
||||
// ..serial auto or manual
|
||||
// ..serial (auto or manual)
|
||||
|
||||
// Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
|
||||
// ..Request Characteristics
|
||||
|
||||
Route::post('laser/characteristics/change', [CharacteristicsController::class, 'storeLaserRequestChar']);
|
||||
|
||||
Route::get('laser/characteristics/request', [CharacteristicsController::class, 'getLaserRequestChar']);
|
||||
|
||||
Route::post('laser-doc-pdf', [PdfController::class, 'storeLaserPdf']);
|
||||
|
||||
// ..Product Characteristics
|
||||
|
||||
@@ -195,6 +203,13 @@ Route::post('grmaster-sno-update', [PdfController::class, 'updateGR']);
|
||||
|
||||
Route::post('file/store', [SapFileController::class, 'store'])->name('file.store');
|
||||
|
||||
// routes/api.php
|
||||
// Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave']);
|
||||
|
||||
// Route::post('send-telegram', [TelegramController::class, 'sendMessage']);
|
||||
|
||||
// Route::post('invoice-exit', [InvoiceValidationController::class, 'handle']);
|
||||
|
||||
|
||||
// Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave'])
|
||||
// ->name('characteristic.hold.save');
|
||||
|
||||
247
routes/web.php
247
routes/web.php
@@ -1,76 +1,116 @@
|
||||
<?php
|
||||
|
||||
use App\Mail\test;
|
||||
use App\Http\Controllers\CharacteristicApprovalController;
|
||||
use App\Http\Controllers\FileUploadController;
|
||||
use App\Models\EquipmentMaster;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
|
||||
Route::get('/', function () {
|
||||
return redirect('/admin');
|
||||
});
|
||||
|
||||
Route::get('/', function () {
|
||||
return redirect('/admin');
|
||||
});
|
||||
// Route::get('/admin', function () {
|
||||
// return redirect('/admin/welcome');
|
||||
// });
|
||||
|
||||
// routes/web.php
|
||||
Route::post('/save-serials-to-session', function (Request $request) {
|
||||
session(['serial_numbers' => $request->serial_numbers]);
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'serial_numbers' => session('serial_numbers'),
|
||||
]);
|
||||
});
|
||||
// ..Characteristic Approval Routes..//
|
||||
|
||||
Route::get('/part-validation-image/{filename}', function ($filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$filename}");
|
||||
Route::get('/characteristic/hold', [CharacteristicApprovalController::class, 'holdForm'])
|
||||
->name('characteristic.hold')
|
||||
->middleware('signed');
|
||||
|
||||
if (!file_exists($path)) {
|
||||
abort(404, 'Image not found');
|
||||
}
|
||||
Route::post('/characteristic/hold-save', [CharacteristicApprovalController::class, 'holdSave'])
|
||||
->name('characteristic.hold.save');
|
||||
|
||||
return response()->file($path);
|
||||
})->name('part.validation.image');
|
||||
Route::get('/approval/hold-success', function () {
|
||||
return view('approval.hold-success');
|
||||
})->name('approval.hold.success');
|
||||
|
||||
// web.php
|
||||
Route::post('/temp-upload', function (Request $request) {
|
||||
if (!$request->hasFile('photo')) {
|
||||
return response()->json(['success' => false], 400);
|
||||
}
|
||||
Route::get('/characteristic/reject', [CharacteristicApprovalController::class, 'rejectForm'])
|
||||
->name('characteristic.reject')
|
||||
->middleware('signed');
|
||||
|
||||
$file = $request->file('photo');
|
||||
$filename = 'capture_' . time() . '.jpeg';
|
||||
$path = $file->storeAs('temp', $filename, 'local'); // storage/app/temp
|
||||
Route::post('/characteristic/reject-save', [CharacteristicApprovalController::class, 'rejectSave'])
|
||||
->name('characteristic.reject.save');
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $path,
|
||||
]);
|
||||
});
|
||||
Route::get('/approval/reject-success', function () {
|
||||
return view('approval.reject-success');
|
||||
})->name('approval.reject.success');
|
||||
|
||||
Route::post('/verify-ocr', function (Request $request) {
|
||||
Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approve'])
|
||||
->name('characteristic.approve')
|
||||
->middleware('signed');
|
||||
|
||||
if (!$request->has('path')) {
|
||||
return response()->json(['success' => false, 'error' => 'No file path provided']);
|
||||
}
|
||||
Route::post('/file-upload', [FileUploadController::class, 'upload'])->name('file.upload');
|
||||
|
||||
$filePath = storage_path('app/private/temp/' . basename($request->path));
|
||||
// Route::get('/characteristic/hold', [CharacteristicApprovalController::class, 'hold'])
|
||||
// ->name('characteristic.hold')
|
||||
// ->middleware('signed');
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
return response()->json(['success' => false, 'error' => 'File not found']);
|
||||
}
|
||||
// Route::get('/characteristic/reject', [CharacteristicApprovalController::class, 'reject'])
|
||||
// ->name('characteristic.reject')
|
||||
// ->middleware('signed');
|
||||
|
||||
try {
|
||||
// routes/web.php
|
||||
Route::post('/save-serials-to-session', function (Request $request) {
|
||||
session(['serial_numbers' => $request->serial_numbers]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'serial_numbers' => session('serial_numbers'),
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/part-validation-image/{filename}', function ($filename) {
|
||||
$path = storage_path("app/private/uploads/PartValidation/{$filename}");
|
||||
|
||||
if (! file_exists($path)) {
|
||||
abort(404, 'Image not found');
|
||||
}
|
||||
|
||||
return response()->file($path);
|
||||
})->name('part.validation.image');
|
||||
|
||||
// web.php
|
||||
Route::post('/temp-upload', function (Request $request) {
|
||||
if (! $request->hasFile('photo')) {
|
||||
return response()->json(['success' => false], 400);
|
||||
}
|
||||
|
||||
$file = $request->file('photo');
|
||||
$filename = 'capture_'.time().'.jpeg';
|
||||
$path = $file->storeAs('temp', $filename, 'local'); // storage/app/temp
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'path' => $path,
|
||||
]);
|
||||
});
|
||||
|
||||
Route::post('/verify-ocr', function (Request $request) {
|
||||
|
||||
if (! $request->has('path')) {
|
||||
return response()->json(['success' => false, 'error' => 'No file path provided']);
|
||||
}
|
||||
|
||||
$filePath = storage_path('app/private/temp/'.basename($request->path));
|
||||
|
||||
if (! file_exists($filePath)) {
|
||||
return response()->json(['success' => false, 'error' => 'File not found']);
|
||||
}
|
||||
|
||||
try {
|
||||
// $text = (new TesseractOCR($filePath))->lang('eng')->run();
|
||||
$text = (new TesseractOCR($filePath))
|
||||
->executable('/usr/bin/tesseract')
|
||||
->lang('eng')
|
||||
->psm(6) // treats the image as a block of text
|
||||
->config('tessedit_char_whitelist', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
|
||||
->run();
|
||||
->executable('/usr/bin/tesseract')
|
||||
->lang('eng')
|
||||
->psm(6) // treats the image as a block of text
|
||||
->config('tessedit_char_whitelist', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
|
||||
->run();
|
||||
|
||||
$text = trim($text); // remove whitespace
|
||||
|
||||
@@ -79,19 +119,19 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
return response()->json(['success' => true, 'text' => 'Text not found']);
|
||||
}
|
||||
|
||||
//return response()->json(['success' => true, 'text' => $text]);
|
||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
||||
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Za-z0-9]+$/', $line));
|
||||
// return response()->json(['success' => true, 'text' => $text]);
|
||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
||||
$serials = array_filter(array_map('trim', $lines), fn ($line) => preg_match('/^[A-Za-z0-9]+$/', $line));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'text' => array_values($serials) // reindex array
|
||||
]);
|
||||
}
|
||||
//catch (\Exception $e) {
|
||||
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||
// }
|
||||
catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'text' => array_values($serials), // reindex array
|
||||
]);
|
||||
}
|
||||
// catch (\Exception $e) {
|
||||
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||
// }
|
||||
catch (\Exception $e) {
|
||||
// Log the full exception class and message
|
||||
\Log::error('Tesseract OCR failed', [
|
||||
'exception_class' => get_class($e),
|
||||
@@ -111,62 +151,61 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('/download/{equipmentNumber}', function ($equipmentNumber) {
|
||||
Route::get('/download/{equipmentNumber}', function ($equipmentNumber) {
|
||||
$model = EquipmentMaster::where('equipment_number', $equipmentNumber)->firstOrFail();
|
||||
|
||||
if (! $model->attachment || ! Storage::disk('local')->exists($model->attachment)) {
|
||||
abort(404, 'File not found.');
|
||||
}
|
||||
return Storage::disk('local')->download($model->attachment);
|
||||
})->name('download.attachment');
|
||||
|
||||
// Route::get('/admin/forgot-password', function () {
|
||||
// return view('auth.forgot-password');
|
||||
// })->name('filament.admin.forgot-password');
|
||||
return Storage::disk('local')->download($model->attachment);
|
||||
})->name('download.attachment');
|
||||
|
||||
// Route::get('/admin/forgot-password', function () {
|
||||
// return view('auth.forgot-password');
|
||||
// })->name('filament.admin.forgot-password');
|
||||
|
||||
// Route::post('/admin/forgot-password', function(Request $request){
|
||||
// Route::post('/admin/forgot-password', function(Request $request){
|
||||
|
||||
// $validator = Validator::make($request->all(), [
|
||||
// 'email'=>'required|email',
|
||||
// 'old_password'=>'required',
|
||||
// 'password'=>'required',
|
||||
// 'password_confirmation'=>'required'
|
||||
// ]);
|
||||
// $validator = Validator::make($request->all(), [
|
||||
// 'email'=>'required|email',
|
||||
// 'old_password'=>'required',
|
||||
// 'password'=>'required',
|
||||
// 'password_confirmation'=>'required'
|
||||
// ]);
|
||||
|
||||
// if($validator->fails()){
|
||||
// return response()->json([
|
||||
// 'emailError' => $validator->errors()->first('email'),
|
||||
// 'oldPasswordError' => $validator->errors()->first('old_password'),
|
||||
// 'newPasswordError' => $validator->errors()->first('password'),
|
||||
// 'confirmPasswordError' => $validator->errors()->first('password_confirmation')
|
||||
// ]);
|
||||
// }
|
||||
// if($validator->fails()){
|
||||
// return response()->json([
|
||||
// 'emailError' => $validator->errors()->first('email'),
|
||||
// 'oldPasswordError' => $validator->errors()->first('old_password'),
|
||||
// 'newPasswordError' => $validator->errors()->first('password'),
|
||||
// 'confirmPasswordError' => $validator->errors()->first('password_confirmation')
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// $user = User::where('email',$request->email)->first();
|
||||
// if(!$user){
|
||||
// return response()->json(['passwordError'=>'No user found with this email.']);
|
||||
// }
|
||||
// $user = User::where('email',$request->email)->first();
|
||||
// if(!$user){
|
||||
// return response()->json(['passwordError'=>'No user found with this email.']);
|
||||
// }
|
||||
|
||||
// if(!Hash::check($request->old_password, $user->password)){
|
||||
// return response()->json(['oldPasswordError'=>'Old password does not match']);
|
||||
// }
|
||||
// if(!Hash::check($request->old_password, $user->password)){
|
||||
// return response()->json(['oldPasswordError'=>'Old password does not match']);
|
||||
// }
|
||||
|
||||
// if($request->password != $request->password_confirmation){
|
||||
// return response()->json(['newPasswordError'=>'New password and confirm password do not match']);
|
||||
// }
|
||||
// if($request->password != $request->password_confirmation){
|
||||
// return response()->json(['newPasswordError'=>'New password and confirm password do not match']);
|
||||
// }
|
||||
|
||||
// $user->password = Hash::make($request->password);
|
||||
// $user->save();
|
||||
// $user->password = Hash::make($request->password);
|
||||
// $user->save();
|
||||
|
||||
// return response()->json(['success'=>'Password changed successfully!']);
|
||||
// })->name('filament.admin.forgot-password.otp');
|
||||
// return response()->json(['success'=>'Password changed successfully!']);
|
||||
// })->name('filament.admin.forgot-password.otp');
|
||||
|
||||
|
||||
// Route::post('/admin/check-email', function(Request $request){
|
||||
// $request->validate(['email' => 'required|email']);
|
||||
// $exists = User::where('email', $request->email)->first();
|
||||
// return response()->json(['exists' => $exists]);
|
||||
// })->name('admin.check-email');
|
||||
// Route::post('/admin/check-email', function(Request $request){
|
||||
// $request->validate(['email' => 'required|email']);
|
||||
// $exists = User::where('email', $request->email)->first();
|
||||
// return response()->json(['exists' => $exists]);
|
||||
// })->name('admin.check-email');
|
||||
|
||||
Reference in New Issue
Block a user