Compare commits
146 Commits
qds
...
cf6c9b81b1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf6c9b81b1 | ||
|
|
034db8f879 | ||
|
|
71f29243e2 | ||
|
|
388d91f8a4 | ||
|
|
be892cb662 | ||
|
|
584d4faa07 | ||
|
|
3f1b46873e | ||
|
|
9d69ce89ae | ||
|
|
e14814e529 | ||
|
|
98feb7bfc5 | ||
|
|
998fbf814c | ||
|
|
d2c7f85917 | ||
|
|
5b8bb29aeb | ||
|
|
b2cf4dc18e | ||
|
|
9774cda2ad | ||
|
|
bbe05d62b1 | ||
|
|
f353a699a2 | ||
|
|
956c282005 | ||
|
|
c9b5a59bf2 | ||
|
|
086910122e | ||
|
|
92a3b5a448 | ||
|
|
64237c3da0 | ||
|
|
3d21975096 | ||
|
|
0710c3a7a1 | ||
|
|
18eb234df4 | ||
|
|
8a3c0639ad | ||
|
|
f50fbf5771 | ||
|
|
3a115241a9 | ||
|
|
062f35cb4d | ||
|
|
062f143dbb | ||
|
|
7406f4c97e | ||
|
|
831c88f0fd | ||
|
|
733cc45e60 | ||
|
|
0f3b516614 | ||
|
|
8187aca5d4 | ||
|
|
1d998d6478 | ||
|
|
86ad06def7 | ||
|
|
6a70b45f4f | ||
|
|
7e1852cfed | ||
|
|
7ca806449c | ||
|
|
90899c87f5 | ||
|
|
fad3cf4ed6 | ||
|
|
2e7c37c6f1 | ||
|
|
4c1950bf29 | ||
|
|
d13f502db8 | ||
|
|
4da6e97e6e | ||
|
|
f670793ff5 | ||
|
|
2abc5199eb | ||
|
|
d4192d3002 | ||
|
|
eaba6b8396 | ||
|
|
237fb1a7b3 | ||
|
|
b178130e8d | ||
|
|
4c1a0a0282 | ||
|
|
af719c2d33 | ||
|
|
bbd192148c | ||
|
|
93b1138752 | ||
|
|
40ef91a60b | ||
|
|
012ce6d865 | ||
|
|
e8637874f4 | ||
|
|
5a7050a5b4 | ||
|
|
24b9b5194a | ||
|
|
9a6e364f52 | ||
|
|
d4582292a4 | ||
|
|
b222c78d4b | ||
|
|
d827c9368f | ||
|
|
b48392a40c | ||
|
|
dc0b4ea75e | ||
|
|
49fea7fcdb | ||
|
|
3848898f37 | ||
|
|
4bb3b60391 | ||
|
|
0381530463 | ||
|
|
2244d82af0 | ||
|
|
594cc252a9 | ||
|
|
21bbbb24c2 | ||
|
|
3b0501ef9e | ||
|
|
23fa24ca46 | ||
|
|
55c0ebfa6d | ||
|
|
db3a69d47f | ||
|
|
5ba9db0278 | ||
|
|
6a195d00c5 | ||
|
|
386b9c4a09 | ||
|
|
853a1542bb | ||
|
|
d3e9237bff | ||
|
|
c76ae58118 | ||
|
|
d2fc4e0b40 | ||
|
|
bd1d7e61b4 | ||
|
|
bac7c610f8 | ||
|
|
36006e6e08 | ||
|
|
319aea377a | ||
|
|
444b4a4804 | ||
|
|
21e048549d | ||
|
|
ba453ef505 | ||
|
|
e5a3d212d0 | ||
|
|
367d103c75 | ||
|
|
365d5b19ab | ||
|
|
8c488e1ced | ||
|
|
1bd14d5f73 | ||
|
|
aaa162a3f2 | ||
|
|
8813567f0b | ||
|
|
ffa2b1f783 | ||
|
|
e29c16c79a | ||
|
|
4d516e955c | ||
|
|
b0d73dbbc6 | ||
|
|
37c91afe25 | ||
|
|
77064399cd | ||
|
|
3398a60d1b | ||
|
|
65aafbeb65 | ||
|
|
ad72d38193 | ||
|
|
cac91722c3 | ||
|
|
bb2b81d0f2 | ||
|
|
2150f6098f | ||
|
|
a0a1e87440 | ||
|
|
8da3c746b9 | ||
|
|
d05623f920 | ||
|
|
e3d29cba81 | ||
|
|
5cbae18532 | ||
|
|
7e688683d7 | ||
|
|
ab5a8c0874 | ||
|
|
19e1f12f5d | ||
|
|
e57962f023 | ||
|
|
c5a730b71d | ||
|
|
967a429595 | ||
|
|
7f0d138383 | ||
|
|
d5c0303be4 | ||
|
|
c2f9b77e1f | ||
| 3053098cfb | |||
| a5ded4a20a | |||
|
|
d419973ab5 | ||
|
|
86e458037f | ||
|
|
e6ba543589 | ||
|
|
1cee8dc71d | ||
|
|
3a009543ea | ||
|
|
d4045b7b0f | ||
|
|
a831f6e787 | ||
|
|
b399141c7e | ||
|
|
8fd2212ec4 | ||
|
|
e6f78c60d5 | ||
|
|
a3a421af88 | ||
|
|
d4eeee7d05 | ||
|
|
bd17af8945 | ||
|
|
95f1e09304 | ||
|
|
fc42e7db6c | ||
|
|
0d3e58e7af | ||
|
|
658d7cb42c | ||
|
|
679d532b17 | ||
|
|
50ddd51f04 |
@@ -30,252 +30,11 @@ class SendInvoiceReport extends Command
|
||||
* 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');
|
||||
//$scheduleType = $this->argument('scheduleType');
|
||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
@@ -303,7 +62,8 @@ class SendInvoiceReport extends Command
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
foreach ($plantIds as $plantId) {
|
||||
foreach ($plantIds as $plantId)
|
||||
{
|
||||
$plant = Plant::find($plantId);
|
||||
$plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
@@ -322,11 +82,27 @@ class SendInvoiceReport extends Command
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$serialInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', null)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('scanned_status', 'Scanned')
|
||||
->where(function($query) {
|
||||
$query->whereNull('quantity')
|
||||
->orWhere('quantity', 0);
|
||||
})
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$serialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalSerialCount,
|
||||
'scannedInvoice' => $scannedSerialCount,
|
||||
'totalInvoiceQuan' => $serialInvoiceQuan,
|
||||
'scannedInvoiceQuan' => $scannedInvoiceQuan,
|
||||
];
|
||||
|
||||
// Material Invoice
|
||||
@@ -344,11 +120,25 @@ class SendInvoiceReport extends Command
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$totalMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$materialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalMatCount,
|
||||
'scannedInvoice' => $scannedMatCount,
|
||||
'totalInvoiceQuan' => $totalMatInvoiceQuan,
|
||||
'scannedInvoiceQuan' => $scannedMatInvoiceQuan,
|
||||
];
|
||||
|
||||
// Bundle Invoice
|
||||
@@ -366,29 +156,49 @@ class SendInvoiceReport extends Command
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$totalBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
$bundleTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalBundleCount,
|
||||
'scannedInvoice' => $scannedBundleCount,
|
||||
'totalInvoiceQuan' => $totalBundleInvoiceQuan,
|
||||
'scannedInvoiceQuan' => $scannedBundleInvoiceQuan,
|
||||
];
|
||||
|
||||
$no++;
|
||||
}
|
||||
|
||||
$mail = new test($serialTableData, $materialTableData, $bundleTableData, $schedule);
|
||||
$contentVars = $mail->content()->with;
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Invoice Report');
|
||||
|
||||
// Send to SerialInvoiceMail recipients
|
||||
if ($mailRules->has('SerialInvoiceMail')) {
|
||||
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, [], []));
|
||||
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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));
|
||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,19 +206,21 @@ class SendInvoiceReport extends Command
|
||||
if ($mailRules->has('InvoiceMail')) {
|
||||
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
|
||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
|
||||
}
|
||||
}
|
||||
|
||||
// Show preview in console
|
||||
$this->info('--- Serial Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
|
||||
|
||||
$this->info('--- Material Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
|
||||
|
||||
$this->info('--- Bundle Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,77 +33,6 @@ class SendProductionReport extends Command
|
||||
* 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');
|
||||
@@ -146,55 +75,6 @@ class SendProductionReport extends Command
|
||||
$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)
|
||||
@@ -232,20 +112,38 @@ class SendProductionReport extends Command
|
||||
|
||||
|
||||
|
||||
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
//$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
|
||||
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
// $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).");
|
||||
// Preview in console
|
||||
$mail = new ProductionMail($scheduleType, $tableData);
|
||||
$contentVars = $mail->content()->with;
|
||||
|
||||
$this->info($contentVars['greeting'] ?? 'Production Report');
|
||||
$this->table(
|
||||
['No', 'Plant', 'Line', 'Type', 'Target Quantity', 'Production Quantity'],
|
||||
$tableData
|
||||
);
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
|
||||
// Send mails
|
||||
if (!empty($emails)) {
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new ProductionMail($tableData));
|
||||
Mail::to($email)->send(new ProductionMail($scheduleType, $tableData));
|
||||
}
|
||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
} else {
|
||||
$this->info('No recipients found for ProductionMailAlert.');
|
||||
$this->warn('No recipients found for ProductionMailAlert.');
|
||||
}
|
||||
|
||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class ConfigurationExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
74
app/Filament/Exports/EquipmentMasterExporter.php
Normal file
74
app/Filament/Exports/EquipmentMasterExporter.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\EquipmentMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class EquipmentMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = EquipmentMaster::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('machine.name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('make')
|
||||
->label('MAKE'),
|
||||
ExportColumn::make('model')
|
||||
->label('MODEL'),
|
||||
ExportColumn::make('equipment_number')
|
||||
->label('EQUIPMENT NUMBER'),
|
||||
ExportColumn::make('instrument_serial_number')
|
||||
->label('INSTRUMENT SERIAL NUMBER'),
|
||||
ExportColumn::make('calibrated_on')
|
||||
->label('CALIBRATED ON'),
|
||||
ExportColumn::make('frequency')
|
||||
->label('FREQUENCY'),
|
||||
ExportColumn::make('next_calibration_date')
|
||||
->label('NEXT CALIBRATION DATE'),
|
||||
ExportColumn::make('calibrated_by')
|
||||
->label('CALIBRATED BY'),
|
||||
ExportColumn::make('calibration_certificate')
|
||||
->label('CALIBRATION CERTIFICATE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your equipment 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;
|
||||
}
|
||||
}
|
||||
56
app/Filament/Exports/GrMasterExporter.php
Normal file
56
app/Filament/Exports/GrMasterExporter.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\GrMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class GrMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = GrMaster::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('item.code')
|
||||
->label('ITEM'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('gr_number')
|
||||
->label('GR NUMBER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your gr 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;
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,48 @@ class LineExporter extends Exporter
|
||||
->label('NAME'),
|
||||
ExportColumn::make('type')
|
||||
->label('TYPE'),
|
||||
ExportColumn::make('group_work_center')
|
||||
->label('GROUP WORK CENTER'),
|
||||
ExportColumn::make('no_of_operation')
|
||||
->label('NO OF OPERATION'),
|
||||
ExportColumn::make('workGroup1.name')
|
||||
->label('WORK GROUP CENTER 1'),
|
||||
ExportColumn::make('workGroup1.operation_number')
|
||||
->label('OPERATION NUMBER 1'),
|
||||
ExportColumn::make('workGroup2.name')
|
||||
->label('WORK GROUP CENTER 2'),
|
||||
ExportColumn::make('workGroup2.operation_number')
|
||||
->label('OPERATION NUMBER 2'),
|
||||
ExportColumn::make('workGroup3.name')
|
||||
->label('WORK GROUP CENTER 3'),
|
||||
ExportColumn::make('workGroup3.operation_number')
|
||||
->label('OPERATION NUMBER 3'),
|
||||
ExportColumn::make('workGroup4.name')
|
||||
->label('WORK GROUP CENTER 4'),
|
||||
ExportColumn::make('workGroup4.operation_number')
|
||||
->label('OPERATION NUMBER 4'),
|
||||
ExportColumn::make('workGroup5.name')
|
||||
->label('WORK GROUP CENTER 5'),
|
||||
ExportColumn::make('workGroup5.operation_number')
|
||||
->label('OPERATION NUMBER 5'),
|
||||
ExportColumn::make('workGroup6.name')
|
||||
->label('WORK GROUP CENTER 6'),
|
||||
ExportColumn::make('workGroup6.operation_number')
|
||||
->label('OPERATION NUMBER 6'),
|
||||
ExportColumn::make('workGroup7.name')
|
||||
->label('WORK GROUP CENTER 7'),
|
||||
ExportColumn::make('workGroup7.operation_number')
|
||||
->label('OPERATION NUMBER 7'),
|
||||
ExportColumn::make('workGroup8.name')
|
||||
->label('WORK GROUP CENTER 8'),
|
||||
ExportColumn::make('workGroup8.operation_number')
|
||||
->label('OPERATION NUMBER 8'),
|
||||
ExportColumn::make('workGroup9.name')
|
||||
->label('WORK GROUP CENTER 9'),
|
||||
ExportColumn::make('workGroup9.operation_number')
|
||||
->label('OPERATION NUMBER 9'),
|
||||
ExportColumn::make('workGroup10.name')
|
||||
->label('WORK GROUP CENTER 10'),
|
||||
ExportColumn::make('workGroup10.operation_number')
|
||||
->label('OPERATION NUMBER 10'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
|
||||
@@ -30,6 +30,8 @@ class MachineExporter extends Exporter
|
||||
->label('MACHINE'),
|
||||
ExportColumn::make('work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('workGroupMaster.name')
|
||||
->label('WORK GROUP CENTER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
|
||||
@@ -22,12 +22,14 @@ class MotorTestingMasterExporter extends Exporter
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('subassembly_code')
|
||||
->label('SUBASSEMBLY CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('isi_model')
|
||||
@@ -69,9 +71,9 @@ class MotorTestingMasterExporter extends Exporter
|
||||
ExportColumn::make('res_br_ul')
|
||||
->label('RESISTANCE BR UL'),
|
||||
ExportColumn::make('lock_volt_limit')
|
||||
->label('LOCK VOLT Limit'),
|
||||
->label('LOCK VOLT LIMIT'),
|
||||
ExportColumn::make('leak_cur_limit')
|
||||
->label('Leak CURRENT Limit'),
|
||||
->label('LEAK CURRENT LIMIT'),
|
||||
ExportColumn::make('lock_cur_ll')
|
||||
->label('LOCK CURRENT LL'),
|
||||
ExportColumn::make('lock_cur_ul')
|
||||
|
||||
@@ -30,23 +30,25 @@ class TestingPanelReadingExporter extends Exporter
|
||||
->label('LINE'),
|
||||
ExportColumn::make('machine.name')
|
||||
->label('MACHINE'),
|
||||
ExportColumn::make('item.code')
|
||||
ExportColumn::make('motorTestingMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
ExportColumn::make('motorTestingMaster.item.description')
|
||||
->label('MODEL'),
|
||||
ExportColumn::make('output')
|
||||
->label('OUTPUT'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('item.kw')
|
||||
ExportColumn::make('winded_serial_number')
|
||||
->label('WINDED SERIAL NUMBER'),
|
||||
ExportColumn::make('motorTestingMaster.kw')
|
||||
->label('KW'),
|
||||
ExportColumn::make('item.hp')
|
||||
ExportColumn::make('motorTestingMaster.hp')
|
||||
->label('HP'),
|
||||
ExportColumn::make('item.phase')
|
||||
ExportColumn::make('motorTestingMaster.phase')
|
||||
->label('PHASE'),
|
||||
ExportColumn::make('item.connection')
|
||||
ExportColumn::make('motorTestingMaster.connection')
|
||||
->label('CONNECTION'),
|
||||
ExportColumn::make('item.isi_model')
|
||||
ExportColumn::make('motorTestingMaster.isi_model')
|
||||
->label('ISI MODEL'),
|
||||
ExportColumn::make('before_fr_volt')
|
||||
->label('BEFORE FR VOLT'),
|
||||
|
||||
58
app/Filament/Exports/UserExporter.php
Normal file
58
app/Filament/Exports/UserExporter.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class UserExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('email')
|
||||
->label('E-MAIL'),
|
||||
ExportColumn::make('password')
|
||||
->label('PASSWORD'),
|
||||
ExportColumn::make('roles')
|
||||
->label('ROLES')
|
||||
->state(function ($record) {
|
||||
// Assuming Spatie\Permission: roles() relationship
|
||||
return $record->roles->pluck('name')->join(', ');
|
||||
}),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your user 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;
|
||||
}
|
||||
}
|
||||
54
app/Filament/Exports/WorkGroupMasterExporter.php
Normal file
54
app/Filament/Exports/WorkGroupMasterExporter.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class WorkGroupMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = WorkGroupMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('operation_number')
|
||||
->label('OPERATION NUMBER'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
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 work group 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;
|
||||
}
|
||||
}
|
||||
@@ -41,15 +41,15 @@ class ConfigurationImporter extends Importer
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->exampleHeader('Line')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I'])
|
||||
->example(['1000'])
|
||||
->label('Plant')
|
||||
->rules(['required']),
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
109
app/Filament/Imports/EquipmentMasterImporter.php
Normal file
109
app/Filament/Imports/EquipmentMasterImporter.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\EquipmentMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class EquipmentMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = EquipmentMaster::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('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Machine Name')
|
||||
->example('1006378')
|
||||
->label('Machine Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->label('Name')
|
||||
->exampleHeader('Name')
|
||||
->example('463605 E-E-078'),
|
||||
ImportColumn::make('description')
|
||||
->label('Description')
|
||||
->exampleHeader('Description')
|
||||
->example('FIN.6INCH.HOUSING LOWER 150R3+ CI RUN-OUT CHECKING FIXTURE'),
|
||||
ImportColumn::make('make')
|
||||
->label('Make')
|
||||
->exampleHeader('Make')
|
||||
->example('Ok'),
|
||||
ImportColumn::make('model')
|
||||
->label('Model')
|
||||
->exampleHeader('Model')
|
||||
->example('Ok'),
|
||||
ImportColumn::make('equipment_number')
|
||||
->label('Equipment Number')
|
||||
->exampleHeader('Equipment Number')
|
||||
->example('463605 E-E-078'),
|
||||
ImportColumn::make('instrument_serial_number')
|
||||
->label('Instrument Serial Number')
|
||||
->exampleHeader('Instrument Serial Number')
|
||||
->example('131548498'),
|
||||
ImportColumn::make('calibrated_on')
|
||||
->label('Calibrated On')
|
||||
->exampleHeader('Calibrated On')
|
||||
->example('01-09-2025 08:00:00')
|
||||
->requiredMapping()
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('frequency')
|
||||
->label('Frequency')
|
||||
->exampleHeader('Frequency')
|
||||
->example('15')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('next_calibration_date')
|
||||
->label('Next Calibration Date')
|
||||
->exampleHeader('Next Calibration Date')
|
||||
->requiredMapping()
|
||||
->example('16-09-2025 08:00:00')
|
||||
->rules(['required', 'datetime']),
|
||||
ImportColumn::make('calibrated_by')
|
||||
->label('Calibration By')
|
||||
->example('Sri Venkateswara Tools')
|
||||
->exampleHeader('Calibration By'),
|
||||
ImportColumn::make('calibration_certificate')
|
||||
->label('Calibration Certificate')
|
||||
->example('1231CRI651')
|
||||
->exampleHeader('Calibration Certificate'),
|
||||
ImportColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->example('RAS00296')
|
||||
->exampleHeader('Created By'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?EquipmentMaster
|
||||
{
|
||||
// return EquipmentMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new EquipmentMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your equipment 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;
|
||||
}
|
||||
}
|
||||
73
app/Filament/Imports/GrMasterImporter.php
Normal file
73
app/Filament/Imports/GrMasterImporter.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\GrMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class GrMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = GrMaster::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('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('630214')
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number')
|
||||
->example('11023567567567')
|
||||
->label('Serial Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('gr_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('GR Number')
|
||||
->example('67345237')
|
||||
->label('GR Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
//ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?GrMaster
|
||||
{
|
||||
// return GrMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new GrMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your gr 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;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
@@ -29,11 +30,61 @@ class LineImporter extends Importer
|
||||
->example('Domestic Assembly')
|
||||
->label('Line Type')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('group_work_center')
|
||||
ImportColumn::make('no_of_operation')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Group Work Center')
|
||||
->example('RMGCEABC')
|
||||
->label('Group Work Center'),
|
||||
->exampleHeader('No of Operation')
|
||||
->example('10')
|
||||
->label('No of Operation'),
|
||||
ImportColumn::make('work_group1_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 1')
|
||||
->example('RMGCGABC')
|
||||
->label('Work Group Center 1'),
|
||||
ImportColumn::make('work_group2_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 2')
|
||||
->example('RMGCGABC1')
|
||||
->label('Work Group Center 2'),
|
||||
ImportColumn::make('work_group3_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 3')
|
||||
->example('RMGCGABC2')
|
||||
->label('Work Group Center 3'),
|
||||
ImportColumn::make('work_group4_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 4')
|
||||
->example('RMGCGABC1')
|
||||
->label('Work Group Center 4'),
|
||||
ImportColumn::make('work_group5_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 5')
|
||||
->example('RMGCGABC5')
|
||||
->label('Work Group Center 5'),
|
||||
ImportColumn::make('work_group6_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 6')
|
||||
->example('RMGCGABC6')
|
||||
->label('Work Group Center 6'),
|
||||
ImportColumn::make('work_group7_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 7')
|
||||
->example('RMGCGABC7')
|
||||
->label('Work Group Center 7'),
|
||||
ImportColumn::make('work_group8_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 8')
|
||||
->example('RMGCGABC8')
|
||||
->label('Work Group Center 8'),
|
||||
ImportColumn::make('work_group9_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 9')
|
||||
->example('RMGCGABC9')
|
||||
->label('Work Group Center 9'),
|
||||
ImportColumn::make('work_group10_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Group Center 10')
|
||||
->example('RMGCGABC10')
|
||||
->label('Work Group Center 10'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
@@ -47,34 +98,110 @@ class LineImporter extends Importer
|
||||
public function resolveRecord(): ?Line
|
||||
{
|
||||
$warnMsg = [];
|
||||
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
|
||||
throw new RowImportFailedException("Plant '{$this->data['plant']}' not found");
|
||||
}
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
$warnMsg[] = "Line name not found";
|
||||
|
||||
if (Str::length($this->data['name'] ?? '') <= 0) {
|
||||
throw new RowImportFailedException("Line name not found");
|
||||
}
|
||||
if (Str::length($this->data['type']) < 0) {
|
||||
$warnMsg[] = "Line type not found";
|
||||
|
||||
if (Str::length($this->data['type'] ?? '') <= 0) {
|
||||
throw new RowImportFailedException("Line type not found");
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
|
||||
$noOfOps = (int) ($this->data['no_of_operation'] ?? 0);
|
||||
|
||||
if (($noOfOps == null || $noOfOps == '' || !is_numeric($noOfOps)) && $noOfOps != 0) {
|
||||
throw new RowImportFailedException("'No of Operation' is required and must be a number $noOfOps");
|
||||
}
|
||||
|
||||
if ($noOfOps > 10)
|
||||
{
|
||||
throw new RowImportFailedException("Invalid 'No Of Operation' value: {$noOfOps}, maximum allowed is 10");
|
||||
}
|
||||
|
||||
// Validate required work groups
|
||||
$missingGroups = [];
|
||||
for ($i = 1; $i <= $noOfOps; $i++) {
|
||||
if (empty($this->data["work_group{$i}_id"])) {
|
||||
$missingGroups[] = "work_group{$i}_id";
|
||||
}
|
||||
}
|
||||
if (!empty($missingGroups)) {
|
||||
throw new RowImportFailedException(
|
||||
"Invalid data: Required work groups missing values in: " . implode(', ', $missingGroups)
|
||||
);
|
||||
}
|
||||
|
||||
// Ensure no extra work groups are filled
|
||||
$invalidGroups = [];
|
||||
for ($i = $noOfOps + 1; $i <= 10; $i++) {
|
||||
if (!empty($this->data["work_group{$i}_id"])) {
|
||||
$invalidGroups[] = "work_group{$i}_id";
|
||||
}
|
||||
}
|
||||
if (!empty($invalidGroups)) {
|
||||
throw new RowImportFailedException(
|
||||
"Invalid data: Only first {$noOfOps} work groups should be filled, but values found in: " . implode(', ', $invalidGroups)
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$workGroupName = $this->data["work_group{$i}_id"] ?? null;
|
||||
if (!$workGroupName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('name', $workGroupName)
|
||||
->where('plant_id', $plant->id)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
throw new RowImportFailedException("Work group '{$workGroupName}' not found in plant '{$this->data['plant']}'");
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plant->id)
|
||||
->where('name', '!=', $this->data['name'])
|
||||
->where("work_group{$i}_id", $workGroupRecord->id)
|
||||
->first();
|
||||
|
||||
if ($existsInLines) {
|
||||
$warnMsg[] = "Work group '{$workGroupName}' is already assigned to another line in plant '{$this->data['plant']}'";
|
||||
}
|
||||
|
||||
$this->data["work_group{$i}_id"] = $workGroupRecord->id;
|
||||
}
|
||||
|
||||
if (!empty($warnMsg))
|
||||
{
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return Line::updateOrCreate([
|
||||
|
||||
Line::updateOrCreate(
|
||||
[
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'type' => $this->data['type'],
|
||||
'group_work_center' => $this->data['group_work_center']
|
||||
'no_of_operation' => $noOfOps,
|
||||
'work_group1_id' => $this->data['work_group1_id'] ?? null,
|
||||
'work_group2_id' => $this->data['work_group2_id'] ?? null,
|
||||
'work_group3_id' => $this->data['work_group3_id'] ?? null,
|
||||
'work_group4_id' => $this->data['work_group4_id'] ?? null,
|
||||
'work_group5_id' => $this->data['work_group5_id'] ?? null,
|
||||
'work_group6_id' => $this->data['work_group6_id'] ?? null,
|
||||
'work_group7_id' => $this->data['work_group7_id'] ?? null,
|
||||
'work_group8_id' => $this->data['work_group8_id'] ?? null,
|
||||
'work_group9_id' => $this->data['work_group9_id'] ?? null,
|
||||
'work_group10_id' => $this->data['work_group10_id'] ?? null,
|
||||
]
|
||||
);
|
||||
// return Line::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
// return new Line();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -35,7 +35,7 @@ class LineStopImporter extends Importer
|
||||
public function resolveRecord(): ?LineStop
|
||||
{
|
||||
$warnMsg = [];
|
||||
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
|
||||
if (Str::length($this->data['code']) < 3 || !ctype_alnum($this->data['code'])) {
|
||||
$warnMsg[] = "Invalid line stop code found";
|
||||
}
|
||||
if (Str::length($this->data['reason']) < 5) {
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Imports;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
@@ -28,7 +29,15 @@ class MachineImporter extends Importer
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->example('RMGCE001')
|
||||
->label('Work Center'),
|
||||
->label('Work Center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('workGroupMaster')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Work Group Center')
|
||||
->example(['RMGCGABC'])
|
||||
->label('Work Group Center')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
@@ -53,26 +62,52 @@ class MachineImporter extends Importer
|
||||
$line = null;
|
||||
$machine = $this->data['name'];
|
||||
$workCenter = $this->data['work_center'];
|
||||
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
$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)
|
||||
$grpWrkCnr = $line->no_of_operation;
|
||||
if (!$grpWrkCnr || $grpWrkCnr < 1)//Str::length($grpWrkCnr) < 1)
|
||||
{
|
||||
$warnMsg[] = "Group work center line not found";
|
||||
$warnMsg[] = "Group work center line not found!";
|
||||
}
|
||||
else if (!$groupWorkCenter) {
|
||||
$warnMsg[] = "Group work center not found!";
|
||||
}
|
||||
else {
|
||||
$dupMachine = Machine::where('plant_id', $plant->id)->where('work_center', '!=', $workCenter)->where('name', $machine)->first();
|
||||
if ($dupMachine) {
|
||||
$warnMsg[] = "Duplicate machine name found!";
|
||||
}
|
||||
else {
|
||||
$isValidGroupWork = false;
|
||||
for ($i = 1; $i <= $line->no_of_operation; $i++) {
|
||||
$column = "work_group{$i}_id";
|
||||
if (!empty($line->$column)) {
|
||||
if ($line->$column == $groupWorkCenter->id) {
|
||||
$isValidGroupWork = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isValidGroupWork) {
|
||||
$warnMsg[] = "Group work center does not match with line!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$warnMsg[] = "Line not found";
|
||||
$warnMsg[] = "Line not found!";
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($machine) <= 0) {
|
||||
$warnMsg[] = "Machine name not found";
|
||||
$warnMsg[] = "Machine name not found!";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
@@ -81,12 +116,13 @@ class MachineImporter extends Importer
|
||||
|
||||
Machine::updateOrCreate(
|
||||
[
|
||||
'name' => $machine,
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id
|
||||
'work_center' => $workCenter
|
||||
],
|
||||
[
|
||||
'work_center' => $workCenter
|
||||
'line_id' => $line->id,
|
||||
'name' => $machine,
|
||||
'work_group_master_id' => $groupWorkCenter->id
|
||||
]
|
||||
);
|
||||
return null;
|
||||
|
||||
@@ -2,11 +2,17 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use DateTime;
|
||||
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 MotorTestingMasterImporter extends Importer
|
||||
{
|
||||
@@ -22,7 +28,14 @@ class MotorTestingMasterImporter extends Importer
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('subassembly_code')
|
||||
->requiredMapping()
|
||||
->exampleHeader('SubAssembly Code')
|
||||
->example(['123456'])
|
||||
->label('SubAssembly Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('isi_model')
|
||||
->requiredMapping()
|
||||
->boolean()
|
||||
->exampleHeader('ISI Model')
|
||||
->example(['Y','N','Y'])
|
||||
@@ -144,8 +157,8 @@ class MotorTestingMasterImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('leak_cur_limit')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Leakage Current Limit')
|
||||
->label('Leakage Current Limit')
|
||||
->exampleHeader('Leak Current Limit')
|
||||
->label('Leak Current Limit')
|
||||
->example(['50','50','50'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lock_cur_ll')
|
||||
@@ -199,9 +212,9 @@ class MotorTestingMasterImporter extends Importer
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I','Ransar Industries-I','Ransar Industries-I'])
|
||||
->example(['1000','1010','1020'])
|
||||
->label('Plant')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
@@ -220,12 +233,245 @@ class MotorTestingMasterImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?MotorTestingMaster
|
||||
{
|
||||
// return MotorTestingMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']);
|
||||
$iCode = trim($this->data['item']);
|
||||
$sCode = trim($this->data['subassembly_code']);
|
||||
$isiModel = (trim($this->data['isi_model']) == "1") ? true : false;
|
||||
$phase = trim($this->data['phase']);
|
||||
$kw = trim($this->data['kw']);
|
||||
$hp = trim($this->data['hp']);
|
||||
$volt = trim($this->data['volt']);
|
||||
$current = trim($this->data['current']);
|
||||
$rpm = trim($this->data['rpm']);
|
||||
$torque = trim($this->data['torque']);
|
||||
$frequency = trim($this->data['frequency']);
|
||||
$connection = trim($this->data['connection']);
|
||||
$insResType = trim($this->data['ins_res_type']);
|
||||
$insResLimit = trim($this->data['ins_res_limit']);
|
||||
$routineTestTime = trim($this->data['routine_test_time']);
|
||||
$resRyLl = trim($this->data['res_ry_ll']);
|
||||
$resRyUl = trim($this->data['res_ry_ul']);
|
||||
$resYbLl = trim($this->data['res_yb_ll']);
|
||||
$resYbUl = trim($this->data['res_yb_ul']);
|
||||
$resBrLl = trim($this->data['res_br_ll']);
|
||||
$resBrUl = trim($this->data['res_br_ul']);
|
||||
$lockVoltLimit = trim($this->data['lock_volt_limit']);
|
||||
$leakCurLimit = trim($this->data['leak_cur_limit']);
|
||||
$lockCurLl = trim($this->data['lock_cur_ll']);
|
||||
$lockCurUl = trim($this->data['lock_cur_ul']);
|
||||
$noloadCurLl = trim($this->data['noload_cur_ll']);
|
||||
$noloadCurUl = trim($this->data['noload_cur_ul']);
|
||||
$noloadPowLl = trim($this->data['noload_pow_ll']);
|
||||
$noloadPowUl = trim($this->data['noload_pow_ul']);
|
||||
$noloadSpdLl = trim($this->data['noload_spd_ll']);
|
||||
$noloadSpdUl = trim($this->data['noload_spd_ul']);
|
||||
$createdBy = trim($this->data['created_by']);
|
||||
$updatedBy = trim($this->data['updated_by']);
|
||||
|
||||
return new MotorTestingMaster();
|
||||
$plant = null;
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod))
|
||||
{
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else if (Str::length($iCode) < 6 || !ctype_alnum($iCode))
|
||||
{
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
else if (Str::length($sCode) < 6 || !ctype_alnum($sCode))
|
||||
{
|
||||
$warnMsg[] = "Invalid sub-assembly code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
$codeExist = Item::where('code', $iCode)->first();
|
||||
if ($plant)
|
||||
{
|
||||
$iCode = Item::where('code', $iCode)->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$plant)
|
||||
{
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else if (!$codeExist)
|
||||
{
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
else if (!$iCode)
|
||||
{
|
||||
$warnMsg[] = "Item code not found for choosed plant";
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (Str::length($isiModel) <= 0 || $isiModel == "0" || $isiModel == "1") {
|
||||
// $warnMsg[] = "Invalid ISI Model found";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $isiModel = ($isiModel == "1");
|
||||
// }
|
||||
if (Str::length($phase) <= 0 || ($phase != "Single" && $phase != "Three")) {//!is_string($phase) ||
|
||||
$warnMsg[] = "Invalid phase found";
|
||||
}
|
||||
if (Str::length($hp) <= 0 || !is_numeric($hp)) {
|
||||
$warnMsg[] = "Invalid HP found";
|
||||
}
|
||||
if (Str::length($kw) <= 0 || !is_numeric($kw)) {
|
||||
$warnMsg[] = "Invalid KW found";
|
||||
}
|
||||
if (Str::length($volt) <= 0 || !is_numeric($volt)) {
|
||||
$warnMsg[] = "Invalid volt found";
|
||||
}
|
||||
if (Str::length($current) <= 0 || !is_numeric($current)) {
|
||||
$warnMsg[] = "Invalid current found";
|
||||
}
|
||||
if (Str::length($rpm) <= 0 || !is_numeric($rpm)) {
|
||||
$warnMsg[] = "Invalid RPM found";
|
||||
}
|
||||
if (Str::length($torque) <= 0 || !is_numeric($torque)) {
|
||||
$warnMsg[] = "Invalid torque found";
|
||||
}
|
||||
if (Str::length($frequency) <= 0 || !is_numeric($frequency)) {
|
||||
$warnMsg[] = "Invalid frequency found";
|
||||
}
|
||||
if (Str::length($connection) <= 0 || ($connection != "Star-Delta" && $connection != "Star" && $connection != "Delta")) {
|
||||
$warnMsg[] = "Invalid connection found";
|
||||
}
|
||||
if (Str::length($insResLimit) <= 0 || !is_numeric($insResLimit)) {
|
||||
$warnMsg[] = "Invalid insulation resistance limit found";
|
||||
}
|
||||
if (Str::length($insResType) <= 0 || ($insResType != "O" && $insResType != "M" && $insResType != "G")) {
|
||||
$warnMsg[] = "Invalid insulation resistance type found";
|
||||
}
|
||||
if (Str::length($routineTestTime) <= 0 || !isValidTimeFormat($routineTestTime)) {
|
||||
$warnMsg[] = "Invalid routine test time found";
|
||||
}
|
||||
if (Str::length($resRyLl) <= 0 || !is_numeric($resRyLl)) {
|
||||
$warnMsg[] = "Invalid resistance RY lower limit found";
|
||||
}
|
||||
if (Str::length($resRyUl) <= 0 || !is_numeric($resRyUl)) {
|
||||
$warnMsg[] = "Invalid resistance RY upper limit found";
|
||||
}
|
||||
if (Str::length($resYbLl) <= 0 || !is_numeric($resYbLl)) {
|
||||
$warnMsg[] = "Invalid resistance YB lower limit found";
|
||||
}
|
||||
if (Str::length($resYbUl) <= 0 || !is_numeric($resYbUl)) {
|
||||
$warnMsg[] = "Invalid resistance YB upper limit found";
|
||||
}
|
||||
if (Str::length($resBrLl) <= 0 || !is_numeric($resBrLl)) {
|
||||
$warnMsg[] = "Invalid resistance BR lower limit found";
|
||||
}
|
||||
if (Str::length($resBrUl) <= 0 || !is_numeric($resBrUl)) {
|
||||
$warnMsg[] = "Invalid resistance BR upper limit found";
|
||||
}
|
||||
if (Str::length($lockVoltLimit) <= 0 || !is_numeric($lockVoltLimit)) {
|
||||
$warnMsg[] = "Invalid locked volt limit found";
|
||||
}
|
||||
if (Str::length($leakCurLimit) <= 0 || !is_numeric($leakCurLimit)) {
|
||||
$warnMsg[] = "Invalid leakage current limit found";
|
||||
}
|
||||
if (Str::length($lockCurLl) <= 0 || !is_numeric($lockCurLl)) {
|
||||
$warnMsg[] = "Invalid locked current lower limit found";
|
||||
}
|
||||
if (Str::length($lockCurUl) <= 0 || !is_numeric($lockCurUl)) {
|
||||
$warnMsg[] = "Invalid locked current upper limit found";
|
||||
}
|
||||
if (Str::length($noloadCurLl) <= 0 || !is_numeric($noloadCurLl)) {
|
||||
$warnMsg[] = "Invalid no load current lower limit found";
|
||||
}
|
||||
if (Str::length($noloadCurUl) <= 0 || !is_numeric($noloadCurUl)) {
|
||||
$warnMsg[] = "Invalid no load current upper limit found";
|
||||
}
|
||||
if (Str::length($noloadPowLl) <= 0 || !is_numeric($noloadPowLl)) {
|
||||
$warnMsg[] = "Invalid no load power lower limit found";
|
||||
}
|
||||
if (Str::length($noloadPowUl) <= 0 || !is_numeric($noloadPowUl)) {
|
||||
$warnMsg[] = "Invalid no load power upper limit found";
|
||||
}
|
||||
if (Str::length($noloadSpdLl) <= 0 || !is_numeric($noloadSpdLl)) {
|
||||
$warnMsg[] = "Invalid no load speed lower limit found";
|
||||
}
|
||||
if (Str::length($noloadSpdUl) <= 0 || !is_numeric($noloadSpdUl)) {
|
||||
$warnMsg[] = "Invalid no load speed upper limit found";
|
||||
}
|
||||
|
||||
$oldCode = MotorTestingMaster::where('item_id', $iCode->id)->where('plant_id', $plant->id)->first();
|
||||
|
||||
if ($oldCode) {
|
||||
$created = $oldCode->created_by ? User::where('name', $oldCode->created_by)->first() : null;
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found on update";
|
||||
}
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found on update";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
MotorTestingMaster::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'item_id' => $iCode->id
|
||||
],
|
||||
[
|
||||
'subassembly_code' => $sCode,
|
||||
'isi_model' => $isiModel,
|
||||
'phase' => $phase,
|
||||
'kw' => $kw,
|
||||
'hp' => $hp,
|
||||
'volt' => $volt,
|
||||
'current' => $current,
|
||||
'rpm' => $rpm,
|
||||
'torque' => $torque,
|
||||
'frequency' => $frequency,
|
||||
'connection' => $connection,
|
||||
'ins_res_limit' => $insResLimit,
|
||||
'ins_res_type' => $insResType,
|
||||
'routine_test_time' => $routineTestTime,
|
||||
'res_ry_ll' => $resRyLl,
|
||||
'res_ry_ul' => $resRyUl,
|
||||
'res_yb_ll' => $resYbLl,
|
||||
'res_yb_ul' => $resYbUl,
|
||||
'res_br_ll' => $resBrLl,
|
||||
'res_br_ul' => $resBrUl,
|
||||
'lock_volt_limit' => $lockVoltLimit,
|
||||
'leak_cur_limit' => $leakCurLimit,
|
||||
'lock_cur_ll' => $lockCurLl,
|
||||
'lock_cur_ul' => $lockCurUl,
|
||||
'noload_cur_ll' => $noloadCurLl,
|
||||
'noload_cur_ul' => $noloadCurUl,
|
||||
'noload_pow_ll' => $noloadPowLl,
|
||||
'noload_pow_ul' => $noloadPowUl,
|
||||
'noload_spd_ll' => $noloadSpdLl,
|
||||
'noload_spd_ul' => $noloadSpdUl,
|
||||
'created_by' => $created->name,
|
||||
'updated_by' => $updated->name,
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return MotorTestingMaster::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new MotorTestingMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
@@ -239,3 +485,13 @@ class MotorTestingMasterImporter extends Importer
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
||||
function isValidTimeFormat($time) {
|
||||
// If time starts with a single digit hour without leading zero, pad it
|
||||
if (preg_match('/^\d(:\d{2}:\d{2})$/', $time, $matches)) {
|
||||
$time = '0' . $time;
|
||||
}
|
||||
|
||||
$dateTime = DateTime::createFromFormat('H:i:s', $time);
|
||||
return $dateTime && $dateTime->format('H:i:s') === $time;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,21 @@ use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
|
||||
class PalletValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = PalletValidation::class;
|
||||
|
||||
// public static function canQueue(): bool
|
||||
// {
|
||||
// return true; // allows this importer to be queued
|
||||
// }
|
||||
|
||||
// public static function getChunkSize(): ?int
|
||||
// {
|
||||
// return 1000;
|
||||
// }
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -59,9 +59,9 @@ class ProductionQuantityImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->exampleHeader('Block')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->label('Block')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
|
||||
@@ -193,9 +193,9 @@ class QualityValidationImporter extends Importer
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
$uniqueCode = trim($this->data['sticker_master_id_code']);// stickerMaster.item
|
||||
$stickMaster = StickerMaster::select('id')->with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCode, $plant) {
|
||||
$query->where('code', $uniqueCode)->where('plant_id', $plant->id);
|
||||
})->value('id');
|
||||
->whereHas('item', function ($query) use ($uniqueCode, $plant) {
|
||||
$query->where('code', $uniqueCode)->where('plant_id', $plant->id);
|
||||
})->value('id');
|
||||
}
|
||||
|
||||
if (!$line) {
|
||||
@@ -281,11 +281,13 @@ class QualityValidationImporter extends Importer
|
||||
|
||||
QualityValidation::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'sticker_master_id' => $stickMaster,//->id
|
||||
'serial_number' => $this->data['serial_number']
|
||||
],
|
||||
[
|
||||
'line_id' => $line->id,
|
||||
'uom' => $this->data['uom'],
|
||||
'production_order' => $this->data['production_order'],
|
||||
'serial_number' => $this->data['serial_number'],
|
||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||
'serial_number_pump' => $this->data['serial_number_pump'],
|
||||
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
|
||||
|
||||
@@ -14,11 +14,11 @@ class TestingPanelReadingImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('item')
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
ImportColumn::make('motorTestingMaster.item.code')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
@@ -28,6 +28,9 @@ class TestingPanelReadingImporter extends Importer
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('winded_serial_number')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('before_fr_volt'),
|
||||
ImportColumn::make('before_fr_cur'),
|
||||
ImportColumn::make('before_fr_pow'),
|
||||
|
||||
114
app/Filament/Imports/UserImporter.php
Normal file
114
app/Filament/Imports/UserImporter.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
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 Spatie\Permission\Models\Role;
|
||||
use Str;
|
||||
|
||||
class UserImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Name')
|
||||
->example('RAW00001')
|
||||
->label('Name')
|
||||
->rules(['required']),//, 'max:255'
|
||||
ImportColumn::make('email')
|
||||
->requiredMapping()
|
||||
->exampleHeader('E-mail')
|
||||
->example('RAW00001@cripumps.com')
|
||||
->label('E-mail')
|
||||
->rules(['required', 'email']),//, 'max:255'
|
||||
ImportColumn::make('password')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Password')
|
||||
->example('RAW00001')
|
||||
->label('Password')
|
||||
->rules(['required']),//, 'max:255'
|
||||
ImportColumn::make('roles')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Roles')
|
||||
->example('Employee')
|
||||
->label('Roles')
|
||||
->rules(['nullable', 'string']), // Optional roles
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?User
|
||||
{
|
||||
$warnMsg = [];
|
||||
if (Str::length($this->data['name']) < 1) {
|
||||
$warnMsg[] = "User name not found!";
|
||||
}
|
||||
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
|
||||
if (Str::length($this->data['email']) < 5) {
|
||||
$warnMsg[] = "Invalid email found!";
|
||||
}
|
||||
if (Str::length($this->data['password']) < 3) {
|
||||
$warnMsg[] = "Invalid password found!";
|
||||
}
|
||||
// Validate roles if provided
|
||||
$roles = [];
|
||||
if (!empty($this->data['roles'])) {
|
||||
$roles = collect(explode(',', $this->data['roles']))
|
||||
->map(fn($role) => trim($role))
|
||||
->filter()
|
||||
->toArray();
|
||||
|
||||
foreach ($roles as $roleName) {
|
||||
if (!Role::where('name', $roleName)->exists()) {
|
||||
$warnMsg[] = "Role : '{$roleName}' does not exist!";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$warnMsg[] = "User roles not found!";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$user = User::updateOrCreate([
|
||||
'email' => $this->data['email'],
|
||||
],
|
||||
[
|
||||
'name' => $this->data['name'],
|
||||
'password' => $this->data['password'],
|
||||
]);
|
||||
|
||||
// Assign roles
|
||||
if (!empty($roles)) {
|
||||
$user->syncRoles($roles);
|
||||
}
|
||||
|
||||
return null;
|
||||
// return User::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
//return new User();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your user 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;
|
||||
}
|
||||
}
|
||||
154
app/Filament/Imports/WorkGroupMasterImporter.php
Normal file
154
app/Filament/Imports/WorkGroupMasterImporter.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use App\Models\WorkGroupMaster;
|
||||
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 WorkGroupMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = WorkGroupMaster::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('Name')
|
||||
->example('RMGCEABC')
|
||||
->label('Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('description')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Description')
|
||||
->example('Testing Model 1')
|
||||
->label('Description')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operation_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operation Number')
|
||||
->example('0020')
|
||||
->label('Operation Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function resolveRecord(): ?WorkGroupMaster
|
||||
{
|
||||
// return WorkGroupMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['name']) <= 0) { //|| !ctype_alnum($this->data['description'])
|
||||
$warnMsg[] = "Invalid name found";
|
||||
}
|
||||
|
||||
if (Str::length(trim($this->data['description'])) <= 0) {
|
||||
$warnMsg[] = "Invalid description found";
|
||||
}
|
||||
|
||||
$desc = trim($this->data['description']);
|
||||
|
||||
if (Str::length($desc) > 44) {
|
||||
$warnMsg[] = "Description should be less than 44 digits.";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['operation_number']) <= 0) {
|
||||
$warnMsg[] = "Invalid operation number found";
|
||||
}
|
||||
|
||||
if(!is_numeric($this->data['operation_number']))
|
||||
{
|
||||
$warnMsg[] = "Invalid operation number found must be numeric";
|
||||
}
|
||||
|
||||
$user = User::where('name', $this->data['created_by'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Check (plant_id, name)
|
||||
$existingByName = WorkGroupMaster::where('plant_id', $plant->id)
|
||||
->where('name', $this->data['name'])
|
||||
->first();
|
||||
|
||||
if ($existingByName) {
|
||||
throw new RowImportFailedException("Work group name already exists for this plant!");
|
||||
}
|
||||
|
||||
//Check (plant_id, operation_number)
|
||||
$existingByOpNum = WorkGroupMaster::where('plant_id', $plant->id)
|
||||
->where('operation_number', $this->data['operation_number'])
|
||||
->where('name', $this->data['name'])
|
||||
->first();
|
||||
|
||||
if ($existingByOpNum) {
|
||||
throw new RowImportFailedException("Operation number already exists for this plant!");
|
||||
}
|
||||
|
||||
//Check (plant_id)
|
||||
$existingByOperator = WorkGroupMaster::where('plant_id', $plant->id)
|
||||
->where('name', $this->data['name'])
|
||||
->first();
|
||||
|
||||
if ($existingByOperator) {
|
||||
throw new RowImportFailedException("Already work group name assigned to another plant!");
|
||||
}
|
||||
}
|
||||
|
||||
WorkGroupMaster::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'name' => $this->data['name'],
|
||||
'description' => $this->data['description'],
|
||||
'operation_number' => $this->data['operation_number'],
|
||||
'created_by' => $this->data['created_by'],
|
||||
]);
|
||||
|
||||
return null;
|
||||
|
||||
//return new WorkGroupMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your work group 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;
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,15 @@ class CreateAlertMailRule extends CreateRecord
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
|
||||
if ($data['is_active']) {
|
||||
$data['plant'] = 0;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateBlock extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BlockResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class CheckPointNameResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 14;
|
||||
protected static ?int $navigationSort = 15;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ class CheckPointTimeResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 15;
|
||||
protected static ?int $navigationSort = 16;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateCompany extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CompanyResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateConfiguration extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ConfigurationResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateDeviceMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DeviceMasterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
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,17 @@
|
||||
<?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;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
505
app/Filament/Resources/EquipmentMasterResource.php
Normal file
505
app/Filament/Resources/EquipmentMasterResource.php
Normal file
@@ -0,0 +1,505 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\EquipmentMasterExporter;
|
||||
use App\Filament\Imports\EquipmentMasterImporter;
|
||||
use App\Filament\Resources\EquipmentMasterResource\Pages;
|
||||
use App\Filament\Resources\EquipmentMasterResource\RelationManagers;
|
||||
use App\Models\EquipmentMaster;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
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\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Storage;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class EquipmentMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = EquipmentMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
//->relationship('machine', 'name')
|
||||
->label('Work Center')
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name'),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description'),
|
||||
Forms\Components\TextInput::make('make')
|
||||
->label('Make'),
|
||||
Forms\Components\TextInput::make('model')
|
||||
->label('Model'),
|
||||
Forms\Components\TextInput::make('equipment_number')
|
||||
->label('Equipment Number')
|
||||
->reactive()
|
||||
->rules(function (callable $get) {
|
||||
return [
|
||||
Rule::unique('equipment_masters', 'equipment_number')
|
||||
->where(function ($query) use ($get) {
|
||||
return $query->where('plant_id', $get('plant_id'));
|
||||
})
|
||||
->ignore($get('id')),
|
||||
];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if (! $state) {
|
||||
return;
|
||||
}
|
||||
|
||||
$model = EquipmentMaster::where('equipment_number', $state)->first();
|
||||
|
||||
if ($model?->attachment) {
|
||||
$set('attachment', $model->attachment);
|
||||
} else {
|
||||
$set('attachment', null);
|
||||
}
|
||||
}),
|
||||
//->afterStateUpdated(function ($state, callable $set) {
|
||||
// if (! $state) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $model = EquipmentMaster::where('equipment_number', $state)->first();
|
||||
|
||||
// if ($model?->attachment) {
|
||||
// $set('attachment', $model->attachment);
|
||||
// } else {
|
||||
// $set('attachment', null);
|
||||
// }
|
||||
// }),
|
||||
Forms\Components\TextInput::make('instrument_serial_number')
|
||||
->label('Instrument Serial Number'),
|
||||
// Forms\Components\DateTimePicker::make('calibrated_on')
|
||||
// ->label('Calibrated On')
|
||||
// ->required(),
|
||||
// Forms\Components\TextInput::make('frequency')
|
||||
// ->label('Frequency')
|
||||
// ->required()
|
||||
// ->numeric()
|
||||
// ->default(1),
|
||||
// Forms\Components\DateTimePicker::make('next_calibration_date')
|
||||
// ->label('Next Calibration Date')
|
||||
// ->required(),
|
||||
Forms\Components\DateTimePicker::make('calibrated_on')
|
||||
->label('Calibrated On')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$frequency = $get('frequency') ?? '1';
|
||||
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
|
||||
$set('next_calibration_date', $nextDate);
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
// $frequency = (int) $get('frequency');
|
||||
|
||||
// if ($state && $frequency != 0) {
|
||||
// $calibratedOn = $state instanceof Carbon ? $state : Carbon::parse($state);
|
||||
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
||||
// $set('next_calibration_date', $nextDate);
|
||||
// } else {
|
||||
// $set('next_calibration_date', null);
|
||||
// }
|
||||
// }),
|
||||
|
||||
Forms\Components\TextInput::make('frequency')
|
||||
->label('Frequency (days)')
|
||||
->required()
|
||||
->numeric()
|
||||
->minValue(1)
|
||||
->default(1)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$calibratedOn = $get('calibrated_on');
|
||||
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
|
||||
$set('next_calibration_date', $nextDate);
|
||||
}),
|
||||
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||
// $calibratedOn = $get('calibrated_on');
|
||||
// $frequency = (int) $state;
|
||||
|
||||
// if ($calibratedOn && $frequency !== 0) {
|
||||
// $calibratedOn = $calibratedOn instanceof Carbon ? $calibratedOn : Carbon::parse($calibratedOn);
|
||||
// $nextDate = $calibratedOn->copy()->addDays($frequency);
|
||||
// $set('next_calibration_date', $nextDate);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $set('next_calibration_date', null);
|
||||
// }
|
||||
// }),
|
||||
|
||||
Forms\Components\DateTimePicker::make('next_calibration_date')
|
||||
->label('Next Calibration Date')
|
||||
->readOnly()
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('calibrated_by')
|
||||
->label('Calibrated By'),
|
||||
Forms\Components\Textarea::make('calibration_certificate')
|
||||
->label('Calibration Certificate'),
|
||||
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
->storeFiles(false)
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->reactive(),
|
||||
|
||||
// Forms\Components\Actions::make([
|
||||
// Action::make('uploadNow')
|
||||
// ->label('Upload PDF Now')
|
||||
// ->action(function ($get, callable $set) {
|
||||
|
||||
// $uploadedFiles = $get('attachment');
|
||||
|
||||
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
// $uploaded = reset($uploadedFiles);
|
||||
|
||||
// if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
// $originalName = $uploaded->getClientOriginalName();
|
||||
// $storedPath = $uploaded->storeAs(
|
||||
// 'uploads/temp',
|
||||
// $originalName,
|
||||
// 'local'
|
||||
// );
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// }),
|
||||
// ]),
|
||||
// Forms\Components\Actions::make([
|
||||
// Action::make('downloadAttachment')
|
||||
// ->label('Download PDF')
|
||||
// ->action(function ($get) {
|
||||
// $uploadedFiles = $get('attachment');
|
||||
|
||||
// $equipmentNumber = $get('equipment_number');
|
||||
|
||||
// if (!$equipmentNumber) {
|
||||
// Notification::make()
|
||||
// ->title('No equipment number entered')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $files = Storage::disk('local')->files('uploads/temp');
|
||||
|
||||
// $fileToDownload = null;
|
||||
|
||||
// foreach ($files as $file) {
|
||||
// if (str_contains($file, $equipmentNumber)) {
|
||||
// $fileToDownload = $file;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!$fileToDownload) {
|
||||
// Notification::make()
|
||||
// ->title('PDF not found for this equipment')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||
// }),
|
||||
// ]),
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
->label('Upload PDF Now')
|
||||
// ->action(function ($get, callable $set) {
|
||||
// $uploadedFiles = $get('attachment');
|
||||
|
||||
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
// $uploaded = reset($uploadedFiles);
|
||||
|
||||
// if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
// $originalName = $uploaded->getClientOriginalName();
|
||||
// $storedPath = $uploaded->storeAs(
|
||||
// 'uploads/temp',
|
||||
// $originalName,
|
||||
// 'local'
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }),
|
||||
->action(function ($get, callable $set) {
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
$uploaded = reset($uploadedFiles);
|
||||
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
$originalName = $uploaded->getClientOriginalName();
|
||||
|
||||
$storedPath = $uploaded->storeAs(
|
||||
'uploads/temp',
|
||||
$originalName,
|
||||
'local'
|
||||
);
|
||||
|
||||
Notification::make()
|
||||
->title('PDF uploaded successfully')
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('No file selected to upload')
|
||||
->warning()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}),
|
||||
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download PDF')
|
||||
->action(function ($get) {
|
||||
$equipmentNumber = $get('equipment_number');
|
||||
|
||||
if (!$equipmentNumber) {
|
||||
Notification::make()
|
||||
->title('No equipment number entered')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$files = Storage::disk('local')->files('uploads/temp');
|
||||
|
||||
$fileToDownload = null;
|
||||
foreach ($files as $file) {
|
||||
if (str_contains($file, $equipmentNumber)) {
|
||||
$fileToDownload = $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fileToDownload) {
|
||||
Notification::make()
|
||||
->title('PDF not found for this equipment')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||
}),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Name')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('description')
|
||||
->label('Description')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('make')
|
||||
->label('Make')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('model')
|
||||
->label('Model')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('equipment_number')
|
||||
->label('Equipment Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('instrument_serial_number')
|
||||
->label('Instrument Serial Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('calibrated_on')
|
||||
->label('Calibrated On')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('frequency')
|
||||
->label('Frequency')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('next_calibration_date')
|
||||
->label('Next Calibration Date')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('calibrated_by')
|
||||
->label('Calibrated By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('calibration_certificate')
|
||||
->label('Calibration Certificate')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created Bys')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated 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(EquipmentMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import equipment master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(EquipmentMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export equipment master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListEquipmentMasters::route('/'),
|
||||
'create' => Pages\CreateEquipmentMaster::route('/create'),
|
||||
'view' => Pages\ViewEquipmentMaster::route('/{record}'),
|
||||
'edit' => Pages\EditEquipmentMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
|
||||
protected static function calculateNextCalibrationDate(?string $startDateTime, ?string $durationDays): ?string
|
||||
{
|
||||
if (!$startDateTime || !$durationDays) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$startDateTimeCarbon = Carbon::parse($startDateTime);
|
||||
$durationDays = str_replace(',', '.', $durationDays);
|
||||
|
||||
if(!is_numeric($durationDays))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$nextCalibrationDate = $startDateTimeCarbon->addDays(floatval($durationDays));
|
||||
return $nextCalibrationDate->format('Y-m-d H:i:s');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EquipmentMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EquipmentMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEquipmentMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EquipmentMasterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EquipmentMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EquipmentMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEquipmentMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = EquipmentMasterResource::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\EquipmentMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EquipmentMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEquipmentMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = EquipmentMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EquipmentMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EquipmentMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewEquipmentMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = EquipmentMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
339
app/Filament/Resources/GrMasterResource.php
Normal file
339
app/Filament/Resources/GrMasterResource.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\GrMasterExporter;
|
||||
use App\Filament\Imports\GrMasterImporter;
|
||||
use App\Filament\Resources\GrMasterResource\Pages;
|
||||
use App\Filament\Resources\GrMasterResource\RelationManagers;
|
||||
use App\Models\GrMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
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\Notifications\Notification;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Storage;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class GrMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = GrMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
//->relationship('item', 'id')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('gr_number')
|
||||
->label('GR Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('gr_masters', 'serial_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
->storeFiles(false)
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->reactive(),
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
->label('Upload PDF Now')
|
||||
->action(function ($get, callable $set) {
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
||||
{
|
||||
$uploaded = reset($uploadedFiles);
|
||||
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
$grNumber = $get('gr_number');
|
||||
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
||||
// $originalName = $uploaded->getClientOriginalName();
|
||||
// $path = 'uploads/GRNumber/' . $originalName;
|
||||
$finalFileName = $safeName . '.pdf';
|
||||
$finalPath = 'uploads/GRNumber/' . $finalFileName;
|
||||
|
||||
if (Storage::disk('local')->exists($finalPath)) {
|
||||
Notification::make()
|
||||
->title('Duplicate File')
|
||||
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
||||
->warning()
|
||||
->send();
|
||||
return; // Stop here
|
||||
}
|
||||
|
||||
$storedPath = $uploaded->storeAs(
|
||||
'uploads/GRNumber',
|
||||
$finalFileName,
|
||||
'local'
|
||||
);
|
||||
|
||||
|
||||
// $fullPath = storage_path('app/' . $storedPath);
|
||||
$fullPath = storage_path('app/private/' . $storedPath);
|
||||
$parser = new Parser();
|
||||
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||
$pdf = $parser->parseFile($fullPath);
|
||||
$text = $pdf->getText();
|
||||
|
||||
//dd($text);
|
||||
|
||||
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
$item1 = $matches[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('Item Code Not Found')
|
||||
->body('Could not find Item code in uploaded PDF.')
|
||||
->warning()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$processOrder = $get('gr_number');
|
||||
|
||||
$itemId = $get('item_id');
|
||||
|
||||
$plant = $get('plant_id');
|
||||
|
||||
$item = Item::find($itemId);
|
||||
|
||||
$plant = Plant::find($plant);
|
||||
|
||||
if ($item)
|
||||
{
|
||||
$itemCode = $item->code;
|
||||
}
|
||||
else
|
||||
{
|
||||
$itemCode = null;
|
||||
Notification::make()
|
||||
->title('Item Not Found')
|
||||
->body("Item not found in uploaded pdf.")
|
||||
->warning()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$storedPath = $uploaded->storeAs(
|
||||
'uploads/GRNumber',
|
||||
$finalFileName,
|
||||
'local'
|
||||
);
|
||||
|
||||
if($itemCode == $item1)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Item Code not matched')
|
||||
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('No file selected to upload')
|
||||
->warning()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}),
|
||||
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download PDF')
|
||||
->action(function ($get) {
|
||||
$equipmentNumber = $get('gr_number');
|
||||
|
||||
if (!$equipmentNumber) {
|
||||
Notification::make()
|
||||
->title('No GR Number entered')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$files = Storage::disk('local')->files('uploads/GRNumber');
|
||||
|
||||
$fileToDownload = null;
|
||||
foreach ($files as $file) {
|
||||
if (str_contains($file, $equipmentNumber)) {
|
||||
$fileToDownload = $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fileToDownload) {
|
||||
Notification::make()
|
||||
->title('PDF not found for this process order')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||
}),
|
||||
]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('gr_number')
|
||||
->label('GR Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->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(GrMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import gr master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(GrMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export gr master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListGrMasters::route('/'),
|
||||
'create' => Pages\CreateGrMaster::route('/create'),
|
||||
'view' => Pages\ViewGrMaster::route('/{record}'),
|
||||
'edit' => Pages\EditGrMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\GrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GrMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateGrMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = GrMasterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\GrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GrMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditGrMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = GrMasterResource::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\GrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GrMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListGrMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = GrMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\GrMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GrMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewGrMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = GrMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class GuardNameResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 13;
|
||||
protected static ?int $navigationSort = 14;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
||||
@@ -481,7 +481,6 @@ class InvoiceValidationResource extends Resource
|
||||
|
||||
$duplicateSerialCodes = array_unique($duplicateSerials);
|
||||
|
||||
|
||||
if (!empty($uniqueInvalidCodes)) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Codes')
|
||||
@@ -539,17 +538,17 @@ class InvoiceValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
})
|
||||
->get();
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
})
|
||||
->get();
|
||||
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
if (!empty($missingCodes))
|
||||
{
|
||||
@@ -615,7 +614,6 @@ class InvoiceValidationResource extends Resource
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import serial invoice');
|
||||
}),
|
||||
|
||||
Tables\Actions\Action::make('Import Invoice Material')
|
||||
->label('Import Material Invoice')
|
||||
->form([
|
||||
|
||||
@@ -61,6 +61,11 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
public function processInvoice($invoiceNumber)
|
||||
{
|
||||
$invoiceNumber = trim($invoiceNumber);
|
||||
@@ -106,6 +111,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -141,6 +147,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->warning()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
@@ -160,6 +167,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
// $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
||||
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
|
||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
@@ -186,6 +194,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -249,6 +258,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -264,6 +274,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -280,6 +291,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -296,6 +308,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -328,6 +341,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -358,6 +372,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -383,6 +398,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -448,6 +464,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
};
|
||||
|
||||
$showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
|
||||
@@ -693,6 +710,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->success()
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
Notification::make()
|
||||
->title("Start the scanning process!")
|
||||
->body("'$inserted' new material invoice records were inserted.")
|
||||
@@ -700,6 +718,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// ->success()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
@@ -737,6 +756,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||
@@ -766,6 +786,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -800,6 +821,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->warning()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
@@ -810,6 +832,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
//$fullPath = $disk->path($filePath);
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('playNotificationSound');
|
||||
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
|
||||
}
|
||||
else
|
||||
@@ -819,6 +842,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->info()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||
|
||||
if($updateStatus == '1')
|
||||
@@ -846,6 +870,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -917,6 +942,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -934,6 +960,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -966,6 +994,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -995,6 +1025,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1019,6 +1050,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1027,7 +1059,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$missPackCodes = $matchedItems
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->panel_box_code)) //filter invalid
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code)) //filter invalid
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
@@ -1043,6 +1075,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1060,6 +1093,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -1075,6 +1110,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1092,6 +1128,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -1171,6 +1209,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
@@ -1208,6 +1248,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
@@ -1236,6 +1277,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -1274,7 +1317,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -1293,7 +1336,9 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Extract filename without extension (e.g., "3RA0018732")
|
||||
@@ -1306,6 +1351,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1335,6 +1381,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -1439,6 +1487,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -1454,6 +1503,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1470,6 +1520,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1487,6 +1538,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -1518,6 +1571,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1548,7 +1602,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
@@ -1572,6 +1626,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1631,6 +1686,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
};
|
||||
|
||||
$showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
|
||||
@@ -1883,6 +1939,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1899,6 +1956,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1941,6 +1999,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1971,6 +2030,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -1995,6 +2055,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -2003,7 +2064,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
$missPackCodes = $matchedItems
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->panel_box_code))
|
||||
->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code))
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
@@ -2019,6 +2080,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -2035,6 +2097,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -2051,6 +2114,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -2067,6 +2131,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -2084,6 +2149,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -2128,6 +2194,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
// ->success()
|
||||
->seconds(1)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
// Update total quantity in the form
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
@@ -2166,6 +2233,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
|
||||
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||
@@ -2193,6 +2261,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
@@ -2256,6 +2325,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2280,6 +2350,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->warning()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2339,6 +2410,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2358,6 +2430,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2377,6 +2450,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2403,6 +2477,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2422,6 +2497,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2448,6 +2524,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2467,6 +2544,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2492,6 +2570,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(1)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2515,6 +2595,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2538,6 +2619,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2560,6 +2642,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2587,7 +2670,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2613,6 +2696,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2634,6 +2718,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2656,6 +2741,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->body('Scan valid Quantity Material QR code proceed!<br>Ex:123456|12345|12345678|1/1')
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2717,6 +2803,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -2746,6 +2833,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2785,6 +2874,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2830,6 +2921,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2873,6 +2966,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2906,12 +3001,14 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
if (!$record) {
|
||||
Notification::make()
|
||||
->title('Serial Number Not Found')
|
||||
->body("Serial '$serialNumber' not found in database for choosed plant.")
|
||||
->title('<b><span style="color:red;">Serial Number Not Found<br>Serial \''.$serialNumber.'\' not found in database for choosed plant.</span></b>')
|
||||
// ->body("Serial '$serialNumber' not found in database for choosed plant.")..........
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('play-warn-sound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2928,12 +3025,14 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
if (!$record) {
|
||||
Notification::make()
|
||||
->title('Unknown: Serial Number')
|
||||
->body("Serial '$serialNumber' not found in invoice.")
|
||||
->title('<b><span style="color:red;">Unknown: Serial Number<br>Serial \''.$serialNumber.'\' not found in invoice.</span></b>')
|
||||
// ->body("Serial '$serialNumber' not found in invoice.")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2960,6 +3059,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -2976,6 +3077,13 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$hasPumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null;
|
||||
$hasCapacitorQr = $record->stickerMasterRelation->panel_box_code ?? null;
|
||||
|
||||
if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
|
||||
{
|
||||
$hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null;
|
||||
$hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
|
||||
$hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null;
|
||||
}
|
||||
|
||||
$hadMotorQr = $record->motor_scanned_status ?? null;
|
||||
$hadPumpQr = $record->pump_scanned_status ?? null;
|
||||
$hadPumpSetQr = $record->scanned_status_set ?? null;
|
||||
@@ -2984,21 +3092,23 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid: Item Code')
|
||||
->body("Scanned 'Item Code' doesn't have valid package type to proceed!")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
->title('Invalid: Item Code')
|
||||
->body("Scanned 'Item Code' doesn't have valid package type to proceed!")
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity'=> $scanSQuan,
|
||||
]);
|
||||
return;
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'update_invoice' => false,
|
||||
'scanned_quantity'=> $scanSQuan,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($isMarkM) {
|
||||
@@ -3010,6 +3120,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -3030,6 +3142,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3092,6 +3206,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->success()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
@@ -3121,6 +3237,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3139,6 +3257,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->danger()
|
||||
->seconds(2)
|
||||
->send();
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -3203,6 +3322,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
@@ -3233,6 +3354,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3252,6 +3375,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3292,6 +3417,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3311,6 +3438,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playWarnSound');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
@@ -3374,6 +3503,8 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->seconds(2)
|
||||
->send();
|
||||
|
||||
$this->dispatch('playNotificationSound');
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
$directory = 'uploads/temp';
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateItem extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ItemResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Filament\Imports\LineImporter;
|
||||
use App\Filament\Resources\LineResource\Pages;
|
||||
use App\Filament\Resources\LineResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
@@ -175,12 +176,770 @@ 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(),
|
||||
|
||||
Forms\Components\TextInput::make('no_of_operation')
|
||||
->label('No of Operation')
|
||||
->required()
|
||||
->numeric()
|
||||
->reactive()
|
||||
->minValue(0)
|
||||
->maxValue(10)
|
||||
->placeholder('Scan the valid No Of Operatrion')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$partValidationColumns = [
|
||||
'work_group1_id', 'work_group2_id', 'work_group3_id', 'work_group4_id',
|
||||
'work_group5_id', 'work_group6_id', 'work_group7_id', 'work_group8_id',
|
||||
'work_group9_id', 'work_group10_id',
|
||||
];
|
||||
|
||||
foreach ($partValidationColumns as $column) {
|
||||
$set($column . '_visible', false);
|
||||
$set($column, null);
|
||||
}
|
||||
|
||||
if (is_numeric($state) && $state > 0) {
|
||||
for ($i = 1; $i <= (int) $state; $i++) {
|
||||
$set("work_group{$i}_id_visible", true);
|
||||
}
|
||||
}
|
||||
})
|
||||
->afterStateHydrated(function (callable $set, $state) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$set("work_group{$i}_id_visible", $state >= $i);
|
||||
}
|
||||
}),
|
||||
|
||||
Forms\Components\Hidden::make('work_group1_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group1_actual_id')
|
||||
->label('Work Group Center 1')
|
||||
->hidden(fn (callable $get) => !$get('work_group1_id_visible'))
|
||||
->default('')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup1) {
|
||||
$set('work_group1_actual_id', $record->workGroup1->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group1_id_error', null);
|
||||
$set('work_group1_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group1_id_error', null);
|
||||
$set('work_group1_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group1_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group1_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
// $existsInLines = Line::where(function ($query) use ($workGroupRecord) {
|
||||
// for ($i = 1; $i <= 10; $i++) {
|
||||
// $query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
// }
|
||||
// })->count();
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group1_actual_id', '');
|
||||
$set('work_group1_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group1_id_error', null);
|
||||
$set('work_group1_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group1_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group1_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group2_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group2_actual_id')
|
||||
->label('Work Group Center 2')
|
||||
->hidden(fn (callable $get) => !$get('work_group2_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup2) {
|
||||
$set('work_group2_actual_id', $record->workGroup2->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group2_id_error', null);
|
||||
$set('work_group2_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group2_id_error', null);
|
||||
$set('work_group2_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group2_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group2_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group2_actual_id', '');
|
||||
$set('work_group2_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group2_id_error', null);
|
||||
$set('work_group2_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group2_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group2_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group3_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group3_actual_id')
|
||||
->label('Work Group Center 3')
|
||||
->hidden(fn (callable $get) => !$get('work_group3_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup3) {
|
||||
$set('work_group3_actual_id', $record->workGroup3->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group3_id_error', null);
|
||||
$set('work_group3_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group3_id_error', null);
|
||||
$set('work_group3_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group3_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group3_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group3_actual_id', '');
|
||||
$set('work_group3_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group3_id_error', null);
|
||||
$set('work_group3_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group3_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group3_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group4_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group4_actual_id')
|
||||
->label('Work Group Center 4')
|
||||
->hidden(fn (callable $get) => !$get('work_group4_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup4) {
|
||||
$set('work_group4_actual_id', $record->workGroup4->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group4_id_error', null);
|
||||
$set('work_group4_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group4_id_error', null);
|
||||
$set('work_group4_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group4_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group4_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group4_actual_id', '');
|
||||
$set('work_group4_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group4_id_error', null);
|
||||
$set('work_group4_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group4_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group4_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group5_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group5_actual_id')
|
||||
->label('Work Group Center 5')
|
||||
->hidden(fn (callable $get) => !$get('work_group5_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup5) {
|
||||
$set('work_group5_actual_id', $record->workGroup5->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group5_id_error', null);
|
||||
$set('work_group5_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group5_id_error', null);
|
||||
$set('work_group5_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group5_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group5_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group5_actual_id', '');
|
||||
$set('work_group5_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group5_id_error', null);
|
||||
$set('work_group5_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group5_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group5_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group6_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group6_actual_id')
|
||||
->label('Work Group Center 6')
|
||||
->hidden(fn (callable $get) => !$get('work_group6_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup6) {
|
||||
$set('work_group6_actual_id', $record->workGroup6->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group6_id_error', null);
|
||||
$set('work_group6_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group6_id_error', null);
|
||||
$set('work_group6_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group6_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group6_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group6_actual_id', '');
|
||||
$set('work_group6_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group6_id_error', null);
|
||||
$set('work_group6_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group6_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group6_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group7_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group7_actual_id')
|
||||
->label('Work Group Center 7')
|
||||
->hidden(fn (callable $get) => !$get('work_group7_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup7) {
|
||||
$set('work_group7_actual_id', $record->workGroup7->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group7_id_error', null);
|
||||
$set('work_group7_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group7_id_error', null);
|
||||
$set('work_group7_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group7_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group7_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group7_actual_id', '');
|
||||
$set('work_group7_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group7_id_error', null);
|
||||
$set('work_group7_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group7_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group7_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group8_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group8_actual_id')
|
||||
->label('Work Group Center 8')
|
||||
->hidden(fn (callable $get) => !$get('work_group8_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup8) {
|
||||
$set('work_group8_actual_id', $record->workGroup8->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group8_id_error', null);
|
||||
$set('work_group8_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group8_id_error', null);
|
||||
$set('work_group8_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group8_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group8_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group8_actual_id', '');
|
||||
$set('work_group8_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group8_id_error', null);
|
||||
$set('work_group8_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group8_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group8_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group9_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group9_actual_id')
|
||||
->label('Work Group Center 9')
|
||||
->hidden(fn (callable $get) => !$get('work_group9_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup9) {
|
||||
$set('work_group9_actual_id', $record->workGroup9->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group9_id_error', null);
|
||||
$set('work_group9_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group9_id_error', null);
|
||||
$set('work_group9_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group9_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group9_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group9_actual_id', '');
|
||||
$set('work_group9_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group9_id_error', null);
|
||||
$set('work_group9_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group9_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group9_id_error'))
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Hidden::make('work_group10_id'),
|
||||
|
||||
Forms\Components\TextInput::make('work_group10_actual_id')
|
||||
->label('Work Group Center 10')
|
||||
->hidden(fn (callable $get) => !$get('work_group10_id_visible'))
|
||||
->default('')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateHydrated(function (callable $set, $record) {
|
||||
if ($record && $record->workGroup10) {
|
||||
$set('work_group10_actual_id', $record->workGroup10->name);
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
// $workGroup1Id = $get('work_group1_actual_id');
|
||||
$plantId = $get('plant_id');
|
||||
$lineName = $get('name');
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('work_group10_id_error', null);
|
||||
$set('work_group10_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('work_group10_id_error', null);
|
||||
$set('work_group10_id', null);
|
||||
|
||||
if (!$plantId) {
|
||||
$set('work_group10_id_error', 'Invalid plant name.');
|
||||
return;
|
||||
}
|
||||
|
||||
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
|
||||
->where('name', $state)
|
||||
->first();
|
||||
|
||||
if (!$workGroupRecord) {
|
||||
$set('work_group10_id_error', 'Work group does not exist for this plant in master.');
|
||||
return;
|
||||
}
|
||||
|
||||
$existsInLines = Line::where('plant_id', $plantId)
|
||||
->where('name', '!=', $lineName) // Exclude current line
|
||||
->where(function ($query) use ($workGroupRecord) {
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($existsInLines > 0) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->title('Work Group Already Assigned')
|
||||
->body("The work group '{$state}' is already assigned to a line.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('work_group10_actual_id', '');
|
||||
$set('work_group10_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('work_group10_id_error', null);
|
||||
$set('work_group10_id', $workGroupRecord->id);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('work_group10_id_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('work_group10_id_error'))
|
||||
->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(),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
@@ -217,8 +976,107 @@ class LineResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('group_work_center')
|
||||
->label('Group Work Center')
|
||||
Tables\Columns\TextColumn::make('no_of_operation')
|
||||
->label('No of Operation')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup1.name')
|
||||
->label('Work Group Center 1')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup1.operation_number')
|
||||
->label('Operation Number 1')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup2.name')
|
||||
->label('Work Group Center 2')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup2.operation_number')
|
||||
->label('Operation Number 2')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup3.name')
|
||||
->label('Work Group Center 3')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup3.operation_number')
|
||||
->label('Operation Number 3')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup4.name')
|
||||
->label('Work Group Center 4')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup4.operation_number')
|
||||
->label('Operation Number 4')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup5.name')
|
||||
->label('Work Group Center 5')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup5.operation_number')
|
||||
->label('Operation Number 5')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup6.name')
|
||||
->label('Work Group Center 6')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup6.operation_number')
|
||||
->label('Operation Number 6')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup7.name')
|
||||
->label('Work Group Center 7')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup7.operation_number')
|
||||
->label('Operation Number 7')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup8.name')
|
||||
->label('Work Group Center 8')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup8.operation_number')
|
||||
->label('Operation Number 8')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup9.name')
|
||||
->label('Work Group Center 9')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup9.operation_number')
|
||||
->label('Operation Number 9')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup10.name')
|
||||
->label('Work Group Center 10')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('workGroup10.operation_number')
|
||||
->label('Operation Number 10')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
@@ -5,8 +5,76 @@ namespace App\Filament\Resources\LineResource\Pages;
|
||||
use App\Filament\Resources\LineResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreateLine extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LineResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
protected function beforeCreate(): void
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
if (!empty($this->data['lPlantError'])) {
|
||||
$errors['lPlantError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['lNameError'])) {
|
||||
$errors['lNameError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['lTypeError'])) {
|
||||
$errors['lTypeError'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group1_id_error'])) {
|
||||
$errors['work_group1_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group2_id_error'])) {
|
||||
$errors['work_group2_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group3_id_error'])) {
|
||||
$errors['work_group1_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group4_id_error'])) {
|
||||
$errors['work_group4_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group5_id_error'])) {
|
||||
$errors['work_group5_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group6_id_error'])) {
|
||||
$errors['work_group6_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group7_id_error'])) {
|
||||
$errors['work_group7_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group8_id_error'])) {
|
||||
$errors['work_group8_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($this->data['work_group9_id_error'])) {
|
||||
$errors['work_group9_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
//..warranty
|
||||
if (!empty($this->data['work_group10_id_error'])) {
|
||||
$errors['work_group10_id_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateLineStop extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LineStopResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-locator-invoice-validation';
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $invoice_number;
|
||||
|
||||
public $pallet_number;
|
||||
|
||||
public $serial_number, $snoCount;
|
||||
@@ -29,8 +31,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
public $locator_number;
|
||||
|
||||
public array $matchedSerialNumbersForRemoval = [];
|
||||
|
||||
public bool $showRemoveSerialsModal = false;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
public function processinvoiceSNo()
|
||||
{
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateLocator extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LocatorResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Filament\Resources\MachineResource\Pages;
|
||||
use App\Filament\Resources\MachineResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
@@ -30,7 +31,7 @@ class MachineResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
protected static ?int $navigationSort = 12;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -49,6 +50,8 @@ class MachineResource extends Resource
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('mPlantError', 'Please select a plant first.');
|
||||
$set('line_id', null);
|
||||
$set('work_group_master_id', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -71,9 +74,7 @@ class MachineResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
return Line::where('plant_id', $get('plant_id'))->where('no_of_operation', '>', 0)->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Machine::latest()->first())->line_id;
|
||||
@@ -83,17 +84,18 @@ class MachineResource extends Resource
|
||||
$lineId = $get('line_id');
|
||||
if (!$lineId) {
|
||||
$set('mLineError', 'Please select a line first.');
|
||||
$set('work_group_master_id', null);
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// $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);
|
||||
}
|
||||
})
|
||||
@@ -102,19 +104,73 @@ class MachineResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('mLineError') ? $get('mLineError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('work_group_master_id')
|
||||
->label('Group Work Center')
|
||||
->relationship('workGroupMaster', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id') || !$get('line_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$line = Line::find($get('line_id'));
|
||||
$workGroupIds = [];
|
||||
for ($i = 1; $i <= $line->no_of_operation; $i++) {
|
||||
$column = "work_group{$i}_id";
|
||||
if (!empty($line->$column)) {
|
||||
$workGroupIds[] = $line->$column;
|
||||
}
|
||||
}
|
||||
|
||||
return WorkGroupMaster::where('plant_id', $get('plant_id'))->whereIn('id', $workGroupIds)->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Machine::latest()->first())->work_group_master_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
if (!$lineId) {
|
||||
$set('mGroupWorkError', 'Please select a line first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// $grpWrkCnr = Line::find($lineId)->group_work_center;
|
||||
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||
// {
|
||||
// $set('mGroupWorkError', 'Please select a group work center line.');
|
||||
// $set('line_id', null);
|
||||
// return;
|
||||
// }
|
||||
$set('mGroupWorkError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('mGroupWorkError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('mGroupWorkError') ? $get('mGroupWorkError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->placeholder('Scan the valid Machine Name')
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('machines', 'name')
|
||||
->where('line_id', $get('line_id'))
|
||||
//->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'),
|
||||
->placeholder('Scan the valid Work Center')
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('machines', 'work_center')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
@@ -135,21 +191,26 @@ class MachineResource extends Resource
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Name')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('workGroupMaster.name')
|
||||
->label('Work Group Center')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMachine extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MachineResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMfmMeter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmMeterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMfmParameter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmParameterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMfmReading extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MfmReadingResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateModuleList extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ModuleListResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,13 @@ use App\Filament\Resources\MotorTestingMasterResource\RelationManagers;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\Item;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -20,6 +25,7 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class MotorTestingMasterResource extends Resource
|
||||
@@ -28,9 +34,9 @@ class MotorTestingMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 12;
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -61,6 +67,11 @@ class MotorTestingMasterResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TimePicker::make('routine_test_time')
|
||||
->label('Routine Test Time')
|
||||
->default('00:40:00')
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
//->relationship('item', 'name')
|
||||
@@ -82,11 +93,39 @@ class MotorTestingMasterResource extends Resource
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TimePicker::make('routine_test_time')
|
||||
->label('Routine Test Time')
|
||||
->default('00:40:00')
|
||||
Forms\Components\TextInput::make('subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
->required()
|
||||
->reactive(),
|
||||
->placeholder('Scan the valid code')
|
||||
->reactive()
|
||||
->alphaNum()
|
||||
->minLength(6)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$code = $get('subassembly_code');
|
||||
if (!$code) {
|
||||
$set('iCodeError', 'Scan the valid Subassembly Code.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($code) < 6) {
|
||||
$set('iCodeError', 'Subassembly code must be at least 6 digits.');
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) {
|
||||
$set('code',null);
|
||||
$set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.');
|
||||
return;
|
||||
}
|
||||
$set('iCodeError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\Select::make('isi_model')
|
||||
->label('ISI Model')
|
||||
->options([
|
||||
@@ -102,11 +141,6 @@ class MotorTestingMasterResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
// if (!$plantId || !$lineId)
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
if ($plantId)
|
||||
{
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
@@ -283,26 +317,32 @@ class MotorTestingMasterResource extends Resource
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.category')
|
||||
->label('Category')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Model')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\IconColumn::make('isi_model')
|
||||
->label('ISI Model')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->boolean(),
|
||||
Tables\Columns\TextColumn::make('phase')
|
||||
@@ -332,6 +372,7 @@ class MotorTestingMasterResource extends Resource
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('connection')
|
||||
->label('Connection')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('ins_res_limit')
|
||||
->label('Insulation Resistance Limit')
|
||||
@@ -391,19 +432,25 @@ class MotorTestingMasterResource extends Resource
|
||||
->label('No Load Speed UL')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter(),
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter(),
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
@@ -412,7 +459,287 @@ class MotorTestingMasterResource 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) {
|
||||
$set('Item', null);
|
||||
$set('isi_type', null);
|
||||
$set('created_by', null);
|
||||
$set('updated_by', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$pId = $get('Plant');
|
||||
return Item::whereHas('motorTestingMasters', function ($query) use ($pId) {
|
||||
if ($pId) {
|
||||
$query->where('plant_id', $pId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
TextInput::make('description')
|
||||
->label('Description')
|
||||
->placeholder('Enter Description'),
|
||||
Radio::make('isi_type')
|
||||
->label('ISI Model ?')
|
||||
->boolean()
|
||||
->options([
|
||||
'All' => 'All',
|
||||
'Y' => 'Y',
|
||||
'N' => 'N'
|
||||
])
|
||||
->default(null)
|
||||
->inlineLabel(false)
|
||||
->inline(),
|
||||
Select::make('phase_type')
|
||||
->label('Select Phase')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if ($plantId)
|
||||
{
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'MOTOR_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Configuration::where('c_name', 'MOTOR_PHASE')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
|
||||
if ($state == 'Single' && $get('connection_type') == 'Star-Delta') {
|
||||
$set('phase_type', 'Three');
|
||||
}
|
||||
})
|
||||
->reactive(),
|
||||
Select::make('connection_type')
|
||||
->label('Select Connection')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId)
|
||||
{
|
||||
return Configuration::where('plant_id', $plantId)
|
||||
->where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Configuration::where('c_name', 'MOTOR_CONNECTION')
|
||||
->orderBy('created_at')
|
||||
->pluck('c_value', 'c_value')
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
if ($state == 'Star-Delta') {
|
||||
$set('phase_type', 'Three');
|
||||
}
|
||||
})
|
||||
->reactive(),
|
||||
Select::make('created_by')
|
||||
->label('Created By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId)
|
||||
{
|
||||
return MotorTestingMaster::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
}
|
||||
else
|
||||
{
|
||||
return MotorTestingMaster::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
Select::make('updated_by')
|
||||
->label('Updated By')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if (!$plantId)
|
||||
{
|
||||
return MotorTestingMaster::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
else
|
||||
{
|
||||
return MotorTestingMaster::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
|
||||
}
|
||||
})
|
||||
->searchable()
|
||||
->reactive(),
|
||||
DateTimePicker::make(name: 'updated_from')
|
||||
->label('Updated From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('updated_to')
|
||||
->label('Updated To')
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Item']) && empty($data['description']) && empty($data['isi_type']) && empty($data['phase_type']) && empty($data['connection_type']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {// || $data['isi_type'] == 'All')
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (!empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
}
|
||||
|
||||
if (!empty($data['Item'])) {
|
||||
$itemIds = Item::where('id', $data['Item'])
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
if (!empty($itemIds)) {
|
||||
$query->whereIn('item_id', $itemIds);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['description'])) {
|
||||
$pId = $data['Plant'] ?? null;
|
||||
$descIds = Item::where('description', 'like', '%' . $data['description'] . '%')->whereHas('motorTestingMasters', function ($query) use ($pId) {
|
||||
if ($pId) { $query->where('plant_id', $pId); }
|
||||
})->pluck('id')->toArray();
|
||||
|
||||
if (!empty($descIds)) {
|
||||
$query->whereIn('item_id', $descIds);
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['isi_type'] == 'Y') {
|
||||
$query->where('isi_model', true);
|
||||
}
|
||||
else if ($data['isi_type'] == 'N') {
|
||||
$query->where('isi_model', false);
|
||||
}
|
||||
|
||||
if (!empty($data['phase_type'])) {
|
||||
$query->where('phase', $data['phase_type']);
|
||||
}
|
||||
|
||||
if (!empty($data['connection_type'])) {
|
||||
$query->where('connection', $data['connection_type']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_by'])) {
|
||||
$query->where('created_by', $data['created_by']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (!empty($data['updated_by'])) {
|
||||
$query->where('updated_by', $data['updated_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['Item'])) {
|
||||
$itemCode = Item::find($data['Item'])->code ?? 'Unknown';
|
||||
$indicators[] = 'Item Codes: ' . $itemCode;
|
||||
}
|
||||
|
||||
if (!empty($data['description'])) {
|
||||
$indicators[] = 'Description: ' . $data['description'];
|
||||
}
|
||||
|
||||
if ($data['isi_type'] == 'Y') {
|
||||
$indicators[] = 'ISI Model: Yes';
|
||||
}
|
||||
else if ($data['isi_type'] == 'N') {
|
||||
$indicators[] = 'ISI Model: No';
|
||||
}
|
||||
|
||||
if (!empty($data['phase_type'])) {
|
||||
$indicators[] = 'Phase: ' . $data['phase_type'];
|
||||
}
|
||||
|
||||
if (!empty($data['connection_type'])) {
|
||||
$indicators[] = 'Connection: ' . $data['connection_type'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: ' . $data['created_by'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_from'])) {
|
||||
$indicators[] = 'Created From: ' . $data['created_from'];
|
||||
}
|
||||
|
||||
if (!empty($data['created_to'])) {
|
||||
$indicators[] = 'Created To: ' . $data['created_to'];
|
||||
}
|
||||
|
||||
if (!empty($data['updated_by'])) {
|
||||
$indicators[] = 'Updated By: ' . $data['updated_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(),
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateMotorTestingMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MotorTestingMasterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,17 +14,22 @@ use Illuminate\View\View;
|
||||
class CreatePalletValidation extends CreateRecord
|
||||
{
|
||||
public $plantId;
|
||||
|
||||
public $pallet_number;
|
||||
|
||||
public $palletNo;
|
||||
|
||||
public $pendingPallet;
|
||||
|
||||
public $snoCount = 0;
|
||||
|
||||
public $pallet_number_locked = false;
|
||||
|
||||
public $serial_number;
|
||||
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-pallet-validation';
|
||||
protected static string $resource = PalletValidationResource::class;
|
||||
|
||||
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-pallet-validation';
|
||||
|
||||
protected static string $resource = PalletValidationResource::class;
|
||||
|
||||
protected $listeners = [
|
||||
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
|
||||
@@ -32,6 +37,10 @@ class CreatePalletValidation extends CreateRecord
|
||||
|
||||
public ?array $data = null;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
public function processPalletSNo()
|
||||
{
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreatePlant extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PlantResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
360
app/Filament/Resources/ProcessOrderResource.php
Normal file
360
app/Filament/Resources/ProcessOrderResource.php
Normal file
@@ -0,0 +1,360 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
use App\Filament\Resources\ProcessOrderResource\RelationManagers;
|
||||
use App\Models\ProcessOrder;
|
||||
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 Storage;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
use Smalot\PdfParser\Parser;
|
||||
|
||||
class ProcessOrderResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ProcessOrder::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Process Order';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('item', 'id')
|
||||
// ->required(),
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
// dd($plantId);
|
||||
|
||||
if ($plantId && $itemId) {
|
||||
// Get the item code using item_id
|
||||
$itemCode = \App\Models\Item::where('id', $itemId)->value('code');
|
||||
|
||||
if ($itemCode) {
|
||||
// Now get the item description using plant_id + code
|
||||
$item = \App\Models\Item::where('plant_id', $plantId)
|
||||
->where('code', $itemCode)
|
||||
->first();
|
||||
|
||||
$set('item_description', $item?->description);
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
}
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->reactive(),
|
||||
// ->readOnly(true),
|
||||
Forms\Components\TextInput::make('process_order')
|
||||
->label('Process Order')
|
||||
->required(),
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
->label('PDF Upload')
|
||||
->acceptedFileTypes(['application/pdf'])
|
||||
->storeFiles(false)
|
||||
->disk('local')
|
||||
->directory('uploads/temp')
|
||||
->preserveFilenames()
|
||||
->reactive(),
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
->label('Upload PDF Now')
|
||||
->action(function ($get, callable $set) {
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
||||
{
|
||||
$uploaded = reset($uploadedFiles);
|
||||
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
$originalName = $uploaded->getClientOriginalName();
|
||||
$path = 'uploads/ProcessOrder/' . $originalName;
|
||||
|
||||
// Check if file already exists
|
||||
if (Storage::disk('local')->exists($path)) {
|
||||
Notification::make()
|
||||
->title('Duplicate File')
|
||||
->body("The file '{$originalName}' already exists in uploads/ProcessOrder.")
|
||||
->warning()
|
||||
->send();
|
||||
return; // Stop here
|
||||
}
|
||||
|
||||
$storedPath = $uploaded->storeAs(
|
||||
'uploads/ProcessOrder',
|
||||
$originalName,
|
||||
'local'
|
||||
);
|
||||
|
||||
// $fullPath = storage_path('app/' . $storedPath);
|
||||
$fullPath = storage_path('app/' . $storedPath);
|
||||
|
||||
// Parse PDF using smalot/pdfparser
|
||||
$parser = new Parser();
|
||||
$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||
$text = $pdf->getText();
|
||||
|
||||
|
||||
// if (preg_match('/Batch ID:\s*(\d+)\s*--/i', $text, $matches))
|
||||
// {
|
||||
// $batchId = $matches[1];
|
||||
// }
|
||||
if (preg_match('/Batch ID:\s*(\d+)(?:\s*--)?/i', $text, $matches)) {
|
||||
$batchId = $matches[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$batchId = null;
|
||||
}
|
||||
|
||||
// Get the value of process_order field
|
||||
$processOrder = $get('process_order');
|
||||
|
||||
if ($batchId != $processOrder) {
|
||||
Notification::make()
|
||||
->title('Mismatch')
|
||||
->body("Batch ID ($batchId) does not match Process Order ($processOrder)")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($batchId == $processOrder)
|
||||
{
|
||||
// If batch matches, store the PDF permanently
|
||||
$storedPath = $uploaded->storeAs(
|
||||
'uploads/ProcessOrder',
|
||||
$originalName,
|
||||
'local'
|
||||
);
|
||||
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Batch ID matches Process Order: $batchId. PDF uploaded successfully.")
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title('No file selected to upload')
|
||||
->warning()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}),
|
||||
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download PDF')
|
||||
->action(function ($get) {
|
||||
$equipmentNumber = $get('process_order');
|
||||
|
||||
if (!$equipmentNumber) {
|
||||
Notification::make()
|
||||
->title('No process order entered')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$files = Storage::disk('local')->files('uploads/ProcessOrder');
|
||||
|
||||
$fileToDownload = null;
|
||||
foreach ($files as $file) {
|
||||
if (str_contains($file, $equipmentNumber)) {
|
||||
$fileToDownload = $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fileToDownload) {
|
||||
Notification::make()
|
||||
->title('PDF not found for this process order')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||
}),
|
||||
|
||||
// Action::make('removeAttachment')
|
||||
// ->label('Remove PDF')
|
||||
// ->action(function ($get) {
|
||||
// $equipmentNumber = $get('process_order');
|
||||
|
||||
// if (!$equipmentNumber) {
|
||||
// Notification::make()
|
||||
// ->title('No process order entered')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Get all files from uploads/temp
|
||||
// $files = Storage::disk('local')->files('uploads/ProcessOrder');
|
||||
|
||||
// $fileToDelete = null;
|
||||
// foreach ($files as $file) {
|
||||
// if (str_contains($file, $equipmentNumber)) {
|
||||
// $fileToDelete = $file;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!$fileToDelete) {
|
||||
// Notification::make()
|
||||
// ->title('PDF not found for this process order')
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // Delete the matched file
|
||||
// Storage::disk('local')->delete($fileToDelete);
|
||||
|
||||
// Notification::make()
|
||||
// ->title('PDF removed successfully')
|
||||
// ->body("File for process order {$equipmentNumber} has been deleted.")
|
||||
// ->success()
|
||||
// ->send();
|
||||
// }),
|
||||
]),
|
||||
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Description')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListProcessOrders::route('/'),
|
||||
'create' => Pages\CreateProcessOrder::route('/create'),
|
||||
'view' => Pages\ViewProcessOrder::route('/{record}'),
|
||||
'edit' => Pages\EditProcessOrder::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProcessOrder extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProcessOrder extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::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\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListProcessOrders extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProcessOrder extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2093,10 +2093,52 @@ class QualityValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
// if ($state == $expectedValue)
|
||||
// {
|
||||
// $set('part_validation5_error', null);
|
||||
// }
|
||||
// else if (strpos($state, '/') != false) {
|
||||
// $parts = explode('/', $state);
|
||||
// if (count($parts) >= 2) {
|
||||
// $segmentToValidate = $parts[1];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $segmentToValidate = null;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $set('part_validation5_error', "Invalid input for part validation 5.");
|
||||
// $set('part_validation5', null);
|
||||
// return;
|
||||
// }
|
||||
if ($state == $expectedValue)
|
||||
{
|
||||
$set('part_validation5_error', null);
|
||||
}
|
||||
else if (strpos($state, '/') != false)
|
||||
{
|
||||
$parts = explode('/', $state);
|
||||
if (count($parts) >= 2)
|
||||
{
|
||||
$segmentToValidate = $parts[1];
|
||||
if ($segmentToValidate == $expectedValue) {
|
||||
$set('part_validation5_error', null);
|
||||
$set('part_validation5', $segmentToValidate);
|
||||
} else {
|
||||
$set('part_validation5_error', "Invalid input for part validation 5.");
|
||||
$set('part_validation5', null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('part_validation5_error', "Invalid input format for part validation 5.");
|
||||
$set('part_validation5', null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('part_validation5_error', "Invalid input for part validation 5.");
|
||||
@@ -2141,6 +2183,7 @@ class QualityValidationResource extends Resource
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('production_order')
|
||||
@@ -2368,7 +2411,6 @@ class QualityValidationResource extends Resource
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
@@ -2417,6 +2459,8 @@ class QualityValidationResource extends Resource
|
||||
$query->whereIn('sticker_master_id', $stickerMasterIds);
|
||||
}
|
||||
}
|
||||
|
||||
//$query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
@@ -21,6 +21,11 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
|
||||
|
||||
protected static string $resource = ReworkLocatorInvoiceValidationResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
|
||||
public function processInvoiceRework($invoiceNo)
|
||||
{
|
||||
$plantId = $this->form->getState()['plant'];
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateShift extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ShiftResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\StickerMasterExporter;
|
||||
use App\Filament\Imports\ShiftImporter;
|
||||
//use App\Filament\Imports\ShiftImporter;
|
||||
use App\Filament\Imports\StickerMasterImporter;
|
||||
use App\Filament\Resources\StickerMasterResource\Pages;
|
||||
use App\Filament\Resources\StickerMasterResource\RelationManagers;
|
||||
//use App\Filament\Resources\StickerMasterResource\RelationManagers;
|
||||
use App\Models\StickerMaster;
|
||||
use Closure;
|
||||
//use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
@@ -18,6 +18,7 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
// use Illuminate\Validation\Rule;
|
||||
@@ -35,383 +36,401 @@ class StickerMasterResource extends Resource
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->default(function () {
|
||||
return optional(StickerMaster::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
|
||||
->afterStateUpdated(fn (callable $set) =>
|
||||
$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) &
|
||||
$set('pack_slip_motor', false) &
|
||||
$set('pack_slip_pump', false) &
|
||||
$set('pack_slip_pumpset', false) &
|
||||
$set('name_plate_motor', false) &
|
||||
$set('name_plate_pump', false) &
|
||||
$set('name_plate_pumpset', false) &
|
||||
$set('tube_sticker_motor', false) &
|
||||
$set('tube_sticker_pump', false) &
|
||||
$set('tube_sticker_pumpset', false) &
|
||||
$set('warranty_card', false)
|
||||
)
|
||||
->required(),
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->default(function () {
|
||||
return optional(StickerMaster::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
|
||||
->afterStateUpdated(fn (callable $set) =>
|
||||
$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) &
|
||||
$set('pack_slip_motor', false) &
|
||||
$set('pack_slip_pump', false) &
|
||||
$set('pack_slip_pumpset', false) &
|
||||
$set('name_plate_motor', false) &
|
||||
$set('name_plate_pump', false) &
|
||||
$set('name_plate_pumpset', false) &
|
||||
$set('tube_sticker_motor', false) &
|
||||
$set('tube_sticker_pump', false) &
|
||||
$set('tube_sticker_pumpset', false) &
|
||||
$set('warranty_card', false)
|
||||
)
|
||||
->required(),
|
||||
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return \App\Models\Item::where('plant_id', $get('plant_id'))
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
})
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('items', 'code')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id')); // Ignore current record during updates
|
||||
// })
|
||||
->required()
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->live(debounce: 500) // Enable live updates
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
return \App\Models\Item::where('plant_id', $get('plant_id'))
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
})
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('items', 'code')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id')); // Ignore current record during updates
|
||||
// })
|
||||
->required()
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->live(debounce: 500) // Enable live updates
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
//If plant_id is changed or empty, reset everything
|
||||
if (blank($plantId)) {
|
||||
$set('item_id', null);
|
||||
$set('item_error', null);
|
||||
$set('item_description', null);
|
||||
return;
|
||||
}
|
||||
|
||||
//If plant_id is changed or empty, reset everything
|
||||
if (blank($plantId)) {
|
||||
$set('item_id', null);
|
||||
$set('item_error', null);
|
||||
$set('item_description', null);
|
||||
return;
|
||||
}
|
||||
if (blank($itemId)) {
|
||||
$set('item_error', null);
|
||||
$set('item_description', null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blank($itemId)) {
|
||||
$set('item_error', null);
|
||||
$set('item_description', null);
|
||||
return;
|
||||
}
|
||||
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
|
||||
if (!$availableItems) {
|
||||
$set('item_error', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
|
||||
if (!$availableItems) {
|
||||
$set('item_error', null);
|
||||
return;
|
||||
}
|
||||
// Ensure `item_id` is not cleared
|
||||
if (!$plantId || !$itemId) {
|
||||
$set('item_description', null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure `item_id` is not cleared
|
||||
if (!$plantId || !$itemId) {
|
||||
$set('item_description', null);
|
||||
return;
|
||||
}
|
||||
// Check if item exists for the selected plant
|
||||
$item = \App\Models\Item::where('plant_id', $plantId)
|
||||
->where('id', $itemId)
|
||||
->first();
|
||||
|
||||
// Check if item exists for the selected plant
|
||||
$item = \App\Models\Item::where('plant_id', $plantId)
|
||||
->where('id', $itemId)
|
||||
->first();
|
||||
if ($item) {
|
||||
$set('item_description', $item->description);
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
}
|
||||
|
||||
if ($item) {
|
||||
$set('item_description', $item->description);
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
}
|
||||
$duplicateSticker = StickerMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->exists();
|
||||
if(!$get('id'))
|
||||
{
|
||||
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('item_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('item_error') ? $get('item_error') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
$duplicateSticker = StickerMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $itemId)
|
||||
->exists();
|
||||
if(!$get('id'))
|
||||
{
|
||||
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('item_error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('item_error') ? $get('item_error') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
|
||||
if ($itemId) {
|
||||
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
|
||||
if ($item) {
|
||||
$set('item_description', $item);
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
}
|
||||
} else {
|
||||
$set('item_description', null);
|
||||
}
|
||||
}
|
||||
})
|
||||
->reactive()
|
||||
->readOnly(true),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation1')
|
||||
->label('Part Validation 1')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->reactive()
|
||||
->readOnly(true),
|
||||
Forms\Components\TextInput::make('part_validation2')
|
||||
->label('Part Validation 2')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation1')
|
||||
->nullable(),
|
||||
Forms\Components\TextInput::make('part_validation3')
|
||||
->label('Part Validation 3')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation2')
|
||||
->nullable(),
|
||||
Forms\Components\TextInput::make('part_validation4')
|
||||
->label('Part Validation 4')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation3')
|
||||
->nullable(),
|
||||
Forms\Components\TextInput::make('part_validation5')
|
||||
->label('Part Validation 5 (Capacitor QR)')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation4')
|
||||
->nullable(),
|
||||
Forms\Components\TextInput::make('laser_part_validation1')
|
||||
->label('Laser Part Validation 1')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation5')
|
||||
->nullable(),
|
||||
Forms\Components\TextInput::make('laser_part_validation2')
|
||||
->label('Laser Part Validation 2')
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation1')
|
||||
->nullable(),
|
||||
Forms\Components\TextInput::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->readOnly(fn (callable $get) => $get('material_type'))
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation2')
|
||||
->nullable(),
|
||||
Forms\Components\TextInput::make('load_rate')
|
||||
->label('Load Rate')
|
||||
->default(0)
|
||||
->required()
|
||||
->disabled(function ($get) {
|
||||
return $get('material_type');
|
||||
})
|
||||
->integer(),
|
||||
|
||||
Forms\Components\TextInput::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->readOnly(fn (callable $get) => $get('material_type'))
|
||||
->nullable(),
|
||||
Forms\Components\Select::make('material_type')
|
||||
->label('Material Type')
|
||||
->options([
|
||||
'1' => 'Individual',
|
||||
'2' => 'Bundle',
|
||||
'3' => 'Quantity',
|
||||
])
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
|
||||
Forms\Components\TextInput::make('load_rate')
|
||||
->label('Load Rate')
|
||||
->default(0)
|
||||
->disabled(function ($get) {
|
||||
return $get('material_type');
|
||||
})
|
||||
->integer()
|
||||
->nullable(),
|
||||
if ($state)
|
||||
{
|
||||
$set('panel_box_code', null);
|
||||
$set('load_rate', 0);
|
||||
}
|
||||
|
||||
if ($state !== "2")
|
||||
{
|
||||
$set('bundle_quantity', null);
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
//$plantId = $get('plant_id');
|
||||
})
|
||||
->nullable(),
|
||||
|
||||
Forms\Components\Select::make('material_type')
|
||||
->label('Material Type')
|
||||
->options([
|
||||
'1' => 'Individual',
|
||||
'2' => 'Bundle',
|
||||
'3' => 'Quantity',
|
||||
])
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
Forms\Components\TextInput::make('bundle_quantity')
|
||||
->label('Bundle Quantity')
|
||||
->integer()
|
||||
->readOnly(fn (callable $get) => $get('material_type') !== "2")
|
||||
->nullable()
|
||||
->minValue(2)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if($get('material_type') !== "2")
|
||||
{
|
||||
$set('bundle_quantity', null);
|
||||
}
|
||||
else if ($get('bundle_quantity') < 2)
|
||||
{
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
}),
|
||||
|
||||
if ($state)
|
||||
{
|
||||
$set('panel_box_code', null);
|
||||
$set('load_rate', 0);
|
||||
}
|
||||
Forms\Components\Checkbox::make('serial_number_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('serial_number_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('serial_number_pumpset'))
|
||||
{
|
||||
$set('serial_number_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
|
||||
|
||||
if ($state !== "2")
|
||||
{
|
||||
$set('bundle_quantity', null);
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
//$plantId = $get('plant_id');
|
||||
})
|
||||
->nullable(),
|
||||
Forms\Components\Checkbox::make('serial_number_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('serial_number_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('serial_number_pumpset'))
|
||||
{
|
||||
$set('serial_number_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\TextInput::make('bundle_quantity')
|
||||
->label('Bundle Quantity')
|
||||
->integer()
|
||||
->readOnly(fn (callable $get) => $get('material_type') !== "2")
|
||||
->nullable()
|
||||
->minValue(2)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if($get('material_type') !== "2")
|
||||
{
|
||||
$set('bundle_quantity', null);
|
||||
}
|
||||
else if ($get('bundle_quantity') < 2)
|
||||
{
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
}),
|
||||
Forms\Components\Checkbox::make('serial_number_pumpset')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('serial_number_motor') || $get('serial_number_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('serial_number_pumpset'))
|
||||
{
|
||||
$set('serial_number_motor', false);
|
||||
$set('serial_number_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('serial_number_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('serial_number_pumpset'))
|
||||
{
|
||||
$set('serial_number_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('pack_slip_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('pack_slip_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('pack_slip_pumpset'))
|
||||
{
|
||||
$set('pack_slip_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('serial_number_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('serial_number_pumpset'))
|
||||
{
|
||||
$set('serial_number_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('pack_slip_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('pack_slip_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('pack_slip_pumpset'))
|
||||
{
|
||||
$set('pack_slip_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_pumpset')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('serial_number_motor') || $get('serial_number_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('serial_number_pumpset'))
|
||||
{
|
||||
$set('serial_number_motor', false);
|
||||
$set('serial_number_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('pack_slip_pumpset')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('pack_slip_motor') || $get('pack_slip_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('pack_slip_pumpset'))
|
||||
{
|
||||
$set('pack_slip_motor', false);
|
||||
$set('pack_slip_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('pack_slip_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('pack_slip_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('pack_slip_pumpset'))
|
||||
{
|
||||
$set('pack_slip_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('name_plate_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('name_plate_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('name_plate_pumpset'))
|
||||
{
|
||||
$set('name_plate_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('pack_slip_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('pack_slip_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('pack_slip_pumpset'))
|
||||
{
|
||||
$set('pack_slip_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('name_plate_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('name_plate_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('name_plate_pumpset'))
|
||||
{
|
||||
$set('name_plate_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('pack_slip_pumpset')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('pack_slip_motor') || $get('pack_slip_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('pack_slip_pumpset'))
|
||||
{
|
||||
$set('pack_slip_motor', false);
|
||||
$set('pack_slip_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('name_plate_pumpset')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('name_plate_motor') || $get('name_plate_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('name_plate_pumpset'))
|
||||
{
|
||||
$set('name_plate_motor', false);
|
||||
$set('name_plate_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('name_plate_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('name_plate_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('name_plate_pumpset'))
|
||||
{
|
||||
$set('name_plate_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('tube_sticker_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('tube_sticker_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('tube_sticker_pumpset'))
|
||||
{
|
||||
$set('tube_sticker_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('name_plate_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('name_plate_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('name_plate_pumpset'))
|
||||
{
|
||||
$set('name_plate_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('tube_sticker_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('tube_sticker_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('tube_sticker_pumpset'))
|
||||
{
|
||||
$set('tube_sticker_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('name_plate_pumpset')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('name_plate_motor') || $get('name_plate_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('name_plate_pumpset'))
|
||||
{
|
||||
$set('name_plate_motor', false);
|
||||
$set('name_plate_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('tube_sticker_pumpset')
|
||||
->nullable()
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('tube_sticker_motor') || $get('tube_sticker_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('tube_sticker_pumpset'))
|
||||
{
|
||||
$set('tube_sticker_motor', false);
|
||||
$set('tube_sticker_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
|
||||
|
||||
Forms\Components\Checkbox::make('tube_sticker_motor')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('tube_sticker_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('tube_sticker_pumpset'))
|
||||
{
|
||||
$set('tube_sticker_motor', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
Forms\Components\Checkbox::make('warranty_card')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('tube_sticker_pump')
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('tube_sticker_pumpset');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('tube_sticker_pumpset'))
|
||||
{
|
||||
$set('tube_sticker_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Checkbox::make('tube_sticker_pumpset')
|
||||
->nullable()
|
||||
->reactive()
|
||||
->disabled(function ($get) {
|
||||
return $get('tube_sticker_motor') || $get('tube_sticker_pump');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set,callable $get) {
|
||||
if ($get('tube_sticker_pumpset'))
|
||||
{
|
||||
$set('tube_sticker_motor', false);
|
||||
$set('tube_sticker_pump', false);
|
||||
}
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
|
||||
|
||||
Forms\Components\Checkbox::make('warranty_card')
|
||||
->nullable()
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
|
||||
]);
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
@@ -424,13 +443,13 @@ class StickerMasterResource extends Resource
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
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;
|
||||
}),
|
||||
->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()
|
||||
|
||||
@@ -21,4 +21,9 @@ class CreateStickerMaster extends CreateRecord
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
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;
|
||||
@@ -15,6 +17,9 @@ 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
|
||||
{
|
||||
@@ -109,6 +114,18 @@ class TempLiveReadingResource extends Resource
|
||||
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
|
||||
|
||||
@@ -14,4 +14,9 @@ class CreateTempLiveReading extends CreateRecord
|
||||
{
|
||||
return 'Create Live Readings';
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,12 @@ use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||
use App\Filament\Exports\TestingPanelReadingExporter;
|
||||
use App\Filament\Imports\TestingPanelReadingImporter;
|
||||
use App\Filament\Resources\TestingPanelReadingResource\Pages;
|
||||
use App\Filament\Resources\TestingPanelReadingResource\RelationManagers;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\TestingPanelReading;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -42,6 +39,8 @@ class TestingPanelReadingResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Testing Panel';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -155,6 +154,8 @@ class TestingPanelReadingResource extends Resource
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('winded_serial_number')
|
||||
->label('Winded Serial Number'),
|
||||
Forms\Components\TextInput::make('before_fr_volt')
|
||||
->label('Before FR Volt'),
|
||||
Forms\Components\TextInput::make('before_fr_cur')
|
||||
@@ -285,6 +286,10 @@ class TestingPanelReadingResource extends Resource
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('winded_serial_number')
|
||||
->label('Winded Serial Number')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.kw')
|
||||
->label('KW')
|
||||
->alignCenter(),
|
||||
@@ -797,274 +802,150 @@ class TestingPanelReadingResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
BulkAction::make('export_pdf')
|
||||
->label('Export Readings PDF')
|
||||
->action(function ($records)
|
||||
{
|
||||
//$records->load('item');
|
||||
$records->load('motorTestingMaster.item');
|
||||
$plantId = $records->first()?->plant_id;
|
||||
|
||||
$plant = $plantId ? Plant::find($plantId) : null;
|
||||
|
||||
// Check if all records are Star-Delta type
|
||||
$isAllStarDelta = $records->every(function ($record) {
|
||||
return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
});
|
||||
// $hasStarDelta = $records->contains(function ($record) {
|
||||
// return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
// });
|
||||
|
||||
|
||||
//dd($isAllStarDelta);
|
||||
if(!$isAllStarDelta)
|
||||
->label('Export Readings PDF')
|
||||
->action(function ($records)
|
||||
{
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
return [
|
||||
// 'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
//$records->load('item');
|
||||
$records->load('motorTestingMaster.item');
|
||||
$plantId = $records->first()?->plant_id;
|
||||
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
$plant = $plantId ? Plant::find($plantId) : null;
|
||||
|
||||
// BEFORE FREE RUN
|
||||
'Voltage_Before' => $record['before_fr_volt'] ?? '',
|
||||
'Current_Before' => $record['before_fr_cur'] ?? '',
|
||||
'Power_Before' => $record['before_fr_pow'] ?? '',
|
||||
'Resistance_RY' => $record['before_fr_res_ry'] ?? '',
|
||||
'Resistance_YB' => $record['before_fr_res_yb'] ?? '',
|
||||
'Resistance_BR' => $record['before_fr_res_br'] ?? '',
|
||||
'Insulation_Resistance' => $record['before_fr_ir'] ?? '',
|
||||
'Frequency_Before' => $record['before_fr_freq'] ?? '',
|
||||
'Speed_Before' => $record['before_fr_speed'] ?? '',
|
||||
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot' => $record['after_fr_ir_hot'] ?? '',
|
||||
'IR_Cool' => $record['after_fr_ir_cool'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Batch_Number' => $record['batch_number'] ?? '',
|
||||
'Batch_Count' => $record['batch_count'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
'Tested_By' => $record['tested_by'] ?? '',
|
||||
];
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
return [
|
||||
//'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
|
||||
// BEFORE FREE RUN
|
||||
'Voltage_Before' => $record['before_fr_volt'] ?? '',
|
||||
'Current_Before' => $record['before_fr_cur'] ?? '',
|
||||
'Power_Before' => $record['before_fr_pow'] ?? '',
|
||||
'Resistance_RY' => $record['before_fr_res_ry'] ?? '',
|
||||
'Resistance_YB' => $record['before_fr_res_yb'] ?? '',
|
||||
'Resistance_BR' => $record['before_fr_res_br'] ?? '',
|
||||
'Insulation_Resistance_R' => $record['before_fr_ir_r'] ?? '',
|
||||
'Insulation_Resistance_Y' => $record['before_fr_ir_y'] ?? '',
|
||||
'Insulation_Resistance_B' => $record['before_fr_ir_b'] ?? '',
|
||||
'Frequency_Before' => $record['before_fr_freq'] ?? '',
|
||||
'Speed_Before' => $record['before_fr_speed'] ?? '',
|
||||
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot_R' => $record['after_fr_ir_hot_r'] ?? '',
|
||||
'IR_Hot_Y' => $record['after_fr_ir_hot_y'] ?? '',
|
||||
'IR_Hot_B' => $record['after_fr_ir_hot_b'] ?? '',
|
||||
'IR_Cool_R' => $record['after_fr_ir_cool_r'] ?? '',
|
||||
'IR_Cool_Y' => $record['after_fr_ir_cool_y'] ?? '',
|
||||
'IR_Cool_B' => $record['after_fr_ir_cool_b'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Batch_Number' => $record['batch_number'] ?? '',
|
||||
'Batch_Count' => $record['batch_count'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
'Tested_By' => $record['tested_by'] ?? '',
|
||||
];
|
||||
// Check if all records are Star-Delta type
|
||||
$isAllStarDelta = $records->every(function ($record) {
|
||||
return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
});
|
||||
}
|
||||
|
||||
$view = $isAllStarDelta ? 'exports.export-three-phase-pdf' : 'exports.testingpanel-pdf';
|
||||
// $hasStarDelta = $records->contains(function ($record) {
|
||||
// return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
// });
|
||||
|
||||
|
||||
$pdf = Pdf::loadView($view, [
|
||||
'records' => $mappedData,
|
||||
'plant' => $plant,
|
||||
]);
|
||||
|
||||
// $pdf = Pdf::loadView('exports.testingpanel-pdf',[
|
||||
// // ['records' => $mappedData]
|
||||
// 'records' => $mappedData,
|
||||
// 'plant' => $plant,
|
||||
|
||||
// ]);
|
||||
|
||||
return response()->streamDownload(
|
||||
fn () => print($pdf->stream()),
|
||||
'TestingPanelReading.pdf'
|
||||
);
|
||||
|
||||
})
|
||||
->icon('heroicon-o-document-arrow-down'),
|
||||
BulkAction::make('export_isi_pdf')
|
||||
->label('Export ISI Readings PDF')
|
||||
->action(function ($records)
|
||||
{
|
||||
$records->load('motorTestingMaster.item');
|
||||
$plantId = $records->first()?->plant_id;
|
||||
|
||||
$plant = $plantId ? Plant::find($plantId) : null;
|
||||
|
||||
$isAllStarDelta = $records->every(function ($record) {
|
||||
return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
});
|
||||
// $hasStarDelta = $records->contains(function ($record) {
|
||||
// return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
// });
|
||||
|
||||
//dd($isAllStarDelta);
|
||||
if(!$isAllStarDelta)
|
||||
{
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
//dd($isAllStarDelta);
|
||||
if(!$isAllStarDelta)
|
||||
{
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
return [
|
||||
// 'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
// 'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot' => $record['after_fr_ir_hot'] ?? '',
|
||||
'IR_Cool' => $record['after_fr_ir_cool'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
// BEFORE FREE RUN
|
||||
'Voltage_Before' => $record['before_fr_volt'] ?? '',
|
||||
'Current_Before' => $record['before_fr_cur'] ?? '',
|
||||
'Power_Before' => $record['before_fr_pow'] ?? '',
|
||||
'Resistance_RY' => $record['before_fr_res_ry'] ?? '',
|
||||
'Resistance_YB' => $record['before_fr_res_yb'] ?? '',
|
||||
'Resistance_BR' => $record['before_fr_res_br'] ?? '',
|
||||
'Insulation_Resistance' => $record['before_fr_ir'] ?? '',
|
||||
'Frequency_Before' => $record['before_fr_freq'] ?? '',
|
||||
'Speed_Before' => $record['before_fr_speed'] ?? '',
|
||||
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot' => $record['after_fr_ir_hot'] ?? '',
|
||||
'IR_Cool' => $record['after_fr_ir_cool'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
];
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Batch_Number' => $record['batch_number'] ?? '',
|
||||
'Batch_Count' => $record['batch_count'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
'Tested_By' => $record['tested_by'] ?? '',
|
||||
];
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
return [
|
||||
// 'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
//'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot_R' => $record['after_fr_ir_hot_r'] ?? '',
|
||||
'IR_Hot_Y' => $record['after_fr_ir_hot_y'] ?? '',
|
||||
'IR_Hot_B' => $record['after_fr_ir_hot_b'] ?? '',
|
||||
'IR_Cool_R' => $record['after_fr_ir_cool_r'] ?? '',
|
||||
'IR_Cool_Y' => $record['after_fr_ir_cool_y'] ?? '',
|
||||
'IR_Cool_B' => $record['after_fr_ir_cool_b'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
// BEFORE FREE RUN
|
||||
'Voltage_Before' => $record['before_fr_volt'] ?? '',
|
||||
'Current_Before' => $record['before_fr_cur'] ?? '',
|
||||
'Power_Before' => $record['before_fr_pow'] ?? '',
|
||||
'Resistance_RY' => $record['before_fr_res_ry'] ?? '',
|
||||
'Resistance_YB' => $record['before_fr_res_yb'] ?? '',
|
||||
'Resistance_BR' => $record['before_fr_res_br'] ?? '',
|
||||
'Insulation_Resistance_R' => $record['before_fr_ir_r'] ?? '',
|
||||
'Insulation_Resistance_Y' => $record['before_fr_ir_y'] ?? '',
|
||||
'Insulation_Resistance_B' => $record['before_fr_ir_b'] ?? '',
|
||||
'Frequency_Before' => $record['before_fr_freq'] ?? '',
|
||||
'Speed_Before' => $record['before_fr_speed'] ?? '',
|
||||
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot_R' => $record['after_fr_ir_hot_r'] ?? '',
|
||||
'IR_Hot_Y' => $record['after_fr_ir_hot_y'] ?? '',
|
||||
'IR_Hot_B' => $record['after_fr_ir_hot_b'] ?? '',
|
||||
'IR_Cool_R' => $record['after_fr_ir_cool_r'] ?? '',
|
||||
'IR_Cool_Y' => $record['after_fr_ir_cool_y'] ?? '',
|
||||
'IR_Cool_B' => $record['after_fr_ir_cool_b'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
];
|
||||
});
|
||||
}
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Batch_Number' => $record['batch_number'] ?? '',
|
||||
'Batch_Count' => $record['batch_count'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
'Tested_By' => $record['tested_by'] ?? '',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$view = $isAllStarDelta ? 'exports.export-three-phase-pdf' : 'exports.testingpanel-pdf';
|
||||
|
||||
$view = $isAllStarDelta ? 'exports.export-isi-three-phase-pdf' : 'exports.export-isi-pdf';
|
||||
|
||||
$pdf = Pdf::loadView($view, [
|
||||
'records' => $mappedData,
|
||||
'plant' => $plant,
|
||||
]);
|
||||
|
||||
// $pdf = Pdf::loadView('exports.export-isi-pdf',[
|
||||
// $pdf = Pdf::loadView('exports.testingpanel-pdf',[
|
||||
// // ['records' => $mappedData]
|
||||
// 'records' => $mappedData,
|
||||
// 'plant' => $plant,
|
||||
@@ -1076,9 +957,132 @@ class TestingPanelReadingResource extends Resource
|
||||
'TestingPanelReading.pdf'
|
||||
);
|
||||
|
||||
})
|
||||
->icon('heroicon-o-document-arrow-down'),
|
||||
})
|
||||
->icon('heroicon-o-document-arrow-down'),
|
||||
BulkAction::make('export_isi_pdf')
|
||||
->label('Export ISI Readings PDF')
|
||||
->action(function ($records)
|
||||
{
|
||||
$records->load('motorTestingMaster.item');
|
||||
$plantId = $records->first()?->plant_id;
|
||||
|
||||
$plant = $plantId ? Plant::find($plantId) : null;
|
||||
|
||||
$isAllStarDelta = $records->every(function ($record) {
|
||||
return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
});
|
||||
// $hasStarDelta = $records->contains(function ($record) {
|
||||
// return $record->motorTestingMaster?->connection === 'Star-Delta';
|
||||
// });
|
||||
|
||||
//dd($isAllStarDelta);
|
||||
if(!$isAllStarDelta)
|
||||
{
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
return [
|
||||
// 'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot' => $record['after_fr_ir_hot'] ?? '',
|
||||
'IR_Cool' => $record['after_fr_ir_cool'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
];
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$mappedData = collect($records)->map(function ($record) {
|
||||
return [
|
||||
// 'Date' => $record['created_at'] ?? '',
|
||||
'Date' =>date('Y-m-d', strtotime($record['created_at'] ?? '')),
|
||||
'Output' => $record['output'] ?? '',
|
||||
'Motor SNo' => $record['serial_number'] ?? '',
|
||||
'Item Code' => $record->motorTestingMaster->item->code ?? '',
|
||||
'Motor Type' => $record->motorTestingMaster->item->description ?? '',
|
||||
|
||||
'kw' => $record->motorTestingMaster->kw ?? '',
|
||||
'hp' => $record->motorTestingMaster->hp ?? '',
|
||||
'phase' => $record->motorTestingMaster->phase ?? '',
|
||||
'isi_model' => $record->motorTestingMaster->isi_model ?? '',
|
||||
|
||||
// AFTER FREE RUN
|
||||
'Voltage_After' => $record['after_fr_vol'] ?? '',
|
||||
'Current_After' => $record['after_fr_cur'] ?? '',
|
||||
'Power_After' => $record['after_fr_pow'] ?? '',
|
||||
'IR_Hot_R' => $record['after_fr_ir_hot_r'] ?? '',
|
||||
'IR_Hot_Y' => $record['after_fr_ir_hot_y'] ?? '',
|
||||
'IR_Hot_B' => $record['after_fr_ir_hot_b'] ?? '',
|
||||
'IR_Cool_R' => $record['after_fr_ir_cool_r'] ?? '',
|
||||
'IR_Cool_Y' => $record['after_fr_ir_cool_y'] ?? '',
|
||||
'IR_Cool_B' => $record['after_fr_ir_cool_b'] ?? '',
|
||||
'Leakage_Current' => $record['after_fr_leak_cur'] ?? '',
|
||||
'Frequency_After' => $record['after_fr_freq'] ?? '',
|
||||
'Speed_After' => $record['after_fr_speed'] ?? '',
|
||||
|
||||
// LOCKED ROTOR TEST
|
||||
'Voltage_Locked' => $record['locked_rt_volt'] ?? '',
|
||||
'Current_Locked' => $record['locked_rt_cur'] ?? '',
|
||||
'Power_Locked' => $record['locked_rt_pow'] ?? '',
|
||||
|
||||
// Last 8 columns
|
||||
'No_Load_Pickup_Voltage' => $record['no_load_pickup_volt'] ?? '',
|
||||
'Room_Temp' => $record['room_temperature'] ?? '',
|
||||
'High_Voltage_Test' => $record['hv_test'] ?? '',
|
||||
'Result' => $record['result'] ?? '',
|
||||
'Remark' => $record['remark'] ?? '',
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$view = $isAllStarDelta ? 'exports.export-isi-three-phase-pdf' : 'exports.export-isi-pdf';
|
||||
|
||||
$pdf = Pdf::loadView($view, [
|
||||
'records' => $mappedData,
|
||||
'plant' => $plant,
|
||||
]);
|
||||
|
||||
// $pdf = Pdf::loadView('exports.export-isi-pdf',[
|
||||
// // ['records' => $mappedData]
|
||||
// 'records' => $mappedData,
|
||||
// 'plant' => $plant,
|
||||
|
||||
// ]);
|
||||
|
||||
return response()->streamDownload(
|
||||
fn () => print($pdf->stream()),
|
||||
'TestingPanelReading.pdf'
|
||||
);
|
||||
|
||||
})
|
||||
->icon('heroicon-o-document-arrow-down'),
|
||||
]),
|
||||
|
||||
])
|
||||
|
||||
@@ -2,13 +2,18 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\UserExporter;
|
||||
use App\Filament\Imports\UserImporter;
|
||||
use App\Filament\Resources\UserResource\Pages;
|
||||
use App\Filament\Resources\UserResource\RelationManagers;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -80,6 +85,7 @@ class UserResource extends Resource
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
@@ -91,18 +97,23 @@ class UserResource extends Resource
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('User Name')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->label('Email')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('email_verified_at')
|
||||
->label('Email Verified At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('roles.name')
|
||||
->label('Roles')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
@@ -134,6 +145,18 @@ class UserResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(UserImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import user');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(UserExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export user');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
|
||||
206
app/Filament/Resources/WorkGroupMasterResource.php
Normal file
206
app/Filament/Resources/WorkGroupMasterResource.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\WorkGroupMasterExporter;
|
||||
use App\Filament\Imports\WorkGroupMasterImporter;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||
use App\Filament\Resources\WorkGroupMasterResource\RelationManagers;
|
||||
use App\Models\Line;
|
||||
use App\Models\WorkGroupMaster;
|
||||
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\Facades\Filament;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class WorkGroupMasterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = WorkGroupMaster::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
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()
|
||||
->columnSpan(1)
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
$set('name', null);
|
||||
$set('description', null);
|
||||
$set('operation_number', null);
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->numeric()
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('work_group_masters', 'operation_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->reactive()
|
||||
->columnSpan(['default' => 1, 'sm' => 3]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(['default' => 1, 'sm' => 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()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('description')
|
||||
->label('Description')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('operation_number')
|
||||
->label('Operation Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->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(WorkGroupMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import work group master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(WorkGroupMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export work group master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListWorkGroupMasters::route('/'),
|
||||
'create' => Pages\CreateWorkGroupMaster::route('/create'),
|
||||
'view' => Pages\ViewWorkGroupMaster::route('/{record}'),
|
||||
'edit' => Pages\EditWorkGroupMaster::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\WorkGroupMasterResource;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateWorkGroupMaster extends CreateRecord
|
||||
{
|
||||
protected static string $resource = WorkGroupMasterResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\WorkGroupMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditWorkGroupMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = WorkGroupMasterResource::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\WorkGroupMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\WorkGroupMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListWorkGroupMasters extends ListRecords
|
||||
{
|
||||
protected static string $resource = WorkGroupMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\WorkGroupMasterResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewWorkGroupMaster extends ViewRecord
|
||||
{
|
||||
protected static string $resource = WorkGroupMasterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
143
app/Http/Controllers/EquipmentMasterController.php
Normal file
143
app/Http/Controllers/EquipmentMasterController.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\EquipmentMaster;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EquipmentMasterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function equipmentMasterData(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
|
||||
$workCenter = $request->header('work-center');
|
||||
|
||||
if (!$plantCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
else if (!$workCenter) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work Center value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (!$plant)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code '{$plantCode}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->first();
|
||||
|
||||
$machinePlant = Machine::where('work_center', $workCenter)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (!$machine)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "work center '{$workCenter}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (!$machinePlant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center '{$workCenter}' not found for the plant code '{$plant->code}'!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$machineId = $machine->id;
|
||||
|
||||
$machineExists = EquipmentMaster::where('plant_id', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->first();
|
||||
|
||||
if (!$machineExists) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center '{$machine->work_center}' not found for the plant code '{$plant->code}' in Equipment Master!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$equipments = EquipmentMaster::where('plant_id', $plant->id)
|
||||
->where('machine_id', $machineId)
|
||||
->get([
|
||||
// 'name',
|
||||
'make',
|
||||
'model',
|
||||
'equipment_number',
|
||||
'calibrated_on',
|
||||
'next_calibration_date',
|
||||
'calibrated_by',
|
||||
]);
|
||||
|
||||
|
||||
return response()->json([
|
||||
'equipments' => $equipments
|
||||
], 200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -41,11 +41,11 @@ class MachineController extends Controller
|
||||
], 403);
|
||||
}
|
||||
|
||||
$machines = Machine::with('plant')->with('line')->orderBy('plant_id')->get();
|
||||
$machines = Machine::with('plant')->with('workGroupMaster')->orderBy('plant_id')->get();
|
||||
$machinesData = $machines->map(function($machine) {
|
||||
return [
|
||||
'plant_code' => $machine->plant ? (String)$machine->plant->code : "",
|
||||
'group_work_center' => $machine->line->group_work_center ?? "",
|
||||
'group_work_center' => $machine->workGroupMaster ? (String)$machine->workGroupMaster->name : "",
|
||||
'work_center' => $machine->work_center ?? "",
|
||||
];
|
||||
});
|
||||
|
||||
232
app/Http/Controllers/PdfController.php
Normal file
232
app/Http/Controllers/PdfController.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\GrMaster;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Str;
|
||||
|
||||
class PdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function getPdf(Request $request)
|
||||
{
|
||||
// Validate input
|
||||
// $request->validate([
|
||||
// 'filename' => 'required|string',
|
||||
// ]);
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$filename = $request->header('process-order');
|
||||
|
||||
if (!$filename)
|
||||
{
|
||||
return response()->json(['error' => 'Missing file-name header'], 400);
|
||||
}
|
||||
|
||||
$filename = basename($filename);
|
||||
|
||||
// Ensure the file has .pdf extension
|
||||
if (!str_ends_with(strtolower($filename), '.pdf')) {
|
||||
$filename .= '.pdf';
|
||||
}
|
||||
|
||||
$filePath = "uploads/ProcessOrder/" . $filename;
|
||||
|
||||
if (!Storage::disk('local')->exists($filePath)) {
|
||||
return response()->json(['error' => 'File not found'], 404);
|
||||
}
|
||||
|
||||
$file = Storage::disk('local')->get($filePath);
|
||||
$mimeType = Storage::disk('local')->mimeType($filePath);
|
||||
|
||||
return Response::make($file, 200, [
|
||||
'Content-Type' => $mimeType,
|
||||
'Content-Disposition' => 'inline; filename="' . $filename . '"',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function getGRPdf(Request $request)
|
||||
{
|
||||
// Validate input
|
||||
// $request->validate([
|
||||
// 'filename' => 'required|string',
|
||||
// ]);
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$filename = $request->header('gr-number');
|
||||
|
||||
if (!$filename)
|
||||
{
|
||||
return response()->json(['error' => 'Missing file-name header'], 400);
|
||||
}
|
||||
|
||||
$filename = basename($filename);
|
||||
|
||||
// Ensure the file has .pdf extension
|
||||
if (!str_ends_with(strtolower($filename), '.pdf')) {
|
||||
$filename .= '.pdf';
|
||||
}
|
||||
|
||||
$filePath = "uploads/GRNumber/" . $filename;
|
||||
|
||||
if (!Storage::disk('local')->exists($filePath)) {
|
||||
return response()->json(['error' => 'File not found'], 404);
|
||||
}
|
||||
|
||||
$file = Storage::disk('local')->get($filePath);
|
||||
$mimeType = Storage::disk('local')->mimeType($filePath);
|
||||
|
||||
return Response::make($file, 200, [
|
||||
'Content-Type' => $mimeType,
|
||||
'Content-Disposition' => 'inline; filename="' . $filename . '"',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function getGRSerial(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
|
||||
$grNumber = $request->header('gr-number');
|
||||
|
||||
|
||||
if (!$plantCode) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code value can't be empty"
|
||||
], 404);
|
||||
}
|
||||
else if (!$grNumber)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'GR Number is cannot be empty!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
$plantId = $plant->id;
|
||||
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant Code '{$plantCode}' not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$grExist = GRMaster::where('gr_number', $grNumber)->first();
|
||||
|
||||
if (!$grExist) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'GR Number not found'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$grExists = GRMaster::where('plant_id', $plantId)
|
||||
->where('gr_number', $grNumber)
|
||||
->first();
|
||||
|
||||
if (!$grExists) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'GR Number not found for this plant!'
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
$serialNumbers = GrMaster::where('plant_id', $plantId)
|
||||
->where('gr_number', $grNumber)
|
||||
->pluck('serial_number')
|
||||
->toArray();
|
||||
|
||||
if (empty($serialNumbers)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'No serial numbers found for the given GR number!'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'serial_numbers' => $serialNumbers
|
||||
], 200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
291
app/Http/Controllers/SapFileController.php
Normal file
291
app/Http/Controllers/SapFileController.php
Normal file
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Str;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class SapFileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
// public function store(Request $request)
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
public function getSapData(Request $request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function readFiles(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
|
||||
if ($plantCode == null || $plantCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($plantCode) < 4 || !is_numeric($plantCode) || !preg_match('/^[1-9]\d{3,}$/', $plantCode))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$path = "/LaserPRD/{$plantCode}";
|
||||
|
||||
// $isDir = is_dir($path);
|
||||
// $isReadable = is_readable($path);
|
||||
|
||||
// Check if folder exists
|
||||
if (!is_dir($path)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Folder for plant-code {$plantCode} not found!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
if (!is_readable($path)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Folder for plant-code {$plantCode} exists but is not readable!"
|
||||
], 500);
|
||||
}
|
||||
|
||||
// Scan folder
|
||||
$allFiles = scandir($path);
|
||||
if ($allFiles === false) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status_description' => 'Failed to scan directory',
|
||||
], 500);
|
||||
}
|
||||
|
||||
$files = array_filter($allFiles, function($item) use ($path) {
|
||||
$fullPath = $path . '/' . $item;
|
||||
return @is_file($fullPath) && pathinfo($item, PATHINFO_EXTENSION) === 'txt';
|
||||
});
|
||||
|
||||
if (empty($files)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'status_description' => 'No text files found',
|
||||
], 404);
|
||||
}
|
||||
|
||||
// $data = [];
|
||||
// foreach ($files as $file)
|
||||
// {
|
||||
// $filePath = $path . '/' . $file;
|
||||
|
||||
// $content = file_get_contents($filePath);
|
||||
|
||||
// $data[] = [
|
||||
// 'filename' => $file,
|
||||
// 'content' => $content,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'success',
|
||||
// 'files' => $data,
|
||||
// ]);
|
||||
|
||||
//$fileName = 'RMGLAS02-1725800-1.txt';
|
||||
$fileName = array_values($files)[0];
|
||||
$filePath = $path . '/' . $fileName;
|
||||
|
||||
$lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
$headerLine = array_shift($lines); // removes first line
|
||||
|
||||
if (!$lines) {
|
||||
return response()->json(['status' => 'ERROR', 'message' => 'File is empty'], 400);
|
||||
}
|
||||
|
||||
// Debug: return first 5 lines to check reading
|
||||
// return response()->json([
|
||||
// 'status' => 'DEBUG_LINES',
|
||||
// 'file' => $fileName,
|
||||
// 'lines_sample' => array_slice($lines, 0, 5) // first 5 lines
|
||||
// ]);
|
||||
|
||||
if (!file_exists($filePath) || !is_readable($filePath)) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'message' => "File {$fileName} not found or not readable"
|
||||
], 500);
|
||||
}
|
||||
|
||||
// $table = 'class_characteristics';
|
||||
// $columns = Schema::getColumnListing($table); // returns lowercase column names
|
||||
|
||||
// $rows = [];
|
||||
// foreach ($lines as $line) {
|
||||
// $values = str_getcsv($line); // split by comma
|
||||
|
||||
// $row = [];
|
||||
// foreach ($columns as $index => $column) {
|
||||
// $value = $values[$index] ?? null; // if missing, set null
|
||||
// if ($value === '') $value = null; // empty string -> null
|
||||
// $row[$column] = $value;
|
||||
// }
|
||||
|
||||
// $rows[] = $row;
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'DEBUG_ROWS',
|
||||
// 'rows_sample' => array_slice($rows, 0, 5),
|
||||
// ]);
|
||||
|
||||
|
||||
// Insert into database
|
||||
// foreach ($rows as $row) {
|
||||
// \App\Models\ClassCharacteristic::create($row);
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'SUCCESS',
|
||||
// 'rows_imported' => count($rows),
|
||||
// ]);
|
||||
|
||||
|
||||
// Prepare arrays
|
||||
// $serialNumbers = [];
|
||||
// $remainingRows = [];
|
||||
|
||||
// foreach ($lines as $line)
|
||||
// {
|
||||
// $values = str_getcsv($line);
|
||||
|
||||
// // Debug: make sure CSV split is correct
|
||||
// if (count($values) < 6) {
|
||||
// return response()->json([
|
||||
// 'status' => 'ERROR',
|
||||
// 'message' => 'In text file has fewer than 6 columns',
|
||||
// 'line' => $line
|
||||
// ], 400);
|
||||
// }
|
||||
|
||||
// $serialNumbers[] = $values[5] ?? null;
|
||||
|
||||
// $remainingRow = $values;
|
||||
// unset($remainingRow[5]);
|
||||
// // $remainingRow = array_values($remainingRow); // reindex
|
||||
// // $remainingRows[] = $remainingRow;
|
||||
// $remainingRow = array_values($remainingRow); // reindex
|
||||
|
||||
// // Only add unique remaining rows
|
||||
// if (!in_array($remainingRow, $remainingRows, true)) {
|
||||
// $remainingRows[] = $remainingRow;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'SUCCESS',
|
||||
// 'serial_numbers' => $serialNumbers,
|
||||
// 'remaining_rows_sample' => array_slice($remainingRows, 0, 5), // just first 5 for debug
|
||||
// ]);
|
||||
|
||||
$serialNumbers = [];
|
||||
$remainingRow = null;
|
||||
$invalidSerials = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$values = str_getcsv($line);
|
||||
|
||||
if (count($values) < 6) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'message' => 'Text file row has fewer than 6 columns',
|
||||
'line' => $line
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Collect serial number
|
||||
// $serialNumbers[] = $values[5] ?? null;
|
||||
$serial = $values[5] ?? null;
|
||||
$serialNumbers[] = $serial;
|
||||
|
||||
if ($serial == null || strlen($serial) < 13) {
|
||||
$invalidSerials[] = $serialNumbers;
|
||||
}
|
||||
|
||||
// Store remaining row only once
|
||||
if ($remainingRow == null) {
|
||||
$remainingRow = $values;
|
||||
unset($remainingRow[5]); // remove serial number
|
||||
$remainingRow = array_values($remainingRow); // reindex
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($invalidSerials)) {
|
||||
return response()->json([
|
||||
'status' => 'ERROR',
|
||||
'status_description' => 'Some serial numbers are invalid (less than 13 characters)',
|
||||
'invalid_serials' => $invalidSerials
|
||||
], 400);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'SUCCESS',
|
||||
'serial_numbers' => $serialNumbers,
|
||||
'remaining_row' => $remainingRow, // only one copy
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use App\Models\Machine;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\TestingPanelReading;
|
||||
use App\Models\WorkGroupMaster;
|
||||
use DB;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -47,7 +48,6 @@ class TestingPanelController extends Controller
|
||||
], 403);
|
||||
}
|
||||
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($data['plant_code'] == null || $data['plant_code'] == '')
|
||||
@@ -78,19 +78,32 @@ class TestingPanelController extends Controller
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
$line = Line::where('group_work_center', $data['line_name'])->first();
|
||||
if (!$line)
|
||||
if ($data['line_name'] == null || $data['line_name'] == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($data['line_name']) < 0)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid group work center found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->first();
|
||||
if (!$gWorkCenter)
|
||||
{
|
||||
//return response("Line not found.", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Group work center not found!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$line = Line::where('group_work_center', $data['line_name'])->where('plant_id', $plantId)->first();
|
||||
|
||||
if (!$line)
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->where('plant_id', $plantId)->first();
|
||||
if (!$gWorkCenter)
|
||||
{
|
||||
//return response( "Line not found for the specified plant : {$data['plant_code']}",400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
@@ -99,13 +112,26 @@ class TestingPanelController extends Controller
|
||||
], 400);
|
||||
}
|
||||
|
||||
$lineId = $line->id;
|
||||
$gWorkCenterId = $gWorkCenter->id;
|
||||
|
||||
if ($data['machine_name'] == null || $data['machine_name'] == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if (Str::length($data['machine_name']) < 0)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Invalid work center found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->first();
|
||||
|
||||
if (!$machine)
|
||||
{
|
||||
// return response('Machine not found', 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Work center not found!'
|
||||
@@ -113,18 +139,15 @@ class TestingPanelController extends Controller
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->first();
|
||||
|
||||
if (!$machine)
|
||||
{
|
||||
// return response("Machine not found for the specified plant : {$data['plant_code']}", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('line_id', $lineId)->first();
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (!$machine)
|
||||
{
|
||||
// return response("Machine not found for the specified line : {$data['line_name']}", 400)->header('Content-Type', 'text/plain');
|
||||
@@ -135,17 +158,15 @@ class TestingPanelController extends Controller
|
||||
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->where('line_id', $lineId)->first();
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (!$machine) {
|
||||
// return response('Machine not found for the specified plant and line', 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Work center not found for the specified plant and group work center!'
|
||||
'status_description' => "Work center not found for the specified Plant : '{$data['plant_code']}' and Group work center : '{$data['line_name']}'!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$lineId = $machine->line_id;
|
||||
$machineId = $machine->id;
|
||||
|
||||
try
|
||||
@@ -262,13 +283,13 @@ class TestingPanelController extends Controller
|
||||
|
||||
$updateCountString = (string)$newUpdateCount;
|
||||
|
||||
$row =
|
||||
[
|
||||
$row = [
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'motor_testing_master_id'=> $motorTestingMasterId,
|
||||
'serial_number' => $serial['serial_number'] ?? null,
|
||||
'winded_serial_number' => $serial['winded_serial_number'] ?? null,
|
||||
'output' => $serial['output'] ?? null,
|
||||
'before_fr_volt' => $serial['before_fr_volt'] ?? null,
|
||||
'before_fr_cur' => $serial['before_fr_cur'] ?? null,
|
||||
@@ -458,6 +479,7 @@ class TestingPanelController extends Controller
|
||||
}
|
||||
|
||||
$output = [
|
||||
"mot_subassembly_code" => $motorTestingMaster->subassembly_code ?? "",
|
||||
"mot_model_name" => $description,
|
||||
"mot_non_isi_model" => $motorTestingMaster->isi_model ? "0" :"1",
|
||||
"mot_phase" => $motorTestingMaster->phase ?? "",
|
||||
@@ -488,7 +510,7 @@ class TestingPanelController extends Controller
|
||||
"mot_noload_pow_ll" => $motorTestingMaster->noload_pow_ll ?? "",
|
||||
"mot_noload_pow_ul" => $motorTestingMaster->noload_pow_ul ?? "",
|
||||
"mot_noload_spd_ll" => $motorTestingMaster->noload_spd_ll ?? "",
|
||||
"mot_noload_spd_ul" => $motorTestingMaster->noload_spd_ul ?? "",
|
||||
"mot_noload_spd_ul" => $motorTestingMaster->noload_spd_ul ?? ""
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
|
||||
34
app/Livewire/NotificationSound.php
Normal file
34
app/Livewire/NotificationSound.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
|
||||
class NotificationSound extends Component
|
||||
{
|
||||
|
||||
protected $listeners = ['playNotificationSound' => 'playSound', 'playWarnSound' => 'playWarnSound', 'beepSound' => 'beepSound'];
|
||||
|
||||
public function playSound()
|
||||
{
|
||||
$this->dispatch('play-notification-sound');
|
||||
}
|
||||
|
||||
public function playWarnSound()
|
||||
{
|
||||
//dd('test');
|
||||
$this->dispatch('play-warn-sound');
|
||||
}
|
||||
public function beepSound()
|
||||
{
|
||||
//dd('test');
|
||||
$this->dispatch('play-beep-sound');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.notification-sound');
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
@@ -14,12 +15,14 @@ class ProductionMail extends Mailable
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tableData;
|
||||
public $scheduleType;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($tableData = [])
|
||||
public function __construct($scheduleType,$tableData = [])
|
||||
{
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
}
|
||||
|
||||
@@ -36,19 +39,57 @@ class ProductionMail extends Mailable
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
// public function content(): Content
|
||||
// {
|
||||
// return new Content(
|
||||
// view: 'mail.production_report',
|
||||
// with: [
|
||||
// 'company' => "CRI Digital Manufacturing Solutions",
|
||||
// 'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,",
|
||||
// // 'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,<br>" . $reportPeriod,
|
||||
// 'tableData' => $this->tableData,
|
||||
// 'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
$greeting = "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,";
|
||||
|
||||
if ($this->scheduleType == 'Daily') {
|
||||
$fromDate = (new DateTime('yesterday 08:00'))->format('d/m/Y H:i') . ':000';
|
||||
$toDate = (new DateTime('today 07:59'))->format('d/m/Y H:i') . ':999';
|
||||
$reportPeriod = "The following report presents results from: $fromDate to $toDate.";
|
||||
$greeting .= $reportPeriod;
|
||||
}
|
||||
|
||||
if ($this->scheduleType == 'Hourly') {
|
||||
$now = now();
|
||||
$fromHour = $now->copy()->subHour()->format('H:i:s');
|
||||
$toHour = $now->format('H:i:s');
|
||||
$reportDate = $now->format('d/m/Y');
|
||||
$greeting .= "The following report presents results from: $reportDate, $fromHour to $toHour.";
|
||||
}
|
||||
|
||||
if ($this->scheduleType == 'Live') {
|
||||
$now = now();
|
||||
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||
$toMinute = $now->format('d/m/Y H:i:s');
|
||||
$greeting .= "The following report presents results from: $fromMinute to $toMinute.";
|
||||
}
|
||||
|
||||
return new Content(
|
||||
view: 'mail.production_report',
|
||||
with: [
|
||||
'company' => "CRI Digital Manufacturing Solutions",
|
||||
'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached production report status details for the 'Target Quantity' and 'Production Quantity' count,",
|
||||
'greeting' => $greeting,
|
||||
'tableData' => $this->tableData,
|
||||
'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
@@ -16,16 +17,16 @@ class test extends Mailable
|
||||
public $materialTableData;
|
||||
public $bundleTableData;
|
||||
|
||||
public $schedule;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
// public function __construct($tableData = [])
|
||||
// {
|
||||
// $this->tableData = $tableData ?? [];
|
||||
// }
|
||||
public function __construct($serialTableData, $materialTableData, $bundleTableData)
|
||||
|
||||
public function __construct($serialTableData, $materialTableData, $bundleTableData, $schedule)
|
||||
{
|
||||
$this->schedule = $schedule;
|
||||
$this->serialTableData = $serialTableData;
|
||||
$this->materialTableData = $materialTableData;
|
||||
$this->bundleTableData = $bundleTableData;
|
||||
@@ -44,18 +45,54 @@ class test extends Mailable
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
// public function content(): Content
|
||||
// {
|
||||
// return new Content(
|
||||
// view: 'mail.test_mail',
|
||||
// with: [
|
||||
// 'company' => "CRI Digital Manufacturing Solutions",
|
||||
// 'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,",
|
||||
// //'tableData' => $this->tableData,
|
||||
// 'serialTableData' => $this->serialTableData,
|
||||
// 'materialTableData' => $this->materialTableData,
|
||||
// 'bundleTableData' => $this->bundleTableData,
|
||||
// 'wishes' => "Thanks & Regards,<br>CRI Digital Manufacturing Solutions"
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
public function content(): Content
|
||||
{
|
||||
$greeting = "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,";
|
||||
|
||||
if ($this->schedule == 'Daily') {
|
||||
$fromDate = (new DateTime('yesterday 08:00'))->format('d/m/Y H:i') . ':000';
|
||||
$toDate = (new DateTime('today 07:59'))->format('d/m/Y H:i') . ':999';
|
||||
$reportPeriod = "The following report presents results from: $fromDate to $toDate.";
|
||||
//$greeting .= $reportPeriod;
|
||||
$greeting .= "<br><br>$reportPeriod";
|
||||
}
|
||||
|
||||
if ($this->schedule == 'Hourly') {
|
||||
$now = now();
|
||||
$fromHour = $now->copy()->subHour()->format('H:i:s');
|
||||
$toHour = $now->format('H:i:s');
|
||||
$reportDate = $now->format('d/m/Y');
|
||||
$greeting .= "The following report presents results from: $reportDate, $fromHour to $toHour.";
|
||||
}
|
||||
|
||||
if ($this->schedule == 'Live') {
|
||||
$now = now();
|
||||
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||
$toMinute = $now->format('d/m/Y H:i:s');
|
||||
$greeting .= "The following report presents results from: $fromMinute to $toMinute.";
|
||||
}
|
||||
|
||||
return new Content(
|
||||
view: 'mail.test_mail',
|
||||
// with: [
|
||||
// 'name' => "CRI Digital Manufacturing Solutions<br><br>Dear Sir/Madam,<br><br> Kindly find the attached invoice status details for the 'Total Number Of Invoices' and 'Scanned Number Of Invoices' count,",
|
||||
// 'tableData' => $this->tableData,
|
||||
// 'wishes' => "Thanks & Regards<br><br>CRI Digital Manufacturing Solutions"
|
||||
// ],
|
||||
with: [
|
||||
with: [
|
||||
'company' => "CRI Digital Manufacturing Solutions",
|
||||
'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,",
|
||||
'greeting' => $greeting,
|
||||
//'greeting' => "Dear Sir/Madam,<br><br>Kindly find the attached invoice status details for the 'Total Number of Invoices' and 'Scanned Number of Invoices' count,",
|
||||
//'tableData' => $this->tableData,
|
||||
'serialTableData' => $this->serialTableData,
|
||||
'materialTableData' => $this->materialTableData,
|
||||
|
||||
69
app/Models/EbReading.php
Normal file
69
app/Models/EbReading.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EbReading extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'lcd_segment_check',
|
||||
'meter_serial_no',
|
||||
'eb_date_time',
|
||||
'ph_seq_of_volt',
|
||||
'ph_assoc_conn_check',
|
||||
'instantaneous_ph_volt',
|
||||
'instantaneous_curr',
|
||||
'instantaneous_freq',
|
||||
'instantaneous_kw_with_sign',
|
||||
'instantaneous_kva',
|
||||
'instantaneous_kv_ar',
|
||||
'instantaneous_pf_with_sign',
|
||||
'rd_with_elapsed_time_kva',
|
||||
'cum_active_import_energy',
|
||||
'tod1_active_energy_6_9',
|
||||
'tod2_active_energy_18_21',
|
||||
'tod3_active_energy_21_22',
|
||||
'tod4_active_energy_5_6_9_18',
|
||||
'tod5_active_energy_22_5',
|
||||
'cum_reac_lag_energy',
|
||||
'cum_reac_lead_energy',
|
||||
'cum_appar_energy',
|
||||
'tod1_appar_energy_6_9',
|
||||
'tod2_appar_energy_18_21',
|
||||
'tod3_appar_energy_21_22',
|
||||
'tod4_appar_energy_5_6_9_18',
|
||||
'tod5_appar_energy_22_5',
|
||||
'avg_pow_factor',
|
||||
'avg_freq_15min_last_ip',
|
||||
'net_kv_arh_high',
|
||||
'net_kv_arh_low',
|
||||
'cum_md_kva',
|
||||
'present_md_kva',
|
||||
'present_md_kva_date_time',
|
||||
'tod1_md_kva_6_9',
|
||||
'tod2_md_kva_18_21',
|
||||
'tod3_md_kva_21_22',
|
||||
'tod4_md_kva_5_6_9_18',
|
||||
'tod5_md_kva_22_5',
|
||||
'total_pow_off_hours',
|
||||
'programming_count',
|
||||
'last_occ_res_event_type',
|
||||
'last_occ_res_event_date_time',
|
||||
'tamper_count',
|
||||
'reset_count',
|
||||
'last_md_reset_date_time',
|
||||
'electrician_sign',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
}
|
||||
40
app/Models/EquipmentMaster.php
Normal file
40
app/Models/EquipmentMaster.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class EquipmentMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'machine_id',
|
||||
'name',
|
||||
'description',
|
||||
'make',
|
||||
'model',
|
||||
'equipment_number',
|
||||
'instrument_serial_number',
|
||||
'calibrated_on',
|
||||
'frequency',
|
||||
'next_calibration_date',
|
||||
'calibrated_by',
|
||||
'calibration_certificate',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
}
|
||||
34
app/Models/GrMaster.php
Normal file
34
app/Models/GrMaster.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class GrMaster extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
"plant_id",
|
||||
"item_id",
|
||||
"serial_number",
|
||||
"gr_number",
|
||||
"created_at",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"updated_at"
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,17 @@ class Line extends Model
|
||||
"name",
|
||||
"type",
|
||||
"group_work_center",
|
||||
"no_of_operation",
|
||||
"work_group1_id",
|
||||
"work_group2_id",
|
||||
"work_group3_id",
|
||||
"work_group4_id",
|
||||
"work_group5_id",
|
||||
"work_group6_id",
|
||||
"work_group7_id",
|
||||
"work_group8_id",
|
||||
"work_group9_id",
|
||||
"work_group10_id",
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
@@ -27,4 +38,114 @@ class Line extends Model
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
}
|
||||
|
||||
public function workGroupMasters(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class);
|
||||
}
|
||||
|
||||
public function workGroup1()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup2()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group2_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup3()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group3_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup4()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group4_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup5()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group5_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup6()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group6_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup7()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group7_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup8()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group8_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup9()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group9_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroup10()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group10_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters1()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group1_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters2()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group2_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters3()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group3_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters4()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group4_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters5()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group5_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters6()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group6_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters7()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group7_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters8()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group8_id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters9()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group9 _id', 'id');
|
||||
}
|
||||
|
||||
public function workGroupMasters10()
|
||||
{
|
||||
return $this->hasMany(WorkGroupMaster::class, 'work_group10_id', 'id');
|
||||
}
|
||||
|
||||
// public function rejectReasons()
|
||||
// {
|
||||
// return $this->hasMany(RejectReason::class, 'line_id', 'id');
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class Machine extends Model
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'work_group_master_id',
|
||||
'name',
|
||||
'work_center',
|
||||
];
|
||||
@@ -27,8 +28,19 @@ class Machine extends Model
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function workGroupMaster(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class);
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
}
|
||||
|
||||
public function equipmentMasters()
|
||||
{
|
||||
return $this->hasMany(EquipmentMaster::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user