Compare commits
232 Commits
231b65ff7a
...
qds
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c070c9763e | ||
|
|
2116ea422e | ||
|
|
acc98ad876 | ||
|
|
45898b2fa2 | ||
|
|
390e013ccb | ||
|
|
dc9f929fa2 | ||
|
|
e58dbfbebd | ||
|
|
15af1edb8f | ||
|
|
705cc8c3a4 | ||
|
|
6e61f83e3a | ||
|
|
197184e2ed | ||
|
|
d6c77bd6c3 | ||
|
|
68d4240ab0 | ||
|
|
68ba8fa89d | ||
|
|
8c84e48f8e | ||
|
|
2e7859656a | ||
|
|
4bfbebb254 | ||
|
|
1ea00b6901 | ||
|
|
5084aa9c0e | ||
|
|
c844a23556 | ||
|
|
76649651f1 | ||
|
|
e15c866078 | ||
|
|
04af1c7c34 | ||
|
|
8871389fe3 | ||
|
|
ec2fd4d3ca | ||
|
|
5c1f77796f | ||
|
|
530bca4c4b | ||
|
|
ccceff9edc | ||
|
|
c53f40d8a0 | ||
|
|
6b67d94476 | ||
|
|
b2d2ab7e05 | ||
|
|
573b02a97a | ||
|
|
96a5dacf95 | ||
|
|
58cdcec6ed | ||
|
|
c67e8fcc59 | ||
|
|
d5588e0b25 | ||
|
|
9ff7f88840 | ||
|
|
03e53e0bb1 | ||
|
|
33b2b6399d | ||
|
|
2437bdf85f | ||
|
|
f51aea626b | ||
|
|
77129cb70b | ||
|
|
bb462a6c45 | ||
|
|
9a2a6bdd9b | ||
|
|
0a414a6804 | ||
|
|
f4bb7a7a78 | ||
|
|
8aad6cf1e6 | ||
|
|
3b18411141 | ||
|
|
162eaa0c9c | ||
|
|
d5f55fbf98 | ||
|
|
cf5cfac555 | ||
|
|
7bf2e8182b | ||
|
|
216b62f8bf | ||
|
|
cad7f19ab5 | ||
|
|
ca9695c922 | ||
|
|
d1f9a3176f | ||
|
|
0b9d0f9995 | ||
|
|
897aa77217 | ||
|
|
000533ef7c | ||
|
|
a78cb75bdd | ||
|
|
ab769d2287 | ||
|
|
0bde54cf1a | ||
|
|
48942307e1 | ||
|
|
8c5f2b5b39 | ||
|
|
b1df9f8b87 | ||
|
|
c0d13db2f3 | ||
|
|
b4bf170c89 | ||
|
|
b0d2132e25 | ||
|
|
83f98d9e83 | ||
|
|
3d84661640 | ||
|
|
26ecaf49ef | ||
|
|
5fe2b74174 | ||
|
|
ce901e3b78 | ||
|
|
31ad036d0e | ||
|
|
c363faa357 | ||
|
|
a71864905e | ||
|
|
c75ac4781f | ||
|
|
c76cf1fb98 | ||
|
|
95a4ddf11e | ||
|
|
c309bed7d9 | ||
|
|
b2dc9e7024 | ||
|
|
bff2601ddc | ||
|
|
e80812b82e | ||
|
|
81c7812ef6 | ||
|
|
14b5f4ae8b | ||
|
|
eb31e6a406 | ||
|
|
740ceff0f8 | ||
|
|
ea1261fb01 | ||
|
|
74ad73622d | ||
|
|
a62220c9d0 | ||
|
|
a5036b7d6f | ||
|
|
27b8058ba8 | ||
|
|
58091726a4 | ||
|
|
6bdd210162 | ||
|
|
b9e3d463ed | ||
|
|
418e4fcf79 | ||
|
|
33881a3978 | ||
|
|
9d4cf0e3d9 | ||
|
|
72704a4a3f | ||
|
|
a34b55267d | ||
|
|
b6dcb93402 | ||
|
|
313dc012d5 | ||
|
|
2541300910 | ||
|
|
d1894e0d35 | ||
|
|
e5143a0ce8 | ||
|
|
b1674bba53 | ||
|
|
52a25fec8e | ||
|
|
dafe1ca458 | ||
|
|
af384faa7c | ||
|
|
c6f61fa19a | ||
|
|
aaa93e740b | ||
|
|
33acf73b5e | ||
|
|
ea5af41f7f | ||
|
|
c8ea502833 | ||
|
|
7e317f6e5f | ||
|
|
1465734acd | ||
|
|
642053653c | ||
|
|
27524c4d62 | ||
|
|
9fa4c0dd49 | ||
|
|
4d5b14fe69 | ||
|
|
b4ca4a9fcd | ||
|
|
484bc6d070 | ||
|
|
b153a53f4b | ||
|
|
658dea8e72 | ||
|
|
e934cdb193 | ||
|
|
d61c61879f | ||
|
|
4b597629aa | ||
|
|
9173dcb50a | ||
|
|
4a17892865 | ||
|
|
e9d967e2c2 | ||
|
|
215e1302cc | ||
|
|
1f085b3f91 | ||
|
|
ab9c3a80db | ||
|
|
5f0c01176a | ||
|
|
b73202e03f | ||
|
|
6a8978f676 | ||
|
|
61320dfae8 | ||
|
|
7715a20c19 | ||
|
|
bb41d72701 | ||
|
|
fcb6a945ff | ||
|
|
2d2f0d3662 | ||
|
|
cb4605221c | ||
|
|
5a8775c092 | ||
|
|
bef0c986b2 | ||
|
|
80163fb0ff | ||
|
|
170b784a9b | ||
|
|
4311c64531 | ||
|
|
3c9cc702d4 | ||
|
|
752c3cb0da | ||
|
|
1597795c74 | ||
|
|
d75dcdfdd1 | ||
|
|
b8738a2f6a | ||
|
|
4ac1823e5b | ||
|
|
eb2b857aa7 | ||
|
|
693e3a23a4 | ||
|
|
49d2f1088f | ||
|
|
34b2a05166 | ||
|
|
ee99ada3e7 | ||
|
|
3665b63ff9 | ||
|
|
aeb3b694e4 | ||
|
|
a4d2c20451 | ||
|
|
15849fc543 | ||
|
|
fec85824c2 | ||
|
|
6d6d3f2d60 | ||
|
|
29de91e03d | ||
|
|
5ab109006e | ||
|
|
35aa2fab56 | ||
|
|
a87bc6e909 | ||
|
|
3818fa612e | ||
|
|
0f6b62b47a | ||
|
|
656dd17603 | ||
|
|
0c27bd4cfd | ||
|
|
c7779f49b7 | ||
|
|
49c4f25c79 | ||
|
|
f37f62be46 | ||
|
|
5465364ffd | ||
|
|
75963b3ce6 | ||
|
|
b36700af92 | ||
|
|
5a654d1d40 | ||
|
|
2f3b028b17 | ||
|
|
904d850638 | ||
|
|
f5e7bcb348 | ||
|
|
171c675014 | ||
|
|
bd5bb7f54c | ||
|
|
74c3243c06 | ||
|
|
bd0eed07ac | ||
|
|
b564e2debe | ||
|
|
4c8fa0bdd6 | ||
|
|
48ce6681ac | ||
|
|
cefebd9f86 | ||
|
|
3a0185391a | ||
|
|
c38a417b85 | ||
|
|
cfe8ac3496 | ||
|
|
be79dcdc45 | ||
|
|
9398374f88 | ||
|
|
43edf2ec5a | ||
|
|
08b142e70f | ||
|
|
de0de426f0 | ||
|
|
3eb9f64fca | ||
|
|
7ff55f0b25 | ||
|
|
3e0633def2 | ||
|
|
cea7f86fed | ||
|
|
af3ae0803c | ||
|
|
10b439f8e3 | ||
|
|
fc6b3efd0a | ||
|
|
6372e293e2 | ||
|
|
c2817aefe4 | ||
|
|
40ad560bca | ||
|
|
a5bc41beda | ||
|
|
ba48c1307e | ||
|
|
d222fe5a3b | ||
|
|
aa4cec997d | ||
|
|
c2c9470979 | ||
|
|
6ea2fc3d23 | ||
|
|
04da674868 | ||
|
|
0174a8494d | ||
|
|
bff1cb0d28 | ||
|
|
5543938eae | ||
|
|
4addab5573 | ||
|
|
000c80c1e6 | ||
|
|
aae2fafc1f | ||
|
|
e958a036c7 | ||
|
|
710ff318ef | ||
|
|
5ec4be082d | ||
|
|
955d143f52 | ||
|
|
5b287f974d | ||
|
|
f5345fc2b8 | ||
|
|
cd09b912ee | ||
|
|
008e9ff791 | ||
|
|
a0c0588e49 | ||
|
|
137341fc6c | ||
|
|
33d22dec5b |
164
app/Console/Commands/ScheduleList.php
Normal file
164
app/Console/Commands/ScheduleList.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\AlertMailRule;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
|
||||
class ScheduleList
|
||||
{
|
||||
// public function schedule(Schedule $schedule): void
|
||||
// {
|
||||
// // Invoice Report Scheduling
|
||||
// $scheduleType = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->where('rule_name', 'InvoiceMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($scheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// // case 'Daily':
|
||||
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
|
||||
// // break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
|
||||
// $SerialscheduleType = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->where('rule_name', 'SerialInvoiceMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($SerialscheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// // case 'Daily':
|
||||
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
|
||||
// // break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
// $materialscheduleType = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->where('rule_name', 'MaterialInvoiceMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($materialscheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// // case 'Daily':
|
||||
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
|
||||
// // break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
|
||||
// // Production Report Scheduling
|
||||
// $productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
// ->where('rule_name', 'ProductionMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($productionScheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:production-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:production-report')->dailyAt('07:59')->runInBackground();
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function schedule(Schedule $schedule): void
|
||||
{
|
||||
// Define the rules you want to schedule
|
||||
$rules = [
|
||||
[
|
||||
'module' => 'InvoiceValidation',
|
||||
'rule_name' => 'InvoiceMail',
|
||||
'argument' => 'InvoiceMail',
|
||||
],
|
||||
[
|
||||
'module' => 'InvoiceValidation',
|
||||
'rule_name' => 'SerialInvoiceMail',
|
||||
'argument' => 'SerialInvoiceMail',
|
||||
],
|
||||
[
|
||||
'module' => 'InvoiceValidation',
|
||||
'rule_name' => 'MaterialInvoiceMail',
|
||||
'argument' => 'MaterialInvoiceMail',
|
||||
],
|
||||
];
|
||||
|
||||
// Loop through each rule and schedule accordingly
|
||||
foreach ($rules as $rule) {
|
||||
$scheduleType = AlertMailRule::where('module', $rule['module'])
|
||||
->where('rule_name', $rule['rule_name'])
|
||||
->value('schedule_type');
|
||||
|
||||
switch ($scheduleType) {
|
||||
case 'Live':
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->everyMinute()->runInBackground();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground();
|
||||
break;
|
||||
case 'Daily':
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->dailyAt('07:59')->runInBackground();
|
||||
break;
|
||||
default:
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Production Report Scheduling
|
||||
$productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->value('schedule_type');
|
||||
|
||||
switch ($productionScheduleType) {
|
||||
case 'Live':
|
||||
$schedule->command('send:production-report')->everyMinute()->runInBackground();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
break;
|
||||
case 'Daily':
|
||||
$schedule->command('send:production-report')->dailyAt('07:59')->runInBackground();
|
||||
break;
|
||||
default:
|
||||
$schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
415
app/Console/Commands/SendInvoiceReport.php
Normal file
415
app/Console/Commands/SendInvoiceReport.php
Normal file
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\test;
|
||||
|
||||
class SendInvoiceReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report{schedule_type} {plant}';
|
||||
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
// public function handle()
|
||||
// {
|
||||
|
||||
// $schedule = $this->argument('schedule_type');
|
||||
// $plantid = $this->argument('plant');
|
||||
|
||||
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// $plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
|
||||
|
||||
// $serialTableData = [];
|
||||
// $materialTableData = [];
|
||||
// $bundleTableData = [];
|
||||
// $noSerial = 1;
|
||||
// $noMaterial = 1;
|
||||
// $noBundle = 1;
|
||||
|
||||
// foreach ($plants as $plantId) {
|
||||
// $plant = Plant::find($plantId);
|
||||
// $plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
// //..Serial Invoice
|
||||
|
||||
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $serialTableData[] = [
|
||||
// 'no' => $noSerial++,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalSerialCount,
|
||||
// 'scannedInvoice' => $scannedSerialCount,
|
||||
// ];
|
||||
|
||||
// //..Individual Invoice
|
||||
|
||||
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $materialTableData[] = [
|
||||
// 'no' => $noMaterial++,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $TotalMatCount,
|
||||
// 'scannedInvoice' => $scannedMatCount,
|
||||
// ];
|
||||
|
||||
// //..BUndle Invoice
|
||||
|
||||
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $bundleTableData[] = [
|
||||
// 'no' => $noBundle++,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalBundleCount,
|
||||
// 'scannedInvoice' => $scannedBundleCount,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// // 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, [], []));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
// if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 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));
|
||||
// }
|
||||
// }
|
||||
// //$this->info(json_encode($materialTableData));
|
||||
// }
|
||||
|
||||
// public function handle()
|
||||
// {
|
||||
// $schedule = $this->argument('schedule_type');
|
||||
// $plantId = $this->argument('plant');
|
||||
|
||||
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
// $serialTableData = [];
|
||||
// $materialTableData = [];
|
||||
// $bundleTableData = [];
|
||||
|
||||
// $plant = Plant::find($plantId);
|
||||
// $plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
// // Serial Invoice
|
||||
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $serialTableData[] = [
|
||||
// 'no' => 1,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalSerialCount,
|
||||
// 'scannedInvoice' => $scannedSerialCount,
|
||||
// ];
|
||||
|
||||
// // Individual Material Invoice
|
||||
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $materialTableData[] = [
|
||||
// 'no' => 1,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $TotalMatCount,
|
||||
// 'scannedInvoice' => $scannedMatCount,
|
||||
// ];
|
||||
|
||||
// // Bundle Invoice
|
||||
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $bundleTableData[] = [
|
||||
// 'no' => 1,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalBundleCount,
|
||||
// 'scannedInvoice' => $scannedBundleCount,
|
||||
// ];
|
||||
|
||||
// // 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, [], []));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
// if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 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));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // $this->table(
|
||||
// // ['No', 'Plant', 'Total Invoice', 'Scanned Invoice'],
|
||||
// // $serialTableData
|
||||
// // );
|
||||
// }
|
||||
public function handle()
|
||||
{
|
||||
$schedule = $this->argument('schedule_type');
|
||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
$serialTableData = [];
|
||||
$materialTableData = [];
|
||||
$bundleTableData = [];
|
||||
|
||||
// Get plant IDs: either one plant or all
|
||||
$plantIds = $plantIdArg == 0
|
||||
? InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id')->toArray()
|
||||
: [$plantIdArg];
|
||||
|
||||
$no = 1;
|
||||
if (strtolower($schedule) == '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 ($plantIds as $plantId) {
|
||||
$plant = Plant::find($plantId);
|
||||
$plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
// Serial Invoice
|
||||
$totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->distinct('invoice_number')
|
||||
->count('invoice_number');
|
||||
|
||||
$scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$serialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalSerialCount,
|
||||
'scannedInvoice' => $scannedSerialCount,
|
||||
];
|
||||
|
||||
// Material Invoice
|
||||
$totalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->distinct('invoice_number')
|
||||
->count('invoice_number');
|
||||
|
||||
$scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$materialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalMatCount,
|
||||
'scannedInvoice' => $scannedMatCount,
|
||||
];
|
||||
|
||||
// Bundle Invoice
|
||||
$totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->distinct('invoice_number')
|
||||
->count('invoice_number');
|
||||
|
||||
$scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$bundleTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalBundleCount,
|
||||
'scannedInvoice' => $scannedBundleCount,
|
||||
];
|
||||
|
||||
$no++;
|
||||
}
|
||||
|
||||
// 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, [], []));
|
||||
}
|
||||
}
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||
}
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
// Show preview in console
|
||||
$this->info('--- Serial Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
|
||||
|
||||
$this->info('--- Material Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
|
||||
|
||||
$this->info('--- Bundle Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
251
app/Console/Commands/SendProductionReport.php
Normal file
251
app/Console/Commands/SendProductionReport.php
Normal file
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ProductionMail;
|
||||
use App\Models\Line;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use DB;
|
||||
|
||||
class SendProductionReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
//protected $signature = 'send:production-report';
|
||||
protected $signature = 'send:production-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 = $this->argument('plant');
|
||||
|
||||
// $mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
||||
// ->where('rule_name', 'ProductionMail')
|
||||
// ->where('plant', $plantId)
|
||||
// ->where('schedule_type', $scheduleType)
|
||||
// ->get();
|
||||
|
||||
// $emails = $mailRules->pluck('email')->unique()->toArray();
|
||||
|
||||
// $plant = Plant::find($plantId);
|
||||
|
||||
// if (!$plant) {
|
||||
// $this->error("Invalid plant ID: $plantId");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $lines = Line::where('plant_id', $plantId)->get();
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
// $PlanstartDate = now()->setTime(8, 0, 0);
|
||||
// $planendDate = now()->copy()->addDay()->setTime(7, 59, 00);
|
||||
|
||||
// $tableData = [];
|
||||
// $no = 1;
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
// $lineId = $line->id;
|
||||
// $lineName = $line->name;
|
||||
|
||||
// $targetQuantity = ProductionPlan::where('plant_id', $plantId)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
// ->sum('plan_quantity');
|
||||
|
||||
// $productionQuantity = ProductionQuantity::where('plant_id', $plantId)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $tableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $lineName,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $productionQuantity,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// // $this->table(
|
||||
// // ['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'],
|
||||
// // $tableData
|
||||
// // );
|
||||
|
||||
// if (!empty($emails)) {
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new ProductionMail($tableData));
|
||||
// }
|
||||
// } else {
|
||||
// $this->info('No recipients found for ProductionMailAlert.');
|
||||
// }
|
||||
|
||||
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
|
||||
// }
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant'); // cast to int for safety
|
||||
|
||||
// Fetch mail rules based on schedule type
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->get();
|
||||
|
||||
$emails = $mailRules->pluck('email')->unique()->toArray();
|
||||
|
||||
$plants = $plantId == 0
|
||||
? Plant::all()
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error("No valid plant(s) found.");
|
||||
return;
|
||||
}
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
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);
|
||||
}
|
||||
|
||||
$PlanstartDate = now()->setTime(8, 0, 0);
|
||||
$planendDate = now()->copy()->addDay()->setTime(7, 59, 0);
|
||||
|
||||
$tableData = [];
|
||||
$no = 1;
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
// $targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
// ->sum('plan_quantity');
|
||||
|
||||
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $tableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $productionQuantity,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// $fgTableData = []; // store FG Line related data
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// // ✅ Only get FG Lines
|
||||
// $fgLines = Line::where('plant_id', $plant->id)
|
||||
// ->where('type', 'FG Line')
|
||||
// ->get();
|
||||
|
||||
// foreach ($fgLines as $line) {
|
||||
// $validationCount = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $fgTableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $validationCount,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
//..
|
||||
|
||||
//.
|
||||
|
||||
foreach ($plants as $plant)
|
||||
{
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
->sum('plan_quantity');
|
||||
|
||||
if (strtolower($line->type) == 'fg line') {
|
||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
} else {
|
||||
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
}
|
||||
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
'line' => $line->name,
|
||||
'type' => $line->type,
|
||||
'targetQuantity' => $targetQuantity,
|
||||
'productionQuantity' => $productionQuantity,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
|
||||
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
|
||||
if (!empty($emails)) {
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new ProductionMail($tableData));
|
||||
}
|
||||
} else {
|
||||
$this->info('No recipients found for ProductionMailAlert.');
|
||||
}
|
||||
|
||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
54
app/Filament/Exports/DeviceMasterExporter.php
Normal file
54
app/Filament/Exports/DeviceMasterExporter.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\DeviceMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class DeviceMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = DeviceMaster::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('DEVICE NAME'),
|
||||
ExportColumn::make('mac_address')
|
||||
->label('MAC ADDRESS'),
|
||||
ExportColumn::make('ip_address')
|
||||
->label('IP ADDRESS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your device 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;
|
||||
}
|
||||
}
|
||||
140
app/Filament/Exports/EbReadingExporter.php
Normal file
140
app/Filament/Exports/EbReadingExporter.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\EbReading;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class EbReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = EbReading::class;
|
||||
static $rowNumber = 0;
|
||||
public static function getColumns(): array
|
||||
{
|
||||
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('lcd_segment_check')
|
||||
->label('LCD SEGMENT CHECK'),
|
||||
ExportColumn::make('meter_serial_no')
|
||||
->label('METER SERIAL NO'),
|
||||
ExportColumn::make('eb_date_time')
|
||||
->label('EB DATE TIME'),
|
||||
ExportColumn::make('ph_seq_of_volt')
|
||||
->label('PH SEQ OF VOLT'),
|
||||
ExportColumn::make('ph_assoc_conn_check')
|
||||
->label('PH ASSOC CONN CHECK'),
|
||||
ExportColumn::make('instantaneous_ph_volt')
|
||||
->label('INSTANTANEOUS PH VOLT'),
|
||||
ExportColumn::make('instantaneous_curr')
|
||||
->label('INSTANTANEOUS CURR'),
|
||||
ExportColumn::make('instantaneous_freq')
|
||||
->label('INSTANTANEOUS FREQ'),
|
||||
ExportColumn::make('instantaneous_kw_with_sign')
|
||||
->label('INSTANTANEOUS KW WITH SIGN'),
|
||||
ExportColumn::make('instantaneous_kva')
|
||||
->label('INSTANTANEOUS KVA'),
|
||||
ExportColumn::make('instantaneous_kv_ar')
|
||||
->label('INSTANTANEOUS KV AR'),
|
||||
ExportColumn::make('instantaneous_pf_with_sign')
|
||||
->label('INSTANTANEOUS PF WITH SIGN'),
|
||||
ExportColumn::make('rd_with_elapsed_time_kva')
|
||||
->label('RD WITH ELAPSED TIME KVA'),
|
||||
ExportColumn::make('cum_active_import_energy')
|
||||
->label('CUM ACTIVE IMPORT ENERGY'),
|
||||
ExportColumn::make('tod1_active_energy_6_9')
|
||||
->label('TOD1 ACTIVE ENERGY 6-9'),
|
||||
ExportColumn::make('tod2_active_energy_18_21')
|
||||
->label('TOD2 ACTIVE ENERGY 18-21'),
|
||||
ExportColumn::make('tod3_active_energy_21_22')
|
||||
->label('TOD3 ACTIVE ENERGY 21-22'),
|
||||
ExportColumn::make('tod4_active_energy_5_6_9_18')
|
||||
->label('TOD4 ACTIVE ENERGY 5-6-9-18'),
|
||||
ExportColumn::make('tod5_active_energy_22_5')
|
||||
->label('TOD5 ACTIVE ENERGY 22-5'),
|
||||
ExportColumn::make('cum_reac_lag_energy')
|
||||
->label('CUM REAC LAG ENERGY'),
|
||||
ExportColumn::make('cum_reac_lead_energy')
|
||||
->label('CUM REAC LEAD ENERGY'),
|
||||
ExportColumn::make('cum_appar_energy')
|
||||
->label('CUM APPAR ENERGY'),
|
||||
ExportColumn::make('tod1_appar_energy_6_9')
|
||||
->label('TOD1 APPAR ENERGY 6-9'),
|
||||
ExportColumn::make('tod2_appar_energy_18_21')
|
||||
->label('TOD2 APPAR ENERGY 18-21'),
|
||||
ExportColumn::make('tod3_appar_energy_21_22')
|
||||
->label('TOD3 APPAR ENERGY 21-22'),
|
||||
ExportColumn::make('tod4_appar_energy_5_6_9_18')
|
||||
->label('TOD4 APPAR ENERGY 5-6-9-18'),
|
||||
ExportColumn::make('tod5_appar_energy_22_5')
|
||||
->label('TOD5 APPAR ENERGY 22-5'),
|
||||
ExportColumn::make('avg_pow_factor')
|
||||
->label('AVG POW FACTOR'),
|
||||
ExportColumn::make('avg_freq_15min_last_ip')
|
||||
->label('AVG FREQ 15MIN LAST IP'),
|
||||
ExportColumn::make('net_kv_arh_high')
|
||||
->label('NET KV ARH HIGH'),
|
||||
ExportColumn::make('net_kv_arh_low')
|
||||
->label('NET KV ARH LOW'),
|
||||
ExportColumn::make('cum_md_kva')
|
||||
->label('CUM MD KVA'),
|
||||
ExportColumn::make('present_md_kva')
|
||||
->label('PRESENT MD KVA'),
|
||||
ExportColumn::make('present_md_kva_date_time')
|
||||
->label('PRESENT MD KVA DATE TIME'),
|
||||
ExportColumn::make('tod1_md_kva_6_9')
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
ExportColumn::make('tod2_md_kva_18_21')
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
ExportColumn::make('tod3_md_kva_21_22')
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
ExportColumn::make('tod4_md_kva_5_6_9_18')
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
ExportColumn::make('tod5_md_kva_22_5')
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
ExportColumn::make('total_pow_off_hours')
|
||||
->label('TOTAL POW OFF HOURS'),
|
||||
ExportColumn::make('programming_count')
|
||||
->label('PROGRAMMING COUNT'),
|
||||
ExportColumn::make('last_occ_res_event_type')
|
||||
->label('LAST OCC RES EVENT TYPE'),
|
||||
ExportColumn::make('last_occ_res_event_date_time')
|
||||
->label('LAST OCC RES EVENT DATE TIME'),
|
||||
ExportColumn::make('tamper_count')
|
||||
->label('TAMPER COUNT'),
|
||||
ExportColumn::make('reset_count')
|
||||
->label('RESET COUNT'),
|
||||
ExportColumn::make('last_md_reset_date_time')
|
||||
->label('LAST MD RESET DATE TIME'),
|
||||
ExportColumn::make('electrician_sign')
|
||||
->label('ELECTRICIAN SIGN'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your eb 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 LineExporter extends Exporter
|
||||
->label('NAME'),
|
||||
ExportColumn::make('type')
|
||||
->label('TYPE'),
|
||||
ExportColumn::make('group_work_center')
|
||||
->label('GROUP WORK CENTER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
|
||||
@@ -24,8 +24,8 @@ class LocatorExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('locator_number')
|
||||
->label('LOCATOR NUMBER'),
|
||||
ExportColumn::make('locator_quantity')
|
||||
|
||||
@@ -23,8 +23,8 @@ class LocatorInvoiceValidationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
|
||||
@@ -13,25 +13,30 @@ class MachineExporter extends Exporter
|
||||
|
||||
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;
|
||||
}),
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('Plant'),
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('Line'),
|
||||
->label('LINE'),
|
||||
ExportColumn::make('name')
|
||||
->label('Name'),
|
||||
->label('MACHINE'),
|
||||
ExportColumn::make('work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('Created At'),
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('Updated At'),
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('Deleted At'),
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
54
app/Filament/Exports/MfmMeterExporter.php
Normal file
54
app/Filament/Exports/MfmMeterExporter.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\MfmMeter;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MfmMeterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = MfmMeter::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('device.name')
|
||||
->label('DEVICE NAME'),
|
||||
ExportColumn::make('sequence')
|
||||
->label('SEQUENCE'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your mfm meter 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;
|
||||
}
|
||||
}
|
||||
63
app/Filament/Exports/MfmParameterExporter.php
Normal file
63
app/Filament/Exports/MfmParameterExporter.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\MfmParameter;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MfmParameterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = MfmParameter::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('deviceName.name')
|
||||
->label('Device Name'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('mfmMeter.name')
|
||||
->label('MFM METER'),
|
||||
ExportColumn::make('register_id')
|
||||
->label('REGISTER ID'),
|
||||
ExportColumn::make('identifier')
|
||||
->label('IDENTIFIER'),
|
||||
ExportColumn::make('byte_to_convert')
|
||||
->label('BYTE TO CONVERT'),
|
||||
ExportColumn::make('type_to_convert')
|
||||
->label('TYPE TO CONVERT'),
|
||||
ExportColumn::make('decimal_to_display')
|
||||
->label('DECIMAL TO DISPLAY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your mfm parameter 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;
|
||||
}
|
||||
}
|
||||
92
app/Filament/Exports/MfmReadingExporter.php
Normal file
92
app/Filament/Exports/MfmReadingExporter.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\MfmReading;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MfmReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = MfmReading::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('mfmMeter.name')
|
||||
->label('MFM METER NAME'),
|
||||
ExportColumn::make('apparent_energy_received')
|
||||
->label('APPARENT ENERGY RECEIVED'),
|
||||
ExportColumn::make('reactive_energy_received')
|
||||
->label('REACTIVE ENERGY RECEIVED'),
|
||||
ExportColumn::make('active_energy_received')
|
||||
->label('ACTIVE ENERGY RECEIVED'),
|
||||
ExportColumn::make('active_power_r')
|
||||
->label('ACTIVE POWER R'),
|
||||
ExportColumn::make('active_power_y')
|
||||
->label('ACTIVE POWER Y'),
|
||||
ExportColumn::make('active_power_b')
|
||||
->label('ACTIVE POWER B'),
|
||||
ExportColumn::make('active_power_total')
|
||||
->label('ACTIVE POWER TOTAL'),
|
||||
ExportColumn::make('voltage_ry')
|
||||
->label('VOLTAGE RY'),
|
||||
ExportColumn::make('voltage_yb')
|
||||
->label('VOLTAGE YB'),
|
||||
ExportColumn::make('voltage_br')
|
||||
->label('VOLTAGE BR'),
|
||||
ExportColumn::make('current_r')
|
||||
->label('CURRENT R'),
|
||||
ExportColumn::make('current_y')
|
||||
->label('CURRENT Y'),
|
||||
ExportColumn::make('current_b')
|
||||
->label('CURRENT B'),
|
||||
ExportColumn::make('current_n')
|
||||
->label('CURRENT N'),
|
||||
ExportColumn::make('voltage_r_n')
|
||||
->label('VOLTAGE R N'),
|
||||
ExportColumn::make('voltage_y_n')
|
||||
->label('VOLTAGE Y N'),
|
||||
ExportColumn::make('voltage_b_n')
|
||||
->label('VOLTAGE B N'),
|
||||
ExportColumn::make('frequency')
|
||||
->label('FREQUENCY'),
|
||||
ExportColumn::make('power_factor_r')
|
||||
->label('POWER FACTOR R'),
|
||||
ExportColumn::make('power_factor_y')
|
||||
->label('POWER FACTOR Y'),
|
||||
ExportColumn::make('power_factor_b')
|
||||
->label('POWER FACTOR B'),
|
||||
ExportColumn::make('power_factor_total')
|
||||
->label('POWER FACTOR TOTAL'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your mfm 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;
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@ class PalletValidationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('pallet_number')
|
||||
->label('PALLET NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
|
||||
@@ -24,8 +24,8 @@ class ReworkLocatorInvoiceValidationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
|
||||
@@ -64,14 +64,18 @@ class StickerMasterExporter extends Exporter
|
||||
->label('PART VALIDATION 4'),
|
||||
ExportColumn::make('part_validation5')
|
||||
->label('PART VALIDATION 5'),
|
||||
ExportColumn::make('laser_part_validation1')
|
||||
->label('LASER PART VALIDATION 1'),
|
||||
ExportColumn::make('laser_part_validation2')
|
||||
->label('LASER PART VALIDATION 2'),
|
||||
ExportColumn::make('panel_box_code')
|
||||
->label('PANEL BOX CODE'),
|
||||
ExportColumn::make('load_rate')
|
||||
->label('LOAD RATE'),
|
||||
ExportColumn::make('bundle_quantity')
|
||||
->label('BUNDLE QUANTITY'),
|
||||
ExportColumn::make('material_type')
|
||||
->label('MATERIAL TYPE'),
|
||||
ExportColumn::make('bundle_quantity')
|
||||
->label('BUNDLE QUANTITY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
|
||||
51
app/Filament/Exports/TempLiveReadingExporter.php
Normal file
51
app/Filament/Exports/TempLiveReadingExporter.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\TempLiveReading;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class TempLiveReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = TempLiveReading::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('mfmMeter.name')
|
||||
->label('MFM METER NAME'),
|
||||
ExportColumn::make('register_data')
|
||||
->label('REGISTER DATA'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your temp live 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;
|
||||
}
|
||||
}
|
||||
@@ -126,10 +126,6 @@ class TestingPanelReadingExporter extends Exporter
|
||||
->label('UPDATE COUNT'),
|
||||
ExportColumn::make('output_flag')
|
||||
->label('OUTPUT FLAG'),
|
||||
ExportColumn::make('pds_status')
|
||||
->label('PDS STATUS'),
|
||||
ExportColumn::make('pds_description')
|
||||
->label('PDS DESCRIPTION'),
|
||||
ExportColumn::make('tested_by')
|
||||
->label('TESTED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
|
||||
70
app/Filament/Imports/DeviceMasterImporter.php
Normal file
70
app/Filament/Imports/DeviceMasterImporter.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\DeviceMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class DeviceMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = DeviceMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Device Name')
|
||||
->label('Device Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mac_address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('MAC Address')
|
||||
->example('00:1A:2B:3C:4D:5E')
|
||||
->label('MAC Address')
|
||||
->rules(['required', 'mac_address']),
|
||||
ImportColumn::make('ip_address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('IP Address')
|
||||
->label('IP Address')
|
||||
->example('172.31.76.67')
|
||||
->rules(['required', 'ip']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?DeviceMaster
|
||||
{
|
||||
// return DeviceMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new DeviceMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your device 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;
|
||||
}
|
||||
}
|
||||
243
app/Filament/Imports/EbReadingImporter.php
Normal file
243
app/Filament/Imports/EbReadingImporter.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\EbReading;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class EbReadingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = EbReading::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lcd_segment_check')
|
||||
->label('LCD Segment Check')
|
||||
->example('Ok')
|
||||
->exampleHeader('LCD Segment Check'),
|
||||
ImportColumn::make('meter_serial_no')
|
||||
->label('Meter Serial No')
|
||||
->example('572880')
|
||||
->exampleHeader('Meter Serial No'),
|
||||
ImportColumn::make('eb_date_time')
|
||||
->label('EB Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->exampleHeader('EB Date Time')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('ph_seq_of_volt')
|
||||
->label('Phase Sequence of Volt')
|
||||
->example('RYB')
|
||||
->exampleHeader('Phase Sequence of Volt'),
|
||||
ImportColumn::make('ph_assoc_conn_check')
|
||||
->example('GOOD')
|
||||
->exampleHeader('Phase Associated Connection Check')
|
||||
->label('Phase Associated Connection Check'),
|
||||
ImportColumn::make('instantaneous_ph_volt')
|
||||
->exampleHeader('Instantaneous Phase Volt')
|
||||
->example('64.35,64.91,64.93')
|
||||
->label('Instantaneous Phase Volt'),
|
||||
ImportColumn::make('instantaneous_curr')
|
||||
->exampleHeader('Instantaneous Current')
|
||||
->example('1.02,1.00,0.94')
|
||||
->label('Instantaneous Current'),
|
||||
ImportColumn::make('instantaneous_freq')
|
||||
->exampleHeader('Instantaneous Frequency')
|
||||
->example('50.07')
|
||||
->label('Instantaneous Frequency'),
|
||||
ImportColumn::make('instantaneous_kw_with_sign')
|
||||
->exampleHeader('Instantaneous KW with Sign')
|
||||
->example('0.176')
|
||||
->label('Instantaneous KW with Sign'),
|
||||
ImportColumn::make('instantaneous_kva')
|
||||
->exampleHeader('Instantaneous KVA')
|
||||
->example('0.176')
|
||||
->label('Instantaneous KVA'),
|
||||
ImportColumn::make('instantaneous_kv_ar')
|
||||
->exampleHeader('Instantaneous KV AR')
|
||||
->example('0.02')
|
||||
->label('Instantaneous KV AR'),
|
||||
ImportColumn::make('instantaneous_pf_with_sign')
|
||||
->exampleHeader('Instantaneous PF with Sign')
|
||||
->example('0.99')
|
||||
->label('Instantaneous PF with Sign'),
|
||||
ImportColumn::make('rd_with_elapsed_time_kva')
|
||||
->exampleHeader('RD with Elapsed Time KVA')
|
||||
->example('0.047')
|
||||
->label('RD with Elapsed Time KVA'),
|
||||
ImportColumn::make('cum_active_import_energy')
|
||||
->exampleHeader('Cumulative Active Import Energy')
|
||||
->example('13246.46')
|
||||
->label('Cumulative Active Import Energy'),
|
||||
ImportColumn::make('tod1_active_energy_6_9')
|
||||
->exampleHeader('TOD1 Active Energy 6-9')
|
||||
->example('1367.75')
|
||||
->label('TOD1 Active Energy 6-9'),
|
||||
ImportColumn::make('tod2_active_energy_18_21')
|
||||
->exampleHeader('TOD2 Active Energy 18-21')
|
||||
->example('1759.08')
|
||||
->label('TOD2 Active Energy 18-21'),
|
||||
ImportColumn::make('tod3_active_energy_21_22')
|
||||
->exampleHeader('TOD3 Active Energy 21-22')
|
||||
->example('457.67')
|
||||
->label('TOD3 Active Energy 21-22'),
|
||||
ImportColumn::make('tod4_active_energy_5_6_9_18')
|
||||
->exampleHeader('TOD4 Active Energy 5-6-9-18')
|
||||
->example('6253.85')
|
||||
->label('TOD4 Active Energy 5-6-9-18'),
|
||||
ImportColumn::make('tod5_active_energy_22_5')
|
||||
->exampleHeader('TOD5 Active Energy 22-5')
|
||||
->example('3408.11')
|
||||
->label('TOD5 Active Energy 22-5'),
|
||||
ImportColumn::make('cum_reac_lag_energy')
|
||||
->exampleHeader('Cumulative Reactive Lag Energy')
|
||||
->example('685.11')
|
||||
->label('Cumulative Reactive Lag Energy'),
|
||||
ImportColumn::make('cum_reac_lead_energy')
|
||||
->exampleHeader('Cumulative Reactive Lead Energy')
|
||||
->example('426.1')
|
||||
->label('Cumulative Reactive Lead Energy'),
|
||||
ImportColumn::make('cum_appar_energy')
|
||||
->exampleHeader('Cumulative Apparent Energy')
|
||||
->example('13306.57')
|
||||
->label('Cumulative Apparent Energy'),
|
||||
ImportColumn::make('tod1_appar_energy_6_9')
|
||||
->exampleHeader('TOD1 Apparent Energy 6-9')
|
||||
->example('1374.63')
|
||||
->label('TOD1 Apparent Energy 6-9'),
|
||||
ImportColumn::make('tod2_appar_energy_18_21')
|
||||
->exampleHeader('TOD2 Apparent Energy 18-21')
|
||||
->example('1766.61')
|
||||
->label('TOD2 Apparent Energy 18-21'),
|
||||
ImportColumn::make('tod3_appar_energy_21_22')
|
||||
->exampleHeader('TOD3 Apparent Energy 21-22')
|
||||
->example('459.47')
|
||||
->label('TOD3 Apparent Energy 21-22'),
|
||||
ImportColumn::make('tod4_appar_energy_5_6_9_18')
|
||||
->exampleHeader('TOD4 Apparent Energy 5-6-9-18')
|
||||
->example('6283.28')
|
||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
||||
ImportColumn::make('tod5_appar_energy_22_5')
|
||||
->exampleHeader('TOD5 Apparent Energy 22-5')
|
||||
->example('3422.56')
|
||||
->label('TOD5 Apparent Energy 22-5'),
|
||||
ImportColumn::make('avg_pow_factor')
|
||||
->exampleHeader('Average Power Factor')
|
||||
->example('0.98')
|
||||
->label('Average Power Factor'),
|
||||
ImportColumn::make('avg_freq_15min_last_ip')
|
||||
->exampleHeader('Average Frequency 15min Last IP')
|
||||
->example('50')
|
||||
->label('Average Frequency 15min Last IP'),
|
||||
ImportColumn::make('net_kv_arh_high')
|
||||
->exampleHeader('Net KV ARH High')
|
||||
->example('2.99')
|
||||
->label('Net KV ARH High'),
|
||||
ImportColumn::make('net_kv_arh_low')
|
||||
->exampleHeader('Net KV ARH Low')
|
||||
->example('143.14')
|
||||
->label('Net KV ARH Low'),
|
||||
ImportColumn::make('cum_md_kva')
|
||||
->exampleHeader('Cumulative MD KVA')
|
||||
->example('43.816')
|
||||
->label('Cumulative MD KVA'),
|
||||
ImportColumn::make('present_md_kva')
|
||||
->exampleHeader('Present MD KVA')
|
||||
->example('0.379')
|
||||
->label('Present MD KVA'),
|
||||
ImportColumn::make('present_md_kva_date_time')
|
||||
->label('Present MD KVA Date Time')
|
||||
->exampleHeader('Present MD KVA Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('tod1_md_kva_6_9')
|
||||
->exampleHeader('TOD1 MD KVA 6-9')
|
||||
->example('0.282')
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
ImportColumn::make('tod2_md_kva_18_21')
|
||||
->exampleHeader('TOD2 MD KVA 18-21')
|
||||
->example('0.268')
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
ImportColumn::make('tod3_md_kva_21_22')
|
||||
->exampleHeader('TOD3 MD KVA 21-22')
|
||||
->example('0')
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
ImportColumn::make('tod4_md_kva_5_6_9_18')
|
||||
->exampleHeader('TOD4 MD KVA 5-6-9-18')
|
||||
->example('0.379')
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
ImportColumn::make('tod5_md_kva_22_5')
|
||||
->exampleHeader('TOD5 MD KVA 22-5')
|
||||
->example('0.379')
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
ImportColumn::make('total_pow_off_hours')
|
||||
->exampleHeader('Total Power Off Hours')
|
||||
->example('6480.56')
|
||||
->label('Total Power Off Hours'),
|
||||
ImportColumn::make('programming_count')
|
||||
->exampleHeader('Programming Count')
|
||||
->example('3')
|
||||
->label('Programming Count'),
|
||||
ImportColumn::make('last_occ_res_event_type')
|
||||
->exampleHeader('Last Occurrence/Reset Event Type')
|
||||
->example('-')
|
||||
->label('Last Occurrence/Reset Event Type'),
|
||||
ImportColumn::make('last_occ_res_event_date_time')
|
||||
->label('Last Occurrence/Reset Event Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->exampleHeader('Last Occurrence/Reset Event Date Time')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('tamper_count')
|
||||
->exampleHeader('Tamper Count')
|
||||
->example('24')
|
||||
->label('Tamper Count'),
|
||||
ImportColumn::make('reset_count')
|
||||
->exampleHeader('Reset Count')
|
||||
->example('108')
|
||||
->label('Reset Count'),
|
||||
ImportColumn::make('last_md_reset_date_time')
|
||||
->exampleHeader('Last MD Reset Date Time')
|
||||
->example('2025-08-05 08:32:58')
|
||||
->label('Last MD Reset Date Time')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('electrician_sign')
|
||||
->exampleHeader('Electrician Sign')
|
||||
->example('Admin')
|
||||
->label('Electrician Sign'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?EbReading
|
||||
{
|
||||
// return EbReading::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new EbReading();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your eb reading 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;
|
||||
}
|
||||
}
|
||||
@@ -59,17 +59,19 @@ class ItemImporter extends Importer
|
||||
public function resolveRecord(): ?Item
|
||||
{
|
||||
$warnMsg = [];
|
||||
$iCode = trim($this->data['code']);
|
||||
$description = trim($this->data['description']);
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
|
||||
if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
// if (Str::length($this->data['uom']) <= 0) {
|
||||
// $warnMsg[] = "Invalid unit of measure found";
|
||||
// }
|
||||
if (Str::length($this->data['description']) < 5) {
|
||||
if (Str::length($description) < 5) {
|
||||
$warnMsg[] = "Invalid description found";
|
||||
}
|
||||
if (Str::length($this->data['hourly_quantity']) < 0 || !is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
|
||||
@@ -79,14 +81,14 @@ class ItemImporter extends Importer
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return Item::updateOrCreate([
|
||||
'code' => $this->data['code'],
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'category' => $this->data['category'],
|
||||
'description' => $this->data['description'],
|
||||
'category' => trim($this->data['category']),
|
||||
'description' => $description,
|
||||
'hourly_quantity' => $this->data['hourly_quantity'],
|
||||
'uom' => $this->data['uom']
|
||||
'uom' => trim($this->data['uom'])
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
|
||||
@@ -29,6 +29,11 @@ class LineImporter extends Importer
|
||||
->example('Domestic Assembly')
|
||||
->label('Line Type')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('group_work_center')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Group Work Center')
|
||||
->example('RMGCEABC')
|
||||
->label('Group Work Center'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
@@ -60,7 +65,8 @@ class LineImporter extends Importer
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'type' => $this->data['type']
|
||||
'type' => $this->data['type'],
|
||||
'group_work_center' => $this->data['group_work_center']
|
||||
]
|
||||
);
|
||||
// return Line::firstOrNew([
|
||||
|
||||
@@ -3,9 +3,15 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Locator;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
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 LocatorImporter extends Importer
|
||||
{
|
||||
@@ -17,36 +23,93 @@ class LocatorImporter extends Importer
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Locator Number')
|
||||
->example(['W01-A1A'])
|
||||
->label('Locator Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('locator_quantity')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Locator Quantity')
|
||||
->example(['0'])
|
||||
->label('Locator Quantity')
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example(['Admin'])
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant_id')
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship('plant', 'name')
|
||||
->exampleHeader('Plant')
|
||||
->label('Plant')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000'])
|
||||
->label('Plant Code')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?Locator
|
||||
{
|
||||
// return Locator::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$user = null;
|
||||
$locator = $this->data['locator_number'];
|
||||
// $locatorQuantity = $this->data['locator_quantity'];
|
||||
$palletQuantity = 0;
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$user = Filament::auth()->user()->name;
|
||||
if (Str::length($locator) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
else {
|
||||
// $locat = Locator::where('name', $locator)->where('plant_id', $plant->id)->first();
|
||||
$palletQuantity = PalletValidation::where('locator_number', $locator)->where('plant_id', $plant->id)->distinct('pallet_number')->count('pallet_number');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Locator();
|
||||
// if (Str::length($locatorQuantity) < 0 || !is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
// $user = User::where('name', $user)->first();
|
||||
// if (!$user) {
|
||||
// $warnMsg[] = "Operator ID not found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
Locator::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'locator_number' => $locator
|
||||
],
|
||||
[
|
||||
'locator_quantity' => $palletQuantity,
|
||||
'operator_id' => $user
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return Locator::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new Locator();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -3,9 +3,15 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
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 LocatorInvoiceValidationImporter extends Importer
|
||||
{
|
||||
@@ -16,10 +22,10 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
@@ -34,56 +40,222 @@ class LocatorInvoiceValidationImporter extends Importer
|
||||
->label('Serial Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('pallet_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Pallet Number')
|
||||
->example('EP-2506001')
|
||||
->label('Pallet Number'),
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Locator Number')
|
||||
->example('W05-D1B')
|
||||
->label('Locator Number'),
|
||||
ImportColumn::make('scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned Status')
|
||||
->example('')
|
||||
->label('Scanned Status'),
|
||||
ImportColumn::make('upload_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Upload Status')
|
||||
->example('Y')
|
||||
->label('Upload Status'),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created At')
|
||||
->example('2025-06-17 01:42:16')
|
||||
->label('Created At')
|
||||
->rules(['date_format:Y-m-d H:i:s']),
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Scanned At')
|
||||
->rules(['date_format:Y-m-d H:i:s']),
|
||||
->label('Scanned At'),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Updated At'),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created by')
|
||||
->example('RAW002365')
|
||||
->example('RAW012345')
|
||||
->label('Created by')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned by')
|
||||
->example('')
|
||||
->example('RAW012345')
|
||||
->label('Scanned by'),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated by')
|
||||
->example('')
|
||||
->example('RAW012345')
|
||||
->label('Updated by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?LocatorInvoiceValidation
|
||||
{
|
||||
// return LocatorInvoiceValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$invoiceNo = $this->data['invoice_number'];
|
||||
$serialNo = $this->data['serial_number'];
|
||||
$palletNo = $this->data['pallet_number'];
|
||||
$locatorNo = $this->data['locator_number'];
|
||||
$scannedStat = $this->data['scanned_status'];
|
||||
$uploadStat = $this->data['upload_status'];
|
||||
$createdAt = $this->data['created_at'];
|
||||
$scannedAt = $this->data['scanned_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
$cDateTime = null;
|
||||
$sDateTime = null;
|
||||
$uDateTime = null;
|
||||
$createdBy = $this->data['created_by'];
|
||||
$scannedBy = $this->data['scanned_by'];
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
|
||||
return new LocatorInvoiceValidation();
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if (Str::length($scannedStat) > 0 && $scannedStat != 'Scanned') {
|
||||
$warnMsg[] = "Invalid scanned status found";
|
||||
}
|
||||
if ($uploadStat != 'Y' && $uploadStat != 'N') {
|
||||
$warnMsg[] = "Invalid upload status found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
if (Str::length($scannedBy) > 0) {
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
}
|
||||
if (Str::length($updatedBy) > 0) {
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (Str::length($scannedAt) > 0)
|
||||
{
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($sDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($updatedAt) > 0)
|
||||
{
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
LocatorInvoiceValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo
|
||||
],
|
||||
[
|
||||
'invoice_number' => $invoiceNo,
|
||||
'pallet_number' => $palletNo,
|
||||
'locator_number' => $locatorNo,
|
||||
'scanned_status' => $scannedStat,
|
||||
'upload_status' => $uploadStat,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'scanned_at' => (Str::length($scannedAt) > 0) ? $sDateTime->format('Y-m-d H:i:s') : null,
|
||||
'updated_at' => (Str::length($updatedAt) > 0) ? $uDateTime->format('Y-m-d H:i:s') : null,
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return LocatorInvoiceValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new LocatorInvoiceValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class MachineImporter extends Importer
|
||||
{
|
||||
@@ -14,13 +18,17 @@ class MachineImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I'])
|
||||
->label('Plant')
|
||||
->exampleHeader('Machine')
|
||||
->example(['1600251'])
|
||||
->label('Machine')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('work_center')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->example('RMGCE001')
|
||||
->label('Work Center'),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
@@ -28,23 +36,66 @@ class MachineImporter extends Importer
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Name')
|
||||
->example(['1600251'])
|
||||
->label('Line')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I'])
|
||||
->label('Plant')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?Machine
|
||||
{
|
||||
// return Machine::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$machine = $this->data['name'];
|
||||
$workCenter = $this->data['work_center'];
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
if ($line) {
|
||||
$grpWrkCnr = $line->group_work_center;
|
||||
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||
{
|
||||
$warnMsg[] = "Group work center line not found";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
}
|
||||
|
||||
return new Machine();
|
||||
if (Str::length($machine) <= 0) {
|
||||
$warnMsg[] = "Machine name not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
Machine::updateOrCreate(
|
||||
[
|
||||
'name' => $machine,
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id
|
||||
],
|
||||
[
|
||||
'work_center' => $workCenter
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return Machine::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new Machine();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
72
app/Filament/Imports/MfmMeterImporter.php
Normal file
72
app/Filament/Imports/MfmMeterImporter.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\MfmMeter;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class MfmMeterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = MfmMeter::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('devicemaster')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Device Name')
|
||||
->example('REG001')
|
||||
->label('Device Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sequence')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Sequence')
|
||||
->example('1')
|
||||
->label('Sequence')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Meter Name')
|
||||
->example('Display SSB')
|
||||
->label('Meter Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?MfmMeter
|
||||
{
|
||||
// return MfmMeter::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmMeter();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your mfm meter 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;
|
||||
}
|
||||
}
|
||||
98
app/Filament/Imports/MfmParameterImporter.php
Normal file
98
app/Filament/Imports/MfmParameterImporter.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\MfmParameter;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class MfmParameterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = MfmParameter::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('deviceName')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Device Name')
|
||||
->example('REG001')
|
||||
->label('Device Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mfmMeter')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mfm Meter Sequence')
|
||||
->example('1')
|
||||
->label('Mfm Meter Sequence')
|
||||
->relationship(resolveUsing:'sequence')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Parameter Name')
|
||||
->example('apparent_energy_received')
|
||||
->label('Parameter Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('register_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Register ID')
|
||||
->example('2715')
|
||||
->label('Register ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('identifier')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Identifier')
|
||||
->example('Kvah')
|
||||
->label('Identifier')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('byte_to_convert')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Byte To Convert')
|
||||
->example('1')
|
||||
->label('Byte To Convert')
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('type_to_convert')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Type To Convert')
|
||||
->example('FLOAT32')
|
||||
->label('Type To Convert')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('decimal_to_display')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Decimal To Display')
|
||||
->example('2')
|
||||
->label('Decimal To Display')
|
||||
->rules(['required', 'integer']),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?MfmParameter
|
||||
{
|
||||
// return MfmParameter::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmParameter();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your mfm parameter 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;
|
||||
}
|
||||
}
|
||||
186
app/Filament/Imports/MfmReadingImporter.php
Normal file
186
app/Filament/Imports/MfmReadingImporter.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\MfmReading;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class MfmReadingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = MfmReading::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mfmMeter')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mfm Meter Name')
|
||||
->example('Display SSB')
|
||||
->label('Display SSB')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('apparent_energy_received')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Apparent Energy Received')
|
||||
->example('1084610')
|
||||
->label('Apparent Energy Received')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('reactive_energy_received')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Reactive Energy Received')
|
||||
->example('347496.9')
|
||||
->label('Reactive Energy Received')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('active_energy_received')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Energy Received')
|
||||
->example('611717.1')
|
||||
->label('Active Energy Received')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('active_power_r')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Power R')
|
||||
->example('3.974')
|
||||
->label('Active Power R')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('active_power_y')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Power Y')
|
||||
->example('0.796')
|
||||
->label('Active Power Y')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('active_power_b')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Power B')
|
||||
->example('1.397')
|
||||
->label('Active Power B')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('active_power_total')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Power Total')
|
||||
->example('6.433')
|
||||
->label('Active Power Total')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('voltage_ry')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Voltage RY')
|
||||
->example('413.308')
|
||||
->label('Voltage RY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('voltage_yb')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Voltage YB')
|
||||
->example('415.305')
|
||||
->label('Voltage YB')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('voltage_br')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Voltage BR')
|
||||
->example('415.216')
|
||||
->label('Voltage BR')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('current_r')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Current R')
|
||||
->example('17.446')
|
||||
->label('Current R')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('current_y')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Current Y')
|
||||
->example('4.801')
|
||||
->label('Current Y')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('current_b')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Current B')
|
||||
->example('7.04')
|
||||
->label('Current B')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('current_n')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Current N')
|
||||
->example('14.063')
|
||||
->label('Current N')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('voltage_r_n')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Voltage R N')
|
||||
->example('237.898')
|
||||
->label('Voltage R N')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('voltage_y_n')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Voltage Y N')
|
||||
->example('239.518')
|
||||
->label('Voltage Y N')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('voltage_b_n')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Voltage B N')
|
||||
->example('240.798')
|
||||
->label('Voltage B N')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('frequency')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Frequency')
|
||||
->example('50.228')
|
||||
->label('Frequency')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('power_factor_r')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Power Factor R')
|
||||
->example('0.988')
|
||||
->label('Power Factor R')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('power_factor_y')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Power Factor Y')
|
||||
->example('0.764')
|
||||
->label('Power Factor Y')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('power_factor_b')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Power Factor B')
|
||||
->example('0.849')
|
||||
->label('Power Factor B')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('power_factor_total')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Power Factor Total')
|
||||
->example('0.919')
|
||||
->label('Power Factor Total')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?MfmReading
|
||||
{
|
||||
// return MfmReading::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmReading();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your mfm reading 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;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,14 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class PalletValidationImporter extends Importer
|
||||
{
|
||||
@@ -14,75 +19,229 @@ class PalletValidationImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->label('Plant Code')
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->label('Serial Number')
|
||||
->exampleHeader('Serial Number')
|
||||
->example('12345678901234')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('pallet_number')
|
||||
->requiredMapping()
|
||||
->label('Pallet Number')
|
||||
->example('EP-2505001'),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->example('12345678901234')
|
||||
->rules(['required']),
|
||||
->exampleHeader('Pallet Number')
|
||||
->example('EP-2507001'),
|
||||
ImportColumn::make('pallet_status')
|
||||
->requiredMapping()
|
||||
->label('Pallet Status')
|
||||
->exampleHeader('Pallet Status')
|
||||
->example('Completed'),
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->label('Locator Number')
|
||||
->exampleHeader('Locator Number')
|
||||
->example('W05-D1B'),
|
||||
ImportColumn::make('locator_quantity')
|
||||
->requiredMapping()
|
||||
->label('Locator Quantity')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Locator Quantity')
|
||||
->example(1)
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->label('Created At')
|
||||
->requiredMapping()
|
||||
->example('01-01-2025 08:00:00')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created At')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_at')
|
||||
->label('Scanned At')
|
||||
->requiredMapping()
|
||||
->label('Scanned At')
|
||||
->exampleHeader('Scanned At')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->label('Updated At')
|
||||
->exampleHeader('Updated At')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->requiredMapping()
|
||||
->example('Jothi')
|
||||
->label('Created By')
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->label('Scanned By')
|
||||
->requiredMapping()
|
||||
->example('Jothi')
|
||||
->label('Scanned By')
|
||||
->exampleHeader('Scanned By')
|
||||
->example('Admin')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->label('Updated By')
|
||||
->example('Jothi')
|
||||
->requiredMapping(),
|
||||
->exampleHeader('Updated By')
|
||||
->example('Admin'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?PalletValidation
|
||||
{
|
||||
// return PalletValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$serialNo = $this->data['serial_number'];
|
||||
$palletNo = $this->data['pallet_number'];
|
||||
$palletStat = $this->data['pallet_status'];
|
||||
$locatorNo = $this->data['locator_number'];
|
||||
$locatorQty = $this->data['locator_quantity'];
|
||||
$createdAt = $this->data['created_at'];
|
||||
$scannedAt = $this->data['scanned_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
$cDateTime = null;
|
||||
$sDateTime = null;
|
||||
$uDateTime = null;
|
||||
$createdBy = $this->data['created_by'];
|
||||
$scannedBy = $this->data['scanned_by'];
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
|
||||
return new PalletValidation();
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($palletStat) > 0 && $palletStat != 'Completed') {
|
||||
$warnMsg[] = "Invalid pallet status found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if (Str::length($palletNo) <= 0 && Str::length($locatorNo) <= 0) {
|
||||
$warnMsg[] = "Pallet and locator number found";
|
||||
}
|
||||
if (Str::length($locatorQty) < 0 || !is_numeric($locatorQty) || $locatorQty < 0 || $locatorQty > 2) {
|
||||
$warnMsg[] = "Invalid locator quantity found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($sDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try
|
||||
{
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
PalletValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo
|
||||
],
|
||||
[
|
||||
'pallet_number' => $palletNo,
|
||||
'pallet_status' => $palletStat,
|
||||
'locator_number' => $locatorNo,
|
||||
'locator_quantity' => $locatorQty,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'scanned_at' => $sDateTime->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return PalletValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new PalletValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -130,7 +130,7 @@ class ProductionQuantityImporter extends Importer
|
||||
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || !is_numeric($this->data['production_order']))) {
|
||||
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14 || !is_numeric($this->data['production_order']))) {
|
||||
$warnMsg[] = "Invalid production order found";
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ class QualityValidationImporter extends Importer
|
||||
$warnMsg[] = "Sticker item code not found";
|
||||
}
|
||||
|
||||
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7) {
|
||||
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14) {
|
||||
$warnMsg[] = "Invalid production order found";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\ReworkLocatorInvoiceValidation;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
{
|
||||
@@ -16,10 +21,10 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
@@ -34,23 +39,51 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
->label('Serial Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('pallet_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Pallet Number')
|
||||
->example('')
|
||||
->label('Pallet Number'),
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Locator Number')
|
||||
->example('')
|
||||
->label('Locator Number'),
|
||||
ImportColumn::make('scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned Status')
|
||||
->example('')
|
||||
->label('Scanned Status'),
|
||||
->label('Scanned Status')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('upload_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Upload Status')
|
||||
->example('Y')
|
||||
->label('Upload Status')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Created At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Scanned At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Updated At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('reworked_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Reworked At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Reworked At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
@@ -58,43 +91,208 @@ class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned By')
|
||||
->example('admin')
|
||||
->label('Scanned By'),
|
||||
->label('Scanned By')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated By')
|
||||
->example('admin')
|
||||
->label('Updated By'),
|
||||
ImportColumn::make('reworked_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Reworked By')
|
||||
->example('admin')
|
||||
->label('Reworked By'),
|
||||
ImportColumn::make('created_at')
|
||||
->exampleHeader('Created At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Created At')
|
||||
->rules(['date_format:Y-m-d H:i:s']),
|
||||
ImportColumn::make('scanned_at')
|
||||
->exampleHeader('Scanned At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Scanned At')
|
||||
->rules(['date_format:Y-m-d H:i:s']),
|
||||
ImportColumn::make('reworked_at')
|
||||
->exampleHeader('Reworked At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Reworked At')
|
||||
->rules(['date_format:Y-m-d H:i:s']),
|
||||
->label('Reworked By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ReworkLocatorInvoiceValidation
|
||||
{
|
||||
// return ReworkLocatorInvoiceValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$invoiceNo = $this->data['invoice_number'];
|
||||
$serialNo = $this->data['serial_number'];
|
||||
$palletNo = $this->data['pallet_number'];
|
||||
$locatorNo = $this->data['locator_number'];
|
||||
$scannedStat = $this->data['scanned_status'];
|
||||
$uploadStat = $this->data['upload_status'];
|
||||
$createdAt = $this->data['created_at'];
|
||||
$scannedAt = $this->data['scanned_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
$reworkedAt = $this->data['reworked_at'];
|
||||
$cDateTime = null;
|
||||
$sDateTime = null;
|
||||
$uDateTime = null;
|
||||
$rDateTime = null;
|
||||
$createdBy = $this->data['created_by'];
|
||||
$scannedBy = $this->data['scanned_by'];
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
$reworkedBy = $this->data['reworked_by'];
|
||||
|
||||
return new ReworkLocatorInvoiceValidation();
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if ($scannedStat != 'Scanned') {
|
||||
$warnMsg[] = "Invalid scanned status found";
|
||||
}
|
||||
if ($uploadStat != 'Y' && $uploadStat != 'N') {
|
||||
$warnMsg[] = "Invalid upload status found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
if (Str::length($updatedBy) > 0) {
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
$reworked = User::where('name', $reworkedBy)->first();
|
||||
if (!$reworked) {
|
||||
$warnMsg[] = "Reworked by not found";
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($sDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$rDateTime = Carbon::createFromFormat($format, $reworkedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($rDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Reworked DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($rDateTime)) {
|
||||
if ($cDateTime->greaterThan($rDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Reworked DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
ReworkLocatorInvoiceValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo,
|
||||
'invoice_number' => $invoiceNo,
|
||||
'pallet_number' => $palletNo,
|
||||
'locator_number' => $locatorNo,
|
||||
'scanned_status' => $scannedStat,
|
||||
'upload_status' => $uploadStat,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'scanned_at' => $sDateTime->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
'reworked_at' => $rDateTime->format('Y-m-d H:i:s'),
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'reworked_by' => $reworkedBy
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return ReworkLocatorInvoiceValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new ReworkLocatorInvoiceValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -25,150 +25,130 @@ class StickerMasterImporter extends Importer
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
|
||||
ImportColumn::make('serial_number_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Serial Number Motor')
|
||||
->label('SERIAL NUMBER MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('serial_number_pump')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Serial Number Pump')
|
||||
->label('SERIAL NUMBER PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('serial_number_pumpset')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Serial Number PumpSet')
|
||||
->label('SERIAL NUMBER PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('pack_slip_motor')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip Motor')
|
||||
->label('PACK SLIP MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('pack_slip_pump')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip Pump')
|
||||
->label('PACK SLIP PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('pack_slip_pumpset')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip PumpSet')
|
||||
->label('PACK SLIP PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('name_plate_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate Motor')
|
||||
->label('NAME PLATE MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('name_plate_pump')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate Pump')
|
||||
->label('NAME PLATE PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('name_plate_pumpset')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate PumpSet')
|
||||
->label('NAME PLATE PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('tube_sticker_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Motor')
|
||||
->label('TUBE STICKER MOTOR')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('tube_sticker_pump')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Pump')
|
||||
->label('TUBE STICKER PUMP')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('tube_sticker_pumpset')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker PumpSet')
|
||||
->label('TUBE STICKER PUMPSET')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('warranty_card')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Warranty Card')
|
||||
->label('WARRANTY CARD')
|
||||
->example('1'),
|
||||
|
||||
ImportColumn::make('part_validation1')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Part Validation 1')
|
||||
->label('PART VALIDATION 1')
|
||||
->example('12345'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation2')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Part Validation 2')
|
||||
->label('PART VALIDATION 2')
|
||||
->example('23456'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation3')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Part Validation 3')
|
||||
->label('PART VALIDATION 3')
|
||||
->example('34567'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation4')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Part Validation 4')
|
||||
->label('PART VALIDATION 4')
|
||||
->example('45678'),
|
||||
|
||||
|
||||
ImportColumn::make('part_validation5')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Part Validation 5')
|
||||
->label('PART VALIDATION 5')
|
||||
->example('56789'),
|
||||
|
||||
|
||||
ImportColumn::make('laser_part_validation1')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Laser Part Validation 1')
|
||||
->label('LASER PART VALIDATION 1')
|
||||
->example('67890'),
|
||||
ImportColumn::make('laser_part_validation2')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Laser Part Validation 2')
|
||||
->label('LASER PART VALIDATION 2')
|
||||
->example('78901'),
|
||||
ImportColumn::make('panel_box_code')
|
||||
//->requiredMapping()
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Panel Box Code')
|
||||
->label('PANEL BOX CODE')
|
||||
->example('123456'),
|
||||
|
||||
|
||||
ImportColumn::make('load_rate')
|
||||
ImportColumn::make('load_rate')
|
||||
->requiredMapping()
|
||||
->integer()
|
||||
->exampleHeader('Load Rate')
|
||||
->label('LOAD RATE')
|
||||
->example('0'),
|
||||
|
||||
|
||||
ImportColumn::make('bundle_quantity')
|
||||
// ->requiredMapping()
|
||||
->integer()
|
||||
->exampleHeader('Bundle Quantity')
|
||||
->label('BUNDLE QUANTITY')
|
||||
->example(''),
|
||||
|
||||
|
||||
->example('0')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('material_type')
|
||||
// ->requiredMapping()
|
||||
// ->requiredMapping()
|
||||
->integer()
|
||||
->exampleHeader('Material Type')
|
||||
->label('MATERIAL TYPE')
|
||||
->example(''),
|
||||
|
||||
ImportColumn::make('bundle_quantity')
|
||||
// ->requiredMapping()
|
||||
->integer()
|
||||
->exampleHeader('Bundle Quantity')
|
||||
->label('BUNDLE QUANTITY')
|
||||
->example(''),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
@@ -182,73 +162,78 @@ class StickerMasterImporter extends Importer
|
||||
public function resolveRecord(): ?StickerMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$item = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
$item = null;
|
||||
if ($plant) {
|
||||
else
|
||||
{
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$item) {
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
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($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = "Serial number pump must be 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($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = "Pack slip motor must be 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($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = "Pack slip pumpset must be 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($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = "Name plate pump must be 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($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = "Tube sticker motor must be 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($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = "Tube sticker pumpset must be 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($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || !ctype_alnum($this->data['panel_box_code']))) {
|
||||
$warnMsg[] = "Invalid panel box code found";
|
||||
}
|
||||
if (!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($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($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 (!$item) {
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
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($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = "Serial number pump must be 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($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = "Pack slip motor must be 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($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = "Pack slip pumpset must be 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($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = "Name plate pump must be 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($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = "Tube sticker motor must be 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($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = "Tube sticker pumpset must be 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($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || !ctype_alnum($this->data['panel_box_code']))) {
|
||||
$warnMsg[] = "Invalid panel box code found";
|
||||
}
|
||||
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($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($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 (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return StickerMaster::updateOrCreate([
|
||||
|
||||
StickerMaster::updateOrCreate([
|
||||
'item_id' => $item->id,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
@@ -271,11 +256,14 @@ class StickerMasterImporter extends Importer
|
||||
'part_validation3' => $this->data['part_validation3'],
|
||||
'part_validation4' => $this->data['part_validation4'],
|
||||
'part_validation5' => $this->data['part_validation5'],
|
||||
'laser_part_validation1' => $this->data['laser_part_validation1'],
|
||||
'laser_part_validation2' => $this->data['laser_part_validation2'],
|
||||
'panel_box_code' => $this->data['panel_box_code'],
|
||||
'load_rate' => $this->data['load_rate'],
|
||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||
'material_type' => $this->data['material_type']
|
||||
]);
|
||||
return null;
|
||||
// return StickerMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
|
||||
66
app/Filament/Imports/TempLiveReadingImporter.php
Normal file
66
app/Filament/Imports/TempLiveReadingImporter.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\TempLiveReading;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class TempLiveReadingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = TempLiveReading::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mfmMeter')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mfm Meter Name')
|
||||
->example('Display SSB')
|
||||
->label('Mfm Meter Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('register_data')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Register Data')
|
||||
->example('65165,5646,561,561')
|
||||
->label('Register Data')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?TempLiveReading
|
||||
{
|
||||
// return TempLiveReading::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new TempLiveReading();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your temp live reading 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;
|
||||
}
|
||||
}
|
||||
@@ -75,8 +75,6 @@ class TestingPanelReadingImporter extends Importer
|
||||
ImportColumn::make('output_flag')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('pds_status'),
|
||||
ImportColumn::make('pds_description'),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
@@ -89,7 +87,7 @@ class TestingPanelReadingImporter extends Importer
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class Dashboard extends \Filament\Pages\Dashboard
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]); // fixed typo
|
||||
$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
}),
|
||||
]);
|
||||
|
||||
@@ -53,6 +53,7 @@ class Dashboard extends \Filament\Pages\Dashboard
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
358
app/Filament/Pages/DataSendToSap.php
Normal file
358
app/Filament/Pages/DataSendToSap.php
Normal file
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class DataSendToSap extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
public $pId , $pOrder, $pUom, $pItem, $transHeadLog, $sNums = [];
|
||||
|
||||
public $scanned_quantity;
|
||||
|
||||
public array $data = []; //Required to back form state
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
protected static string $view = 'filament.pages.data-send-to-sap';
|
||||
|
||||
protected static ?string $navigationGroup = 'Send To SAP';
|
||||
|
||||
protected $listeners = ['updateScannedQuantity' => 'setScannedQuantity'];
|
||||
|
||||
|
||||
|
||||
public function setScannedQuantity($quantity)
|
||||
{
|
||||
// Set the scanned_quantity value in the Filament page/form
|
||||
$this->scanned_quantity = $quantity;
|
||||
$this->form->fill([
|
||||
'scanned_quantity' => $quantity,
|
||||
'production_order' => $this->pOrder,
|
||||
'plant_id' => $this->pId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('data')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pId = $plantId;
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$productionOrder = $get('production_order');
|
||||
|
||||
if (!$productionOrder) {
|
||||
$set('pqproducError', 'Please provide production order.');
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pOrder = null;
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqproducError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqproducError') ? $get('pqproducError') : null)
|
||||
->hintColor('danger')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processValues($event.target.value)',
|
||||
]),
|
||||
|
||||
TextInput::make('scanned_quantity')
|
||||
->reactive() // Make it reactive to update when changed
|
||||
->afterStateUpdated(function ($state, $set, $get) {
|
||||
$this->scanned_quantity = $state;
|
||||
})
|
||||
->readOnly(),
|
||||
|
||||
// Add your custom action button here
|
||||
Actions::make([
|
||||
Action::make('send_to_sap')
|
||||
->label('Send Data to SAP')
|
||||
->action(function ($set, $get) {
|
||||
$year = date('y'); // '25' for 2025
|
||||
$month = date('m'); // '05' for May
|
||||
$plantId = $get('plant_id');
|
||||
$code = Plant::where('id', $plantId)->value('code');
|
||||
$finalBatch = $year . $month . $code;
|
||||
$transHeadLogId = $this->transHeadLog; //'3256';
|
||||
$lineItemCnt = '1'; //1 hard code
|
||||
$sapOrder = $get('production_order');
|
||||
$itemCode = $this->pItem;
|
||||
$quantity = (string)$get('scanned_quantity');
|
||||
$UOM = $this->pUom;
|
||||
$batchNumber = $finalBatch;
|
||||
$locationName = '';
|
||||
$lamiCdate = $get('lami_cdate');
|
||||
$serialNumbers = $this->sNums;
|
||||
|
||||
// dd($batchNumber);
|
||||
|
||||
$currentDateTime = date('j/n/Y h:i:s A');
|
||||
|
||||
$header = [
|
||||
'Trans_Head_Log_Id' => $transHeadLogId, //'3256',
|
||||
'Line_Item_Count' => $lineItemCnt, //'1',
|
||||
'SAP_Order_Number' => $sapOrder, //'12345678'
|
||||
'Item_Code' => $itemCode, //'6458795'
|
||||
];
|
||||
// $serialNumbers = ['12024090000142', '12024090000142', '12024090000142'];
|
||||
$Receipt = [
|
||||
// 'Receipt' => [
|
||||
[
|
||||
'Quantity' => $quantity, //'1',
|
||||
'UOM' => $UOM,
|
||||
'Batch_Number' => $batchNumber,
|
||||
'Location_Name' => $locationName,
|
||||
'LAMI_Cdate' => $currentDateTime, //'9/9/2024 10:48:37 AM',
|
||||
'Serial_Number' => array_map(function ($serial) {
|
||||
return ['Serial_Number' => $serial];
|
||||
}, $serialNumbers)
|
||||
]
|
||||
// ]
|
||||
];
|
||||
|
||||
|
||||
$payload = [
|
||||
// ...$header,
|
||||
'Receipt' => $Receipt
|
||||
];
|
||||
// dd($payload);
|
||||
|
||||
// $header = [
|
||||
// 'Trans_Head_Log_Id' => '3256',
|
||||
// 'Line_Item_Count' => '1',
|
||||
// 'SAP_Order_Number' => '12345678',
|
||||
// 'Item_Code' => '6458795'
|
||||
// ];
|
||||
// $serialNumbers = ['12024090000142'];
|
||||
// $Receipt = [
|
||||
// // 'Receipt' => [
|
||||
// [
|
||||
// 'Quantity' => '1',
|
||||
// 'UOM' => 'EA',
|
||||
// 'Batch_Number' => '',
|
||||
// 'Location_Name' => '',
|
||||
// 'LAMI_Cdate' => '9/9/2024 10:48:37 AM',
|
||||
// 'Serial_Number' => array_map(function ($serial) {
|
||||
// return ['Serial_Number' => $serial];
|
||||
// }, $serialNumbers)
|
||||
// ]
|
||||
// // ]
|
||||
// ];
|
||||
|
||||
|
||||
// $payload = [
|
||||
// // ...$header,
|
||||
// 'Receipt' => $Receipt
|
||||
// ];
|
||||
// dd($payload);
|
||||
try {
|
||||
// $response = Http::withHeaders([
|
||||
// 'Content-Type' => 'application/json',
|
||||
// 'Trans_Head_Log_Id' => '3256',//$transHeadLogId,
|
||||
// 'Line_Item_Count' => '1', // $lineItemCnt,
|
||||
// 'SAP_Order_Number' => '12345678', //$sapOrder,
|
||||
// 'Item_Code' => '6458795', //$itemCode,
|
||||
// ])
|
||||
$response = Http::withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Trans_Head_Log_Id' => $transHeadLogId,
|
||||
'Line_Item_Count' => $lineItemCnt,
|
||||
'SAP_Order_Number' => $sapOrder,
|
||||
'Item_Code' => $itemCode,
|
||||
])
|
||||
|
||||
->withBasicAuth(
|
||||
env('SAP_API_USERNAME'),
|
||||
env('SAP_API_PASSWORD')
|
||||
)
|
||||
->withBody(json_encode($payload), 'application/json')
|
||||
->post(env('SAP_API_URL'), $payload);
|
||||
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
|
||||
if ($messageCode && str_starts_with($messageCode, 'ERROR')) {
|
||||
|
||||
$cleanError = str_replace('ERROR:|', '', $messageCode);
|
||||
|
||||
// Update rows where plant_id and production_order match
|
||||
QualityValidation::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'ERROR',
|
||||
'sap_msg_description' => $cleanError,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Error')
|
||||
->body($cleanError)
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
$sapSuccessMsg = str_replace('SUCCESS:|', '', $messageCode);
|
||||
|
||||
QualityValidation::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'SUCCESS',
|
||||
'sap_msg_description' => $sapSuccessMsg,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Success')
|
||||
->body($sapSuccessMsg)
|
||||
->success()
|
||||
->send();
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Exception')
|
||||
->body('Error sending data to SAP: ' . $e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
})
|
||||
->color('success')
|
||||
->outlined()
|
||||
->hidden(fn (callable $get) => (!$get('scanned_quantity'))) //!$get('plant_id') && !$get('production_order') &&
|
||||
->extraAttributes(['class' => 'align-to-input']),
|
||||
]),
|
||||
])
|
||||
->columns(4);
|
||||
}
|
||||
|
||||
public function processValues($value)
|
||||
{
|
||||
|
||||
$this->pOrder = $value;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id']) ?? null;
|
||||
//$this->plantId = $plantId;
|
||||
|
||||
|
||||
// $this->pUom = QualityValidation::where('plant_id',$this->pId)
|
||||
// ->where('production_order',$this->pOrder)
|
||||
// ->latest()
|
||||
// ->first()
|
||||
// ->value('uom');
|
||||
|
||||
// $this->transHeadLog = QualityValidation::where('plant_id',$this->pId)
|
||||
// ->where('production_order',$this->pOrder)
|
||||
// ->latest()
|
||||
// ->value('id');
|
||||
|
||||
$latestValidation = QualityValidation::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$latestValidation) {
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body('No data found for the selected plant and production order.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
$this->pOrder = null;
|
||||
$this->form->fill([
|
||||
'plant_id' => $this->pId,
|
||||
'production_order' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->pUom = $latestValidation->uom;
|
||||
$this->transHeadLog = $latestValidation->id;
|
||||
|
||||
$this->sNums = [];
|
||||
|
||||
if(!$this->pUom)
|
||||
{
|
||||
Notification::make()
|
||||
->title('UOM Not Found')
|
||||
->body('UOM not found for the production order')
|
||||
->icon('heroicon-o-x-circle') // optional, to force red/error-style icon
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->pItem = Item::where('id', StickerMaster::where('id', QualityValidation::where('plant_id',$this->pId)->where('production_order',$this->pOrder)->latest()->first()->sticker_master_id)->value('item_id'))->value('code');
|
||||
|
||||
$this->sNums = QualityValidation::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->pluck('serial_number')
|
||||
->toArray();
|
||||
|
||||
//dd($this-> pItem);
|
||||
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
}
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view quality data send to sap');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Quality Data';
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ class InvoiceFinder extends Page implements HasForms
|
||||
|
||||
protected static ?string $navigationGroup = 'Export Dispatch';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
//use InteractsWithForms;
|
||||
|
||||
public $pId, $invoiceNumber;
|
||||
@@ -59,7 +61,7 @@ class InvoiceFinder extends Page implements HasForms
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
TextInput::make('total_sno_quantity')
|
||||
->label('Total SNo. Quantity')
|
||||
->label('Invoice Quantity')
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
|
||||
@@ -75,9 +77,10 @@ class InvoiceFinder extends Page implements HasForms
|
||||
if(!$invoiceNo)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Invoice number '$invoiceNo' can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -96,13 +99,14 @@ class InvoiceFinder extends Page implements HasForms
|
||||
if(!$invoiceExists)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' does not exist in locator invoice table!")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Invoice number '$invoiceNo' does not exist in locator invoice table!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'scan_invoice' => $invoiceNo,
|
||||
'scan_invoice' => null,//$invoiceNo,
|
||||
'total_sno_quantity' => 0,
|
||||
'pending_quantity' => 0,
|
||||
'scan_quantity' => 0
|
||||
@@ -118,21 +122,22 @@ class InvoiceFinder extends Page implements HasForms
|
||||
|
||||
if(!$invoiceCompleted)
|
||||
{
|
||||
$count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
|
||||
->where('plant_id', $plantId)
|
||||
->count();
|
||||
// $count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->count();
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' already completed the scanning process...")
|
||||
->success()
|
||||
->send();
|
||||
->title("Invoice number '$invoiceNo' already completed the scanning process..!")
|
||||
->success()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'scan_invoice' => $invoiceNo,
|
||||
'total_sno_quantity' => $count,
|
||||
'pending_quantity' => 0,
|
||||
'scan_quantity' => $count
|
||||
'scan_invoice' => null,//$invoiceNo,
|
||||
'total_sno_quantity' => 0,//$count,
|
||||
'pending_quantity' => 0,//0,
|
||||
'scan_quantity' => 0//$count
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Locator;
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -26,6 +27,8 @@ class PalletFromLocator extends Page implements HasForms
|
||||
|
||||
protected static ?string $navigationGroup = 'Export Dispatch';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $locatorNo;
|
||||
@@ -91,6 +94,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
TextInput::make('scan_locator_number')
|
||||
->label('Scan Locator Number')
|
||||
->reactive()
|
||||
->minLength(7)
|
||||
->columnSpan(1)
|
||||
->readOnly(fn (callable $get) => !$get('plant') || $get('scan_serial_number') || $get('scan_remove_sno'))
|
||||
->extraAttributes([
|
||||
@@ -99,6 +103,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
TextInput::make('scan_serial_number')
|
||||
->label('Scan Serial Number')
|
||||
->reactive()
|
||||
->minLength(9)
|
||||
->columnSpan(1)
|
||||
->readOnly(fn (callable $get) => !$get('plant') || $get('scan_locator_number') || $get('scan_remove_sno'))
|
||||
->extraAttributes([
|
||||
@@ -107,6 +112,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
TextInput::make('scan_remove_sno')
|
||||
->label('Remove Serial Number')
|
||||
->reactive()
|
||||
->minLength(9)
|
||||
->columnSpan(1)
|
||||
->readOnly(fn (callable $get) => !$get('plant') || $get('scan_locator_number') || $get('scan_serial_number') || count($this->records) <= 0)
|
||||
->extraAttributes([
|
||||
@@ -139,8 +145,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -157,8 +164,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Remove Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -177,8 +185,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Locator Number')
|
||||
->body("Locator number can't be empty!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -196,8 +205,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Locator Number')
|
||||
->body("Locator number '$locatorNo' must be at least 7 digits.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -220,8 +230,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Unknown: Locator Number')
|
||||
->body("Locator number '$locatorNo' does not exist in the master.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -252,8 +263,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->body("Scanned locator number '$locatorNo' does not have any locator serial numbers to store into the pallet.<br>
|
||||
Please scan a valid stored locator number to proceed.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -271,8 +283,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Add: Locator Serial Numbers')
|
||||
->body("Scanned locator number '$locatorNo' has '".$serialLocator->count()."' locator serial numbers!<br>Do you want to store it into 'PALLET DATA' table?")
|
||||
->info()
|
||||
->seconds(2)
|
||||
->duration(2000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('open-confirm-modal', locatorNo: $locatorNo, plantId: $plantId);
|
||||
}
|
||||
}
|
||||
@@ -330,7 +343,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->orWhere('pallet_number', '');
|
||||
})
|
||||
->where('locator_number', $locatorNo)
|
||||
->orderByDesc('created_at')
|
||||
->orderBy('created_at', 'asc') //orderByDesc('created_at')
|
||||
->get()
|
||||
->map(function ($record) use($operatorName) {
|
||||
return [
|
||||
@@ -387,7 +400,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Add: Locator Serial Number')
|
||||
->body("Scanned locator serial number '$serialNo' successfully added into 'PALLET DATA' table.")
|
||||
->success()
|
||||
->seconds(3)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -410,7 +423,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Remove: Locator Serial Number')
|
||||
->body("Scanned locator serial number '$removeserial' removed successfully from 'PALLET DATA' table.")
|
||||
->success()
|
||||
->seconds(3)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
@@ -449,8 +462,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Add: Locator Serial Numbers')
|
||||
->body("Scanned locator number '$locatorNo' has '$serialLocator' locator serial numbers!<br>Successfully added into 'PALLET DATA' table.")
|
||||
->success()
|
||||
->seconds(3)
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -469,8 +483,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Skipped: Locator Number')
|
||||
->body('Scan the new locator number to proceed..!')
|
||||
->info()
|
||||
->seconds(3)
|
||||
->duration(2000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -499,8 +514,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Locator Number" field to proceed..!')
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -517,8 +533,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Remove Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -537,8 +554,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -550,14 +568,15 @@ class PalletFromLocator extends Page implements HasForms
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) < 13)
|
||||
else if (strlen($serialNo) < 9 || strlen($serialNo) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$serialNo' must be at least 13 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -575,8 +594,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -600,22 +620,53 @@ class PalletFromLocator extends Page implements HasForms
|
||||
|
||||
if ($serialLocator == '' || $serialLocator == null)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Unknown: Serial Number')
|
||||
->body("Scanned serial number: '$serialNo' doesn't exist in pallet table.<br>Scan the valid exist locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->send();
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => null,
|
||||
]);
|
||||
return;
|
||||
$invoicesnoexists = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('serial_number', $serialNo)
|
||||
->where('scanned_status', '=','Scanned')
|
||||
->first();
|
||||
|
||||
$invoiceNo = $invoicesnoexists?->invoice_number;
|
||||
|
||||
if ($invoicesnoexists)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$serialNo' already exists in invoice number '$invoiceNo' and completed the scanning process..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => $count,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Unknown: Serial Number')
|
||||
->body("Scanned serial number: '$serialNo' doesn't exist in pallet table.<br>Scan the valid exist locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => $count,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
elseif ($serialLocator->pallet_number != '' && $serialLocator->pallet_number != null)
|
||||
{
|
||||
@@ -623,8 +674,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Scanned serial number: '$serialNo' already exist in pallet number '".$serialLocator->pallet_number."'.<br>Scan the valid locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -632,7 +684,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => null,
|
||||
'sno_quantity' => $count,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
@@ -655,8 +707,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Locator Serials Not Found')
|
||||
->body("Add some locator serial numbers to proceed generate pallet..!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -673,14 +726,28 @@ class PalletFromLocator extends Page implements HasForms
|
||||
$month = now()->format('m');
|
||||
$prefix = "EP-{$year}{$month}";
|
||||
|
||||
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")
|
||||
->where('plant_id', $plantId)
|
||||
->orderByDesc('pallet_number')
|
||||
->first();
|
||||
|
||||
$newNumber = $lastPallet
|
||||
? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT)
|
||||
: '001';
|
||||
$lastPallet1 = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
||||
$lastPallet2 = LocatorInvoiceValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first();
|
||||
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
|
||||
if ($lastPallet1 && $lastPallet2) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
if (intval($serialPart1) > intval($serialPart2)) {
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
else if ($lastPallet1) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
// OR
|
||||
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
}
|
||||
else if ($lastPallet2) {
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||
|
||||
@@ -748,15 +815,16 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Success: Pallet Generated')
|
||||
->body("Pallet number '$newPalletNumber' completed the master packing successfully!")
|
||||
->success()
|
||||
->seconds(3)
|
||||
->duration(600)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => $locatorNo,
|
||||
'scan_serial_number' => $serialNo,
|
||||
'scan_remove_sno' => $removeSerial,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => 0,
|
||||
]);
|
||||
return;
|
||||
@@ -768,15 +836,16 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Failed: Pallet Generated')
|
||||
->body("No locator serial number records found to generate pallet..!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'scan_locator_number' => $locatorNo,
|
||||
'scan_serial_number' => $serialNo,
|
||||
'scan_remove_sno' => $removeSerial,
|
||||
'scan_locator_number' => null,
|
||||
'scan_serial_number' => null,
|
||||
'scan_remove_sno' => null,
|
||||
'sno_quantity' => 0,
|
||||
]);
|
||||
return;
|
||||
@@ -798,6 +867,7 @@ class PalletFromLocator extends Page implements HasForms
|
||||
// ->title('Pallet Generated')
|
||||
// ->body("Pallet number {$this->latestPalletNumber} assigned to all serials for locator {$locatorNo}")
|
||||
// ->success()
|
||||
// ->duration(1000)
|
||||
// ->send();
|
||||
// $this->dispatch('loadData', $this->records, $plantId);
|
||||
// $this->form->fill([
|
||||
@@ -826,8 +896,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Locator Number" field to proceed..!')
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -844,8 +915,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
Notification::make()
|
||||
->title('Press enter on "Scan Serial Number" field to proceed..!')
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -864,8 +936,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -877,14 +950,15 @@ class PalletFromLocator extends Page implements HasForms
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($removeSno) < 13)
|
||||
else if (strlen($removeSno) < 9 || strlen($removeSno) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$removeSno' must be at least 13 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -902,8 +976,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Invalid: Serial Number')
|
||||
->body("Serial number '$removeSno' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -934,8 +1009,9 @@ class PalletFromLocator extends Page implements HasForms
|
||||
->title('Unknown: Serial Number')
|
||||
->body("Scanned serial number: '$removeSno' doesn't exist in 'PALLET DATA' table.<br>Scan the valid exist locator-serial number to proceed..!")
|
||||
->danger()
|
||||
->seconds(3)
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $this->records, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
|
||||
370
app/Filament/Pages/ProductionDataSap.php
Normal file
370
app/Filament/Pages/ProductionDataSap.php
Normal file
@@ -0,0 +1,370 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionDataSap extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
public $pId , $pOrder, $pUom, $pItem, $transHeadLog, $sNums = [];
|
||||
|
||||
public $scanned_quantity;
|
||||
|
||||
public array $data = []; //Required to back form state
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
protected static string $view = 'filament.pages.production-data-sap';
|
||||
|
||||
protected static ?string $navigationGroup = 'Send To SAP';
|
||||
|
||||
protected $listeners = ['updateScannedQuantity' => 'setScannedQuantity'];
|
||||
|
||||
|
||||
|
||||
public function setScannedQuantity($quantity)
|
||||
{
|
||||
// Set the scanned_quantity value in the Filament page/form
|
||||
$this->scanned_quantity = $quantity;
|
||||
$this->form->fill([
|
||||
'scanned_quantity' => $quantity,
|
||||
'production_order' => $this->pOrder,
|
||||
'plant_id' => $this->pId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('data')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pId = $plantId;
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$productionOrder = $get('production_order');
|
||||
|
||||
if (!$productionOrder) {
|
||||
$set('pqproducError', 'Please provide production order.');
|
||||
$set('scanned_quantity', null);
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pOrder = null;
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqproducError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqproducError') ? $get('pqproducError') : null)
|
||||
->hintColor('danger')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processValues($event.target.value)',
|
||||
]),
|
||||
|
||||
TextInput::make('scanned_quantity')
|
||||
->reactive() // Make it reactive to update when changed
|
||||
->afterStateUpdated(function ($state, $set, $get) {
|
||||
$this->scanned_quantity = $state;
|
||||
})
|
||||
->readOnly()
|
||||
->required(),
|
||||
|
||||
// Add your custom action button here
|
||||
Actions::make([
|
||||
Action::make('send_to_sap')
|
||||
->label('Send Data to SAP')
|
||||
->action(function ($set, $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$plantWarehouseCodes = [
|
||||
// plant_id => warehouse_code
|
||||
1 => '110', // Ransar I
|
||||
2 => '101', // Ransar II
|
||||
3 => '102', // Chola Pumps
|
||||
4 => '104', // Tuff Pumps
|
||||
//5 => '107', //WH-Nark
|
||||
5 => '200', // Go-flex
|
||||
//7 => '301', // Krisgo II
|
||||
];
|
||||
|
||||
$year = date('y'); // '25' for 2025
|
||||
$month = date('m'); // '05' for May
|
||||
$transHeadLogId = $this->transHeadLog; //'3256';
|
||||
$lineItemCnt = '1'; //1 hard code
|
||||
$sapOrder = $get('production_order');
|
||||
$itemCode = $this->pItem;
|
||||
$quantity = (string)$get('scanned_quantity');
|
||||
$UOM = $this->pUom;
|
||||
|
||||
$locationName = '';
|
||||
$lamiCdate = $get('lami_cdate');
|
||||
$serialNumbers = $this->sNums;
|
||||
|
||||
$warehouseCode = $plantWarehouseCodes[$plantId] ?? null;
|
||||
$finalBatch = $warehouseCode . $year . $month;
|
||||
|
||||
$batchNumber = $finalBatch;
|
||||
//dd($batchNumber);
|
||||
|
||||
$currentDateTime = date('j/n/Y h:i:s A');
|
||||
|
||||
$header = [
|
||||
'Trans_Head_Log_Id' => $transHeadLogId, //'3256',
|
||||
'Line_Item_Count' => $lineItemCnt, //'1',
|
||||
'SAP_Order_Number' => $sapOrder, //'12345678'
|
||||
'Item_Code' => $itemCode, //'6458795'
|
||||
];
|
||||
// $serialNumbers = ['12024090000142', '12024090000142', '12024090000142'];
|
||||
$Receipt = [
|
||||
// 'Receipt' => [
|
||||
[
|
||||
'Quantity' => $quantity, //'1',
|
||||
'UOM' => $UOM,
|
||||
'Batch_Number' => $batchNumber,
|
||||
'Location_Name' => $locationName,
|
||||
'LAMI_Cdate' => $currentDateTime, //'9/9/2024 10:48:37 AM',
|
||||
'Serial_Number' => array_map(function ($serial) {
|
||||
return ['Serial_Number' => $serial];
|
||||
}, $serialNumbers)
|
||||
]
|
||||
// ]
|
||||
];
|
||||
|
||||
|
||||
$payload = [
|
||||
// ...$header,
|
||||
'Receipt' => $Receipt
|
||||
];
|
||||
// dd($payload);
|
||||
|
||||
// $header = [
|
||||
// 'Trans_Head_Log_Id' => '3256',
|
||||
// 'Line_Item_Count' => '1',
|
||||
// 'SAP_Order_Number' => '12345678',
|
||||
// 'Item_Code' => '6458795'
|
||||
// ];
|
||||
// $serialNumbers = ['12024090000142'];
|
||||
// $Receipt = [
|
||||
// // 'Receipt' => [
|
||||
// [
|
||||
// 'Quantity' => '1',
|
||||
// 'UOM' => 'EA',
|
||||
// 'Batch_Number' => '',
|
||||
// 'Location_Name' => '',
|
||||
// 'LAMI_Cdate' => '9/9/2024 10:48:37 AM',
|
||||
// 'Serial_Number' => array_map(function ($serial) {
|
||||
// return ['Serial_Number' => $serial];
|
||||
// }, $serialNumbers)
|
||||
// ]
|
||||
// // ]
|
||||
// ];
|
||||
|
||||
|
||||
// $payload = [
|
||||
// // ...$header,
|
||||
// 'Receipt' => $Receipt
|
||||
// ];
|
||||
// dd($payload);
|
||||
try {
|
||||
// $response = Http::withHeaders([
|
||||
// 'Content-Type' => 'application/json',
|
||||
// 'Trans_Head_Log_Id' => '3256',//$transHeadLogId,
|
||||
// 'Line_Item_Count' => '1', // $lineItemCnt,
|
||||
// 'SAP_Order_Number' => '12345678', //$sapOrder,
|
||||
// 'Item_Code' => '6458795', //$itemCode,
|
||||
// ])
|
||||
$response = Http::withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Trans_Head_Log_Id' => $transHeadLogId,
|
||||
'Line_Item_Count' => $lineItemCnt,
|
||||
'SAP_Order_Number' => $sapOrder,
|
||||
'Item_Code' => $itemCode,
|
||||
])
|
||||
->withBasicAuth(
|
||||
'sb-eba140ab-74bb-44a4-8d92-70a636940def!b1182|it-rt-dev-cri-stjllphr!b68',
|
||||
'616d8991-307b-4ab1-be37-7894a8c6db9d$0p0fE2I7w1Ve23-lVSKQF0ka3mKrTVcKPJYELr-i4nE='
|
||||
)
|
||||
->withBody(json_encode($payload), 'application/json')
|
||||
//->dump()
|
||||
|
||||
->post('https://dev-cri-stjllphr.it-cpi004-rt.cfapps.ap11.hana.ondemand.com/http/LA2CRI/GoodsReceiptAgFG', $payload);
|
||||
|
||||
// dump($response->transferStats->getRequest());
|
||||
|
||||
// dd(json_encode($payload, JSON_PRETTY_PRINT));
|
||||
//dd($response->status(), $response->body());
|
||||
|
||||
// dump($response);
|
||||
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
|
||||
if ($messageCode && str_starts_with($messageCode, 'ERROR')) {
|
||||
|
||||
$cleanError = str_replace('ERROR:|', '', $messageCode);
|
||||
|
||||
// Update rows where plant_id and production_order match
|
||||
ProductionQuantity::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'ERROR',
|
||||
'sap_msg_description' => $cleanError,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Error')
|
||||
->body($cleanError)
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
$sapSuccessMsg = str_replace('SUCCESS:|', '', $messageCode);
|
||||
|
||||
ProductionQuantity::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'SUCCESS',
|
||||
'sap_msg_description' => $sapSuccessMsg,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Success')
|
||||
->body($sapSuccessMsg)
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Exception')
|
||||
->body('Error sending data to SAP: ' . $e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
})
|
||||
->color('success')
|
||||
->outlined()
|
||||
->hidden(fn (callable $get) => (!$get('scanned_quantity'))) //!$get('plant_id') && !$get('production_order') &&
|
||||
->extraAttributes(['class' => 'align-to-input']),
|
||||
]),
|
||||
])
|
||||
->columns(4);
|
||||
}
|
||||
|
||||
public function processValues($value)
|
||||
{
|
||||
|
||||
$this->pOrder = $value;
|
||||
|
||||
$latestValidation = ProductionQuantity::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$latestValidation) {
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body('No data found for the selected plant and production order.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
return;
|
||||
}
|
||||
|
||||
// $this->pUom = $latestValidation->uom;
|
||||
$this->transHeadLog = $latestValidation->id;
|
||||
|
||||
$itemId = $latestValidation->item_id;
|
||||
|
||||
$this->pUom = Item::where('id', $itemId)->value('uom');
|
||||
|
||||
$this->sNums = [];
|
||||
|
||||
if(!$this->pUom)
|
||||
{
|
||||
Notification::make()
|
||||
->title('UOM Not Found')
|
||||
->body('UOM not found for the production order')
|
||||
->icon('heroicon-o-x-circle')
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$latestProduction = ProductionQuantity::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
$this->pItem = $latestProduction
|
||||
? Item::where('id', $latestProduction->item_id)->value('code')
|
||||
: null;
|
||||
|
||||
|
||||
$this->sNums = ProductionQuantity::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->pluck('serial_number')
|
||||
->toArray();
|
||||
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production data send to sap');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Data';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ use Route;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
|
||||
class ProductionQuantityPage extends Page implements HasForms
|
||||
{
|
||||
@@ -130,7 +132,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->live()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->default(function () {
|
||||
@@ -163,7 +164,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->label('Block')
|
||||
->required()
|
||||
// ->nullable()
|
||||
->live()
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
@@ -174,7 +175,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->default(function () {
|
||||
$latestShiftId = optional(ProductionQuantity::latest()->first())->shift_id;
|
||||
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||
@@ -276,7 +276,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->live()
|
||||
->default(function () {
|
||||
return optional(ProductionQuantity::latest()->first())->line_id;
|
||||
})
|
||||
@@ -321,34 +320,55 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->hintColor('danger'),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->live()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
$this->prodOrder = $state;
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required()
|
||||
->minLength(7)
|
||||
->maxLength(14)
|
||||
//->columnSpan(1)
|
||||
->columnSpan(['default' => 1, 'sm' => 1])
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
|
||||
{
|
||||
$set('productionError', "Must be a numeric value with 7 to 14 digits.");
|
||||
$set('production_order', null);
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
$this->prodOrder = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('productionError', null);
|
||||
$set('production_order', $state);
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
$this->prodOrder = $state;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('productionError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
return;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}),
|
||||
|
||||
TextInput::make('item_code')
|
||||
->label('Item Code')
|
||||
->columnSpan(1)
|
||||
->autofocus(true)
|
||||
->reactive()
|
||||
->live()
|
||||
->default(fn () => $this->clear_qr)
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processAllValues($event.target.value)',
|
||||
]),
|
||||
// TextInput::make('item_code')
|
||||
// ->label('Item Code')
|
||||
// ->columnSpan(1)
|
||||
// ->autofocus(true)
|
||||
// //->reactive()
|
||||
// ->live(onBlur: true) // avoids per-keystroke triggering
|
||||
// ->default(fn () => $this->clear_qr)
|
||||
// ->extraAttributes([
|
||||
// 'wire:keydown.enter' => 'processAllValues($event.target.value)',
|
||||
// ]),
|
||||
|
||||
Hidden::make('serial_number')
|
||||
->required(),
|
||||
@@ -362,7 +382,8 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
TextInput::make('recent_qr')
|
||||
->label('Last scanned QR')
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->columnSpan(['default' => 1, 'sm' => 2])
|
||||
//->columnSpan(2)
|
||||
// ->default(function () {
|
||||
// // Get the latest 'item_id' foreign key from 'production_quantities' table
|
||||
// $latestProductionQuantity = ProductionQuantity::latest()->first();
|
||||
@@ -383,7 +404,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
|
||||
// })
|
||||
->default(fn () => $this->recQr)
|
||||
|
||||
->readOnly(true),
|
||||
|
||||
TextInput::make('id')
|
||||
@@ -392,11 +412,19 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()->name),
|
||||
])
|
||||
->columns(7);
|
||||
// ->columns(6);
|
||||
->columns(['default' => 1, 'sm' => 7]);
|
||||
}
|
||||
|
||||
|
||||
// Method to process the value when Enter is pressed
|
||||
|
||||
#[On('handleQrScan')]
|
||||
public function handleQrScan($value)
|
||||
{
|
||||
$this->processAllValues($value);
|
||||
}
|
||||
|
||||
public function processAllValues($formQRData)
|
||||
{
|
||||
|
||||
@@ -417,36 +445,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
$user = Filament::auth()->user(); //->name
|
||||
$operatorName = $user->name;
|
||||
$this->qrData = $formQRData;
|
||||
// dd($formData, $formQRData);
|
||||
// dd($this->form->getState()['serial_number']);
|
||||
|
||||
// try {
|
||||
// // Access the nested form data
|
||||
// $componentData = json_decode($formValues['components'][0]['snapshot'], true);
|
||||
// $formData = $componentData['data']['data'][0]; // Access first item in data array
|
||||
|
||||
// // Extract specific values
|
||||
// $this->qrData = $formQRData ?? $formData['item_code'];
|
||||
// $this->pId = $formData['plant_id'] ?? null;
|
||||
// $this->bId = $formData['block_name'] ?? null;
|
||||
// $this->sId = $formData['shift_id'] ?? null;
|
||||
// $this->lId = $formData['line_id'] ?? null;
|
||||
// $this->iId = $formData['item_id'] ?? null;
|
||||
// $this->succId = $formData['success_msg'] ?? null;
|
||||
// // $this->sNoId = $formData['serial_number'] ?? null;
|
||||
// $this->prodOrder = $formData['production_order'] ?? null;
|
||||
// $this->recQr = $formData['recent_qr'] ?? null;
|
||||
// $this->dispatch('plant-line-updated', $this->pId,$this->lId);
|
||||
// } catch (\Exception $e) {
|
||||
// //dd('Error parsing form data:', $e->getMessage(), $formValues);
|
||||
// Notification::make()
|
||||
// ->title("Error Parsing Form Data") // {$operatorName}
|
||||
// ->body($e->getMessage())
|
||||
// ->danger()
|
||||
// // ->persistent()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
$latestProductionQuantity = ProductionQuantity::latest()->first();
|
||||
|
||||
@@ -456,7 +454,6 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
$this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
|
||||
}
|
||||
|
||||
|
||||
if (empty($formQRData)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -616,7 +613,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
|
||||
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -635,7 +632,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
|
||||
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
@@ -1303,7 +1300,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
// 'item_code'=> null,
|
||||
//'item_code'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
@@ -1317,6 +1314,7 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
->title("Valid QR Found") // {$operatorName}
|
||||
->body("Valid QR code scanned: {$this->qrData}.")
|
||||
->success()
|
||||
->duration(200)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -1327,25 +1325,25 @@ class ProductionQuantityPage extends Page implements HasForms
|
||||
// For example:
|
||||
$model = ProductionQuantity::create($formValues);
|
||||
|
||||
// dd('Production Updated Event Dispatched');
|
||||
// dd('Production Updated Event Dispatched');
|
||||
|
||||
$this->dispatch('productionUpdated');
|
||||
|
||||
// // Optionally, you can emit an event or perform a redirect after saving
|
||||
// $this->emit('formSaved', $model->id);
|
||||
}
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
if (session()->has('select_plant') && session()->has('select_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
}
|
||||
}
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
if (session()->has('select_plant') && session()->has('select_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
}
|
||||
}
|
||||
|
||||
// Override the getTitle method
|
||||
public function getTitle(): string
|
||||
{
|
||||
return ''; // Return an empty string to remove the title
|
||||
}
|
||||
// Override the getTitle method
|
||||
public function getTitle(): string
|
||||
{
|
||||
return ''; // Return an empty string to remove the title
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
|
||||
1448
app/Filament/Pages/StickerReprint.php
Normal file
1448
app/Filament/Pages/StickerReprint.php
Normal file
File diff suppressed because it is too large
Load Diff
131
app/Filament/Pages/TrendChartAnalys.php
Normal file
131
app/Filament/Pages/TrendChartAnalys.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\TrendChartAnalysis;
|
||||
use App\Models\MfmMeter;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TrendChartAnalys extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.trend-chart-analys';
|
||||
|
||||
protected static ?string $navigationGroup = 'EMS DashBoard';
|
||||
|
||||
// use HasFiltersForm;
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
|
||||
$this->filtersForm->fill([
|
||||
'selected_plant' => null,
|
||||
'selected_meter' => null,
|
||||
'from_datetime' => null,
|
||||
'to_datetime' => null,
|
||||
'parameter' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
DateTimePicker::make('from_datetime')
|
||||
->label('From DateTime')
|
||||
->required()
|
||||
->before('to_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['from_datetime' => $formatted]);
|
||||
}),
|
||||
DateTimePicker::make('to_datetime')
|
||||
->label('To DateTime')
|
||||
->required()
|
||||
->after('from_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['to_datetime' => $formatted]);
|
||||
}),
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
// When plant changes, also reset meter_name
|
||||
$set('meter_name', null);
|
||||
session(['selected_meter' => null]);
|
||||
// dd($state);
|
||||
}),
|
||||
|
||||
Select::make('meter_name')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
|
||||
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Meter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_meter' => $state]);
|
||||
}),
|
||||
Select::make('parameter')
|
||||
->options([
|
||||
'Phase Voltage' => 'Phase Voltage',
|
||||
'Line Voltage' => 'Line Voltage',
|
||||
'Current' => 'Current',
|
||||
'Active Power' => 'Active Power',
|
||||
'Power Factor' => 'Power Factor',
|
||||
'Units' => 'Units',
|
||||
])
|
||||
->label('Select Parameter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['parameter' => $state]);
|
||||
}),
|
||||
|
||||
])
|
||||
->columns(5);
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Trend Chart Analysis';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Trend Chart Analysis';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (TrendChartAnalysis::canView()) {
|
||||
$widgets[] = TrendChartAnalysis::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view ems trend chart analysis dashboard');
|
||||
}
|
||||
}
|
||||
129
app/Filament/Pages/TrendLineAnalysis.php
Normal file
129
app/Filament/Pages/TrendLineAnalysis.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\TrendLineChart;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use App\Models\MfmMeter;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TrendLineAnalysis extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.trend-line-analysis';
|
||||
|
||||
protected static ?string $navigationGroup = 'EMS DashBoard';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
|
||||
$this->filtersForm->fill([
|
||||
'selected_plant' => null,
|
||||
'selected_meter' => null,
|
||||
'from_datetime' => null,
|
||||
'to_datetime' => null,
|
||||
'parameter' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
DateTimePicker::make('from_datetime')
|
||||
->label('From DateTime')
|
||||
->required()
|
||||
->before('to_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['from_datetime' => $formatted]);
|
||||
}),
|
||||
DateTimePicker::make('to_datetime')
|
||||
->label('To DateTime')
|
||||
->required()
|
||||
->after('from_datetime')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
|
||||
session(['to_datetime' => $formatted]);
|
||||
}),
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
// When plant changes, also reset meter_name
|
||||
$set('meter_name', null);
|
||||
session(['selected_meter' => null]);
|
||||
// dd($state);
|
||||
}),
|
||||
|
||||
Select::make('meter_name')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
|
||||
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Meter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_meter' => $state]);
|
||||
}),
|
||||
Select::make('parameter')
|
||||
->options([
|
||||
'Phase Voltage' => 'Phase Voltage',
|
||||
'Line Voltage' => 'Line Voltage',
|
||||
'Current' => 'Current',
|
||||
'Active Power' => 'Active Power',
|
||||
'Power Factor' => 'Power Factor',
|
||||
'Units' => 'Units',
|
||||
])
|
||||
->label('Select Parameter')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['parameter' => $state]);
|
||||
}),
|
||||
|
||||
])
|
||||
->columns(5);
|
||||
}
|
||||
// public static function getNavigationLabel(): string
|
||||
// {
|
||||
// return 'Trend Chart Analysis';
|
||||
// }
|
||||
// public function getHeading(): string
|
||||
// {
|
||||
// return 'Trend Chart Analysis';
|
||||
// }
|
||||
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (TrendLineChart::canView()) {
|
||||
$widgets[] = TrendLineChart::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view ems trend line analysis dashboard');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
182
app/Filament/Resources/AlertMailRuleResource.php
Normal file
182
app/Filament/Resources/AlertMailRuleResource.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Plant;
|
||||
use Dotenv\Exception\ValidationException;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
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\Section;
|
||||
use Illuminate\Validation\ValidationException as ValidationValidationException;
|
||||
|
||||
class AlertMailRuleResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AlertMailRule::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Alert Mail';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->options(fn () => Plant::pluck('name', 'id')->toArray())
|
||||
->required(fn ($get) => ! $get('is_active'))
|
||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
||||
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
|
||||
Forms\Components\Select::make('module')
|
||||
->label('Module')
|
||||
->required()
|
||||
->options([
|
||||
'InvoiceValidation' => 'InvoiceValidation',
|
||||
'ProductionQuantities' => 'ProductionQuantities',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
->options([
|
||||
'InvoiceMail' => 'Invoice Mail',
|
||||
'SerialInvoiceMail' => 'Serial Invoice Mail',
|
||||
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
||||
'ProductionMail' => 'Production Mail',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
->label('Email')
|
||||
->required(),
|
||||
Forms\Components\Select::make('schedule_type')
|
||||
->label('Schedule Type')
|
||||
->required()
|
||||
->options([
|
||||
'Live' => 'Live',
|
||||
'Hourly' => 'Hourly',
|
||||
'Daily' => 'Daily',
|
||||
]),
|
||||
Checkbox::make('is_active')
|
||||
->label('All Plants Reports')
|
||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
|
||||
->reactive(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(5),
|
||||
]);
|
||||
}
|
||||
|
||||
// Optionally, also override for update/editing
|
||||
// public static function mutateFormDataBeforeSave(array $data): array
|
||||
// {
|
||||
// dd('test');
|
||||
// if ($data['is_active']) {
|
||||
// $data['plant'] = 'All Plants';
|
||||
// }
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant')
|
||||
->label('Plant')
|
||||
->sortable()
|
||||
->formatStateUsing(function ($state) {
|
||||
static $plants;
|
||||
if (! $plants) {
|
||||
$plants = Plant::pluck('name', 'id')->toArray();
|
||||
}
|
||||
return $plants[$state] ?? 'All Plants';
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('module')
|
||||
->label('Module')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('rule_name')
|
||||
->label('Rule Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->label('Email')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('schedule_type')
|
||||
->label('Schedule Type')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAlertMailRules::route('/'),
|
||||
'create' => Pages\CreateAlertMailRule::route('/create'),
|
||||
'view' => Pages\ViewAlertMailRule::route('/{record}'),
|
||||
'edit' => Pages\EditAlertMailRule::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAlertMailRule extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
|
||||
if ($data['is_active']) {
|
||||
$data['plant'] = 0;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAlertMailRule extends EditRecord
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
//dd('test');
|
||||
if ($data['is_active']) {
|
||||
$data['plant'] = 0;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
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\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAlertMailRules extends ListRecords
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewAlertMailRule extends ViewRecord
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
151
app/Filament/Resources/DeviceMasterResource.php
Normal file
151
app/Filament/Resources/DeviceMasterResource.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\DeviceMasterExporter;
|
||||
use App\Filament\Imports\DeviceMasterImporter;
|
||||
use App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
use App\Filament\Resources\DeviceMasterResource\RelationManagers;
|
||||
use App\Models\DeviceMaster;
|
||||
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\Section;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class DeviceMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = DeviceMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Device Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('mac_address')
|
||||
->label('MAC Address'),
|
||||
Forms\Components\TextInput::make('ip_address')
|
||||
->label('IP Address'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(4),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Device Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mac_address')
|
||||
->label('MAC Address')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('ip_address')
|
||||
->label('IP Address')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->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([
|
||||
ImportAction::make()
|
||||
->importer(DeviceMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import device master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(DeviceMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export device master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListDeviceMasters::route('/'),
|
||||
'create' => Pages\CreateDeviceMaster::route('/create'),
|
||||
'view' => Pages\ViewDeviceMaster::route('/{record}'),
|
||||
'edit' => Pages\EditDeviceMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDeviceMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditDeviceMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::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\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListDeviceMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\DeviceMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\DeviceMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewDeviceMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
443
app/Filament/Resources/EbReadingResource.php
Normal file
443
app/Filament/Resources/EbReadingResource.php
Normal file
@@ -0,0 +1,443 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\EbReadingExporter;
|
||||
use App\Filament\Imports\EbReadingImporter;
|
||||
use App\Filament\Resources\EbReadingResource\Pages;
|
||||
use App\Filament\Resources\EbReadingResource\RelationManagers;
|
||||
use App\Models\EbReading;
|
||||
use App\Models\Plant;
|
||||
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\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
|
||||
class EbReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = EbReading::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('lcd_segment_check')
|
||||
->label('LCD Segment Check'),
|
||||
Forms\Components\TextInput::make('meter_serial_no')
|
||||
->label('Meter Serial No'),
|
||||
Forms\Components\DateTimePicker::make('eb_date_time')
|
||||
->required()
|
||||
->label('EB Date Time'),
|
||||
Forms\Components\TextInput::make('ph_seq_of_volt')
|
||||
->label('PH Sequence of Volt'),
|
||||
Forms\Components\TextInput::make('ph_assoc_conn_check')
|
||||
->label('PH Association Connection Check'),
|
||||
Forms\Components\TextInput::make('instantaneous_ph_volt')
|
||||
->label('Instantaneous PH Volt'),
|
||||
Forms\Components\TextInput::make('instantaneous_curr')
|
||||
->label('Instantaneous Current'),
|
||||
Forms\Components\TextInput::make('instantaneous_freq')
|
||||
->label('Instantaneous Frequency'),
|
||||
Forms\Components\TextInput::make('instantaneous_kw_with_sign')
|
||||
->label('Instantaneous KW with Sign'),
|
||||
Forms\Components\TextInput::make('instantaneous_kva')
|
||||
->label('Instantaneous KVA'),
|
||||
Forms\Components\TextInput::make('instantaneous_kv_ar')
|
||||
->label('Instantaneous KV AR'),
|
||||
Forms\Components\TextInput::make('instantaneous_pf_with_sign')
|
||||
->label('Instantaneous PF with Sign'),
|
||||
Forms\Components\TextInput::make('rd_with_elapsed_time_kva')
|
||||
->label('RD with Elapsed Time KVA'),
|
||||
Forms\Components\TextInput::make('cum_active_import_energy')
|
||||
->label('Cumulative Active Import Energy'),
|
||||
Forms\Components\TextInput::make('tod1_active_energy_6_9')
|
||||
->label('TOD1 Active Energy 6-9'),
|
||||
Forms\Components\TextInput::make('tod2_active_energy_18_21')
|
||||
->label('TOD2 Active Energy 18-21'),
|
||||
Forms\Components\TextInput::make('tod3_active_energy_21_22')
|
||||
->label('TOD3 Active Energy 21-22'),
|
||||
Forms\Components\TextInput::make('tod4_active_energy_5_6_9_18')
|
||||
->label('TOD4 Active Energy 5-6-9-18'),
|
||||
Forms\Components\TextInput::make('tod5_active_energy_22_5')
|
||||
->label('TOD5 Active Energy 22-5'),
|
||||
Forms\Components\TextInput::make('cum_reac_lag_energy')
|
||||
->label('Cumulative Reactive Lag Energy'),
|
||||
Forms\Components\TextInput::make('cum_reac_lead_energy')
|
||||
->label('Cumulative Reactive Lead Energy'),
|
||||
Forms\Components\TextInput::make('cum_appar_energy')
|
||||
->label('Cumulative Apparent Energy'),
|
||||
Forms\Components\TextInput::make('tod1_appar_energy_6_9')
|
||||
->label('TOD1 Apparent Energy 6-9'),
|
||||
Forms\Components\TextInput::make('tod2_appar_energy_18_21')
|
||||
->label('TOD2 Apparent Energy 18-21'),
|
||||
Forms\Components\TextInput::make('tod3_appar_energy_21_22')
|
||||
->label('TOD3 Apparent Energy 21-22'),
|
||||
Forms\Components\TextInput::make('tod4_appar_energy_5_6_9_18')
|
||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
||||
Forms\Components\TextInput::make('tod5_appar_energy_22_5')
|
||||
->label('TOD5 Apparent Energy 22-5'),
|
||||
Forms\Components\TextInput::make('avg_pow_factor')
|
||||
->label('Average Power Factor'),
|
||||
Forms\Components\TextInput::make('avg_freq_15min_last_ip')
|
||||
->label('Average Frequency 15min Last IP'),
|
||||
Forms\Components\TextInput::make('net_kv_arh_high')
|
||||
->label('Net KV ARH High'),
|
||||
Forms\Components\TextInput::make('net_kv_arh_low')
|
||||
->label('Net KV ARH Low'),
|
||||
Forms\Components\TextInput::make('cum_md_kva')
|
||||
->label('Cumulative MD KVA'),
|
||||
Forms\Components\TextInput::make('present_md_kva')
|
||||
->label('Present MD KVA'),
|
||||
Forms\Components\DateTimePicker::make('present_md_kva_date_time')
|
||||
->label('Present MD KVA Date Time')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('tod1_md_kva_6_9')
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
Forms\Components\TextInput::make('tod2_md_kva_18_21')
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
Forms\Components\TextInput::make('tod3_md_kva_21_22')
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
Forms\Components\TextInput::make('tod4_md_kva_5_6_9_18')
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
Forms\Components\TextInput::make('tod5_md_kva_22_5')
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
Forms\Components\TextInput::make('total_pow_off_hours')
|
||||
->label('Total Power Off Hours'),
|
||||
Forms\Components\TextInput::make('programming_count')
|
||||
->label('Programming Count'),
|
||||
Forms\Components\TextInput::make('last_occ_res_event_type')
|
||||
->label('Last Occurrence/Reset Event Type'),
|
||||
Forms\Components\DateTimePicker::make('last_occ_res_event_date_time')
|
||||
->label('Last Occurrence/Reset Event Date Time')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('tamper_count')
|
||||
->label('Tamper Count'),
|
||||
Forms\Components\TextInput::make('reset_count')
|
||||
->label('Reset Count'),
|
||||
Forms\Components\DateTimePicker::make('last_md_reset_date_time')
|
||||
->label('Last MD Reset Date Time')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('electrician_sign')
|
||||
->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('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('lcd_segment_check')
|
||||
->alignCenter()
|
||||
->label('LCD Segment Check'),
|
||||
Tables\Columns\TextColumn::make('meter_serial_no')
|
||||
->alignCenter()
|
||||
->label('Meter Serial No'),
|
||||
Tables\Columns\TextColumn::make('eb_date_time')
|
||||
->alignCenter()
|
||||
->label('EB Date Time'),
|
||||
Tables\Columns\TextColumn::make('ph_seq_of_volt')
|
||||
->alignCenter()
|
||||
->label('PH Sequence of Volt'),
|
||||
Tables\Columns\TextColumn::make('ph_assoc_conn_check')
|
||||
->alignCenter()
|
||||
->label('PH Association Connection Check'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_ph_volt')
|
||||
->alignCenter()
|
||||
->label('Instantaneous PH Volt'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_curr')
|
||||
->alignCenter()
|
||||
->label('Instantaneous Current'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_freq')
|
||||
->alignCenter()
|
||||
->label('Instantaneous Frequency'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_kw_with_sign')
|
||||
->alignCenter()
|
||||
->label('Instantaneous KW with Sign'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_kva')
|
||||
->alignCenter()
|
||||
->label('Instantaneous KVA'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_kv_ar')
|
||||
->alignCenter()
|
||||
->label('Instantaneous KV AR'),
|
||||
Tables\Columns\TextColumn::make('instantaneous_pf_with_sign')
|
||||
->alignCenter()
|
||||
->label('Instantaneous PF with Sign'),
|
||||
Tables\Columns\TextColumn::make('rd_with_elapsed_time_kva')
|
||||
->alignCenter()
|
||||
->label('RD with Elapsed Time KVA'),
|
||||
Tables\Columns\TextColumn::make('cum_active_import_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Active Import Energy'),
|
||||
Tables\Columns\TextColumn::make('tod1_active_energy_6_9')
|
||||
->alignCenter()
|
||||
->label('TOD1 Active Energy 6-9'),
|
||||
Tables\Columns\TextColumn::make('tod2_active_energy_18_21')
|
||||
->alignCenter()
|
||||
->label('TOD2 Active Energy 18-21'),
|
||||
Tables\Columns\TextColumn::make('tod3_active_energy_21_22')
|
||||
->alignCenter()
|
||||
->label('TOD3 Active Energy 21-22'),
|
||||
Tables\Columns\TextColumn::make('tod4_active_energy_5_6_9_18')
|
||||
->alignCenter()
|
||||
->label('TOD4 Active Energy 5-6-9-18'),
|
||||
Tables\Columns\TextColumn::make('tod5_active_energy_22_5')
|
||||
->alignCenter()
|
||||
->label('TOD5 Active Energy 22-5'),
|
||||
Tables\Columns\TextColumn::make('cum_reac_lag_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Reactive Lag Energy'),
|
||||
Tables\Columns\TextColumn::make('cum_reac_lead_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Reactive Lead Energy'),
|
||||
Tables\Columns\TextColumn::make('cum_appar_energy')
|
||||
->alignCenter()
|
||||
->label('Cumulative Apparent Energy'),
|
||||
Tables\Columns\TextColumn::make('tod1_appar_energy_6_9')
|
||||
->alignCenter()
|
||||
->label('TOD1 Apparent Energy 6-9'),
|
||||
Tables\Columns\TextColumn::make('tod2_appar_energy_18_21')
|
||||
->alignCenter()
|
||||
->label('TOD2 Apparent Energy 18-21'),
|
||||
Tables\Columns\TextColumn::make('tod3_appar_energy_21_22')
|
||||
->alignCenter()
|
||||
->label('TOD3 Apparent Energy 21-22'),
|
||||
Tables\Columns\TextColumn::make('tod4_appar_energy_5_6_9_18')
|
||||
->alignCenter()
|
||||
->label('TOD4 Apparent Energy 5-6-9-18'),
|
||||
Tables\Columns\TextColumn::make('tod5_appar_energy_22_5')
|
||||
->alignCenter()
|
||||
->label('TOD5 Apparent Energy 22-5'),
|
||||
Tables\Columns\TextColumn::make('avg_pow_factor')
|
||||
->alignCenter()
|
||||
->label('Average Power Factor'),
|
||||
Tables\Columns\TextColumn::make('avg_freq_15min_last_ip')
|
||||
->alignCenter()
|
||||
->label('Average Frequency 15min Last IP'),
|
||||
Tables\Columns\TextColumn::make('net_kv_arh_high')
|
||||
->alignCenter()
|
||||
->label('Net KV ARH High'),
|
||||
Tables\Columns\TextColumn::make('net_kv_arh_low')
|
||||
->alignCenter()
|
||||
->label('Net KV ARH Low'),
|
||||
Tables\Columns\TextColumn::make('cum_md_kva')
|
||||
->alignCenter()
|
||||
->label('Cumulative MD KVA'),
|
||||
Tables\Columns\TextColumn::make('present_md_kva')
|
||||
->alignCenter()
|
||||
->label('Present MD KVA'),
|
||||
Tables\Columns\TextColumn::make('present_md_kva_date_time')
|
||||
->alignCenter()
|
||||
->label('Present MD KVA Date Time'),
|
||||
Tables\Columns\TextColumn::make('tod1_md_kva_6_9')
|
||||
->alignCenter()
|
||||
->label('TOD1 MD KVA 6-9'),
|
||||
Tables\Columns\TextColumn::make('tod2_md_kva_18_21')
|
||||
->alignCenter()
|
||||
->label('TOD2 MD KVA 18-21'),
|
||||
Tables\Columns\TextColumn::make('tod3_md_kva_21_22')
|
||||
->alignCenter()
|
||||
->label('TOD3 MD KVA 21-22'),
|
||||
Tables\Columns\TextColumn::make('tod4_md_kva_5_6_9_18')
|
||||
->alignCenter()
|
||||
->label('TOD4 MD KVA 5-6-9-18'),
|
||||
Tables\Columns\TextColumn::make('tod5_md_kva_22_5')
|
||||
->alignCenter()
|
||||
->label('TOD5 MD KVA 22-5'),
|
||||
Tables\Columns\TextColumn::make('total_pow_off_hours')
|
||||
->alignCenter()
|
||||
->label('Total Power Off Hours'),
|
||||
Tables\Columns\TextColumn::make('programming_count')
|
||||
->alignCenter()
|
||||
->label('Programming Count'),
|
||||
Tables\Columns\TextColumn::make('last_occ_res_event_type')
|
||||
->alignCenter()
|
||||
->label('Last Occurrence/Reset Event Type'),
|
||||
Tables\Columns\TextColumn::make('last_occ_res_event_date_time')
|
||||
->alignCenter()
|
||||
->label('Last Occurrence/Reset Event Date Time'),
|
||||
Tables\Columns\TextColumn::make('tamper_count')
|
||||
->alignCenter()
|
||||
->label('Tamper Count'),
|
||||
Tables\Columns\TextColumn::make('reset_count')
|
||||
->alignCenter()
|
||||
->label('Reset Count'),
|
||||
Tables\Columns\TextColumn::make('last_md_reset_date_time')
|
||||
->alignCenter()
|
||||
->label('Last MD Reset Date Time'),
|
||||
Tables\Columns\TextColumn::make('electrician_sign')
|
||||
->alignCenter()
|
||||
->label('Created By'),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->alignCenter()
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
// ->filters([
|
||||
// Tables\Filters\TrashedFilter::make(),
|
||||
// ])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function () {
|
||||
return Plant::pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('electrician_sign', null);
|
||||
}),
|
||||
TextInput::make('electrician_sign')
|
||||
->label('Created By'),
|
||||
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),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['electrician_sign'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
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['electrician_sign'])) {
|
||||
$query->where('electrician_sign', $data['electrician_sign']);
|
||||
}
|
||||
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['electrician_sign'])) {
|
||||
$indicators[] = 'Created By: ' . $data['electrician_sign'];
|
||||
}
|
||||
|
||||
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(EbReadingImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import eb reading');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(EbReadingExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export eb reading');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListEbReadings::route('/'),
|
||||
'create' => Pages\CreateEbReading::route('/create'),
|
||||
'view' => Pages\ViewEbReading::route('/{record}'),
|
||||
'edit' => Pages\EditEbReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEbReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEbReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = EbReadingResource::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\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEbReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EbReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EbReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewEbReading extends ViewRecord
|
||||
{
|
||||
protected static string $resource = EbReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -73,14 +73,14 @@ class GuardNameResource extends Resource
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('identification1')
|
||||
->label('Identification-1')
|
||||
->label('Aadhar Number')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('identification2')
|
||||
->label('Identification-2')
|
||||
->label('PAN Number')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
|
||||
@@ -17,6 +17,7 @@ use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action as ActionsAction;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -121,12 +122,14 @@ class InvoiceValidationResource extends Resource
|
||||
->readOnly(fn (callable $get) => empty($get('invoice_number')))
|
||||
//->disabled(fn (Get $get) => empty($get('invoice_number')))
|
||||
->extraAttributes([
|
||||
'id' => 'serial_number_input',
|
||||
'x-data' => '{ value: "" }',
|
||||
'x-model' => 'value',
|
||||
'wire:keydown.enter.prevent' => 'processSerialNumber(value)', // Using wire:keydown
|
||||
])
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('update_invoice', 0);
|
||||
// $this->dispatch('focus-serial-number');
|
||||
// if (!$invNo) { return; } else { }
|
||||
})
|
||||
->columnSpan(1),
|
||||
@@ -145,16 +148,16 @@ class InvoiceValidationResource extends Resource
|
||||
->reactive()
|
||||
->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || !empty($get('serial_number')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if(!$get('plant_id'))
|
||||
if (!$get('plant_id'))
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
}
|
||||
|
||||
if($get('update_invoice') === "1")
|
||||
if ($get('update_invoice') == "1")
|
||||
{
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count();
|
||||
if($totQuan <= 0)
|
||||
if ($totQuan <= 0)
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
@@ -164,9 +167,9 @@ class InvoiceValidationResource extends Resource
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count();
|
||||
|
||||
if($totMQuan > 0)
|
||||
if ($totMQuan > 0)
|
||||
{
|
||||
if ($totQuan === $scanMQuan)
|
||||
if ($totQuan == $scanMQuan)
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
@@ -174,7 +177,7 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($totQuan === $scanSQuan)
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
@@ -340,15 +343,57 @@ class InvoiceValidationResource extends Resource
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
||||
if ($totQuan > 0)
|
||||
{
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->count();
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
|
||||
Notification::make()
|
||||
->title("Serial invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
$invoicePlantId = $invoiceFirst->plant_id;
|
||||
if ($plantId != $invoicePlantId)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Serial invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
|
||||
if($totQuan == $scanSQuan && $totQuan > 0)
|
||||
if ($totQuan > 0 && $totQuan == $scanSQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial invoice already completed the scanning process for selected plant.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial invoice already completed the scanning process for selected plant.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
@@ -361,7 +406,7 @@ class InvoiceValidationResource extends Resource
|
||||
{
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if((count($rows) - 1) <= 0)
|
||||
if ((count($rows) - 1) <= 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
@@ -385,7 +430,7 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -396,19 +441,17 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
if (!empty($materialCode))
|
||||
{
|
||||
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
{
|
||||
$invalidMatCodes[] = $materialCode;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (empty($serialNumber)) {
|
||||
$missingSerials[] = $materialCode;
|
||||
|
||||
}
|
||||
else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
$invalidSerialCodes[] = $serialNumber;
|
||||
}
|
||||
@@ -450,7 +493,6 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!empty($uniqueMissingSerials)) {
|
||||
Notification::make()
|
||||
->title('Missing Serial Numbers')
|
||||
@@ -476,7 +518,7 @@ class InvoiceValidationResource extends Resource
|
||||
else if (!empty($duplicateSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Numbers')
|
||||
->body('The following serial numbers are already exist in database:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->danger()
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
@@ -529,30 +571,30 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
// Check which codes have a material_type set (not null)
|
||||
$invalidCodes = $matchedItems
|
||||
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
if (count($invalidCodes) > 10)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid item codes found')
|
||||
->body('' . count($invalidCodes) . 'item codes found have material type.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid item codes found')
|
||||
->body('' . count($invalidCodes) . 'item codes found have material type.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(count($invalidCodes) > 0)
|
||||
else if (count($invalidCodes) > 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid item codes found')
|
||||
->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes))
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid item codes found')
|
||||
->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
@@ -564,7 +606,7 @@ class InvoiceValidationResource extends Resource
|
||||
// Save full file path to session
|
||||
session(['uploaded_invoice_path' => $fullPath]);
|
||||
Notification::make()
|
||||
->title('Serial invoice imported successfully.')
|
||||
->title('Serial invoice imported successfully.')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
@@ -600,7 +642,6 @@ class InvoiceValidationResource extends Resource
|
||||
->visible(fn (Get $get) => !empty($get('plant_id')))
|
||||
->directory('uploads/temp'),
|
||||
])
|
||||
|
||||
->action(function (array $data) {
|
||||
$uploadedFile = $data['invoice_material'];
|
||||
|
||||
@@ -617,10 +658,52 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
$fullPath = Storage::disk('local')->path($path);
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
||||
if ($totQuan > 0)
|
||||
{
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->count();
|
||||
if ($totQuan == $scanMQuan)
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
|
||||
Notification::make()
|
||||
->title("Material invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
||||
$invoicePlantId = $invoiceFirst->plant_id;
|
||||
if ($plantId != $invoicePlantId)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Material invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
if($totQuan == $scanMQuan && $totQuan > 0)
|
||||
if ($totQuan > 0 && $totQuan == $scanMQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Material invoice already completed the scanning process for selected plant.')
|
||||
@@ -636,7 +719,7 @@ class InvoiceValidationResource extends Resource
|
||||
{
|
||||
$rows = Excel::toArray(null, $fullPath)[0];
|
||||
|
||||
if((count($rows) - 1) <= 0)
|
||||
if ((count($rows) - 1) <= 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Records Not Found')
|
||||
@@ -659,7 +742,7 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$materialQuantity = trim($row[1]);
|
||||
@@ -669,13 +752,13 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
|
||||
if (!empty($materialCode)) {
|
||||
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
||||
{
|
||||
$invalidMatCodes[] = $materialCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($materialQuantity == 0)
|
||||
if ($materialQuantity == 0)
|
||||
{
|
||||
$invalidMaterialQuan[] = $materialCode;
|
||||
}
|
||||
@@ -683,7 +766,7 @@ class InvoiceValidationResource extends Resource
|
||||
{
|
||||
$missingQuantities[] = $materialCode;
|
||||
}
|
||||
else if(!is_numeric($materialQuantity))
|
||||
else if (!is_numeric($materialQuantity))
|
||||
{
|
||||
$invalidMatQuan[] = $materialCode;
|
||||
}
|
||||
@@ -818,7 +901,7 @@ class InvoiceValidationResource extends Resource
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(count($invalidCodes) > 0)
|
||||
else if (count($invalidCodes) > 0)
|
||||
{
|
||||
$invalidCodes = array_unique($invalidCodes);
|
||||
Notification::make()
|
||||
@@ -849,29 +932,29 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalExcelQty === 0) {
|
||||
if ($totalExcelQty == 0) {
|
||||
$zeroQtyCodes[] = $code;
|
||||
} elseif (!is_numeric($totalExcelQty)) {
|
||||
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
|
||||
$notDivisibleCodes[] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$showValidationNotification = function(array $codes, string $message) {
|
||||
if (count($codes) === 0) return;
|
||||
if (count($codes) == 0) return;
|
||||
|
||||
$uniqueCodes = array_unique($codes);
|
||||
$codeList = implode(', ', $uniqueCodes);
|
||||
@@ -927,6 +1010,16 @@ class InvoiceValidationResource extends Resource
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Radio::make('invoice_type')
|
||||
->label('Type ?')
|
||||
->boolean()
|
||||
->options([
|
||||
'Serial' => 'Serial',
|
||||
'Material' => 'Material'
|
||||
])
|
||||
->default('Serial')
|
||||
->inlineLabel(false)
|
||||
->inline(),
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
@@ -936,6 +1029,7 @@ class InvoiceValidationResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('sticker_master_id', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
TextInput::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
@@ -960,6 +1054,31 @@ class InvoiceValidationResource extends Resource
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('scanned_status')
|
||||
->label('Scanned Status')
|
||||
->nullable()
|
||||
->options([
|
||||
'Scanned' => 'Scanned',
|
||||
'Pending' => 'Pending',
|
||||
])
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('operator_id')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId)
|
||||
{
|
||||
return InvoiceValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
return InvoiceValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -973,10 +1092,46 @@ class InvoiceValidationResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
|
||||
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
||||
if (empty($data['invoice_type']))
|
||||
{
|
||||
Notification::make()
|
||||
->title('Please, choose invoice type to filter.')
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if ($data['invoice_type'] == 'Serial') {
|
||||
$query->whereNull('quantity');
|
||||
|
||||
if (!empty($data['scanned_status'])) {
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
$query->whereNotNull('scanned_status')->where('scanned_status', '!=', '');
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
//$query->whereNull('scanned_status')->orWhere('scanned_status', '');
|
||||
$query->where(function ($query) use ($data) {
|
||||
// if (empty($data['scanned_status']) || $data['scanned_status'] == 'Pending') {
|
||||
$query->whereNull('scanned_status')->orWhere('scanned_status', '!=', 'Scanned');
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
} elseif ($data['invoice_type'] == 'Material') {
|
||||
$query->whereNotNull('quantity');//->where('quantity', '>', 0)
|
||||
|
||||
if (!empty($data['scanned_status'])) {
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
$query->whereNotNull('serial_number')->where('serial_number', '!=', '');
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
$query->where(function ($query) use ($data) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '=', '');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
@@ -997,6 +1152,10 @@ class InvoiceValidationResource extends Resource
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$query->where('operator_id', $data['operator_id']);
|
||||
}
|
||||
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
|
||||
->pluck('id')
|
||||
@@ -1022,6 +1181,15 @@ class InvoiceValidationResource extends Resource
|
||||
$indicators[] = 'Serial Number: ' . $data['serial_number'];
|
||||
}
|
||||
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Code: ' . $itemCode;
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$indicators[] = 'Created By: ' . $data['operator_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
@@ -1030,9 +1198,8 @@ class InvoiceValidationResource extends Resource
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
if (!empty($data['sticker_master_id'])) {
|
||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Code: ' . $itemCode;
|
||||
if (!empty($data['scanned_status'])) {
|
||||
$indicators[] = 'Scanned Status: ' . $data['scanned_status'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Imports\ExcelImport;
|
||||
use App\Livewire\InvoiceDataTable;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Pages\Concerns\ExposesTableToWidgets;
|
||||
@@ -74,6 +75,22 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$this->plantId = $plantId;
|
||||
|
||||
$plant = Plant::find($plantId);
|
||||
|
||||
if ($plant)
|
||||
{
|
||||
$plantCode = $plant->code;
|
||||
}
|
||||
else
|
||||
{
|
||||
$plantCode = null;
|
||||
}
|
||||
|
||||
//..GET SERIAL INVOICE API
|
||||
|
||||
|
||||
//..
|
||||
|
||||
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
|
||||
|
||||
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;
|
||||
@@ -116,7 +133,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scanMQuan,
|
||||
]);
|
||||
|
||||
if ($totQuan === $scanMQuan)
|
||||
if ($totQuan == $scanMQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Completed: Material Invoice")
|
||||
@@ -134,7 +151,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -147,7 +164,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
if($updateStatus === '1')
|
||||
if($updateStatus == '1')
|
||||
{
|
||||
//'Material invoice update in progress...';
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
@@ -185,7 +202,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$materialQuantity = trim($row[1]);
|
||||
@@ -390,7 +407,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -399,16 +416,16 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalExcelQty === 0) {
|
||||
if ($totalExcelQty == 0) {
|
||||
$zeroQtyCodes[] = $code;
|
||||
} elseif (!is_numeric($totalExcelQty)) {
|
||||
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
|
||||
$notDivisibleCodes[] = $code;
|
||||
}
|
||||
}
|
||||
@@ -420,7 +437,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$showValidationNotification = function(array $codes, string $message) {
|
||||
if (count($codes) === 0) return;
|
||||
if (count($codes) == 0) return;
|
||||
|
||||
$uniqueCodes = array_unique($codes);
|
||||
$codeList = implode(', ', $uniqueCodes);
|
||||
@@ -452,7 +469,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$inserted = 0;
|
||||
foreach ($matchedItems as $sticker)
|
||||
{
|
||||
if ($newQuan === -1 && !$hasQuanTyp)
|
||||
if ($newQuan == -1 && !$hasQuanTyp)
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '');
|
||||
@@ -461,7 +478,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
}
|
||||
else if ($newQuan === -1 && $hasQuanTyp)
|
||||
else if ($newQuan == -1 && $hasQuanTyp)
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
|
||||
$query->whereNull('serial_number')->orWhere('serial_number', '');
|
||||
@@ -481,7 +498,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -490,7 +507,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -522,7 +539,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -531,7 +548,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -564,7 +581,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -573,7 +590,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty;
|
||||
}
|
||||
}
|
||||
@@ -669,7 +686,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
if ($inserted > 0 || $oldQuan !== $newQuan)
|
||||
if ($inserted > 0 || $oldQuan != $newQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Material invoice successfully updatad.")
|
||||
@@ -695,13 +712,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -775,7 +792,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
||||
// $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
if ($totQuan === $scanSQuan)
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Completed: Serial Invoice")
|
||||
@@ -793,7 +810,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -804,7 +821,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->send();
|
||||
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
if($updateStatus === '1')
|
||||
if($updateStatus == '1')
|
||||
{
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
@@ -846,7 +863,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -1087,7 +1104,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$inserted = 0;
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) // Skip header;
|
||||
if ($index == 0) // Skip header;
|
||||
{
|
||||
InvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where(function($query) {
|
||||
@@ -1138,7 +1155,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
if ($inserted > 0 || $oldQuan !== $newQuan)
|
||||
if ($inserted > 0 || $oldQuan != $newQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Serial invoice successfully updated.")
|
||||
@@ -1165,13 +1182,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1283,7 +1300,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$uploadedFilename = pathinfo($fullPath, PATHINFO_FILENAME);
|
||||
|
||||
// Compare with invoice number
|
||||
if ($uploadedFilename !== $invoiceNumber) {
|
||||
if ($uploadedFilename != $invoiceNumber) {
|
||||
Notification::make()
|
||||
->title("Uploaded file name does not match the invoice number.")
|
||||
->danger()
|
||||
@@ -1326,7 +1343,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue;
|
||||
if ($index == 0) continue;
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
|
||||
@@ -1365,7 +1382,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
if($invoiceType === 'M')
|
||||
if($invoiceType == 'M')
|
||||
{
|
||||
$invalidMatCodes = [];
|
||||
$materialCodes = [];
|
||||
@@ -1375,7 +1392,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$materialQuantity = trim($row[1]);
|
||||
@@ -1578,7 +1595,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1587,23 +1604,23 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalExcelQty === 0) {
|
||||
if ($totalExcelQty == 0) {
|
||||
$zeroQtyCodes[] = $code;
|
||||
} elseif (!is_numeric($totalExcelQty)) {
|
||||
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
|
||||
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
|
||||
$notDivisibleCodes[] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$showValidationNotification = function(array $codes, string $message) {
|
||||
if (count($codes) === 0) return;
|
||||
if (count($codes) == 0) return;
|
||||
|
||||
$uniqueCodes = array_unique($codes);
|
||||
$codeList = implode(', ', $uniqueCodes);
|
||||
@@ -1642,7 +1659,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1651,7 +1668,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -1677,7 +1694,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1686,7 +1703,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -1711,7 +1728,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$excelCode = trim($row[0]);
|
||||
$excelMatQty = trim($row[1]);
|
||||
@@ -1720,7 +1737,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($excelCode === $code && is_numeric($excelMatQty)) {
|
||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||
}
|
||||
}
|
||||
@@ -1759,13 +1776,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1805,7 +1822,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($invoiceType === 'S')
|
||||
else if($invoiceType == 'S')
|
||||
{
|
||||
$invalidMatCodes = [];
|
||||
$materialCodes = [];
|
||||
@@ -1817,7 +1834,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue; // Skip header
|
||||
if ($index == 0) continue; // Skip header
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -2077,7 +2094,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$inserted = 0;
|
||||
foreach ($rows as $index => $row)
|
||||
{
|
||||
if ($index === 0) continue;
|
||||
if ($index == 0) continue;
|
||||
|
||||
$materialCode = trim($row[0]);
|
||||
$serialNumber = trim($row[1]);
|
||||
@@ -2123,13 +2140,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
{
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2201,9 +2218,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count();
|
||||
if ($totalQuantity === $scannedQuantity)
|
||||
if ($totalQuantity == $scannedQuantity)
|
||||
{
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2255,7 +2272,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
if ($totMQuan > 0)
|
||||
{
|
||||
if ($totQuan === $scanMQuan)
|
||||
if ($totQuan == $scanMQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Material Invoice')
|
||||
@@ -2282,7 +2299,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -2759,7 +2776,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
|
||||
if($totQuan === $scannedMQuantity)
|
||||
if($totQuan == $scannedMQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Material Invoice')
|
||||
@@ -2786,7 +2803,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2804,7 +2821,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($totQuan === $scanSQuan)
|
||||
if ($totQuan == $scanSQuan)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -2831,7 +2848,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -3004,7 +3021,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadMotorQr === $hasMotorQr)
|
||||
else if($hadMotorQr == $hasMotorQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Motor QR')
|
||||
@@ -3027,7 +3044,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
$record->motor_scanned_status = 1;
|
||||
//if($hadPumpQr === $hasPumpQr && $hadPumpSetQr === $hasPumpSetQr)
|
||||
//if($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
||||
if($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr)
|
||||
{
|
||||
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -3038,7 +3055,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt === $scanCnt)
|
||||
if($packCnt == $scanCnt)
|
||||
{
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
@@ -3067,7 +3084,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if($totQuan === $scannedQuantity)
|
||||
if($totQuan == $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -3085,7 +3102,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3114,7 +3131,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadPumpQr === $hasPumpQr)
|
||||
else if($hadPumpQr == $hasPumpQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump QR')
|
||||
@@ -3137,7 +3154,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
$record->pump_scanned_status = 1;
|
||||
// if($hadMotorQr === $hasMotorQr && $hadPumpSetQr === $hasPumpSetQr && ($hadCapacitorQr === '1' && $hasCapacitorQr))
|
||||
// if($hadMotorQr == $hasMotorQr && $hadPumpSetQr == $hasPumpSetQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
|
||||
if($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr)
|
||||
{
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -3148,7 +3165,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt === $scanCnt)
|
||||
if($packCnt == $scanCnt)
|
||||
{
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
@@ -3177,7 +3194,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if($totQuan === $scannedQuantity)
|
||||
if($totQuan == $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -3195,7 +3212,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3226,7 +3243,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadCapacitorQr === '1' && $hasCapacitorQr)
|
||||
else if($hadCapacitorQr == '1' && $hasCapacitorQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Capacitor QR')
|
||||
@@ -3285,7 +3302,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if($hadPumpSetQr === $hasPumpSetQr)
|
||||
else if($hadPumpSetQr == $hasPumpSetQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Duplicate: Pump Set QR')
|
||||
@@ -3308,7 +3325,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$packCnt = 1;
|
||||
$scanCnt = 1;
|
||||
$record->scanned_status_set = 1;
|
||||
// if($hadMotorQr === $hasMotorQr && $hadPumpQr === $hasPumpQr && ($hadCapacitorQr === '1' && $hasCapacitorQr))
|
||||
// if($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
|
||||
if($hasMotorQr || $hasPumpQr || $hasCapacitorQr)
|
||||
{
|
||||
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
|
||||
@@ -3319,7 +3336,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
|
||||
$scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
|
||||
|
||||
if($packCnt === $scanCnt)
|
||||
if($packCnt == $scanCnt)
|
||||
{
|
||||
$record->scanned_status = 'Scanned';
|
||||
}
|
||||
@@ -3348,7 +3365,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
'scanned_quantity'=> $scannedQuantity,
|
||||
]);
|
||||
|
||||
if($totQuan === $scannedQuantity)
|
||||
if($totQuan == $scannedQuantity)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Completed: Serial Invoice')
|
||||
@@ -3366,7 +3383,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ class LineResource extends Resource
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
@@ -174,6 +175,9 @@ class LineResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('group_work_center')
|
||||
->label('Group Work Center')
|
||||
->placeholder('Scan the valid Group Work Center'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
@@ -198,6 +202,11 @@ class LineResource extends Resource
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
@@ -208,8 +217,8 @@ class LineResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
Tables\Columns\TextColumn::make('group_work_center')
|
||||
->label('Group Work Center')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
@@ -43,6 +43,8 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Export Dispatch';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -63,7 +65,9 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
$set('invoice_number', null);
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('sno_quantity', null);
|
||||
$set('sno_quantity', 0);
|
||||
$set('scan_quantity', 0);
|
||||
$set('pend_quantity', 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -71,7 +75,9 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
$set('invoice_number', null);
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('sno_quantity', null);
|
||||
$set('sno_quantity', 0);
|
||||
$set('scan_quantity', 0);
|
||||
$set('pend_quantity', 0);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -90,18 +96,33 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->readOnly(fn (callable $get) => !$get('plant') || $get('pallet_number') || $get('serial_number'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$invNo = $get('invoice_number');
|
||||
$snoCount = 0;
|
||||
$pendingCount = 0;
|
||||
$scannedCount = 0;
|
||||
if (!$plantId) {
|
||||
$set('invoice_number', null);
|
||||
$set('pallet_number', null);
|
||||
}
|
||||
else if ($invNo)
|
||||
{
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invNo)->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invNo)->where('plant_id', $plantId)->whereNull('scanned_status')->orWhere('scanned_status', '=', '')->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invNo)->where('plant_id', $plantId)->where('scanned_status', '=', 'Scanned')->count();
|
||||
}
|
||||
$set('update_invoice', null);
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('sno_quantity', $snoCount);
|
||||
$set('scan_quantity', $scannedCount);
|
||||
$set('pend_quantity', $pendingCount);
|
||||
}),
|
||||
Forms\Components\TextInput::make('pallet_number')
|
||||
->label('Scan Pallet No')
|
||||
->reactive()
|
||||
->minLength(10)
|
||||
// ->readOnly(fn (callable $get) => !$get('plant') || !$get('invoice_number') || $get('serial_number'))
|
||||
->readOnly(function (callable $get) {
|
||||
$invoiceNumber = $get('invoice_number');
|
||||
@@ -143,6 +164,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Scan Serial No')
|
||||
->reactive()
|
||||
->minLength(9)
|
||||
// ->readOnly(fn (callable $get) => !$get('plant') || !$get('invoice_number') || $get('pallet_number'))
|
||||
->readOnly(function (callable $get) {
|
||||
$invoiceNumber = $get('invoice_number');
|
||||
@@ -176,7 +198,18 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
'x-on:keydown.enter.prevent' => '$wire.processSerialNo()',
|
||||
]),
|
||||
Forms\Components\TextInput::make('sno_quantity')
|
||||
->label('SNo. Quantity')
|
||||
->label('Invoice Quantity')
|
||||
->default(0)
|
||||
->readOnly(),
|
||||
|
||||
Forms\Components\TextInput::make('scan_quantity')
|
||||
->label('Scanned Quantity')
|
||||
->default(0)
|
||||
->readOnly(),
|
||||
|
||||
Forms\Components\TextInput::make('pend_quantity')
|
||||
->label('Pending Quantity')
|
||||
->default(0)
|
||||
->readOnly(),
|
||||
|
||||
//Forms\Components\View::make('forms.components.update-invoice-button'),
|
||||
@@ -262,9 +295,10 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
if (!$palletRecord)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '{$palletNumber}' does not exist.")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Pallet number '{$palletNumber}' does not exist.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -285,8 +319,9 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
Notification::make()
|
||||
->title("Pallet number '{$palletNumber}' is not completed in masters")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
// if ($allCompleted)
|
||||
@@ -329,6 +364,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
// Notification::make()
|
||||
// ->title("Pallet number '{$palletNumber}' scanned successfully")
|
||||
// ->success()
|
||||
// ->duration(800)
|
||||
// ->send();
|
||||
// }
|
||||
|
||||
@@ -360,6 +396,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
// Notification::make()
|
||||
// ->title("Pallet number '{$palletNumber}' scanned successfully")
|
||||
// ->success()
|
||||
// ->duration(800)
|
||||
// ->send();
|
||||
// }
|
||||
|
||||
@@ -460,16 +497,16 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->label('Import Invoice')
|
||||
->form([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id')->toArray())
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_serial_number', null);
|
||||
})
|
||||
->reactive(),
|
||||
->options(Plant::pluck('name', 'id')->toArray())
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_serial_number', null);
|
||||
})
|
||||
->reactive(),
|
||||
|
||||
FileUpload::make('invoice_serial_number')
|
||||
->label('Invoice Serial Number')
|
||||
@@ -520,6 +557,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Invalid Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
@@ -545,7 +583,7 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Str::length($serialNumber) < 13 || !ctype_alnum($serialNumber))
|
||||
if(Str::length($serialNumber) < 9 || Str::length($serialNumber) > 20 || !ctype_alnum($serialNumber))
|
||||
{
|
||||
$invalidSerialCodes[] = $serialNumber;
|
||||
}
|
||||
@@ -567,10 +605,12 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
|
||||
if (!empty($uniqueSerialCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Numbers Found')
|
||||
->body('The following serial numbers should contain minimum 13 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->danger()
|
||||
->send();
|
||||
->title('Invalid Serial Numbers Found')
|
||||
->body('The following serial numbers should contain minimum 9 digit (and maximum 20 digit) alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
@@ -584,7 +624,9 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
@@ -596,10 +638,12 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Invalid Locator Invoice Found')
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -616,20 +660,22 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
->title('Duplicate Serial Numbers Found')
|
||||
->body('The following serial numbers already exist with a different invoice number:<br>' . implode(', ', $existingSerials))
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
if ($disk->exists($path))
|
||||
{
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
$disk->delete($path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save full file path to session
|
||||
// Save full file path to session
|
||||
session(['uploaded_invoice_path' => $fullPath]);
|
||||
Notification::make()
|
||||
->title('Success: Invoice imported successfully.')
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -640,11 +686,15 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
|
||||
ImportAction::make()
|
||||
->importer(LocatorInvoiceValidationImporter::class)
|
||||
->label('Import Locator Invoice')
|
||||
->color('warning')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import locator invoice validation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(LocatorInvoiceValidationExporter::class)
|
||||
->label('Export Locator Invoice')
|
||||
->color('warning')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export locator invoice validation');
|
||||
}),
|
||||
@@ -894,6 +944,11 @@ class LocatorInvoiceValidationResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Scan Invoice';
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,16 +7,25 @@ use App\Filament\Imports\LocatorImporter;
|
||||
use App\Filament\Resources\LocatorResource\Pages;
|
||||
use App\Filament\Resources\LocatorResource\RelationManagers;
|
||||
use App\Models\Locator;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
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;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Str;
|
||||
|
||||
class LocatorResource extends Resource
|
||||
{
|
||||
@@ -34,19 +43,87 @@ class LocatorResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
->required()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(Locator::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
// Ensure `linestop_id` is not cleared
|
||||
if (!$plantId) {
|
||||
$set('locPlantError', 'Please select a plant first.');
|
||||
$set('locator_number', null);
|
||||
$set('locator_quantity', 0);
|
||||
$set('operator_id', Filament::auth()->user()?->name);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('locPlantError', null);
|
||||
$set('locator_number', null);
|
||||
$set('locator_quantity', 0);
|
||||
$set('operator_id', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('locPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('locPlantError') ? $get('locPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('locator_number')
|
||||
->label('Locator Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('locator_quantity')
|
||||
->minLength(7)
|
||||
->reactive()
|
||||
->required()
|
||||
->numeric()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$locator = $get('locator_number');
|
||||
if (!$plantId) {
|
||||
$set('locNameError', 'Please select a plant first.');
|
||||
$set('locator_number', null);
|
||||
$set('locator_quantity', 0);
|
||||
$set('operator_id', Filament::auth()->user()?->name);
|
||||
return;
|
||||
}
|
||||
else if (!$locator || Str::length($locator) < 7) {
|
||||
$set('locNameError', 'Please scan the valid locator number.');
|
||||
$set('locator_quantity', 0);
|
||||
$set('operator_id', Filament::auth()->user()?->name);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('locNameError', null);
|
||||
$set('locator_quantity', PalletValidation::where('locator_number', $locator)->where('plant_id', $plantId)->distinct('pallet_number')->count('pallet_number'));
|
||||
$set('operator_id', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('locNameError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('locNameError') ? $get('locNameError') : null)
|
||||
->hintColor('danger')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('locators', 'locator_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('locator_quantity')
|
||||
->label('Locator Quantity')
|
||||
->required()
|
||||
->readOnly()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Forms\Components\Hidden::make('operator_id')
|
||||
->default(Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
|
||||
->default(Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -67,34 +144,183 @@ class LocatorResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->numeric()
|
||||
->searchable()
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('locator_number')
|
||||
->label('Locator Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('locator_quantity')
|
||||
->label('Locator Quantity')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('operator_id')
|
||||
->label('Operator ID')
|
||||
->searchable()
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
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('Select Plant')
|
||||
->nullable()
|
||||
->options(function () {
|
||||
return Plant::pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('locator_number', null);
|
||||
$set('locator_quantity', null);
|
||||
$set('created_from', null);
|
||||
$set('created_to', null);
|
||||
$set('created_by', null);
|
||||
$set('updated_from', null);
|
||||
$set('updated_to', null);
|
||||
}),
|
||||
Select::make('locator_number')
|
||||
->label('Locator Number')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
return Locator::where('plant_id', $plantId)->orderBy('locator_number', 'asc')->get()->unique('locator_number')->pluck('locator_number', 'locator_number')->toArray();
|
||||
// ->whereNotNull('locator_number')
|
||||
// ->where('locator_number','!=', '')
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('locator_quantity')
|
||||
->label('Locator Quantity')
|
||||
->options([
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
])
|
||||
->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),
|
||||
TextInput::make('created_by')
|
||||
->label('Created By')
|
||||
->reactive()
|
||||
->placeholder(placeholder: 'Enter Created By'),
|
||||
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['locator_number']) && $data['locator_quantity'] == null && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && 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']);
|
||||
}
|
||||
|
||||
if (!empty($data['locator_number'])) {
|
||||
$query->where('locator_number', $data['locator_number']);
|
||||
}
|
||||
|
||||
if ($data['locator_quantity'] != null && $data['locator_quantity'] != '') { //isset($data['locator_quantity']) &&
|
||||
$query->where('locator_quantity', $data['locator_quantity']);//(int)
|
||||
}
|
||||
|
||||
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['created_by'])) {
|
||||
$query->where('operator_id', $data['created_by']);
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
if (!empty($data['locator_number'])) {
|
||||
$indicators[] = 'Locator Number: ' . $data['locator_number'];
|
||||
}
|
||||
|
||||
if ($data['locator_quantity'] != null && $data['locator_quantity'] != '') { //isset($data['locator_quantity']) &&
|
||||
$indicators[] = 'Locator Quantity: ' . $data['locator_quantity'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: ' . $data['created_by'];
|
||||
}
|
||||
|
||||
if (!empty($data['updated_from'])) {
|
||||
$indicators[] = 'Updated From: ' . $data['updated_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['updated_to'])) {
|
||||
$indicators[] = 'Updated To: ' . $data['updated_to'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
|
||||
@@ -19,6 +19,8 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Str;
|
||||
|
||||
class MachineResource extends Resource
|
||||
{
|
||||
@@ -85,6 +87,13 @@ class MachineResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
$grpWrkCnr = Line::find($lineId)->group_work_center;
|
||||
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||
{
|
||||
$set('mLineError', 'Please select a group work center line.');
|
||||
$set('line_id', null);
|
||||
return;
|
||||
}
|
||||
$set('mLineError', null);
|
||||
}
|
||||
})
|
||||
@@ -95,7 +104,17 @@ class MachineResource extends Resource
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required(),
|
||||
->placeholder('Scan the valid Machine Name')
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('machines', 'name')
|
||||
->where('line_id', $get('line_id'))
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('work_center')
|
||||
->label('Work Center')
|
||||
->placeholder('Scan the valid Work Center'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
@@ -126,6 +145,11 @@ class MachineResource extends Resource
|
||||
->label('Name')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
|
||||
157
app/Filament/Resources/MfmMeterResource.php
Normal file
157
app/Filament/Resources/MfmMeterResource.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\MfmMeterExporter;
|
||||
use App\Filament\Imports\MfmMeterImporter;
|
||||
use App\Filament\Resources\MfmMeterResource\Pages;
|
||||
use App\Filament\Resources\MfmMeterResource\RelationManagers;
|
||||
use App\Models\DeviceMaster;
|
||||
use App\Models\MfmMeter;
|
||||
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\Section;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class MfmMeterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MfmMeter::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('device_master_id')
|
||||
//->relationship('device', 'name')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
return DeviceMaster::where('plant_id', $plantId)->pluck('name', 'id');
|
||||
})
|
||||
->label('Device Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('sequence')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(4),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
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')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('devicemaster.name')
|
||||
->label('Device Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sequence')
|
||||
->label('Sequence')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Meter Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(MfmMeterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import mfm meter');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(MfmMeterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export mfm meter');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMfmMeters::route('/'),
|
||||
'create' => Pages\CreateMfmMeter::route('/create'),
|
||||
'view' => Pages\ViewMfmMeter::route('/{record}'),
|
||||
'edit' => Pages\EditMfmMeter::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMfmMeter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMfmMeter extends EditRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::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\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMfmMeters extends ListRecords
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmMeterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmMeterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewMfmMeter extends ViewRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
188
app/Filament/Resources/MfmParameterResource.php
Normal file
188
app/Filament/Resources/MfmParameterResource.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\MfmParameterExporter;
|
||||
use App\Filament\Imports\MfmParameterImporter;
|
||||
use App\Filament\Resources\MfmParameterResource\Pages;
|
||||
use App\Filament\Resources\MfmParameterResource\RelationManagers;
|
||||
use App\Models\MfmParameter;
|
||||
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\Section;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class MfmParameterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MfmParameter::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('device_master_id')
|
||||
->label('Device Master')
|
||||
->relationship('deviceName', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('mfm_meter_id')
|
||||
->label('Mfm Meter')
|
||||
->relationship('mfmMeter', 'sequence')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Parameter Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('register_id')
|
||||
->label('Register ID')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('identifier')
|
||||
->label('Identifier')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('byte_to_convert')
|
||||
->label('Byte To Convert')
|
||||
->default(2)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('type_to_convert')
|
||||
->label('Type To Convert')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('decimal_to_display')
|
||||
->label('Decimal To Display')
|
||||
->default(1)
|
||||
->required(),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deviceName.name')
|
||||
->label('Device Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mfmMeter.name')
|
||||
->label('Sequence')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Parameter Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('register_id')
|
||||
->label('Register ID')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('identifier')
|
||||
->label('Identifier')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('byte_to_convert')
|
||||
->label('Byte To Convert')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('type_to_convert')
|
||||
->label('Type To Convert')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('decimal_to_display')
|
||||
->label('Decimal To Display')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('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([
|
||||
ImportAction::make()
|
||||
->importer(MfmParameterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import mfm parameter');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(MfmParameterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export mfm parameter');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMfmParameters::route('/'),
|
||||
'create' => Pages\CreateMfmParameter::route('/create'),
|
||||
'view' => Pages\ViewMfmParameter::route('/{record}'),
|
||||
'edit' => Pages\EditMfmParameter::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMfmParameter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMfmParameter extends EditRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::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\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMfmParameters extends ListRecords
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmParameterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmParameterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewMfmParameter extends ViewRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
243
app/Filament/Resources/MfmReadingResource.php
Normal file
243
app/Filament/Resources/MfmReadingResource.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\MfmReadingExporter;
|
||||
use App\Filament\Imports\MfmReadingImporter;
|
||||
use App\Filament\Resources\MfmReadingResource\Pages;
|
||||
use App\Filament\Resources\MfmReadingResource\RelationManagers;
|
||||
use App\Models\MfmReading;
|
||||
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\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
class MfmReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MfmReading::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('mfm_meter_id')
|
||||
->relationship('mfmMeter', 'name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('apparent_energy_received'),
|
||||
Forms\Components\TextInput::make('reactive_energy_received'),
|
||||
Forms\Components\TextInput::make('active_energy_received'),
|
||||
Forms\Components\TextInput::make('active_power_r'),
|
||||
Forms\Components\TextInput::make('active_power_y'),
|
||||
Forms\Components\TextInput::make('active_power_b'),
|
||||
Forms\Components\TextInput::make('active_power_total'),
|
||||
Forms\Components\TextInput::make('voltage_ry'),
|
||||
Forms\Components\TextInput::make('voltage_yb'),
|
||||
Forms\Components\TextInput::make('voltage_br'),
|
||||
Forms\Components\TextInput::make('current_r'),
|
||||
Forms\Components\TextInput::make('current_y'),
|
||||
Forms\Components\TextInput::make('current_b'),
|
||||
Forms\Components\TextInput::make('current_n'),
|
||||
Forms\Components\TextInput::make('voltage_r_n'),
|
||||
Forms\Components\TextInput::make('voltage_y_n'),
|
||||
Forms\Components\TextInput::make('voltage_b_n'),
|
||||
Forms\Components\TextInput::make('frequency'),
|
||||
Forms\Components\TextInput::make('power_factor_r'),
|
||||
Forms\Components\TextInput::make('power_factor_y'),
|
||||
Forms\Components\TextInput::make('power_factor_b'),
|
||||
Forms\Components\TextInput::make('power_factor_total'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mfmMeter.name')
|
||||
->label('Mfm Meter')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('apparent_energy_received')
|
||||
->label('Apparent Energy Received')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('reactive_energy_received')
|
||||
->label('Reactive Energy Received')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_energy_received')
|
||||
->label('Active Energy Received')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_r')
|
||||
->label('Active Power R')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_y')
|
||||
->label('Active Power Y')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_b')
|
||||
->label('Active Power B')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('active_power_total')
|
||||
->label('Active Power Total')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_ry')
|
||||
->label('Voltage RY')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_yb')
|
||||
->label('Voltage YB')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_br')
|
||||
->label('Voltage BR')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_r')
|
||||
->label('Current R')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_y')
|
||||
->label('Current Y')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_b')
|
||||
->label('Current B')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('current_n')
|
||||
->label('Current N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_r_n')
|
||||
->label('Voltage R N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_y_n')
|
||||
->label('Voltage Y N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('voltage_b_n')
|
||||
->label('Voltage B N')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('frequency')
|
||||
->label('Frequency')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_r')
|
||||
->label('Power Factor R')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_y')
|
||||
->label('Power Factor Y')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_b')
|
||||
->label('Power Factor B')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('power_factor_total')
|
||||
->label('Power Factor Total')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->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([
|
||||
ImportAction::make()
|
||||
->importer(MfmReadingImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import mfm reading');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(MfmReadingExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export mfm reading');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMfmReadings::route('/'),
|
||||
'create' => Pages\CreateMfmReading::route('/create'),
|
||||
'view' => Pages\ViewMfmReading::route('/{record}'),
|
||||
'edit' => Pages\EditMfmReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMfmReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMfmReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::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\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMfmReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\MfmReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\MfmReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewMfmReading extends ViewRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
125
app/Filament/Resources/ModuleListResource.php
Normal file
125
app/Filament/Resources/ModuleListResource.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource\Pages;
|
||||
use App\Filament\Resources\ModuleListResource\RelationManagers;
|
||||
use App\Models\ModuleList;
|
||||
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\Section;
|
||||
|
||||
class ModuleListResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ModuleList::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Modules';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('module_name')
|
||||
->label('Module Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('dashboard_name')
|
||||
->label('DashBoard Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('filter_name')
|
||||
->label('Filter Name')
|
||||
->required(),
|
||||
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),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('module_name')
|
||||
->label('Module Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('dashboard_name')
|
||||
->label('DashBoard Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('filter_name')
|
||||
->label('Filter Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
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(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListModuleLists::route('/'),
|
||||
'create' => Pages\CreateModuleList::route('/create'),
|
||||
'view' => Pages\ViewModuleList::route('/{record}'),
|
||||
'edit' => Pages\EditModuleList::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateModuleList extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditModuleList extends EditRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::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\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListModuleLists extends ListRecords
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ModuleListResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ModuleListResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewModuleList extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use App\Filament\Imports\PalletValidationImporter;
|
||||
use App\Filament\Resources\PalletValidationResource\Pages;
|
||||
use App\Filament\Resources\PalletValidationResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
@@ -20,7 +21,6 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Log;
|
||||
@@ -36,8 +36,11 @@ class PalletValidationResource extends Resource
|
||||
protected static ?string $model = PalletValidation::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Export Dispatch';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
@@ -68,7 +71,7 @@ class PalletValidationResource extends Resource
|
||||
'x-on:keydown.enter.prevent' => '$wire.processPalletNo()',
|
||||
])
|
||||
->suffixAction(fn ($get,$set) =>
|
||||
Forms\Components\Actions\Action::make('addPallet')
|
||||
Forms\Components\Actions\Action::make('addPallet')
|
||||
->label('')
|
||||
->button()
|
||||
->icon('heroicon-o-plus')
|
||||
@@ -79,28 +82,39 @@ class PalletValidationResource extends Resource
|
||||
->action(function ($get, $set, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
$user = Filament::auth()->user();
|
||||
session(['pallet_clicked_time' => now()->toDateTimeString()]);
|
||||
|
||||
$operatorName = $user->name;
|
||||
|
||||
$clickedTime = now();
|
||||
|
||||
$created = $operatorName;
|
||||
|
||||
session(['pallet_clicked_time' => $clickedTime->toDateTimeString()]);
|
||||
|
||||
session(['pallet_created_by' => $created]);
|
||||
session(['pallet_created_by' => Filament::auth()->user()->name]);
|
||||
|
||||
$year = now()->format('y');
|
||||
$month = now()->format('m');
|
||||
$prefix = "EP-{$year}{$month}";
|
||||
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")
|
||||
->where('plant_id', $plantId)
|
||||
->orderByDesc('pallet_number')
|
||||
->first();
|
||||
$newNumber = $lastPallet
|
||||
? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT)
|
||||
: '001';
|
||||
|
||||
$lastPallet1 = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
|
||||
$lastPallet2 = LocatorInvoiceValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first();
|
||||
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
|
||||
if ($lastPallet1 && $lastPallet2) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
if (intval($serialPart1) > intval($serialPart2)) {
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
} else {
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
else if ($lastPallet1) {
|
||||
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
|
||||
// OR
|
||||
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
||||
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
|
||||
}
|
||||
else if ($lastPallet2) {
|
||||
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
|
||||
// OR
|
||||
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
|
||||
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||
|
||||
$set('pallet_number', $newPalletNumber);
|
||||
@@ -114,6 +128,7 @@ class PalletValidationResource extends Resource
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Scan Serial No')
|
||||
->reactive()
|
||||
->minLength(9)
|
||||
->readOnly(fn (callable $get) => !$get('pallet_number') || $get('removeSno_number'))
|
||||
->extraAttributes([
|
||||
'x-on:keydown.enter.prevent' => '$wire.processPalletSNo()',
|
||||
@@ -121,6 +136,7 @@ class PalletValidationResource extends Resource
|
||||
Forms\Components\TextInput::make('removeSno_number')
|
||||
->label('Remove Serial No')
|
||||
->reactive()
|
||||
->minLength(9)
|
||||
->readOnly(fn (callable $get) => !$get('pallet_number') || $get('serial_number'))
|
||||
->extraAttributes([
|
||||
'x-data' => '{ value: "" }',
|
||||
@@ -222,24 +238,24 @@ class PalletValidationResource extends Resource
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scanned_by')
|
||||
->label('Scanned By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
Tables\Columns\TextColumn::make('scanned_by')
|
||||
->label('Scanned By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scanned_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('scanned_at')
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
@@ -256,218 +272,218 @@ class PalletValidationResource extends Resource
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function () {
|
||||
return Plant::pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('pallet_status', null);
|
||||
$set('locator_number', null);
|
||||
$set('locator_quantity', null);
|
||||
$set('created_from', null);
|
||||
$set('created_to', null);
|
||||
$set('created_by', null);
|
||||
$set('scanned_from', null);
|
||||
$set('scanned_to', null);
|
||||
$set('scanned_by', null);
|
||||
}),
|
||||
Select::make('pallet_number')
|
||||
->label('Pallet Number')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
return PalletValidation::where('plant_id', $plantId)
|
||||
->whereNotNull('pallet_number')
|
||||
->where('pallet_number','!=', '')
|
||||
->orderBy('pallet_number', 'asc')
|
||||
->get()
|
||||
->unique('pallet_number')
|
||||
->pluck('pallet_number', 'pallet_number')
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->placeholder(placeholder: 'Enter Serial Number'),
|
||||
Select::make('pallet_status')
|
||||
->label('Pallet Status')
|
||||
->options([
|
||||
'Completed' => 'Completed',
|
||||
]),
|
||||
Select::make('locator_number')
|
||||
->label('Locator Number')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
return PalletValidation::where('plant_id', $plantId)
|
||||
->whereNotNull('locator_number')
|
||||
->where('locator_number','!=', '')
|
||||
->orderBy('locator_number', 'asc')
|
||||
->get()
|
||||
->unique('locator_number')
|
||||
->pluck('locator_number', 'locator_number')
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('locator_quantity')
|
||||
->label('Locator Quantity')
|
||||
->options([
|
||||
0 => 0,
|
||||
1 => '1',
|
||||
2 => '2',
|
||||
])
|
||||
->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),
|
||||
TextInput::make('created_by')
|
||||
->label('Created By')
|
||||
->placeholder(placeholder: 'Enter Created By'),
|
||||
DateTimePicker::make(name: 'scanned_from')
|
||||
->label('Scanned From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('scanned_to')
|
||||
->label('Scanned To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
TextInput::make('scanned_by')
|
||||
->label('Scanned By')
|
||||
->placeholder(placeholder: 'Enter Scanned By'),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['pallet_number']) && empty($data['serial_number']) && empty($data['pallet_status']) && empty($data['locator_number']) && empty($data['locator_quantity']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && empty($data['scanned_from']) && empty($data['scanned_to']) && empty($data['scanned_by'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function () {
|
||||
return Plant::pluck('name', 'id');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('pallet_number', null);
|
||||
$set('serial_number', null);
|
||||
$set('pallet_status', null);
|
||||
$set('locator_number', null);
|
||||
$set('locator_quantity', null);
|
||||
$set('created_from', null);
|
||||
$set('created_to', null);
|
||||
$set('created_by', null);
|
||||
$set('scanned_from', null);
|
||||
$set('scanned_to', null);
|
||||
$set('scanned_by', null);
|
||||
}),
|
||||
Select::make('pallet_number')
|
||||
->label('Pallet Number')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
return PalletValidation::where('plant_id', $plantId)
|
||||
->whereNotNull('pallet_number')
|
||||
->where('pallet_number','!=', '')
|
||||
->orderBy('pallet_number', 'asc')
|
||||
->get()
|
||||
->unique('pallet_number')
|
||||
->pluck('pallet_number', 'pallet_number')
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->placeholder(placeholder: 'Enter Serial Number'),
|
||||
Select::make('pallet_status')
|
||||
->label('Pallet Status')
|
||||
->options([
|
||||
'Completed' => 'Completed',
|
||||
]),
|
||||
Select::make('locator_number')
|
||||
->label('Locator Number')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
return PalletValidation::where('plant_id', $plantId)
|
||||
->whereNotNull('locator_number')
|
||||
->where('locator_number','!=', '')
|
||||
->orderBy('locator_number', 'asc')
|
||||
->get()
|
||||
->unique('locator_number')
|
||||
->pluck('locator_number', 'locator_number')
|
||||
->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
Select::make('locator_quantity')
|
||||
->label('Locator Quantity')
|
||||
->options([
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
])
|
||||
->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),
|
||||
TextInput::make('created_by')
|
||||
->label('Created By')
|
||||
->placeholder(placeholder: 'Enter Created By'),
|
||||
DateTimePicker::make(name: 'scanned_from')
|
||||
->label('Scanned From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('scanned_to')
|
||||
->label('Scanned To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
TextInput::make('scanned_by')
|
||||
->label('Scanned By')
|
||||
->placeholder(placeholder: 'Enter Scanned By'),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['pallet_number']) && empty($data['serial_number']) && empty($data['pallet_status']) && empty($data['locator_number']) && $data['locator_quantity'] == null && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && empty($data['scanned_from']) && empty($data['scanned_to']) && empty($data['scanned_by'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
if (!empty($data['pallet_number'])) {
|
||||
$query->where('pallet_number', $data['pallet_number']);
|
||||
}
|
||||
if (!empty($data['pallet_number'])) {
|
||||
$query->where('pallet_number', $data['pallet_number']);
|
||||
}
|
||||
|
||||
if (!empty($data['serial_number'])) {
|
||||
$query->where('serial_number', $data['serial_number']);
|
||||
}
|
||||
if (!empty($data['serial_number'])) {
|
||||
$query->where('serial_number', $data['serial_number']);
|
||||
}
|
||||
|
||||
if (!empty($data['pallet_status'])) {
|
||||
$query->where('pallet_status', $data['pallet_status']);
|
||||
}
|
||||
if (!empty($data['pallet_status'])) {
|
||||
$query->where('pallet_status', $data['pallet_status']);
|
||||
}
|
||||
|
||||
if (!empty($data['locator_number'])) {
|
||||
$query->where('locator_number', $data['locator_number']);
|
||||
}
|
||||
if (!empty($data['locator_number'])) {
|
||||
$query->where('locator_number', $data['locator_number']);
|
||||
}
|
||||
|
||||
// if (!empty($data['locator_quantity'])) {
|
||||
// $query->where('locator_quantity', $data['locator_quantity']);
|
||||
// }
|
||||
// if (!empty($data['locator_quantity'])) {
|
||||
// $query->where('locator_quantity', $data['locator_quantity']);
|
||||
// }
|
||||
|
||||
if (isset($data['locator_quantity']) && $data['locator_quantity'] != '') {
|
||||
$query->where('locator_quantity', (int)$data['locator_quantity']);
|
||||
}
|
||||
if ($data['locator_quantity'] != null && $data['locator_quantity'] != '') { //isset($data['locator_quantity']) &&
|
||||
$query->where('locator_quantity', $data['locator_quantity']);//(int)
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
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['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_by'])) {
|
||||
$query->where('created_by', $data['created_by']);
|
||||
}
|
||||
if (!empty($data['created_by'])) {
|
||||
$query->where('created_by', $data['created_by']);
|
||||
}
|
||||
|
||||
if (!empty($data['scanned_from'])) {
|
||||
$query->where('scanned_at', '>=', $data['scanned_from']);
|
||||
}
|
||||
if (!empty($data['scanned_from'])) {
|
||||
$query->where('scanned_at', '>=', $data['scanned_from']);
|
||||
}
|
||||
|
||||
if (!empty($data['scanned_to'])) {
|
||||
$query->where('scanned_at', '<=', $data['scanned_to']);
|
||||
}
|
||||
if (!empty($data['scanned_to'])) {
|
||||
$query->where('scanned_at', '<=', $data['scanned_to']);
|
||||
}
|
||||
|
||||
if (!empty($data['scanned_by'])) {
|
||||
$query->where('scanned_by', $data['scanned_by']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
if (!empty($data['scanned_by'])) {
|
||||
$query->where('scanned_by', $data['scanned_by']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
if (!empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
||||
}
|
||||
|
||||
if (!empty($data['pallet_number'])) {
|
||||
$indicators[] = 'Pallet Number: ' . $data['pallet_number'];
|
||||
}
|
||||
if (!empty($data['pallet_number'])) {
|
||||
$indicators[] = 'Pallet Number: ' . $data['pallet_number'];
|
||||
}
|
||||
|
||||
if (!empty($data['serial_number'])) {
|
||||
$indicators[] = 'Serial Number: ' . $data['serial_number'];
|
||||
}
|
||||
if (!empty($data['serial_number'])) {
|
||||
$indicators[] = 'Serial Number: ' . $data['serial_number'];
|
||||
}
|
||||
|
||||
if (!empty($data['pallet_status'])) {
|
||||
$indicators[] = 'Pallet Status: ' . $data['pallet_status'];
|
||||
}
|
||||
if (!empty($data['pallet_status'])) {
|
||||
$indicators[] = 'Pallet Status: ' . $data['pallet_status'];
|
||||
}
|
||||
|
||||
if (!empty($data['locator_number'])) {
|
||||
$indicators[] = 'Locator Number: ' . $data['locator_number'];
|
||||
}
|
||||
if (!empty($data['locator_number'])) {
|
||||
$indicators[] = 'Locator Number: ' . $data['locator_number'];
|
||||
}
|
||||
|
||||
// if (!empty($data['locator_quantity'])) {
|
||||
// $indicators[] = 'Locator Quantity: ' . $data['locator_quantity'];
|
||||
// }
|
||||
if (isset($data['locator_quantity']) && $data['locator_quantity'] !== '') {
|
||||
$indicators[] = 'Locator Quantity: ' . $data['locator_quantity'];
|
||||
}
|
||||
// if (!empty($data['locator_quantity'])) {
|
||||
// $indicators[] = 'Locator Quantity: ' . $data['locator_quantity'];
|
||||
// }
|
||||
if ($data['locator_quantity'] != null && $data['locator_quantity'] != '') { //isset($data['locator_quantity']) &&
|
||||
$indicators[] = 'Locator Quantity: ' . $data['locator_quantity'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: ' . $data['created_by'];
|
||||
}
|
||||
if (!empty($data['scanned_from'])) {
|
||||
$indicators[] = 'Scanned From: ' . $data['scanned_from'];
|
||||
}
|
||||
if (!empty($data['scanned_to'])) {
|
||||
$indicators[] = 'Scanned To: ' . $data['scanned_to'];
|
||||
}
|
||||
if (!empty($data['scanned_by'])) {
|
||||
$indicators[] = 'Scanned By: ' . $data['scanned_by'];
|
||||
}
|
||||
if (!empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: ' . $data['created_by'];
|
||||
}
|
||||
if (!empty($data['scanned_from'])) {
|
||||
$indicators[] = 'Scanned From: ' . $data['scanned_from'];
|
||||
}
|
||||
if (!empty($data['scanned_to'])) {
|
||||
$indicators[] = 'Scanned To: ' . $data['scanned_to'];
|
||||
}
|
||||
if (!empty($data['scanned_by'])) {
|
||||
$indicators[] = 'Scanned By: ' . $data['scanned_by'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
return $indicators;
|
||||
})
|
||||
])
|
||||
->filtersFormMaxHeight('280px')
|
||||
->actions([
|
||||
@@ -481,14 +497,64 @@ class PalletValidationResource extends Resource
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
// ->headerActions([
|
||||
->headerActions([
|
||||
Tables\Actions\Action::make('reprint_pallet')
|
||||
->label('Re-Print Pallet QR')
|
||||
->form([
|
||||
Forms\Components\Section::make()
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant')
|
||||
->label('Select Plant')
|
||||
->options(Plant::pluck('name', 'id')->toArray())
|
||||
->required()
|
||||
->reactive()
|
||||
->columnSpan(2),
|
||||
Forms\Components\Select::make('pallet_list')
|
||||
->label('Select Pallet')
|
||||
->searchable()
|
||||
->required()
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return PalletValidation::query()
|
||||
->where('plant_id', $plantId)
|
||||
->whereNotNull('pallet_number')
|
||||
->where('pallet_number', '!=', '')
|
||||
->select('pallet_number')
|
||||
->distinct()
|
||||
->orderBy('pallet_number')
|
||||
->pluck('pallet_number', 'pallet_number')
|
||||
->toArray();
|
||||
}),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 3]),
|
||||
])
|
||||
->action(function (array $data) {
|
||||
$selectedPalletNumber = $data['pallet_list'];
|
||||
return redirect()->route('download-reprint-qr-pdf', ['palletNo' => $selectedPalletNumber]);
|
||||
|
||||
})
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view reprint pallet number');
|
||||
}),
|
||||
ImportAction::make()
|
||||
->importer(PalletValidationImporter::class)
|
||||
->label('Import Pallet')
|
||||
->color('warning')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import pallet validation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(PalletValidationExporter::class)
|
||||
->label('Export Pallet')
|
||||
->color('warning')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export pallet validation');
|
||||
}),
|
||||
@@ -502,6 +568,11 @@ class PalletValidationResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Scan Pallet';
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -57,13 +57,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
$clickedBy = session('pallet_created_by');
|
||||
|
||||
|
||||
if(!$palletNumber)
|
||||
if (!$palletNumber)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Pallet number cannot be empty')
|
||||
->danger()
|
||||
->send();
|
||||
->title("Pallet number can't be empty")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
'plant_id' => $plantId,
|
||||
@@ -76,18 +77,17 @@ class CreatePalletValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$count = PalletValidation::where('plant_id', $plantId)
|
||||
->where('pallet_number', $palletNumber)
|
||||
->count('pallet_number');
|
||||
|
||||
|
||||
if(!$serialNumber)
|
||||
if (!$serialNumber)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number cannot be empty')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial number is required to add.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -100,12 +100,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
if(strlen($serialNumber) < 13)
|
||||
else if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number should contain minimum 13 digits.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial number should contain minimum 9 digits and maximum 20 digits.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -118,12 +120,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
if (!ctype_alnum($serialNumber))
|
||||
else if (!ctype_alnum($serialNumber))
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -143,12 +147,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
->first();
|
||||
|
||||
$invoiceNumber = $existInvoiceSno?->invoice_number;
|
||||
if($existInvoiceSno)
|
||||
if ($existInvoiceSno)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number : {$invoiceNumber}.<br>Scan the new serial number to add!")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number : {$invoiceNumber}.<br>Scan the new serial number to add!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -173,6 +179,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
// Notification::make()
|
||||
// ->title("Scanned serial number '{$serialNumber}' exists in pallet table .<br>scan the valid serial number to proceed...")
|
||||
// ->danger()
|
||||
// ->duration(5000)
|
||||
// ->send();
|
||||
// $this->form->fill([
|
||||
// 'serial_number' => null,
|
||||
@@ -191,6 +198,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' is already exists in pallet number '{$palletNumber}'.<br>Scan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
else if ($existingRecord && $existingRecord->pallet_number && $existingRecord->pallet_number != $palletNumber)
|
||||
@@ -198,6 +206,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' already exists in pallet number '{$existingRecord->pallet_number}'.<br>Scan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
else if ($existingRecord && $existingRecord->locator_number)
|
||||
@@ -205,6 +214,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' is already exists in locator number '{$existingRecord->locator_number}'.<br>Scan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
@@ -248,15 +258,17 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
if ($record)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned serial number : '{$serialNumber}' successfully inserted into pallet table!<br>Scan the next new serial number to proceed...")
|
||||
->success()
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title("Scanned serial number '{$serialNumber}' successfully inserted into pallet table!<br>Scan the next new serial number to proceed...")
|
||||
// ->success()
|
||||
// ->duration(600)
|
||||
// ->send();
|
||||
|
||||
$this->snoCount = PalletValidation::where('plant_id', $plantId)
|
||||
->where('pallet_number', $palletNumber)
|
||||
->count();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'pallet_number' => $palletNumber,
|
||||
@@ -266,34 +278,36 @@ class CreatePalletValidation extends CreateRecord
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Pallet validation not inserted.')
|
||||
->title("Failed to insert scanned serial number '$serialNumber' into pallet table!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'pallet_number' => $palletNumber,
|
||||
'serial_number' => null,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'pallet_number' => $palletNumber,
|
||||
'serial_number' => null,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Error: Pallet validation not inserted.')
|
||||
->body("Something went wrong while inserting serial number : '{$serialNumber}' into pallet table!\nScan the new serial number to proceed...")
|
||||
->title('Error: Serial not inserted.')
|
||||
->body("Something went wrong while inserting serial number '{$serialNumber}' into pallet table!\nScan the new serial number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -362,12 +376,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if(!$palletExist)
|
||||
if (!$palletExist)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' does not have serial numbers to save!<br>Add the valid serial number into pallet number to proceed...")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Pallet number '$palletNumber' does not have serial numbers to save!<br>Add the valid serial number into pallet number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -391,7 +407,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' already completed the master packing!<br>Generate the new pallet number or choose from pending pallet list!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -405,9 +423,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$count = PalletValidation::where('plant_id', $plantId)
|
||||
->where('pallet_number', $palletNumber)
|
||||
->count('pallet_number');
|
||||
// $count = PalletValidation::where('plant_id', $plantId)
|
||||
// ->where('pallet_number', $palletNumber)
|
||||
// ->count('pallet_number');
|
||||
|
||||
if (!$isCompleted)
|
||||
{
|
||||
@@ -420,7 +438,12 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
if ($updated > 0)
|
||||
{
|
||||
Notification::make()->title("Pallet number '$palletNumber' records saved successfully!")->success()->send();
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' records saved successfully!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -446,7 +469,12 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
if ($updated > 0)
|
||||
{
|
||||
Notification::make()->title("Pallet number '$palletNumber' completed the master packing successfully!")->success()->send();
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' completed the master packing successfully!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -487,6 +515,7 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Pallet number is required to remove.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
@@ -501,7 +530,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Serial number is required to remove.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -514,12 +545,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
if(strlen($serialNumber) < 13)
|
||||
else if (strlen($serialNumber) < 9 || strlen($serialNumber) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number should contain minimum 13 digits.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial number should contain minimum 9 digits and maximum 20 digits.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -535,9 +568,11 @@ class CreatePalletValidation extends CreateRecord
|
||||
else if (!ctype_alnum($serialNumber))
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial number must contain alpha-numeric values only.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -556,12 +591,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
->where('scanned_status', '=', 'Scanned')
|
||||
->first();
|
||||
|
||||
if($invoiceExist)
|
||||
if ($invoiceExist)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number : '{$invoiceExist->invoice_number}'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number '{$invoiceExist->invoice_number}'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -578,12 +615,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
$serialexist = PalletValidation::where('plant_id', $plantId)
|
||||
->where('serial_number', $serialNumber)
|
||||
->first();
|
||||
if(!$serialexist)
|
||||
if (!$serialexist)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Serial number not exists in pallet table.')
|
||||
->danger()
|
||||
->send();
|
||||
->title('Serial number not exists in pallet table.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -603,12 +642,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
->where('pallet_number', '!=', null)
|
||||
->first();
|
||||
|
||||
if($palletExist && $palletExist->pallet_number != $palletNumber)
|
||||
if ($palletExist && $palletExist->pallet_number != $palletNumber)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned serial number exist in pallet number '$palletExist->pallet_number'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Scanned serial number exist in pallet number '$palletExist->pallet_number'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -628,12 +669,14 @@ class CreatePalletValidation extends CreateRecord
|
||||
->where('locator_number', '!=', null)
|
||||
->first();
|
||||
|
||||
if($locatorExist && $locatorExist->locator_number)
|
||||
if ($locatorExist && $locatorExist->locator_number)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned serial number exist in locator number '$locatorExist->locator_number'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Scanned serial number exist in locator number '$locatorExist->locator_number'.<br>Scan the valid exist serial number to remove!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -655,10 +698,11 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
if ($deleted)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned serial number : '$serialNumber' successfully removed from pallet table!<br>Scan the next exist serial number to remove...")
|
||||
->success()
|
||||
->send();
|
||||
// Notification::make()
|
||||
// ->title("Scanned serial number '$serialNumber' successfully removed from pallet table!<br>Scan the next exist serial number to remove...")
|
||||
// ->success()
|
||||
// ->duration(600)
|
||||
// ->send();
|
||||
|
||||
$this->snoCount = PalletValidation::where('plant_id', $plantId)
|
||||
->where('pallet_number', $palletNumber)
|
||||
@@ -679,24 +723,24 @@ class CreatePalletValidation extends CreateRecord
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Failed to delete serial number.')
|
||||
->title("Failed to remove scanned serial number '$serialNumber' from pallet table!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
'plant_id' => $plantId,
|
||||
'pallet_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
'plant_id' => $plantId,
|
||||
'pallet_number' => $palletNumber,
|
||||
'pending_pallet_list' => $pendingPallet,
|
||||
'Sno_quantity' => $count,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
}
|
||||
|
||||
//$this->dispatch('removeSno', $serialNumber, $palletNumber, $plantId);
|
||||
|
||||
}
|
||||
|
||||
public function processPalletNo()
|
||||
@@ -735,7 +779,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title('Pallet number is required.')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -754,7 +800,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNumber' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadLocator' ,'',$plantId);
|
||||
$this->form->fill([
|
||||
'serial_number' => null,
|
||||
@@ -782,8 +830,9 @@ class CreatePalletValidation extends CreateRecord
|
||||
if (!$palletNotCompleted)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Already completed for pallet number $palletNumber")
|
||||
->title("Already completed for pallet number $palletNumber!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||
|
||||
@@ -319,8 +319,10 @@ class ProductionQuantityResource extends Resource
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->required()
|
||||
->minLength(7)
|
||||
->maxLength(14)
|
||||
->columnSpan(2)
|
||||
// ->rules(['regex:/^[1-9][0-9]{6,}$/'])
|
||||
//->rules(['regex:/^[1-9][0-9]{6,}$/'])
|
||||
// ->disabled(function ($get) {
|
||||
// return $get('item_code');
|
||||
// })
|
||||
@@ -332,15 +334,35 @@ class ProductionQuantityResource extends Resource
|
||||
return $latestProduction ? $latestProduction->production_order : null;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $get, callable $set): void {
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('validationError', null);
|
||||
return;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}),
|
||||
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
|
||||
{
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
$set('serial_number', null);
|
||||
$set('production_order', null);
|
||||
$set('prodOrdError', "Must be a numeric value with 7 to 14 digits.");
|
||||
$set('validationError', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('item_code', null);
|
||||
$set('item_id', null);
|
||||
// $set('item_description', null);
|
||||
$set('serial_number', null);
|
||||
$set('production_order', $state);
|
||||
$set('prodOrdError', null);
|
||||
$set('validationError', null);
|
||||
return;
|
||||
// if (empty($state)) {
|
||||
// }
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('prodOrdError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('prodOrdError') ? $get('prodOrdError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('item_code')
|
||||
->label('Item Code')
|
||||
// ->required()
|
||||
@@ -1035,6 +1057,7 @@ class ProductionQuantityResource extends Resource
|
||||
$set('Shift', null);
|
||||
$set('Item', null);
|
||||
$set('sap_msg_status', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//line
|
||||
@@ -1050,7 +1073,10 @@ class ProductionQuantityResource extends Resource
|
||||
return Line::where('plant_id', $plantId)
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
->reactive(),
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//block
|
||||
Select::make('Block')
|
||||
@@ -1067,6 +1093,7 @@ class ProductionQuantityResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Shift', null);
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
//shift
|
||||
@@ -1085,7 +1112,10 @@ class ProductionQuantityResource extends Resource
|
||||
->where('block_id', $blockId)
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
->reactive(),
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('operator_id', null);
|
||||
}),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
@@ -1133,6 +1163,37 @@ class ProductionQuantityResource extends Resource
|
||||
// ->options(QualityValidation::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status'))
|
||||
->reactive(),
|
||||
|
||||
Select::make('operator_id')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
$shiftId = $get('Shift');
|
||||
if (!$plantId && !$lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && !$lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && $lineId && !$shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else if ($plantId && !$lineId && $shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
else// if ($plantId && $lineId && $shiftId)
|
||||
{
|
||||
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -1146,7 +1207,7 @@ class ProductionQuantityResource extends Resource
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['operator_id']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -1178,6 +1239,10 @@ class ProductionQuantityResource extends Resource
|
||||
$query->where('sap_msg_status', $data['sap_msg_status']);
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$query->where('operator_id', $data['operator_id']);
|
||||
}
|
||||
|
||||
if ($from = $data['created_from'] ?? null) {
|
||||
$query->where('created_at', '>=', $from);
|
||||
}
|
||||
@@ -1185,6 +1250,7 @@ class ProductionQuantityResource extends Resource
|
||||
if ($to = $data['created_to'] ?? null) {
|
||||
$query->where('created_at', '<=', $to);
|
||||
}
|
||||
|
||||
// return $query;
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
@@ -1218,6 +1284,10 @@ class ProductionQuantityResource extends Resource
|
||||
$indicators[] = 'SAP Message Status: ' . $data['sap_msg_status'];
|
||||
}
|
||||
|
||||
if (!empty($data['operator_id'])) {
|
||||
$indicators[] = 'Created By: ' . $data['operator_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
|
||||
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -354,7 +354,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
|
||||
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
@@ -1050,7 +1050,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
->body("Valid QR code scanned:<br>{$this->qrData}")
|
||||
->success()
|
||||
// ->persistent()
|
||||
->seconds(2)
|
||||
->duration(600)
|
||||
->send();
|
||||
|
||||
$formQRData = null;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,8 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Export Dispatch';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -84,6 +86,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
->label('Scan Pallet No')
|
||||
->required( fn ($get) => $get('rework_type') == 'pallet')
|
||||
->readOnly(fn ($get) => $get('rework_type') == 'invoice')
|
||||
->minLength(10)
|
||||
->reactive()
|
||||
->readOnly(fn (callable $get) => (!$get('plant') || !$get('rework_type') || ($get('rework_type') == 'invoice' && !$get('invoice_number')) || $get('scan_serial_no')))
|
||||
->extraAttributes([
|
||||
@@ -91,8 +94,9 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
]),
|
||||
Forms\Components\TextInput::make('scan_serial_no')
|
||||
->label('Scan Serial No')
|
||||
->reactive()
|
||||
->readOnly(fn (callable $get) => (!$get('plant') || !$get('rework_type') || ($get('rework_type') == 'invoice' && !$get('invoice_number')) || ($get('rework_type') == 'invoice' && $get('scan_pallet_no')) || ($get('rework_type') == 'pallet' && !$get('scan_pallet_no'))))
|
||||
->minLength(9)
|
||||
->reactive()
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processSno($event.target.value)',
|
||||
]),
|
||||
@@ -143,21 +147,21 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
$invoiceNumber = $get('invoice_number');
|
||||
|
||||
$rows = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->get();
|
||||
->where('plant_id', $plantId)
|
||||
->get();
|
||||
|
||||
$notCompletedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->where(function($query) {
|
||||
$query->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '');
|
||||
})
|
||||
->count();
|
||||
->where('plant_id', $plantId)
|
||||
->where(function($query) {
|
||||
$query->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '');
|
||||
})
|
||||
->count();
|
||||
|
||||
$isScanningComplete = true;
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
if ($row->scanned_status !== 'Scanned') {
|
||||
if ($row->scanned_status != 'Scanned') {
|
||||
$isScanningComplete = false;
|
||||
break;
|
||||
}
|
||||
@@ -166,9 +170,13 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
if (!$isScanningComplete)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$set('invoice_number', null);
|
||||
$set('update_invoice', null);
|
||||
return;
|
||||
}
|
||||
}),
|
||||
@@ -182,24 +190,16 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant');
|
||||
|
||||
$invoiceNumber = $get('invoice_number');
|
||||
$palletNumber = $get('scan_pallet_no');
|
||||
|
||||
$rows = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->get();
|
||||
|
||||
$notCompletedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->where(function($query) {
|
||||
$query->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '');
|
||||
})
|
||||
->count();
|
||||
$rows = PalletValidation::where('pallet_number', $palletNumber)
|
||||
->where('plant_id', $plantId)
|
||||
->get();
|
||||
|
||||
$isScanningComplete = true;
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
if ($row->scanned_status !== 'Scanned') {
|
||||
if ($row->pallet_status != 'Completed') {
|
||||
$isScanningComplete = false;
|
||||
break;
|
||||
}
|
||||
@@ -208,9 +208,13 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
if (!$isScanningComplete)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
|
||||
->danger()
|
||||
->send();
|
||||
->title("Scanned pallet number '$palletNumber' does not completed the master packing!<br>Please, scan the valid completed pallet number to proceed...")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$set('scan_pallet_no', null);
|
||||
$set('update_pallet', null);
|
||||
return;
|
||||
}
|
||||
}),
|
||||
@@ -241,6 +245,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('invoice_number')
|
||||
->label('Invoice Number')
|
||||
@@ -314,11 +319,15 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(ReworkLocatorInvoiceValidationImporter::class)
|
||||
->label('Import Rework Invoice')
|
||||
->color('warning')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import rework invoice validation');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(ReworkLocatorInvoiceValidationExporter::class)
|
||||
->label('Export Rework Invoice')
|
||||
->color('warning')
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export rework invoice validation');
|
||||
}),
|
||||
@@ -531,6 +540,11 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Scan Rework';
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
@@ -540,10 +554,6 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
'edit' => Pages\EditReworkLocatorInvoiceValidation::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Rework Invoice / Pallet';
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
|
||||
@@ -54,7 +54,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Invoice Number")
|
||||
->body("Invoice number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -81,6 +83,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Invoice number '$invoiceNo' doesn't exist in invoice table!<br><br>Scan the valid exist 'Invoice Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -126,7 +129,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -143,13 +148,40 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) > 0 && strlen($serialNo) < 13)
|
||||
else if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 13 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNo,
|
||||
'scan_pallet_no' => null,
|
||||
'scan_serial_no' => null,
|
||||
'rework_type' => $reworkType,
|
||||
'reworkType' => $reworkType,
|
||||
'update_invoice' => 0,
|
||||
'update_pallet' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) > 0 && !ctype_alnum($serialNo))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -196,6 +228,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Invoice')
|
||||
->body("Scanned invoice number '$invoiceNo' successfully moved into rework invoice table.<br><br>Please, scan the next completed invoice number to proceed..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -219,6 +252,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Invoice Found')
|
||||
->body("Press 'Yes' and Press 'Enter' in Scan Invoice No to do rework for entire invoice.<br><br>Press 'No' to do rework against 'Pallet or Serial Number'..!")
|
||||
->info()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -244,6 +278,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Completed')
|
||||
->body("Scanned invoice number '$invoiceNo' doesn't completed the scanning process!<br><br>Has '$notCompletedCount' pending serial number to scan!<br><br>Please, scan the valid completed invoice number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -269,15 +304,18 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Choosed: Pallet Rework Type")
|
||||
->body("Scan valid pallet number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title("Rework Type Not Found")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -331,7 +369,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Invoice Number")
|
||||
->body("Invoice number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -358,6 +398,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Invoice number '$invoiceNo' doesn't exist in invoice table!<br><br>Scan the valid exist 'Invoice Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -403,7 +444,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -427,7 +470,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -453,6 +498,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Found')
|
||||
->body("Pallet number '$palletNo' doesn't exist in scanned invoice number '$invoiceNo'!<br><br>Scan the valid exist 'Pallet Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -472,13 +518,40 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($serialNo) > 0 && strlen($serialNo) < 13)
|
||||
if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 13 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, $palletNo, $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNo,
|
||||
'scan_pallet_no' => $palletNo,
|
||||
'scan_serial_no' => null,
|
||||
'rework_type' => $reworkType,
|
||||
'reworkType' => $reworkType,
|
||||
'update_invoice' => 0,
|
||||
'update_pallet' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) > 0 && !ctype_alnum($serialNo))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, $palletNo, $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -526,6 +599,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Pallet from Invoice')
|
||||
->body("Scanned pallet number '$palletNo' successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next pallet number to proceed..!")
|
||||
->success()
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$InvoiceSerialNumbers = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->first();
|
||||
@@ -535,6 +609,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("All available serial numbers are successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next invoice number to proceed..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -576,6 +651,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Completed')
|
||||
->body("Scanned invoice number '$invoiceNo' doesn't completed the scanning process!<br><br>Has '$notCompletedCount' pending serial number to scan!<br><br>Please, scan the valid completed invoice number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -603,7 +679,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -627,7 +705,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -653,6 +733,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Found')
|
||||
->body("Pallet number '$palletNo' doesn't exist in pallet table!<br><br>Scan the valid exist 'Pallet Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -692,6 +773,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Locator Pallet Found')
|
||||
->body("Scanned pallet number '$palletNo' exist in locator number '$locatExist'.<br><br>Remove scanned 'Pallet' from 'Locator' to proceed re-master packing..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -712,13 +794,40 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($serialNo) > 0 && strlen($serialNo) < 13)
|
||||
if (strlen($serialNo) > 0 && (strlen($serialNo) < 9 || strlen($serialNo) > 20))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 13 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => null,
|
||||
'scan_pallet_no' => $palletNo,
|
||||
'scan_serial_no' => null,
|
||||
'rework_type' => $reworkType,
|
||||
'reworkType' => $reworkType,
|
||||
'update_invoice' => 0,
|
||||
'update_pallet' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) > 0 && !ctype_alnum($serialNo))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -747,6 +856,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Pallet')
|
||||
->body("Scanned pallet number '$palletNo' successfully removed from pallet table.<br><br>Please, scan the next pallet number to re-master packing..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -771,6 +881,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Pallet Found')
|
||||
->body("Press 'Yes' and Press 'Enter' in Scan Pallet No to do re-master packing for entire pallet.<br><br>Press 'No' to do partial re-master packing against 'Serial Number'..!")
|
||||
->info()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -797,6 +908,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Completed')
|
||||
->body("Scanned pallet number '$palletNo' doesn't completed the master packing!<br><br>Please, scan the valid completed pallet number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -821,7 +933,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Rework Type Not Found")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -875,7 +989,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Invoice Number")
|
||||
->body("Invoice number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -902,6 +1018,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Found')
|
||||
->body("Invoice number '$invoiceNo' doesn't exist in invoice table!<br><br>Scan the valid exist 'Invoice Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -947,7 +1064,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -970,7 +1089,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -988,13 +1109,40 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) < 13)
|
||||
else if (strlen($serialNo) < 9 || strlen($serialNo) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 13 digits.")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => $invoiceNo,
|
||||
'scan_pallet_no' => null,
|
||||
'scan_serial_no' => null,
|
||||
'rework_type' => $reworkType,
|
||||
'reworkType' => $reworkType,
|
||||
'update_invoice' => 0,
|
||||
'update_pallet' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (!ctype_alnum($serialNo))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1020,6 +1168,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Serial Not Found')
|
||||
->body("Serial number '$serialNo' doesn't exist in scanned invoice number '$invoiceNo'!<br><br>Scan the valid exist 'Serial Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, '', $plantId, $reworkType);
|
||||
@@ -1069,6 +1218,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Serial from Invoice')
|
||||
->body("Scanned serial number '$serialNo' successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next serial number to proceed..!")
|
||||
->success()
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$InvoiceSerialNumbers = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->first();
|
||||
@@ -1078,6 +1228,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("All available serial numbers are successfully moved into rework invoice table from invoice number '$invoiceNo'.<br><br>Please, scan the next invoice number to proceed..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1119,6 +1270,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Invoice Not Completed')
|
||||
->body("Scanned invoice number '$invoiceNo' doesn't completed the scanning process!<br><br>Has '$notCompletedCount' pending serial number to scan!<br><br>Please, scan the valid completed invoice number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1146,7 +1298,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -1170,7 +1324,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Pallet Number")
|
||||
->body("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1196,6 +1352,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Found')
|
||||
->body("Pallet number '$palletNo' doesn't exist in pallet table!<br><br>Scan the valid exist 'Pallet Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1235,6 +1392,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Locator Pallet Found')
|
||||
->body("Scanned pallet number '$palletNo' exist in locator number '$locatExist'.<br><br>Remove scanned 'Pallet' from 'Locator' to proceed re-master packing..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '' , '', $plantId, $reworkType);
|
||||
@@ -1261,7 +1419,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
// $snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNo)->count();
|
||||
$this->form->fill([
|
||||
@@ -1279,13 +1439,40 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (strlen($serialNo) < 13)
|
||||
else if (strlen($serialNo) < 9 || strlen($serialNo) > 20)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must be at least 13 digits.")
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number should contain minimum 9 digits and maximum 20 digits.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'plant' => $plantId,
|
||||
'invoice_number' => null,
|
||||
'scan_pallet_no' => $palletNo,
|
||||
'scan_serial_no' => null,
|
||||
'rework_type' => $reworkType,
|
||||
'reworkType' => $reworkType,
|
||||
'update_invoice' => 0,
|
||||
'update_pallet' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else if (!ctype_alnum($serialNo))
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invalid: Serial Number")
|
||||
->body("Serial number '$serialNo' must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1311,6 +1498,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Serial Not Found')
|
||||
->body("Serial number '$serialNo' doesn't exist in pallet number '$palletNo'!<br><br>Scan the valid exist 'Serial Number' to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', $palletNo, $plantId, $reworkType);
|
||||
@@ -1332,9 +1520,10 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
|
||||
foreach ($records as $row)
|
||||
{
|
||||
if ($PalletSerialNumbers->serial_number != null && $PalletSerialNumbers->serial_number != '' && $PalletSerialNumbers->serial_number != $serialNo)
|
||||
if ($row->serial_number != null && $row->serial_number != '' && $row->serial_number == $serialNo)
|
||||
{
|
||||
$row->forceDelete();
|
||||
continue;
|
||||
}
|
||||
|
||||
$row->pallet_status = null;
|
||||
@@ -1347,6 +1536,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Completed: Rework Serial from Pallet')
|
||||
->body("Scanned serial number '$serialNo' successfully removed from pallet number '$palletNo'.<br><br>Please, scan the next pallet number to re-master packing..!")
|
||||
->success()
|
||||
->duration(500)
|
||||
->send();
|
||||
|
||||
$PalletSerialNumbers = PalletValidation::where('plant_id', $plantId)->where('pallet_number', $palletNo)->first();
|
||||
@@ -1356,6 +1546,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNo' successfully re-master packed.<br><br>Please, scan the next pallet number to re-master packing..!")
|
||||
->success()
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
@@ -1398,6 +1589,7 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
->title('Pallet Not Completed')
|
||||
->body("Pallet number '$palletNo' doesn't completed the master packing for scanned serial number '$serialNo'!<br><br>Please, scan the valid completed pallet number to proceed..!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '' , '', $plantId, $reworkType);
|
||||
@@ -1422,7 +1614,9 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
Notification::make()
|
||||
->title("Rework Type Not Found")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData', '', '', $plantId, $reworkType);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
|
||||
@@ -48,11 +48,17 @@ class StickerMasterResource extends Resource
|
||||
$set('item_id', null) & //when plant changed remove all the data which is in text input box
|
||||
$set('item_description', null) &
|
||||
$set('item_error', null) &
|
||||
$set('panel_box_code', null) &
|
||||
$set('load_rate', null) &
|
||||
$set('bundle_quantity', null) &
|
||||
$set('material_type', null) &
|
||||
$set('part_validation1', null) &
|
||||
$set('part_validation2', null) &
|
||||
$set('part_validation3', null) &
|
||||
$set('part_validation4', null) &
|
||||
$set('part_validation5', null) &
|
||||
$set('laser_part_validation1', null) &
|
||||
$set('laser_part_validation2', null) &
|
||||
$set('serial_number_motor', false) &
|
||||
$set('serial_number_pump', false) &
|
||||
$set('serial_number_pumpset', false) &
|
||||
@@ -169,6 +175,12 @@ class StickerMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('part_validation5')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation1')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation2')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->readOnly(fn (callable $get) => $get('material_type'))
|
||||
@@ -509,6 +521,12 @@ class StickerMasterResource extends Resource
|
||||
Tables\Columns\TextColumn::make('part_validation5')
|
||||
->label('Part Validation 5')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('laser_part_validation1')
|
||||
->label('Laser Part Validation 1')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('laser_part_validation2')
|
||||
->label('Laser Part Validation 2')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->alignCenter(),
|
||||
@@ -521,7 +539,18 @@ class StickerMasterResource extends Resource
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('material_type')
|
||||
->label('Material Type')
|
||||
->alignCenter(),
|
||||
->alignCenter()
|
||||
->formatStateUsing(function ($state) {
|
||||
if (is_null($state) || $state === '') {
|
||||
return '';
|
||||
}
|
||||
return match ($state) {
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
default => '',
|
||||
};
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
|
||||
165
app/Filament/Resources/TempLiveReadingResource.php
Normal file
165
app/Filament/Resources/TempLiveReadingResource.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\TempLiveReadingExporter;
|
||||
use App\Filament\Imports\TempLiveReadingImporter;
|
||||
use App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
use App\Filament\Resources\TempLiveReadingResource\RelationManagers;
|
||||
use App\Models\MfmMeter;
|
||||
use App\Models\TempLiveReading;
|
||||
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\Section;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
|
||||
class TempLiveReadingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TempLiveReading::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static ?string $navigationGroup = 'Power House';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->required(),
|
||||
Forms\Components\Select::make('mfm_meter_id')
|
||||
->label('MFM Meter ID')
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return MfmMeter::where('plant_id', $plantId)
|
||||
->pluck('sequence', 'id')
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\TextInput::make('register_data')
|
||||
->label('Register Data')
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(3),
|
||||
]);
|
||||
}
|
||||
|
||||
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')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('mfm_meter_id.sequence')
|
||||
// ->label('Sequence')
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('mfmMeter.name')
|
||||
->label('Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('register_data')
|
||||
->label('Register Data')
|
||||
->sortable(),
|
||||
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(),
|
||||
])
|
||||
->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(TempLiveReadingImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import temp live reading');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(TempLiveReadingExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export temp live reading');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Live Readings';
|
||||
}
|
||||
|
||||
public static function getHeading(): string
|
||||
{
|
||||
return 'Live Readings';
|
||||
}
|
||||
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTempLiveReadings::route('/'),
|
||||
'create' => Pages\CreateTempLiveReading::route('/create'),
|
||||
'view' => Pages\ViewTempLiveReading::route('/{record}'),
|
||||
'edit' => Pages\EditTempLiveReading::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTempLiveReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Create Live Readings';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTempLiveReading extends EditRecord
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Edit Live Readings';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TempLiveReadingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\TempLiveReadingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTempLiveReadings extends ListRecords
|
||||
{
|
||||
protected static string $resource = TempLiveReadingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Live Readings';
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user