Compare commits
223 Commits
9554e48459
...
ranjith-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8777db5c7 | ||
|
|
2ae495473a | ||
|
|
472d2e6943 | ||
|
|
095e010dea | ||
|
|
b83f005512 | ||
|
|
207d52a443 | ||
|
|
82e5c43a23 | ||
|
|
b323ad0e3d | ||
|
|
9799a391a4 | ||
|
|
02352aeb32 | ||
|
|
7d40f50821 | ||
|
|
5531160860 | ||
|
|
0a635f129d | ||
|
|
79e0c00e4b | ||
|
|
4ecef99002 | ||
|
|
d9f0201710 | ||
|
|
72b90abb66 | ||
|
|
d12faa7e4d | ||
|
|
66329fad13 | ||
|
|
f44ffecb62 | ||
|
|
c6c0fec823 | ||
|
|
184f458b75 | ||
|
|
234ad1431a | ||
|
|
8e6859fca2 | ||
|
|
95ff0fd1a2 | ||
|
|
ddad5de505 | ||
|
|
3b44cce762 | ||
|
|
693c203001 | ||
|
|
968a564109 | ||
|
|
028d985e9f | ||
|
|
531c627e72 | ||
|
|
17030f2c7f | ||
|
|
3f31425e4b | ||
|
|
65f8c8cfc9 | ||
|
|
5dde6f6d9a | ||
|
|
d128d48bde | ||
|
|
b520c02e12 | ||
|
|
9fc79624fb | ||
|
|
ba0c6b18d7 | ||
|
|
a4370aa492 | ||
|
|
fc77e63c70 | ||
|
|
07589520f1 | ||
|
|
b5a3fe123e | ||
|
|
4fbb9246e6 | ||
|
|
ca5c19d7f9 | ||
|
|
280b62d27d | ||
|
|
8c362bd83f | ||
|
|
e27326258e | ||
|
|
29b4775af2 | ||
|
|
58629f4cbb | ||
|
|
ef6443b68a | ||
|
|
c8b978984a | ||
|
|
773948ec75 | ||
|
|
a8ebb2086e | ||
|
|
5350be85bb | ||
|
|
6f9928a989 | ||
|
|
75ccd36acd | ||
|
|
48a7926448 | ||
|
|
6162b1026c | ||
|
|
e044e8f39d | ||
|
|
f14dfb137e | ||
|
|
70213143f8 | ||
|
|
e4a763db1c | ||
|
|
e0937b21dd | ||
|
|
3622bbde00 | ||
|
|
583c5ffe59 | ||
|
|
c9ac1b82fb | ||
|
|
6181b25065 | ||
|
|
bf2cbbe00a | ||
|
|
52af54dbd0 | ||
|
|
173a9e40a9 | ||
|
|
d556525e36 | ||
|
|
938514fe0d | ||
|
|
de3acf0f6c | ||
|
|
9b15dd6c11 | ||
|
|
b58e419e86 | ||
|
|
1c3dfef558 | ||
|
|
bf0c65c9c5 | ||
|
|
6aad1ab2f1 | ||
|
|
0fa1c5f34b | ||
|
|
b7ac7da6ec | ||
|
|
dca5d499be | ||
|
|
d2f4d417ba | ||
|
|
737f062cd4 | ||
|
|
ddc3e2a093 | ||
|
|
d4766a73e9 | ||
|
|
da526c7c0d | ||
|
|
1f3d697b57 | ||
|
|
4a4cf17732 | ||
|
|
fc85f64fbc | ||
|
|
3d0089c3b2 | ||
|
|
800cfbd960 | ||
|
|
4378f3adbd | ||
|
|
68ee079529 | ||
|
|
be85c85e06 | ||
|
|
5ebbf491f6 | ||
|
|
dee8246320 | ||
|
|
9d02be360e | ||
|
|
dd037e7f8a | ||
|
|
f599fdc05b | ||
|
|
0f6276fd76 | ||
|
|
ee898b935b | ||
|
|
6fd005acf9 | ||
|
|
6a1fb39068 | ||
|
|
33635fd9af | ||
|
|
10e493ca51 | ||
|
|
85f1a84321 | ||
|
|
994591da54 | ||
|
|
7aaca611dc | ||
|
|
251ef26c41 | ||
|
|
ebf5e60a00 | ||
|
|
37eed0640f | ||
|
|
143fe85b2e | ||
|
|
bb8000d177 | ||
|
|
2d4f6d8069 | ||
|
|
219279c641 | ||
|
|
2fb7ed7895 | ||
|
|
b4ef782067 | ||
|
|
dc028c91bb | ||
|
|
a42f7c1fae | ||
|
|
ec0fe66874 | ||
|
|
a6ec37fd3d | ||
|
|
f4bfc5c4dc | ||
|
|
2a83033541 | ||
|
|
f8dc95054b | ||
|
|
017f57878d | ||
|
|
561e0b448f | ||
|
|
8eb0985128 | ||
|
|
245c9e1782 | ||
|
|
b8fe29644e | ||
|
|
e09a362c96 | ||
|
|
7d84624843 | ||
|
|
b6519e3bbf | ||
|
|
bceba8db5f | ||
|
|
dd1a884b22 | ||
|
|
5b333621fe | ||
|
|
b52fd57c23 | ||
|
|
6bac832d1f | ||
|
|
8dbdcf4f35 | ||
|
|
115cc912c7 | ||
|
|
544e593d19 | ||
|
|
246b8715ca | ||
|
|
cd3598d67e | ||
|
|
3b9d94552b | ||
|
|
ba55567aed | ||
|
|
d32408bebd | ||
|
|
854330caf2 | ||
|
|
4309003fbd | ||
|
|
c500759f52 | ||
|
|
0a07e4b6e6 | ||
|
|
21b40b499a | ||
|
|
447c0a73a0 | ||
|
|
2431f73571 | ||
|
|
62259d4afe | ||
|
|
ec831f0fb9 | ||
|
|
e09f6582e9 | ||
|
|
7e543b30c3 | ||
|
|
8b9901c27d | ||
|
|
adfce88a3e | ||
|
|
fb12e2fb48 | ||
|
|
52cee81573 | ||
|
|
0bd910c6d0 | ||
|
|
a74aa3bde5 | ||
|
|
6f93f2bd92 | ||
|
|
d19b8120e2 | ||
|
|
8fb42203c3 | ||
|
|
bb2f5082b1 | ||
|
|
3215cd39ad | ||
|
|
7755d15741 | ||
|
|
4586fc0d60 | ||
|
|
65fc5202a4 | ||
|
|
770f0c9af3 | ||
|
|
47a0cf31d2 | ||
|
|
e5f23303d9 | ||
|
|
b9e164725e | ||
|
|
4699de9a77 | ||
|
|
196117f07f | ||
|
|
84b617f8fb | ||
|
|
9f6959784f | ||
|
|
bbdd9fb75c | ||
|
|
cc788ea6d4 | ||
|
|
8c0af96b94 | ||
|
|
b02954d0a2 | ||
|
|
9b098864bc | ||
|
|
50f542c3d1 | ||
|
|
dfb48055ea | ||
|
|
881e2fa6d9 | ||
|
|
3a7104513c | ||
|
|
25cfaa6479 | ||
|
|
b7e8182309 | ||
|
|
bce19056c7 | ||
|
|
8e2a0e79dc | ||
|
|
63c1cc14b2 | ||
|
|
1ddd27433c | ||
|
|
80d7258ae0 | ||
|
|
f10b4daddf | ||
|
|
b183a1d350 | ||
|
|
dd57d14f79 | ||
|
|
71e89c7927 | ||
|
|
a230208718 | ||
|
|
e27871d0c0 | ||
|
|
b188714b06 | ||
|
|
9bb6e05589 | ||
|
|
6cb33879f5 | ||
|
|
27164556ee | ||
|
|
b70d078ca9 | ||
|
|
2f36fe7270 | ||
|
|
bc874e23d2 | ||
|
|
fcd7d1ccc1 | ||
|
|
b409a021c4 | ||
|
|
48e6732257 | ||
|
|
653026a36d | ||
|
|
7a423d0f62 | ||
|
|
a6d3add1ac | ||
|
|
4d2a016777 | ||
|
|
8213748aa8 | ||
|
|
fb65fa99bc | ||
|
|
9bf1d6fc59 | ||
|
|
7e1fea11c6 | ||
|
|
fba8101da3 | ||
|
|
252dcc7afd | ||
|
|
fe404c050a | ||
|
|
4de8a306ea |
@@ -40,6 +40,7 @@ class Scheduler extends Command
|
||||
{
|
||||
|
||||
$this->call('approval:trigger-mails');
|
||||
// $this->call('sftp:process-files');
|
||||
|
||||
// --- Production Rules ---
|
||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
@@ -76,7 +77,7 @@ class Scheduler extends Command
|
||||
}
|
||||
}
|
||||
|
||||
// --- Invoice Validation Rules ---
|
||||
// --- Invoice Validation Rules --- (Invoice Mail)
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'InvoiceMail')
|
||||
->select('plant', 'schedule_type')
|
||||
@@ -113,6 +114,82 @@ class Scheduler extends Command
|
||||
}
|
||||
}
|
||||
|
||||
//..SerialInvoice
|
||||
|
||||
$invoiceSerialRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'SerialInvoiceMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($invoiceSerialRules as $rule) {
|
||||
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//..MaterialInvoice
|
||||
|
||||
$invoiceMaterialRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'MaterialInvoiceMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($invoiceMaterialRules as $rule) {
|
||||
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:invoice-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// foreach ($invoiceRules as $rule) {
|
||||
|
||||
// switch ($rule->schedule_type) {
|
||||
@@ -234,6 +311,89 @@ class Scheduler extends Command
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$ImportTransitRules = AlertMailRule::where('module', 'ImportTransit')
|
||||
->where('rule_name', 'ImportTransitMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($ImportTransitRules as $rule) {
|
||||
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send-import-transit', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send-import-transit', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '11:10') {
|
||||
try {
|
||||
\Artisan::call('send-import-transit', [
|
||||
'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;
|
||||
}
|
||||
}
|
||||
|
||||
$vehicleReports = AlertMailRule::where('module', 'VehicleReport')
|
||||
->where('rule_name', 'VehicleReportMail')
|
||||
->select('plant', 'schedule_type')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
foreach ($vehicleReports as $rule) {
|
||||
switch ($rule->schedule_type) {
|
||||
case 'Live':
|
||||
// Run every minute
|
||||
\Artisan::call('send:vehicle-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
break;
|
||||
case 'Hourly':
|
||||
if (now()->minute == 0) {
|
||||
\Artisan::call('send:vehicle-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case 'Daily':
|
||||
if (now()->format('H:i') == '07:59') {
|
||||
\Artisan::call('send:vehicle-report', [
|
||||
'schedule_type' => $rule->schedule_type,
|
||||
'plant' => $rule->plant,
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
140
app/Console/Commands/SendImportTransit.php
Normal file
140
app/Console/Commands/SendImportTransit.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\ImportTransitMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\ImportTransit;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendImportTransit extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send-import-transit {schedule_type} {plant}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant');
|
||||
|
||||
$mailRules = AlertMailRule::where('module', 'ImportTransit')
|
||||
->where('rule_name', 'ImportTransitMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->get();
|
||||
|
||||
$plants = ($plantId == 0)
|
||||
? Plant::all()
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
$plantCodes = $plants->pluck('name', 'id');
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// $todayRecordExists = ImportTransit::whereDate('created_at', now()->toDateString())->first();
|
||||
|
||||
// if (!$todayRecordExists) {
|
||||
// $this->info('No records created today. Mail not sent.');
|
||||
// return;
|
||||
// }
|
||||
|
||||
$tableData = ImportTransit::select([
|
||||
'cri_rfq_number',
|
||||
'mail_received_date',
|
||||
'pricol_ref_number',
|
||||
'requester',
|
||||
'shipper',
|
||||
'shipper_location',
|
||||
'shipper_invoice',
|
||||
'shipper_invoice_date',
|
||||
'customs_agent_name',
|
||||
'eta_date',
|
||||
'status',
|
||||
'delivery_location',
|
||||
'etd_date',
|
||||
'mode',
|
||||
'inco_terms',
|
||||
'port_of_loading',
|
||||
'port_of_discharge',
|
||||
'delivery_city',
|
||||
'packages',
|
||||
'type_of_package',
|
||||
'gross_weight',
|
||||
'volume',
|
||||
'bill_number',
|
||||
'bill_received_date',
|
||||
'vessel_number',
|
||||
'remark',
|
||||
'is_transit_identified',
|
||||
])
|
||||
->where('status', '!=', 'Delivered')
|
||||
->get();
|
||||
|
||||
if ($tableData->isEmpty()) {
|
||||
$this->info('No pending Import Transit records found. Mail skipped.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (strtolower($scheduleType) == 'daily')
|
||||
{
|
||||
foreach ($mailRules as $rule) {
|
||||
|
||||
$mailSubject = 'Daily Import Transit Report';
|
||||
|
||||
$mail = new ImportTransitMail(
|
||||
$scheduleType,
|
||||
$tableData,
|
||||
$mailSubject
|
||||
);
|
||||
|
||||
$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 {$rule->id} — no To emails.");
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)
|
||||
->cc($ccEmails)
|
||||
->send($mail);
|
||||
|
||||
$this->info(
|
||||
"Mail sent → Rule {$rule->id} | To: " . implode(', ', $toEmails)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\test;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -31,23 +32,37 @@ class SendInvoiceReport extends Command
|
||||
public function handle()
|
||||
{
|
||||
$schedule = $this->argument('schedule_type');
|
||||
// $scheduleType = $this->argument('scheduleType');
|
||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||
$plantIdArg = (int) $this->argument('plant');
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'InvoiceMail')
|
||||
->where('plant', $plantIdArg)
|
||||
->get();
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
$serialRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'SerialInvoiceMail')
|
||||
->where('plant', $plantIdArg)
|
||||
->get();
|
||||
|
||||
$materialRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
->where('rule_name', 'MaterialInvoiceMail')
|
||||
->where('plant', $plantIdArg)
|
||||
->get();
|
||||
|
||||
// $this->info('Invoice Rules: ' . $invoiceRules->toJson());
|
||||
// $this->info('Serial Rules: ' . $serialRules->toJson());
|
||||
// $this->info('Material Rules: ' . $materialRules->toJson());
|
||||
|
||||
$serialTableData = [];
|
||||
$materialTableData = [];
|
||||
$bundleTableData = [];
|
||||
|
||||
// Get plant IDs: either one plant or all
|
||||
$plantIds = $plantIdArg == 0
|
||||
? InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id')->toArray()
|
||||
: [$plantIdArg];
|
||||
|
||||
$isPlantRun = $plantIdArg != 0;
|
||||
|
||||
$no = 1;
|
||||
if (strtolower($schedule) == 'daily') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
@@ -91,6 +106,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$serialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalSerialCount,
|
||||
'scannedInvoice' => $scannedSerialCount,
|
||||
@@ -127,6 +143,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$materialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalMatCount,
|
||||
'scannedInvoice' => $scannedMatCount,
|
||||
@@ -163,6 +180,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$bundleTableData[] = [
|
||||
'no' => $no,
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalBundleCount,
|
||||
'scannedInvoice' => $scannedBundleCount,
|
||||
@@ -173,52 +191,119 @@ class SendInvoiceReport extends Command
|
||||
$no++;
|
||||
}
|
||||
|
||||
$mail = new test($serialTableData, $materialTableData, $bundleTableData, $schedule);
|
||||
$contentVars = $mail->content()->with;
|
||||
// $mail = new test($serialTableData, $materialTableData, $bundleTableData, $schedule);
|
||||
// $contentVars = $mail->content()->with;
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Invoice Report');
|
||||
|
||||
// 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));
|
||||
// }
|
||||
foreach ($mailRules->get('SerialInvoiceMail') as $rule) {
|
||||
// if ($mailRules->has('SerialInvoiceMail')) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
// foreach ($mailRules->get('SerialInvoiceMail') as $rule) {
|
||||
|
||||
$ccEmails = collect(explode(',', $rule->cc_emails ?? ''))
|
||||
->map(fn ($e) => trim($e))
|
||||
->filter()
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
// $filteredSerialData = [];
|
||||
|
||||
if (empty($toEmails)) {
|
||||
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
|
||||
// $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;
|
||||
// }
|
||||
|
||||
// if ($rule->plant == 0) {
|
||||
// $filteredSerialData = $serialTableData;
|
||||
|
||||
// } else {
|
||||
// $filteredSerialData = collect($serialTableData)
|
||||
// ->where('plant_id', $rule->plant)
|
||||
// ->values()
|
||||
// ->toArray();
|
||||
// }
|
||||
|
||||
// if (empty($filteredSerialData)) {
|
||||
// $this->warn("Skipping empty mail for rule {$rule->id}");
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// // \Mail::to($toEmails)
|
||||
// // ->cc($ccEmails)
|
||||
// // ->send(new test(
|
||||
// // $filteredSerialData,
|
||||
// // [],
|
||||
// // [],
|
||||
// // $schedule
|
||||
// // ));
|
||||
|
||||
// $mail = new test(
|
||||
// $filteredSerialData,
|
||||
// [],
|
||||
// [],
|
||||
// $schedule
|
||||
// );
|
||||
|
||||
// \Mail::to($toEmails)
|
||||
// ->cc($ccEmails)
|
||||
// ->send($mail);
|
||||
|
||||
// // \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) : ''));
|
||||
// }
|
||||
// }
|
||||
|
||||
if ($serialRules->isNotEmpty()) {
|
||||
|
||||
foreach ($serialRules as $rule) {
|
||||
|
||||
if (
|
||||
$isPlantRun &&
|
||||
$plantIdArg != 0 &&
|
||||
$rule->plant != 0 &&
|
||||
$rule->plant != $plantIdArg
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
|
||||
if (
|
||||
$plantIdArg == 0 &&
|
||||
$rule->plant != 0
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$data = collect($serialTableData)
|
||||
->when($rule->plant != 0, fn ($q) => $q->where('plant_id', $rule->plant))
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (empty($data)) continue;
|
||||
|
||||
\Mail::to($rule->email)
|
||||
->cc($rule->cc_emails ?? [])
|
||||
->send(new test($data, [], [], $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
if ($materialRules->isNotEmpty()) {
|
||||
// $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) {
|
||||
foreach ($materialRules as $rule) {
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
@@ -240,20 +325,61 @@ class SendInvoiceReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
// FILTER DATA
|
||||
if ($rule->plant == 0) {
|
||||
|
||||
$filteredMaterialData = $materialTableData;
|
||||
$filteredBundleData = $bundleTableData;
|
||||
|
||||
} else {
|
||||
|
||||
$filteredMaterialData = collect($materialTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$filteredBundleData = collect($bundleTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)
|
||||
->cc($ccEmails)
|
||||
->send(new test(
|
||||
[],
|
||||
$filteredMaterialData,
|
||||
$filteredBundleData,
|
||||
$schedule
|
||||
));
|
||||
|
||||
// \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));
|
||||
// $this->info("✅ Sent InvoiceMail to: {$email}");
|
||||
// }
|
||||
foreach ($mailRules->get('InvoiceMail') as $rule) {
|
||||
if ($invoiceRules->isNotEmpty()) {
|
||||
|
||||
foreach ($invoiceRules as $rule) {
|
||||
|
||||
// During global run, only execute plant=0 rule
|
||||
if ($plantIdArg == 0 && $rule->plant != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// During plant run, only execute matching rule
|
||||
if (
|
||||
$plantIdArg != 0 &&
|
||||
$rule->plant != 0 &&
|
||||
$rule->plant != $plantIdArg
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filteredSerialData = [];
|
||||
$filteredMaterialData = [];
|
||||
$filteredBundleData = [];
|
||||
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
->map(fn ($e) => trim($e))
|
||||
@@ -275,9 +401,69 @@ class SendInvoiceReport extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
if ($rule->plant == 0) {
|
||||
|
||||
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
|
||||
$filteredSerialData = $serialTableData;
|
||||
$filteredMaterialData = $materialTableData;
|
||||
$filteredBundleData = $bundleTableData;
|
||||
|
||||
} else {
|
||||
|
||||
$filteredSerialData = collect($serialTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$filteredMaterialData = collect($materialTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
$filteredBundleData = collect($bundleTableData)
|
||||
->where('plant_id', $rule->plant)
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
// Prevent empty mails
|
||||
if (
|
||||
empty($filteredSerialData) &&
|
||||
empty($filteredMaterialData) &&
|
||||
empty($filteredBundleData)
|
||||
) {
|
||||
$this->warn("Skipping empty mail for rule {$rule->id}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// \Mail::to($toEmails)
|
||||
// ->cc($ccEmails)
|
||||
// ->send(new test(
|
||||
// $filteredSerialData,
|
||||
// $filteredMaterialData,
|
||||
// $filteredBundleData,
|
||||
// $schedule
|
||||
// ));
|
||||
|
||||
$mail = new test(
|
||||
$filteredSerialData,
|
||||
$filteredMaterialData,
|
||||
$filteredBundleData,
|
||||
$schedule
|
||||
);
|
||||
|
||||
\Mail::to($toEmails)
|
||||
->cc($ccEmails)
|
||||
->send($mail);
|
||||
|
||||
// \Mail::raw('Test mail', function ($message) use ($toEmails, $ccEmails) {
|
||||
// $message->to($toEmails)
|
||||
// ->cc($ccEmails)
|
||||
// ->subject('Test');
|
||||
// });
|
||||
|
||||
// \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) : ''));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
134
app/Console/Commands/SendVehicleReport.php
Normal file
134
app/Console/Commands/SendVehicleReport.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\VehicleEntryMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Plant;
|
||||
use App\Models\VehicleEntry;
|
||||
use Illuminate\Console\Command;
|
||||
use Mail;
|
||||
|
||||
class SendVehicleReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:vehicle-report {schedule_type} {plant}';
|
||||
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant');
|
||||
|
||||
$mailRules = AlertMailRule::where('module', 'VehicleReport')
|
||||
->where('rule_name', 'VehicleReportMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->get();
|
||||
|
||||
$plants = ($plantId == 0)
|
||||
? Plant::all()
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error('No valid plant(s) found.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (strtolower($scheduleType) == 'daily') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
|
||||
foreach ($plants as $plant) {
|
||||
|
||||
$vehicleEntries = VehicleEntry::select([
|
||||
'vehicle_number',
|
||||
'boom_opened',
|
||||
'entry_time',
|
||||
'exit_time',
|
||||
'duration',
|
||||
'type',
|
||||
])
|
||||
->where('plant_id', $plant->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->get();
|
||||
|
||||
if ($vehicleEntries->isEmpty()) {
|
||||
$this->warn("No records for {$plant->name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
$tableData = [];
|
||||
$no = 1;
|
||||
|
||||
foreach ($vehicleEntries as $vehicleEntry) {
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
'vehicleNumber' => strtoupper($vehicleEntry->vehicle_number),
|
||||
'entryTime' => $vehicleEntry->entry_time,
|
||||
'exitTime' => $vehicleEntry->exit_time,
|
||||
'duration' => $vehicleEntry->duration,
|
||||
'type' => $vehicleEntry->type,
|
||||
'boom' => $vehicleEntry->boom_opened,
|
||||
];
|
||||
}
|
||||
|
||||
if ($plantId == 0) {
|
||||
$rule = $mailRules->first();
|
||||
} else {
|
||||
$rule = $mailRules->where('plant', $plant->id)->first();
|
||||
}
|
||||
|
||||
if (!$rule) {
|
||||
$this->warn("No mail rule for {$plant->name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
$mail = new VehicleEntryMail(
|
||||
$scheduleType,
|
||||
$tableData,
|
||||
'Daily Vehicle Transit Report'
|
||||
);
|
||||
|
||||
Mail::to($toEmails)->cc($ccEmails)->send($mail);
|
||||
|
||||
$this->info("Mail sent for {$plant->name}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -5,9 +5,12 @@ namespace App\Console\Commands;
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use App\Models\TempClassCharacteristic;
|
||||
// use App\Models\TempClassCharacteristic;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class TriggerPendingApprovalMails extends Command
|
||||
{
|
||||
@@ -40,6 +43,8 @@ class TriggerPendingApprovalMails extends Command
|
||||
|
||||
public $subjectLine;
|
||||
|
||||
// public $tempCharacteristics = [];
|
||||
|
||||
public $wfId;
|
||||
|
||||
public function handle()
|
||||
@@ -195,6 +200,38 @@ class TriggerPendingApprovalMails extends Command
|
||||
$updateData['mail_status'] = 'Sent-Mail3';
|
||||
}
|
||||
|
||||
$totalMinutes =
|
||||
$this->convertToMinutes($approver->duration1 ?? 0) +
|
||||
$this->convertToMinutes($approver->duration2 ?? 0) +
|
||||
$this->convertToMinutes($approver->duration3 ?? 0);
|
||||
|
||||
$expiryTime = Carbon::parse($first->created_at)
|
||||
->copy()
|
||||
->addMinutes($totalMinutes);
|
||||
|
||||
$ids = $groupRecords->pluck('id');
|
||||
|
||||
$this->info("Expiry Time for ID {$first->id}: {$expiryTime}, Now: {$now}");
|
||||
|
||||
// --- AUTO REJECT ---
|
||||
if (
|
||||
$first->mail_status == 'Sent-Mail3' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||
(is_null($first->approver_status3) || $first->approver_status3 == 'Hold') &&
|
||||
$now->gte($expiryTime)
|
||||
) {
|
||||
RequestCharacteristic::whereIn('id', $ids)
|
||||
->update([
|
||||
'approver_status3' => 'Rejected',
|
||||
'approver_remark3' => 'Time Limit Reached',
|
||||
'approved3_at' => now(),
|
||||
]);
|
||||
|
||||
$this->info("Auto Rejected ID: {$first->id}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
@@ -203,6 +240,8 @@ class TriggerPendingApprovalMails extends Command
|
||||
|
||||
$subjectLine = 'Characteristic Approval Mail';
|
||||
|
||||
// $emails = array_map('trim', explode(',', $mail));
|
||||
|
||||
Mail::to($mail)->send(
|
||||
new CharacteristicApprovalMail(
|
||||
$first,
|
||||
@@ -251,6 +290,23 @@ class TriggerPendingApprovalMails extends Command
|
||||
return $approver && $approver->approver_type == 'Quality';
|
||||
});
|
||||
|
||||
// $approvers = CharacteristicApproverMaster::where('approver_type', 'Quality')
|
||||
// ->get()
|
||||
// ->keyBy('id');
|
||||
|
||||
// $qualityRecords = RequestCharacteristic::where(function ($q) {
|
||||
// $q->whereNull('approver_status1')->orWhere('approver_status1', 'Hold');
|
||||
// })
|
||||
// ->where(function ($q) {
|
||||
// $q->whereNull('approver_status2')->orWhere('approver_status2', 'Hold');
|
||||
// })
|
||||
// ->where(function ($q) {
|
||||
// $q->whereNull('approver_status3')->orWhere('approver_status3', 'Hold');
|
||||
// })
|
||||
// ->whereIn('characteristic_approver_master_id', $approvers->keys())
|
||||
// ->get();
|
||||
|
||||
|
||||
if ($qualityRecords->isEmpty()) {
|
||||
$this->info('No quality pending approvals');
|
||||
return;
|
||||
@@ -283,6 +339,43 @@ class TriggerPendingApprovalMails extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
$columns = Schema::getColumnListing('temp_class_characteristics');
|
||||
|
||||
$exclude = ['id', 'plant_id', 'machine_id', 'item_id', 'aufnr', 'class', 'arbid', 'gamng', 'lmnga', 'zz1_cn_bill_ord', 'zmm_heading', 'created_at', 'updated_at', 'deleted_at', 'has_work_flow_id', 'model_type', 'created_by', 'updated_by' ];
|
||||
|
||||
$filteredColumns = array_diff($columns, $exclude);
|
||||
|
||||
$row1 = TempClassCharacteristic::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('aufnr', $first->aufnr)
|
||||
->where('model_type', $first->model_type)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
$this->info(json_encode([
|
||||
'id' => $row1->id,
|
||||
'plant_id' => $row1->plant_id,
|
||||
'machine_id' => $row1->machine_id,
|
||||
'aufnr' => $row1->aufnr,
|
||||
'motor_speed' => $row1->zmm_motor_speed,
|
||||
'all_data' => $row1->toArray(),
|
||||
]));
|
||||
|
||||
$data = [];
|
||||
|
||||
if ($row1) {
|
||||
foreach ($filteredColumns as $column) {
|
||||
|
||||
$value = $row1->getAttribute($column);
|
||||
|
||||
if ($value != null && $value != '') {
|
||||
$data[$column] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$characteristics = $data;
|
||||
|
||||
$level = null;
|
||||
$mail = null;
|
||||
$name = null;
|
||||
@@ -359,6 +452,38 @@ class TriggerPendingApprovalMails extends Command
|
||||
$updateData['mail_status'] = 'Sent-Mail3';
|
||||
}
|
||||
|
||||
$totalMinutes =
|
||||
$this->convertToMinutes($approver->duration1 ?? 0) +
|
||||
$this->convertToMinutes($approver->duration2 ?? 0) +
|
||||
$this->convertToMinutes($approver->duration3 ?? 0);
|
||||
|
||||
$expiryTime = Carbon::parse($first->created_at)
|
||||
->copy()
|
||||
->addMinutes($totalMinutes);
|
||||
|
||||
$ids = $groupRecords->pluck('id');
|
||||
|
||||
$this->info("Expiry Time for ID {$first->id}: {$expiryTime}, Now: {$now}");
|
||||
|
||||
// --- AUTO REJECT ---
|
||||
if (
|
||||
$first->mail_status == 'Sent-Mail3' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||
(is_null($first->approver_status3) || $first->approver_status3 == 'Hold') &&
|
||||
$now->gte($expiryTime)
|
||||
) {
|
||||
RequestCharacteristic::whereIn('id', $ids)
|
||||
->update([
|
||||
'approver_status3' => 'Rejected',
|
||||
'approver_remark3' => 'Time Limit Reached',
|
||||
'approved3_at' => now(),
|
||||
]);
|
||||
|
||||
$this->info("Auto Rejected ID: {$first->id}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
@@ -381,8 +506,8 @@ class TriggerPendingApprovalMails extends Command
|
||||
$pdfPath,
|
||||
$pendingApprovers,
|
||||
$approverNameFromMaster,
|
||||
$subjectLine
|
||||
// $characteristics
|
||||
$subjectLine,
|
||||
$characteristics
|
||||
)
|
||||
);
|
||||
|
||||
@@ -406,4 +531,16 @@ class TriggerPendingApprovalMails extends Command
|
||||
|
||||
$this->info('Approval mail job completed');
|
||||
}
|
||||
|
||||
public function convertToMinutes($duration)
|
||||
{
|
||||
if (!$duration) return 0;
|
||||
|
||||
$parts = explode('.', (string)$duration);
|
||||
|
||||
$hours = (int)($parts[0] ?? 0);
|
||||
$minutes = (int)($parts[1] ?? 0);
|
||||
|
||||
return ($hours * 60) + $minutes;
|
||||
}
|
||||
}
|
||||
|
||||
70
app/Filament/Exports/AsrsItemValidationExporter.php
Normal file
70
app/Filament/Exports/AsrsItemValidationExporter.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\AsrsItemValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class AsrsItemValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = AsrsItemValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item_code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item_description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('uom')
|
||||
->label('UOM'),
|
||||
ExportColumn::make('material_type')
|
||||
->label('MATERIAL TYPE'),
|
||||
ExportColumn::make('material_group')
|
||||
->label('MATERIAL GROUP'),
|
||||
ExportColumn::make('mhe')
|
||||
->label('MHE'),
|
||||
ExportColumn::make('bin_quantity')
|
||||
->label('BIN QUANTITY'),
|
||||
ExportColumn::make('asrs')
|
||||
->label('ASRS'),
|
||||
ExportColumn::make('asrs_category')
|
||||
->label('ASRS CATEGORY'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your asrs item validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -298,6 +298,8 @@ class ClassCharacteristicExporter extends Exporter
|
||||
->label('ZMM MOTOR SPEED'),
|
||||
ExportColumn::make('zqmm_qty')
|
||||
->label('ZQMM QTY'),
|
||||
ExportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('mark_status')
|
||||
->label('MARKED STATUS'),
|
||||
ExportColumn::make('marked_datetime')
|
||||
|
||||
63
app/Filament/Exports/EmployeeMasterExporter.php
Normal file
63
app/Filament/Exports/EmployeeMasterExporter.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\EmployeeMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class EmployeeMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = EmployeeMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('code')
|
||||
->label('CODE'),
|
||||
ExportColumn::make('department')
|
||||
->label('DEPARTMENT'),
|
||||
// ExportColumn::make('designation')
|
||||
// ->label('DESIGNATION'),
|
||||
ExportColumn::make('email')
|
||||
->label('EMAIL'),
|
||||
ExportColumn::make('mobile_number')
|
||||
->label('MOBILE NUMBER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your employee master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
97
app/Filament/Exports/ImportTransitExporter.php
Normal file
97
app/Filament/Exports/ImportTransitExporter.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ImportTransit;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ImportTransitExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ImportTransit::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('cri_rfq_number')
|
||||
->label('CRI RFQ NUMBER'),
|
||||
ExportColumn::make('mail_received_date')
|
||||
->label('MAIL RECEIVED DATE'),
|
||||
ExportColumn::make('pricol_ref_number')
|
||||
->label('PRICOL REF NUMBER'),
|
||||
ExportColumn::make('requester')
|
||||
->label('REQUESTER'),
|
||||
ExportColumn::make('shipper')
|
||||
->label('SHIPPER'),
|
||||
ExportColumn::make('shipper_location')
|
||||
->label('SHIPPER LOCATION'),
|
||||
ExportColumn::make('shipper_invoice')
|
||||
->label('SHIPPER INVOICE'),
|
||||
ExportColumn::make('shipper_invoice_date')
|
||||
->label('SHIPPER INVOICE DATE'),
|
||||
ExportColumn::make('customs_agent_name')
|
||||
->label('CUSTOMS AGENT NAME'),
|
||||
ExportColumn::make('eta_date')
|
||||
->label('ETA DATE'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('delivery_location')
|
||||
->label('DELIVERY LOCATION'),
|
||||
ExportColumn::make('etd_date')
|
||||
->label('ETD DATE'),
|
||||
ExportColumn::make('mode')
|
||||
->label('MODE'),
|
||||
ExportColumn::make('inco_terms')
|
||||
->label('INCO TERMS'),
|
||||
ExportColumn::make('port_of_loading')
|
||||
->label('PORT OF LOADING'),
|
||||
ExportColumn::make('port_of_discharge')
|
||||
->label('PORT OF DISCHARGE'),
|
||||
ExportColumn::make('delivery_city')
|
||||
->label('DELIVERY CITY'),
|
||||
ExportColumn::make('packages')
|
||||
->label('PACKAGES'),
|
||||
ExportColumn::make('type_of_package')
|
||||
->label('TYPE OF PACKAGE'),
|
||||
ExportColumn::make('gross_weight')
|
||||
->label('GROSS WEIGHT'),
|
||||
ExportColumn::make('volume')
|
||||
->label('VOLUME'),
|
||||
ExportColumn::make('bill_number')
|
||||
->label('BILL NUMBER'),
|
||||
ExportColumn::make('bill_received_date')
|
||||
->label('BILL RECEIVED DATE'),
|
||||
ExportColumn::make('vessel_number')
|
||||
->label('VESSEL NUMBER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your import transit export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,17 @@ class InvoiceValidationExporter extends Exporter
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('stickerMaster.item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('stickerMaster.item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('stickerMaster.material_type')
|
||||
->label('MATERIAL TYPE')
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
4 => 'Bundle Individual',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('motor_scanned_status')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ExportColumn::make('pump_scanned_status')
|
||||
|
||||
64
app/Filament/Exports/LeakTestReadingExporter.php
Normal file
64
app/Filament/Exports/LeakTestReadingExporter.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\LeakTestReading;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class LeakTestReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = LeakTestReading::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item_code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('test_status')
|
||||
->label('TEST STATUS')
|
||||
->formatStateUsing(function ($state) {
|
||||
if (! $state || $state == '' || $state == null) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return match ($state) {
|
||||
'P' => 'PASS',
|
||||
'F' => 'FAIL',
|
||||
default => '-',
|
||||
};
|
||||
}),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your leak test reading export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ class PlantExporter extends Exporter
|
||||
->label('CODE'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('warehouse_number')
|
||||
->label('WAREHOUSE_NUMBER'),
|
||||
ExportColumn::make('address')
|
||||
->label('ADDRESS'),
|
||||
ExportColumn::make('created_at')
|
||||
@@ -44,10 +46,10 @@ class PlantExporter extends Exporter
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your plant export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
$body = 'Your plant export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -59,7 +59,6 @@ class ProcessOrderExporter extends Exporter
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ class ProductCharacteristicsMasterExporter extends Exporter
|
||||
->label('CHARACTERISTICS TYPE'),
|
||||
ExportColumn::make('name')
|
||||
->label('CHARACTERISTICS NAME'),
|
||||
ExportColumn::make('category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('inspection_type')
|
||||
->label('INSPECTION TYPE'),
|
||||
ExportColumn::make('lower')
|
||||
|
||||
@@ -29,9 +29,9 @@ class ProductionOrderExporter extends Exporter
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('start_date')
|
||||
->label('START DATETIME'),
|
||||
->label('START DATE'),
|
||||
ExportColumn::make('end_date')
|
||||
->label('END DATETIME'),
|
||||
->label('END DATE'),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('from_serial_number')
|
||||
@@ -43,9 +43,11 @@ class ProductionOrderExporter extends Exporter
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
->label('UPDATED AT')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
->label('UPDATED BY')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
|
||||
@@ -297,6 +297,8 @@ class TempClassCharacteristicExporter extends Exporter
|
||||
->label('ZMM MOTOR SPEED'),
|
||||
ExportColumn::make('zqmm_qty')
|
||||
->label('ZQMM QTY'),
|
||||
ExportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE'),
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('model_type')
|
||||
|
||||
63
app/Filament/Exports/VehicleEntryExporter.php
Normal file
63
app/Filament/Exports/VehicleEntryExporter.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\VehicleEntry;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class VehicleEntryExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = VehicleEntry::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('boom_opened')
|
||||
->label('BOOM OPENED'),
|
||||
ExportColumn::make('vehicle_number')
|
||||
->label('VEHICLE NUMBER'),
|
||||
ExportColumn::make('entry_time')
|
||||
->label('ENTRY TIME'),
|
||||
ExportColumn::make('exit_time')
|
||||
->label('EXIT TIME'),
|
||||
ExportColumn::make('duration')
|
||||
->label('DURATION'),
|
||||
ExportColumn::make('type')
|
||||
->label('TYPE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your vehicle entry export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
72
app/Filament/Exports/VisitorEntryExporter.php
Normal file
72
app/Filament/Exports/VisitorEntryExporter.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\VisitorEntry;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class VisitorEntryExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = VisitorEntry::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('register_id')
|
||||
->label('REGISTER ID'),
|
||||
ExportColumn::make('employeeMaster.name')
|
||||
->label('EMPLOYEE NAME'),
|
||||
ExportColumn::make('mobile_number')
|
||||
->label('MOBILE NUMBER'),
|
||||
ExportColumn::make('name')
|
||||
->label('VISITOR NAME'),
|
||||
ExportColumn::make('company')
|
||||
->label('COMPANY'),
|
||||
ExportColumn::make('purpose_of_visit')
|
||||
->label('PURPOSE OF VISIT'),
|
||||
ExportColumn::make('type')
|
||||
->label('TYPE'),
|
||||
ExportColumn::make('photo')
|
||||
->label('PHOTO')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('number_of_person')
|
||||
->label('NUMBER OF PERSON'),
|
||||
ExportColumn::make('in_time')
|
||||
->label('IN TIME'),
|
||||
ExportColumn::make('out_time')
|
||||
->label('OUT TIME'),
|
||||
ExportColumn::make('valid_upto')
|
||||
->label('VALID UPTO'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your visitor entry export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
118
app/Filament/Imports/AsrsItemValidationImporter.php
Normal file
118
app/Filament/Imports/AsrsItemValidationImporter.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\AsrsItemValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
|
||||
class AsrsItemValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = AsrsItemValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_code')
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('ITEM001')
|
||||
->label('ITEM CODE')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item_description')
|
||||
->exampleHeader('ITEM DESCRIPTION')
|
||||
->example('Item Description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ImportColumn::make('uom')
|
||||
->exampleHeader('UOM')
|
||||
->example('EA')
|
||||
->label('UOM'),
|
||||
ImportColumn::make('material_type')
|
||||
->exampleHeader('MATERIAL TYPE')
|
||||
->example('Material Type')
|
||||
->label('MATERIAL TYPE'),
|
||||
ImportColumn::make('material_group')
|
||||
->exampleHeader('MATERIAL GROUP')
|
||||
->example('Material Group')
|
||||
->label('MATERIAL GROUP'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?AsrsItemValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$iCode = trim($this->data['item_code']) ?? '';
|
||||
$itemDes = trim($this->data['item_description']) ?? '';
|
||||
$uom = trim($this->data['uom']) ?? '';
|
||||
$materialType = trim($this->data['material_type']) ?? '';
|
||||
$materialGroup = trim($this->data['material_group']) ?? '';
|
||||
$createdBy = Filament::auth()->user()?->name ?? '';
|
||||
$updatedBy = $createdBy;
|
||||
|
||||
$plantId = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '' || ! $plantCod) {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (! is_numeric($plantCod)) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' should contain only numeric values!";
|
||||
} elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' must be between 4 and 7 digits only!";
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code '{$plantCod}' found!";
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
}
|
||||
if (Str::length($itemDes) < 5) {
|
||||
$warnMsg[] = 'Invalid description found';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return AsrsItemValidation::updateOrCreate([
|
||||
'item_code' => $iCode,
|
||||
'plant_id' => $plant->id,
|
||||
],
|
||||
[
|
||||
'item_description' => $itemDes,
|
||||
'uom' => trim($this->data['uom']),
|
||||
'material_type' => $materialType,
|
||||
'material_group' => $materialGroup,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your asrs item validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -575,6 +575,10 @@ class ClassCharacteristicImporter extends Importer
|
||||
->label('ZQMM QTY')
|
||||
->exampleHeader('ZQMM QTY')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->exampleHeader('ZMM OPERATING TEMPERATURE')
|
||||
->example(''),
|
||||
ImportColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->exampleHeader('MARKED STATUS')
|
||||
|
||||
@@ -17,6 +17,8 @@ class CustomerPoMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CustomerPoMaster::class;
|
||||
|
||||
protected array $importedPos = [];
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
@@ -67,6 +69,8 @@ class CustomerPoMasterImporter extends Importer
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$item = null;
|
||||
$customerPo = trim($this->data['customer_po']);
|
||||
$customerName = trim($this->data['customer_name']);
|
||||
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
@@ -90,6 +94,23 @@ class CustomerPoMasterImporter extends Importer
|
||||
$warnMsg[] = 'Customer PO cannot be empty.';
|
||||
}
|
||||
|
||||
if (isset($this->importedPos[$customerPo])) {
|
||||
|
||||
if (strtolower(trim($this->importedPos[$customerPo])) != strtolower($customerName)){
|
||||
$warnMsg[] = "Customer PO '{$customerPo}' has multiple customer names in the import file.";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->importedPos[$customerPo] = $customerName;
|
||||
}
|
||||
|
||||
$existingPo = CustomerPoMaster::where('plant_id', $plant->id)->where('customer_po', $this->data['customer_po'])->first();
|
||||
|
||||
if ($existingPo && trim(strtolower($existingPo->customer_name)) != trim(strtolower($this->data['customer_name'])))
|
||||
{
|
||||
$warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already mapped to customer '{$existingPo->customer_name}'.";
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
// if (! $user) {
|
||||
// $warnMsg[] = 'User not found';
|
||||
|
||||
147
app/Filament/Imports/EmployeeMasterImporter.php
Normal file
147
app/Filament/Imports/EmployeeMasterImporter.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\EmployeeMaster;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class EmployeeMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = EmployeeMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->exampleHeader('EMPLOYEE NAME')
|
||||
->example('John Doe')
|
||||
->label('EMPLOYEE NAME'),
|
||||
ImportColumn::make('code')
|
||||
->exampleHeader('EMPLOYEE ID')
|
||||
->example('EMP001')
|
||||
->label('EMPLOYEE ID'),
|
||||
ImportColumn::make('department')
|
||||
->exampleHeader('DEPARTMENT')
|
||||
->example('HR')
|
||||
->label('DEPARTMENT'),
|
||||
// ImportColumn::make('designation')
|
||||
// ->exampleHeader('DESIGNATION')
|
||||
// ->example('Manager')
|
||||
// ->label('DESIGNATION'),
|
||||
ImportColumn::make('email')
|
||||
->exampleHeader('EMAIL')
|
||||
->example('john.doe@example.com')
|
||||
->label('EMAIL'),
|
||||
ImportColumn::make('mobile_number')
|
||||
->exampleHeader('MOBILE NUMBER')
|
||||
->example('1234567890')
|
||||
->label('MOBILE NUMBER'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?EmployeeMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$employeeName = trim($this->data['name']) ?? '';
|
||||
$employeeCode = trim($this->data['code']) ?? '';
|
||||
$employeeDepartment = trim($this->data['department']) ?? '';
|
||||
// $employeeDesignation = trim($this->data['designation']) ?? '';
|
||||
$employeeEmail = trim($this->data['email']) ?? '';
|
||||
$employeeMobile = trim($this->data['mobile_number']) ?? '';
|
||||
$createdBy = Filament::auth()->user()?->name ?? '';
|
||||
$updatedBy = $createdBy;
|
||||
|
||||
$plantId = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '' || ! $plantCod) {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (! is_numeric($plantCod)) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' should contain only numeric values!";
|
||||
} elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' must be between 4 and 7 digits only!";
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code '{$plantCod}' found!";
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($employeeCode == null || $employeeCode == '' || ! $employeeCode) {
|
||||
$warnMsg[] = "Employee ID can't be empty!";
|
||||
} elseif (Str::length($employeeCode) < 3 || Str::length($employeeCode) > 20) {
|
||||
$warnMsg[] = "Employee ID '{$employeeCode}' must be between 3 and 20 characters only!";
|
||||
}
|
||||
if ($employeeEmail != null && $employeeEmail != '' && ! filter_var($employeeEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
$warnMsg[] = "Invalid email address '{$employeeEmail}' found!";
|
||||
}
|
||||
if ($employeeMobile != null && $employeeMobile != '' && ! is_numeric($employeeMobile)) {
|
||||
$warnMsg[] = "Mobile number '{$employeeMobile}' should contain only numeric values!";
|
||||
} elseif (Str::length($employeeMobile) < 10 || Str::length($employeeMobile) > 10) {
|
||||
$warnMsg[] = "Mobile number '{$employeeMobile}' must be exactly 10 digits!";
|
||||
}
|
||||
else
|
||||
{
|
||||
$existingMobile = EmployeeMaster::where('mobile_number', $employeeMobile)
|
||||
->where('code', '!=', $employeeCode)
|
||||
->first();
|
||||
|
||||
if ($existingMobile) {
|
||||
$warnMsg[] = "Mobile number '{$employeeMobile}' is already assigned to another employee!";
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
else
|
||||
{
|
||||
EmployeeMaster::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plantId ?? null,
|
||||
'code' => $employeeCode ?? null,
|
||||
],
|
||||
[
|
||||
'name' => $employeeName ?? null,
|
||||
'email' => $employeeEmail ?? null,
|
||||
'mobile_number' => $employeeMobile ?? null,
|
||||
'department' => $employeeDepartment ?? null,
|
||||
// 'designation' => $employeeDesignation ?? null,
|
||||
'created_by' => $createdBy ?? null,
|
||||
'updated_by' => $updatedBy ?? null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your employee master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class InvoiceValidationImporter extends Importer
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('OPERATOR ID')
|
||||
->example('USER1')
|
||||
->example('USER00001')
|
||||
->label('OPERATOR ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
@@ -122,19 +122,19 @@ class InvoiceValidationImporter extends Importer
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('USER1')
|
||||
->example('USER00001')
|
||||
->label('CREATED BY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example('USER1')
|
||||
->example('')
|
||||
->label('UPDATED AT')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('')
|
||||
->example('USER00001')
|
||||
->label('UPDATED BY')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
@@ -37,6 +37,12 @@ class PlantImporter extends Importer
|
||||
->example('Ransar Industries-I')
|
||||
->label('NAME')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('warehouse_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('WAREHOUSE_NUMBER')
|
||||
->example('001')
|
||||
->label('WAREHOUSE_NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ADDRESS')
|
||||
@@ -53,6 +59,7 @@ class PlantImporter extends Importer
|
||||
$comp = trim($this->data['company']) ?? null;
|
||||
$code = trim($this->data['code']) ?? null;
|
||||
$name = trim($this->data['name']) ?? null;
|
||||
$wareHouseNo = trim($this->data['warehouse_number']) ?? null;
|
||||
$addr = trim($this->data['address']) ?? null;
|
||||
|
||||
if ($comp == null || $comp == '' || ! $comp) {
|
||||
@@ -66,7 +73,7 @@ class PlantImporter extends Importer
|
||||
$warnMsg[] = 'Code should contain only numeric values!';
|
||||
} elseif (Str::length($code) < 4 || Str::length($code) > 7) {
|
||||
$warnMsg[] = 'Code must be between 4 and 7 digits only!';
|
||||
} elseif (! preg_match('/^[1-9]\d{6,}$/', $code)) {
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $code)) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
}
|
||||
if ($name == null || $name == '' || ! $name) {
|
||||
@@ -74,6 +81,13 @@ class PlantImporter extends Importer
|
||||
} elseif (Str::length($name) < 5) {
|
||||
$warnMsg[] = 'Name should contain at least 5 characters!';
|
||||
}
|
||||
if ($wareHouseNo == null || $wareHouseNo == '' || ! $wareHouseNo) {
|
||||
// $warnMsg[] = "Warehouse number can't be empty!";
|
||||
} elseif (! is_numeric($wareHouseNo)) {
|
||||
$warnMsg[] = 'Warehouse number should contain only numeric values!';
|
||||
} elseif (Str::length($wareHouseNo) == 3) {
|
||||
$warnMsg[] = 'Warehouse number must contain 3 digits only!';
|
||||
}
|
||||
if ($addr == null || $addr == '' || ! $addr) {
|
||||
$warnMsg[] = "Address can't be empty!";
|
||||
} elseif (Str::length($addr) < 5) {
|
||||
@@ -92,6 +106,7 @@ class PlantImporter extends Importer
|
||||
}
|
||||
|
||||
$plantCN = Plant::where('code', $code)->where('name', $name)->first();
|
||||
$plantCW = Plant::where('code', $code)->where('warehouse_number', $wareHouseNo)->first();
|
||||
if (! $plantCN) {
|
||||
$plantCode = Plant::where('code', $code)->first();
|
||||
$plantName = Plant::where('name', $name)->first();
|
||||
@@ -99,6 +114,16 @@ class PlantImporter extends Importer
|
||||
throw new RowImportFailedException('Duplicate plant name found!');
|
||||
} elseif ($plantCode) {
|
||||
throw new RowImportFailedException('Duplicate plant code found!');
|
||||
} elseif (! $plantCW) {
|
||||
$wareHouse = Plant::where('warehouse_number', $wareHouseNo)->first();
|
||||
if ($wareHouse) {
|
||||
throw new RowImportFailedException('Duplicate warehouse number found!');
|
||||
}
|
||||
}
|
||||
} elseif (! $plantCW) {
|
||||
$wareHouse = Plant::where('warehouse_number', $wareHouseNo)->first();
|
||||
if ($wareHouse) {
|
||||
throw new RowImportFailedException('Duplicate warehouse number found!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +132,7 @@ class PlantImporter extends Importer
|
||||
'name' => $name,
|
||||
],
|
||||
[
|
||||
'warehouse_number' => $wareHouseNo,
|
||||
'address' => $addr,
|
||||
'company_id' => $compId,
|
||||
]
|
||||
|
||||
@@ -127,7 +127,7 @@ class ProcessOrderImporter extends Importer
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
}
|
||||
if ($iCode == null || $iCode == '') {
|
||||
|
||||
@@ -70,6 +70,11 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
->exampleHeader('CHARACTERISTICS NAME')
|
||||
->example(['TEST01', 'TEST02'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('category')
|
||||
->label('CATEGORY')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CATEGORY')
|
||||
->example(['Open Pump', 'Submersible Pump']),
|
||||
ImportColumn::make('inspection_type')
|
||||
->label('INSPECTION TYPE')
|
||||
->requiredMapping()
|
||||
@@ -102,7 +107,6 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?ProductCharacteristicsMaster
|
||||
{
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? null;
|
||||
$itemCod = trim($this->data['item']) ?? null;
|
||||
@@ -111,6 +115,7 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
$workCenter = trim($this->data['machine']) ?? null;
|
||||
$charTyp = trim($this->data['characteristics_type']) ?? null;
|
||||
$charNam = trim($this->data['name']) ?? null;
|
||||
$category = trim($this->data['category']) ?? null;
|
||||
$inspectTyp = trim($this->data['inspection_type']) ?? null;
|
||||
$lower = trim($this->data['lower']) ?? null;
|
||||
$middle = trim($this->data['middle']) ?? null;
|
||||
@@ -296,6 +301,7 @@ class ProductCharacteristicsMasterImporter extends Importer
|
||||
'name' => $charNam,
|
||||
],
|
||||
[
|
||||
'category' => $category,
|
||||
'inspection_type' => $inspectTyp,
|
||||
'lower' => $lower,
|
||||
'middle' => $middle,
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class ProductionCharacteristicImporter extends Importer
|
||||
{
|
||||
@@ -16,40 +23,170 @@ class ProductionCharacteristicImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1200')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
->exampleHeader('LINE NAME')
|
||||
->example('Poly Wrapped Wire SFG')
|
||||
->label('LINE NAME')
|
||||
->relationship(resolveUsing: 'name'),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
ImportColumn::make('machine_name')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->exampleHeader('MACHINE NAME')
|
||||
->example('RMI001234')
|
||||
->label('MACHINE NAME')
|
||||
// ->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('production_order'),
|
||||
ImportColumn::make('serial_number'),
|
||||
ImportColumn::make('characteristic_name'),
|
||||
ImportColumn::make('observed_value'),
|
||||
ImportColumn::make('status'),
|
||||
ImportColumn::make('inspection_status'),
|
||||
ImportColumn::make('remark'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('production_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PRODUCTION ORDER')
|
||||
->example('1880231')
|
||||
->label('PRODUCTION ORDER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SERIAL NUMBER')
|
||||
->example('20001202121')
|
||||
->label('SERIAL NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('characteristic_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('CHARACTERISTIC NAME')
|
||||
->example('Voltage')
|
||||
->label('CHARACTERISTIC NAME'),
|
||||
ImportColumn::make('observed_value')
|
||||
->exampleHeader('OBSERVED VALUE')
|
||||
->example('0')
|
||||
->label('OBSERVED VALUE'),
|
||||
ImportColumn::make('status')
|
||||
->exampleHeader('STATUS')
|
||||
->example('Ok')
|
||||
->label('STATUS'),
|
||||
ImportColumn::make('remark')
|
||||
->exampleHeader('REMARK')
|
||||
->example('Issue')
|
||||
->label('REMARK'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionCharacteristic
|
||||
{
|
||||
// return ProductionCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ProductionCharacteristic();
|
||||
$warnMsg = [];
|
||||
$plant = null;
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$plantId = null;
|
||||
$iCode = trim($this->data['item']) ?? '';
|
||||
$itemId = null;
|
||||
$lineNam = trim($this->data['line']) ?? '';
|
||||
$lineId = null;
|
||||
$machineName = trim($this->data['machine_name'] ?? '');
|
||||
$pOrder = trim($this->data['production_order'] ?? '');
|
||||
$sNo = trim($this->data['serial_number'] ?? '');
|
||||
$charName = trim($this->data['characteristic_name'] ?? '');
|
||||
$obsValue = trim($this->data['observed_value'] ?? '');
|
||||
$status = trim($this->data['status'] ?? '');
|
||||
$remark = trim($this->data['remark'] ?? '');
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
}
|
||||
if ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
|
||||
$warnMsg[] = 'Invalid machine name found!';
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found for the given plant!';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$lineExists = Line::where('name', $lineNam)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant!';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$machineExists = Machine::where('work_center', $machineName)->first();
|
||||
if (! $machineExists) {
|
||||
$warnMsg[] = 'Machine not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$machineAgainstPlant = Machine::where('work_center', $machineName)->where('plant_id', $plantId)->first();
|
||||
if (! $machineAgainstPlant) {
|
||||
$warnMsg[] = 'Machine not found for the given plant!';
|
||||
} else {
|
||||
$machineId = $machineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
ProductionCharacteristic::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'item_id' => $itemId,
|
||||
'machine_id' => $machineId,
|
||||
'production_order' => $pOrder,
|
||||
'serial_number' => $sNo,
|
||||
'characteristic_name' => $charName,
|
||||
'observed_value' => $obsValue,
|
||||
'status' => $status,
|
||||
'remark' => $remark,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
'created_by' => Filament::auth()->user()->name,
|
||||
'updated_by' => Filament::auth()->user()->name,
|
||||
]
|
||||
);
|
||||
|
||||
return null;
|
||||
|
||||
// return new ProductionCharacteristic();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Carbon\Carbon;
|
||||
@@ -9,6 +10,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class ProductionOrderImporter extends Importer
|
||||
@@ -22,7 +24,7 @@ class ProductionOrderImporter extends Importer
|
||||
->requiredMapping()
|
||||
->label('PLANT CODE')
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->example('TEST007')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
@@ -33,45 +35,47 @@ class ProductionOrderImporter extends Importer
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('quantity')
|
||||
->requiredMapping()
|
||||
->label('QUANTITY')
|
||||
->exampleHeader('QUANTITY')
|
||||
->example('3')
|
||||
->example('1')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('start_date')
|
||||
->label('START DATETIME')
|
||||
->exampleHeader('START DATETIME')
|
||||
->example('2026-04-30 10:00:00')
|
||||
->requiredMapping()
|
||||
->label('START DATE')
|
||||
->exampleHeader('START DATE')
|
||||
->example('30-01-2026') // 00:00:00
|
||||
->rules(['required']),
|
||||
ImportColumn::make('end_date')
|
||||
->label('END DATETIME')
|
||||
->exampleHeader('END DATETIME')
|
||||
->example('2026-05-30 10:00:00')
|
||||
->requiredMapping()
|
||||
->label('END DATE')
|
||||
->exampleHeader('END DATE')
|
||||
->example('30-01-2026') // 00:00:00
|
||||
->rules(['required']),
|
||||
ImportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER')
|
||||
->exampleHeader('PRODUCTION ORDER')
|
||||
->example('260116180001')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('from_serial_number')
|
||||
->label('FROM SERIAL NUMBER')
|
||||
->exampleHeader('FROM SERIAL NUMBER')
|
||||
->example('1000211260400001')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('to_serial_number')
|
||||
->label('TO SERIAL NUMBER')
|
||||
->exampleHeader('TO SERIAL NUMBER')
|
||||
->example('1000211260400003')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('USER00001')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('USER00001')
|
||||
->rules(['required']),
|
||||
->exampleHeader('PRODUCTION ORDER'),
|
||||
// ->example('260116180001')
|
||||
// ImportColumn::make('from_serial_number')
|
||||
// ->label('FROM SERIAL NUMBER')
|
||||
// // ->exampleHeader('FROM SERIAL NUMBER')
|
||||
// // ->example('1000211260400001')
|
||||
// ->rules(['required']),
|
||||
// ImportColumn::make('to_serial_number')
|
||||
// ->label('TO SERIAL NUMBER')
|
||||
// // ->exampleHeader('TO SERIAL NUMBER')
|
||||
// // ->example('1000211260400003')
|
||||
// ->rules(['required']),
|
||||
// ImportColumn::make('created_by')
|
||||
// ->label('CREATED BY')
|
||||
// // ->exampleHeader('CREATED BY')
|
||||
// // ->example('USER00001')
|
||||
// ->rules(['required']),
|
||||
// ImportColumn::make('updated_by')
|
||||
// ->label('UPDATED BY')
|
||||
// // ->exampleHeader('UPDATED BY')
|
||||
// // ->example('USER00001')
|
||||
// ->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -88,82 +92,206 @@ class ProductionOrderImporter extends Importer
|
||||
$startAt = trim($this->data['start_date']) ?? '';
|
||||
$endAt = trim($this->data['end_date']) ?? '';
|
||||
$prodOrd = trim($this->data['production_order']) ?? '';
|
||||
$fromSerNo = trim($this->data['from_serial_number']) ?? '';
|
||||
$toSerNo = trim($this->data['to_serial_number']) ?? '';
|
||||
$createdBy = trim($this->data['created_by']) ?? '';
|
||||
$updatedBy = trim($this->data['updated_by']) ?? '';
|
||||
$createdBy = Filament::auth()->user()?->name ?? '';
|
||||
$updatedBy = $createdBy;
|
||||
|
||||
if ($qnty) {
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (! is_numeric($plantCod)) {
|
||||
$warnMsg[] = 'Plant code should contain only numeric values!';
|
||||
} elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) {
|
||||
$warnMsg[] = 'Plant code must be between 4 and 7 digits only!';
|
||||
} elseif (! preg_match('/^[1-9]\d{6,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
$qValid = false;
|
||||
$oValid = false;
|
||||
$dValid = false;
|
||||
|
||||
if ($plantCod == null || $plantCod == '' || ! $plantCod) {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (! is_numeric($plantCod)) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' should contain only numeric values!";
|
||||
} elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) {
|
||||
$warnMsg[] = "Plant code '{$plantCod}' must be between 4 and 7 digits only!";
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code '{$plantCod}' found!";
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($itemCod == null || $itemCod == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (! ctype_alnum($itemCod)) {
|
||||
$warnMsg[] = "Item code '{$itemCod}' should contain only alpha-numeric values!";
|
||||
} elseif (Str::length($itemCod) < 6) {
|
||||
$warnMsg[] = "Item code '{$itemCod}' should contain minimum 6 digits!";
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$item = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found for the given plant!';
|
||||
} else {
|
||||
$itemId = $item->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($qnty == null || $qnty == '' || $qnty == '0') {
|
||||
$warnMsg[] = "Quantity can't be empty or zero!";
|
||||
} elseif (! is_numeric($qnty)) {
|
||||
$warnMsg[] = "Quantity '{$qnty}' should contain only numeric values!";
|
||||
} else {
|
||||
$qValid = true;
|
||||
}
|
||||
|
||||
if ($prodOrd == null || $prodOrd == '' || ! $prodOrd) {
|
||||
$oValid = true;
|
||||
} elseif (! is_numeric($prodOrd)) {
|
||||
$warnMsg[] = "Production order '{$prodOrd}' should contain only numeric values!";
|
||||
} elseif (Str::length($prodOrd) < 7 || Str::length($prodOrd) > 12) {
|
||||
$warnMsg[] = "Production order '{$prodOrd}' must be between 7 and 12 digits only!";
|
||||
} else {
|
||||
$oValid = true;
|
||||
}
|
||||
|
||||
if (! $startAt) {
|
||||
$warnMsg[] = "Start date can't be empty!";
|
||||
}
|
||||
if (! $endAt) {
|
||||
$warnMsg[] = "End date can't be empty!";
|
||||
}
|
||||
if ($startAt && $endAt) {
|
||||
$formats = ['d-m-Y', 'd-m-Y H:i', 'd-m-Y H:i:s'];
|
||||
|
||||
$cDateTime = null;
|
||||
$uDateTime = null;
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $startAt);
|
||||
if ($format === 'd-m-Y' || $format === 'd-m-Y H:i' || $format === 'd-m-Y H:i:s') {
|
||||
$cDateTime = $cDateTime->startOfDay();
|
||||
}
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
$dupProd = ProductionOrder::where('production_order', $prodOrd)->first(); // where('plant_id', $plantId)->
|
||||
if ($dupProd) {
|
||||
$warnMsg[] = "Production Order '{$prodOrd}' already exists in database!";
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $endAt);
|
||||
if ($format === 'd-m-Y' || $format === 'd-m-Y H:i' || $format === 'd-m-Y H:i:s') {
|
||||
$uDateTime = $uDateTime->endOfDay();
|
||||
}
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
if (! isset($cDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Start Date' format. Expected DD-MM-YYYY"; // DD-MM-YYYY HH:MM:SS
|
||||
}
|
||||
|
||||
if (! isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'End Date' format. Expected DD-MM-YYYY";
|
||||
}
|
||||
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Start Date' is greater than 'End Date'.";
|
||||
} else {
|
||||
$dValid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($plantId && $itemId && $qValid && $oValid && $dValid) {
|
||||
$now = Carbon::now();
|
||||
$plantId = $plantCod ?? null;
|
||||
$quantity = $qnty ?? null;
|
||||
$plantCode = Plant::find($plantId)->code;
|
||||
|
||||
$year = $now->format('y'); // Year (last 2 digits)
|
||||
$month = $now->format('m');
|
||||
|
||||
$monthText = strtoupper($now->format('M')); // APR
|
||||
$monthNumber = '';
|
||||
if ($prodOrd) {
|
||||
$dupProd = ProductionOrder::where('plant_id', $plantId)->where('production_order', $prodOrd)->first();
|
||||
if ($dupProd) {
|
||||
$warnMsg[] = "Production Order '{$prodOrd}' already exists in database for the given plant!";
|
||||
} else {
|
||||
$dupProd = ProductionOrder::where('production_order', $prodOrd)->first();
|
||||
if ($dupProd) {
|
||||
$warnMsg[] = "Production Order '{$prodOrd}' already exists in database!";
|
||||
}
|
||||
}
|
||||
|
||||
foreach (str_split($monthText) as $char) {
|
||||
$curSeq = ord($char) - 64;
|
||||
$monthNumber .= str_pad($curSeq, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$prefix = $year.$monthNumber;
|
||||
|
||||
$last = ProductionOrder::where('production_order', 'like', "{$prefix}%")->orderByDesc('production_order')->first(); // ProductionOrder::where('production_order', 'like', $prefix.'%')->orderBy('production_order', 'desc')->first();
|
||||
|
||||
if ($last) {
|
||||
$lastSeq = substr($last->production_order, -4);
|
||||
$nextSeq = str_pad(((int) $lastSeq + 1), 4, '0', STR_PAD_LEFT);
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
} else {
|
||||
$nextSeq = '0001';
|
||||
$monthText = strtoupper($now->format('M')); // APR
|
||||
$monthNumber = '';
|
||||
|
||||
foreach (str_split($monthText) as $char) {
|
||||
$curSeq = ord($char) - 64;
|
||||
$monthNumber .= str_pad($curSeq, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$prefix = $year.$monthNumber;
|
||||
|
||||
$last = ProductionOrder::where('production_order', 'like', "{$prefix}%")->orderByDesc('production_order')->first(); // ProductionOrder::where('production_order', 'like', $prefix.'%')->orderBy('production_order', 'desc')->first();
|
||||
|
||||
if ($last) {
|
||||
$lastSeq = substr($last->production_order, -4);
|
||||
$nextSeq = str_pad(((int) $lastSeq + 1), 4, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$nextSeq = '0001';
|
||||
}
|
||||
|
||||
$prodOrd = $prefix.$nextSeq;
|
||||
}
|
||||
|
||||
$productionOrder = $prefix.$nextSeq;
|
||||
|
||||
$prefixSerial = $plantCode.$year.$month;
|
||||
$prefixSerial = $plantCod.$year.$month;
|
||||
|
||||
$last = ProductionOrder::where('to_serial_number', 'like', "{$prefixSerial}%")->orderByDesc('to_serial_number')->first();
|
||||
|
||||
if ($last) {
|
||||
$lastSeq = (int) substr($last->to_serial_number, -6);
|
||||
$startSeq = $lastSeq + 1;
|
||||
$startSeq = str_pad(($lastSeq + 1), 6, '0', STR_PAD_LEFT);
|
||||
$endSeq = str_pad(($lastSeq + $qnty), 6, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$startSeq = 1;
|
||||
$startSeq = '000001';
|
||||
$endSeq = str_pad($qnty, 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$endSeq = $startSeq + $quantity - 1;
|
||||
// $endSeq = $startSeq + $qnty - 1;
|
||||
$fromSerial = $prefixSerial.$startSeq; // str_pad($startSeq, 6, '0', STR_PAD_LEFT)
|
||||
$toSerial = $prefixSerial.$endSeq; // str_pad($endSeq, 6, '0', STR_PAD_LEFT)
|
||||
|
||||
$fromSerial = $prefixSerial.str_pad($startSeq, 6, '0', STR_PAD_LEFT);
|
||||
$toSerial = $prefixSerial.str_pad($endSeq, 6, '0', STR_PAD_LEFT);
|
||||
ProductionOrder::create([
|
||||
'plant_id' => $plantId ?? null,
|
||||
'item_id' => $itemId ?? null,
|
||||
'quantity' => $qnty ?? null,
|
||||
'start_date' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'end_date' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
'production_order' => $prodOrd ?? null,
|
||||
'from_serial_number' => $fromSerial ?? null,
|
||||
'to_serial_number' => $toSerial ?? null,
|
||||
'created_by' => $createdBy ?? null,
|
||||
'updated_by' => $updatedBy ?? null,
|
||||
]);
|
||||
} else {
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
}
|
||||
// return ProductionOrder::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ProductionOrder;
|
||||
return null;
|
||||
// return new ProductionOrder;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
141
app/Filament/Imports/RequestCharacteristicImporter.php
Normal file
141
app/Filament/Imports/RequestCharacteristicImporter.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class RequestCharacteristicImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = RequestCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example('RMGLAS01')
|
||||
->label('WORK CENTER')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ITEM CODE')
|
||||
->example('630214')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('characteristicApproverMaster')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('aufnr')
|
||||
->label('AUFNR')
|
||||
->exampleHeader('AUFNR')
|
||||
->example('1234567'),
|
||||
ImportColumn::make('characteristic_name')
|
||||
->label('CHARACTERISTIC NAME')
|
||||
->exampleHeader('CHARACTERISTIC NAME')
|
||||
->example('ZMM_PUMPSET_MODEL'),
|
||||
ImportColumn::make('current_value')
|
||||
->label('CURRENT VALUE')
|
||||
->exampleHeader('CURRENT VALUE')
|
||||
->example('MVN-32/02 D R'),
|
||||
ImportColumn::make('update_value')
|
||||
->label('UPDATE VALUE')
|
||||
->exampleHeader('UPDATE VALUE')
|
||||
->example('MVN-32/02 TR3'),
|
||||
ImportColumn::make('approver_status1')
|
||||
->label('APPROVER STATUS 1')
|
||||
->exampleHeader('APPROVER STATUS 1')
|
||||
->example('Hold'),
|
||||
ImportColumn::make('approver_status2')
|
||||
->label('APPROVER STATUS 2')
|
||||
->exampleHeader('APPROVER STATUS 2')
|
||||
->example('Approved'),
|
||||
ImportColumn::make('approver_status3')
|
||||
->label('APPROVER STATUS 3')
|
||||
->exampleHeader('APPROVER STATUS 3')
|
||||
->example('Rejected'),
|
||||
ImportColumn::make('approver_remark1')
|
||||
->label('APPROVER REMARK 1')
|
||||
->exampleHeader('APPROVER REMARK 1')
|
||||
->example('Hold for review'),
|
||||
ImportColumn::make('approver_remark2')
|
||||
->label('APPROVER REMARK 2')
|
||||
->exampleHeader('APPROVER REMARK 2')
|
||||
->example('Approved with comments'),
|
||||
ImportColumn::make('approver_remark3')
|
||||
->label('APPROVER REMARK 3')
|
||||
->exampleHeader('APPROVER REMARK 3')
|
||||
->example('Rejected due to incorrect value'),
|
||||
ImportColumn::make('work_flow_id')
|
||||
->label('WORK FLOW ID')
|
||||
->exampleHeader('WORK FLOW ID')
|
||||
->example('WF-260303-0001'),
|
||||
ImportColumn::make('mail_status')
|
||||
->label('MAIL STATUS')
|
||||
->exampleHeader('MAIL STATUS')
|
||||
->example('Sent'),
|
||||
ImportColumn::make('trigger_at')
|
||||
->label('TRIGGER AT')
|
||||
->exampleHeader('MAIL STATUS')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('approved1_at')
|
||||
->label('APPROVED1 AT')
|
||||
->exampleHeader('APPROVED1 AT')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('approved2_at')
|
||||
->label('APPROVED2 AT')
|
||||
->exampleHeader('APPROVED2 AT')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('approved3_at')
|
||||
->label('APPROVED3 AT')
|
||||
->exampleHeader('APPROVED3 AT')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('RAW01234'),
|
||||
ImportColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('RAW01234'),
|
||||
ImportColumn::make('model_type')
|
||||
->label('MODEL TYPE')
|
||||
->exampleHeader('MODEL TYPE')
|
||||
->example('PUMP'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?RequestCharacteristic
|
||||
{
|
||||
// return RequestCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new RequestCharacteristic();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your request characteristic import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -179,29 +179,64 @@ class StickerMasterImporter extends Importer
|
||||
$part5 = trim($this->data['part_validation5']);
|
||||
$laserPart1 = trim($this->data['laser_part_validation1']);
|
||||
$laserPart2 = trim($this->data['laser_part_validation2']);
|
||||
$SerialNumberMotor = trim($this->data['serial_number_motor']) ?? null;
|
||||
$SerialNumberMotor = ($SerialNumberMotor == '0') ? null : $SerialNumberMotor;
|
||||
$SerialNumberPump = trim($this->data['serial_number_pump']) ?? null;
|
||||
$SerialNumberPump = ($SerialNumberPump == '0') ? null : $SerialNumberPump;
|
||||
$SerialNumberPumpSet = trim($this->data['serial_number_pumpset']) ?? null;
|
||||
$SerialNumberPumpSet = ($SerialNumberPumpSet == '0') ? null : $SerialNumberPumpSet;
|
||||
$PackSlipMotor = trim($this->data['pack_slip_motor']) ?? null;
|
||||
$PackSlipMotor = ($PackSlipMotor == '0') ? null : $PackSlipMotor;
|
||||
$PackSlipPump = trim($this->data['pack_slip_pump']) ?? null;
|
||||
$PackSlipPump = ($PackSlipPump == '0') ? null : $PackSlipPump;
|
||||
$PackSlipPumpSet = trim($this->data['pack_slip_pumpset']) ?? null;
|
||||
$PackSlipPumpSet = ($PackSlipPumpSet == '0') ? null : $PackSlipPumpSet;
|
||||
$NamePlateMotor = trim($this->data['name_plate_motor']) ?? null;
|
||||
$NamePlateMotor = ($NamePlateMotor == '0') ? null : $NamePlateMotor;
|
||||
$NamePlatePump = trim($this->data['name_plate_pump']) ?? null;
|
||||
$NamePlatePump = ($NamePlatePump == '0') ? null : $NamePlatePump;
|
||||
$NamePlatePumpSet = trim($this->data['name_plate_pumpset']) ?? null;
|
||||
$NamePlatePumpSet = ($NamePlatePumpSet == '0') ? null : $NamePlatePumpSet;
|
||||
$TubeStickMotor = trim($this->data['tube_sticker_motor']) ?? null;
|
||||
$TubeStickMotor = ($TubeStickMotor == '0') ? null : $TubeStickMotor;
|
||||
$TubeStickPump = trim($this->data['tube_sticker_pump']) ?? null;
|
||||
$TubeStickPump = ($TubeStickPump == '0') ? null : $TubeStickPump;
|
||||
$TubeStickPumpSet = trim($this->data['tube_sticker_pumpset']) ?? null;
|
||||
$TubeStickPumpSet = ($TubeStickPumpSet == '0') ? null : $TubeStickPumpSet;
|
||||
$WarrantyCard = trim($this->data['warranty_card']) ?? null;
|
||||
$WarrantyCard = ($WarrantyCard == '0') ? null : $WarrantyCard;
|
||||
$LoadRate = $this->data['load_rate'] ?? 0;
|
||||
$BundleQuantity = $this->data['bundle_quantity'] ?? null;
|
||||
$MaterialType = $this->data['material_type'] ?? null;
|
||||
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = Filament::auth()->user()->name;
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (! is_numeric($plantCod)) {
|
||||
$warnMsg[] = 'Plant code should contain only numeric values!';
|
||||
} elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) {
|
||||
$warnMsg[] = 'Plant code must be between 4 and 7 digits only!';
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
}
|
||||
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
if (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found for the plant';
|
||||
$warnMsg[] = 'Item code not found for the plant!';
|
||||
} else {
|
||||
$itemId = $item->id;
|
||||
|
||||
@@ -211,7 +246,7 @@ class StickerMasterImporter extends Importer
|
||||
}
|
||||
|
||||
if (Str::length($panelCod) > 0 && (Str::length($panelCod) < 6 || ! ctype_alnum($panelCod))) {
|
||||
$warnMsg[] = 'Invalid panel box code found';
|
||||
$warnMsg[] = 'Invalid panel box code found!';
|
||||
} elseif ($panelCod) {
|
||||
$parts = [$part1, $part2, $part3, $part4];
|
||||
$validParts = array_values(array_filter($parts, fn ($p) => ! empty($p)));
|
||||
@@ -222,53 +257,53 @@ class StickerMasterImporter extends Importer
|
||||
[$part1, $part2, $part3, $part4, $part5] = array_pad($validParts, 5, '');
|
||||
}
|
||||
|
||||
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
||||
$warnMsg[] = 'Serial number motor must be 1 or empty';
|
||||
if (Str::length($SerialNumberMotor) > 0 && (! is_numeric($SerialNumberMotor) || $SerialNumberMotor < 1)) {
|
||||
$warnMsg[] = "Serial number motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = 'Serial number pump must be 1 or empty';
|
||||
if (Str::length($SerialNumberPump) > 0 && (! is_numeric($SerialNumberPump) || $SerialNumberPump < 1)) {
|
||||
$warnMsg[] = "Serial number pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Serial number pumpset must be 1 or empty';
|
||||
if (Str::length($SerialNumberPumpSet) > 0 && (! is_numeric($SerialNumberPumpSet) || $SerialNumberPumpSet < 1)) {
|
||||
$warnMsg[] = "Serial number pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = 'Pack slip motor must be 1 or empty';
|
||||
if (Str::length($PackSlipMotor) > 0 && (! is_numeric($PackSlipMotor) || $PackSlipMotor < 1)) {
|
||||
$warnMsg[] = "Pack slip motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pump must be 1 or empty';
|
||||
if (Str::length($PackSlipPump) > 0 && (! is_numeric($PackSlipPump) || $PackSlipPump < 1)) {
|
||||
$warnMsg[] = "Pack slip pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pumpset must be 1 or empty';
|
||||
if (Str::length($PackSlipPumpSet) > 0 && (! is_numeric($PackSlipPumpSet) || $PackSlipPumpSet < 1)) {
|
||||
$warnMsg[] = "Pack slip pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
|
||||
$warnMsg[] = 'Name plate motor must be 1 or empty';
|
||||
if (Str::length($NamePlateMotor) > 0 && (! is_numeric($NamePlateMotor) || $NamePlateMotor < 1)) {
|
||||
$warnMsg[] = "Name plate motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = 'Name plate pump must be 1 or empty';
|
||||
if (Str::length($NamePlatePump) > 0 && (! is_numeric($NamePlatePump) || $NamePlatePump < 1)) {
|
||||
$warnMsg[] = "Name plate pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Name plate pumpset must be 1 or empty';
|
||||
if (Str::length($NamePlatePumpSet) > 0 && (! is_numeric($NamePlatePumpSet) || $NamePlatePumpSet < 1)) {
|
||||
$warnMsg[] = "Name plate pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker motor must be 1 or empty';
|
||||
if (Str::length($TubeStickMotor) > 0 && (! is_numeric($TubeStickMotor) || $TubeStickMotor < 1)) {
|
||||
$warnMsg[] = "Tube sticker motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pump must be 1 or empty';
|
||||
if (Str::length($TubeStickPump) > 0 && (! is_numeric($TubeStickPump) || $TubeStickPump < 1)) {
|
||||
$warnMsg[] = "Tube sticker pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pumpset must be 1 or empty';
|
||||
if (Str::length($TubeStickPumpSet) > 0 && (! is_numeric($TubeStickPumpSet) || $TubeStickPumpSet < 1)) {
|
||||
$warnMsg[] = "Tube sticker pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
|
||||
$warnMsg[] = 'Warranty card must be 1 or empty';
|
||||
if (Str::length($WarrantyCard) > 0 && (! is_numeric($WarrantyCard) || $WarrantyCard < 1)) {
|
||||
$warnMsg[] = "Warranty card must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['load_rate']) < 0 || ! is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
|
||||
$warnMsg[] = 'Load rate must be greater than or equal to 0';
|
||||
if (Str::length($LoadRate) < 0 || ! is_numeric($LoadRate) || $LoadRate < 0) {
|
||||
$warnMsg[] = "Load rate must be greater than or equal to '0'!";
|
||||
}
|
||||
if (Str::length($this->data['bundle_quantity']) > 0 && (! is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
|
||||
if (Str::length($BundleQuantity) > 0 && (! is_numeric($BundleQuantity) || $BundleQuantity <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { // ($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = 'Material type must be 1 or 2 or 3 or empty';
|
||||
if (Str::length($MaterialType) > 0 && $MaterialType != '1' && $MaterialType != '2' && $MaterialType != '3' && $MaterialType != '4') { // ($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = "Material type must be '1' or '2' or '3' or '4' or empty!";
|
||||
}
|
||||
|
||||
if (empty($warnMsg)) {
|
||||
@@ -292,19 +327,19 @@ class StickerMasterImporter extends Importer
|
||||
'plant_id' => $plantId,
|
||||
],
|
||||
[
|
||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||
'serial_number_pump' => $this->data['serial_number_pump'],
|
||||
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
|
||||
'pack_slip_motor' => $this->data['pack_slip_motor'],
|
||||
'pack_slip_pump' => $this->data['pack_slip_pump'],
|
||||
'pack_slip_pumpset' => $this->data['pack_slip_pumpset'],
|
||||
'name_plate_motor' => $this->data['name_plate_motor'],
|
||||
'name_plate_pump' => $this->data['name_plate_pump'],
|
||||
'name_plate_pumpset' => $this->data['name_plate_pumpset'],
|
||||
'tube_sticker_motor' => $this->data['tube_sticker_motor'],
|
||||
'tube_sticker_pump' => $this->data['tube_sticker_pump'],
|
||||
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'],
|
||||
'warranty_card' => $this->data['warranty_card'],
|
||||
'serial_number_motor' => $SerialNumberMotor,
|
||||
'serial_number_pump' => $SerialNumberPump,
|
||||
'serial_number_pumpset' => $SerialNumberPumpSet,
|
||||
'pack_slip_motor' => $PackSlipMotor,
|
||||
'pack_slip_pump' => $PackSlipPump,
|
||||
'pack_slip_pumpset' => $PackSlipPumpSet,
|
||||
'name_plate_motor' => $NamePlateMotor,
|
||||
'name_plate_pump' => $NamePlatePump,
|
||||
'name_plate_pumpset' => $NamePlatePumpSet,
|
||||
'tube_sticker_motor' => $TubeStickMotor,
|
||||
'tube_sticker_pump' => $TubeStickPump,
|
||||
'tube_sticker_pumpset' => $TubeStickPumpSet,
|
||||
'warranty_card' => $WarrantyCard,
|
||||
'part_validation1' => $part1,
|
||||
'part_validation2' => $part2,
|
||||
'part_validation3' => $part3,
|
||||
@@ -313,9 +348,9 @@ class StickerMasterImporter extends Importer
|
||||
'laser_part_validation1' => $laserPart1,
|
||||
'laser_part_validation2' => $laserPart2,
|
||||
'panel_box_code' => $panelCod,
|
||||
'load_rate' => $this->data['load_rate'],
|
||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||
'material_type' => $this->data['material_type'],
|
||||
'load_rate' => $LoadRate,
|
||||
'material_type' => $MaterialType,
|
||||
'bundle_quantity' => $BundleQuantity,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
|
||||
@@ -575,6 +575,10 @@ class TempClassCharacteristicImporter extends Importer
|
||||
->label('ZQMM QTY')
|
||||
->exampleHeader('ZQMM QTY')
|
||||
->example(''),
|
||||
ImportColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->exampleHeader('ZMM OPERATING TEMPERATURE')
|
||||
->example(''),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->label('WINDed SERIAL NUMBER')
|
||||
->exampleHeader('WINDED SERIAL NUMBER')
|
||||
|
||||
@@ -8,6 +8,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Str;
|
||||
|
||||
@@ -56,6 +57,12 @@ class UserImporter extends Importer
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant_id'];
|
||||
$plant = null;
|
||||
$user = $this->data['name'];
|
||||
$mail = $this->data['email'];
|
||||
$pass = $this->data['password'];
|
||||
$restrictedUsers = ['Admin', 'Dhanabalan S', 'Ranjith B'];
|
||||
$adminUser = Filament::auth()->user()?->name;
|
||||
|
||||
if (Str::length($plantCod) > 0 && (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod))) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
} elseif (Str::length($plantCod) <= 0) {
|
||||
@@ -70,14 +77,14 @@ class UserImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($this->data['name']) < 3) {
|
||||
if (Str::length($user) < 3) {
|
||||
$warnMsg[] = 'Invalid user name found!';
|
||||
}
|
||||
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
|
||||
if (Str::length($this->data['email']) < 5) {
|
||||
if (Str::length($mail) < 5) {
|
||||
$warnMsg[] = 'Invalid email found!';
|
||||
}
|
||||
if (Str::length($this->data['password']) < 3) {
|
||||
if (Str::length($pass) < 3) {
|
||||
$warnMsg[] = 'Invalid password found!';
|
||||
}
|
||||
// Validate roles if provided
|
||||
@@ -97,16 +104,20 @@ class UserImporter extends Importer
|
||||
$warnMsg[] = 'User roles not found!';
|
||||
}
|
||||
|
||||
if (! in_array($adminUser, $restrictedUsers, true) && in_array($user, $restrictedUsers, true)) {
|
||||
throw new RowImportFailedException("You don't have permission to import user with name '{$user}'!");
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$user = User::updateOrCreate([
|
||||
'email' => $this->data['email'],
|
||||
'email' => $mail,
|
||||
],
|
||||
[
|
||||
'name' => $this->data['name'],
|
||||
'password' => $this->data['password'],
|
||||
'name' => $user,
|
||||
'password' => $pass,
|
||||
'plant_id' => $plant,
|
||||
]);
|
||||
|
||||
@@ -118,7 +129,7 @@ class UserImporter extends Importer
|
||||
return null;
|
||||
// return User::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// 'email' => $mail,
|
||||
// ]);
|
||||
|
||||
// return new User();
|
||||
|
||||
88
app/Filament/Imports/VehicleEntryImporter.php
Normal file
88
app/Filament/Imports/VehicleEntryImporter.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\VehicleEntry;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class VehicleEntryImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = VehicleEntry::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example('1000')
|
||||
->label('PLANT CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('vehicle_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('VEHICLE NUMBER')
|
||||
->example('ABC123')
|
||||
->label('VEHICLE NUMBER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->exampleHeader('UUID')
|
||||
->example('ABC123'),
|
||||
ImportColumn::make('boom_opened')
|
||||
->exampleHeader('BOOM OPENED')
|
||||
->example('Auto')
|
||||
->label('BOOM OPENED'),
|
||||
ImportColumn::make('entry_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ENTRY TIME')
|
||||
->example('2023-01-01 09:00:00')
|
||||
->label('ENTRY TIME'),
|
||||
ImportColumn::make('exit_time')
|
||||
->exampleHeader('EXIT TIME')
|
||||
->example('2023-01-01 17:00:00')
|
||||
->label('EXIT TIME'),
|
||||
ImportColumn::make('duration')
|
||||
->exampleHeader('DURATION (HOURS)')
|
||||
->example('8')
|
||||
->label('DURATION (HOURS)'),
|
||||
ImportColumn::make('type')
|
||||
->exampleHeader('TYPE')
|
||||
->example('TRUCK')
|
||||
->label('TYPE'),
|
||||
ImportColumn::make('created_by')
|
||||
->exampleHeader('CREATED BY')
|
||||
->example('John Doe')
|
||||
->label('CREATED BY'),
|
||||
ImportColumn::make('updated_by')
|
||||
->exampleHeader('UPDATED BY')
|
||||
->example('Jane Doe')
|
||||
->label('UPDATED BY'),
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?VehicleEntry
|
||||
{
|
||||
// return VehicleEntry::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new VehicleEntry();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your vehicle entry import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
65
app/Filament/Imports/VisitorEntryImporter.php
Normal file
65
app/Filament/Imports/VisitorEntryImporter.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\VisitorEntry;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class VisitorEntryImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = VisitorEntry::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('employeeMaster')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mobile_number')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('name'),
|
||||
ImportColumn::make('company'),
|
||||
ImportColumn::make('purpose_of_visit'),
|
||||
ImportColumn::make('type'),
|
||||
ImportColumn::make('photo'),
|
||||
ImportColumn::make('number_of_person')
|
||||
->numeric()
|
||||
->rules(['integer']),
|
||||
ImportColumn::make('in_time')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('out_time')
|
||||
->rules(['datetime']),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('register_id'),
|
||||
ImportColumn::make('valid_upto')
|
||||
->rules(['datetime']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?VisitorEntry
|
||||
{
|
||||
// return VisitorEntry::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new VisitorEntry();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your visitor entry import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ class Dashboard extends \Filament\Pages\Dashboard
|
||||
|
||||
protected static string $view = 'filament.pages.dashboard';
|
||||
|
||||
protected static ?string $slug = 'welcome';
|
||||
|
||||
// public function mount(): void
|
||||
// {
|
||||
// session()->forget(['selected_plant']);
|
||||
|
||||
79
app/Filament/Pages/GateOutEntry.php
Normal file
79
app/Filament/Pages/GateOutEntry.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\VisitorEntry;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class GateOutEntry extends Page implements HasForms
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.gate-out-entry';
|
||||
|
||||
protected static ?string $navigationGroup = 'Gate Entry';
|
||||
|
||||
|
||||
public $pId, $invoiceNumber;
|
||||
|
||||
public array $invoiceOverviewData = [];
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('') // You can give your section a title or leave it blank
|
||||
->schema([
|
||||
TextInput::make('scan_out_gate_pass')
|
||||
->label('Scan Out Gate Pass')
|
||||
->required()
|
||||
->reactive()
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processGatePass($event.target.value)',
|
||||
]),
|
||||
])
|
||||
->columns(5)
|
||||
]);
|
||||
}
|
||||
|
||||
public function processGatePass($gatePass)
|
||||
{
|
||||
$entry = VisitorEntry::where('register_id', $gatePass)->first();
|
||||
|
||||
if ($entry) {
|
||||
$entry->out_time = now();
|
||||
$entry->save();
|
||||
|
||||
Notification::make()
|
||||
->title('Gate Pass Processed')
|
||||
->body('Gate pass has been successfully processed. Visitor marked as exited.')
|
||||
->success()
|
||||
->send();
|
||||
$this->filters['scan_out_gate_pass'] = '';
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Invalid Gate Pass')
|
||||
->body('The scanned gate pass is not valid. Please try again.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view gate entry page');
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ use Filament\Forms\Form;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
|
||||
class InvoiceDashboard extends Page
|
||||
{
|
||||
@@ -27,9 +28,13 @@ class InvoiceDashboard extends Page
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selec_plant', 'select_invoice']);
|
||||
session()->forget(['from_date']);
|
||||
session()->forget(['to_date']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'invoice' => null,
|
||||
'from_date' => null,
|
||||
'to_date' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -62,9 +67,23 @@ class InvoiceDashboard extends Page
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['select_invoice' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
})
|
||||
}),
|
||||
DatePicker::make('created_from')
|
||||
->label('Created From')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['from_date' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
}),
|
||||
DatePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['to_date' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
}),
|
||||
])
|
||||
->columns(2);
|
||||
->columns(4);
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
|
||||
@@ -291,7 +291,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
$machineId = $get('machine_id');
|
||||
|
||||
$this->mNam = $machineId;
|
||||
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
// 'class' => $get('pqLineError') ? 'border-red-500' : '',
|
||||
|
||||
@@ -58,6 +58,8 @@ class AlertMailRuleResource extends Resource
|
||||
'ProductionQuantities' => 'ProductionQuantities',
|
||||
'QualityValidation' => 'QualityValidation',
|
||||
'InvoiceTransit' => 'InvoiceTransit',
|
||||
'ImportTransit' => 'ImportTransit',
|
||||
'VehicleReport' => 'VehicleReport',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
@@ -69,6 +71,8 @@ class AlertMailRuleResource extends Resource
|
||||
'InvoiceDataMail' => 'Invoice Data Mail',
|
||||
'QualityMail' => 'Quality Mail',
|
||||
'InvoiceTransitMail' => 'Invoice Transit Mail',
|
||||
'ImportTransitMail' => 'Import Transit Mail',
|
||||
'VehicleReportMail' => 'Vehicle Report Mail',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
|
||||
446
app/Filament/Resources/AsrsItemValidationResource.php
Normal file
446
app/Filament/Resources/AsrsItemValidationResource.php
Normal file
@@ -0,0 +1,446 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\AsrsItemValidationExporter;
|
||||
use App\Filament\Imports\AsrsItemValidationImporter;
|
||||
use App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
use App\Filament\Resources\AsrsItemValidationResource\RelationManagers;
|
||||
use App\Models\AsrsItemValidation;
|
||||
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 Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Forms\Get;
|
||||
use App\Models\Item;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AsrsItemValidationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AsrsItemValidation::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\Select::make('item_code')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
->options(function (Get $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return AsrsItemValidation::where('plant_id', $plantId)
|
||||
->pluck('item_code', 'item_code');
|
||||
})
|
||||
->searchable()
|
||||
->afterStateUpdated(function (callable $set, $state) {
|
||||
$item = AsrsItemValidation::where('item_code', $state)->first();
|
||||
|
||||
if ($item) {
|
||||
$set('item_description', $item->item_description);
|
||||
$set('uom', $item->uom);
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
$set('uom', null);
|
||||
}
|
||||
})
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Item Description')
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\TextInput::make('uom')
|
||||
->label('UOM')
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\TextInput::make('material_type')
|
||||
->label('Material Type')
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\TextInput::make('material_group')
|
||||
->label('Material Group')
|
||||
->readOnly()
|
||||
->reactive()
|
||||
->disabledOn('edit'),
|
||||
Forms\Components\Select::make('mhe')
|
||||
->label('MHE')
|
||||
->options([
|
||||
'Bin1000*800*750' => 'Bin 1000*800*750',
|
||||
'Bin1000*800*1000' => 'Bin 1000*800*1000',
|
||||
'Pallet' => 'Pallet',
|
||||
'ChinaBin' => 'China Bin',
|
||||
'PalletWithPlasticCrate' => 'Pallet With Plastic Crate',
|
||||
'PlasticCrateBig' => 'Plastic Crate Big',
|
||||
'PlasticCrateSmall' => 'Plastic Crate Small',
|
||||
'OutsideStorage' => 'Outside Storage',
|
||||
]),
|
||||
Forms\Components\TextInput::make('bin_quantity')
|
||||
->label('Bin Quantity'),
|
||||
Forms\Components\Select::make('asrs')
|
||||
->label('ASRS')
|
||||
->options([
|
||||
'ASRS1' => 'ASRS1',
|
||||
'ASRS2' => 'ASRS2',
|
||||
]),
|
||||
Forms\Components\Select::make('asrs_category')
|
||||
->label('ASRS Category')
|
||||
->options([
|
||||
'In' => 'In',
|
||||
'Out' => 'Out',
|
||||
]),
|
||||
// Forms\Components\Select::make('status')
|
||||
// ->label('Status')
|
||||
// ->options([
|
||||
// 'Updated' => 'Updated',
|
||||
// 'NotUpdated' => 'Not Updated',
|
||||
// ]),
|
||||
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;
|
||||
})
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item_code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable(query: function ($query, string $search) {
|
||||
$itemCode = explode('|', trim($search))[0];
|
||||
$query->where('item_code', $itemCode);
|
||||
})
|
||||
// ->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item_description')
|
||||
->label('Item Description')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('uom')
|
||||
->label('UOM')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('material_type')
|
||||
->label('Material Type')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('material_group')
|
||||
->label('Material Group')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('mhe')
|
||||
->label('MHE')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('bin_quantity')
|
||||
->label('Bin Quantity')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('asrs')
|
||||
->label('ASRS')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('asrs_category')
|
||||
->label('ASRS Category')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('asrsItemValidations', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_code', null);
|
||||
}),
|
||||
Select::make('item_code')
|
||||
->label('Item Code')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return AsrsItemValidation::where('plant_id', $plantId)
|
||||
->distinct()
|
||||
->pluck('item_code', 'item_code')
|
||||
->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('uom', null);
|
||||
}),
|
||||
TextInput::make('uom')
|
||||
->label('UOM')
|
||||
->reactive()
|
||||
->placeholder('Enter UOM'),
|
||||
Select::make('status')
|
||||
->label('Status')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'Updated' => 'Updated',
|
||||
'NotUpdated' => 'Not Updated',
|
||||
];
|
||||
}),
|
||||
DateTimePicker::make('created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
|
||||
$status = $data['status'] ?? 'NotUpdated';
|
||||
// Hide all records initially if no filters are applied
|
||||
// if (empty($data['Plant']) && empty($data['item_code']) && empty($data['status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
// // return $query->whereRaw('1 = 0');
|
||||
// $query->where('status', 'NotUpdated');
|
||||
// }
|
||||
|
||||
if (
|
||||
empty($data['Plant']) &&
|
||||
empty($data['item_code']) &&
|
||||
empty($data['uom']) &&
|
||||
empty($data['status']) &&
|
||||
empty($data['created_from']) &&
|
||||
empty($data['created_to'])
|
||||
) {
|
||||
// $query->where('status', 'NotUpdated');
|
||||
$query->where(function ($q) {
|
||||
$q->where('status', 'NotUpdated')
|
||||
->orWhereNull('status')
|
||||
->orWhere('status', '');
|
||||
});
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
//else {
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// if ($userHas && strlen($userHas) > 0) {
|
||||
// return $query->whereRaw('1 = 0');
|
||||
// }
|
||||
// }
|
||||
|
||||
if (! empty($data['item_code'])) {
|
||||
$query->where('item_code', 'like', '%'.$data['item_code'].'%');
|
||||
}
|
||||
if (! empty($data['uom'])) {
|
||||
$query->where('uom', 'like', '%'.$data['uom'].'%');
|
||||
}
|
||||
if (!empty($data['status'])) {
|
||||
|
||||
if ($data['status'] == 'NotUpdated') {
|
||||
$query->where(function ($q) {
|
||||
$q->where('status', 'NotUpdated')
|
||||
->orWhereNull('status')
|
||||
->orWhere('status', '');
|
||||
});
|
||||
} else {
|
||||
$query->where('status', $data['status']);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
// $query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
//else {
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// if ($userHas && strlen($userHas) > 0) {
|
||||
// return 'Plant Name: Choose plant to filter records.';
|
||||
// }
|
||||
// }
|
||||
|
||||
if (! empty($data['item_code'])) {
|
||||
$indicators[] = 'Item Code: '.$data['item_code'];
|
||||
}
|
||||
|
||||
if (! empty($data['uom'])) {
|
||||
$indicators[] = 'UOM: '.$data['uom'];
|
||||
}
|
||||
|
||||
if (! empty($data['status'])) {
|
||||
$indicators[] = 'Status: '.$data['status'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
// ->hidden(function ($record): bool {
|
||||
// if (auth()->user()?->hasRole('SuperAdmin')) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// return trim(strtolower($record->status)) == 'updated';
|
||||
// }),
|
||||
// ->visible(function ($record): bool {
|
||||
// return auth()->user()?->hasRole('SuperAdmin')
|
||||
// || strtolower(trim($record->status ?? '')) != 'updated' || strtolower(trim($record->status ?? '')) == null || strtolower(trim($record->status ?? '')) == '';
|
||||
// }),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(AsrsItemValidationImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import asrs item validation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(AsrsItemValidationExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export asrs item validation');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAsrsItemValidations::route('/'),
|
||||
'create' => Pages\CreateAsrsItemValidation::route('/create'),
|
||||
'view' => Pages\ViewAsrsItemValidation::route('/{record}'),
|
||||
'edit' => Pages\EditAsrsItemValidation::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAsrsItemValidation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAsrsItemValidation extends EditRecord
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
$data['status'] = 'Updated';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl(
|
||||
'index',
|
||||
[
|
||||
'tableFilters' => [
|
||||
'advanced_filters' => [
|
||||
'status' => 'NotUpdated',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
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\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAsrsItemValidations extends ListRecords
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AsrsItemValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AsrsItemValidationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewAsrsItemValidation extends ViewRecord
|
||||
{
|
||||
protected static string $resource = AsrsItemValidationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
||||
use App\Filament\Imports\CharacteristicApproverMasterImporter;
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -20,6 +21,10 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
|
||||
class CharacteristicApproverMasterResource extends Resource
|
||||
{
|
||||
@@ -392,7 +397,203 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('requestCharacteristics', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('machine', null);
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
Select::make('machine')
|
||||
->label('Search by Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::whereHas('requestCharacteristics', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('work_center', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
// $set('item_id', null);
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
Select::make('approver_type')
|
||||
->label('Approver Type')
|
||||
->options([
|
||||
'Characteristic' => 'Characteristic',
|
||||
'Quality' => 'Quality',
|
||||
])
|
||||
->placeholder('Select Type')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('name1', null);
|
||||
$set('name2', null);
|
||||
$set('name3', null);
|
||||
}),
|
||||
TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->placeholder('Enter Machine Name'),
|
||||
TextInput::make('characteristic_field')
|
||||
->label('Characteristic Field')
|
||||
->placeholder('Enter Characteristic Field'),
|
||||
TextInput::make('name1')
|
||||
->label('Approver Name 1')
|
||||
->placeholder('Enter Approver Name 2')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('name2', null);
|
||||
$set('name3', null);
|
||||
}),
|
||||
TextInput::make('name2')
|
||||
->label('Approver Name 2')
|
||||
->placeholder('Enter Approver Name 2')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('name3', null);
|
||||
}),
|
||||
TextInput::make('name3')
|
||||
->label('Approver Name 3')
|
||||
->placeholder('Enter Approver Name 2'),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['machine_name']) && empty($data['characteristic_field']) && empty($data['approver_type']) && empty($data['name1']) && empty($data['name2']) && empty($data['name3']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['machine'])) {
|
||||
$query->where('machine_id', $data['machine']);
|
||||
}
|
||||
|
||||
if (! empty($data['machine_name'])) {
|
||||
$query->where('machine_name', 'like', '%'.$data['machine_name'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['characteristic_field'])) {
|
||||
$query->where('characteristic_field', 'like', '%'.$data['characteristic_field'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['approver_type'])) {
|
||||
$query->where('approver_type', 'like', '%'.$data['approver_type'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['name1'])) {
|
||||
$query->where('name1', 'like', '%'.$data['name1'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['name2'])) {
|
||||
$query->where('name2', 'like', '%'.$data['name2'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['name3'])) {
|
||||
$query->where('name3', 'like', '%'.$data['name3'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['machine'])) {
|
||||
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine'])->value('work_center');
|
||||
}
|
||||
|
||||
if (! empty($data['machine_name'])) {
|
||||
$indicators[] = 'Machine Name: '.$data['machine_name'];
|
||||
}
|
||||
|
||||
if (! empty($data['characteristic_field'])) {
|
||||
$indicators[] = 'Characteristic Field: '.$data['characteristic_field'];
|
||||
}
|
||||
|
||||
if (! empty($data['approver_type'])) {
|
||||
$indicators[] = 'Approver Type: '.$data['approver_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['name1'])) {
|
||||
$indicators[] = 'Approver Name 1: '.$data['name1'];
|
||||
}
|
||||
|
||||
if (! empty($data['name2'])) {
|
||||
$indicators[] = 'Approver Name 2: '.$data['name2'];
|
||||
}
|
||||
|
||||
if (! empty($data['name3'])) {
|
||||
$indicators[] = 'Approver Name 3: '.$data['name3'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
|
||||
@@ -968,6 +968,12 @@ class ClassCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->reactive()
|
||||
@@ -1804,6 +1810,10 @@ class ClassCharacteristicResource extends Resource
|
||||
->label('ZQMM QTY')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mark_status')
|
||||
->label('MARKED STATUS')
|
||||
->alignCenter()
|
||||
@@ -2028,6 +2038,9 @@ class ClassCharacteristicResource extends Resource
|
||||
TextInput::make('gernr')
|
||||
->label('Serial Number')
|
||||
->placeholder('Enter Serial Number'),
|
||||
TextInput::make('zmm_heading')
|
||||
->label('Heading')
|
||||
->placeholder('Enter Heading'),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
@@ -2041,7 +2054,7 @@ class ClassCharacteristicResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -2071,6 +2084,10 @@ class ClassCharacteristicResource extends Resource
|
||||
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['zmm_heading'])) {
|
||||
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
@@ -2108,6 +2125,10 @@ class ClassCharacteristicResource extends Resource
|
||||
$indicators[] = 'Serial Number: '.$data['gernr'];
|
||||
}
|
||||
|
||||
if (! empty($data['zmm_heading'])) {
|
||||
$indicators[] = 'Heading: '.$data['zmm_heading'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
219
app/Filament/Resources/EmployeeMasterResource.php
Normal file
219
app/Filament/Resources/EmployeeMasterResource.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\EmployeeMasterExporter;
|
||||
use App\Filament\Imports\EmployeeMasterImporter;
|
||||
use App\Filament\Resources\EmployeeMasterResource\Pages;
|
||||
use App\Filament\Resources\EmployeeMasterResource\RelationManagers;
|
||||
use App\Models\EmployeeMaster;
|
||||
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 Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class EmployeeMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = EmployeeMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Gate Entry';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->reactive()
|
||||
->extraInputAttributes([
|
||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',
|
||||
]),
|
||||
Forms\Components\TextInput::make('code')
|
||||
->label('ID')
|
||||
->extraInputAttributes([
|
||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z0-9]/g, "")',])
|
||||
->required()
|
||||
->unique(
|
||||
table: 'employee_masters',
|
||||
column: 'code',
|
||||
ignoreRecord: true
|
||||
)
|
||||
->validationMessages([
|
||||
'unique' => 'Duplicate employee code already exists.',
|
||||
]),
|
||||
Forms\Components\TextInput::make('department')
|
||||
->label('Department')
|
||||
->required(),
|
||||
// Forms\Components\TextInput::make('designation')
|
||||
// ->label('Designation')
|
||||
// ->extraInputAttributes([
|
||||
// 'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',])
|
||||
// ->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
->label('Email')
|
||||
->email()
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('mobile_number')
|
||||
->label('Mobile Number')
|
||||
->length(10)
|
||||
->reactive()
|
||||
->extraInputAttributes([
|
||||
'oninput' => 'this.value = this.value.replace(/[^0-9]/g, "").slice(0, 10)', // blocks non-numbers + limits to 10 chars
|
||||
'maxlength' => 10,
|
||||
])
|
||||
->required()
|
||||
->unique(
|
||||
table: 'employee_masters',
|
||||
column: 'mobile_number',
|
||||
ignoreRecord: true
|
||||
)
|
||||
->validationMessages([
|
||||
'unique' => 'Duplicate mobile number already exists.',
|
||||
]),
|
||||
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;
|
||||
})
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->numeric()
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Name')
|
||||
->sortable()
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('code')
|
||||
->label('Employee ID')
|
||||
->sortable()
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('department')
|
||||
->label('Department')
|
||||
->sortable()
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
// Tables\Columns\TextColumn::make('designation')
|
||||
// ->label('Designation')
|
||||
// ->sortable()
|
||||
// ->alignCenter()
|
||||
// ->searchable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->label('Email')
|
||||
->sortable()
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('mobile_number')
|
||||
->label('Mobile Number')
|
||||
->sortable()
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created by')
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated by')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->alignCenter(),
|
||||
])
|
||||
->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(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(EmployeeMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import employee master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(EmployeeMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export employee master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListEmployeeMasters::route('/'),
|
||||
'create' => Pages\CreateEmployeeMaster::route('/create'),
|
||||
'view' => Pages\ViewEmployeeMaster::route('/{record}'),
|
||||
'edit' => Pages\EditEmployeeMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EmployeeMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EmployeeMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEmployeeMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EmployeeMasterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EmployeeMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EmployeeMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEmployeeMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = EmployeeMasterResource::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\EmployeeMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EmployeeMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEmployeeMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = EmployeeMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EmployeeMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EmployeeMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewEmployeeMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = EmployeeMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
683
app/Filament/Resources/ImportTransitResource.php
Normal file
683
app/Filament/Resources/ImportTransitResource.php
Normal file
@@ -0,0 +1,683 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\ImportTransitExporter;
|
||||
use App\Filament\Resources\ImportTransitResource\Pages;
|
||||
use App\Filament\Resources\ImportTransitResource\RelationManagers;
|
||||
use App\Models\ImportTransit;
|
||||
use App\Models\InvoiceDataValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
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 Filament\Forms\Components\FileUpload;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
// use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
class ImportTransitResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ImportTransit::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Manufacturing SD';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('cri_rfq_number')
|
||||
->label('CRI/RFQ Number')
|
||||
->disabled(fn ($operation) => $operation == 'edit')
|
||||
->unique(ignoreRecord: true),
|
||||
Forms\Components\DatePicker::make('mail_received_date')
|
||||
->label('Mail Received Date')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('pricol_ref_number')
|
||||
->label('Pricol Ref Number')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('requester')
|
||||
->label('Requester')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('shipper')
|
||||
->label('Shipper')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('shipper_location')
|
||||
->label('Shipper Location')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('shipper_invoice')
|
||||
->label('Shipper Invoice')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\DatePicker::make('shipper_invoice_date')
|
||||
->label('Shipper Invoice Date')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('customs_agent_name')
|
||||
->label('Customs Agent Name')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\DatePicker::make('eta_date')
|
||||
->label('ETA Date')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Under Service Provider Finalization' => 'Under Service Provider Finalization',
|
||||
'Yet to pick up' => 'Yet to pick up',
|
||||
'Awaiting Vessel Loading' => 'Awaiting Vessel Loading',
|
||||
'In Transit' => 'In Transit',
|
||||
'Under Import Customs Clearance in Destination' => 'Under Import Customs Clearance in Destination',
|
||||
'Delivered' => 'Delivered',
|
||||
])
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('delivery_location')
|
||||
->label('Delivery Location')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\DatePicker::make('etd_date')
|
||||
->label('ETD Date')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('mode')
|
||||
->label('Mode')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('inco_terms')
|
||||
->label('Inco Terms')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('port_of_loading')
|
||||
->label('Port of Loading')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('port_of_discharge')
|
||||
->label('Port of Discharge')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('delivery_city')
|
||||
->label('Delivery City')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('packages')
|
||||
->label('Packages')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('type_of_package')
|
||||
->label('Type of Package')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('gross_weight')
|
||||
->label('Gross Weight')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('volume')
|
||||
->label('Volume')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('bill_number')
|
||||
->label('Bill Number')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\DatePicker::make('bill_received_date')
|
||||
->label('Bill Received Date')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('vessel_number')
|
||||
->label('Vessel Number')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('remark')
|
||||
->label('Remark')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('is_transit_identified')
|
||||
->label('Is Transit Identified')
|
||||
->default(0)
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->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),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->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('cri_rfq_number')
|
||||
->label('CRI/RFQ Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mail_received_date')
|
||||
->label('Mail Received Date')
|
||||
->date()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pricol_ref_number')
|
||||
->label('Pricol Ref Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('requester')
|
||||
->label('Requester')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper')
|
||||
->label('Shipper')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper_location')
|
||||
->label('Shipper Location')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper_invoice')
|
||||
->label('Shipper Invoice')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('shipper_invoice_date')
|
||||
->label('Shipper Invoice Date')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('customs_agent_name')
|
||||
->label('Customs Agent Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('eta_date')
|
||||
->label('ETA Date')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('delivery_location')
|
||||
->label('Delivery Location')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('etd_date')
|
||||
->label('ETD Date')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mode')
|
||||
->label('Mode')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('inco_terms')
|
||||
->label('Inco Terms')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('port_of_loading')
|
||||
->label('Port of Loading')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('port_of_discharge')
|
||||
->label('Port of Discharge')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('delivery_city')
|
||||
->label('Delivery City')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('packages')
|
||||
->label('Packages')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type_of_package')
|
||||
->label('Type of Package')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('gross_weight')
|
||||
->label('Gross Weight')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('volume')
|
||||
->label('Volume')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bill_number')
|
||||
->label('Bill Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bill_received_date')
|
||||
->label('Bill Received Date')
|
||||
->alignCenter()
|
||||
->date()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('vessel_number')
|
||||
->label('Vessel Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('remark')
|
||||
->label('Remark')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('is_transit_identified')
|
||||
->label('Is Transit Identified')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->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(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
Tables\Actions\Action::make('Import Transit')
|
||||
->label('Import Transit')
|
||||
->form([
|
||||
FileUpload::make('import_transit_file')
|
||||
->label('Import Transit')
|
||||
// ->required()
|
||||
->preserveFilenames()
|
||||
->storeFiles(false)
|
||||
->reactive()
|
||||
->required()
|
||||
->disk('local')
|
||||
// ->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||
->directory('uploads/ImportTransit'),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$uploadedFile = $data['import_transit_file'];
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
// Get original filename
|
||||
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
|
||||
|
||||
$originalNameOnly = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
|
||||
// Store manually using storeAs to keep original name
|
||||
$path = $uploadedFile->storeAs('uploads/ImportTransit', $originalName, 'local'); // returns relative path
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
if ($fullPath && file_exists($fullPath)) {
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if ((count($rows) - 1) <= 0) {
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
->body("Import the valid 'Import Transit' file to proceed..!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$invalidCriNo = [];
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowNumber = $index + 1;
|
||||
|
||||
$criRfqNo = trim($row[1] ?? '');
|
||||
$mailRcvdDate = trim($row[2] ?? '');
|
||||
$pricolRefNo = trim($row[3] ?? '');
|
||||
$requester = trim($row[4] ?? '');
|
||||
$shipper = trim($row[5] ?? '');
|
||||
$shipperLocation = trim($row[6] ?? '');
|
||||
$shipperInv = trim($row[7] ?? '');
|
||||
$shipperInvDate = trim($row[8] ?? '');
|
||||
$cha = trim($row[9] ?? '');
|
||||
$eta = trim($row[10] ?? '');
|
||||
$status = trim($row[11] ?? '');
|
||||
$dlyLoc = trim($row[12] ?? '');
|
||||
$etd = trim($row[13] ?? '');
|
||||
$mode = trim($row[14] ?? '');
|
||||
$incoTerms = trim($row[15] ?? '');
|
||||
$portOfLoading = trim($row[16] ?? '');
|
||||
$portOfDischarge = trim($row[17] ?? '');
|
||||
$deliveryCity = trim($row[18] ?? '');
|
||||
$packages = trim($row[19] ?? '');
|
||||
$typeOfPkg = trim($row[20] ?? '');
|
||||
$grossWeight = trim($row[21] ?? '');
|
||||
$volumeWeight = trim($row[22] ?? '');
|
||||
$blNo = trim($row[23] ?? '');
|
||||
$blRcvdDate = trim($row[24] ?? '');
|
||||
$vesselNo = trim($row[25] ?? '');
|
||||
|
||||
if (empty($criRfqNo)) {
|
||||
$invalidCriNo[] = $rowNumber;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($invalidCriNo)){
|
||||
|
||||
$errorMsg = '';
|
||||
|
||||
if (! empty($invalidCriNo)) {
|
||||
$errorMsg .= 'Missing CRI Rfq No in rows: '.implode(', ', $invalidCriNo).'<br>';
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Missing Mandatory Fields')
|
||||
->body($errorMsg)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// $spreadsheet = IOFactory::load($fullPath);
|
||||
|
||||
// foreach ($spreadsheet->getAllSheets() as $sheet) {
|
||||
// $state = $sheet->getSheetState();
|
||||
// if ($state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_HIDDEN ||
|
||||
// $state == \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::SHEETSTATE_VERYHIDDEN) {
|
||||
// Notification::make()
|
||||
// ->title('Import Failed')
|
||||
// ->body("Hidden sheet found: \"{$sheet->getTitle()}\". Please remove all hidden sheets and try again.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowNumber = $index + 1;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
$formattedDate = null;
|
||||
$formattedShipperDate = null;
|
||||
$etaDate = null;
|
||||
$etdDate = null;
|
||||
$formattedBlRcvdDate = null;
|
||||
|
||||
$criRfqNo = trim($row[1] ?? '');
|
||||
$mailRcvdDate = trim($row[2] ?? '');
|
||||
$pricolRefNo = trim($row[3] ?? '');
|
||||
$requester = trim($row[4] ?? '');
|
||||
$shipper = trim($row[5] ?? '');
|
||||
$shipperLocation = trim($row[6] ?? '');
|
||||
$shipperInv = trim($row[7] ?? '');
|
||||
$shipperInvDate = trim($row[8] ?? '');
|
||||
$cha = trim($row[9] ?? '');
|
||||
$eta = trim($row[10] ?? '');
|
||||
$status = trim($row[11] ?? '');
|
||||
$dlyLoc = trim($row[12] ?? '');
|
||||
$etd = trim($row[13] ?? '');
|
||||
$mode = trim($row[14] ?? '');
|
||||
$incoTerms = trim($row[15] ?? '');
|
||||
$portOfLoading = trim($row[16] ?? '');
|
||||
$portOfDischarge = trim($row[17] ?? '');
|
||||
$deliveryCity = trim($row[18] ?? '');
|
||||
$packages = trim($row[19] ?? '');
|
||||
$typeOfPkg = trim($row[20] ?? '');
|
||||
$grossWeight = trim($row[21] ?? '');
|
||||
$volumeWeight = trim($row[22] ?? '');
|
||||
$blNo = trim($row[23] ?? '');
|
||||
$blRcvdDate = trim($row[24] ?? '');
|
||||
$vesselNo = trim($row[25] ?? '');
|
||||
|
||||
|
||||
if (! empty($mailRcvdDate)) {
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $mailRcvdDate)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $mailRcvdDate);
|
||||
$formattedDate = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($mailRcvdDate)) {
|
||||
$formattedDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($mailRcvdDate)->format('Y-m-d');
|
||||
} else {
|
||||
$formattedDate = date('Y-m-d', strtotime($mailRcvdDate));
|
||||
}
|
||||
}
|
||||
if (! empty($shipperInvDate)) {
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $shipperInvDate)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $shipperInvDate);
|
||||
$formattedShipperDate = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($shipperInvDate)) {
|
||||
$formattedShipperDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($shipperInvDate)->format('Y-m-d');
|
||||
} else {
|
||||
$formattedShipperDate = date('Y-m-d', strtotime($shipperInvDate));
|
||||
}
|
||||
}
|
||||
if (! empty($eta)) {
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $eta)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $eta);
|
||||
$etaDate = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($eta)) {
|
||||
$etaDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($eta)->format('Y-m-d');
|
||||
} else {
|
||||
$etaDate = date('Y-m-d', strtotime($eta));
|
||||
}
|
||||
}
|
||||
if (! empty($etd)) {
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $etd)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $etd);
|
||||
$etdDate = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($etd)) {
|
||||
$etdDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($etd)->format('Y-m-d');
|
||||
} else {
|
||||
$etdDate = date('Y-m-d', strtotime($etd));
|
||||
}
|
||||
}
|
||||
if (! empty($blRcvdDate)) {
|
||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $blRcvdDate)) {
|
||||
[$day, $month, $year] = preg_split('/[-\/]/', $blRcvdDate);
|
||||
$formattedBlRcvdDate = "{$year}-{$month}-{$day}";
|
||||
} elseif (is_numeric($blRcvdDate)) {
|
||||
$formattedBlRcvdDate = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($blRcvdDate)->format('Y-m-d');
|
||||
} else {
|
||||
$formattedBlRcvdDate = date('Y-m-d', strtotime($blRcvdDate));
|
||||
}
|
||||
}
|
||||
|
||||
$inserted = ImportTransit::updateOrCreate(
|
||||
[
|
||||
'cri_rfq_number' => $criRfqNo,
|
||||
],
|
||||
[
|
||||
'mail_received_date' => $formattedDate ?? null,
|
||||
'pricol_ref_number' => $pricolRefNo ?? null,
|
||||
'requester' => $requester ?? null,
|
||||
'shipper' => $shipper ?? null,
|
||||
'shipper_location' => $shipperLocation ?? null,
|
||||
'shipper_invoice' => $shipperInv ?? null,
|
||||
'shipper_invoice_date' => $formattedShipperDate ?? null,
|
||||
'customs_agent_name' => $cha ?? null,
|
||||
'eta_date' => $etaDate ?? null,
|
||||
'status' => $status ?? null,
|
||||
'delivery_location' => $dlyLoc ?? null,
|
||||
'etd_date' => $etdDate ?? null,
|
||||
'mode' => $mode ?? null,
|
||||
'inco_terms' => $incoTerms ?? null,
|
||||
'port_of_loading' => $portOfLoading ?? null,
|
||||
'port_of_discharge' => $portOfDischarge ?? null,
|
||||
'delivery_city' => $deliveryCity ?? null,
|
||||
'packages' => $packages ?? null,
|
||||
'type_of_package' => $typeOfPkg ?? null,
|
||||
'gross_weight' => $grossWeight ?? null,
|
||||
'volume' => $volumeWeight ?? null,
|
||||
'bill_number' => $blNo ?? null,
|
||||
'bill_received_date' => $formattedBlRcvdDate ?? null,
|
||||
'vessel_number' => $vesselNo ?? null,
|
||||
'created_by' => $operatorName,
|
||||
]
|
||||
);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Import Failed')
|
||||
->body("Error occurred while processing row. Error : {$e->getMessage()}")
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
if (! $inserted) {
|
||||
Notification::make()
|
||||
->title('Failed')
|
||||
->body("Records insertion failed!")
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
else{
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Records inserted successfully!")
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Import Failed')
|
||||
->body("No records were inserted. Error : {$e->getMessage()}")
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
})
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import transit');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Import Transit')
|
||||
->color('warning')
|
||||
->exporter(ImportTransitExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export import transit');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListImportTransits::route('/'),
|
||||
'create' => Pages\CreateImportTransit::route('/create'),
|
||||
'view' => Pages\ViewImportTransit::route('/{record}'),
|
||||
'edit' => Pages\EditImportTransit::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ImportTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ImportTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateImportTransit extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ImportTransitResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ImportTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ImportTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditImportTransit extends EditRecord
|
||||
{
|
||||
protected static string $resource = ImportTransitResource::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\ImportTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ImportTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListImportTransits extends ListRecords
|
||||
{
|
||||
protected static string $resource = ImportTransitResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ImportTransitResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ImportTransitResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewImportTransit extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ImportTransitResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,8 @@ use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\WireMasterPacking;
|
||||
use DB;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Concerns\ExposesTableToWidgets;
|
||||
@@ -174,17 +176,15 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
if (isset($matches[1])) {
|
||||
$invoiceNumber = $matches[1];
|
||||
$invoiceNumber = strtoupper($matches[1]);
|
||||
}
|
||||
} else {
|
||||
$invoiceNumber = strtoupper($invoiceNumber);
|
||||
}
|
||||
|
||||
// dd($invoiceNumber);
|
||||
|
||||
// ..
|
||||
|
||||
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
||||
|
||||
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;
|
||||
$this->invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number'])) ?? $invoiceNumber;
|
||||
|
||||
$invoiceType = null;
|
||||
// $this->invoiceNumber = $this->invoiceNumber ?? $invoiceNumber;
|
||||
@@ -581,7 +581,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$materialType = $sticker->material_type;
|
||||
// $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($code) { $query->where('plant_id', $this->plantId)->where('code', $code); })->first();
|
||||
|
||||
if ($materialType == 1) {
|
||||
if ($materialType == 1 || $materialType == 4) {
|
||||
$totalExcelQty = 0;
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
@@ -1765,7 +1765,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$materialType = $sticker->material_type;
|
||||
// $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($code) { $query->where('plant_id', $this->plantId)->where('code', $code); })->first();
|
||||
|
||||
if ($materialType == 1) {
|
||||
if ($materialType == 1 || $materialType == 4) {
|
||||
$totalExcelQty = 0;
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
@@ -2317,7 +2317,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
protected function refreshInvoiceTable()
|
||||
{
|
||||
$this->plantId = $this->form->getState()['plant_id'] ?? '';
|
||||
$this->invoiceNumber = $this->form->getState()['invoice_number'] ?? '';
|
||||
$this->invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number'])) ?? '';
|
||||
|
||||
if (! empty($this->invoiceNumber)) {
|
||||
$hasInvoice = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->first();
|
||||
@@ -2378,7 +2378,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$serialNumber = null;
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
$this->plantId = $plantId;
|
||||
$invoiceNumber = $this->form->getState()['invoice_number'];
|
||||
$invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number']));
|
||||
$this->invoiceNumber = $invoiceNumber;
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
@@ -2455,14 +2455,65 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
}
|
||||
|
||||
$pattern0 = '/^(?<item_code>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>[^|]+)\|(?<batch_quantity>[0-9]+(?:\.[0-9]+)?)\s?kg$/i';
|
||||
$pattern1 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>[^|]+)\/(?<batch_quantity>.+)$/i';
|
||||
$pattern2 = '/^(?<item_code>[^|]+)\|(?<batch_number>[^|]+)\|(?<batch_id>[^|]+)\|(?<batch_count>.+)$/i';
|
||||
$pattern3 = '/^(?<item_code>[^|]+)\|(?<batch_id>[^|]+)-(?<batch_count>.+)$/i';
|
||||
$pattern4 = '/^MP-(?<code>.+)$/i';
|
||||
$itemCode = '';
|
||||
$batchNumber = '';
|
||||
$curScanQty = '';
|
||||
$wirePallet = '';
|
||||
$curMaterialQty = '';
|
||||
$curMaterialSer = '';
|
||||
|
||||
if (preg_match($pattern1, $serNo, $matches)) {
|
||||
if (preg_match($pattern0, $serNo, $matches)) {
|
||||
$itemCode = $matches['item_code'];
|
||||
$this->currentItemCode = $itemCode;
|
||||
$curScanQty = trim($matches['batch_quantity']);
|
||||
$serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
|
||||
$serNo = null;
|
||||
|
||||
if (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif (empty($matches['batch_count']) || ! $matches['batch_count']) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
} elseif (preg_match($pattern1, $serNo, $matches)) {
|
||||
$itemCode = $matches['item_code'];
|
||||
$this->currentItemCode = $itemCode;
|
||||
$batchNumber = $matches['batch_number'];
|
||||
@@ -2470,11 +2521,45 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$curScanQty = $matches['batch_quantity'];
|
||||
$serNo = null;
|
||||
|
||||
if (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||
if (empty($matches['batch_number']) || ! $matches['batch_number']) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
@@ -2508,42 +2593,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif (! is_numeric($curScanQty)) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
@@ -2580,13 +2630,48 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$this->currentItemCode = $itemCode;
|
||||
$batchNumber = $matches['batch_number'];
|
||||
$serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
|
||||
$curMaterialSer = $matches['batch_number'].'-'.$matches['batch_id'];
|
||||
$curMaterialQty = $matches['batch_count'];
|
||||
$serNo = null;
|
||||
|
||||
if (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||
if (empty($matches['batch_number']) || ! $matches['batch_number']) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
// .Mail
|
||||
|
||||
// $mailData = $this->getMail();
|
||||
// $mPlantName = $mailData['plant_name'];
|
||||
// $emails = $mailData['emails'];
|
||||
// $mInvoiceType = 'Material';
|
||||
|
||||
// if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(
|
||||
// new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
|
||||
// );
|
||||
// } else {
|
||||
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||
// }
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
} elseif (empty($matches['batch_id']) || ! $matches['batch_id']) {
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
@@ -2619,7 +2704,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
@@ -2659,7 +2744,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
@@ -2693,7 +2778,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
@@ -2723,6 +2808,294 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
return;
|
||||
}
|
||||
} elseif (preg_match($pattern4, $serNo, $matches)) {
|
||||
$wirePallet = 'MP-'.$matches['code'];
|
||||
$wirePattern = '/^MP-(?<code>\d+)$/i';
|
||||
|
||||
if (! preg_match($wirePattern, $serNo, $matches)) {
|
||||
Notification::make()
|
||||
->title('Invalid Master Packing QR Format')
|
||||
->body("Scan valid Master Packing QR code proceed!<br>Sample format : 'MP-2601001'")
|
||||
->danger()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$wireMaster = WireMasterPacking::where('plant_id', $plantId)->where('wire_packing_number', $wirePallet)->first();
|
||||
|
||||
if (! $wireMaster) {
|
||||
Notification::make()
|
||||
->title('Master Pallet Not Found')
|
||||
->body("No record found for this Master Packing QR $wirePallet")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$wireItemCodes = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||
->where('wire_master_packings.plant_id', $plantId)
|
||||
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||
->pluck('items.code')
|
||||
->unique()
|
||||
->toArray();
|
||||
|
||||
$invoiceItemCodes = InvoiceValidation::join(
|
||||
'sticker_masters',
|
||||
'sticker_masters.id',
|
||||
'=',
|
||||
'invoice_validations.sticker_master_id'
|
||||
)
|
||||
->join(
|
||||
'items',
|
||||
'items.id',
|
||||
'=',
|
||||
'sticker_masters.item_id'
|
||||
)
|
||||
->where('invoice_validations.plant_id', $plantId)
|
||||
->where('invoice_validations.invoice_number', $this->invoiceNumber)
|
||||
->pluck('items.code')
|
||||
->unique()
|
||||
->toArray();
|
||||
|
||||
$missedCodes = array_diff($wireItemCodes, $invoiceItemCodes);
|
||||
|
||||
if (! empty($missedCodes)) {
|
||||
|
||||
Notification::make()
|
||||
->title('Items Missing in Invoice')
|
||||
->body('Item codes are missing in invoice: '.implode(', ', $missedCodes))
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$duplicateSerial = [];
|
||||
$weightExceeded = [];
|
||||
$processedItems = [];
|
||||
$invalidMaterialItems = [];
|
||||
|
||||
$wireItems1 = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||
->where('wire_master_packings.plant_id', $plantId)
|
||||
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||
->select(
|
||||
'items.code as item_code',
|
||||
'wire_master_packings.process_order',
|
||||
DB::raw('SUM(wire_master_packings.weight::numeric) as pallet_weight')
|
||||
)
|
||||
->groupBy('items.code', 'wire_master_packings.process_order')
|
||||
->get();
|
||||
|
||||
foreach ($wireItems1 as $wireItem) {
|
||||
$processOrder = $wireItem->process_order;
|
||||
$palletWeight = $wireItem->pallet_weight;
|
||||
$itemCode = $wireItem->item_code;
|
||||
|
||||
$processedItems[] = $itemCode;
|
||||
|
||||
$duplicate = InvoiceValidation::where('plant_id', $this->plantId)
|
||||
->where('invoice_number', $this->invoiceNumber)
|
||||
->where('serial_number', $processOrder)
|
||||
->exists();
|
||||
|
||||
if ($duplicate) {
|
||||
$duplicateSerial[] = $processOrder;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$materialType = StickerMaster::where('item_id', function ($q) use ($itemCode) {
|
||||
$q->select('id')->from('items')->where('code', $itemCode);
|
||||
})->value('material_type');
|
||||
|
||||
if ($materialType != 3) {
|
||||
if (! in_array($itemCode, $invalidMaterialItems)) {
|
||||
$invalidMaterialItems[] = $itemCode;
|
||||
}
|
||||
}
|
||||
|
||||
$scannedQty = InvoiceValidation::join('sticker_masters', 'sticker_masters.id', '=', 'invoice_validations.sticker_master_id')
|
||||
->join('items', 'items.id', '=', 'sticker_masters.item_id')
|
||||
->where('invoice_validations.plant_id', $plantId)
|
||||
->where('invoice_validations.invoice_number', $this->invoiceNumber)
|
||||
->where('items.code', $itemCode)
|
||||
->sum(DB::raw('invoice_validations.quantity::numeric'));
|
||||
|
||||
if ($palletWeight > $scannedQty) {
|
||||
$weightExceeded[] = $itemCode;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($invalidMaterialItems)) {
|
||||
$uniqueInvalidItems = array_unique($invalidMaterialItems);
|
||||
Notification::make()
|
||||
->title('Invalid Material Type')
|
||||
->body(implode(', ', $uniqueInvalidItems)."<br>Invalid material type found for the invoice '$invoiceNumber'.")
|
||||
->danger()
|
||||
->seconds(4)
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (! empty($weightExceeded)) {
|
||||
Notification::make()
|
||||
->title('Item Code Limit')
|
||||
->body(implode(', ', $weightExceeded)."<br>Master pallet weight exceeds the remaining quantity in invoice '$invoiceNumber'.")
|
||||
->danger()
|
||||
->seconds(4)
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (! empty($duplicateSerial)) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Number')
|
||||
->body(implode(', ', $duplicateSerial)."<br>Duplicate Serial numbers found for the invoice '$invoiceNumber'.")
|
||||
->danger()
|
||||
->seconds(4)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$itemExceeded = [];
|
||||
|
||||
$invoiceRows = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->whereNull('serial_number')
|
||||
->get();
|
||||
|
||||
$palletItems = WireMasterPacking::where('wire_master_packings.plant_id', $plantId)
|
||||
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||
->join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||
->select(
|
||||
'items.code as item_code',
|
||||
DB::raw('SUM(wire_master_packings.weight::numeric) as pallet_weight')
|
||||
)
|
||||
->groupBy('items.code')
|
||||
->get();
|
||||
|
||||
foreach ($invoiceRows as $row) {
|
||||
$itemCode = $row->stickerMaster->item->code ?? null;
|
||||
|
||||
if (! $itemCode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pallet = $palletItems->firstWhere('item_code', $itemCode);
|
||||
$palletWeight = $pallet->pallet_weight ?? 0;
|
||||
|
||||
$remainingQty = $row->quantity;
|
||||
|
||||
if ($palletWeight > $remainingQty) {
|
||||
$itemExceeded[] = $itemCode;
|
||||
}
|
||||
}
|
||||
|
||||
$items = implode(', ', $itemExceeded);
|
||||
|
||||
if (! empty($itemExceeded)) {
|
||||
Notification::make()
|
||||
->title('Item Code Limit')
|
||||
->body("Pallet weight exceeds remaining quantity for invoice number '$invoiceNumber'for below item codes <br>$items")
|
||||
->danger()
|
||||
->seconds(5)
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$wireItems = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id')
|
||||
->where('wire_master_packings.wire_packing_number', $wirePallet)
|
||||
->select(
|
||||
'items.code as item_code',
|
||||
'wire_master_packings.process_order',
|
||||
'wire_master_packings.weight as pallet_weight'
|
||||
// DB::raw('(wire_master_packings.weight::numeric) as pallet_weight')
|
||||
)
|
||||
->get();
|
||||
|
||||
foreach ($wireItems as $wireItem) {
|
||||
|
||||
$itemCode = $wireItem->item_code;
|
||||
$palletWeight = $wireItem->pallet_weight;
|
||||
$processOrder = $wireItem->process_order;
|
||||
|
||||
if (! $processOrder || $palletWeight <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$records = InvoiceValidation::join('sticker_masters', 'sticker_masters.id', '=', 'invoice_validations.sticker_master_id')
|
||||
->join('items', 'items.id', '=', 'sticker_masters.item_id')
|
||||
->where('invoice_validations.invoice_number', $invoiceNumber)
|
||||
->where('invoice_validations.plant_id', $plantId)
|
||||
->where('items.code', $itemCode)
|
||||
->whereNull('invoice_validations.serial_number')
|
||||
->where('invoice_validations.quantity', '>', 0)
|
||||
->orderBy('invoice_validations.created_at')
|
||||
->select('invoice_validations.*')
|
||||
->get();
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($records as $record) {
|
||||
|
||||
if ($palletWeight <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
$usedQty = min($record->quantity, $palletWeight);
|
||||
|
||||
$record->quantity -= $usedQty;
|
||||
|
||||
if ($usedQty == $record->quantity + $usedQty) {
|
||||
$record->serial_number = $processOrder;
|
||||
$record->quantity = $palletWeight;
|
||||
$record->save();
|
||||
} else {
|
||||
$record->save();
|
||||
|
||||
InvoiceValidation::create([
|
||||
'sticker_master_id' => $record->sticker_master_id,
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => $processOrder,
|
||||
'quantity' => $usedQty,
|
||||
'operator_id' => $operatorName,
|
||||
'created_by' => $operatorName,
|
||||
'updated_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
$palletWeight -= $usedQty;
|
||||
|
||||
// if ($record->quantity <= 0) {
|
||||
// $records->forget($key);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
$totQuan = InvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity' => $scanMQuan,
|
||||
]);
|
||||
|
||||
return;
|
||||
} else {
|
||||
$itemCode = null;
|
||||
$this->currentItemCode = '';
|
||||
@@ -2733,7 +3106,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Material QR Format')
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->body('Scan valid Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
@@ -2866,6 +3239,12 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$hasQuanTyp = ($record->material_type == 3) ? true : false;
|
||||
|
||||
if ($hasQuanTyp && $curMaterialSer && $curMaterialQty) {
|
||||
$batchNumber = null;
|
||||
$serialNumber = $curMaterialSer;
|
||||
$curScanQty = $curMaterialQty;
|
||||
}
|
||||
|
||||
$record = InvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->whereHas('stickerMasterRelation.item', function ($query) use ($itemCode) {
|
||||
@@ -2948,7 +3327,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->danger()
|
||||
->title('Invalid Quantity Material QR Format')
|
||||
->body('Scan valid Quantity Material QR code proceed!<br>Ex:123456|12345|12345678|1/1')
|
||||
->body('Scan valid Quantity Material QR code to proceed!<br>Sample formats are:<br>123456|123456789|001|5kg (or)<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
@@ -2994,8 +3373,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$record->serial_number = $serialNumber;
|
||||
$record->batch_number = $batchNumber;
|
||||
$record->operator_id = $operatorName;
|
||||
// $record->updated_by = $operatorName;
|
||||
// $record->updated_at = now();
|
||||
$record->updated_by = $operatorName;
|
||||
$record->updated_at = now();
|
||||
$record->save();
|
||||
|
||||
// InvoiceValidation::create([
|
||||
@@ -3231,7 +3610,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first();
|
||||
// $invoiceNumber = $this->form->getState()['invoice_number'];
|
||||
|
||||
if (! $record) {
|
||||
Notification::make()
|
||||
|
||||
463
app/Filament/Resources/LeakTestReadingResource.php
Normal file
463
app/Filament/Resources/LeakTestReadingResource.php
Normal file
@@ -0,0 +1,463 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\LeakTestReadingExporter;
|
||||
use App\Filament\Resources\LeakTestReadingResource\Pages;
|
||||
use App\Models\LeakTestReading;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class LeakTestReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = LeakTestReading::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->required()
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->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::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(LeakTestReading::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
$set('lsrPlantError', null);
|
||||
$set('lsrCodeError', null);
|
||||
$set('lsrSerialError', null);
|
||||
$set('item_code', null);
|
||||
$set('serial_number', null);
|
||||
$set('test_status', null);
|
||||
if (! $plantId) {
|
||||
$set('lsrPlantError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lsrPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lsrPlantError') ? $get('lsrPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('item_code')
|
||||
->required()
|
||||
->label('Item Code')
|
||||
->placeholder('Scan the valid item code')
|
||||
->autofocus(true)
|
||||
->alphaNum()
|
||||
->minLength(6)
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => ! empty($get('id')) && ! Filament::auth()->user()->hasRole('Super Admin'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('item_code');
|
||||
$set('lsrCodeError', null);
|
||||
if (! $code) {
|
||||
$set('lsrCodeError', 'Scan the valid item code.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (strlen($code) < 6) {
|
||||
$set('lsrCodeError', 'Item code must be at least 6 digits.');
|
||||
|
||||
return;
|
||||
} elseif (! ctype_alnum($code)) {
|
||||
$set('item_code', null);
|
||||
$set('lsrCodeError', 'Item code must contain only alpha-numeric characters!');
|
||||
|
||||
return;
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $code)) {
|
||||
$set('item_code', null);
|
||||
$set('lsrCodeError', "Item code should not begin with '0' or letter!");
|
||||
|
||||
return;
|
||||
}
|
||||
$set('lsrCodeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lsrCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lsrCodeError') ? $get('lsrCodeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->required()
|
||||
->label('Serial Number')
|
||||
->placeholder('Scan the valid serial number')
|
||||
->alphaNum()
|
||||
->minLength(9)
|
||||
->reactive()
|
||||
->disabled(fn (Get $get) => ! empty($get('id')) && ! Filament::auth()->user()->hasRole('Super Admin'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$serial = $get('serial_number');
|
||||
$set('lsrSerialError', null);
|
||||
if (! $serial) {
|
||||
$set('lsrSerialError', 'Scan the valid serial number!');
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (strlen($serial) < 9) {
|
||||
$set('lsrSerialError', 'Serial number must be at least 9 digits!');
|
||||
|
||||
return;
|
||||
} elseif (! ctype_alnum($serial)) {
|
||||
$set('serial_number', null);
|
||||
$set('lsrSerialError', 'Serial number must contain only alpha-numeric characters!');
|
||||
|
||||
return;
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serial)) {
|
||||
$set('serial_number', null);
|
||||
$set('lsrSerialError', "Serial number should not begin with '0' or letter!");
|
||||
|
||||
return;
|
||||
}
|
||||
$set('lsrSerialError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lsrSerialError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lsrSerialError') ? $get('lsrSerialError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('test_status')
|
||||
->required()
|
||||
->label('Test Status')
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->options(function (callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemCode = $get('item_code');
|
||||
$serialNumber = $get('serial_number');
|
||||
|
||||
if (! $plantId || ! $itemCode || ! $serialNumber) {
|
||||
$set('test_status', null);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'P' => 'PASS',
|
||||
'F' => 'FAIL',
|
||||
];
|
||||
})
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? 'F' : 'P';
|
||||
// return optional(CharacteristicApproverMaster::latest()->first())->approver_type ?? null;
|
||||
}),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 2]),
|
||||
]);
|
||||
}
|
||||
|
||||
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 Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item_code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('test_status')
|
||||
->label('Test Status')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable()
|
||||
->formatStateUsing(function ($state) {
|
||||
return match ($state) {
|
||||
'P' => 'PASS',
|
||||
'F' => 'FAIL',
|
||||
default => '-',
|
||||
};
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->searchPlaceholder('Search Serial Number')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('leakTestReadings', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('item_code', null);
|
||||
$set('serial_number', null);
|
||||
$set('test_status', null);
|
||||
}),
|
||||
Select::make('item_code')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
return $plantId ? LeakTestReading::where('plant_id', $plantId)->pluck('item_code', 'item_code')->toArray() : [];
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('serial_number', null);
|
||||
$set('test_status', null);
|
||||
}),
|
||||
TextInput::make('serial_number')
|
||||
->label('Search by Serial Number')
|
||||
->placeholder(placeholder: 'Enter Serial Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('test_status', null);
|
||||
}),
|
||||
Select::make('test_status')
|
||||
->label('Search by Test Status')
|
||||
->nullable()
|
||||
->options(function () {
|
||||
return [
|
||||
'P' => 'PASS',
|
||||
'F' => 'FAIL',
|
||||
];
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make(name: 'updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['item_code']) && empty($data['serial_number']) && empty($data['test_status']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_from']) && empty($data['updated_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['item_code'])) {
|
||||
$query->where('item_code', $data['item_code']);
|
||||
}
|
||||
|
||||
if (! empty($data['serial_number'])) {
|
||||
$query->where('serial_number', 'like', '%'.$data['serial_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['test_status'])) {
|
||||
$query->where('test_status', $data['test_status']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$query->where('updated_at', '>=', $data['updated_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$query->where('updated_at', '<=', $data['updated_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['item_code'])) {
|
||||
$indicators[] = 'Item Code: '.$data['item_code'];
|
||||
}
|
||||
|
||||
if (! empty($data['serial_number'])) {
|
||||
$indicators[] = 'Serial Number: '.$data['serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['test_status'])) {
|
||||
$indicators[] = 'Test Status: '.$data['test_status'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_from'])) {
|
||||
$indicators[] = 'From: '.$data['updated_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_to'])) {
|
||||
$indicators[] = 'To: '.$data['updated_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->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(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ExportAction::make()
|
||||
->label('Export Leak Test Readings')
|
||||
->color('warning')
|
||||
->exporter(LeakTestReadingExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export leak test reading');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListLeakTestReadings::route('/'),
|
||||
'create' => Pages\CreateLeakTestReading::route('/create'),
|
||||
'view' => Pages\ViewLeakTestReading::route('/{record}'),
|
||||
'edit' => Pages\EditLeakTestReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LeakTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\LeakTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateLeakTestReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LeakTestReadingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LeakTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\LeakTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditLeakTestReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = LeakTestReadingResource::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\LeakTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\LeakTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListLeakTestReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = LeakTestReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\LeakTestReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\LeakTestReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewLeakTestReading extends ViewRecord
|
||||
{
|
||||
protected static string $resource = LeakTestReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ class MachineResource extends Resource
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
@@ -75,6 +76,7 @@ class MachineResource extends Resource
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
->relationship('line', 'name')
|
||||
->searchable()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
@@ -115,6 +117,7 @@ class MachineResource extends Resource
|
||||
Forms\Components\Select::make('work_group_master_id')
|
||||
->label('Group Work Center')
|
||||
->relationship('workGroupMaster', 'name')
|
||||
->searchable()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
@@ -142,6 +145,7 @@ class MachineResource extends Resource
|
||||
$lineId = $get('line_id');
|
||||
if (! $lineId) {
|
||||
$set('mGroupWorkError', 'Please select a line first.');
|
||||
$set('work_group_master_id', null);
|
||||
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,7 @@ class PlantResource extends Resource
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('code')
|
||||
->label('Code')
|
||||
->required()
|
||||
->unique(ignoreRecord: true)
|
||||
->integer()
|
||||
@@ -78,7 +79,8 @@ class PlantResource extends Resource
|
||||
->hint(fn ($get) => $get('pCodeError') ? $get('pCodeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('company_id')
|
||||
// ->placeholder('Choose the valid company name')
|
||||
->label('Company')
|
||||
->placeholder('Choose the valid company nany')
|
||||
->relationship('company', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
@@ -104,9 +106,10 @@ class PlantResource extends Resource
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->label('Name')
|
||||
->placeholder('Scan the valid name')
|
||||
->unique(ignoreRecord: true)
|
||||
->columnSpanFull()
|
||||
// ->columnSpanFull()
|
||||
->reactive()
|
||||
->minLength(5)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
@@ -128,8 +131,38 @@ class PlantResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('pNameError') ? $get('pNameError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('warehouse_number')
|
||||
// ->required()
|
||||
->label('Warehouse Number')
|
||||
->placeholder('Scan the valid warehouse number')
|
||||
->unique(ignoreRecord: true)
|
||||
->reactive()
|
||||
->numeric()
|
||||
->length(3),
|
||||
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
// $codeId = $get('warehouse_number');
|
||||
// // Ensure `linestop_id` is not cleared
|
||||
// if (! $codeId) {
|
||||
// $set('wNumberError', 'Scan the valid warehouse number.');
|
||||
|
||||
// return;
|
||||
// } else {
|
||||
// if (strlen($codeId) != 3) {
|
||||
// $set('wNumberError', 'Warehouse number must be exactly 3 digits!');
|
||||
|
||||
// return;
|
||||
// }
|
||||
// $set('wNumberError', null);
|
||||
// }
|
||||
// })
|
||||
// ->extraAttributes(fn ($get) => [
|
||||
// 'class' => $get('wNumberError') ? 'border-red-500' : '',
|
||||
// ])
|
||||
// ->hint(fn ($get) => $get('wNumberError') ? $get('wNumberError') : null)
|
||||
// ->hintColor('danger'),
|
||||
Forms\Components\Textarea::make('address')
|
||||
->required()
|
||||
->label('Address')
|
||||
->placeholder('Scan the valid address')
|
||||
->unique(ignoreRecord: true)
|
||||
->columnSpanFull()
|
||||
@@ -190,6 +223,11 @@ class PlantResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('warehouse_number')
|
||||
->label('Warehouse Number')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('address')
|
||||
->label('Address')
|
||||
->alignCenter()
|
||||
|
||||
@@ -221,6 +221,12 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('category')
|
||||
->label('Category')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('inspection_type')
|
||||
->label('Inspection Type')
|
||||
->searchable()
|
||||
@@ -351,6 +357,11 @@ class ProductCharacteristicsMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('category')
|
||||
->label('Category')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line Name')
|
||||
->alignCenter()
|
||||
|
||||
@@ -339,8 +339,9 @@ class ProductionCharacteristicResource extends Resource
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Line', null);
|
||||
$set('Item', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line Name')
|
||||
@@ -361,7 +362,7 @@ class ProductionCharacteristicResource extends Resource
|
||||
})->pluck('name', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
$set('Machine', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Filament\Exports\ProductionOrderExporter;
|
||||
use App\Filament\Imports\ProductionOrderImporter;
|
||||
use App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Carbon\Carbon;
|
||||
@@ -21,6 +22,12 @@ use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Str;
|
||||
|
||||
|
||||
class ProductionOrderResource extends Resource
|
||||
{
|
||||
@@ -45,7 +52,8 @@ class ProductionOrderResource extends Resource
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->disabled(fn (string $context): bool => $context == 'edit')
|
||||
->dehydrated(true)
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -84,7 +92,7 @@ class ProductionOrderResource extends Resource
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? optional(ProductionOrder::where('plant_id', $userHas)->latest()->first())->plant_id : optional(ProductionOrder::latest()->first())->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? optional(ProductionOrder::where('plant_id', $userHas)->latest()->first())->item_id : optional(ProductionOrder::latest()->first())->item_id;
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
@@ -102,6 +110,7 @@ class ProductionOrderResource extends Resource
|
||||
->integer()
|
||||
->required()
|
||||
->readOnly(fn ($get) => ($get('plant_id') == null || $get('item_id') == null))
|
||||
->disabled(fn (string $context): bool => $context === 'edit')
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
if (! empty($state) && $state > 0) {
|
||||
$set('show_extra_fields', true);
|
||||
@@ -170,21 +179,38 @@ class ProductionOrderResource extends Resource
|
||||
Forms\Components\Hidden::make('show_extra_fields')
|
||||
->default(false),
|
||||
Forms\Components\DateTimePicker::make('start_date')
|
||||
->label('Start Date'),
|
||||
->label('Start Date')
|
||||
->reactive()
|
||||
// ->minDate(function () {
|
||||
// return Carbon::now()->addMinute();
|
||||
// })
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('end_date', null);
|
||||
}),
|
||||
Forms\Components\DateTimePicker::make('end_date')
|
||||
->label('End Date'),
|
||||
->label('End Date')
|
||||
->reactive(),
|
||||
// ->rule('after:start_date')
|
||||
// ->minDate(function (callable $get) {
|
||||
// $startDate = $get('start_date');
|
||||
// if ($startDate) {
|
||||
// return Carbon::parse($startDate)->addMinute();
|
||||
// }
|
||||
|
||||
// return Carbon::now()->addMinute();
|
||||
// }),
|
||||
Forms\Components\TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->readOnly()
|
||||
->visible(fn ($get) => $get('show_extra_fields')),
|
||||
->visible(fn ($get) => $get('quantity') > 0),
|
||||
Forms\Components\TextInput::make('from_serial_number')
|
||||
->label('From Serial Number')
|
||||
->readOnly()
|
||||
->visible(fn ($get) => $get('show_extra_fields')),
|
||||
->visible(fn ($get) => $get('quantity') > 0),
|
||||
Forms\Components\TextInput::make('to_serial_number')
|
||||
->label('To Serial Number')
|
||||
->readOnly()
|
||||
->visible(fn ($get) => $get('show_extra_fields')),
|
||||
->visible(fn ($get) => $get('quantity') > 0),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
@@ -203,6 +229,7 @@ class ProductionOrderResource extends Resource
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
@@ -220,6 +247,18 @@ class ProductionOrderResource extends Resource
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Item Description')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Unit of Measure')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('quantity')
|
||||
->label('Quantity')
|
||||
->searchable()
|
||||
@@ -255,22 +294,191 @@ class ProductionOrderResource extends Resource
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('productionOrder', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Line', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('productionOrders', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('production_order', null);
|
||||
}),
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->placeholder('Enter Production Order')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
TextInput::make('from_serial_number')
|
||||
->label('From Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter From Serial Number'),
|
||||
TextInput::make('to_serial_number')
|
||||
->label('To Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter To Serial Number'),
|
||||
DateTimePicker::make('created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Item']) && empty($data['production_order']) && empty($data['from_serial_number']) && empty($data['to_serial_number']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$query->where('item_id', $data['Item']);
|
||||
}
|
||||
|
||||
if (! empty($data['production_order'])) {
|
||||
$query->where('production_order', 'like', '%'.$data['production_order'].'%');
|
||||
}
|
||||
|
||||
if (!empty($data['from_serial_number']) && !empty($data['to_serial_number'])) {
|
||||
|
||||
$from = $data['from_serial_number'];
|
||||
$to = $data['to_serial_number'];
|
||||
|
||||
$query->where(function ($q) use ($from, $to) {
|
||||
$q->whereBetween('from_serial_number', [$from, $to])
|
||||
->orWhereBetween('to_serial_number', [$from, $to]);
|
||||
});
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
// $query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant Name: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['production_order'])) {
|
||||
$indicators[] = 'Production Order: '.$data['production_order'];
|
||||
}
|
||||
|
||||
if (! empty($data['from_serial_number'])) {
|
||||
$indicators[] = 'From Serial Number: '.$data['from_serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['to_serial_number'])) {
|
||||
$indicators[] = 'To Serial Number: '.$data['to_serial_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -30,7 +31,9 @@ class CreateProductionOrder extends CreateRecord
|
||||
|
||||
$tSerNo = trim($this->form->getState()['to_serial_number'] ?? '') ?? null;
|
||||
|
||||
$operatorName = Filament::auth()->user()?->name;
|
||||
$createdBy = trim($this->form->getState()['created_by'] ?? '') ?? Filament::auth()->user()?->name;
|
||||
|
||||
$updatedBy = trim($this->form->getState()['updated_by'] ?? '') ?? Filament::auth()->user()?->name;
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
@@ -88,9 +91,16 @@ class CreateProductionOrder extends CreateRecord
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($operatorName)) {
|
||||
} elseif (empty($createdBy)) {
|
||||
Notification::make()
|
||||
->title('Operator Name cannot be empty!')
|
||||
->title('Created By cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($updatedBy)) {
|
||||
Notification::make()
|
||||
->title('Updated By cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
@@ -116,7 +126,8 @@ class CreateProductionOrder extends CreateRecord
|
||||
'production_order' => $pOrder ?? null,
|
||||
'from_serial_number' => $fSerNo ?? null,
|
||||
'to_serial_number' => $tSerNo ?? null,
|
||||
'created_by' => $operatorName ?? null,
|
||||
'created_by' => $createdBy ?? null,
|
||||
'updated_by' => $updatedBy ?? null,
|
||||
]);
|
||||
|
||||
if ($insert) {
|
||||
@@ -135,6 +146,8 @@ class CreateProductionOrder extends CreateRecord
|
||||
'from_serial_number' => $fSerNo,
|
||||
'to_serial_number' => $tSerNo,
|
||||
'show_extra_fields' => true,
|
||||
'created_by' => $createdBy ?? null,
|
||||
'updated_by' => $updatedBy ?? null,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -153,6 +166,8 @@ class CreateProductionOrder extends CreateRecord
|
||||
'production_order' => null,
|
||||
'from_serial_number' => null,
|
||||
'to_serial_number' => null,
|
||||
'created_by' => $createdBy ?? null,
|
||||
'updated_by' => $updatedBy ?? null,
|
||||
]);
|
||||
|
||||
return;
|
||||
@@ -161,15 +176,31 @@ class CreateProductionOrder extends CreateRecord
|
||||
|
||||
public function printProductionOrder()
|
||||
{
|
||||
$pOrder = $this->form->getState()['production_order'];
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$pOrder = trim($pOrder) ?? null;
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$pOrderExists = ProductionOrder::where('production_order', $pOrder)->first();
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print")
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
@@ -179,6 +210,78 @@ class CreateProductionOrder extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
public function printItemSerial()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
}
|
||||
|
||||
public function printPanel()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [];
|
||||
|
||||
@@ -3,13 +3,160 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProductionOrder extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProductionOrderResource::class;
|
||||
|
||||
public function printProductionOrder()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.print', ['production_order' => $pOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
public function printPanel()
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'] ?? null;
|
||||
$plantId = filled($plantId) ? (int) $plantId : null;
|
||||
|
||||
$pOrder = $this->form->getState()['production_order'] ?? null;
|
||||
$pOrder = filled($pOrder) ? trim($pOrder) : null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public function printItemSerial()
|
||||
// {
|
||||
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||
// if (empty($plantId)) {
|
||||
// Notification::make()
|
||||
// ->title('Plant name cannot be empty!')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// } elseif (empty($pOrder)) {
|
||||
// Notification::make()
|
||||
// ->title('Production order cannot be empty!')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
// if (! $pOrderExists) {
|
||||
// Notification::make()
|
||||
// ->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// } else {
|
||||
// return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function printItemSerial()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -3,13 +3,162 @@
|
||||
namespace App\Filament\Resources\ProductionOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionOrderResource;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProductionOrder extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProductionOrderResource::class;
|
||||
|
||||
public function printProductionOrder()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.print', ['production_order' => $pOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
public function printPanel()
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'] ?? null;
|
||||
$plantId = filled($plantId) ? (int) $plantId : null;
|
||||
|
||||
$pOrder = $this->form->getState()['production_order'] ?? null;
|
||||
$pOrder = filled($pOrder) ? trim($pOrder) : null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printpanel', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public function printItemSerial()
|
||||
// {
|
||||
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
// if (empty($plantId)) {
|
||||
// Notification::make()
|
||||
// ->title('Plant name cannot be empty!')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// } elseif (empty($pOrder)) {
|
||||
// Notification::make()
|
||||
// ->title('Production order cannot be empty!')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
// if (! $pOrderExists) {
|
||||
// Notification::make()
|
||||
// ->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// } else {
|
||||
// return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function printItemSerial()
|
||||
{
|
||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if (empty($plantId)) {
|
||||
Notification::make()
|
||||
->title('Plant name cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
} elseif (empty($pOrder)) {
|
||||
Notification::make()
|
||||
->title('Production order cannot be empty!')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
||||
|
||||
if (! $pOrderExists) {
|
||||
Notification::make()
|
||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
} else {
|
||||
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@ class CreateQualityValidation extends CreateRecord
|
||||
'checklistUpdated' => 'setChecklist',
|
||||
'checklist-cancelled' => 'handleChecklistCancel',
|
||||
'checklist-saved' => 'checkListSaved',
|
||||
'trigger-create' => 'doCreate',
|
||||
// 'trigger-create' => 'doCreate',
|
||||
];
|
||||
|
||||
public function setChecklist($checklist)
|
||||
@@ -89,13 +89,15 @@ class CreateQualityValidation extends CreateRecord
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$categoryName = trim($item->category) ?? null;
|
||||
|
||||
if (!$item) {
|
||||
$this->existingRecords = collect();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $item->id)
|
||||
->where('category', $categoryName)
|
||||
->where('line_id', $lineId)
|
||||
->get();
|
||||
}
|
||||
@@ -201,6 +203,7 @@ class CreateQualityValidation extends CreateRecord
|
||||
$checklist = $this->data['data']['checklist'] ?? [];
|
||||
|
||||
if (count($this->existingRecords) > 0){
|
||||
|
||||
$this->showChecklist = true;
|
||||
$this->halt();
|
||||
}
|
||||
@@ -223,10 +226,11 @@ class CreateQualityValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$item_id = $item->id;
|
||||
// $item_id = $item->id;
|
||||
$categoryName = trim($item->category) ?? null;
|
||||
|
||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plant_id)
|
||||
->where('item_id', $item_id)
|
||||
->where('category', $categoryName)
|
||||
->where('line_id', $line_id)
|
||||
->get();
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\RequestCharacteristicExporter;
|
||||
use App\Filament\Imports\RequestCharacteristicImporter;
|
||||
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use App\Models\StickerMaster;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
@@ -19,6 +21,7 @@ use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
@@ -27,6 +30,7 @@ use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -128,6 +132,16 @@ class RequestCharacteristicResource extends Resource
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\Hidden::make('show_validation_image')
|
||||
->reactive()
|
||||
->default(false),
|
||||
Forms\Components\Hidden::make('validation1_image_url')
|
||||
->reactive(),
|
||||
|
||||
Forms\Components\View::make('components.part-validation-error-icon')
|
||||
->statePath('validation1_image_url')
|
||||
->visible(fn ($get) => $get('show_validation_image') == true)
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->readOnly()
|
||||
@@ -139,7 +153,42 @@ class RequestCharacteristicResource extends Resource
|
||||
return self::isNewWorkFlow($get);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
})
|
||||
->suffixAction(
|
||||
Forms\Components\Actions\Action::make('toggleValidationImage')
|
||||
->icon(fn (callable $get) => $get('show_validation_image') ? 'heroicon-o-eye-slash' : 'heroicon-o-eye')
|
||||
->tooltip('View Validation Image')
|
||||
->action(function (callable $get, $set) {
|
||||
|
||||
$currentState = $get('show_validation_image');
|
||||
$set('show_validation_image', ! $currentState);
|
||||
|
||||
if ($currentState == true) {
|
||||
$set('validation1_image_url', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$workFlowId = $get('work_flow_id');
|
||||
|
||||
if (!$workFlowId) {
|
||||
Notification::make()
|
||||
->title('Missing Workflow ID')
|
||||
->body('Please select a Workflow ID.')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// Build filename
|
||||
$fileName = "{$workFlowId}.png";
|
||||
|
||||
$imageUrl = route('workflow.image', [
|
||||
'filename' => $fileName,
|
||||
]);
|
||||
|
||||
$set('validation1_image_url', $imageUrl);
|
||||
})
|
||||
),
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('request_characteristics', 'work_flow_id')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
@@ -312,7 +361,7 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\Select::make('characteristic_approver_master_id')
|
||||
->label('Master Characteristic Field')
|
||||
// ->relationship('characteristicApproverMaster', 'characteristic_field')
|
||||
->columnSpan(2)
|
||||
// ->columnSpan(2)
|
||||
->reactive()
|
||||
->nullable()
|
||||
->searchable()
|
||||
@@ -340,6 +389,17 @@ class RequestCharacteristicResource extends Resource
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('model_type')
|
||||
->label('Model Type')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('characteristic_name', null);
|
||||
$set('current_value', null);
|
||||
$set('update_value', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
// ->disabled(fn ($get) => self::isFieldDisabled($get))
|
||||
Section::make('Request Characteristic Details')
|
||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||
@@ -500,6 +560,7 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('approver_remark1')
|
||||
->label('Approver Remark')
|
||||
->live()
|
||||
->maxLength(60)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$appStat = $get('approver_status1');
|
||||
if ($appStat && $state) {
|
||||
@@ -615,6 +676,7 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('approver_remark2')
|
||||
->label('Approver Remark')
|
||||
->live()
|
||||
->maxLength(60)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$appStat = $get('approver_status2');
|
||||
if ($appStat && $state) {
|
||||
@@ -727,6 +789,7 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('approver_remark3')
|
||||
->label('Approver Remark')
|
||||
->live()
|
||||
->maxLength(60)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$appStat = $get('approver_status3');
|
||||
if ($appStat && $state) {
|
||||
@@ -916,6 +979,11 @@ class RequestCharacteristicResource extends Resource
|
||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||
->extraAttributes(['class' => 'uppercase'])
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('model_type')
|
||||
->label('Model Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_name')
|
||||
->label('Characteristic Name')
|
||||
->default('-')
|
||||
@@ -956,12 +1024,14 @@ class RequestCharacteristicResource extends Resource
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->default('-')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_remark1')
|
||||
->label('Approver Remark 1')
|
||||
// ->color('success')
|
||||
->alignCenter()
|
||||
->default('-')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved1_at')
|
||||
@@ -984,12 +1054,14 @@ class RequestCharacteristicResource extends Resource
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->default('-')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_remark2')
|
||||
->label('Approver Remark 2')
|
||||
// ->color('success')
|
||||
->alignCenter()
|
||||
->default('-')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved2_at')
|
||||
@@ -1012,12 +1084,14 @@ class RequestCharacteristicResource extends Resource
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->default('-')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approver_remark3')
|
||||
->label('Approver Remark 3')
|
||||
// ->color('success')
|
||||
->alignCenter()
|
||||
->default('-')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('approved3_at')
|
||||
@@ -1160,6 +1234,67 @@ class RequestCharacteristicResource extends Resource
|
||||
->numeric()
|
||||
->minlength(7)
|
||||
->maxlength(10),
|
||||
TextInput::make('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->placeholder('Enter Work Flow ID'),
|
||||
TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->placeholder('Enter Machine Name'),
|
||||
Select::make('request_type')
|
||||
->label('Request Type')
|
||||
->options([
|
||||
'Characteristic' => 'Characteristic',
|
||||
'Quality' => 'Quality',
|
||||
])
|
||||
->placeholder('Select Request Type'),
|
||||
TextInput::make('master_characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->placeholder('Enter Master Characteristic Field'),
|
||||
TextInput::make('model_type')
|
||||
->label('Model Type')
|
||||
->placeholder('Enter Model Type'),
|
||||
Select::make('approver_status')
|
||||
->label('Approver Status')
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->placeholder('Select Status')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('approver_status1', null);
|
||||
$set('approver_status2', null);
|
||||
$set('approver_status3', null);
|
||||
}),
|
||||
Select::make('approver_status1')
|
||||
->label('Approver Status 1')
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->placeholder('Select Status')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('approver_status2', null);
|
||||
$set('approver_status3', null);
|
||||
}),
|
||||
Select::make('approver_status2')
|
||||
->label('Approver Status 2')
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->placeholder('Select Status'),
|
||||
Select::make('approver_status3')
|
||||
->label('Approver Status 3')
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
'Rejected' => 'Rejected',
|
||||
])
|
||||
->placeholder('Select Status'),
|
||||
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
@@ -1173,7 +1308,7 @@ class RequestCharacteristicResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['model_type']) && empty($data['work_flow_id']) && empty($data['machine_name']) && empty($data['request_type']) && empty($data['master_characteristic_field'])&& empty($data['approver_status1']) && empty($data['approver_status2']) && empty($data['approver_status3']) && empty($data['approver_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -1199,6 +1334,70 @@ class RequestCharacteristicResource extends Resource
|
||||
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$query->where('model_type', 'like', '%'.$data['model_type'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['work_flow_id'])) {
|
||||
$query->where('work_flow_id', 'like', '%'.$data['work_flow_id'].'%');
|
||||
}
|
||||
|
||||
if (!empty($data['machine_name'])) {
|
||||
$query->whereHas('characteristicApproverMaster', function ($q) use ($data) {
|
||||
$q->where('characteristic_approver_masters.machine_name', '=', (string) $data['machine_name']);
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($data['request_type'])) {
|
||||
$query->whereHas('characteristicApproverMaster', function ($q) use ($data) {
|
||||
$q->where('characteristic_approver_masters.approver_type', '=', (string) $data['request_type']);
|
||||
});
|
||||
}
|
||||
|
||||
if (!empty($data['master_characteristic_field'])) {
|
||||
$query->whereHas('characteristicApproverMaster', function ($q) use ($data) {
|
||||
$q->where('characteristic_approver_masters.characteristic_field', '=', (string) $data['master_characteristic_field']);
|
||||
});
|
||||
}
|
||||
|
||||
if (! empty($data['approver_status1'])) {
|
||||
$query->where('approver_status1', 'like', '%'.$data['approver_status1'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['approver_status2'])) {
|
||||
$query->where('approver_status2', 'like', '%'.$data['approver_status2'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['approver_status3'])) {
|
||||
$query->where('approver_status3', 'like', '%'.$data['approver_status3'].'%');
|
||||
}
|
||||
|
||||
if (!empty($data['approver_status'])) {
|
||||
|
||||
$status = $data['approver_status'];
|
||||
|
||||
$query->whereRaw("
|
||||
CASE
|
||||
|
||||
-- If status3 exists, it must be considered first
|
||||
WHEN approver_status3 IS NOT NULL AND approver_status3 != ''
|
||||
THEN approver_status3
|
||||
|
||||
-- then status2 overrides only if status3 is empty
|
||||
WHEN approver_status2 IS NOT NULL AND approver_status2 != ''
|
||||
THEN approver_status2
|
||||
|
||||
-- finally status1 only if both 2 and 3 are empty
|
||||
WHEN approver_status1 IS NOT NULL AND approver_status1 != ''
|
||||
THEN approver_status1
|
||||
|
||||
ELSE NULL
|
||||
|
||||
END = ?
|
||||
", [$status]);
|
||||
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
@@ -1232,6 +1431,42 @@ class RequestCharacteristicResource extends Resource
|
||||
$indicators[] = 'Job No: '.$data['aufnr'];
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$indicators[] = 'Model Type: '.$data['model_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['work_flow_id'])) {
|
||||
$indicators[] = 'Work Flow ID: '.$data['work_flow_id'];
|
||||
}
|
||||
|
||||
if (! empty($data['machine_name'])) {
|
||||
$indicators[] = 'Machine Name: '.$data['machine_name'];
|
||||
}
|
||||
|
||||
if (! empty($data['request_type'])) {
|
||||
$indicators[] = 'Request Type: '.$data['request_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['master_characteristic_field'])) {
|
||||
$indicators[] = 'Master Characteristic Field: '.$data['master_characteristic_field'];
|
||||
}
|
||||
|
||||
if (! empty($data['approver_status'])) {
|
||||
$indicators[] = 'Approver Status: '.$data['approver_status'];
|
||||
}
|
||||
|
||||
if (! empty($data['approver_status1'])) {
|
||||
$indicators[] = 'Approver Status 1: '.$data['approver_status1'];
|
||||
}
|
||||
|
||||
if (! empty($data['approver_status2'])) {
|
||||
$indicators[] = 'Approver Status 2: '.$data['approver_status2'];
|
||||
}
|
||||
|
||||
if (! empty($data['approver_status3'])) {
|
||||
$indicators[] = 'Approver Status 3: '.$data['approver_status3'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
@@ -1256,13 +1491,13 @@ class RequestCharacteristicResource extends Resource
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
// ImportAction::make()
|
||||
// ->label('Import Request Characteristics')
|
||||
// ->color('warning')
|
||||
// ->importer(RequestCharacteristicImporter::class)
|
||||
// ->visible(function () {
|
||||
// return Filament::auth()->user()->can('view import request characteristic');
|
||||
// }),
|
||||
ImportAction::make()
|
||||
->label('Import Request Characteristics')
|
||||
->color('warning')
|
||||
->importer(RequestCharacteristicImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import request characteristic');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Request Characteristics')
|
||||
->color('warning')
|
||||
|
||||
@@ -296,9 +296,10 @@ class StickerMasterResource extends Resource
|
||||
Forms\Components\Select::make('material_type')
|
||||
->label('Material Type')
|
||||
->options([
|
||||
'1' => 'Individual',
|
||||
'2' => 'Bundle',
|
||||
'3' => 'Quantity',
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
4 => 'Bundle Individual',
|
||||
])
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
@@ -307,7 +308,7 @@ class StickerMasterResource extends Resource
|
||||
$set('load_rate', 0);
|
||||
}
|
||||
|
||||
if ($state !== '2') {
|
||||
if ($state != '2' && $state != '4') {
|
||||
$set('bundle_quantity', null);
|
||||
} else {
|
||||
$set('bundle_quantity', 2);
|
||||
@@ -319,12 +320,12 @@ class StickerMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('bundle_quantity')
|
||||
->label('Bundle Quantity')
|
||||
->integer()
|
||||
->readOnly(fn (callable $get) => $get('material_type') !== '2')
|
||||
->readOnly(fn (callable $get) => $get('material_type') != 2 && $get('material_type') != 4)
|
||||
->nullable()
|
||||
->minValue(2)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if ($get('material_type') !== '2') {
|
||||
if ($get('material_type') != 2 && $get('material_type') != 4) {
|
||||
$set('bundle_quantity', null);
|
||||
} elseif ($get('bundle_quantity') < 2) {
|
||||
$set('bundle_quantity', 2);
|
||||
@@ -655,10 +656,6 @@ class StickerMasterResource extends Resource
|
||||
->label('Load Rate')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('bundle_quantity')
|
||||
->label('Bundle Quantity')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('material_type')
|
||||
->label('Material Type')
|
||||
->default('-')
|
||||
@@ -672,9 +669,14 @@ class StickerMasterResource extends Resource
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
4 => 'Bundle Individual',
|
||||
default => '-',
|
||||
};
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('bundle_quantity')
|
||||
->label('Bundle Quantity')
|
||||
->default('-')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
@@ -754,12 +756,13 @@ class StickerMasterResource extends Resource
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('material_type')
|
||||
->label('Select Material Type')
|
||||
->label('Search by Material Type')
|
||||
->nullable()
|
||||
->options([
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
4 => 'Bundle Individual',
|
||||
])
|
||||
->searchable()
|
||||
->reactive(),
|
||||
@@ -870,6 +873,8 @@ class StickerMasterResource extends Resource
|
||||
$indicators[] = 'Material Type: Bundle';
|
||||
} elseif ($data['material_type'] == 3) {
|
||||
$indicators[] = 'Material Type: Quantity';
|
||||
} elseif ($data['material_type'] == 4) {
|
||||
$indicators[] = 'Material Type: Bundle Individual';
|
||||
}
|
||||
// $indicators[] = 'Material Type: '.$data['material_type'];
|
||||
}
|
||||
|
||||
@@ -5,28 +5,27 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\TempClassCharacteristicExporter;
|
||||
use App\Filament\Imports\TempClassCharacteristicImporter;
|
||||
use App\Filament\Resources\TempClassCharacteristicResource\Pages;
|
||||
use App\Filament\Resources\TempClassCharacteristicResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\TempClassCharacteristic;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Get;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class TempClassCharacteristicResource extends Resource
|
||||
{
|
||||
@@ -968,6 +967,12 @@ class TempClassCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER')
|
||||
->reactive()
|
||||
@@ -1029,6 +1034,10 @@ class TempClassCharacteristicResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('model_type')
|
||||
->label('MODEL TYPE')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('aufnr')
|
||||
->label('AUFNR')
|
||||
->alignCenter()
|
||||
@@ -1055,10 +1064,6 @@ class TempClassCharacteristicResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('model_type')
|
||||
->label('MODEL TYPE')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zz1_cn_bill_ord')
|
||||
->label('ZZ1 CN BILL ORD')
|
||||
->alignCenter()
|
||||
@@ -1181,6 +1186,7 @@ class TempClassCharacteristicResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zmm_ratedpower')
|
||||
->label('ZMM RATEDPOWER')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zmm_region')
|
||||
->label('ZMM REGION')
|
||||
@@ -1574,17 +1580,19 @@ class TempClassCharacteristicResource extends Resource
|
||||
->label('ZQMM QTY')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('zmm_operating_temperature')
|
||||
->label('ZMM OPERATING TEMPERATURE')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation_1')
|
||||
->label('PART VALIDATION 1')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_validation_2')
|
||||
->label('PART VALIDATION 2')
|
||||
Tables\Columns\TextColumn::make('model_type')
|
||||
->label('MODEL TYPE')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('has_work_flow_id')
|
||||
->label('HAS WORK FLOW ID')
|
||||
@@ -1599,14 +1607,28 @@ class TempClassCharacteristicResource extends Resource
|
||||
};
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('CREATED AT')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('CREATED BY')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('UPDATED AT')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('UPDATED BY')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
@@ -1690,6 +1712,12 @@ class TempClassCharacteristicResource extends Resource
|
||||
TextInput::make('gernr')
|
||||
->label('Serial Number')
|
||||
->placeholder('Enter Serial Number'),
|
||||
TextInput::make('zmm_heading')
|
||||
->label('Heading')
|
||||
->placeholder('Enter Heading'),
|
||||
TextInput::make('model_type')
|
||||
->label('Model Type')
|
||||
->placeholder('Enter Model Type'),
|
||||
Select::make('work_flow_status')
|
||||
->label('Work Flow Status')
|
||||
->placeholder('Select Work Flow Status')
|
||||
@@ -1711,7 +1739,7 @@ class TempClassCharacteristicResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['created_from']) && empty($data['created_to']) && !array_key_exists('work_flow_status', $data)) {
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['zmm_heading']) && empty($data['model_type']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -1741,6 +1769,14 @@ class TempClassCharacteristicResource extends Resource
|
||||
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['zmm_heading'])) {
|
||||
$query->where('zmm_heading', 'like', '%'.$data['zmm_heading'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$query->where('model_type', 'like', '%'.$data['model_type'].'%');
|
||||
}
|
||||
|
||||
if (array_key_exists('work_flow_status', $data) && $data['work_flow_status'] != '') {
|
||||
$query->where('has_work_flow_id', $data['work_flow_status']);
|
||||
}
|
||||
@@ -1782,6 +1818,14 @@ class TempClassCharacteristicResource extends Resource
|
||||
$indicators[] = 'Serial Number: '.$data['gernr'];
|
||||
}
|
||||
|
||||
if (! empty($data['zmm_heading'])) {
|
||||
$indicators[] = 'Heading: '.$data['zmm_heading'];
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$indicators[] = 'Model Type: '.$data['model_type'];
|
||||
}
|
||||
|
||||
if (array_key_exists('work_flow_status', $data) && $data['work_flow_status'] != '') {
|
||||
$statusMap = [
|
||||
'1' => 'Pending Approval',
|
||||
@@ -1789,7 +1833,7 @@ class TempClassCharacteristicResource extends Resource
|
||||
'0' => 'Approved',
|
||||
];
|
||||
|
||||
$indicators[] = 'Work Flow Status: ' . ($statusMap[$data['work_flow_status']] ?? '');
|
||||
$indicators[] = 'Work Flow Status: '.($statusMap[$data['work_flow_status']] ?? '');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
|
||||
@@ -49,7 +49,7 @@ class TestingPanelReadingResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -438,7 +438,7 @@ class TestingPanelReadingResource extends Resource
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.subassembly_code')
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.description')
|
||||
@@ -630,7 +630,7 @@ class TestingPanelReadingResource extends Resource
|
||||
->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
@@ -639,7 +639,7 @@ class TestingPanelReadingResource extends Resource
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
//return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
@@ -732,7 +732,7 @@ class TestingPanelReadingResource extends Resource
|
||||
// ->pluck('description', 'id')
|
||||
// ->toArray();
|
||||
}
|
||||
//return $query->pluck('description', 'description')->toArray();
|
||||
// return $query->pluck('description', 'description')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
@@ -969,8 +969,8 @@ class TestingPanelReadingResource extends Resource
|
||||
// if (!empty($data['phase'])) {
|
||||
// $indicators[] = 'Phase: ' . $data['phase'];
|
||||
// }
|
||||
if (!empty($data['connection'])) {
|
||||
$indicators[] = 'Connection: ' . $data['connection'];
|
||||
if (! empty($data['connection'])) {
|
||||
$indicators[] = 'Connection: '.$data['connection'];
|
||||
}
|
||||
if (! empty($data['remark'])) {
|
||||
$indicators[] = 'Remark: '.$data['remark'];
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
@@ -33,8 +34,10 @@ class UserResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
@@ -45,19 +48,25 @@ class UserResource extends Resource
|
||||
return optional(User::latest()->first())->plant_id;
|
||||
}),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->autofocus()
|
||||
->minLength(3)
|
||||
// ->reactive()
|
||||
->live(debounce: 600)
|
||||
->disabled(fn (Get $get) => ! empty($get('id')) && Filament::auth()->user()?->name != 'Admin' && Filament::auth()->user()?->name != 'Dhanabalan S' && Filament::auth()->user()?->name != 'Ranjith B' && ($get('name') == 'Admin' || $get('name') == 'Dhanabalan S' || $get('name') == 'Ranjith B'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('email', $state.'@cripumps.com');
|
||||
if (Filament::auth()->user()?->name != 'Dhanabalan S') {
|
||||
$set('email', $state.'@cripumps.com');
|
||||
}
|
||||
})
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('email')
|
||||
->label('Email')
|
||||
->required()
|
||||
// ->email()
|
||||
->unique(ignoreRecord: true)
|
||||
->required()
|
||||
->readOnly()
|
||||
->readOnly(fn () => Filament::auth()->user()?->name != 'Dhanabalan S')
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('users', 'email')
|
||||
// ->ignore($get('id')); // Ignore current record during updates
|
||||
@@ -66,17 +75,22 @@ class UserResource extends Resource
|
||||
// ->prefix(fn ($get) => $get('name') ?? null)
|
||||
// ->suffix('@cripumps.com')
|
||||
->maxLength(255),
|
||||
Forms\Components\DateTimePicker::make('email_verified_at'),
|
||||
Forms\Components\DateTimePicker::make('email_verified_at')
|
||||
->label('Email Verified At'),
|
||||
Forms\Components\TextInput::make('password')
|
||||
->password()
|
||||
->revealable()
|
||||
->label('Password')
|
||||
->required()
|
||||
->password()
|
||||
->minLength(3)
|
||||
->revealable()
|
||||
->disabled(fn (Get $get) => ! empty($get('id')) && Filament::auth()->user()?->name != 'Admin' && Filament::auth()->user()?->name != 'Dhanabalan S' && Filament::auth()->user()?->name != 'Ranjith B' && ($get('name') == 'Admin' || $get('name') == 'Dhanabalan S' || $get('name') == 'Ranjith B'))
|
||||
// ->dehydrateStateUsing(fn (string $state): string => Hash::make($state))
|
||||
->maxLength(255),
|
||||
// Forms\Components\Select::make('roles')
|
||||
// ->multiple()
|
||||
// ->relationship('roles', 'name'),
|
||||
Forms\Components\Select::make('roles')
|
||||
->label('Roles')
|
||||
->relationship('roles', 'name')
|
||||
// ->relationship(name: 'roles', titleAttribute: 'name')
|
||||
// ->saveRelationshipsUsing(function (Model $record, $state) {
|
||||
@@ -110,7 +124,8 @@ class UserResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->label('Plant Name')
|
||||
->default('All')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -144,8 +159,7 @@ class UserResource extends Resource
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\VehicleEntryExporter;
|
||||
use App\Filament\Imports\VehicleEntryImporter;
|
||||
use App\Filament\Resources\VehicleEntryResource\Pages;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\VehicleEntry;
|
||||
use Carbon\Carbon;
|
||||
@@ -14,6 +17,12 @@ use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
|
||||
class VehicleEntryResource extends Resource
|
||||
{
|
||||
@@ -37,9 +46,15 @@ class VehicleEntryResource extends Resource
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('uuid')
|
||||
->label('Uuid')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('boom_opened')
|
||||
->label('Boom Opened')
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('entry_time')
|
||||
->label('Entry Time')
|
||||
->required()
|
||||
@@ -102,10 +117,21 @@ class VehicleEntryResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
// Tables\Columns\TextColumn::make('uuid')
|
||||
// ->label('UUID')
|
||||
// ->alignCenter()
|
||||
// ->sortable()
|
||||
// ->searchable(),
|
||||
Tables\Columns\TextColumn::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => strtoupper($state)),
|
||||
Tables\Columns\TextColumn::make('boom_opened')
|
||||
->label('Boom Opened')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('entry_time')
|
||||
->label('Entry Time')
|
||||
@@ -133,12 +159,22 @@ class VehicleEntryResource extends Resource
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
@@ -148,7 +184,106 @@ class VehicleEntryResource extends Resource
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('vehicleEntries', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('vehicle_number', null);
|
||||
}),
|
||||
TextInput::make('vehicle_number')
|
||||
->label('Vehicle Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Vehicle Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
DateTimePicker::make('created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['vehicle_number']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['vehicle_number'])) {
|
||||
$query->where('vehicle_number', 'like', '%'.$data['vehicle_number'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
// $query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant Name: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['vehicle_number'])) {
|
||||
$indicators[] = 'Vehicle Number: '.$data['vehicle_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
@@ -159,6 +294,18 @@ class VehicleEntryResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(VehicleEntryImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import vehicle entry');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(VehicleEntryExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export vehicle entry');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
592
app/Filament/Resources/VisitorEntryResource.php
Normal file
592
app/Filament/Resources/VisitorEntryResource.php
Normal file
@@ -0,0 +1,592 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\VisitorEntryExporter;
|
||||
use App\Filament\Imports\VisitorEntryImporter;
|
||||
use App\Filament\Resources\VisitorEntryResource\Pages;
|
||||
use App\Filament\Resources\VisitorEntryResource\RelationManagers;
|
||||
use App\Models\VisitorEntry;
|
||||
use App\Models\EmployeeMaster;
|
||||
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 Filament\Infolists\Infolist;
|
||||
use Filament\Infolists\Components\ImageEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Infolists\Components\Section;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
class VisitorEntryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = VisitorEntry::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Gate Entry';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('register_id')
|
||||
->label('Register ID')
|
||||
->default(function () {
|
||||
|
||||
$datePart = Carbon::now()->format('ymd'); // 260527
|
||||
|
||||
$prefix = 'CRI' . $datePart . 'V';
|
||||
|
||||
// Get latest record for today
|
||||
$lastRecord = VisitorEntry::where('register_id', 'like', $prefix . '%')
|
||||
->latest('id')
|
||||
->first();
|
||||
|
||||
if ($lastRecord) {
|
||||
$lastNumber = (int) substr($lastRecord->register_id, -3);
|
||||
$nextNumber = str_pad($lastNumber + 1, 3, '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$nextNumber = '001';
|
||||
}
|
||||
|
||||
return $prefix . $nextNumber;
|
||||
})
|
||||
->readOnly(),
|
||||
Forms\Components\TextInput::make('mobile_number')
|
||||
->label('Mobile Number')
|
||||
->length(10)
|
||||
->reactive()
|
||||
->extraInputAttributes([
|
||||
'oninput' => 'this.value = this.value.replace(/[^0-9]/g, "").slice(0, 10)', // blocks non-numbers + limits to 10 chars
|
||||
'maxlength' => 10,
|
||||
])
|
||||
->required()
|
||||
->extraAttributes([
|
||||
'id' => 'mobile_number_input',
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'wire:keydown.enter.prevent' => 'processMobile(value)',
|
||||
]),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->reactive()
|
||||
->extraInputAttributes([
|
||||
'oninput' => 'this.value = this.value.replace(/[^a-zA-Z\s]/g, "")',
|
||||
]),
|
||||
Forms\Components\Select::make('type')
|
||||
->label('Type')
|
||||
->reactive()
|
||||
->options([
|
||||
'Student' => 'Student',
|
||||
'Consultant' => 'Consultant',
|
||||
'Supplier' => 'Supplier',
|
||||
'InterviewCandidates' => 'Interview Candidates',
|
||||
'Customers/Dealers' => 'Customers/Dealers',
|
||||
'Bankers' => 'Bankers',
|
||||
'ServiceProviders' => 'Service Providers',
|
||||
'GovermentOfficials' => 'Government Officials',
|
||||
'Other' => 'Other',
|
||||
])
|
||||
->required()
|
||||
->dehydrateStateUsing(function ($state, callable $get) {
|
||||
return $state == 'Other'
|
||||
? $get('other_type')
|
||||
: $state;
|
||||
}),
|
||||
Forms\Components\TextInput::make('other_type')
|
||||
->label('Specify Type')
|
||||
->reactive()
|
||||
->visible(fn (callable $get) => $get('type') == 'Other')
|
||||
->required(fn (callable $get) => $get('type') == 'Other')
|
||||
->dehydrated(false),
|
||||
Forms\Components\TextInput::make('company')
|
||||
->label('Company')
|
||||
->required(),
|
||||
Forms\Components\Select::make('department')
|
||||
->label('Employee Department')
|
||||
->options(
|
||||
EmployeeMaster::distinct()
|
||||
->pluck('department', 'department')
|
||||
)
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('employee_master_id', null);
|
||||
$set('code', null);
|
||||
}),
|
||||
// Forms\Components\Select::make('employee_master_id')
|
||||
// ->label('Recipient Employee')
|
||||
// ->required()
|
||||
// ->options(function (callable $get) {
|
||||
// $department = $get('department');
|
||||
|
||||
// if (!$department) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// return \App\Models\EmployeeMaster::where('department', $department)
|
||||
// ->pluck('name', 'id');
|
||||
// })
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $department = $get('department');
|
||||
|
||||
// $employee = \App\Models\EmployeeMaster::where('id', $state)
|
||||
// ->where('department', $department)
|
||||
// ->first();
|
||||
|
||||
// $set('code', $employee ? $employee->code : '');
|
||||
// }),
|
||||
|
||||
Forms\Components\Select::make('employee_master_id')
|
||||
->label('Recipient Employee')
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$department = $get('department');
|
||||
// Always load ALL employees, filter by department if set
|
||||
if ($department) {
|
||||
return EmployeeMaster::where('department', $department)
|
||||
->pluck('name', 'id');
|
||||
}
|
||||
// Fallback: load all so fill() can always match the ID
|
||||
return EmployeeMaster::pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, ?string $state) {
|
||||
$employee = EmployeeMaster::find($state);
|
||||
$set('code', $employee?->code ?? '');
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('code')
|
||||
->label('Employee Code')
|
||||
->readOnly(),
|
||||
Forms\Components\Textarea::make('purpose_of_visit')
|
||||
->label('Purpose of Visit')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('number_of_person')
|
||||
->numeric()
|
||||
->default(1)
|
||||
->required(),
|
||||
Forms\Components\DateTimePicker::make('in_time')
|
||||
->label('In Time')
|
||||
->required()
|
||||
->default(now()),
|
||||
Forms\Components\DateTimePicker::make('out_time')
|
||||
->label('Out Time'),
|
||||
Forms\Components\DateTimePicker::make('valid_upto')
|
||||
->label('Valid Upto')
|
||||
->after('in_time')
|
||||
->validationMessages([
|
||||
'after' => 'Valid Upto must be after the In Time.',
|
||||
]),
|
||||
Forms\Components\View::make('components.webcam-field')
|
||||
->columnSpanFull(),
|
||||
Forms\Components\Hidden::make('photo'),
|
||||
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')
|
||||
->alignCenter()
|
||||
->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\ImageColumn::make('photo')
|
||||
->label('Photo')
|
||||
->disk('public')
|
||||
->height(50)
|
||||
->width(50)
|
||||
// ->defaultImageUrl('https://ui-avatars.com/api/?name=Visitor&background=555&color=fff')
|
||||
->defaultImageUrl(asset('images/profile.png'))
|
||||
->alignCenter()
|
||||
->extraImgAttributes(['style' => 'border-radius: 6px; object-fit: cover;']),
|
||||
Tables\Columns\TextColumn::make('register_id')
|
||||
->label('Register ID')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label('Visitor Type')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Visitor Name')
|
||||
->sortable()
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('mobile_number')
|
||||
->label('Visitor Mobile Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('employeeMaster.name')
|
||||
->label('Recipient Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('employeeMaster.code')
|
||||
->label('Receipient ID')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('employeeMaster.department')
|
||||
->label('Receipient Department')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('number_of_person')
|
||||
->label('Number of Person')
|
||||
->numeric()
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('in_time')
|
||||
->label('In Time')
|
||||
->searchable()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('out_time')
|
||||
->label('Out Time')
|
||||
->searchable()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('valid_upto')
|
||||
->label('Valid Upto')
|
||||
->searchable()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->alignCenter()
|
||||
->color(fn ($record) => $record->valid_upto && \Carbon\Carbon::parse($record->valid_upto)->isPast()
|
||||
? 'danger'
|
||||
: 'success'
|
||||
),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true)
|
||||
->alignCenter(),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
TextInput::make('register_id')
|
||||
->label('Register ID')
|
||||
->reactive()
|
||||
->placeholder('Enter Register ID')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
Select::make('type')
|
||||
->label('Type')
|
||||
->reactive()
|
||||
->options([
|
||||
'Student' => 'Student',
|
||||
'Consultant' => 'Consultant',
|
||||
'Supplier' => 'Supplier',
|
||||
'InterviewCandidates' => 'Interview Candidates',
|
||||
'Customers/Dealers' => 'Customers/Dealers',
|
||||
'Bankers' => 'Bankers',
|
||||
'ServiceProviders' => 'Service Providers',
|
||||
'GovermentOfficials' => 'Government Officials',
|
||||
'Other' => 'Other',
|
||||
])
|
||||
->placeholder('Choose Type')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('name', null);
|
||||
}),
|
||||
TextInput::make('other_type')
|
||||
->label('Specify Type')
|
||||
->placeholder('Enter Type')
|
||||
->visible(fn (callable $get) => $get('type') == 'Other')
|
||||
->required(fn (callable $get) => $get('type') == 'Other'),
|
||||
TextInput::make('name')
|
||||
->label('Visitor Name')
|
||||
->reactive()
|
||||
->placeholder('Enter Visitor Name')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('company', null);
|
||||
}),
|
||||
TextInput::make('company')
|
||||
->label('Visitor Company')
|
||||
->reactive()
|
||||
->placeholder('Enter Visitor Company')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
Select::make('employee_master_id')
|
||||
->label('Employee Name')
|
||||
->relationship('employeeMaster', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->reactive()
|
||||
->placeholder('Select Employee')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
DateTimePicker::make('created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['register_id']) && empty($data['type']) && empty($data['name']) && empty($data['company']) && empty($data['employee_master_id']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
$query->where(function ($q) {
|
||||
});
|
||||
}
|
||||
|
||||
if (! empty($data['register_id'])) {
|
||||
$query->where('register_id', $data['register_id']);
|
||||
}
|
||||
|
||||
if (! empty($data['type'])) {
|
||||
if ($data['type'] == 'Other') {
|
||||
$query->where('type', 'like', '%'.$data['other_type'].'%');
|
||||
}
|
||||
else{
|
||||
$query->where('type', $data['type']);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$query->where('name', 'like', '%'.$data['name'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['company'])) {
|
||||
$query->where('company', 'like', '%'.$data['company'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['employee_master_id'])) {
|
||||
$query->where('employee_master_id', $data['employee_master_id']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
// $query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['register_id'])) {
|
||||
$indicators[] = 'Register ID: '.$data['register_id'];
|
||||
}
|
||||
|
||||
if (! empty($data['type'])) {
|
||||
$indicators[] = 'Type: '.$data['type'];
|
||||
}
|
||||
|
||||
if (! empty($data['other_type'])) {
|
||||
$indicators[] = 'Specify Type: '.$data['other_type'];
|
||||
}
|
||||
|
||||
if (! empty($data['name'])) {
|
||||
$indicators[] = 'Name: '.$data['name'];
|
||||
}
|
||||
|
||||
if (! empty($data['company'])) {
|
||||
$indicators[] = 'Company: '.$data['company'];
|
||||
}
|
||||
|
||||
if (! empty($data['employee_master_id'])) {
|
||||
$indicators[] = 'Employee Name: '.EmployeeMaster::where('id', $data['employee_master_id'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->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(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(VisitorEntryImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import visitor entries');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(VisitorEntryExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export visitor entries');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function infolist(Infolist $infolist): Infolist
|
||||
{
|
||||
return $infolist
|
||||
->schema([
|
||||
|
||||
// ── Visitor Photo (full width at the top) ──
|
||||
Section::make('Visitor Photo')
|
||||
->schema([
|
||||
ImageEntry::make('photo')
|
||||
->label('')
|
||||
->disk('public')
|
||||
->height(220)
|
||||
->defaultImageUrl(asset('images/profile.png'))
|
||||
->extraImgAttributes([
|
||||
'style' => 'border-radius: 10px; object-fit: cover;'
|
||||
]),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
|
||||
// ── Visitor Details ──
|
||||
Section::make('Visitor Details')
|
||||
->schema([
|
||||
TextEntry::make('register_id')
|
||||
->label('Register ID'),
|
||||
TextEntry::make('name')
|
||||
->label('Visitor Name'),
|
||||
TextEntry::make('mobile_number')
|
||||
->label('Mobile Number'),
|
||||
TextEntry::make('type')
|
||||
->label('Visitor Type')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'internal' => 'success',
|
||||
'external' => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('company')
|
||||
->label('Company'),
|
||||
TextEntry::make('purpose_of_visit')
|
||||
->label('Purpose of Visit')
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
// ── Employee Details ──
|
||||
Section::make('Recipient Details')
|
||||
->schema([
|
||||
TextEntry::make('employeeMaster.name')
|
||||
->label('Recipient Employee'),
|
||||
TextEntry::make('code')
|
||||
->label('Employee Code'),
|
||||
TextEntry::make('employeeMaster.department')
|
||||
->label('Department'),
|
||||
TextEntry::make('number_of_person')
|
||||
->label('Number of Persons'),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
// ── Visit Timing ──
|
||||
Section::make('Visit Timing')
|
||||
->schema([
|
||||
TextEntry::make('in_time')
|
||||
->label('In Time')
|
||||
->dateTime(),
|
||||
TextEntry::make('out_time')
|
||||
->label('Out Time')
|
||||
->dateTime(),
|
||||
TextEntry::make('valid_upto')
|
||||
->label('Valid Upto')
|
||||
->dateTime()
|
||||
->badge()
|
||||
->color(fn ($record) => $record->valid_upto && \Carbon\Carbon::parse($record->valid_upto)->isPast()
|
||||
? 'danger'
|
||||
: 'success'
|
||||
),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListVisitorEntries::route('/'),
|
||||
'create' => Pages\CreateVisitorEntry::route('/create'),
|
||||
'view' => Pages\ViewVisitorEntry::route('/{record}'),
|
||||
'edit' => Pages\EditVisitorEntry::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VisitorEntryResource;
|
||||
use App\Models\EmployeeMaster;
|
||||
use App\Models\VisitorEntry;
|
||||
use Filament\Actions;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class CreateVisitorEntry extends CreateRecord
|
||||
{
|
||||
protected static string $resource = VisitorEntryResource::class;
|
||||
|
||||
public $capturedPhoto;
|
||||
|
||||
public function processMobile($mobile)
|
||||
{
|
||||
$visitor = VisitorEntry::where('mobile_number', $mobile)->latest()->first();
|
||||
|
||||
if ($visitor) {
|
||||
|
||||
$employee = EmployeeMaster::where('id', $visitor->employee_master_id)->first();
|
||||
|
||||
$this->form->fill([
|
||||
'register_id' => $visitor->register_id ?? '',
|
||||
'mobile_number' => $mobile ?? '',
|
||||
'name' => $visitor->name ?? '',
|
||||
'company' => $visitor->company ?? '',
|
||||
'type' => $visitor->type ?? '',
|
||||
'department' => $employee->department ?? '',
|
||||
'employee_master_id' => $visitor->employee_master_id->name ?? '',
|
||||
'code' => $employee->code ?? '',
|
||||
]);
|
||||
}
|
||||
else {
|
||||
|
||||
$registerId = $this->form->getState()['register_id'] ?? '';
|
||||
|
||||
$this->form->fill([
|
||||
'register_id' => $registerId ?? '',
|
||||
'mobile_number' => $mobile ?? '',
|
||||
'name' => $visitor->name ?? '',
|
||||
'company' => $visitor->company ?? '',
|
||||
'type' => $visitor->type ?? '',
|
||||
'department' => $employee->department ?? '',
|
||||
'employee_master_id' => $visitor->employee_master_id->name ?? '',
|
||||
'code' => $employee->code ?? '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
#[On('photo-captured')]
|
||||
public function handlePhotoCapture(string $photo): void
|
||||
{
|
||||
$this->data['photo'] = $photo;
|
||||
\Log::info('WEBCAM: photo-captured event received, length: ' . strlen($photo));
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
if (
|
||||
!empty($data['photo']) &&
|
||||
str_starts_with($data['photo'], 'data:image')
|
||||
) {
|
||||
try {
|
||||
$imageData = explode(',', $data['photo'])[1];
|
||||
|
||||
$filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
|
||||
|
||||
$path = 'visitor-photos/' . $filename;
|
||||
|
||||
$decoded = base64_decode($imageData);
|
||||
|
||||
$saved = Storage::disk('public')->put($path, $decoded);
|
||||
|
||||
$data['photo'] = $path;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('PHOTO UPLOAD ERROR: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function setPhoto(string $photo): void
|
||||
{
|
||||
$this->capturedPhoto = $photo;
|
||||
|
||||
$this->dispatch('photo-captured', photo: $photo)->to(\App\Filament\Resources\VisitorEntryResource\Pages\CreateVisitorEntry::class);
|
||||
}
|
||||
|
||||
// ── Custom form action buttons ──
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [
|
||||
$this->getCreateFormAction(),
|
||||
$this->getCreateAnotherFormAction(),
|
||||
|
||||
Action::make('createAndPrint')
|
||||
->label('Create & Print')
|
||||
->color('success')
|
||||
->icon('heroicon-o-printer')
|
||||
->action(function () {
|
||||
// Save the record using existing logic (calls mutateFormDataBeforeCreate internally)
|
||||
$this->create();
|
||||
|
||||
// Open the badge print page in a new tab
|
||||
$this->js("window.open('" . route('visitor.badge', $this->record->id) . "', '_blank')");
|
||||
}),
|
||||
|
||||
$this->getCancelFormAction(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('view', ['record' => $this->record]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VisitorEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class EditVisitorEntry extends EditRecord
|
||||
{
|
||||
protected static string $resource = VisitorEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
// Receives the photo from the webcam component
|
||||
#[On('photo-captured')]
|
||||
public function handlePhotoCapture(string $photo): void
|
||||
{
|
||||
$this->data['photo'] = $photo;
|
||||
}
|
||||
|
||||
// Runs automatically before the record is updated in the database
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
if (
|
||||
!empty($data['photo']) &&
|
||||
str_starts_with($data['photo'], 'data:image')
|
||||
) {
|
||||
// Delete the old photo file if one exists
|
||||
$oldPhoto = $this->record->photo;
|
||||
if ($oldPhoto && Storage::disk('public')->exists($oldPhoto)) {
|
||||
Storage::disk('public')->delete($oldPhoto);
|
||||
}
|
||||
|
||||
// Save the new photo
|
||||
$imageData = explode(',', $data['photo'])[1];
|
||||
$filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
|
||||
$path = 'visitor-photos/' . $filename;
|
||||
Storage::disk('public')->put($path, base64_decode($imageData));
|
||||
|
||||
$data['photo'] = $path;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VisitorEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListVisitorEntries extends ListRecords
|
||||
{
|
||||
protected static string $resource = VisitorEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\VisitorEntryResource\Pages;
|
||||
|
||||
use App\Filament\Resources\VisitorEntryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewVisitorEntry extends ViewRecord
|
||||
{
|
||||
protected static string $resource = VisitorEntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
|
||||
Actions\Action::make('print')
|
||||
->label('Print Badge')
|
||||
->icon('heroicon-o-printer')
|
||||
->color('success')
|
||||
->url(fn () => route('visitor.badge', $this->record->id))
|
||||
->openUrlInNewTab(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WireMasterPacking;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -17,6 +19,10 @@ use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Str;
|
||||
|
||||
class WireMasterPackingResource extends Resource
|
||||
{
|
||||
@@ -269,7 +275,189 @@ class WireMasterPackingResource extends Resource
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('wireMasterPacking', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('wireMasterPacking', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
TextInput::make('wire_packing_number')
|
||||
->label('Wire Packing Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Wire Packing Number')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->reactive()
|
||||
->placeholder('Enter Process Order')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Rework', null);
|
||||
}),
|
||||
TextInput::make('customer_po_master_id')
|
||||
->label('Customer PO')
|
||||
->reactive()
|
||||
->placeholder('Enter Customer PO'),
|
||||
Select::make('wire_packing_status')
|
||||
->label('Wire Packing Status')
|
||||
->reactive()
|
||||
->options([
|
||||
'Completed' => 'Completed',
|
||||
'Pending' => 'Pending',
|
||||
]),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && empty($data['wire_packing_number']) && empty($data['customer_po_master_id']) && empty($data['wire_packing_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$query->where('item_id', $data['Item']);
|
||||
}
|
||||
|
||||
if (! empty($data['process_order'])) {
|
||||
$query->where('process_order', 'like', '%'.$data['process_order'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['wire_packing_number'])) {
|
||||
$query->where('wire_packing_number', 'like', '%'.$data['wire_packing_number'].'%');
|
||||
}
|
||||
|
||||
if (!empty($data['customer_po_master_id'])) {
|
||||
|
||||
$customerPoId = CustomerPoMaster::where('customer_po', $data['customer_po_master_id'])
|
||||
->where('plant_id', $data['Plant'])
|
||||
->value('id');
|
||||
|
||||
$query->where('customer_po_master_id', $customerPoId);
|
||||
}
|
||||
|
||||
if (! empty($data['wire_packing_status'])) {
|
||||
if ($data['wire_packing_status'] == 'Pending') {
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('wire_packing_status')
|
||||
->orWhere('wire_packing_status', '');
|
||||
});
|
||||
} else {
|
||||
$query->where('wire_packing_status', $data['wire_packing_status']);
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
// $query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant Name: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['process_order'])) {
|
||||
$indicators[] = 'Process Order: '.$data['process_order'];
|
||||
}
|
||||
|
||||
if (! empty($data['wire_packing_number'])) {
|
||||
$indicators[] = 'Wire Packing Number: '.$data['wire_packing_number'];
|
||||
}
|
||||
|
||||
if (! empty($data['customer_po_master_id'])) {
|
||||
$indicators[] = 'Customer PO: '.$data['customer_po_master_id'];
|
||||
}
|
||||
|
||||
if (! empty($data['wire_packing_status'])) {
|
||||
$indicators[] = 'Wire Packing Status: '.$data['wire_packing_status'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\WireMasterPackingResource;
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WireMasterPacking;
|
||||
@@ -81,7 +82,9 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
|
||||
// $pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
|
||||
// $pattern = '/^([^|]+)\|([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
|
||||
$pattern = '/^([^|]+)\|([^|]+)\|([^|]+)\|(\d+(\.\d+)?)(kg)?$/i';
|
||||
|
||||
if (!preg_match($pattern, $processOrder, $matches))
|
||||
{
|
||||
@@ -106,7 +109,8 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
|
||||
$materialCode = $matches[1];
|
||||
$processOrderId = $matches[2];
|
||||
$weight = $matches[3];
|
||||
$coilNo = $matches[3];
|
||||
$weight = $matches[4];
|
||||
|
||||
$icode = Item::where('code', $materialCode)->first();
|
||||
|
||||
@@ -160,7 +164,34 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$processOrderAgaPlant = WireMasterPacking::where('process_order', $processOrderId)->where('plant_id', $plantId)->first();
|
||||
$itemId = Item::where('code', $materialCode)
|
||||
->where('plant_id', $plantId)
|
||||
->value('id');
|
||||
|
||||
$icodeAgaCPoPlant = CustomerPoMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$icodeAgaCPoPlant)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Unknown Item Code in Customer PO")
|
||||
->body("Item Code '$materialCode' not found in any active Customer PO against Plant Code '$plantcode'")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$processOrderAgaPlant = WireMasterPacking::where('process_order', $processOrderId . '-' . $coilNo)->where('plant_id', $plantId)->first();
|
||||
|
||||
if($processOrderAgaPlant)
|
||||
{
|
||||
@@ -182,6 +213,68 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$customerPoRecord = CustomerPoMaster::where('id', $customerPo)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
$customerPoName = $customerPoRecord->customer_po;
|
||||
|
||||
if ($customerPoRecord) {
|
||||
$customerPoName = $customerPoRecord->customer_po;
|
||||
} else {
|
||||
$customerPoName = null;
|
||||
}
|
||||
|
||||
if(!$customerPoRecord)
|
||||
{
|
||||
Notification::make()
|
||||
->title("PO Not Found")
|
||||
->body("Customer PO '$customerPoName' for Item '$materialCode' not found against Plant '$plantcode'")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->selectRaw('SUM(CAST(weight AS NUMERIC)) as total_weight')
|
||||
->value('total_weight');
|
||||
|
||||
$totalQty = (float)$alreadyScannedQty + (float)$weight;
|
||||
|
||||
if($totalQty > (float)$customerPoRecord->quantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned Weight Exceeds PO Quantity")
|
||||
->body("Scanned weight '$weight' and already scanned weight '$alreadyScannedQty' exceeds allowed quantity '{$customerPoRecord->quantity}' for PO '$customerPoName' and Item '$materialCode'")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
$existingPallet = WireMasterPacking::where('plant_id', $plantId)
|
||||
@@ -200,7 +293,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'wire_packing_number' => $wirePackNo,
|
||||
'process_order' => $processOrderId,
|
||||
'process_order' => $processOrderId . '-' . $coilNo,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'weight' => $weight,
|
||||
'created_by' => $createdBy,
|
||||
@@ -590,6 +683,33 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$pattern = '/^([^|]+)\|([^|]+)\|([^|]+)\|(\d+(\.\d+)?)(kg)?$/i';
|
||||
|
||||
if (!preg_match($pattern, $processOrder, $matches))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scan Valid Qr code ")
|
||||
->body("Expected Format : (MaterialCode|Process Order|Id|Weight)")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'process_order' => null,
|
||||
'plant_id' => $plantId,
|
||||
'customer_po_master_id' => $customerPo,
|
||||
'Sno_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$materialCode = $matches[1];
|
||||
$processOrderId = $matches[2];
|
||||
$coilNo = $matches[3];
|
||||
$weight = $matches[4];
|
||||
|
||||
$count = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('wire_packing_number', $palletNumber)
|
||||
->count('wire_packing_number');
|
||||
@@ -618,7 +738,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
|
||||
|
||||
$processOrderexist = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('process_order', $processOrderId . '-' . $coilNo)
|
||||
->first();
|
||||
if (!$processOrderexist)
|
||||
{
|
||||
@@ -643,7 +763,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
}
|
||||
|
||||
$palletExist = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('process_order', $processOrderId . '-' . $coilNo)
|
||||
->where('wire_packing_number', '!=', '')
|
||||
->where('wire_packing_number', '!=', null)
|
||||
->first();
|
||||
@@ -673,7 +793,7 @@ class CreateWireMasterPacking extends CreateRecord
|
||||
|
||||
$deleted = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('wire_packing_number', $palletNumber)
|
||||
->where('process_order', $processOrder)
|
||||
->where('process_order', $processOrderId . '-' . $coilNo)
|
||||
->forceDelete();
|
||||
|
||||
if ($deleted)
|
||||
|
||||
@@ -40,6 +40,7 @@ class WorkGroupMasterResource extends Resource
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
@@ -55,22 +56,20 @@ class WorkGroupMasterResource extends Resource
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if (! $plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
$set('wgmPlantError', null);
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
if (! $plantId) {
|
||||
$set('wgmPlantError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('wgmPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('wgmPlantError') ? $get('wgmPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Group Work Center')
|
||||
|
||||
@@ -22,6 +22,10 @@ class InvoiceChart extends ChartWidget
|
||||
{
|
||||
$selectedPlant = session('selec_plant');
|
||||
$selectedInvoice = session('select_invoice');
|
||||
|
||||
$fromDt = session('from_date');
|
||||
$toDt = session('to_date');
|
||||
|
||||
$activeFilter = $this->filter; // Assuming filter is passed and activeFilter can be 'yesterday', 'this_week', 'this_month'
|
||||
|
||||
if (!$selectedPlant || !$selectedInvoice) {
|
||||
@@ -31,23 +35,33 @@ class InvoiceChart extends ChartWidget
|
||||
];
|
||||
}
|
||||
|
||||
// Define the date range based on the active filter
|
||||
if ($activeFilter == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
} elseif ($activeFilter == 'this_week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'day_of_week';
|
||||
} elseif ($activeFilter == 'this_month') {
|
||||
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfMonth()->setTime(8, 0, 0);
|
||||
$groupBy = 'week_of_month';
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
$isCustomDate = !empty($fromDt) && !empty($toDt);
|
||||
|
||||
if (!empty($fromDt) && !empty($toDt)) {
|
||||
$startDate = \Carbon\Carbon::parse($fromDt)->setTime(8, 0, 0);
|
||||
$endDate = \Carbon\Carbon::parse($toDt)->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'none';
|
||||
}
|
||||
else{
|
||||
|
||||
// Define the date range based on the active filter
|
||||
if ($activeFilter == 'yesterday') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
} elseif ($activeFilter == 'this_week') {
|
||||
$startDate = now()->startOfWeek()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfWeek()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'day_of_week';
|
||||
} elseif ($activeFilter == 'this_month') {
|
||||
$startDate = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endDate = now()->endOfMonth()->setTime(8, 0, 0);
|
||||
$groupBy = 'week_of_month';
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
$groupBy = 'none'; // No grouping by hour
|
||||
}
|
||||
}
|
||||
|
||||
// Get the counts for Imported Invoices (unique invoice numbers) and Completed Invoices
|
||||
@@ -111,7 +125,11 @@ class InvoiceChart extends ChartWidget
|
||||
$labels = []; // Labels for each bar
|
||||
$datasets = []; // Datasets for the chart
|
||||
|
||||
if (in_array($activeFilter, ['yesterday'])) {
|
||||
if (!empty($fromDt) && !empty($toDt)) {
|
||||
$activeFilter = null;
|
||||
}
|
||||
|
||||
if ($isCustomDate || in_array($activeFilter, ['yesterday'])) {
|
||||
$labels = ['Imported Invoice', 'Completed Invoice'];
|
||||
$datasets = [[
|
||||
'label' => 'Invoices',
|
||||
@@ -120,8 +138,7 @@ class InvoiceChart extends ChartWidget
|
||||
'fill' => false,
|
||||
]];
|
||||
}
|
||||
|
||||
elseif ($activeFilter == 'this_week')
|
||||
elseif ($isCustomDate || $activeFilter == 'this_week')
|
||||
{
|
||||
$daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
$importedInvoicesPerDay = array_fill(0, 7, 0);
|
||||
@@ -191,7 +208,7 @@ class InvoiceChart extends ChartWidget
|
||||
],
|
||||
];
|
||||
}
|
||||
elseif ($activeFilter == 'this_month') {
|
||||
elseif ($isCustomDate || $activeFilter == 'this_month') {
|
||||
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
|
||||
$endOfMonth = now()->endOfMonth()->addDay()->setTime(23, 59, 59); // include full last day
|
||||
$monthName = $startOfMonth->format('M');
|
||||
@@ -279,7 +296,7 @@ class InvoiceChart extends ChartWidget
|
||||
],
|
||||
];
|
||||
}
|
||||
else
|
||||
elseif (!$isCustomDate)
|
||||
{
|
||||
$labels = ['Imported Invoice', 'Completed Invoice'];
|
||||
$datasets = [[
|
||||
@@ -354,7 +371,7 @@ class InvoiceChart extends ChartWidget
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
// dd('Checking route:', request()->route()->getName());
|
||||
// dd('Checking route:', request()->route()->getName());
|
||||
// to avoid showing the widget in other pages
|
||||
return request()->routeIs('filament.admin.pages.invoice-dashboard');
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CharacteristicApprovalController extends Controller
|
||||
{
|
||||
@@ -358,10 +360,26 @@ class CharacteristicApprovalController extends Controller
|
||||
->where('work_flow_id', $record->work_flow_id)
|
||||
->get();
|
||||
|
||||
$approverMasterNames = CharacteristicApproverMaster::find($record->characteristic_approver_master_id);
|
||||
|
||||
if (! $approverMasterNames) {
|
||||
abort(500, 'Approver master not found');
|
||||
}
|
||||
|
||||
$approverNameColumn = match ($level) {
|
||||
1 => 'name1',
|
||||
2 => 'name2',
|
||||
3 => 'name3',
|
||||
default => null,
|
||||
};
|
||||
|
||||
$updatedBy = $approverNameColumn ? $approverMasterNames->$approverNameColumn : null;
|
||||
|
||||
$updateData = [
|
||||
$statusColumn => $status,
|
||||
$remarkColumn => $request->input('remark'),
|
||||
$approvedAtColumn => Carbon::now(),
|
||||
'updated_by' => $updatedBy,
|
||||
];
|
||||
|
||||
if (in_array($status, ['Approved', 'Rejected'])) {
|
||||
@@ -386,6 +404,14 @@ class CharacteristicApprovalController extends Controller
|
||||
// ->where('aufnr', $record->aufnr)
|
||||
// ->update(['has_work_flow_id' => $record->work_flow_id]);
|
||||
|
||||
if ($status == 'Rejected') {
|
||||
$filePath = 'uploads/LaserDocs/'.$record->work_flow_id.'.png';
|
||||
|
||||
if (Storage::disk('local')->exists($filePath)) {
|
||||
Storage::disk('local')->delete($filePath);
|
||||
}
|
||||
}
|
||||
|
||||
if ($returnView) {
|
||||
return match ($status) {
|
||||
'Approved' => view('approval.success'),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -107,7 +107,7 @@ class PalletPrintController extends Controller
|
||||
|
||||
$index = $completedPallets->search($pallet);
|
||||
|
||||
$currentPalletNo = ($index != false) ? $index + 1 : 0;
|
||||
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||
|
||||
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
||||
|
||||
@@ -143,8 +143,10 @@ class PalletPrintController extends Controller
|
||||
'customerName' => $customerName,
|
||||
'masterBox' => $boxLabel,
|
||||
'items' => $items,
|
||||
'grossWeight' => $grossWeight,
|
||||
'netWeight' => $grossWeight - 3.05,
|
||||
'grossWeight' => $grossWeight + 3.050,
|
||||
'netWeight' => $grossWeight,
|
||||
// 'grossWeight' => $grossWeight,
|
||||
// 'netWeight' => $grossWeight - 3.05,
|
||||
'pallet' => $pallet,
|
||||
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||
|
||||
|
||||
@@ -29,30 +29,30 @@ class PlantController extends Controller
|
||||
public function get_all_data(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plants = Plant::with('company')->orderBy('code')->get();
|
||||
$plantsData = $plants->map(function($plant) {
|
||||
$plantsData = $plants->map(function ($plant) {
|
||||
return [
|
||||
'company' => $plant->company ? $plant->company->name : "", // Get company name
|
||||
'plant_code' => (String)$plant->code,
|
||||
'plant_name' => $plant->name,
|
||||
'plant_address' => $plant->address,
|
||||
'company' => $plant->company ? $plant->company->name : '', // Get company name
|
||||
'plant_code' => (string) $plant->code,
|
||||
'plant_name' => $plant->name,
|
||||
'plant_warehouse_number' => (string) $plant->warehouse_number,
|
||||
'plant_address' => $plant->address,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'plants' => $plantsData
|
||||
'plants' => $plantsData,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionOrder;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
// use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Mpdf\QrCode\QrCode;
|
||||
use Mpdf\QrCode\Output;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
|
||||
class ProductionOrderController extends Controller
|
||||
@@ -39,9 +44,15 @@ class ProductionOrderController extends Controller
|
||||
|
||||
$qrData = $itemCode . '|' . $serial;
|
||||
|
||||
$qrBase64 = base64_encode(
|
||||
QrCode::format('png')->size(100)->generate($qrData)
|
||||
);
|
||||
// $qrBase64 = base64_encode(
|
||||
// QrCode::format('png')->size(100)->generate($qrData)
|
||||
// );
|
||||
|
||||
$qrCode = new QrCode($qrData);
|
||||
$output = new Output\Png;
|
||||
// $qrBinary = $output->output($qrCode, 100);
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
$stickers[] = [
|
||||
'serial' => $serial,
|
||||
@@ -58,6 +69,144 @@ class ProductionOrderController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function printpanel($production_order, $plantCode){
|
||||
|
||||
\Log::info('Print Panel Started', [
|
||||
'production_order' => $production_order,
|
||||
'plantCode' => $plantCode,
|
||||
]);
|
||||
|
||||
$order = ProductionOrder::where('production_order', $production_order)->first();
|
||||
|
||||
$wareHouseNo = Plant::where('code', $plantCode)->first();
|
||||
|
||||
$wareNo = $wareHouseNo->warehouse_number ?? null;
|
||||
|
||||
|
||||
\Log::info('Plant Data', [
|
||||
'plant' => $wareHouseNo ? $wareHouseNo->toArray() : null,
|
||||
]);
|
||||
|
||||
\Log::info('Warehouse Number', [
|
||||
'warehouse_number' => $wareNo,
|
||||
'final_code' => $plantCode . $wareNo,
|
||||
]);
|
||||
|
||||
if (!$order) {
|
||||
abort(404, 'Production Order not found');
|
||||
}
|
||||
else{
|
||||
$fromSerial = (int) $order->from_serial_number;
|
||||
$toSerial = (int) $order->to_serial_number;
|
||||
$itemCode = $order->item->code ?? '';
|
||||
$itemDes = $order->item->description ?? '';
|
||||
$now = Carbon::now();
|
||||
$year = $now->format('y');
|
||||
$month = $now->format('m');
|
||||
|
||||
$stickers = [];
|
||||
|
||||
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||
{
|
||||
|
||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||
$serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||
|
||||
$qrData = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||
|
||||
$panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||
|
||||
$qrCode = new QrCode($qrData);
|
||||
$output = new Output\Png;
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
$stickers[] = [
|
||||
'serial' => $panel,
|
||||
'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||
'production_order' => $production_order,
|
||||
'description' => $itemDes ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
$pdf = Pdf::loadView('production-orders.printpanel', compact('stickers'))
|
||||
->setPaper([0, 0, 113.39, 113.39]);
|
||||
|
||||
return $pdf->stream('stickers.pdf');
|
||||
}
|
||||
}
|
||||
|
||||
public function printitemserial($production_order, $plantCode)
|
||||
{
|
||||
$order = ProductionOrder::where('production_order', $production_order)->first();
|
||||
|
||||
if (!$order) {
|
||||
abort(404, 'Production Order not found');
|
||||
}
|
||||
else{
|
||||
$fromSerial = (int) $order->from_serial_number;
|
||||
$toSerial = (int) $order->to_serial_number;
|
||||
$itemCode = $order->item->code ?? '';
|
||||
$itemDes = $order->item->description ?? '';
|
||||
|
||||
$wareHouseNo = Plant::where('code', $plantCode)->first();
|
||||
|
||||
$wareNo = $wareHouseNo->warehouse_number ?? null;
|
||||
|
||||
$now = Carbon::now();
|
||||
$year = $now->format('y');
|
||||
$month = $now->format('m');
|
||||
|
||||
$stickers = [];
|
||||
|
||||
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||
{
|
||||
|
||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
if(!empty($wareNo)){
|
||||
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||
$qrData = $itemCode . '|' . $serial;
|
||||
} else {
|
||||
$qrData = $itemCode . '|' . $serial;
|
||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
// $qrData = $itemCode . '|' . $serial;
|
||||
|
||||
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||
|
||||
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||
|
||||
// $qrData = $itemCode . '|' . $serialWithWarehouse;
|
||||
|
||||
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||
|
||||
// $qrBase64 = base64_encode(
|
||||
// QrCode::format('png')->size(100)->generate($qrData)
|
||||
// );
|
||||
|
||||
$qrCode = new QrCode($qrData);
|
||||
$output = new Output\Png;
|
||||
// $qrBinary = $output->output($qrCode, 100);
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
$stickers[] = [
|
||||
'serial' => $serial,
|
||||
'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||
'production_order' => $itemCode,
|
||||
'description' => $itemDes ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
$pdf = Pdf::loadView('production-orders.printItemSerial', compact('stickers'))
|
||||
->setPaper([0, 0, 170, 40]);
|
||||
|
||||
return $pdf->stream('stickers.pdf');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ class StickerMasterController extends Controller
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant code must be between 4 and 7 digits only!',
|
||||
], 400);
|
||||
} elseif (! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
@@ -190,7 +190,7 @@ class StickerMasterController extends Controller
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant code must be between 4 and 7 digits only!',
|
||||
], 400);
|
||||
} elseif (! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\LeakTestReading;
|
||||
use App\Models\Machine;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
@@ -23,9 +23,9 @@ class TestingPanelController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* Store a newly created readings in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function storeReadings(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
@@ -48,12 +48,12 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 400);
|
||||
], 404);
|
||||
} elseif (Str::length($data['plant_code']) < 4 || ! is_numeric($data['plant_code']) || ! preg_match('/^[1-9]\d{3,}$/', $data['plant_code'])) {// !ctype_digit($data['plant_code'])
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $data['plant_code'])->first();
|
||||
@@ -62,7 +62,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
@@ -71,12 +71,12 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!",
|
||||
], 400);
|
||||
], 404);
|
||||
} elseif (Str::length($data['line_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid group work center found!',
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->first();
|
||||
@@ -84,7 +84,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Group work center not found!',
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->where('plant_id', $plantId)->first();
|
||||
@@ -93,7 +93,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$gWorkCenterId = $gWorkCenter->id;
|
||||
@@ -102,12 +102,12 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!",
|
||||
], 400);
|
||||
], 404);
|
||||
} elseif (Str::length($data['machine_name']) < 0) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid work center found!',
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->first();
|
||||
@@ -115,7 +115,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Work center not found!',
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->first();
|
||||
@@ -123,7 +123,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
@@ -132,7 +132,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$data['line_name']}'!",
|
||||
], 400);
|
||||
], 404);
|
||||
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Plant : '{$data['plant_code']}' and Group work center : '{$data['line_name']}'!",
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$lineId = $machine->line_id;
|
||||
@@ -162,7 +162,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code can't be empty!",
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
// Collect duplicates
|
||||
@@ -196,7 +196,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Duplicate item codes found in request: '.implode(', ', $duplicateItemCodes),
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$uniqueInvalidCodes = array_unique($missedItemCodes);
|
||||
@@ -209,7 +209,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item codes : '.implode(', ', $uniqueInvalidCodes)." not found in master for the specified plant : '{$plant->name}'!",
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
|
||||
$insertedSnoCount = [];
|
||||
@@ -326,7 +326,7 @@ class TestingPanelController extends Controller
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Missed serial numbers are: '.implode(', ', $missingSno),
|
||||
], 400);
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -338,6 +338,309 @@ class TestingPanelController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created leak test status in storage.
|
||||
*/
|
||||
public function storeLeakTestStatus(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$plantCode = $data['plant_code'] ?? '';
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$serialNumber = $data['serial_number'] ?? '';
|
||||
$testStatus = $data['test_status'] ?? 'F';
|
||||
|
||||
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 404);
|
||||
} elseif (! is_numeric($plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' should contain only numeric values!",
|
||||
], 404);
|
||||
} elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' must be between 4 and 7 digits only!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code '{$plantCode}' found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($itemCode == null || $itemCode == '' || ! $itemCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($itemCode) < 6) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should contain minimum 6 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($itemCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $itemCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should not begin with '0'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($serialNumber == null || $serialNumber == '' || ! $serialNumber) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Serial number can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($serialNumber) < 9) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Serial number '{$serialNumber}' should contain minimum 9 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($serialNumber)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Serial number '{$serialNumber}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNumber)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Serial number '{$serialNumber}' should not begin with '0' or letter!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($testStatus == null || $testStatus == '') {
|
||||
$testStatus = 'F';
|
||||
} elseif (Str::contains($testStatus, 'P', ignoreCase: true)) {
|
||||
$testStatus = 'P';
|
||||
} elseif (Str::contains($testStatus, 'F', ignoreCase: true)) {
|
||||
$testStatus = 'F';
|
||||
} else {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Leak test status must be 'P' or 'F'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (! $plant) {
|
||||
// return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' not found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
try {
|
||||
LeakTestReading::create([
|
||||
'plant_id' => $plantId,
|
||||
'item_code' => $itemCode,
|
||||
'serial_number' => $serialNumber,
|
||||
'test_status' => $testStatus,
|
||||
]);
|
||||
|
||||
$existing = LeakTestReading::where('serial_number', $serialNumber)->where('item_code', $itemCode)->where('test_status', $testStatus)->where('plant_id', $plantId)->latest()->first();
|
||||
|
||||
if ($existing) {
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Successfully updated leak test status.',
|
||||
], 200);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Failed to update leak test status!',
|
||||
], 200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// return response($e->getMessage(), 500)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Store leak test status internal server error : '.$e?->getCode(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get leak test status.
|
||||
*/
|
||||
public function getLeakTestStatus(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
|
||||
// $data = $request->all();
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code') ?? null;
|
||||
$serialNumbers = $request->header('serial-numbers') ?? null;
|
||||
// $description = $item ? $item->description : '';
|
||||
|
||||
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
], 404);
|
||||
} elseif (! is_numeric($plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' should contain only numeric values!",
|
||||
], 404);
|
||||
} elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' must be between 4 and 7 digits only!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code '{$plantCode}' found!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($serialNumbers == null || $serialNumbers == '' || ! $serialNumbers) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Serial numbers can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
if (! $plant) {
|
||||
// return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code '{$plantCode}' not found!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$serialArray = array_map('trim', explode(',', $serialNumbers));
|
||||
// $serialNumber = 'SNO-'.Str::random(5).'-'.time(); // Default random serial number if not provided
|
||||
|
||||
// Remove null, empty string, or falsy values from $serialArray
|
||||
$serialArray = array_filter($serialArray, function ($serial) {
|
||||
return $serial != null && $serial != '' && $serial;
|
||||
});
|
||||
|
||||
$serialStatus = [];
|
||||
$validSerials = [];
|
||||
$hasFail = false;
|
||||
foreach ($serialArray as $serialNumber) {
|
||||
if ($serialNumber == null || $serialNumber == '' || ! $serialNumber) {
|
||||
$serialStatus[$serialNumber] = "Serial number can't be empty!";
|
||||
$hasFail = true;
|
||||
// $serialStatus[$serialNumber] = 'I';
|
||||
} elseif (Str::length($serialNumber) < 9) {
|
||||
$serialStatus[$serialNumber] = 'Should contain minimum 9 digits!';
|
||||
$hasFail = true;
|
||||
// $serialStatus[$serialNumber] = 'I';
|
||||
} elseif (! ctype_alnum($serialNumber)) {
|
||||
$serialStatus[$serialNumber] = 'Should contain only alpha-numeric values!';
|
||||
$hasFail = true;
|
||||
// $serialStatus[$serialNumber] = 'I';
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $serialNumber)) {
|
||||
$serialStatus[$serialNumber] = "Should not begin with '0' or letter!";
|
||||
$hasFail = true;
|
||||
// $serialStatus[$serialNumber] = 'I';
|
||||
} else {
|
||||
$validSerials[$serialNumber] = 'Not Found';
|
||||
}
|
||||
}
|
||||
|
||||
// $key = array_search('26021040180982', $serialArray);
|
||||
// if ($key !== false) {
|
||||
// unset($serialArray[$key]);
|
||||
// }
|
||||
|
||||
if ($validSerials == null || empty($validSerials)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_descriptions' => $serialStatus,
|
||||
], 404);
|
||||
} else {
|
||||
$serialArray = $validSerials; // nonExistingSerials
|
||||
}
|
||||
|
||||
// Check which serial numbers exist in leak_test_readings table
|
||||
$existingSerials = [];
|
||||
|
||||
$existingSerials = LeakTestReading::where('plant_id', $plantId)->whereIn('serial_number', array_keys($serialArray))
|
||||
->pluck('test_status', 'serial_number')
|
||||
->toArray();
|
||||
|
||||
if ($existingSerials == null || empty($existingSerials)) {
|
||||
$mergedResult = $serialStatus + $serialArray; // array_merge($serialStatus, $serialArray);
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_descriptions' => $mergedResult,
|
||||
], 404);
|
||||
}
|
||||
|
||||
$hasFail = (! $hasFail) ? in_array('F', $existingSerials) : $hasFail;
|
||||
// Map 'F' to 'Fail' and 'P' to 'Pass'
|
||||
$existingSerials = array_map(function ($status) {
|
||||
return $status === 'F' ? 'Fail' : ($status === 'P' ? 'Pass' : $status);
|
||||
}, $existingSerials);
|
||||
|
||||
// Sort: Fail comes first, then Pass
|
||||
uasort($existingSerials, function ($a, $b) {
|
||||
// 'Fail' < 'Pass' so Fail comes first
|
||||
return $a <=> $b;
|
||||
});
|
||||
|
||||
// Get non-existing serial numbers (serials not in the database)
|
||||
// $serialArray = array_diff($serialArray, array_keys($existingSerials));
|
||||
$nonExistingSerials = array_diff_key($serialArray, $existingSerials);
|
||||
|
||||
if ($nonExistingSerials == null || empty($nonExistingSerials)) {
|
||||
$mergedResult = $serialStatus + $existingSerials;
|
||||
|
||||
return response()->json([
|
||||
'status_code' => $hasFail ? 'ERROR' : 'SUCCESS',
|
||||
'status_descriptions' => $mergedResult,
|
||||
], $hasFail ? 404 : 200);
|
||||
} else {
|
||||
$mergedResult = $serialStatus + $nonExistingSerials + $existingSerials; // nonExistingSerials
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_descriptions' => $mergedResult,
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
|
||||
@@ -41,12 +41,11 @@ class VehicleController extends Controller
|
||||
|
||||
if (!ctype_digit((string) $plantCode)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "plant code must be $plantCode a numeric value",
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
$plantCod = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if(!$plantCod){
|
||||
@@ -58,100 +57,180 @@ class VehicleController extends Controller
|
||||
|
||||
$plantId = $plantCod->id;
|
||||
|
||||
$data = $request->all();
|
||||
// $data = $request->all();
|
||||
|
||||
$vehicleNo = $data['vehicle_number'] ?? '';
|
||||
$entryTimeRaw = $data['entry_time'] ?? '';
|
||||
$exitTimeRaw = $data['exit_time'] ?? '';
|
||||
$duration = $data['duration'] ?? '';
|
||||
$type = $data['type'] ?? '';
|
||||
$data = $request->json()->all();
|
||||
|
||||
if(!$vehicleNo)
|
||||
$results = [];
|
||||
|
||||
foreach ($data as $item) {
|
||||
|
||||
$uuid = $item['uuid'] ?? '';
|
||||
$vehicleNo = trim($item['vehicle_number'] ?? '');
|
||||
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||
$duration = $item['duration'] ?? '';
|
||||
$type = $item['type'] ?? '';
|
||||
|
||||
if (!$vehicleNo) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Vehicle number can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (strlen($vehicleNo) < 8) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Vehicle number '$vehicleNo' must be at least 8 characters long"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (!$entryTimeRaw) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Entry time can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif (!$type) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Type can't be empty!"
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
elseif ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
elseif ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||
|
||||
$results[] = [
|
||||
'uuid' => $uuid,
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid duration format $duration"
|
||||
];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($results)){
|
||||
return response()->json($results, 404);
|
||||
}
|
||||
|
||||
foreach ($data as $item) {
|
||||
|
||||
$uuid = $item['uuid'] ?? '';
|
||||
// $vehicleNo = strtoupper(trim($item['vehicle_number'] ?? ''));
|
||||
$vehicleNo = strtoupper(
|
||||
str_replace(' ', '', trim($item['vehicle_number'] ?? ''))
|
||||
);
|
||||
$entryTimeRaw = $item['entry_time'] ?? '';
|
||||
$exitTimeRaw = $item['exit_time'] ?? '';
|
||||
$duration = $item['duration'] ?? '';
|
||||
$type = $item['type'] ?? '';
|
||||
|
||||
$manualVehicles = [
|
||||
'TN01KK0004',
|
||||
'TN01KK0001',
|
||||
];
|
||||
|
||||
$boomOpened = in_array($vehicleNo, $manualVehicles) ? 'Manual' : 'Auto';
|
||||
|
||||
if(!empty($entryTimeRaw)){
|
||||
$entryTime = $entryTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||
: null;
|
||||
}
|
||||
|
||||
$exitTime = null;
|
||||
|
||||
if(!empty($exitTimeRaw)){
|
||||
|
||||
$exitTime = $exitTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||
: null;
|
||||
}
|
||||
|
||||
if (
|
||||
empty($duration) &&
|
||||
!empty($entryTime) &&
|
||||
!empty($exitTime)
|
||||
) {
|
||||
$entry = Carbon::parse($entryTime); // 2026-05-22 16:13:35
|
||||
$exit = Carbon::parse($exitTime); // 2026-05-25 14:17:29
|
||||
|
||||
$totalSeconds = $entry->diffInSeconds($exit);
|
||||
|
||||
$hours = floor($totalSeconds / 3600);
|
||||
$minutes = floor(($totalSeconds % 3600) / 60);
|
||||
$seconds = $totalSeconds % 60;
|
||||
|
||||
$duration = sprintf(
|
||||
'%02d:%02d:%02d',
|
||||
$hours,
|
||||
$minutes,
|
||||
$seconds
|
||||
);
|
||||
}
|
||||
|
||||
$record = VehicleEntry::updateOrInsert(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'uuid' => $uuid
|
||||
],
|
||||
[
|
||||
'vehicle_number' => $vehicleNo,
|
||||
'boom_opened' => $boomOpened,
|
||||
'entry_time' => $entryTime,
|
||||
'exit_time' => $exitTime ?? null,
|
||||
'duration' => $duration ?: null,
|
||||
'type' => $type,
|
||||
'updated_at' => now(),
|
||||
'created_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if($record){
|
||||
return response()->json([
|
||||
'status' => 'SUCCESS',
|
||||
'status_description' => 'Vehicle entry inserted successfully'
|
||||
], 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Vehicle number cant't be empty!",
|
||||
'status_description' => 'Failed to insert record in the table vehicle entry'
|
||||
], 404);
|
||||
}
|
||||
else if (strlen($vehicleNo) < 8) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "vehicle number '$vehicleNo' must be at least 8 characters long",
|
||||
], 404);
|
||||
}
|
||||
else if(!$entryTimeRaw)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Entry time cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$exitTimeRaw)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Exit time cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$duration)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Duration cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
else if(!$type)
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "type cant't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
if ($entryTimeRaw && !Carbon::hasFormat($entryTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Entry time format $entryTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($exitTimeRaw && !Carbon::hasFormat($exitTimeRaw, 'd/m/Y h:i:s A')) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => "Invalid Exit time format $exitTimeRaw. Expected dd/mm/yyyy hh:mm:ss AM/PM",
|
||||
], 404);
|
||||
}
|
||||
else if ($duration && !preg_match('/^\d{2}:\d{2}:\d{2}$/', $duration)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status_description' => "Invalid duration format $duration. Expected HH:MM:SS",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$entryTime = $entryTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $entryTimeRaw)
|
||||
: null;
|
||||
|
||||
$exitTime = $exitTimeRaw
|
||||
? Carbon::createFromFormat('d/m/Y h:i:s A', $exitTimeRaw)
|
||||
: null;
|
||||
|
||||
VehicleEntry::insert([
|
||||
'plant_id' => $plantId,
|
||||
'vehicle_number' => $vehicleNo,
|
||||
'entry_time' => $entryTime,
|
||||
'exit_time' => $exitTime,
|
||||
'duration' => $duration,
|
||||
'type' => $type,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'status_description' => 'Vehicle entry inserted successfully'
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
21
app/Http/Controllers/VisitorBadgeController.php
Normal file
21
app/Http/Controllers/VisitorBadgeController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\VisitorEntry;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class VisitorBadgeController extends Controller
|
||||
{
|
||||
public function show($id)
|
||||
{
|
||||
$visitor = VisitorEntry::with('employeeMaster')->findOrFail($id);
|
||||
|
||||
$photoUrl = $visitor->photo
|
||||
? Storage::disk('public')->url($visitor->photo)
|
||||
: null;
|
||||
|
||||
return view('visitor.badge', compact('visitor', 'photoUrl'));
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,7 @@ class InvoiceDataTable extends Component
|
||||
'refreshEmptyInvoice' => 'loadEmptyData',
|
||||
'refreshInvoiceData' => 'loadData',
|
||||
'refreshMaterialInvoiceData' => 'loadMaterialData',
|
||||
'refreshMaterialInvoiceData1' => 'loadMaterialData1',
|
||||
'openCapacitorModal' => 'showCapacitorInputBox',
|
||||
];
|
||||
|
||||
@@ -406,49 +407,47 @@ class InvoiceDataTable extends Component
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
if ($sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1) {
|
||||
|
||||
if ($sm->tube_sticker_motor == 1) {
|
||||
// $sm->tube_sticker_motor == 1 || $sm->tube_sticker_pump == 1 || $sm->tube_sticker_pumpset == 1
|
||||
if (! empty($sm->tube_sticker_motor) || ! empty($sm->tube_sticker_pump) || ! empty($sm->tube_sticker_pumpset)) {
|
||||
|
||||
if (! empty($sm->tube_sticker_motor)) {
|
||||
$stickCount++;
|
||||
if ($record->motor_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
$sm->tube_sticker_pump == 1 ||
|
||||
($sm->tube_sticker_pumpset != 1 &&
|
||||
$sm->tube_sticker_pump != 1 &&
|
||||
$sm->pack_slip_pump == 1)
|
||||
) {
|
||||
// ($sm->tube_sticker_pumpset != 1 && $sm->tube_sticker_pump != 1 && $sm->pack_slip_pump == 1)
|
||||
if (! empty($sm->tube_sticker_pump) || (empty($sm->tube_sticker_pumpset) && empty($sm->tube_sticker_pump) && ! empty($sm->pack_slip_pump))) {
|
||||
$stickCount++;
|
||||
if ($record->pump_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->tube_sticker_pumpset == 1) {
|
||||
if (! empty($sm->tube_sticker_pumpset)) {
|
||||
$stickCount++;
|
||||
if ($record->scanned_status_set == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
} elseif ($sm->pack_slip_motor == 1 || $sm->pack_slip_pump == 1 || $sm->pack_slip_pumpset == 1) {
|
||||
if ($sm->pack_slip_motor == 1) {
|
||||
} elseif (! empty($sm->pack_slip_motor) || ! empty($sm->pack_slip_pump) || ! empty($sm->pack_slip_pumpset)) {
|
||||
if (! empty($sm->pack_slip_motor)) {
|
||||
$stickCount++;
|
||||
if ($record->motor_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->pack_slip_pump == 1) {
|
||||
if (! empty($sm->pack_slip_pump)) {
|
||||
$stickCount++;
|
||||
if ($record->pump_scanned_status == 1) {
|
||||
$scannedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sm->pack_slip_pumpset == 1) {
|
||||
if (! empty($sm->pack_slip_pumpset)) {
|
||||
$stickCount++;
|
||||
if ($record->scanned_status_set == 1) {
|
||||
$scannedCount++;
|
||||
@@ -596,12 +595,14 @@ class InvoiceDataTable extends Component
|
||||
// $stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
|
||||
$row['code'] = StickerMaster::with('item')->find($row['sticker_master_id'] ?? null)?->item?->code ?? 'N/A';
|
||||
$matType = StickerMaster::where('id', $row['sticker_master_id'] ?? null)->first()->material_type ?? '';
|
||||
if ($matType === 1) {
|
||||
if ($matType == 1) {
|
||||
$row['material_type'] = 'Individual';
|
||||
} elseif ($matType === 2) {
|
||||
} elseif ($matType == 2) {
|
||||
$row['material_type'] = 'Bundle';
|
||||
} elseif ($matType === 3) {
|
||||
} elseif ($matType == 3) {
|
||||
$row['material_type'] = 'Quantity';
|
||||
} elseif ($matType == 4) {
|
||||
$row['material_type'] = 'Bundle Individual';
|
||||
} else {
|
||||
$row['material_type'] = 'N/A';
|
||||
}
|
||||
@@ -679,7 +680,7 @@ class InvoiceDataTable extends Component
|
||||
|
||||
// foreach ($this->invoiceData as &$row) {
|
||||
|
||||
// if (($row['code'] ?? '') === $this->currentItemCode && ($row['serial_number'] ?? '') === $this->currentSerialNumber) {
|
||||
// if (($row['code'] ?? '') == $this->currentItemCode && ($row['serial_number'] ?? '') == $this->currentSerialNumber) {
|
||||
// $row['panel_box_supplier'] = $supplier;
|
||||
// $row['panel_box_code'] = $itemCode;
|
||||
// $row['panel_box_serial_number'] = $serialNumber;
|
||||
@@ -691,7 +692,7 @@ class InvoiceDataTable extends Component
|
||||
// ->where('plant_id', $this->plantId)
|
||||
// ->get()
|
||||
// ->first(function ($validation) {
|
||||
// return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
// return $validation->stickerMaster?->item?->code == $this->currentItemCode;
|
||||
// });
|
||||
|
||||
// // dd($matchingValidation);
|
||||
@@ -709,7 +710,7 @@ class InvoiceDataTable extends Component
|
||||
|
||||
// $packCnt = 1;
|
||||
// $scanCnt = 1;
|
||||
// // if ($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
// // if ($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
||||
// if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr) {
|
||||
// $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
// $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -719,7 +720,7 @@ class InvoiceDataTable extends Component
|
||||
// $scanCnt = $hadPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||
// $scanCnt = $hadPumpSetQr ? $scanCnt + 1 : $scanCnt;
|
||||
|
||||
// if ($packCnt === $scanCnt) {
|
||||
// if ($packCnt == $scanCnt) {
|
||||
// $matchingValidation->update([
|
||||
// 'panel_box_supplier' => $supplier,
|
||||
// 'panel_box_code' => $itemCode,
|
||||
@@ -766,7 +767,7 @@ class InvoiceDataTable extends Component
|
||||
// // 'scanned_quantity'=> $scannedQuantity,
|
||||
// // ]);
|
||||
|
||||
// if ($totalQuantity === $scannedQuantity) {
|
||||
// if ($totalQuantity == $scannedQuantity) {
|
||||
// Notification::make()
|
||||
// ->title('Completed: Serial Invoice')
|
||||
// ->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
|
||||
@@ -845,7 +846,7 @@ class InvoiceDataTable extends Component
|
||||
$stickerCode = $row->stickerMasterRelation?->item?->code ?? null;
|
||||
$serialNo = $row->serial_number ?? null;
|
||||
|
||||
if ($stickerCode === $this->currentItemCode && $serialNo === $this->currentSerialNumber) {
|
||||
if ($stickerCode == $this->currentItemCode && $serialNo == $this->currentSerialNumber) {
|
||||
$row['panel_box_supplier'] = $supplier;
|
||||
$row['panel_box_code'] = $itemCode;
|
||||
$row['panel_box_serial_number'] = $serialNumber;
|
||||
@@ -857,7 +858,7 @@ class InvoiceDataTable extends Component
|
||||
->where('plant_id', $this->plantId)
|
||||
->get()
|
||||
->first(function ($validation) {
|
||||
return $validation->stickerMaster?->item?->code === $this->currentItemCode;
|
||||
return $validation->stickerMaster?->item?->code == $this->currentItemCode;
|
||||
});
|
||||
|
||||
// dd($matchingValidation);
|
||||
@@ -875,7 +876,7 @@ class InvoiceDataTable extends Component
|
||||
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
// if ($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
// if ($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr) {
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -932,7 +933,7 @@ class InvoiceDataTable extends Component
|
||||
// 'scanned_quantity'=> $scannedQuantity,
|
||||
// ]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity) {
|
||||
if ($totalQuantity == $scannedQuantity) {
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
|
||||
|
||||
33
app/Livewire/Webcam.php
Normal file
33
app/Livewire/Webcam.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Webcam extends Component
|
||||
{
|
||||
|
||||
public string $capturedPhoto = '';
|
||||
|
||||
// Called from JavaScript when a photo is taken
|
||||
public function setPhoto(string $photo): void
|
||||
{
|
||||
$this->capturedPhoto = $photo;
|
||||
|
||||
// Fires a browser event that the Filament form will listen to
|
||||
$this->dispatch('photo-captured', photo: $photo);
|
||||
}
|
||||
|
||||
// Called from JavaScript when user clicks "Retake"
|
||||
public function clearPhoto(): void
|
||||
{
|
||||
$this->capturedPhoto = '';
|
||||
|
||||
$this->dispatch('photo-captured', photo: '');
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.webcam');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ class CharacteristicApprovalMail extends Mailable
|
||||
|
||||
public $subjectLine;
|
||||
|
||||
public $characteristics;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user