Compare commits
459 Commits
ranjith-de
...
7a242c820c
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a242c820c | |||
| bc02a49b54 | |||
| aa60fc14e0 | |||
| e7a7ea063f | |||
| 891b02b6a4 | |||
| 10eff34cc9 | |||
| 1a37dd5e49 | |||
| 6bdabe3e1f | |||
| 1dba08f5da | |||
| 80d24b7448 | |||
| db43960f43 | |||
| c633d78d7e | |||
| 31f96dd11e | |||
| 4044af92c4 | |||
| 2ccf1a38e2 | |||
| 084c041f6d | |||
| b3d39d416a | |||
| dbaadd27e3 | |||
| 313edfed0b | |||
| a5d4c12348 | |||
| 23cdc04a09 | |||
| fb5f69df5f | |||
| 7ec3e5e9f7 | |||
| c7239b02f2 | |||
| f61e452f33 | |||
| 54f5a3b386 | |||
| ebc4ba672a | |||
| 68a75b2677 | |||
| 2f28cf28e1 | |||
| 592818c743 | |||
| 0dd6e5796b | |||
| c317eec67e | |||
| 9895297570 | |||
| e5f92b1348 | |||
| a960752ba6 | |||
| e84d0c7f00 | |||
| c5bd6cd995 | |||
| cf534af204 | |||
| 875ea7ac2d | |||
| bd93f3e86e | |||
| ad6d56b944 | |||
| 71f1b14757 | |||
| a0a1812a57 | |||
| d6b7b6a1af | |||
| 9091e7d080 | |||
| 957eb3cb58 | |||
| 9889f7b664 | |||
| 25ec7666ae | |||
| 87de4243aa | |||
| d1bf69fe68 | |||
| abd97d6bfb | |||
| 412b50c6c0 | |||
| 1bf85da54d | |||
| 7bfd534781 | |||
| f4f470a98a | |||
| 09cb02046f | |||
| a1eb635fe0 | |||
| 57ab4137a5 | |||
| 705d3416d7 | |||
| 77277cd4e8 | |||
| 3adfe42e95 | |||
| 9a2c8712a7 | |||
| f6bfa6ca13 | |||
| 9d3256a3a9 | |||
| 24d76f59a7 | |||
| 292e809a7f | |||
| 82c100162d | |||
| 417b6f4dea | |||
| 0379858239 | |||
| d7147084f9 | |||
| a3c37a16d2 | |||
| ab6925a896 | |||
| 8e7b8e52b7 | |||
| f1175ff5bc | |||
| bd0d9ba979 | |||
| 8038eabeda | |||
| afb045ca4c | |||
| bf977c08bd | |||
| db05e9e738 | |||
| 3c5c18cea4 | |||
| b9d1dcb1c1 | |||
| b105d38bfe | |||
| 1cc8403f2a | |||
| eb3ed2b8f1 | |||
| 6ff007e3a1 | |||
| 60cfab3b89 | |||
| 67ee3ce0f2 | |||
| 57c56fffeb | |||
| 88b6fb4256 | |||
| 9a514a758e | |||
| 6d01112c4d | |||
| b74095713b | |||
| d027156614 | |||
| 27ea356e8f | |||
| 435f46fae4 | |||
| b5be827bc3 | |||
| 8ba03cf2b9 | |||
| 0dcf34d713 | |||
| 4025fcf783 | |||
| 3363498fb6 | |||
| a6b8a5c0cc | |||
| c6714b195e | |||
| d392fe9c78 | |||
| eccc6342c0 | |||
| dbc9a02669 | |||
| 837b936b51 | |||
| 528914e2d0 | |||
| bb94206a1e | |||
| d7f758b584 | |||
| 85bfb99273 | |||
| 2f2faa3019 | |||
| d72f4c89fd | |||
| 4c07abe394 | |||
| 8a0e7d6878 | |||
| d1031d8a6e | |||
| fa06c2c6cb | |||
| e06a458fc0 | |||
| 36dd07817b | |||
| 51a20219db | |||
| dc564f9c28 | |||
| bab5b879e6 | |||
| a09264a053 | |||
| 82f776ef41 | |||
| 952b9a01a5 | |||
| 2b8a3a2838 | |||
| 4acb66c464 | |||
| ea64aea9ce | |||
| 72e6621cc0 | |||
| 2c49e6b272 | |||
| d6ec50c20e | |||
| 19382d0644 | |||
| 408e426545 | |||
| 62b338be22 | |||
| c407f9c6c2 | |||
| a09adf0ea5 | |||
| b864bda85e | |||
| 734ab9dfdc | |||
| 6907083ec0 | |||
| bd7e0422e6 | |||
| 53f14711b2 | |||
| a39a10d104 | |||
| 17bca76d06 | |||
| 500a2ae3ca | |||
| 0adb82afcf | |||
| cc7fd5b16d | |||
| 70d38c7a7b | |||
| efba8af539 | |||
| caac5ad7eb | |||
| 7e799d507a | |||
| 358d31cb71 | |||
| 4ffc2d7a92 | |||
| be5d02bc50 | |||
| eff0da491c | |||
| 2e0ccd7c34 | |||
| 2a2bf8db4c | |||
| c2c50eb451 | |||
| 75ba355252 | |||
| b40a7e3ae7 | |||
| b50493f2f2 | |||
| 7bc70341d6 | |||
| 9c869e9726 | |||
| b5fe0018df | |||
| 76216bd304 | |||
| 8b12d7612f | |||
| 717cfcaa53 | |||
| 1426f868cb | |||
| e6c103b56a | |||
| 8ab8e465b9 | |||
| 920a217613 | |||
| 780f00f11a | |||
| f631fcd43c | |||
| 444ec30b34 | |||
| d1b487aadb | |||
| c89574f070 | |||
| 2e52499aba | |||
| 8b08a54f04 | |||
| dda77f4ac7 | |||
| 5ebd5cfa47 | |||
| bddcc95c21 | |||
| 956c34a5da | |||
| 88046d7a2a | |||
| c60eae50a1 | |||
| 4289fb3ef1 | |||
| b032f14deb | |||
| 0653a69d8d | |||
| 3ce5867615 | |||
| 82aa723d52 | |||
| 72e1df1329 | |||
| 077872d418 | |||
| caeb0a5afd | |||
| e4fdd9521e | |||
| 3d26ad29ef | |||
| ce5393f858 | |||
| 12c9e55d45 | |||
| a1c9a1083c | |||
| b5ed826213 | |||
| f11b95e44e | |||
| 908ea3fb21 | |||
| 78987f1430 | |||
| a16ae0ca16 | |||
| 5ee964b5f7 | |||
| de1bf16ace | |||
| a1f5fa0457 | |||
| b7b6ab6c77 | |||
| 32b86b4289 | |||
| c33db6b934 | |||
| 4807c572eb | |||
| 252014bd51 | |||
| e1d5793922 | |||
| 56152816e2 | |||
| 8b2d4c4faf | |||
| 0430d605e7 | |||
| 0decbc6e29 | |||
| 9aa727cc36 | |||
| 22ece583b7 | |||
| 8c90d1fc03 | |||
| 5e68debd87 | |||
| 855e9f91c8 | |||
| 6d088471bf | |||
| f167b732c0 | |||
| 4264c5493c | |||
| 61774d240a | |||
| ae01370107 | |||
| f3389399eb | |||
| c18a07853e | |||
| 555f810c0f | |||
| 2e5d185be1 | |||
| 0ece1d0dd6 | |||
| e145560920 | |||
| e02052e536 | |||
| 39e40e011f | |||
| 7184eda58c | |||
| 3c4b419078 | |||
| 7ba5375386 | |||
| c3324caa08 | |||
| ace14124f3 | |||
| c68a45ef8d | |||
| 3edd8fafc6 | |||
| 2c66f2e6bd | |||
| e791176500 | |||
| 1eddecc660 | |||
| 379e8fc8f9 | |||
| b018ef48d7 | |||
| e45c166345 | |||
| d53d3dedbb | |||
| 18e74f4a52 | |||
| 16c525773b | |||
| 501cd541b9 | |||
| 62e14fb3c3 | |||
| 78f4929e27 | |||
| b674966886 | |||
| 103515a387 | |||
| dd182c6504 | |||
| 1fed559feb | |||
| 312de66a1c | |||
| 7d8a891f95 | |||
| 557c367f4c | |||
| cef3e17dc7 | |||
| f89ad49eff | |||
| c9006ee0a1 | |||
| 2fa58b587e | |||
| bb0a684366 | |||
| 16b1802412 | |||
| 079ed2eba6 | |||
| f1f6b596a4 | |||
| b2aa572994 | |||
| 44bdcba615 | |||
| 76a5379c02 | |||
| eeeec722ee | |||
| d8a4ddf6e9 | |||
| 9493bf5edf | |||
| feab063017 | |||
| b2f5194ef9 | |||
| 3a3322ccc4 | |||
| 7a9dac239d | |||
| 77d98b16fb | |||
| a2554fb4a9 | |||
| 353774b184 | |||
| 29fecaea3d | |||
| a35185e4b1 | |||
| f07ba9dd00 | |||
| 2a7f48cc75 | |||
| c7f4f49669 | |||
| 2e9a52a890 | |||
| 3c34495048 | |||
| b70907cb9f | |||
| 9ee4fe5c7e | |||
| 6f06319752 | |||
| 785be70629 | |||
| e5cb7f3d88 | |||
| 1dbbd53fc9 | |||
| 04d0c2dc82 | |||
| 048977a44b | |||
| 8395599d9d | |||
| 9a7b42dea5 | |||
| 0ce59ebe22 | |||
| c032cdc58d | |||
| 4074374614 | |||
| 15712c44b6 | |||
| 99f7450e5e | |||
| f6f6f0924e | |||
| 3bab0310a1 | |||
| 6924990ace | |||
| ba0b2c2709 | |||
| 51416cdf37 | |||
| a8ff5b5120 | |||
| 4ca965ccb1 | |||
| 22cbb6c4d3 | |||
| 6db07e1825 | |||
| 1bc0a4b01d | |||
| dc77a51c3c | |||
| b07a9596e5 | |||
| b96a54aae5 | |||
| fe0e1e139e | |||
| a95766fd45 | |||
| d5d5a6d193 | |||
| 25125cfead | |||
| d6c6cf0c69 | |||
| 99a95dc150 | |||
| 6d26307c4a | |||
| 8703aec73e | |||
| f8691500cf | |||
| 12f9cb683f | |||
| 73c26a649a | |||
| 80f6aeb3d6 | |||
| f633285a57 | |||
| 841922a4b3 | |||
| 3a819737cb | |||
| 18f60ec336 | |||
| 4ab7be97bb | |||
| a643bce1c2 | |||
| 45392419cd | |||
| 7b300f63d2 | |||
| 650314a435 | |||
| eaefffd51b | |||
| 084d9b04f1 | |||
| 75a3a8641c | |||
| f7f1d3a855 | |||
| f00fc8b4d7 | |||
| 73eb79a8d0 | |||
| 5856fe64c1 | |||
| 4615e45c74 | |||
| 486b94bb79 | |||
| 71eda460bd | |||
| 938f9b9fdf | |||
| 648551c619 | |||
| 308e68b79a | |||
| 5b9cb33a63 | |||
| 8b57518408 | |||
| 4b68133bf1 | |||
| a52fc9580a | |||
| 94819ccc4f | |||
| 6e51b9fba8 | |||
| 0a66526a63 | |||
| 0398cd5262 | |||
| cca6fbe428 | |||
| 633c8c89ca | |||
| 543ab7f44f | |||
| 09aeff2b96 | |||
| 2f3973f6af | |||
| 7f76a604a3 | |||
| 837ac47120 | |||
| e6fb2c1bae | |||
| a687b8af3b | |||
| cd45e6658a | |||
| 0b221c5eae | |||
| 8c062505c9 | |||
| 9411d0b33b | |||
| ab3a2047bb | |||
| f0ef2dda8e | |||
| 968d67d808 | |||
| 2342c6003d | |||
| 290d218a0d | |||
| c455c76715 | |||
| a1abe537c3 | |||
| c65265e68e | |||
| 3da016ae49 | |||
| ea17636670 | |||
| 31b56ae9b2 | |||
| 9517b38f9b | |||
| 2c1caa40a3 | |||
| c3fef2f3a0 | |||
| 904e18e63a | |||
| 27dc2690ca | |||
| 8e1c4f46e8 | |||
| d699c043d4 | |||
| 1806f32a7b | |||
| eb2ae19641 | |||
| 2dbcc8b859 | |||
| 79e3427cdb | |||
| 81a5fa16c4 | |||
| 6520c3ca87 | |||
| 2e167c75b0 | |||
| aca5d6c957 | |||
| 9edbaf3d43 | |||
| a46aaa72a2 | |||
| d917aa530d | |||
| 45944c5c25 | |||
| fda672948b | |||
| f15e6451ca | |||
| c8aac9116d | |||
| bcd107a8bc | |||
| 458e143b9a | |||
| de2dda0dc5 | |||
| 7543f8a416 | |||
| f76316ec91 | |||
| acea7b14a6 | |||
| 87f49e8491 | |||
| f612551288 | |||
| 4f84735eaf | |||
| 45b8c1fbb4 | |||
| 6015968043 | |||
| 2bc8584e7a | |||
| d126e931c8 | |||
| 62bf68ad2e | |||
| c6c63dcb35 | |||
| d1663ae58a | |||
| deb46cdda2 | |||
| 002bdc597d | |||
| a406d1b58a | |||
| 58d0b9f0ae | |||
| c0d8ca7b1e | |||
| f31ab62ec0 | |||
| 4285a31f94 | |||
| 0c9228bfec | |||
| 58b45c849d | |||
| 61a2e7ffad | |||
| 3779cf3e3b | |||
| acf955dd94 | |||
| 0de49f14ce | |||
| 0473ca33cf | |||
| 8a01033459 | |||
| 0555f9faff | |||
| 8cbbaa4845 | |||
| cb6b201648 | |||
| c3089a147c | |||
| 45f0e39f73 | |||
| fe1e1b9918 | |||
| e20915ca82 | |||
| 58e6cbfac0 | |||
| 1ace049687 | |||
| e5e85a8eea | |||
| 555802ab35 | |||
| 587b743f12 | |||
| 42555d4a81 | |||
| fd1e554076 | |||
| 022654f192 | |||
| 55f1088fda | |||
| f9233f44d8 | |||
| e0fec6b07c | |||
| 6bda9c1459 | |||
| 39bdd3df57 | |||
| 5bcf0703d9 | |||
| 80e522b7e6 | |||
| ee101f80ea | |||
| 37a99d03c1 | |||
| 5fdced003a | |||
| 0b0bb90efb | |||
| 32ce6da2c1 |
@@ -42,6 +42,7 @@ class TriggerPendingApprovalMails extends Command
|
||||
|
||||
public $wfId;
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Approval mail job started');
|
||||
@@ -73,163 +74,165 @@ class TriggerPendingApprovalMails extends Command
|
||||
});
|
||||
|
||||
if ($records->isEmpty()) {
|
||||
$this->info('No characteristics pending approvals');
|
||||
}else{
|
||||
$grouped = $records->groupBy(function ($item) {
|
||||
$this->wfId = $item->work_flow_id;
|
||||
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
|
||||
});
|
||||
$this->info('No pending approvals');
|
||||
return;
|
||||
}
|
||||
|
||||
$pendingApprovers = RequestCharacteristic::where('work_flow_id', $this->wfId)->latest()->first();
|
||||
$grouped = $records->groupBy(function ($item) {
|
||||
$this->wfId = $item->work_flow_id;
|
||||
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
|
||||
});
|
||||
|
||||
$this->info($pendingApprovers->approver_status1, $pendingApprovers->approver_status2);
|
||||
$pendingApprovers = RequestCharacteristic::where('work_flow_id', $this->wfId)->latest()->first();
|
||||
|
||||
$this->info($pendingApprovers->approver_status1, $pendingApprovers->approver_status2);
|
||||
|
||||
|
||||
$approverNameFromMaster = null;
|
||||
if ($pendingApprovers && $pendingApprovers->characteristic_approver_master_id) {
|
||||
$approverNameFromMaster = CharacteristicApproverMaster::find($pendingApprovers->characteristic_approver_master_id);
|
||||
$approverNameFromMaster = null;
|
||||
if ($pendingApprovers && $pendingApprovers->characteristic_approver_master_id) {
|
||||
$approverNameFromMaster = CharacteristicApproverMaster::find($pendingApprovers->characteristic_approver_master_id);
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach ($grouped as $groupRecords) {
|
||||
|
||||
$first = $groupRecords->first();
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('id', $first->characteristic_approver_master_id)
|
||||
->first();
|
||||
|
||||
if (!$approver) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$characteristics = $groupRecords->map(fn ($r) => [
|
||||
'work_flow_id' => $r->work_flow_id,
|
||||
'characteristic_name' => $r->characteristic_name,
|
||||
'current_value' => $r->current_value,
|
||||
'update_value' => $r->update_value,
|
||||
])->toArray();
|
||||
|
||||
foreach ($grouped as $groupRecords) {
|
||||
$level = null;
|
||||
$mail = null;
|
||||
$name = null;
|
||||
$updateData = [];
|
||||
$now = Carbon::now();
|
||||
|
||||
$first = $groupRecords->first();
|
||||
// --- FIRST MAIL ---
|
||||
if (is_null($first->mail_status)){
|
||||
$level = 1;
|
||||
$mail = $approver->mail1;
|
||||
$name = $approver->name1;
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $first->plant_id)
|
||||
->where('machine_id', $first->machine_id)
|
||||
->where('id', $first->characteristic_approver_master_id)
|
||||
->first();
|
||||
$updateData['mail_status'] = 'Sent';
|
||||
|
||||
if (!$approver) {
|
||||
continue;
|
||||
if ($approver->duration1 > 0)
|
||||
{
|
||||
|
||||
$duration = number_format((float)$approver->duration1, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now
|
||||
->copy()
|
||||
->addMinutes($totalMinutes)
|
||||
->startOfMinute();
|
||||
}
|
||||
|
||||
$characteristics = $groupRecords->map(fn ($r) => [
|
||||
'work_flow_id' => $r->work_flow_id,
|
||||
'characteristic_name' => $r->characteristic_name,
|
||||
'current_value' => $r->current_value,
|
||||
'update_value' => $r->update_value,
|
||||
])->toArray();
|
||||
|
||||
$level = null;
|
||||
$mail = null;
|
||||
$name = null;
|
||||
$updateData = [];
|
||||
$now = Carbon::now();
|
||||
|
||||
// --- FIRST MAIL ---
|
||||
if (is_null($first->mail_status)){
|
||||
$level = 1;
|
||||
$mail = $approver->mail1;
|
||||
$name = $approver->name1;
|
||||
|
||||
$updateData['mail_status'] = 'Sent';
|
||||
|
||||
if ($approver->duration1 > 0)
|
||||
{
|
||||
|
||||
$duration = number_format((float)$approver->duration1, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now
|
||||
->copy()
|
||||
->addMinutes($totalMinutes)
|
||||
->startOfMinute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// --- SECOND MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
|
||||
$this->info(
|
||||
"mail_status: {$first->mail_status}, ".
|
||||
"approver_status1: {$first->approver_status1}, ".
|
||||
"trigger_at: {$first->trigger_at}, ".
|
||||
"now: {$now}"
|
||||
);
|
||||
|
||||
$level = 2;
|
||||
$mail = $approver->mail2;
|
||||
$name = $approver->name2;
|
||||
|
||||
if ($approver->duration2 > 0) {
|
||||
|
||||
$duration = number_format((float)$approver->duration2, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now->copy()->addMinutes($totalMinutes);
|
||||
} else {
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
|
||||
$updateData['mail_status'] = 'Sent-Mail2';
|
||||
}
|
||||
|
||||
// --- THIRD MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent-Mail2' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
$level = 3;
|
||||
$mail = $approver->mail3;
|
||||
$name = $approver->name3;
|
||||
|
||||
else
|
||||
{
|
||||
$updateData['trigger_at'] = null;
|
||||
$updateData['mail_status'] = 'Sent-Mail3';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
// --- SECOND MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
|
||||
$pdfPath = 'uploads/LaserDocs/' . $first->work_flow_id . '.pdf';
|
||||
|
||||
$subjectLine = 'Characteristic Approval Mail';
|
||||
|
||||
Mail::to($mail)->send(
|
||||
new CharacteristicApprovalMail(
|
||||
$first,
|
||||
$name,
|
||||
$level,
|
||||
$pdfPath,
|
||||
$pendingApprovers,
|
||||
$approverNameFromMaster,
|
||||
$subjectLine,
|
||||
$characteristics
|
||||
)
|
||||
$this->info(
|
||||
"mail_status: {$first->mail_status}, ".
|
||||
"approver_status1: {$first->approver_status1}, ".
|
||||
"trigger_at: {$first->trigger_at}, ".
|
||||
"now: {$now}"
|
||||
);
|
||||
|
||||
RequestCharacteristic::whereIn('id', $groupRecords->pluck('id'))
|
||||
->update($updateData);
|
||||
$level = 2;
|
||||
$mail = $approver->mail2;
|
||||
$name = $approver->name2;
|
||||
|
||||
$rows[] = [
|
||||
$first->id,
|
||||
$first->plant_id,
|
||||
$first->machine_id,
|
||||
"Level $level",
|
||||
$mail,
|
||||
'SENT'
|
||||
];
|
||||
if ($approver->duration2 > 0) {
|
||||
|
||||
$duration = number_format((float)$approver->duration2, 2, '.', '');
|
||||
[$hours, $minutes] = explode('.', $duration);
|
||||
|
||||
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
|
||||
|
||||
$updateData['trigger_at'] = $now->copy()->addMinutes($totalMinutes);
|
||||
} else {
|
||||
$updateData['trigger_at'] = null;
|
||||
}
|
||||
|
||||
$updateData['mail_status'] = 'Sent-Mail2';
|
||||
}
|
||||
|
||||
// --- THIRD MAIL ---
|
||||
elseif (
|
||||
$first->mail_status == 'Sent-Mail2' &&
|
||||
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
|
||||
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
|
||||
$first->trigger_at &&
|
||||
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
|
||||
) {
|
||||
$level = 3;
|
||||
$mail = $approver->mail3;
|
||||
$name = $approver->name3;
|
||||
|
||||
$updateData['trigger_at'] = null;
|
||||
$updateData['mail_status'] = 'Sent-Mail3';
|
||||
}
|
||||
|
||||
if (!$level || !$mail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pdfPath = 'uploads/LaserDocs/' . $first->work_flow_id . '.pdf';
|
||||
|
||||
$subjectLine = 'Characteristic Approval Mail';
|
||||
|
||||
Mail::to($mail)->send(
|
||||
new CharacteristicApprovalMail(
|
||||
$first,
|
||||
$name,
|
||||
$level,
|
||||
$pdfPath,
|
||||
$pendingApprovers,
|
||||
$approverNameFromMaster,
|
||||
$subjectLine,
|
||||
$characteristics
|
||||
)
|
||||
);
|
||||
|
||||
RequestCharacteristic::whereIn('id', $groupRecords->pluck('id'))
|
||||
->update($updateData);
|
||||
|
||||
$rows[] = [
|
||||
$first->id,
|
||||
$first->plant_id,
|
||||
$first->machine_id,
|
||||
"Level $level",
|
||||
$mail,
|
||||
'SENT'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// .. Quality Mail trigger logic
|
||||
|
||||
$qualityRecords = RequestCharacteristic::where(function ($q) {
|
||||
@@ -371,9 +374,7 @@ class TriggerPendingApprovalMails extends Command
|
||||
|
||||
$subjectLine = 'Quality Approval Mail';
|
||||
|
||||
$emails = array_map('trim', explode(',', $mail));
|
||||
|
||||
Mail::to($emails)->send(
|
||||
Mail::to($mail)->send(
|
||||
new CharacteristicApprovalMail(
|
||||
$first,
|
||||
$name,
|
||||
@@ -381,8 +382,8 @@ class TriggerPendingApprovalMails extends Command
|
||||
$pdfPath,
|
||||
$pendingApprovers,
|
||||
$approverNameFromMaster,
|
||||
$subjectLine
|
||||
// $characteristics
|
||||
$subjectLine,
|
||||
$characteristics
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Axn;
|
||||
use App\Models\InvoiceValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class AxnExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = InvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
// ExportColumn::make('plant.code')
|
||||
// ->label('PLANT CODE'),
|
||||
// ExportColumn::make('invoice_number')
|
||||
// ->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('year')
|
||||
->label('YEAR')
|
||||
->state(function ($record) {
|
||||
return substr($record->serial_number, 0, 2);
|
||||
}),
|
||||
ExportColumn::make('month')
|
||||
->label('MONTH')
|
||||
->state(function ($record) {
|
||||
return substr($record->serial_number, 2, 2);
|
||||
}),
|
||||
ExportColumn::make('vendor')
|
||||
->label('VENDOR NUMBER')
|
||||
->state(function ($record) {
|
||||
return substr($record->serial_number, 4, 4);
|
||||
}),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER')
|
||||
->state(function ($record) {
|
||||
return substr($record->serial_number, 8);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your axn 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;
|
||||
}
|
||||
}
|
||||
@@ -28,28 +28,28 @@ class CharacteristicApproverMasterExporter extends Exporter
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('approver_type')
|
||||
->label('APPROVER TYPE'),
|
||||
ExportColumn::make('machine_name')
|
||||
->label('MACHINE NAME'),
|
||||
ExportColumn::make('approver_type')
|
||||
->label('APPROVER TYPE'),
|
||||
ExportColumn::make('characteristic_field')
|
||||
->label('MASTER CHARACTERISTIC FIELD'),
|
||||
ExportColumn::make('name1')
|
||||
->label('APPROVER NAME 1'),
|
||||
ExportColumn::make('mail1')
|
||||
->label('MAIL 1'),
|
||||
->label('APPROVER MAIL 1'),
|
||||
ExportColumn::make('duration1')
|
||||
->label('DURATION 1'),
|
||||
ExportColumn::make('name2')
|
||||
->label('APPROVER NAME 2'),
|
||||
ExportColumn::make('mail2')
|
||||
->label('MAIL 2'),
|
||||
->label('APPROVER MAIL 2'),
|
||||
ExportColumn::make('duration2')
|
||||
->label('DURATION 2'),
|
||||
ExportColumn::make('name3')
|
||||
->label('APPROVER NAME 3'),
|
||||
ExportColumn::make('mail3')
|
||||
->label('MAIL 3'),
|
||||
->label('APPROVER MAIL 3'),
|
||||
ExportColumn::make('duration3')
|
||||
->label('DURATION 3'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -36,8 +36,6 @@ class ProcessOrderExporter extends Exporter
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('order_quantity')
|
||||
->label('ORDER QUANTITY'),
|
||||
ExportColumn::make('updated_order_quantity')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ExportColumn::make('received_quantity')
|
||||
->label('RECEIVED QUANTITY'),
|
||||
ExportColumn::make('sfg_number')
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ProductionCharacteristicExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ProductionCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE NAME'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('machine.work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('characteristic_name')
|
||||
->label('CHARACTERISTIC NAME'),
|
||||
ExportColumn::make('observed_value')
|
||||
->label('OBSERVED VALUE'),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
ExportColumn::make('inspection_status')
|
||||
->label('INSPECTION STATUS'),
|
||||
ExportColumn::make('remark')
|
||||
->label('REMARK'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your production characteristic 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;
|
||||
}
|
||||
}
|
||||
@@ -71,19 +71,7 @@ class RequestCharacteristicExporter extends Exporter
|
||||
ExportColumn::make('approved3_at')
|
||||
->label('APPROVED AT 1'),
|
||||
ExportColumn::make('mail_status')
|
||||
->label('MAIL STATUS')
|
||||
->formatStateUsing(function ($state) {
|
||||
if (! $state || $state == '' || $state == null) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return match ($state) {
|
||||
'Sent' => 'Sent-M1',
|
||||
'Sent-Mail2' => 'Sent-M2',
|
||||
'Sent-Mail3' => 'Sent-M3',
|
||||
default => '-',
|
||||
};
|
||||
}),
|
||||
->label('MAIL STATUS'),
|
||||
ExportColumn::make('trigger_at')
|
||||
->label('TRIGGERED AT'),
|
||||
ExportColumn::make('created_at')
|
||||
|
||||
@@ -28,10 +28,6 @@ class StickerMasterExporter extends Exporter
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('ITEM DESCRIPTION'),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
->label('SERIAL NUMBER MOTOR'),
|
||||
ExportColumn::make('serial_number_pump')
|
||||
|
||||
@@ -3,14 +3,9 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class CharacteristicApproverMasterImporter extends Importer
|
||||
{
|
||||
@@ -22,80 +17,80 @@ class CharacteristicApproverMasterImporter extends Importer
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->examples(['1000', '1000'])
|
||||
->examples(['1000','1000'])
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->examples(['RMGLAS02', 'RMGLAS02'])
|
||||
->examples(['RMGLAS02','RMGLAS02'])
|
||||
->label('Work Center')
|
||||
->relationship(resolveUsing: 'work_center')
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('approver_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Type')
|
||||
->examples(['Characteristic', 'Quality'])
|
||||
->label('Approver Type'),
|
||||
ImportColumn::make('machine_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Machine Name')
|
||||
->examples(['15002635', '17002635'])
|
||||
->examples(['15002635','17002635'])
|
||||
->label('Machine Name'),
|
||||
ImportColumn::make('characteristic_field')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Master Characteristic Field')
|
||||
->examples(['NIL', 'MV SERIES'])
|
||||
->label('Master Characteristic Field'),
|
||||
ImportColumn::make('name1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 1')
|
||||
->examples(['Test 1', 'Test 4'])
|
||||
->examples(['Suresh.D','Suresh.D'])
|
||||
->label('Approver Name 1'),
|
||||
ImportColumn::make('mail1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mail 1')
|
||||
->examples(['test1@cripumps.com', 'test4@cripumps.com'])
|
||||
->label('Mail 1'),
|
||||
->exampleHeader('Approver Mail 1')
|
||||
->examples(['suresh@cripumps.com','suresh@cripumps.com'])
|
||||
->label('Approver Mail 1'),
|
||||
ImportColumn::make('name2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 2')
|
||||
->examples(['Ramesh.G','Ramesh.G'])
|
||||
->label('Approver Name 2'),
|
||||
ImportColumn::make('mail2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 2')
|
||||
->examples(['ramesh@cripumps.com','ramesh@cripumps.com'])
|
||||
->label('Approver Mail 2'),
|
||||
ImportColumn::make('name3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 3')
|
||||
->examples(['Ganesh.K','Ganesh.K'])
|
||||
->label('Approver Name 3'),
|
||||
ImportColumn::make('mail3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Mail 3')
|
||||
->examples(['ganesh@cripumps.com','ganesh@cripumps.com'])
|
||||
->label('Approver Mail 3'),
|
||||
ImportColumn::make('duration1')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 1')
|
||||
->examples(['0.05', '0.30'])
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 1'),
|
||||
ImportColumn::make('name2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 2')
|
||||
->examples(['Test 2', 'Test 5'])
|
||||
->label('Approver Name 2'),
|
||||
ImportColumn::make('mail2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mail 2')
|
||||
->examples(['test2@cripumps.com', 'test5@cripumps.com'])
|
||||
->label('Mail 2'),
|
||||
ImportColumn::make('duration2')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 2')
|
||||
->examples(['0.05', '0.30'])
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 2'),
|
||||
ImportColumn::make('name3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Name 3')
|
||||
->examples(['Test 3', 'Test 6'])
|
||||
->label('Approver Name 3'),
|
||||
ImportColumn::make('mail3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mail 3')
|
||||
->examples(['test3@cripumps.com', 'test6@cripumps.com'])
|
||||
->label('Mail 3'),
|
||||
ImportColumn::make('duration3')
|
||||
->numeric()
|
||||
->requiredMapping()
|
||||
->exampleHeader('Duration 3')
|
||||
->examples(['0.05', '0.30'])
|
||||
->examples(['0.05','0.30'])
|
||||
->label('Duration 3'),
|
||||
ImportColumn::make('characteristic_field')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Characteristic Field')
|
||||
->examples(['MV SERIES','PV SERIES'])
|
||||
->label('Characteristic Field'),
|
||||
ImportColumn::make('approver_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Approver Type')
|
||||
->examples(['Characteristic','Quality'])
|
||||
->label('Approver Type'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -106,132 +101,15 @@ class CharacteristicApproverMasterImporter extends Importer
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
$warnMsg = [];
|
||||
$plantCod = trim($this->data['plant']) ?? null;
|
||||
$workCenter = trim($this->data['machine']) ?? null;
|
||||
$apprTyp = trim($this->data['approver_type']) ?? null;
|
||||
$machineNam = trim($this->data['machine_name']) ?? null;
|
||||
$mastCharFld = trim($this->data['characteristic_field']) ?? null; // zmm_pumpseries
|
||||
$apprNam1 = trim($this->data['name1']) ?? null;
|
||||
$apprMail1 = trim($this->data['mail1']) ?? null;
|
||||
$apprDur1 = trim($this->data['duration1']) ?? 0.01;
|
||||
$apprNam2 = trim($this->data['name2']) ?? null;
|
||||
$apprMail2 = trim($this->data['mail2']) ?? null;
|
||||
$apprDur2 = trim($this->data['duration2']) ?? 0.01;
|
||||
$apprNam3 = trim($this->data['name3']) ?? null;
|
||||
$apprMail3 = trim($this->data['mail3']) ?? null;
|
||||
$apprDur3 = trim($this->data['duration3']) ?? 0.01;
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = $createdBy;
|
||||
|
||||
$plantId = null;
|
||||
$machineId = null;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = "Plant code can't be empty!";
|
||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found!';
|
||||
}
|
||||
if ($workCenter == null || $workCenter == '') {
|
||||
$warnMsg[] = "Work center can't be empty!";
|
||||
}
|
||||
if ($apprTyp == '' || $apprTyp == null || ($apprTyp != 'Characteristic' && $apprTyp != 'Quality')) {
|
||||
$warnMsg[] = "Approver type must be either 'Characteristic' or 'Quality'!";
|
||||
}
|
||||
if ($machineNam == null || $machineNam == '') {
|
||||
$warnMsg[] = "Machine name can't be empty!";
|
||||
}
|
||||
if ($mastCharFld == null || $mastCharFld == '') {
|
||||
$mastCharFld = 'NIL';
|
||||
}
|
||||
if ($apprNam1 == null || $apprNam1 == '') {
|
||||
$warnMsg[] = "Approver name 1 can't be empty!";
|
||||
}
|
||||
if ($apprMail1 == null || $apprMail1 == '') {
|
||||
$warnMsg[] = "Approver email 1 can't be empty!";
|
||||
}
|
||||
if (! is_numeric($apprDur1)) {
|
||||
$warnMsg[] = 'Duration 1 must be a numeric value (HH.MM)!';
|
||||
}
|
||||
if ($apprDur2 != null && $apprDur2 != '' && ! is_numeric($apprDur2)) {
|
||||
$warnMsg[] = 'Duration 2 must be a numeric value (HH.MM)!';
|
||||
}
|
||||
if ($apprDur3 != null && $apprDur3 != '' && ! is_numeric($apprDur3)) {
|
||||
$warnMsg[] = 'Duration 3 must be a numeric value (HH.MM)!';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant code not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
|
||||
$machine = Machine::where('work_center', $workCenter)->first();
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work center not found!';
|
||||
} else {
|
||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->first();
|
||||
|
||||
if (! $machine) {
|
||||
$warnMsg[] = 'Work center not found for the given plant!';
|
||||
} else {
|
||||
$machineId = $machine->id;
|
||||
}
|
||||
}
|
||||
|
||||
$getCreatedBy = CharacteristicApproverMaster::where('plant_id', $plantId)
|
||||
->where('machine_id', $machineId)
|
||||
->where('approver_type', $apprTyp)
|
||||
->where('machine_name', $machineNam)
|
||||
->where('characteristic_field', $mastCharFld)
|
||||
->first()?->created_by;
|
||||
|
||||
if ($getCreatedBy) {
|
||||
$createdBy = $getCreatedBy;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
CharacteristicApproverMaster::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
'machine_id' => $machineId,
|
||||
'approver_type' => $apprTyp,
|
||||
'machine_name' => $machineNam,
|
||||
'characteristic_field' => $mastCharFld,
|
||||
],
|
||||
[
|
||||
'name1' => $apprNam1,
|
||||
'mail1' => $apprMail1,
|
||||
'duration1' => $apprDur1,
|
||||
'name2' => $apprNam2,
|
||||
'mail2' => $apprMail2,
|
||||
'duration2' => $apprDur2,
|
||||
'name3' => $apprNam3,
|
||||
'mail3' => $apprMail3,
|
||||
'duration3' => $apprDur3,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
|
||||
return null;
|
||||
|
||||
// return new CharacteristicApproverMaster;
|
||||
return new CharacteristicApproverMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your characteristic approver master import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
$body = 'Your characteristic approver 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.';
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -211,9 +211,9 @@ class MotorTestingMasterImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->exampleHeader('Plant')
|
||||
->example(['1000', '1010', '1020'])
|
||||
->label('Plant Code')
|
||||
->label('Plant')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
@@ -31,7 +30,7 @@ class ProcessOrderImporter extends Importer
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->exampleHeader('LINE NAME')
|
||||
->example('Poly Wrapped Wire SFG')
|
||||
->example(' Poly Wrapped Wire SFG')
|
||||
->label('LINE NAME')
|
||||
->relationship(resolveUsing: 'name'),
|
||||
ImportColumn::make('item')
|
||||
@@ -44,7 +43,7 @@ class ProcessOrderImporter extends Importer
|
||||
ImportColumn::make('process_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PROCESS ORDER')
|
||||
->example('202601123456')
|
||||
->example('2025002123456')
|
||||
->label('PROCESS ORDER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('order_quantity')
|
||||
@@ -53,9 +52,6 @@ class ProcessOrderImporter extends Importer
|
||||
->example('1000')
|
||||
->label('ORDER QUANTITY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_order_quantity')
|
||||
->exampleHeader('UPDATED ORDER QUANTITY')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ImportColumn::make('coil_number')
|
||||
->exampleHeader('COIL NUMBER')
|
||||
// ->example('01')
|
||||
@@ -105,16 +101,15 @@ class ProcessOrderImporter extends Importer
|
||||
$plant = null;
|
||||
$plantCod = trim($this->data['plant']) ?? '';
|
||||
$plantId = null;
|
||||
$item = null;
|
||||
$iCode = trim($this->data['item']) ?? '';
|
||||
$itemId = null;
|
||||
$lineNam = trim($this->data['line']) ?? '';
|
||||
$lineId = null;
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
$coilNo = trim($this->data['coil_number'] ?? '');
|
||||
$sfgNo = trim($this->data['sfg_number'] ?? '');
|
||||
$machineName = trim($this->data['machine_name'] ?? '');
|
||||
$orderQuan = trim($this->data['order_quantity'] ?? '');
|
||||
$updatedOrderQuan = trim($this->data['updated_order_quantity'] ?? '');
|
||||
$scrapQuan = trim($this->data['scrap_quantity'] ?? '');
|
||||
$reworkStatus = trim($this->data['rework_status'] ?? '');
|
||||
$recQuan = trim($this->data['received_quantity'] ?? '');
|
||||
@@ -133,10 +128,7 @@ class ProcessOrderImporter extends Importer
|
||||
if ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
|
||||
$warnMsg[] = 'Invalid machine name found!';
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
}
|
||||
if ($processOrder == null || $processOrder == '') {
|
||||
$warnMsg[] = "Process order can't be empty!";
|
||||
@@ -153,12 +145,6 @@ class ProcessOrderImporter extends Importer
|
||||
} elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) {
|
||||
$warnMsg[] = 'Invalid order quantity found!';
|
||||
}
|
||||
if ($updatedOrderQuan == null || $updatedOrderQuan == '' || $updatedOrderQuan == 0 || $updatedOrderQuan == '0') {
|
||||
$updatedOrderQuan = $orderQuan;
|
||||
} elseif (Str::length($updatedOrderQuan) >= 1 && ! is_numeric($updatedOrderQuan)) {
|
||||
$warnMsg[] = 'Invalid Updated order quantity found!';
|
||||
}
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
$coilNo = '0';
|
||||
}
|
||||
@@ -173,7 +159,7 @@ class ProcessOrderImporter extends Importer
|
||||
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
|
||||
$reworkStatus = 1;
|
||||
} else {
|
||||
$warnMsg[] = 'Invalid rework status found!';
|
||||
$warnMsg[] = 'Invalid rework status found';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
@@ -231,26 +217,14 @@ class ProcessOrderImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if ($plantId && $itemId && $lineId && $processOrder != '') {
|
||||
if ($plantId && $itemCode && $lineId && $processOrder != '') {
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code!';
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
}
|
||||
|
||||
// $masterExist = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
// if (! $masterExist) {
|
||||
// $warnMsg[] = 'Characteristics master not found for the given plant!';
|
||||
// } else {
|
||||
// $masterExist = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->where('item_id', $itemId)->first();
|
||||
|
||||
// if (! $masterExist) {
|
||||
// $warnMsg[] = 'Characteristics master not found for the given line!';
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
@@ -269,39 +243,6 @@ class ProcessOrderImporter extends Importer
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
$receivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->sum('received_quantity');
|
||||
|
||||
if ($existing) {
|
||||
$liveOrdQuan = (float) $existing->order_quantity;
|
||||
$liveUpdatedOrdQuan = (float) $existing->updated_order_quantity;
|
||||
|
||||
$allowedIncrease = $liveOrdQuan * 0.10;
|
||||
|
||||
$maxAllowedQty = $liveOrdQuan + $allowedIncrease;
|
||||
$minAllowedQty = $liveOrdQuan - $allowedIncrease;
|
||||
|
||||
if ($liveUpdatedOrdQuan > $maxAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $minAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $receivedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease below its received quantity {$receivedQty}!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) {
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
@@ -309,17 +250,6 @@ class ProcessOrderImporter extends Importer
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
// $existingProcess = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->first();
|
||||
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
if (! $existingCoil) {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
@@ -329,7 +259,6 @@ class ProcessOrderImporter extends Importer
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'sfg_number' => $sfgNo,
|
||||
@@ -359,16 +288,10 @@ class ProcessOrderImporter extends Importer
|
||||
}
|
||||
} else {
|
||||
$coilNo = '0';
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// // ->where('coil_number', $coilNo)
|
||||
// ->first();
|
||||
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
|
||||
ProcessOrder::create([
|
||||
@@ -378,7 +301,6 @@ class ProcessOrderImporter extends Importer
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => '0',
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => 0,
|
||||
'scrap_quantity' => 0,
|
||||
'created_by' => $createdBy,
|
||||
@@ -393,7 +315,6 @@ class ProcessOrderImporter extends Importer
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan ?? 0,
|
||||
'sfg_number' => $sfgNo,
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class ProductionCharacteristicImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ProductionCharacteristic::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('production_order'),
|
||||
ImportColumn::make('serial_number'),
|
||||
ImportColumn::make('characteristic_name'),
|
||||
ImportColumn::make('observed_value'),
|
||||
ImportColumn::make('status'),
|
||||
ImportColumn::make('inspection_status'),
|
||||
ImportColumn::make('remark'),
|
||||
ImportColumn::make('created_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionCharacteristic
|
||||
{
|
||||
// return ProductionCharacteristic::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ProductionCharacteristic();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your production characteristic import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@@ -10,117 +9,64 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Dashboard extends \Filament\Pages\Dashboard
|
||||
{
|
||||
use HasFiltersForm;
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift';
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
protected static string $view = 'filament.pages.dashboard';
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null
|
||||
]);
|
||||
}
|
||||
|
||||
// public function mount(): void
|
||||
// {
|
||||
// session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
// $this->filtersForm->fill([
|
||||
// 'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// // 'success_status' => null
|
||||
// ]);
|
||||
// }
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Store form state in 'filters'
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]); // fixed typo
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
}),
|
||||
]);
|
||||
|
||||
// public function filtersForm(Form $form): Form
|
||||
// {
|
||||
// return $form
|
||||
// ->statePath('filters') // Store form state in 'filters'
|
||||
// ->schema([
|
||||
// Select::make('plant')
|
||||
// ->label('Select Plant')
|
||||
// ->reactive()
|
||||
// // ->options(Plant::pluck('name', 'id'))
|
||||
// ->options(function (callable $get) {
|
||||
// $userHas = Filament::auth()->user()->plant_id;
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
// })
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['selected_plant' => $state]); // fixed typo
|
||||
// //$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// // Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
// }),
|
||||
}
|
||||
|
||||
// // Select::make('success_status')
|
||||
// // ->label('Select Status')
|
||||
// // ->options([
|
||||
// // 'Ok' => 'Ok',
|
||||
// // 'Not Ok' => 'Not Ok',
|
||||
// // ])
|
||||
// // ->reactive()
|
||||
// // ->afterStateUpdated(function ($state) {
|
||||
// // session(['success_status' => $state]);
|
||||
// // }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
// public static function getNavigationLabel(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getHeading(): string
|
||||
// {
|
||||
// return 'Production Line Count';
|
||||
// }
|
||||
|
||||
// public function getWidgets(): array
|
||||
// {
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// }
|
||||
|
||||
// public static function canAccess(): bool
|
||||
// {
|
||||
// return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
// }
|
||||
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Welcome';
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
if (CumulativeChart::canView()) {
|
||||
$widgets[] = CumulativeChart::class;
|
||||
}
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,124 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use App\Filament\Widgets\ProductionQuantityStat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Welcome extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-s-gift'; // 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.welcome';
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
protected static ?string $slug = 'production-line-count';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
// session()->forget(['from_date']);
|
||||
// session()->forget(['to_date']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
// 'from_date' => null,
|
||||
// 'to_date' => null,
|
||||
// 'success_status' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
// ->options(Plant::pluck('name', 'id'))
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['selected_plant' => $state]);
|
||||
//$this->dispatch('cumulativeChart'); // custom Livewire event
|
||||
// Reset success_status whenever plant changes
|
||||
// $set('success_status', null);
|
||||
// session()->forget('success_status');
|
||||
}),
|
||||
|
||||
// Select::make('success_status')
|
||||
// ->label('Select Status')
|
||||
// ->options([
|
||||
// 'Ok' => 'Ok',
|
||||
// 'Not Ok' => 'Not Ok',
|
||||
// ])
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state) {
|
||||
// session(['success_status' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_from')
|
||||
// ->label('Created From')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['from_date' => $state]);
|
||||
// }),
|
||||
|
||||
// DatePicker::make('created_to')
|
||||
// ->label('Created To')
|
||||
// ->reactive()
|
||||
// ->afterStateUpdated(function ($state,callable $set) {
|
||||
// session(['to_date' => $state]);
|
||||
// }),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Production Line Count';
|
||||
return '';
|
||||
}
|
||||
|
||||
// public function getWidgets(): array
|
||||
// public static function canAccess(): bool
|
||||
// {
|
||||
// $widgets = [];
|
||||
|
||||
// if (CumulativeChart::canView()) {
|
||||
// $widgets[] = CumulativeChart::class;
|
||||
|
||||
// }
|
||||
// return $widgets;
|
||||
// return Auth::check() && Auth::user()->can('view welcome page');
|
||||
// }
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CharacteristicApproverMasterResource extends Resource
|
||||
{
|
||||
@@ -84,7 +83,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->label('Machine')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->required()
|
||||
@@ -102,7 +101,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Select::make('approver_type')
|
||||
->label('Approver Type')
|
||||
->label('Request Type')
|
||||
->columnSpan(1)
|
||||
->reactive()
|
||||
->nullable()
|
||||
@@ -131,7 +130,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
// return optional(CharacteristicApproverMaster::latest()->first())->approver_type ?? null;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('characteristic_field', 'NIL');
|
||||
$set('characteristic_field', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('characteristic_field')
|
||||
@@ -150,14 +149,6 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
$set('characteristic_field', 'NIL');
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('characteristic_approver_masters', 'characteristic_field')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->where('machine_id', $get('machine_id'))
|
||||
->where('approver_type', trim($get('approver_type')))
|
||||
->where('machine_name', trim($get('machine_name')))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Section::make('Approver - 1')
|
||||
// ->description('Prevent abuse by limiting the number of requests per period')
|
||||
@@ -177,6 +168,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->required()
|
||||
->suffixIcon('heroicon-m-envelope')
|
||||
->suffixIconColor('primary')
|
||||
->email()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -213,6 +205,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->reactive()
|
||||
->suffixIcon('heroicon-m-envelope')
|
||||
->suffixIconColor('primary')
|
||||
->email()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -245,6 +238,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->reactive()
|
||||
->suffixIcon('heroicon-m-envelope')
|
||||
->suffixIconColor('primary')
|
||||
->email()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -290,7 +284,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
@@ -304,11 +298,6 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
->alignCenter()
|
||||
@@ -316,6 +305,11 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||
->extraAttributes(['class' => 'uppercase'])
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name1')
|
||||
->label('Approver Name 1')
|
||||
->alignCenter()
|
||||
|
||||
@@ -19,13 +19,12 @@ use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ConfigurationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Configuration::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-s-cog';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
@@ -108,16 +107,7 @@ class ConfigurationResource extends Resource
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('c_value')
|
||||
->label('Value')
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('configurations', 'c_value')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->where('line_id', $get('line_id'))
|
||||
->where('c_type', $get('c_type'))
|
||||
->where('c_group', $get('c_group'))
|
||||
->where('c_name', $get('c_name'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||
use App\Filament\Exports\AxnExporter;
|
||||
use App\Filament\Exports\InvoiceValidationExporter;
|
||||
use App\Filament\Imports\InvoiceValidationImporter;
|
||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||
@@ -1142,13 +1141,6 @@ class InvoiceValidationResource extends Resource
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export invoice');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Axn')
|
||||
->color('warning')
|
||||
->exporter(AxnExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export axn invoice');
|
||||
}),
|
||||
])
|
||||
|
||||
->filters([
|
||||
|
||||
@@ -48,12 +48,10 @@ class ItemResource extends Resource
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
// ->preload()
|
||||
// ->nullable(),
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
@@ -193,7 +191,7 @@ class ItemResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -232,7 +230,8 @@ class ItemResource extends Resource
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
@@ -247,21 +246,13 @@ class ItemResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('items', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('code', null);
|
||||
@@ -328,23 +319,11 @@ class ItemResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['uom'])) {
|
||||
if ($data['uom'] == 'empty') {
|
||||
$query->where(function ($q) {
|
||||
$q->where('uom', '')->orWhereNull('uom');
|
||||
});
|
||||
} else {
|
||||
$query->where('uom', 'like', '%'.$data['uom'].'%');
|
||||
}
|
||||
$query->where('uom', 'like', '%'.$data['uom'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['category'])) {
|
||||
if ($data['category'] == 'empty') {
|
||||
$query->where(function ($q) {
|
||||
$q->where('category', '')->orWhereNull('category');
|
||||
});
|
||||
} else {
|
||||
$query->where('category', '%'.$data['category'].'%');
|
||||
}
|
||||
$query->where('category', '%'.$data['category'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
@@ -377,11 +356,11 @@ class ItemResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['uom'])) {
|
||||
$indicators[] = ($data['uom'] == 'empty') ? "UOM: ''" : 'UOM: '.$data['uom'];
|
||||
$indicators[] = 'UOM: '.$data['uom'];
|
||||
}
|
||||
|
||||
if (! empty($data['category'])) {
|
||||
$indicators[] = ($data['category'] == 'empty') ? "Category: ''" : 'Category: '.$data['category'];
|
||||
$indicators[] = 'Category: '.$data['category'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
|
||||
@@ -42,10 +42,9 @@ class MotorTestingMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
@@ -65,8 +64,6 @@ class MotorTestingMasterResource extends Resource
|
||||
} else {
|
||||
$set('mTmError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('mTmError') ? 'border-red-500' : '',
|
||||
@@ -77,9 +74,6 @@ class MotorTestingMasterResource extends Resource
|
||||
->label('Routine Test Time')
|
||||
->default('00:40:00')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
@@ -90,27 +84,13 @@ class MotorTestingMasterResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! $get('id')) {
|
||||
// whereHas
|
||||
return Item::where('plant_id', $plantId)->whereDoesntHave('motorTestingMasters')->pluck('code', 'id');
|
||||
} else {
|
||||
$itemId = MotorTestingMaster::where('id', $get('id'))->first()?->item_id;
|
||||
|
||||
return Item::where('plant_id', $plantId)
|
||||
->where(function ($query) use ($itemId) {
|
||||
$query->whereDoesntHave('motorTestingMasters')
|
||||
->orWhere('id', $itemId);
|
||||
})
|
||||
->pluck('code', 'id');
|
||||
}
|
||||
// return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray();
|
||||
return Item::where('plant_id', $plantId)
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('motor_testing_masters', 'item_id')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
@@ -118,7 +98,7 @@ class MotorTestingMasterResource extends Resource
|
||||
}),
|
||||
Forms\Components\TextInput::make('subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
// ->required()
|
||||
->required()
|
||||
->placeholder('Scan the valid code')
|
||||
->reactive()
|
||||
->alphaNum()
|
||||
@@ -142,8 +122,6 @@ class MotorTestingMasterResource extends Resource
|
||||
}
|
||||
$set('iCodeError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('iCodeError') ? 'border-red-500' : '',
|
||||
@@ -160,9 +138,6 @@ class MotorTestingMasterResource extends Resource
|
||||
->selectablePlaceholder(false)
|
||||
->default(1)
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('phase')
|
||||
->label('Phase')
|
||||
@@ -184,57 +159,35 @@ class MotorTestingMasterResource extends Resource
|
||||
})
|
||||
->selectablePlaceholder(false)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
|
||||
if ($state == 'Single' && $get('connection') == 'Star-Delta') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default('Single')
|
||||
->required()
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('hp')
|
||||
->label('HP')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('kw')
|
||||
->label('KW')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('volt')
|
||||
->label('Volt')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('current')
|
||||
->label('Current')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('rpm')
|
||||
->label('RPM')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('torque')
|
||||
->label('Torque')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('frequency')
|
||||
->label('Frequency')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\Select::make('connection')
|
||||
->label('Connection')
|
||||
->selectablePlaceholder(false)
|
||||
@@ -257,17 +210,12 @@ class MotorTestingMasterResource extends Resource
|
||||
if ($state == 'Star-Delta') {
|
||||
$set('phase', 'Three');
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->default('Star')
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('ins_res_limit')
|
||||
->label('Insulation Resistance Limit')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('ins_res_type')
|
||||
->label('Insulation Resistance Type')
|
||||
@@ -288,106 +236,55 @@ class MotorTestingMasterResource extends Resource
|
||||
->toArray();
|
||||
}
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('res_ry_ll')
|
||||
->label('Resistance RY LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('res_ry_ul')
|
||||
->label('Resistance RY UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('res_yb_ll')
|
||||
->label('Resistance YB LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('res_yb_ul')
|
||||
->label('Resistance YB UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('res_br_ll')
|
||||
->label('Resistance BR LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('res_br_ul')
|
||||
->label('Resistance BR UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('lock_volt_limit')
|
||||
->label('Lock Volt Limit')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('leak_cur_limit')
|
||||
->label('Leakage Current Limit')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('lock_cur_ll')
|
||||
->label('Lock Current LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('lock_cur_ul')
|
||||
->label('Lock Current UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('noload_cur_ll')
|
||||
->label('No Load Current LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('noload_cur_ul')
|
||||
->label('No Load Current UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('noload_pow_ll')
|
||||
->label('No Load Power LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('noload_pow_ul')
|
||||
->label('No Load Power UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('noload_spd_ll')
|
||||
->label('No Load Speed LL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('noload_spd_ul')
|
||||
->label('No Load Speed UL')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
@@ -414,7 +311,7 @@ class MotorTestingMasterResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
@@ -561,26 +458,17 @@ class MotorTestingMasterResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
// ->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
// })
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('motorTestingMasters', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('isi_type', null);
|
||||
@@ -793,7 +681,7 @@ class MotorTestingMasterResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\NotInStockExporter;
|
||||
use App\Filament\Imports\NotInStockImporter;
|
||||
use App\Filament\Resources\NotInStockResource\Pages;
|
||||
use App\Models\NotInStock;
|
||||
use App\Models\StickerMaster;
|
||||
@@ -15,9 +13,6 @@ use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
|
||||
|
||||
class NotInStockResource extends Resource
|
||||
{
|
||||
@@ -237,22 +232,6 @@ class NotInStockResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import Not In Stock')
|
||||
->color('warning')
|
||||
->importer(NotInStockImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import not in stock');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Not In Stock')
|
||||
->color('warning')
|
||||
->exporter(NotInStockExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export not in stock');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -273,7 +252,6 @@ class NotInStockResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
|
||||
@@ -9,7 +9,6 @@ use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProcessOrder;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
@@ -75,7 +74,6 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -115,7 +113,6 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -131,14 +128,10 @@ class ProcessOrderResource extends Resource
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
// $lineId = $get('line_id');
|
||||
if (empty($plantId)) {// || empty($lineId)
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// $availItems = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->pluck('item_id', 'item_id')->toArray();
|
||||
|
||||
// return Item::where('plant_id', $plantId)->whereIn('id', $availItems)->pluck('code', 'id');
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
@@ -148,7 +141,6 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -225,7 +217,6 @@ class ProcessOrderResource extends Resource
|
||||
$plantId = $get('plant_id');
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -378,11 +369,9 @@ class ProcessOrderResource extends Resource
|
||||
$itemId = $get('item_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$set('received_quantity', '0');
|
||||
// $set('updated_order_quantity', $state);
|
||||
$set('scrap_quantity', '0');
|
||||
if (! $plantId || ! $itemId || ! $processOrder) {
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
}
|
||||
|
||||
$query = ProcessOrder::where('plant_id', $plantId)
|
||||
@@ -398,47 +387,6 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('updated_order_quantity')
|
||||
->label('Updated Order Quantity')
|
||||
->required()
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == '' || trim($get('order_quantity')) == '' || trim($get('order_quantity')) == null))
|
||||
->reactive()
|
||||
->rules([
|
||||
function (callable $get): Closure {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$receivedQty = $get('received_quantity');
|
||||
|
||||
$currentId = $get('id');
|
||||
|
||||
$orderQty = (float) $get('order_quantity');
|
||||
$updatedQty = (float) $value;
|
||||
|
||||
$allowedVariance = $orderQty * 0.10;
|
||||
|
||||
$maxAllowed = $orderQty + $allowedVariance;
|
||||
$minAllowed = $orderQty - $allowedVariance;
|
||||
|
||||
if ($updatedQty > $maxAllowed || $updatedQty < $minAllowed) {
|
||||
$fail('Quantity can vary by ±10% of the order quantity.');
|
||||
}
|
||||
|
||||
$otherReceivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->when($currentId, fn ($q) => $q->where('id', '!=', $currentId))
|
||||
->sum('received_quantity');
|
||||
|
||||
$currentReceivedQty = (float) $get('received_quantity');
|
||||
|
||||
$totalReceivedQty = $otherReceivedQty + $currentReceivedQty;
|
||||
|
||||
if ($updatedQty < $totalReceivedQty) {
|
||||
$fail("You cannot set quantity below received quantity ({$totalReceivedQty}).");
|
||||
}
|
||||
};
|
||||
},
|
||||
]),
|
||||
Forms\Components\TextInput::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->default('0.000')
|
||||
@@ -461,8 +409,7 @@ class ProcessOrderResource extends Resource
|
||||
->where('item_id', $itemId)->latest()->first();
|
||||
|
||||
if ($orderExist) {
|
||||
// $orderQty = $orderExist->order_quantity ?? 0;
|
||||
$orderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
$orderQty = $orderExist->order_quantity ?? 0;
|
||||
|
||||
$alreadyReceived = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
@@ -636,7 +583,6 @@ class ProcessOrderResource extends Resource
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->reactive()
|
||||
->maxLength(18)
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
@@ -728,7 +674,6 @@ class ProcessOrderResource extends Resource
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
$originalName = $uploaded->getClientOriginalName();
|
||||
$path = 'uploads/ProcessOrder/'.$originalName;
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
// Check if file already exists
|
||||
if (Storage::disk('local')->exists($path)) {
|
||||
@@ -766,34 +711,34 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
|
||||
// Get the value of process_order field
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if ($batchId != $processOrder) {
|
||||
Notification::make()
|
||||
->title('Mismatch')
|
||||
->body("Batch ID ($batchId) does not match Process Order ($processOrder)")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
// if ($batchId != $processOrder) {
|
||||
// Notification::make()
|
||||
// ->title('Mismatch')
|
||||
// ->body("Batch ID ($batchId) does not match Process Order ($processOrder)")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if ($batchId == $processOrder) {
|
||||
if ($batchId == $processOrder) {
|
||||
// If batch matches, store the PDF permanently
|
||||
$storedPath = $uploaded->storeAs(
|
||||
'uploads/ProcessOrder',
|
||||
$processOrder,
|
||||
$originalName,
|
||||
'local'
|
||||
);
|
||||
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Process Order: $processOrder. PDF uploaded successfully.")
|
||||
->body("Batch ID matches Process Order: $batchId. PDF uploaded successfully.")
|
||||
->success()
|
||||
->send();
|
||||
|
||||
return;
|
||||
// }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Notification::make()
|
||||
@@ -910,11 +855,6 @@ class ProcessOrderResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_order_quantity')
|
||||
->label('Updated Order Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->alignCenter()
|
||||
|
||||
@@ -3,28 +3,10 @@
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use App\Models\ProcessOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProcessOrder extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$plantId = $this->data['plant_id'];
|
||||
$processOrder = $this->data['process_order'];
|
||||
$updatedQty = (float) $this->data['updated_order_quantity'];
|
||||
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->update([
|
||||
'updated_order_quantity' => $updatedQty,
|
||||
'updated_by' => Filament::auth()->user()->name,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,78 +3,13 @@
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use App\Models\ProcessOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProcessOrder extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function beforeSave(): void
|
||||
{
|
||||
$plantId = $this->data['plant_id'] ?? null;
|
||||
$processOrder = $this->data['process_order'] ?? null;
|
||||
$extraQty = (float) ($this->data['updated_order_quantity'] ?? 0);
|
||||
$extraQtyRaw = $this->data['updated_order_quantity'] ?? '';
|
||||
|
||||
if (!preg_match('/^\d+(\.\d{1,3})?$/', $extraQtyRaw)) {
|
||||
Notification::make()
|
||||
->title('Invalid Quantity')
|
||||
->body('Only positive numbers with up to 3 decimal places are allowed.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt(); // stop save
|
||||
}
|
||||
|
||||
if ($extraQty < 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid Quantity')
|
||||
->body('Negative values are not allowed.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
if ($extraQty > 0) {
|
||||
|
||||
$order = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($order) {
|
||||
|
||||
$baseQty = (float) $order->order_quantity;
|
||||
$maxAllowed = $baseQty * 0.10;
|
||||
|
||||
$maxFinalQty = $baseQty + $maxAllowed;
|
||||
|
||||
if ($extraQty > $maxFinalQty) {
|
||||
Notification::make()
|
||||
->title('Limit Exceeded')
|
||||
->body("You can only increase the order by 10% (Max allowed: {$maxFinalQty}).")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt(); // stops save
|
||||
}
|
||||
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->update([
|
||||
'updated_order_quantity' => $extraQty,
|
||||
'updated_by' => Filament::auth()->user()?->name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -1,603 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\ProductionCharacteristicExporter;
|
||||
use App\Filament\Imports\ProductionCharacteristicImporter;
|
||||
use App\Filament\Resources\ProductionCharacteristicResource\Pages;
|
||||
use App\Filament\Resources\ProductionCharacteristicResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Get;
|
||||
use Str;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
|
||||
class ProductionCharacteristicResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ProductionCharacteristic::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->default(function () {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(ProductionCharacteristic::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('line_id', null);
|
||||
$set('item_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('production_order', null);
|
||||
$set('serial_number', null);
|
||||
$set('observed_value', null);
|
||||
$set('status', 'NotOk');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('poPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('poPlantError') ? $get('poPlantError') : null)
|
||||
->hintColor('danger')
|
||||
->required(),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('item_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('production_order', null);
|
||||
$set('serial_number', null);
|
||||
$set('observed_value', null);
|
||||
$set('status', 'NotOk');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
if (! $plantId) {
|
||||
$set('line_id', null);
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id') || ! $get('line_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $get('plant_id'))
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('machine_id', null);
|
||||
$set('production_order', null);
|
||||
$set('serial_number', null);
|
||||
$set('observed_value', null);
|
||||
$set('status', 'NotOk');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
if (! $plantId) {
|
||||
$set('item_id', null);
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id') || ! $get('line_id') || ! $get('item_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::where('plant_id', $get('plant_id'))
|
||||
->where('line_id', $get('line_id'))
|
||||
->pluck('work_center', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$set('production_order', null);
|
||||
$set('serial_number', null);
|
||||
$set('observed_value', null);
|
||||
$set('status', 'NotOk');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
if (! $plantId) {
|
||||
$set('machine_id', null);
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
}
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('production_order')
|
||||
->label('Production Order'),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number'),
|
||||
Forms\Components\TextInput::make('characteristic_name')
|
||||
->label('Characteristic Name'),
|
||||
Forms\Components\TextInput::make('observed_value')
|
||||
->label('Observed Value'),
|
||||
Forms\Components\Select::make('status')
|
||||
->label('Status')
|
||||
->options([
|
||||
'Ok' => 'Ok',
|
||||
'NotOk' => 'Not Ok',
|
||||
'ConditionallyAccepted' => 'Conditionally Accepted',
|
||||
])
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('inspection_status')
|
||||
->label('Inspection Status'),
|
||||
Forms\Components\TextInput::make('remark')
|
||||
->label('Remark')
|
||||
->reactive()
|
||||
->required(fn ($get) => $get('status') == 'ConditionallyAccepted')
|
||||
->visible(fn ($get) => $get('status') == 'ConditionallyAccepted'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By'),
|
||||
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 Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Item Description')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('production_order')
|
||||
->label('Production Order')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_name')
|
||||
->label('Characteristic Name')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('machine.name')
|
||||
->label('Spec. Value')
|
||||
// ->searchable()
|
||||
->formatStateUsing(function ($record) {
|
||||
$specVal = ProductCharacteristicsMaster::where('plant_id', $record->plant_id)->where('item_id', $record->item_id)->where('line_id', $record->line_id)->where('machine_id', $record->machine_id)->first();
|
||||
|
||||
// return $record?->plant_id.'-'.$record?->item_id.'-'.$record->line_id.'-'.$record?->machine_id;
|
||||
return $specVal?->lower.' - '.$specVal?->upper;
|
||||
})
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('observed_value')
|
||||
->label('Observed Value')
|
||||
->searchable()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Status')
|
||||
->searchable()
|
||||
// ->formatStateUsing(function ($record) {
|
||||
// return empty($record->status == 'Ok') ? 'Ok' : 'Not Ok';
|
||||
// })
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'Ok' => 'success',
|
||||
'Not Ok' => 'danger',
|
||||
'NotOk' => 'danger',
|
||||
'ConditionallyAccepted' => 'success',
|
||||
default => 'gray',
|
||||
})
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('inspection_status')
|
||||
// ->label('Inspection Status')
|
||||
// ->searchable()
|
||||
// ->color(fn (string $state): string => match ($state) {
|
||||
// 'Ok' => 'success',
|
||||
// 'Not Ok' => 'danger',
|
||||
// 'NotOk' => 'danger',
|
||||
// default => 'gray',
|
||||
// })
|
||||
// ->alignCenter()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('remark')
|
||||
->label('Remark')
|
||||
->searchable()
|
||||
->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(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('productionCharacteristics', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('Item', null);
|
||||
$set('Line', null);
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::whereHas('productionCharacteristics', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('name', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('process_order', null);
|
||||
}),
|
||||
Select::make('Item')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('productionCharacteristics', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('production_order', null);
|
||||
}),
|
||||
Select::make('Machine')
|
||||
->label('Search by Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::whereHas('productionCharacteristics', function ($query) use ($plantId, $lineId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId)->where('line_id', $lineId);
|
||||
}
|
||||
})->pluck('work_center', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('production_order', null);
|
||||
}),
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->placeholder('Enter Production Order')
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('serial_number', null);
|
||||
}),
|
||||
TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Serial Number'),
|
||||
Select::make('status')
|
||||
->label('Search by Status')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options([
|
||||
'Ok' => 'Ok',
|
||||
'NotOk' => 'Not Ok',
|
||||
'ConditionallyAccepted' => 'Conditionally Accepted',
|
||||
]),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['production_order']) && Str::length($data['serial_number']) <= 0 && ($data['status'] == null || $data['status'] == '') && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$query->where('line_id', $data['Line']);
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$query->where('item_id', $data['Item']);
|
||||
}
|
||||
|
||||
if (! empty($data['Machine'])) {
|
||||
$query->where('machine_id', $data['Machine']);
|
||||
}
|
||||
|
||||
if (! empty($data['production_order'])) {
|
||||
$query->where('production_order', 'like', '%'.$data['production_order'].'%');
|
||||
}
|
||||
|
||||
if (Str::length($data['serial_number']) > 0) {
|
||||
// $query->where('machine_name', $data['machine_name']);
|
||||
$query->where('serial_number', 'like', '%'.$data['serial_number'].'%');
|
||||
}
|
||||
|
||||
if ($data['status'] != null && $data['status'] != '') {
|
||||
$query->where('status', $data['status']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
// $query->orderBy('created_at', 'asc');
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant Name: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
|
||||
if (! empty($data['Item'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['Machine'])) {
|
||||
$indicators[] = 'Machine: '.Machine::where('id', $data['Machine'])->value('work_center');
|
||||
}
|
||||
|
||||
if (! empty($data['production_order'])) {
|
||||
$indicators[] = 'Production Order: '.$data['production_order'];
|
||||
}
|
||||
|
||||
if (Str::length($data['serial_number']) > 0) {
|
||||
$indicators[] = 'Serial Number: '.$data['serial_number'];
|
||||
}
|
||||
|
||||
// if ($data['status'] != null && $data['status'] != '') {
|
||||
// $indicators[] = ($data['status'] == 'Ok') ? 'Status: Ok' : 'Status: Not Ok';
|
||||
// }
|
||||
|
||||
if ($data['status'] != null && $data['status'] != '') {
|
||||
if ($data['status'] == 'Ok') {
|
||||
$indicators[] = 'Status: Ok';
|
||||
} elseif ($data['status'] == 'NotOk') {
|
||||
$indicators[] = 'Status: Not Ok';
|
||||
} elseif ($data['status'] == 'ConditionallyAccepted') {
|
||||
$indicators[] = 'Status: Conditionally Accepted';
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
->label('Import Production Characteristics')
|
||||
->color('warning')
|
||||
->importer(ProductionCharacteristicImporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import production characteristics');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export Production Characteristics')
|
||||
->color('warning')
|
||||
->exporter(ProductionCharacteristicExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export production characteristics');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListProductionCharacteristics::route('/'),
|
||||
'create' => Pages\CreateProductionCharacteristic::route('/create'),
|
||||
'view' => Pages\ViewProductionCharacteristic::route('/{record}'),
|
||||
'edit' => Pages\EditProductionCharacteristic::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProductionCharacteristic extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProductionCharacteristicResource::class;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProductionCharacteristic extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProductionCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListProductionCharacteristics extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProductionCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ProductionCharacteristicResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProductionCharacteristicResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProductionCharacteristic extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProductionCharacteristicResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -92,12 +92,7 @@ class QualityValidationResource extends Resource
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Hidden::make('plant')
|
||||
->default(fn () => session('last_selected_plant_id'))
|
||||
->afterStateHydrated(function ($state, $set) {
|
||||
if (!$state && request()->has('plant_id')) {
|
||||
$set('plant_id', request()->get('plant_id'));
|
||||
}
|
||||
}),
|
||||
->default(fn () => session('last_selected_plant_id')),
|
||||
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
@@ -134,12 +129,7 @@ class QualityValidationResource extends Resource
|
||||
->hint(fn ($get) => $get('pqLineError') ? $get('pqLineError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Hidden::make('line')
|
||||
->default(fn () => session('last_selected_line'))
|
||||
->afterStateHydrated(function ($state, $set) {
|
||||
if (!$state && request()->has('line_id')) {
|
||||
$set('line_id', request()->get('line_id'));
|
||||
}
|
||||
}),
|
||||
->default(fn () => session('last_selected_line')),
|
||||
Forms\Components\Hidden::make('sticker_master_id')
|
||||
// ->relationship('stickerMaster', 'id')
|
||||
->required(),
|
||||
@@ -176,12 +166,7 @@ class QualityValidationResource extends Resource
|
||||
->required(),
|
||||
|
||||
Forms\Components\Hidden::make('production')
|
||||
->default(fn () => session('last_selected_production'))
|
||||
->afterStateHydrated(function ($state, $set) {
|
||||
if (!$state && request()->has('production_order')) {
|
||||
$set('production_order', request()->get('production_order'));
|
||||
}
|
||||
}),
|
||||
->default(fn () => session('last_selected_production')),
|
||||
|
||||
Forms\Components\Hidden::make('operator_id')
|
||||
->required()
|
||||
@@ -217,7 +202,6 @@ class QualityValidationResource extends Resource
|
||||
|
||||
Forms\Components\TextInput::make('item_id')
|
||||
->label('Item Code')
|
||||
// ->id('item_id')
|
||||
->placeholder('Scan the valid QR code')
|
||||
->reactive()
|
||||
->required()
|
||||
@@ -584,18 +568,10 @@ class QualityValidationResource extends Resource
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('validationError') ? 'border-red-500' : '',
|
||||
'id' => 'item_id',
|
||||
'onkeydown' => "if (event.key === 'Enter') { event.preventDefault(); event.stopPropagation(); return false; }",
|
||||
])
|
||||
// ->extraAttributes(fn ($get) => [
|
||||
// 'class' => $get('validationError') ? 'border-red-500' : '',
|
||||
// ])
|
||||
// ->extraAttributes([
|
||||
// 'onkeydown' => "if (event.key == 'Enter') { event.preventDefault(); return false; }",
|
||||
// ])
|
||||
// ->extraAttributes([
|
||||
// 'id' => 'item_id'
|
||||
// ])
|
||||
->extraAttributes([
|
||||
'onkeydown' => "if (event.key === 'Enter') { event.preventDefault(); return false; }",
|
||||
])
|
||||
->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
@@ -2402,7 +2378,6 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
$expectedValue = $stickerMaster->part_validation1;
|
||||
$mExpectedValue = $expectedValue ?? null;
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('part_validation1_error', null);
|
||||
@@ -2423,11 +2398,10 @@ class QualityValidationResource extends Resource
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, $mExpectedValue, 'InvalidPartNumber')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
@@ -2501,7 +2475,6 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
$expectedValue = $stickerMaster->part_validation2;
|
||||
$mExpectedValue = $expectedValue ?? null;
|
||||
|
||||
if ($state == null || trim($state) == '') {
|
||||
$set('part_validation2_error', null);
|
||||
@@ -2519,11 +2492,10 @@ class QualityValidationResource extends Resource
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, $mExpectedValue, 'InvalidPartNumber2')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber2')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
@@ -2604,7 +2576,6 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
$expectedValue = $stickerMaster->part_validation3;
|
||||
$mExpectedValue = $expectedValue ?? null;
|
||||
|
||||
if ($state == $expectedValue) {
|
||||
$set('part_validation3_error', null);
|
||||
@@ -2619,7 +2590,7 @@ class QualityValidationResource extends Resource
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, $mExpectedValue, 'InvalidPartNumber3')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber3')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
@@ -2692,7 +2663,6 @@ class QualityValidationResource extends Resource
|
||||
}
|
||||
|
||||
$expectedValue = $stickerMaster->part_validation4;
|
||||
$mExpectedValue = $expectedValue ?? null;
|
||||
|
||||
// If input is empty, reset the error
|
||||
if ($state == null || trim($state) == '') {
|
||||
@@ -2711,11 +2681,10 @@ class QualityValidationResource extends Resource
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
|
||||
|
||||
if (! empty($emails)) {
|
||||
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
|
||||
Mail::to($emails)->send(
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, $mExpectedValue, 'InvalidPartNumber4')
|
||||
new InvalidQualityMail($state, $mPorder, $mPlantName, $mLinePart, $mUserName, 'InvalidPartNumber4')
|
||||
);
|
||||
} else {
|
||||
\Log::warning("No recipients found for plant {$mPlantName}, module Serial, rule invalid_serial.");
|
||||
@@ -2854,31 +2823,12 @@ class QualityValidationResource extends Resource
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
|
||||
Forms\Components\View::make('components.production-checklist-wrapper')
|
||||
->visible(fn ($livewire) => $livewire->showChecklist)
|
||||
->statePath('checklist')
|
||||
->viewData(fn ($livewire) => [
|
||||
'existingRecords' => $livewire->existingRecords->toArray(),
|
||||
'data' => $livewire->data,
|
||||
'showChecklist' => $livewire->showChecklist,
|
||||
]),
|
||||
|
||||
// Forms\Components\View::make('components.production-checklist-wrapper')
|
||||
// ->statePath('checklist')
|
||||
// ->key('checklist-view')
|
||||
// ->viewData(fn ($livewire) => [
|
||||
// 'existingRecords' => is_array($livewire->existingRecords)
|
||||
// ? $livewire->existingRecords
|
||||
// : $livewire->existingRecords->toArray(),
|
||||
// 'showChecklist' => $livewire->showChecklist,
|
||||
// ]),
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getMailData($plantId)
|
||||
{
|
||||
|
||||
$globalEmails = AlertMailRule::where('plant', 0)
|
||||
->where('module', 'QualityValidation')
|
||||
->where('rule_name', 'QualityMail')
|
||||
@@ -3290,6 +3240,7 @@ class QualityValidationResource extends Resource
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -3,50 +3,18 @@
|
||||
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\QualityValidationResource;
|
||||
use App\Livewire\ProductionCheckList;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use App\Models\QualityValidation;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class CreateQualityValidation extends CreateRecord
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
public $showChecklist = false;
|
||||
public $checklist;
|
||||
|
||||
public $skipChecklistValidation = false;
|
||||
|
||||
public bool $shouldSkipChecklist = false;
|
||||
|
||||
public $existingRecords = [];
|
||||
|
||||
protected $listeners = [
|
||||
'checklistUpdated' => 'setChecklist',
|
||||
'checklist-cancelled' => 'handleChecklistCancel',
|
||||
'checklist-saved' => 'checkListSaved',
|
||||
'trigger-create' => 'doCreate',
|
||||
];
|
||||
|
||||
public function setChecklist($checklist)
|
||||
{
|
||||
$this->data['checklist'] = $checklist;
|
||||
}
|
||||
|
||||
public function doCreate()
|
||||
{
|
||||
$this->create();
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
parent::mount();
|
||||
|
||||
session()->forget([
|
||||
'last_selected_plant_id',
|
||||
'last_selected_line',
|
||||
@@ -54,68 +22,6 @@ class CreateQualityValidation extends CreateRecord
|
||||
]);
|
||||
}
|
||||
|
||||
public function handleChecklistCancel()
|
||||
{
|
||||
$this->skipChecklistValidation = true;
|
||||
$this->showChecklist = false;
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
if ($this->shouldSkipChecklist) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ($this->checkIfHasCharacteristics($data)) {
|
||||
$this->showChecklist = true;
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkIfHasCharacteristics(array $data)
|
||||
{
|
||||
$plantId = $data['plant_id'] ?? null;
|
||||
$itemCode = $data['item_id'] ?? null;
|
||||
$lineId = $data['line_id'] ?? null;
|
||||
|
||||
if (!$plantId || !$itemCode || !$lineId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = \App\Models\Item::where('code', $itemCode)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (!$item) {
|
||||
$this->existingRecords = collect();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plantId)
|
||||
->where('item_id', $item->id)
|
||||
->where('line_id', $lineId)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function checkListSaved()
|
||||
{
|
||||
$this->showChecklist = false;
|
||||
|
||||
$plantId = $this->data['plant_id'] ?? null;
|
||||
$lineId = $this->data['line_id'] ?? null;
|
||||
$productionOrder = $this->data['production_order'] ?? null;
|
||||
|
||||
return redirect()->to(
|
||||
static::getResource()::getUrl('create', [
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
'production_order' => $this->data['production_order'] ?? null,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
protected function beforeCreate(): void
|
||||
{
|
||||
@@ -192,82 +98,18 @@ class CreateQualityValidation extends CreateRecord
|
||||
$errors['part_validation5_error'] = ['Fix the errors before submitting.'];
|
||||
}
|
||||
|
||||
|
||||
if (!empty($errors)) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
|
||||
$this->checkExisting();
|
||||
|
||||
$checklist = $this->data['data']['checklist'] ?? [];
|
||||
|
||||
if (count($this->existingRecords) > 0){
|
||||
$this->showChecklist = true;
|
||||
$this->halt();
|
||||
}
|
||||
else{
|
||||
$this->showChecklist = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkExisting()
|
||||
{
|
||||
$plant_id = $this->data['plant_id'] ?? null;
|
||||
$item_code = $this->data['item_id'] ?? null;
|
||||
$line_id = $this->data['line_id'] ?? null;
|
||||
|
||||
|
||||
$item = \App\Models\Item::where('code', $item_code)->where('plant_id', $plant_id)->first();
|
||||
|
||||
if (!$item) {
|
||||
$this->existingRecords = collect();
|
||||
return;
|
||||
}
|
||||
|
||||
$item_id = $item->id;
|
||||
|
||||
$this->existingRecords = ProductCharacteristicsMaster::where('plant_id', $plant_id)
|
||||
->where('item_id', $item_id)
|
||||
->where('line_id', $line_id)
|
||||
->get();
|
||||
}
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
// Get the value from the hidden field 'plant'
|
||||
// Get the value from the hidden field 'plant'
|
||||
$plant = $this->form->getState()['plant'] ?? null;
|
||||
$line = $this->form->getState()['line'] ?? null;
|
||||
$production = $this->form->getState()['production'] ?? null;
|
||||
|
||||
// $this->skipChecklistValidation = false;
|
||||
// $this->showChecklist = false;
|
||||
// $this->checklist = [];
|
||||
|
||||
// $this->form->fill();
|
||||
|
||||
// reset checklist
|
||||
$this->checklist = [];
|
||||
|
||||
$this->skipChecklistValidation = false;
|
||||
$this->showChecklist = false;
|
||||
|
||||
$this->form->fill([]);
|
||||
|
||||
$this->data = [];
|
||||
|
||||
$this->resetValidation();
|
||||
$this->resetErrorBag();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => null,
|
||||
'line_id' => null,
|
||||
'production_order' => null,
|
||||
]);
|
||||
|
||||
|
||||
// $this->dispatch('focus-item-id');
|
||||
session()->flash('focus_item_id_after_redirect', true);
|
||||
logger('Focus flag set in session');
|
||||
|
||||
if ($plant) {
|
||||
session(['last_selected_plant_id' => $plant]);
|
||||
}
|
||||
@@ -279,14 +121,13 @@ class CreateQualityValidation extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
//return $this->getResource()::getUrl('create'); // Stay on Create Page after savin
|
||||
//return $this->getResource()::getUrl('create'); // Stay on Create Page after saving
|
||||
|
||||
return $this->getResource()::getUrl('create', [
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
'production_order' => $this->data['production_order'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ class EditQualityValidation extends EditRecord
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
|
||||
public bool $showChecklist = false;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -10,8 +10,6 @@ class ListQualityValidations extends ListRecords
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
|
||||
public bool $showChecklist = false;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -10,8 +10,6 @@ class ViewQualityValidation extends ViewRecord
|
||||
{
|
||||
protected static string $resource = QualityValidationResource::class;
|
||||
|
||||
public bool $showChecklist = false;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -12,10 +12,7 @@ use App\Models\RequestCharacteristic;
|
||||
use Closure;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
@@ -23,7 +20,6 @@ use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
@@ -174,9 +170,6 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\TextInput::make('aufnr')
|
||||
->label('Job Number')
|
||||
->reactive()
|
||||
->numeric()
|
||||
->minlength(7)
|
||||
->maxlength(10)
|
||||
->required(function (callable $get) {
|
||||
$item = $get('item_id');
|
||||
if ($item) {
|
||||
@@ -877,8 +870,7 @@ class RequestCharacteristicResource extends Resource
|
||||
Tables\Columns\TextColumn::make('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(), // isIndividual: true
|
||||
->searchable(), // isIndividual: true
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->alignCenter()
|
||||
@@ -1037,19 +1029,21 @@ class RequestCharacteristicResource extends Resource
|
||||
}
|
||||
|
||||
return match ($state) {
|
||||
'Sent' => 'Sent-M1',
|
||||
'Sent-Mail2' => 'Sent-M2',
|
||||
'Sent-Mail3' => 'Sent-M3',
|
||||
'Sent' => 'Sent-Mail1',
|
||||
'Sent-Mail2' => 'Sent-Mail2',
|
||||
'Sent-Mail3' => 'Sent-Mail3',
|
||||
default => '-',
|
||||
};
|
||||
})
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('trigger_at')
|
||||
->label('Trigger At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
@@ -1085,165 +1079,7 @@ class RequestCharacteristicResource extends Resource
|
||||
->searchPlaceholder('Search Work Flow ID')
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
Filter::make('advanced_filters')
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('requestCharacteristics', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('machine', null);
|
||||
$set('item_id', null);
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
Select::make('machine')
|
||||
->label('Search by Work Center')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Machine::whereHas('requestCharacteristics', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('work_center', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
// $set('item_id', null);
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
Select::make('item_id')
|
||||
->label('Search by Item Code')
|
||||
->nullable()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('requestCharacteristics', function ($query) use ($plantId) {
|
||||
if ($plantId) {
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
})->pluck('code', 'id');
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
// $set('aufnr', null);
|
||||
}),
|
||||
TextInput::make('aufnr')
|
||||
->label('Job Number')
|
||||
->placeholder('Enter Job Number')
|
||||
->numeric()
|
||||
->minlength(7)
|
||||
->maxlength(10),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder('Select From DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
DateTimePicker::make('created_to')
|
||||
->label('Created To')
|
||||
->placeholder('Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null
|
||||
$query->where('plant_id', $data['Plant']);
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['machine'])) {
|
||||
$query->where('machine_id', $data['machine']);
|
||||
}
|
||||
|
||||
if (! empty($data['item_id'])) {
|
||||
$query->where('item_id', $data['item_id']);
|
||||
}
|
||||
|
||||
if (! empty($data['aufnr'])) {
|
||||
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
|
||||
if (! empty($data['created_to'])) {
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return 'Plant: Choose plant to filter records.';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($data['machine'])) {
|
||||
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine'])->value('work_center');
|
||||
}
|
||||
|
||||
if (! empty($data['item_id'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['item_id'])->value('code');
|
||||
}
|
||||
|
||||
if (! empty($data['aufnr'])) {
|
||||
$indicators[] = 'Job No: '.$data['aufnr'];
|
||||
}
|
||||
|
||||
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(),
|
||||
|
||||
@@ -49,9 +49,7 @@ class StickerMasterResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->reactive()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
@@ -190,7 +188,7 @@ class StickerMasterResource extends Resource
|
||||
->hintColor('danger'),
|
||||
|
||||
Forms\Components\TextInput::make('item_description')
|
||||
->label('Item Description')
|
||||
->label('Description')
|
||||
->required()
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
@@ -531,7 +529,7 @@ class StickerMasterResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
@@ -539,19 +537,6 @@ class StickerMasterResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('item.description')
|
||||
->label('Item Description')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('item.uom')
|
||||
->label('Unit of Measure')
|
||||
->default('-')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\CheckboxColumn::make('serial_number_motor')
|
||||
->label('Serial Number Motor')
|
||||
->disabled(true)
|
||||
@@ -707,19 +692,12 @@ class StickerMasterResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('stickersMasters', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
@@ -832,7 +810,7 @@ class StickerMasterResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
|
||||
@@ -56,9 +56,8 @@ class TestingPanelReadingResource extends Resource
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->searchable()
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
@@ -74,19 +73,17 @@ class TestingPanelReadingResource extends Resource
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
$set('line_id', null);
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('item_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', 'Please select a plant first.');
|
||||
|
||||
return;
|
||||
} else {
|
||||
$set('line_id', null);
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('item_id', null);
|
||||
$set('machine_id', null);
|
||||
$set('tPrError', null);
|
||||
}
|
||||
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('tPrError') ? 'border-red-500' : '',
|
||||
@@ -94,9 +91,8 @@ class TestingPanelReadingResource extends Resource
|
||||
->hint(fn ($get) => $get('tPrError') ? $get('tPrError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line Name')
|
||||
->label('Line')
|
||||
->relationship('line', 'name')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (! $plantId) {
|
||||
@@ -113,14 +109,10 @@ class TestingPanelReadingResource extends Resource
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('motor_testing_master_id', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->afterStateUpdated(fn (callable $set) => $set('item_id', null)),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
->relationship('machine', 'work_center')
|
||||
->searchable()
|
||||
->label('Machine')
|
||||
->relationship('machine', 'name')
|
||||
->options(function (callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
if (! $lineId) {
|
||||
@@ -129,7 +121,7 @@ class TestingPanelReadingResource extends Resource
|
||||
|
||||
// Only show machines for the selected line
|
||||
return Machine::where('line_id', $lineId)
|
||||
->pluck('work_center', 'id')
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
@@ -137,10 +129,7 @@ class TestingPanelReadingResource extends Resource
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->reactive(),
|
||||
Forms\Components\Select::make('motor_testing_master_id')
|
||||
->label('Item Code')
|
||||
// ->relationship('motorTestingMaster', 'item.code')
|
||||
@@ -174,234 +163,101 @@ class TestingPanelReadingResource extends Resource
|
||||
// )
|
||||
->required()
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->reactive(),
|
||||
Forms\Components\TextInput::make('output')
|
||||
->label('Output')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->required()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('winded_serial_number')
|
||||
->label('Winded Serial Number')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Winded Serial Number'),
|
||||
Forms\Components\TextInput::make('before_fr_volt')
|
||||
->label('Before FR Volt')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Volt'),
|
||||
Forms\Components\TextInput::make('before_fr_cur')
|
||||
->label('Before FR Current')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Current'),
|
||||
Forms\Components\TextInput::make('before_fr_pow')
|
||||
->label('Before FR Power')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Power'),
|
||||
Forms\Components\TextInput::make('before_fr_res_ry')
|
||||
->label('Before FR Resistance RY')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Resistance RY'),
|
||||
Forms\Components\TextInput::make('before_fr_res_yb')
|
||||
->label('Before FR Resistance YB')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Resistance YB'),
|
||||
Forms\Components\TextInput::make('before_fr_res_br')
|
||||
->label('Before FR Resistance BR')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Resistance BR'),
|
||||
Forms\Components\TextInput::make('before_fr_ir')
|
||||
->label('Before FR IR')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR IR'),
|
||||
Forms\Components\TextInput::make('before_fr_ir_r')
|
||||
->label('Before FR IR R')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR IR R'),
|
||||
Forms\Components\TextInput::make('before_fr_ir_y')
|
||||
->label('Before FR IR Y')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR IR Y'),
|
||||
Forms\Components\TextInput::make('before_fr_ir_b')
|
||||
->label('Before FR IR B')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR IR B'),
|
||||
Forms\Components\TextInput::make('before_fr_freq')
|
||||
->label('Before FR Frequency')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Frequency'),
|
||||
Forms\Components\TextInput::make('before_fr_speed')
|
||||
->label('Before FR Speed')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Before FR Speed'),
|
||||
Forms\Components\TextInput::make('after_fr_vol')
|
||||
->label('After FR Volt')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR Volt'),
|
||||
Forms\Components\TextInput::make('after_fr_cur')
|
||||
->label('After FR Current')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR Current'),
|
||||
Forms\Components\TextInput::make('after_fr_pow')
|
||||
->label('After FR Power')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR Power'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_hot')
|
||||
->label('After FR IR Hot')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Hot'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_hot_r')
|
||||
->label('After FR IR Hot R')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Hot R'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_hot_y')
|
||||
->label('After FR IR Hot Y')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Hot Y'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_hot_b')
|
||||
->label('After FR IR Hot B')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Hot B'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_cool')
|
||||
->label('After FR IR Cool')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Cool'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_cool_r')
|
||||
->label('After FR IR Cool R')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Cool R'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_cool_y')
|
||||
->label('After FR IR Cool Y')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Cool Y'),
|
||||
Forms\Components\TextInput::make('after_fr_ir_cool_b')
|
||||
->label('After FR IR Cool B')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR IR Cool B'),
|
||||
Forms\Components\TextInput::make('after_fr_freq')
|
||||
->label('After FR Frequency')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR Frequency'),
|
||||
Forms\Components\TextInput::make('after_fr_speed')
|
||||
->label('After FR Speed')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR Speed'),
|
||||
Forms\Components\TextInput::make('after_fr_leak_cur')
|
||||
->label('After FR Leak Current')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('After FR Leak Current'),
|
||||
Forms\Components\TextInput::make('locked_rt_volt')
|
||||
->label('Locked RT Volt')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Locked RT Volt'),
|
||||
Forms\Components\TextInput::make('locked_rt_cur')
|
||||
->label('Locked RT Current')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Locked RT Current'),
|
||||
Forms\Components\TextInput::make('locked_rt_pow')
|
||||
->label('Locked RT Power')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Locked RT Power'),
|
||||
Forms\Components\TextInput::make('no_load_pickup_volt')
|
||||
->label('No Load Pickup Volt')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('No Load Pickup Volt'),
|
||||
Forms\Components\TextInput::make('room_temperature')
|
||||
->label('Room Temperature')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Room Temperature'),
|
||||
Forms\Components\TextInput::make('hv_test')
|
||||
->label('High Voltage Test')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('High Voltage Test'),
|
||||
Forms\Components\TextInput::make('batch_number')
|
||||
->label('Batch Number')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Batch Number'),
|
||||
Forms\Components\TextInput::make('batch_count')
|
||||
->label('Batch Count')
|
||||
->default('0')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->default('0'),
|
||||
Forms\Components\TextInput::make('result')
|
||||
->label('Result')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Result'),
|
||||
Forms\Components\TextInput::make('remark')
|
||||
->label('Remark')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->label('Remark'),
|
||||
Forms\Components\TextInput::make('rework_count')
|
||||
->label('Rework Count')
|
||||
->default('0')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->default('0'),
|
||||
Forms\Components\TextInput::make('update_count')
|
||||
->label('Update Count')
|
||||
->default('0')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->default('0'),
|
||||
Forms\Components\TextInput::make('output_flag')
|
||||
->label('Output Flag')
|
||||
->default('0')
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
->default('0'),
|
||||
Forms\Components\TextInput::make('tested_by')
|
||||
->label('Tested By')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
->label('Tested By'),
|
||||
Forms\Components\TextInput::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
->label('Updated By'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
@@ -427,20 +283,17 @@ class TestingPanelReadingResource extends Resource
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant Name')
|
||||
->label('Plant')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line Name')
|
||||
->label('Line')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('machine.work_center')
|
||||
->label('Work Center')
|
||||
Tables\Columns\TextColumn::make('machine.name')
|
||||
->label('Machine')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.subassembly_code')
|
||||
->label('Subassembly Code')
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('motorTestingMaster.item.description')
|
||||
->label('Model')
|
||||
->alignCenter(),
|
||||
@@ -624,22 +477,13 @@ class TestingPanelReadingResource extends Resource
|
||||
->label('Advanced Filters')
|
||||
->form([
|
||||
Select::make('Plant')
|
||||
->label('Search by Plant Name')
|
||||
->searchable()
|
||||
->label('Select Plant')
|
||||
->nullable()
|
||||
->options(function () {
|
||||
// return Plant::pluck('name', 'id');
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
if ($userHas && strlen($userHas) > 0) {
|
||||
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||
} else {
|
||||
return Plant::whereHas('testingPanelReadings', function ($query) {
|
||||
$query->whereNotNull('id');
|
||||
})->orderBy('code')->pluck('name', 'id');
|
||||
}
|
||||
|
||||
//return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
@@ -648,8 +492,7 @@ class TestingPanelReadingResource extends Resource
|
||||
|
||||
}),
|
||||
Select::make('Line')
|
||||
->label('Search by Line Name')
|
||||
->searchable()
|
||||
->label('Select Line')
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
@@ -664,11 +507,11 @@ class TestingPanelReadingResource extends Resource
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_code', null);
|
||||
|
||||
}),
|
||||
Select::make('item_code')
|
||||
->label('Search by Item Code')
|
||||
->label('Item Code')
|
||||
->searchable()
|
||||
->nullable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
if ($plantId) {
|
||||
@@ -677,20 +520,15 @@ class TestingPanelReadingResource extends Resource
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('code', 'id')
|
||||
// ->toArray();
|
||||
return Item::whereHas('motorTestingMasters')
|
||||
->pluck('code', 'id')
|
||||
->toArray();
|
||||
}
|
||||
// return [];
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_description', null);
|
||||
}),
|
||||
->reactive(),
|
||||
Select::make('machine_name')
|
||||
->label('Search by Work Center')
|
||||
->searchable()
|
||||
->nullable()
|
||||
->label('Machine Name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
$lineId = $get('Line');
|
||||
@@ -701,43 +539,30 @@ class TestingPanelReadingResource extends Resource
|
||||
|
||||
return Machine::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->pluck('work_center', 'id')
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->reactive(),
|
||||
TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->placeholder('Enter Serial Number'),
|
||||
->placeholder(placeholder: 'Enter Serial Number'),
|
||||
Select::make('item_description')
|
||||
->label('Model')
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('Plant');
|
||||
|
||||
// $query = Item::query();
|
||||
// if ($plantId) {
|
||||
// $query->where('plant_id', $plantId);
|
||||
// }
|
||||
|
||||
$plantId = $get('Plant');
|
||||
$query = Item::query();
|
||||
if ($plantId) {
|
||||
return Item::where('plant_id', $plantId)
|
||||
->whereHas('motorTestingMasters')
|
||||
->pluck('description', 'id')
|
||||
->toArray();
|
||||
} else {
|
||||
return [];
|
||||
// return Item::whereHas('motorTestingMasters')
|
||||
// ->pluck('description', 'id')
|
||||
// ->toArray();
|
||||
$query->where('plant_id', $plantId);
|
||||
}
|
||||
//return $query->pluck('description', 'description')->toArray();
|
||||
|
||||
return $query->pluck('description', 'description')->toArray();
|
||||
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_code', null);
|
||||
}),
|
||||
->reactive(),
|
||||
|
||||
Select::make('output')
|
||||
->label('Output')
|
||||
->searchable()
|
||||
@@ -877,23 +702,12 @@ class TestingPanelReadingResource extends Resource
|
||||
}
|
||||
|
||||
if (! empty($data['item_description'])) {
|
||||
$itemId = $data['item_description']; // Item::where('description', $data['item_description'])->first()?->id ?? null;
|
||||
$item = Item::where('description', $data['item_description'])->first();
|
||||
|
||||
if ($itemId) { // $item
|
||||
$mastId = MotorTestingMaster::where('item_id', $itemId)->first()?->id ?? null;
|
||||
if ($mastId) { // $item
|
||||
$motId = TestingPanelReading::where('motor_testing_master_id', $mastId)->first()?->id ?? null;
|
||||
if ($motId) { // $item
|
||||
$query->where('motor_testing_master_id', $mastId);
|
||||
// $query->whereHas('motorTestingMaster', function ($subQuery) use ($itemId) {
|
||||
// $subQuery->where('item_id', $itemId); //$item->id
|
||||
// });
|
||||
} else {
|
||||
$query->whereRaw('1 = 0');
|
||||
}
|
||||
} else {
|
||||
$query->whereRaw('1 = 0');
|
||||
}
|
||||
if ($item) {
|
||||
$query->whereHas('motorTestingMaster', function ($subQuery) use ($item) {
|
||||
$subQuery->where('item_id', $item->id);
|
||||
});
|
||||
} else {
|
||||
$query->whereRaw('1 = 0');
|
||||
}
|
||||
@@ -942,7 +756,7 @@ class TestingPanelReadingResource extends Resource
|
||||
$indicators = [];
|
||||
|
||||
if (! empty($data['Plant'])) {
|
||||
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||
} else {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
@@ -951,27 +765,26 @@ class TestingPanelReadingResource extends Resource
|
||||
}
|
||||
}
|
||||
if (! empty($data['Line'])) {
|
||||
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||
$indicators[] = 'Line: '.Line::where('id', $data['Line'])->value('name');
|
||||
}
|
||||
if (! empty($data['item_code'])) {
|
||||
$indicators[] = 'Item Code: '.Item::where('id', $data['item_code'])->value('code');
|
||||
}
|
||||
if (! empty($data['machine_name'])) {
|
||||
$indicators[] = 'Work Center: '.Machine::where('id', $data['machine_name'])->value('work_center');
|
||||
$indicators[] = 'Machine: '.Machine::where('id', $data['machine_name'])->value('name');
|
||||
}
|
||||
if (! empty($data['output'])) {
|
||||
$indicators[] = 'Output: '.$data['output'];
|
||||
}
|
||||
if (! empty($data['item_description'])) {
|
||||
$item = Item::where('id', $data['item_description'])->first()?->description ?? null;
|
||||
$indicators[] = 'Model: '.$item;
|
||||
$indicators[] = 'Model: '.$data['item_description'];
|
||||
}
|
||||
// if (!empty($data['phase'])) {
|
||||
// $indicators[] = 'Phase: ' . $data['phase'];
|
||||
// }
|
||||
if (!empty($data['connection'])) {
|
||||
$indicators[] = 'Connection: ' . $data['connection'];
|
||||
}
|
||||
// if (!empty($data['connection'])) {
|
||||
// $indicators[] = 'Connection: ' . $data['connection'];
|
||||
// }
|
||||
if (! empty($data['remark'])) {
|
||||
$indicators[] = 'Remark: '.$data['remark'];
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestingTempResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TestingTemp::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-c-circle-stack';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'IIOT Temp';
|
||||
|
||||
@@ -36,7 +36,7 @@ class TestingTempResource extends Resource
|
||||
->required()
|
||||
->searchable()
|
||||
// ->preload()
|
||||
->nullable()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->columnSpan(1)
|
||||
->options(function (callable $get) {
|
||||
@@ -151,7 +151,6 @@ class TestingTempResource extends Resource
|
||||
Forms\Components\Actions::make([
|
||||
Action::make('uploadNow')
|
||||
->label('Upload File')
|
||||
->icon('heroicon-c-cloud-arrow-up')
|
||||
->color('success')
|
||||
->requiresConfirmation(function (callable $get) {
|
||||
$filePath = $get('attachment');
|
||||
@@ -232,7 +231,6 @@ class TestingTempResource extends Resource
|
||||
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download File')
|
||||
->icon('heroicon-c-cloud-arrow-down')
|
||||
->color('warning')
|
||||
->requiresConfirmation(function (callable $get) {
|
||||
$filePath = $get('selected_file');
|
||||
@@ -283,7 +281,6 @@ class TestingTempResource extends Resource
|
||||
|
||||
Action::make('deleteAttachment')
|
||||
->label('Delete File')
|
||||
->icon('heroicon-c-trash')
|
||||
->color('danger')
|
||||
->requiresConfirmation(function (callable $get) {
|
||||
$filePath = $get('selected_file');
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\VehicleEntryResource\Pages;
|
||||
use App\Filament\Resources\VehicleEntryResource\RelationManagers;
|
||||
use App\Models\Plant;
|
||||
use App\Models\VehicleEntry;
|
||||
use Carbon\Carbon;
|
||||
@@ -19,9 +20,7 @@ class VehicleEntryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = VehicleEntry::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-m-truck'; // heroicon-o-rectangle-stack
|
||||
|
||||
protected static ?string $navigationGroup = 'Vehicle';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
@@ -87,7 +86,7 @@ class VehicleEntryResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ClassCharacteristic;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -53,13 +52,14 @@ class CharacteristicApprovalController extends Controller
|
||||
foreach ($levels as $lvl => $column) {
|
||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $record->$column,
|
||||
'status' => $record->$column,
|
||||
'message' => 'Your request has already been processed by another approver',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($levels as $lvl => $column) {
|
||||
foreach ($levels as $lvl => $column)
|
||||
{
|
||||
if ($record->$column == 'Hold') {
|
||||
|
||||
if ($lvl == $level) {
|
||||
@@ -127,12 +127,13 @@ class CharacteristicApprovalController extends Controller
|
||||
foreach ($levels as $lvl => $column) {
|
||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $record->$column,
|
||||
'status' => $record->$column,
|
||||
'message' => 'Your request has already been processed by another approver',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// foreach ($levels as $lvl => $column) {
|
||||
// if ($record->$column == 'Hold') {
|
||||
|
||||
@@ -149,6 +150,7 @@ class CharacteristicApprovalController extends Controller
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$allowedMailStatusByLevel = [
|
||||
1 => 'Sent',
|
||||
2 => 'Sent-Mail2',
|
||||
@@ -159,11 +161,12 @@ class CharacteristicApprovalController extends Controller
|
||||
|
||||
if ($record->mail_status != $expectedMailStatus) {
|
||||
return view('approval.approve-level', [
|
||||
'status' => $currentStatus,
|
||||
'status'=> $currentStatus,
|
||||
'message' => 'Your approval time limit has expired.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
return view('approval.reject-form', compact('id', 'level'));
|
||||
}
|
||||
|
||||
@@ -200,12 +203,13 @@ class CharacteristicApprovalController extends Controller
|
||||
foreach ($levels as $lvl => $column) {
|
||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $record->$column,
|
||||
'status' => $record->$column,
|
||||
'message' => 'Your request has already been processed by another approver',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// foreach ($levels as $lvl => $column) {
|
||||
// if ($record->$column == 'Hold') {
|
||||
|
||||
@@ -232,7 +236,7 @@ class CharacteristicApprovalController extends Controller
|
||||
|
||||
if ($record->mail_status != $expectedMailStatus) {
|
||||
return view('approval.approve-level', [
|
||||
'status' => $currentStatus,
|
||||
'status'=> $currentStatus,
|
||||
'message' => 'Your approval time limit has expired.',
|
||||
]);
|
||||
}
|
||||
@@ -324,7 +328,7 @@ class CharacteristicApprovalController extends Controller
|
||||
foreach ($levels as $lvl => $column) {
|
||||
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||
return view('approval.already-processed', [
|
||||
'status' => $record->$column,
|
||||
'status' => $record->$column,
|
||||
'message' => 'your request has already been processed by another approver',
|
||||
]);
|
||||
}
|
||||
@@ -341,7 +345,7 @@ class CharacteristicApprovalController extends Controller
|
||||
if ($record->mail_status != $expectedMailStatus) {
|
||||
if ($returnView) {
|
||||
return view('approval.approve-level', [
|
||||
'status' => $currentStatus,
|
||||
'status' => $currentStatus,
|
||||
'message' => 'Your approval time limit has expired.',
|
||||
]);
|
||||
}
|
||||
@@ -380,12 +384,6 @@ class CharacteristicApprovalController extends Controller
|
||||
$r->update($updateData);
|
||||
}
|
||||
|
||||
// UPDATE class characteristics
|
||||
// ClassCharacteristic::where('plant_id', $record->plant_id)
|
||||
// ->where('machine_id', $record->machine_id)
|
||||
// ->where('aufnr', $record->aufnr)
|
||||
// ->update(['has_work_flow_id' => $record->work_flow_id]);
|
||||
|
||||
if ($returnView) {
|
||||
return match ($status) {
|
||||
'Approved' => view('approval.success'),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -627,7 +627,7 @@ class PdfController extends Controller
|
||||
// 'coil_number' => $proOrdAgPlant->coil_number ?? "",
|
||||
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
|
||||
'coil_number' => $currentCoil,
|
||||
'order_quantity' => (string) $lastRecord->updated_order_quantity ?? '0.000',
|
||||
'order_quantity' => (string) $lastRecord->order_quantity ?? '0.000',
|
||||
'ok_quantity' => (string) $okQty ?? '0',
|
||||
'not_ok_quantity' => (string) $notOkQty ?? '0',
|
||||
'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000',
|
||||
@@ -686,7 +686,7 @@ class PdfController extends Controller
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$lineName = $data['line_name'] ?? '';
|
||||
$coilNo = $data['coil_number'] ?? '';
|
||||
$updatedOrderQty = $data['order_quantity'] ?? 0;
|
||||
$orderQty = $data['order_quantity'] ?? 0;
|
||||
$receivedQty = $data['received_quantity'] ?? 0;
|
||||
$scrapQty = $data['scrap_quantity'] ?? 0;
|
||||
$sfgNo = $data['sfg_number'] ?? '';
|
||||
@@ -872,8 +872,7 @@ class PdfController extends Controller
|
||||
->where('item_id', $itemId)
|
||||
->sum('received_quantity');
|
||||
|
||||
$orderQty = 0;
|
||||
if ($updatedOrderQty == 0) {
|
||||
if ($orderQty == 0) {
|
||||
$orderExist = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)->latest()->first();
|
||||
@@ -881,7 +880,6 @@ class PdfController extends Controller
|
||||
|
||||
if ($orderExist) {
|
||||
$orderQty = $orderExist->order_quantity ?? 0;
|
||||
$updatedOrderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
} else {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -895,11 +893,9 @@ class PdfController extends Controller
|
||||
// ->value('order_quantity') ?? 0;
|
||||
|
||||
if ($orderExist) {
|
||||
// $existOrderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
$orderQty = $orderExist->order_quantity ?? 0;
|
||||
$existUpdatedOrdQuan = $orderExist->updated_order_quantity ?? 0;
|
||||
$existOrderQty = $orderExist->order_quantity ?? 0;
|
||||
|
||||
if ($existUpdatedOrdQuan != $updatedOrderQty) {
|
||||
if ($existOrderQty != $orderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Order quantity doesn't equal to exist process order '{$processOrder}'",
|
||||
@@ -950,10 +946,10 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($total > $updatedOrderQty) {
|
||||
if ($total > $orderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
|
||||
'status_description' => "Rework received quantity should not exceed exist order quantity! Exist Order Qty = '{$orderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -972,7 +968,6 @@ class PdfController extends Controller
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'updated_order_quantity' => $updatedOrderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
@@ -1107,10 +1102,10 @@ class PdfController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($total > $updatedOrderQty) {
|
||||
if ($total > $orderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Received Qty = '{$receivedQty}'",
|
||||
'status_description' => "Received quantity should not exceed exist order quantity! Exist Order Qty = '{$orderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
@@ -1122,7 +1117,6 @@ class PdfController extends Controller
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'updated_order_quantity' => $updatedOrderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\MotorTestingMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -29,48 +30,56 @@ class StickerMasterController extends Controller
|
||||
public function get_master_type(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$itemCode = $request->header('item-code');
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
if ($plantCode == null || $plantCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
}
|
||||
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!',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
} elseif ($itemCode == null || $itemCode == '') {
|
||||
}
|
||||
else if ($itemCode == null || $itemCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code can't be empty!",
|
||||
'status_description' => "Item Code can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($itemCode) < 6 || ! ctype_alnum($itemCode)) {
|
||||
}
|
||||
else if (Str::length($itemCode) < 6 || !ctype_alnum($itemCode))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid item code found!',
|
||||
'status_description' => "Invalid item code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (! $plant) {
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
'status_description' => "Plant not found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -78,71 +87,64 @@ class StickerMasterController extends Controller
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item Code not found in item table!',
|
||||
'status_description' => "Item Code not found in item table!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!",
|
||||
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$itemId = $item->id;
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||
|
||||
$stickerMaster = StickerMaster::where('item_id', $itemId)->first();
|
||||
|
||||
if (! $stickerMaster) {
|
||||
if (!$stickerMaster)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item Code not found in sticker master table!',
|
||||
'status_description' => "Item Code not found in sticker master table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
$serial_number_motor = $stickerMaster->serial_number_motor ?? null;
|
||||
$serial_number_pump = $stickerMaster->serial_number_pump ?? null;
|
||||
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
if (! $stickerMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in sticker master table for the plant : '$plant->name'!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$serial_number_motor = $stickerMaster->serial_number_motor ?? null;
|
||||
$serial_number_pump = $stickerMaster->serial_number_pump ?? null;
|
||||
|
||||
if ($serial_number_motor != 1 && $serial_number_pump != 1) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The Item Code '$itemCode' does not have serial pump or serial motor selected!",
|
||||
], 400);
|
||||
}
|
||||
|
||||
$serialInfo = [];
|
||||
|
||||
if ($serial_number_motor == 1 && $serial_number_pump == 1) {
|
||||
$serialInfo[] = 'Serial Pump';
|
||||
} else {
|
||||
if ($serial_number_motor == 1) {
|
||||
$serialInfo[] = 'Serial Motor';
|
||||
if ($serial_number_motor != 1 && $serial_number_pump != 1) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "The Item Code '$itemCode' does not have serial pump or serial motor selected!"
|
||||
], 400);
|
||||
}
|
||||
if ($serial_number_pump == 1) {
|
||||
|
||||
$serialInfo = [];
|
||||
|
||||
if ($serial_number_motor == 1 && $serial_number_pump == 1)
|
||||
{
|
||||
$serialInfo[] = 'Serial Pump';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($serial_number_motor == 1) {
|
||||
$serialInfo[] = 'Serial Motor';
|
||||
}
|
||||
if ($serial_number_pump == 1) {
|
||||
$serialInfo[] = 'Serial Pump';
|
||||
}
|
||||
}
|
||||
|
||||
$output = [
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => implode(', ', $serialInfo),
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
$output = [
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => implode(', ', $serialInfo),
|
||||
];
|
||||
return response()->json($output, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,48 +153,56 @@ class StickerMasterController extends Controller
|
||||
public function get_master(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$plantCode = $request->header('plant-code');
|
||||
$itemCode = $request->header('item-code');
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
if ($plantCode == null || $plantCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
}
|
||||
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!',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
} elseif ($itemCode == null || $itemCode == '') {
|
||||
}
|
||||
else if ($itemCode == null || $itemCode == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code can't be empty!",
|
||||
'status_description' => "Item Code can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($itemCode) < 6 || ! ctype_alnum($itemCode)) {
|
||||
}
|
||||
else if (Str::length($itemCode) < 6 || !ctype_alnum($itemCode))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid item code found!',
|
||||
'status_description' => "Invalid item code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (! $plant) {
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
'status_description' => "Plant not found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -200,56 +210,48 @@ class StickerMasterController extends Controller
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item Code not found in item table!',
|
||||
'status_description' => "Item Code not found in item table!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!",
|
||||
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
$description = $item ? $item->description : '';
|
||||
|
||||
$uom = $item ? $item->uom : '';
|
||||
|
||||
// $category = $item ? $item->category : '';
|
||||
$category = $item ? $item->category : '';
|
||||
|
||||
$stickerMaster = StickerMaster::where('item_id', $itemId)->first();
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||
|
||||
if (! $stickerMaster) {
|
||||
if (!$stickerMaster)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item Code not found in sticker master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$stickerMaster = StickerMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
if (! $stickerMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item Code not found in sticker master table for the plant : '$plant->name'!",
|
||||
'status_description' => "Item Code not found in sticker master table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$output = [
|
||||
'item_description' => $description ?? '',
|
||||
'uom' => $uom ?? '',
|
||||
'Part_Validation_1' => $stickerMaster?->laser_part_validation1 ?? '',
|
||||
'Part_Validation_2' => $stickerMaster?->laser_part_validation2 ?? '',
|
||||
'Part_Validation_3' => $stickerMaster?->laser_part_validation3 ?? '',
|
||||
'Part_Validation_4' => $stickerMaster?->laser_part_validation4 ?? '',
|
||||
'Part_Validation_5' => $stickerMaster?->laser_part_validation5 ?? '',
|
||||
"item_description" => $description ?? "",
|
||||
"uom" => $uom ?? "",
|
||||
"Part_Validation_1" => $stickerMaster?->laser_part_validation1 ?? "",
|
||||
"Part_Validation_2" => $stickerMaster?->laser_part_validation2 ?? "",
|
||||
"Part_Validation_3" => $stickerMaster?->laser_part_validation3 ?? "",
|
||||
"Part_Validation_4" => $stickerMaster?->laser_part_validation4 ?? "",
|
||||
"Part_Validation_5" => $stickerMaster?->laser_part_validation5 ?? "",
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
|
||||
@@ -9,7 +9,14 @@ 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;
|
||||
use Mpdf\Mpdf;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
use chillerlan\QRCode\Output\QROutputInterface;
|
||||
use Mpdf\QrCode\Output;
|
||||
use Mpdf\QrCode\QrCode;
|
||||
use Str;
|
||||
|
||||
class TestingPanelController extends Controller
|
||||
@@ -28,151 +35,173 @@ class TestingPanelController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($data['plant_code'] == null || $data['plant_code'] == '') {
|
||||
if ($data['plant_code'] == null || $data['plant_code'] == '')
|
||||
{
|
||||
// return response("ERROR: Please provide a valid plant code.", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($data['plant_code']) < 4 || ! is_numeric($data['plant_code']) || ! preg_match('/^[1-9]\d{3,}$/', $data['plant_code'])) {// !ctype_digit($data['plant_code'])
|
||||
}
|
||||
else if (Str::length($data['plant_code']) < 4 || !is_numeric($data['plant_code']) || !preg_match('/^[1-9]\d{3,}$/', $data['plant_code']))//!ctype_digit($data['plant_code'])
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid plant code found!',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $data['plant_code'])->first();
|
||||
if (! $plant) {
|
||||
// return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
if (!$plant) {
|
||||
//return response("Plant not found.", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
'status_description' => 'Plant not found!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plantId = $plant->id;
|
||||
|
||||
if ($data['line_name'] == null || $data['line_name'] == '') {
|
||||
if ($data['line_name'] == null || $data['line_name'] == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center can't be empty!",
|
||||
'status_description' => "Group work center can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($data['line_name']) < 0) {
|
||||
}
|
||||
else if (Str::length($data['line_name']) < 0)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid group work center found!',
|
||||
'status_description' => "Invalid group work center found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$gWorkCenter = WorkGroupMaster::where('name', $data['line_name'])->first();
|
||||
if (! $gWorkCenter) {
|
||||
if (!$gWorkCenter)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Group work center not found!',
|
||||
'status_description' => 'Group work center not found!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$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');
|
||||
if (!$gWorkCenter)
|
||||
{
|
||||
//return response( "Line not found for the specified plant : {$data['plant_code']}",400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Group work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
'status_description' => "Group work center not found for the specified plant : '{$data['plant_code']}'!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$gWorkCenterId = $gWorkCenter->id;
|
||||
|
||||
if ($data['machine_name'] == null || $data['machine_name'] == '') {
|
||||
if ($data['machine_name'] == null || $data['machine_name'] == '')
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center can't be empty!",
|
||||
'status_description' => "Work center can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($data['machine_name']) < 0) {
|
||||
}
|
||||
else if (Str::length($data['machine_name']) < 0)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid work center found!',
|
||||
'status_description' => "Invalid work center found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->first();
|
||||
if (! $machine) {
|
||||
if (!$machine)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Work center not found!',
|
||||
'status_description' => 'Work center not found!'
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->first();
|
||||
if (! $machine) {
|
||||
if (!$machine)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!",
|
||||
'status_description' => "Work center not found for the specified plant : '{$data['plant_code']}'!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (! $machine) {
|
||||
if (!$machine)
|
||||
{
|
||||
// return response("Machine not found for the specified line : {$data['line_name']}", 400)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$data['line_name']}'!",
|
||||
'status_description' => "Work center not found for the specified Group work center : '{$data['line_name']}'!"
|
||||
], 400);
|
||||
|
||||
}
|
||||
|
||||
$machine = Machine::where('work_center', $data['machine_name'])->where('plant_id', $plantId)->where('work_group_master_id', $gWorkCenterId)->first();
|
||||
if (! $machine) {
|
||||
if (!$machine) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Work center not found for the specified Plant : '{$data['plant_code']}' and Group work center : '{$data['line_name']}'!",
|
||||
'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 {
|
||||
try
|
||||
{
|
||||
$insertedSerials = [];
|
||||
$missedItemCodes = [];
|
||||
$duplicateItemCodes = [];
|
||||
$existSnoCount = [];
|
||||
|
||||
if (! empty($data['item_codes']) && is_array($data['item_codes'])) {
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
if (!empty($data['item_codes']) && is_array($data['item_codes']))
|
||||
{
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
$code = $item['item_code'] ?? null;
|
||||
|
||||
// Check if item_code is present
|
||||
if ($code == '' || $code == null) {
|
||||
if ($code == '' || $code == null)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code can't be empty!",
|
||||
'status_description' => "Item code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Collect duplicates
|
||||
if (isset($itemCodeCounts[$code])) {
|
||||
if (isset($itemCodeCounts[$code]))
|
||||
{
|
||||
$itemCodeCounts[$code]++;
|
||||
// Only add to duplicates array once
|
||||
if ($itemCodeCounts[$code] == 2) {
|
||||
$duplicateItemCodes[] = $code;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$itemCodeCounts[$code] = 1;
|
||||
}
|
||||
|
||||
@@ -180,41 +209,43 @@ class TestingPanelController extends Controller
|
||||
$query->where('code', $item['item_code']);
|
||||
})->where('plant_id', $plantId)->first();
|
||||
|
||||
if (! $motorTestingMaster) {
|
||||
if (!$motorTestingMaster) {
|
||||
$missedItemCodes[] = $item['item_code'];
|
||||
}
|
||||
|
||||
if (! empty($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
if (!empty($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial)
|
||||
{
|
||||
$existSnoCount[] = $serial['serial_number'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If any duplicates found, return error
|
||||
if (! empty($duplicateItemCodes)) {
|
||||
if (!empty($duplicateItemCodes)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Duplicate item codes found in request: '.implode(', ', $duplicateItemCodes),
|
||||
'status_description' => 'Duplicate item codes found in request: ' . implode(', ', $duplicateItemCodes)
|
||||
], 400);
|
||||
}
|
||||
|
||||
$uniqueInvalidCodes = array_unique($missedItemCodes);
|
||||
|
||||
if (! empty($uniqueInvalidCodes)) {
|
||||
if (!empty($uniqueInvalidCodes)) {
|
||||
|
||||
// return response("Item codes : ". implode(', ', $uniqueInvalidCodes)." not found in motor testing master for the specified plant {$plant->name}", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
// return response("Item codes : ". implode(', ', $uniqueInvalidCodes)." not found in motor testing master for the specified plant {$plant->name}", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item codes : '.implode(', ', $uniqueInvalidCodes)." not found in master for the specified plant : '{$plant->name}'!",
|
||||
'status_description' => "Item codes : ". implode(', ', $uniqueInvalidCodes)." not found in master for the specified plant : '{$plant->name}'!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$insertedSnoCount = [];
|
||||
|
||||
foreach ($data['item_codes'] as $item) {
|
||||
foreach ($data['item_codes'] as $item)
|
||||
{
|
||||
|
||||
$motorTestingMaster = MotorTestingMaster::whereHas('item', callback: function ($query) use ($item) {
|
||||
$query->where('code', $item['item_code']);
|
||||
@@ -222,16 +253,18 @@ class TestingPanelController extends Controller
|
||||
|
||||
$motorTestingMasterId = $motorTestingMaster->id;
|
||||
|
||||
if (! empty($item['serial_numbers']) && is_array($item['serial_numbers'])) {
|
||||
foreach ($item['serial_numbers'] as $serial) {
|
||||
// For update_count calculation
|
||||
if (!empty($item['serial_numbers']) && is_array($item['serial_numbers']))
|
||||
{
|
||||
foreach ($item['serial_numbers'] as $serial)
|
||||
{
|
||||
//For update_count calculation
|
||||
$updateCount = [
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'motor_testing_master_id' => $motorTestingMasterId,
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'machine_id' => $machineId,
|
||||
'motor_testing_master_id' => $motorTestingMasterId,
|
||||
'serial_number' => $serial['serial_number'] ?? null,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
];
|
||||
|
||||
// // Find the current max update_count for this composite key //updated_at
|
||||
@@ -244,64 +277,64 @@ class TestingPanelController extends Controller
|
||||
$maxLength = TestingPanelReading::where($updateCount)->selectRaw('MAX(LENGTH(update_count)) as max_length')->value('max_length');
|
||||
|
||||
// Then, get all records with that length
|
||||
$lastUpdateCount = TestingPanelReading::where($updateCount)->whereRaw('LENGTH(update_count) = ?', [$maxLength])->orderByDesc('update_count')->select('update_count')->first(); // ->get();
|
||||
$lastUpdateCount = TestingPanelReading::where($updateCount)->whereRaw('LENGTH(update_count) = ?', [$maxLength])->orderByDesc('update_count')->select('update_count')->first();//->get();
|
||||
|
||||
$newUpdateCount = ($lastUpdateCount == null || $lastUpdateCount == '') ? 0 : (int) $lastUpdateCount?->update_count + 1; // $maxUpdateCount?->update_count
|
||||
$newUpdateCount = ($lastUpdateCount == null || $lastUpdateCount == '') ? 0 : (int)$lastUpdateCount?->update_count + 1;//$maxUpdateCount?->update_count
|
||||
|
||||
$updateCountString = (string) $newUpdateCount;
|
||||
$updateCountString = (string)$newUpdateCount;
|
||||
|
||||
$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,
|
||||
'before_fr_pow' => $serial['before_fr_pow'] ?? null,
|
||||
'before_fr_res_ry' => $serial['before_fr_res_ry'] ?? null,
|
||||
'before_fr_res_yb' => $serial['before_fr_res_yb'] ?? null,
|
||||
'before_fr_res_br' => $serial['before_fr_res_br'] ?? null,
|
||||
'before_fr_ir' => $serial['before_fr_ir'] ?? null,
|
||||
'before_fr_ir_r' => $serial['before_fr_ir_r'] ?? null,
|
||||
'before_fr_ir_y' => $serial['before_fr_ir_y'] ?? null,
|
||||
'before_fr_ir_b' => $serial['before_fr_ir_b'] ?? null,
|
||||
'before_fr_freq' => $serial['before_fr_freq'] ?? null,
|
||||
'before_fr_speed' => $serial['before_fr_speed'] ?? null,
|
||||
'after_fr_vol' => $serial['after_fr_vol'] ?? null,
|
||||
'after_fr_cur' => $serial['after_fr_cur'] ?? null,
|
||||
'after_fr_pow' => $serial['after_fr_pow'] ?? null,
|
||||
'after_fr_ir_hot' => $serial['after_fr_ir_hot'] ?? null,
|
||||
'after_fr_ir_hot_r' => $serial['after_fr_ir_hot_r'] ?? null,
|
||||
'after_fr_ir_hot_y' => $serial['after_fr_ir_hot_y'] ?? null,
|
||||
'after_fr_ir_hot_b' => $serial['after_fr_ir_hot_b'] ?? null,
|
||||
'after_fr_ir_cool' => $serial['after_fr_ir_cool'] ?? null,
|
||||
'after_fr_ir_cool_r' => $serial['after_fr_ir_cool_r'] ?? null,
|
||||
'after_fr_ir_cool_y' => $serial['after_fr_ir_cool_y'] ?? null,
|
||||
'after_fr_ir_cool_b' => $serial['after_fr_ir_cool_b'] ?? null,
|
||||
'after_fr_freq' => $serial['after_fr_freq'] ?? null,
|
||||
'after_fr_speed' => $serial['after_fr_speed'] ?? null,
|
||||
'after_fr_leak_cur' => $serial['after_fr_leak_cur'] ?? null,
|
||||
'locked_rt_volt' => $serial['locked_rt_volt'] ?? null,
|
||||
'locked_rt_cur' => $serial['locked_rt_cur'] ?? null,
|
||||
'locked_rt_pow' => $serial['locked_rt_pow'] ?? null,
|
||||
'no_load_pickup_volt' => $serial['no_load_pickup_volt'] ?? null,
|
||||
'room_temperature' => $serial['room_temperature'] ?? null,
|
||||
'hv_test' => $serial['hv_test'] ?? null,
|
||||
'batch_number' => $serial['batch_number'] ?? null,
|
||||
'batch_count' => $serial['batch_count'] ?? 0,
|
||||
'result' => $serial['result'] ?? null,
|
||||
'remark' => $serial['remark'] ?? null,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
'output_flag' => $serial['output_flag'] ?? 0,
|
||||
'tested_by' => $serial['tested_by'] ?? null,
|
||||
'updated_by' => $serial['updated_by'] ?? null,
|
||||
'created_at' => $serial['created_at'] ?? null,
|
||||
'updated_at' => $serial['updated_at'] ?? $serial['created_at'],
|
||||
'scanned_at' => $serial['scanned_at'] ?? null,
|
||||
'update_count' => $updateCountString,
|
||||
'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,
|
||||
'before_fr_pow' => $serial['before_fr_pow'] ?? null,
|
||||
'before_fr_res_ry' => $serial['before_fr_res_ry'] ?? null,
|
||||
'before_fr_res_yb' => $serial['before_fr_res_yb'] ?? null,
|
||||
'before_fr_res_br' => $serial['before_fr_res_br'] ?? null,
|
||||
'before_fr_ir' => $serial['before_fr_ir'] ?? null,
|
||||
'before_fr_ir_r' => $serial['before_fr_ir_r'] ?? null,
|
||||
'before_fr_ir_y' => $serial['before_fr_ir_y'] ?? null,
|
||||
'before_fr_ir_b' => $serial['before_fr_ir_b'] ?? null,
|
||||
'before_fr_freq' => $serial['before_fr_freq'] ?? null,
|
||||
'before_fr_speed' => $serial['before_fr_speed'] ?? null,
|
||||
'after_fr_vol' => $serial['after_fr_vol'] ?? null,
|
||||
'after_fr_cur' => $serial['after_fr_cur'] ?? null,
|
||||
'after_fr_pow' => $serial['after_fr_pow'] ?? null,
|
||||
'after_fr_ir_hot' => $serial['after_fr_ir_hot'] ?? null,
|
||||
'after_fr_ir_hot_r' => $serial['after_fr_ir_hot_r'] ?? null,
|
||||
'after_fr_ir_hot_y' => $serial['after_fr_ir_hot_y'] ?? null,
|
||||
'after_fr_ir_hot_b' => $serial['after_fr_ir_hot_b'] ?? null,
|
||||
'after_fr_ir_cool' => $serial['after_fr_ir_cool'] ?? null,
|
||||
'after_fr_ir_cool_r' => $serial['after_fr_ir_cool_r'] ?? null,
|
||||
'after_fr_ir_cool_y' => $serial['after_fr_ir_cool_y'] ?? null,
|
||||
'after_fr_ir_cool_b' => $serial['after_fr_ir_cool_b'] ?? null,
|
||||
'after_fr_freq' => $serial['after_fr_freq'] ?? null,
|
||||
'after_fr_speed' => $serial['after_fr_speed'] ?? null,
|
||||
'after_fr_leak_cur' => $serial['after_fr_leak_cur'] ?? null,
|
||||
'locked_rt_volt' => $serial['locked_rt_volt'] ?? null,
|
||||
'locked_rt_cur' => $serial['locked_rt_cur'] ?? null,
|
||||
'locked_rt_pow' => $serial['locked_rt_pow'] ?? null,
|
||||
'no_load_pickup_volt' => $serial['no_load_pickup_volt'] ?? null,
|
||||
'room_temperature' => $serial['room_temperature'] ?? null,
|
||||
'hv_test' => $serial['hv_test'] ?? null,
|
||||
'batch_number' => $serial['batch_number'] ?? null,
|
||||
'batch_count' => $serial['batch_count'] ?? 0,
|
||||
'result' => $serial['result'] ?? null,
|
||||
'remark' => $serial['remark'] ?? null,
|
||||
'rework_count' => $serial['rework_count'] ?? 0,
|
||||
'output_flag' => $serial['output_flag'] ?? 0,
|
||||
'tested_by' => $serial['tested_by'] ?? null,
|
||||
'updated_by' => $serial['updated_by'] ?? null,
|
||||
'created_at' => $serial['created_at'] ?? null,
|
||||
'updated_at' => $serial['updated_at'] ?? $serial['created_at'],
|
||||
'scanned_at' => $serial['scanned_at'] ?? null,
|
||||
'update_count' => $updateCountString,
|
||||
];
|
||||
|
||||
// Insert the new record
|
||||
@@ -313,27 +346,32 @@ class TestingPanelController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($insertedSerials)) {
|
||||
if (count($existSnoCount) == count($insertedSnoCount)) {
|
||||
if (!empty($insertedSerials))
|
||||
{
|
||||
if(count($existSnoCount) == count($insertedSnoCount))
|
||||
{
|
||||
// $messages[] = "Inserted serial numbers are: " . implode(', ', $insertedSerials);
|
||||
return response()->json([
|
||||
'status_code' => 'SUCCESS',
|
||||
'status_description' => 'Inserted serial numbers are: '.implode(', ', $insertedSerials),
|
||||
'status_description' => 'Inserted serial numbers are: ' . implode(', ', $insertedSerials)
|
||||
], 200);
|
||||
} else {
|
||||
$missingSno = array_diff($existSnoCount, $insertedSnoCount);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$missingSno = array_diff($existSnoCount,$insertedSnoCount);
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Missed serial numbers are: '.implode(', ', $missingSno),
|
||||
'status_description' => "Missed serial numbers are: " . implode(', ', $missingSno)
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// return response($e->getMessage(), 500)->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Store testing panel readings internal server error : '.$e?->getCode(),
|
||||
'status_description' => 'Store testing panel readings internal server error : '.$e?->getCode()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
@@ -344,15 +382,16 @@ class TestingPanelController extends Controller
|
||||
public function get_motor_master(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser.':'.$expectedPw;
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
$header_auth = $request->header('Authorization');
|
||||
$expectedToken = $expectedUser . ':' . $expectedPw;
|
||||
|
||||
// $data = $request->all();
|
||||
if ('Bearer '.$expectedToken != $header_auth) {
|
||||
//$data = $request->all();
|
||||
if ("Bearer " . $expectedToken != $header_auth)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Invalid authorization token!',
|
||||
'status_description' => 'Invalid authorization token!'
|
||||
], 403);
|
||||
}
|
||||
|
||||
@@ -360,46 +399,45 @@ class TestingPanelController extends Controller
|
||||
$itemCode = $request->header('item-code');
|
||||
// $description = $item ? $item->description : '';
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
if ($plantCode == null || $plantCode == '')
|
||||
{
|
||||
// return response("ERROR: Plant Name can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Plant code can't be empty!",
|
||||
'status_description' => "Plant code can't be empty!"
|
||||
], 400);
|
||||
} elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
}
|
||||
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!',
|
||||
'status_description' => "Invalid plant code found!"
|
||||
], 400);
|
||||
} elseif ($itemCode == null || $itemCode == '' || ! $itemCode) {
|
||||
}
|
||||
else if($itemCode == null || $itemCode == '')
|
||||
{
|
||||
// return response("ERROR: OBD Number can't be empty", 400)
|
||||
// ->header('Content-Type', 'text/plain');
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code can't be empty!",
|
||||
], 404);
|
||||
} elseif (Str::length($itemCode) < 6) {
|
||||
'status_description' => "Item Code can't be empty!"
|
||||
], 400);
|
||||
}
|
||||
else if(Str::length($itemCode) < 6 || !ctype_alnum($itemCode))
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should contain minimum 6 digits!",
|
||||
], 404);
|
||||
} elseif (! ctype_alnum($itemCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should contain only alpha-numeric values!",
|
||||
], 404);
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $itemCode)) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code '{$itemCode}' should not begin with '0'!",
|
||||
], 404);
|
||||
'status_description' => "Invalid item code found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
|
||||
if (! $plant) {
|
||||
if (!$plant) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Plant not found!',
|
||||
'status_description' => "Plant not found!"
|
||||
], 400);
|
||||
}
|
||||
|
||||
@@ -407,79 +445,72 @@ class TestingPanelController extends Controller
|
||||
|
||||
$item = Item::where('code', $itemCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item code not found in item table!',
|
||||
'status_description' => "Item Code not found in item table!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||
|
||||
if (! $item) {
|
||||
if (!$item)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code not found in item table for the plant : '$plant->name'!",
|
||||
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$itemId = $item->id;
|
||||
|
||||
// Get description or empty string if not found
|
||||
$description = $item ? $item->description : '';
|
||||
|
||||
$category = $item ? $item->category : '';
|
||||
|
||||
$motorTestingMaster = MotorTestingMaster::where('item_id', $itemId)->first();
|
||||
$motorTestingMaster = MotorTestingMaster::where('plant_id', $plantId)->where('item_id', $item->id)->first();
|
||||
|
||||
if (! $motorTestingMaster) {
|
||||
if (!$motorTestingMaster)
|
||||
{
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => 'Item code not found in motor testing master table!',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$motorTestingMaster = MotorTestingMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
|
||||
|
||||
if (! $motorTestingMaster) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Item code not found in motor testing master table for the plant : '$plant->name'!",
|
||||
'status_description' => "Item Code not found in motor testing master table for the plant : '$plant->name'!"
|
||||
], 404);
|
||||
}
|
||||
|
||||
$output = [
|
||||
'mot_subassembly_code' => $motorTestingMaster->subassembly_code ?? '',
|
||||
'mot_model_name' => ($itemCode == '123456') ? 'SAMPLE TYPE' : $description,
|
||||
'mot_non_isi_model' => $motorTestingMaster->isi_model ? '0' : '1',
|
||||
'mot_phase' => $motorTestingMaster->phase ?? '',
|
||||
'mot_hp' => $motorTestingMaster->hp ?? '',
|
||||
'mot_kw' => $motorTestingMaster->kw ?? '',
|
||||
'mot_volt' => $motorTestingMaster->volt ?? '',
|
||||
'mot_cur' => $motorTestingMaster->current ?? '',
|
||||
'mot_rpm' => $motorTestingMaster->rpm ?? '',
|
||||
'mot_rate_torque_kg' => $motorTestingMaster->torque ?? '',
|
||||
'mot_freq' => $motorTestingMaster->frequency ?? '',
|
||||
'mot_conn' => $motorTestingMaster->connection ?? '',
|
||||
'mot_ins_res_limit' => $motorTestingMaster->ins_res_limit ?? '',
|
||||
'mot_ins_res_type' => $motorTestingMaster->ins_res_type ?? '',
|
||||
'mot_category' => $category,
|
||||
'mot_routine_test_time' => $motorTestingMaster->routine_test_time ?? '',
|
||||
'mot_res_ry_ll' => $motorTestingMaster->res_ry_ll ?? '',
|
||||
'mot_res_ry_ul' => $motorTestingMaster->res_ry_ul ?? '',
|
||||
'mot_res_yb_ll' => $motorTestingMaster->res_yb_ll ?? '',
|
||||
'mot_res_yb_ul' => $motorTestingMaster->res_yb_ul ?? '',
|
||||
'mot_res_br_ll' => $motorTestingMaster->res_br_ll ?? '',
|
||||
'mot_res_br_ul' => $motorTestingMaster->res_br_ul ?? '',
|
||||
'mot_lock_volt_limit' => $motorTestingMaster->lock_volt_limit ?? '',
|
||||
'mot_leak_cur_limit' => $motorTestingMaster->leak_cur_limit ?? '',
|
||||
'mot_lock_cur_ll' => $motorTestingMaster->lock_cur_ll ?? '',
|
||||
'mot_lock_cur_ul' => $motorTestingMaster->lock_cur_ul ?? '',
|
||||
'mot_noload_cur_ll' => $motorTestingMaster->noload_cur_ll ?? '',
|
||||
'mot_noload_cur_ul' => $motorTestingMaster->noload_cur_ul ?? '',
|
||||
'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_subassembly_code" => $motorTestingMaster->subassembly_code ?? "",
|
||||
"mot_model_name" => $description,
|
||||
"mot_non_isi_model" => $motorTestingMaster->isi_model ? "0" :"1",
|
||||
"mot_phase" => $motorTestingMaster->phase ?? "",
|
||||
"mot_hp" => $motorTestingMaster->hp ?? "",
|
||||
"mot_kw" => $motorTestingMaster->kw ?? "",
|
||||
"mot_volt" => $motorTestingMaster->volt ?? "",
|
||||
"mot_cur" => $motorTestingMaster->current ?? "",
|
||||
"mot_rpm" => $motorTestingMaster->rpm ?? "",
|
||||
"mot_rate_torque_kg" => $motorTestingMaster->torque ?? "",
|
||||
"mot_freq" => $motorTestingMaster->frequency ?? "",
|
||||
"mot_conn" => $motorTestingMaster->connection ?? "",
|
||||
"mot_ins_res_limit" => $motorTestingMaster->ins_res_limit ?? "",
|
||||
"mot_ins_res_type" => $motorTestingMaster->ins_res_type ?? "",
|
||||
"mot_category" => $category,
|
||||
"mot_routine_test_time" => $motorTestingMaster->routine_test_time ?? "",
|
||||
"mot_res_ry_ll" => $motorTestingMaster->res_ry_ll ?? "",
|
||||
"mot_res_ry_ul" => $motorTestingMaster->res_ry_ul ?? "",
|
||||
"mot_res_yb_ll" => $motorTestingMaster->res_yb_ll ?? "",
|
||||
"mot_res_yb_ul" => $motorTestingMaster->res_yb_ul ?? "",
|
||||
"mot_res_br_ll" => $motorTestingMaster->res_br_ll ?? "",
|
||||
"mot_res_br_ul" => $motorTestingMaster->res_br_ul ?? "",
|
||||
"mot_lock_volt_limit" => $motorTestingMaster->lock_volt_limit ?? "",
|
||||
"mot_leak_cur_limit" => $motorTestingMaster->leak_cur_limit ?? "",
|
||||
"mot_lock_cur_ll" => $motorTestingMaster->lock_cur_ll ?? "",
|
||||
"mot_lock_cur_ul" => $motorTestingMaster->lock_cur_ul ?? "",
|
||||
"mot_noload_cur_ll" => $motorTestingMaster->noload_cur_ll ?? "",
|
||||
"mot_noload_cur_ul" => $motorTestingMaster->noload_cur_ul ?? "",
|
||||
"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 ?? ""
|
||||
];
|
||||
|
||||
return response()->json($output, 200);
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Mail\InvalidQualityMail;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductCharacteristicsMaster;
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use App\Models\QualityValidation;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
|
||||
class ProductionCheckList extends Component
|
||||
{
|
||||
|
||||
public $records = [];
|
||||
|
||||
public $existingRecords = [];
|
||||
|
||||
public bool $shouldSkipChecklist = false;
|
||||
|
||||
public array $checklist = [];
|
||||
|
||||
public $showChecklist = false;
|
||||
|
||||
public $skipChecklistValidation = false;
|
||||
|
||||
protected $listeners = ['focus-item-id' => 'handleFocus', 'trigger-create' => 'doCreate',];
|
||||
|
||||
public $data =
|
||||
[
|
||||
'item_id' => '',
|
||||
'plant_id' => '',
|
||||
];
|
||||
|
||||
public $data1 = [
|
||||
'checklist' => [],
|
||||
];
|
||||
|
||||
#[On('focus-item-id')]
|
||||
public function handleFocus()
|
||||
{
|
||||
$this->dispatch('focus-input');
|
||||
}
|
||||
|
||||
public function doCreate()
|
||||
{
|
||||
$this->create();
|
||||
|
||||
$this->shouldSkipChecklist = false;
|
||||
}
|
||||
|
||||
|
||||
public function mount($records = [])
|
||||
{
|
||||
$this->records = collect($records);
|
||||
}
|
||||
|
||||
public function cancel()
|
||||
{
|
||||
$this->dispatch('checklist-cancelled');
|
||||
}
|
||||
|
||||
public function saveChecklist()
|
||||
{
|
||||
if (empty($this->checklist) || count($this->checklist) != count($this->records)) {
|
||||
Notification::make()
|
||||
->title('Incomplete Checklist')
|
||||
->body('Please complete all checklist fields before submitting.')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$item = Item::where('code', $this->data['item_id'])->first();
|
||||
|
||||
if (! $item) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Code')
|
||||
->body('Item not found for given code.')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$itemAgaPlant = Item::where('code', $this->data['item_id'])->where('plant_id', $this->data['plant_id'])->first();
|
||||
|
||||
$plant = Plant::find($this->data['plant_id']);
|
||||
|
||||
if (! $itemAgaPlant) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Code')
|
||||
->body("Item code '$this->data['item_id']' not found for given plant code '{$plant?->code}'.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$itemId = $itemAgaPlant->id;
|
||||
|
||||
$exists = QualityValidation::where('plant_id', $this->data['plant_id'] ?? null)
|
||||
->where('serial_number', $this->data['serial_number'] ?? null)
|
||||
->first();
|
||||
|
||||
$plan = Plant::find($this->data['plant_id']);
|
||||
|
||||
if ($exists) {
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Number')
|
||||
->body("serial number {$this->data['serial_number']} already exists for the selected plant $plan->code.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$qualityValidation = QualityValidation::create([
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
'sticker_master_id' => $this->data['sticker_master_id'] ?? null,
|
||||
'production_order' => $this->data['production_order'] ?? null,
|
||||
'serial_number_motor' => $this->data['serial_number_motor'] ?? null,
|
||||
'serial_number_pump' => $this->data['serial_number_pump'] ?? null,
|
||||
'serial_number_pumpset' => $this->data['serial_number_pumpset'] ?? null,
|
||||
'pack_slip_motor' => $this->data['pack_slip_motor'] ?? null,
|
||||
'pack_slip_pump' => $this->data['pack_slip_pump'] ?? null,
|
||||
'pack_slip_pumpset' => $this->data['pack_slip_pumpset'] ?? null,
|
||||
'name_plate_motor' => $this->data['name_plate_motor'] ?? null,
|
||||
'name_plate_pump' => $this->data['name_plate_pump'] ?? null,
|
||||
'name_plate_pumpset' => $this->data['name_plate_pumpset'] ?? null,
|
||||
'tube_sticker_motor' => $this->data['tube_sticker_motor'] ?? null,
|
||||
'tube_sticker_pump' => $this->data['tube_sticker_pump'] ?? null,
|
||||
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'] ?? null,
|
||||
'warranty_card' => $this->data['warranty_card'] ?? null,
|
||||
'part_validation1' => $this->data['part_validation1'] ?? null,
|
||||
'part_validation2' => $this->data['part_validation2'] ?? null,
|
||||
'part_validation3' => $this->data['part_validation3'] ?? null,
|
||||
'part_validation4' => $this->data['part_validation4'] ?? null,
|
||||
'part_validation5' => $this->data['part_validation5'] ?? null,
|
||||
'operator_id' => $this->data['operator_id'] ?? null,
|
||||
'uom' => $this->data['uom'] ?? null,
|
||||
'serial_number' => $this->data['serial_number'] ?? null,
|
||||
]);
|
||||
|
||||
if (! $qualityValidation || ! $qualityValidation->exists) {
|
||||
Notification::make()
|
||||
->title('Failed to save Quality Validation')
|
||||
->body('Something went wrong while inserting data.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$hasNotOk = collect($this->checklist)->contains(function ($val) {
|
||||
return $val != 'ok';
|
||||
});
|
||||
|
||||
$finalInspectionStatus = $hasNotOk ? 'NotOk' : 'Ok';
|
||||
|
||||
foreach ($this->checklist as $characteristicId => $value) {
|
||||
|
||||
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
|
||||
|
||||
ProductionCharacteristic::create([
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'item_id' => $itemId ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
'machine_id' => $characteristic?->machine_id ?? null,
|
||||
'production_order' => $this->data['production_order'] ?? null,
|
||||
'serial_number' => $this->data['serial_number'] ?? null,
|
||||
'characteristic_name' => $characteristic?->name ?? null,
|
||||
'observed_value' => $this->data['observed_value'] ?? null,
|
||||
'status' => $value == 'ok' ? 'Ok' : 'NotOk',
|
||||
'inspection_status' => $finalInspectionStatus ?? null,
|
||||
'created_by' => $this->data['operator_id'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($finalInspectionStatus == 'NotOk') {
|
||||
|
||||
$mailData = \App\Filament\Resources\QualityValidationResource::getMailData($this->data['plant_id']);
|
||||
|
||||
$mPlantName = $mailData['plant_name'];
|
||||
$emails = $mailData['emails'];
|
||||
$mUserName = Filament::auth()->user()->name;
|
||||
$itemCode = $this->data['item_id'] ?? null;
|
||||
$sNo = $this->data['serial_number'] ?? null;
|
||||
$mPorder = $this->data['production_order'] ?? null;
|
||||
$mLinePart = Line::where('id', $this->data['line_id'] ?? null)
|
||||
->value('name');
|
||||
$mExpectedValue = null; // optional
|
||||
$state = $itemCode . '|' . $sNo;
|
||||
|
||||
if (!empty($emails)) {
|
||||
Mail::to($emails)->queue(
|
||||
new InvalidQualityMail(
|
||||
$state,
|
||||
$mPorder,
|
||||
$mPlantName,
|
||||
$mLinePart,
|
||||
$mUserName,
|
||||
$mExpectedValue,
|
||||
'FinalInspectionNotOk'
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
\Log::warning("No emails configured for plant: {$mPlantName}");
|
||||
}
|
||||
}
|
||||
|
||||
$this->showChecklist = false;
|
||||
|
||||
$this->dispatch('checklist-saved');
|
||||
}
|
||||
|
||||
public static function getMailData($plantId)
|
||||
{
|
||||
$globalEmails = AlertMailRule::where('plant', 0)
|
||||
->where('module', 'QualityValidation')
|
||||
->where('rule_name', 'QualityMail')
|
||||
->where(fn ($q) => $q->whereNull('schedule_type')->orWhere('schedule_type', ''))
|
||||
->pluck('email')
|
||||
->toArray();
|
||||
|
||||
if (! empty($globalEmails)) {
|
||||
return [
|
||||
'plant_id' => 0,
|
||||
'plant_name' => 'All Plants',
|
||||
'emails' => $globalEmails,
|
||||
];
|
||||
}
|
||||
|
||||
$mPlantName = Plant::where('id', $plantId)->value('name');
|
||||
|
||||
$emails = AlertMailRule::where('plant', $plantId)
|
||||
->where('module', 'QualityValidation')
|
||||
->where('rule_name', 'QualityMail')
|
||||
->where(fn ($q) => $q->whereNull('schedule_type')->orWhere('schedule_type', ''))
|
||||
->pluck('email')
|
||||
->toArray();
|
||||
|
||||
return [
|
||||
'plant_id' => $plantId,
|
||||
'plant_name' => $mPlantName,
|
||||
'emails' => $emails,
|
||||
];
|
||||
}
|
||||
|
||||
public function updatedDataChecklist()
|
||||
{
|
||||
$this->dispatch('checklistUpdated', $this->data['checklist']);
|
||||
}
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.production-check-list');
|
||||
}
|
||||
}
|
||||
@@ -28,12 +28,10 @@ class InvalidQualityMail extends Mailable
|
||||
public $greeting;
|
||||
public $subjectLine;
|
||||
|
||||
public $mExpectedValue;
|
||||
|
||||
public $mLinePart;
|
||||
|
||||
public $itemCode;
|
||||
public function __construct($parNo, $mProdOrder, $mplantName, $mLinePart, $mUserName, $mExpectedValue, $mailType = 'InvalidPartNumber')
|
||||
public function __construct($parNo, $mProdOrder, $mplantName, $mLinePart, $mUserName, $mailType = 'InvalidPartNumber')
|
||||
{
|
||||
$this->mPartNo = $parNo;
|
||||
$this->mProdOrder = $mProdOrder;
|
||||
@@ -41,7 +39,6 @@ class InvalidQualityMail extends Mailable
|
||||
$this->mLinePart = $mLinePart;
|
||||
$this->mUserName = $mUserName;
|
||||
$this->mailType = $mailType;
|
||||
$this->mExpectedValue = $mExpectedValue;
|
||||
}
|
||||
|
||||
public function envelope(): Envelope
|
||||
@@ -60,12 +57,6 @@ class InvalidQualityMail extends Mailable
|
||||
case 'InvalidPartNumber5':
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
break;
|
||||
case 'FinalInspectionNotOk':
|
||||
$this->subjectLine = "Quality Part Validation Inspection Status ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidTubeStickerPump':
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
break;
|
||||
case 'InvalidPartNumber':
|
||||
default:
|
||||
$this->subjectLine = "Quality Part Validation ({$this->mplantName})";
|
||||
@@ -89,7 +80,6 @@ class InvalidQualityMail extends Mailable
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 2:</b> {$this->mPartNo}<br>
|
||||
<b>Expected Scanned Part Number 2:</b> {$this->mExpectedValue}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
@@ -101,7 +91,6 @@ class InvalidQualityMail extends Mailable
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 3:</b> {$this->mPartNo}<br>
|
||||
<b>Expected Scanned Part Number 2:</b> {$this->mExpectedValue}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
@@ -113,7 +102,6 @@ class InvalidQualityMail extends Mailable
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 4:</b> {$this->mPartNo}<br>
|
||||
<b>Expected Scanned Part Number 2:</b> {$this->mExpectedValue}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
@@ -125,52 +113,6 @@ class InvalidQualityMail extends Mailable
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 5:</b> {$this->mPartNo}<br>
|
||||
<b>Expected Scanned Part Number 2:</b> {$this->mExpectedValue}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'FinalInspectionNotOk':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the final inspection is not ok for scanned serial number.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Serial Number:</b> {$this->mPartNo}<br>
|
||||
<b>Final Inspection :</b>Not OK<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidTubeStickerPump':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned tube sticker pump serial number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Tube Pump QR:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidTubeStickerMotor':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned tube sticker motor serial number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Tube Motor QR:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
case 'InvalidTubeStickerPumpset':
|
||||
$this->greeting = "
|
||||
Dear Sir/Madam,<br><br>
|
||||
Please note that the scanned tube sticker pumpset serial number appears to be incorrect.<br>
|
||||
<b>Plant:</b> {$this->mplantName}<br>
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Tube Pumpset QR:</b> {$this->mPartNo}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
@@ -183,7 +125,6 @@ class InvalidQualityMail extends Mailable
|
||||
<b>Line Name:</b> {$this->mLinePart}<br>
|
||||
<b>Production Order:</b> {$this->mProdOrder}<br>
|
||||
<b>Scanned Part Number 1:</b> {$this->mPartNo}<br>
|
||||
<b>Expected Scanned Part Number 1:</b> {$this->mExpectedValue}<br>
|
||||
<b>Employee Code:</b> {$this->mUserName}<br>
|
||||
";
|
||||
break;
|
||||
|
||||
@@ -41,7 +41,7 @@ class Item extends Model
|
||||
|
||||
public function motorTestingMasters()
|
||||
{
|
||||
return $this->hasMany(MotorTestingMaster::class, 'item_id', 'id');
|
||||
return $this->hasMany(MotorTestingMaster::class);
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
@@ -69,16 +69,6 @@ class Item extends Model
|
||||
return $this->hasMany(ClassCharacteristic::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
public function requestCharacteristics()
|
||||
{
|
||||
return $this->hasMany(RequestCharacteristic::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
public function productionCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ProductionCharacteristic::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
public function weightValidations()
|
||||
{
|
||||
return $this->hasMany(WeightValidation::class);
|
||||
|
||||
@@ -71,11 +71,6 @@ class Line extends Model
|
||||
return $this->hasMany(CharacteristicValue::class);
|
||||
}
|
||||
|
||||
public function productionCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ProductionCharacteristic::class);
|
||||
}
|
||||
|
||||
public function workGroup1()
|
||||
{
|
||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
|
||||
|
||||
@@ -48,16 +48,6 @@ class Machine extends Model
|
||||
return $this->hasMany(ClassCharacteristic::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
public function requestCharacteristics()
|
||||
{
|
||||
return $this->hasMany(RequestCharacteristic::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
public function productionCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ProductionCharacteristic::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
|
||||
@@ -63,11 +63,6 @@ class Plant extends Model
|
||||
return $this->hasMany(QualityValidation::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function motorTestingMasters()
|
||||
{
|
||||
return $this->hasMany(MotorTestingMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class, 'plant_id', 'id');
|
||||
@@ -128,16 +123,6 @@ class Plant extends Model
|
||||
// return $this->hasMany(RejectReason::class, 'plant_id', 'id');
|
||||
// }
|
||||
|
||||
public function requestCharacteristics()
|
||||
{
|
||||
return $this->hasMany(RequestCharacteristic::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function productionCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ProductionCharacteristic::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class, 'plant_id', 'id');
|
||||
|
||||
@@ -21,7 +21,6 @@ class ProcessOrder extends Model
|
||||
'coil_number',
|
||||
'order_quantity',
|
||||
'received_quantity',
|
||||
'updated_order_quantity',
|
||||
'sfg_number',
|
||||
'machine_name',
|
||||
'scrap_quantity',
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProductionCharacteristic extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'plant_id',
|
||||
'line_id',
|
||||
'item_id',
|
||||
'machine_id',
|
||||
'production_order',
|
||||
'serial_number',
|
||||
'observed_value',
|
||||
'characteristic_name',
|
||||
'status',
|
||||
'inspection_status',
|
||||
'remark',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function plant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Plant::class);
|
||||
}
|
||||
|
||||
public function line(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Line::class);
|
||||
}
|
||||
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
public function machine(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Machine::class);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\ProductionCharacteristic;
|
||||
use App\Models\User;
|
||||
|
||||
class ProductionCharacteristicPolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view-any ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, ProductionCharacteristic $productioncharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('view ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('create ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, ProductionCharacteristic $productioncharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('update ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, ProductionCharacteristic $productioncharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete any models.
|
||||
*/
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('delete-any ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, ProductionCharacteristic $productioncharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore any models.
|
||||
*/
|
||||
public function restoreAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('restore-any ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can replicate the model.
|
||||
*/
|
||||
public function replicate(User $user, ProductionCharacteristic $productioncharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('replicate ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can reorder the models.
|
||||
*/
|
||||
public function reorder(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('reorder ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
public function forceDelete(User $user, ProductionCharacteristic $productioncharacteristic): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete ProductionCharacteristic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete any models.
|
||||
*/
|
||||
public function forceDeleteAny(User $user): bool
|
||||
{
|
||||
return $user->checkPermissionTo('force-delete-any ProductionCharacteristic');
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ return new class extends Migration
|
||||
zmm_type TEXT DEFAULT NULL,
|
||||
zmm_usp TEXT DEFAULT NULL,
|
||||
mark_status TEXT DEFAULT NULL,
|
||||
marked_datetime TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
marked_physical_count TEXT DEFAULT '0',
|
||||
marked_expected_time TEXT DEFAULT '0',
|
||||
marked_by TEXT DEFAULT NULL,
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE process_orders
|
||||
ADD COLUMN updated_order_quantity NUMERIC(10,3) NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
CREATE TABLE production_characteristics (
|
||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||
plant_id BIGINT NOT NULL,
|
||||
line_id BIGINT NOT NULL,
|
||||
item_id BIGINT NOT NULL,
|
||||
machine_id BIGINT NOT NULL,
|
||||
|
||||
production_order TEXT DEFAULT NULL,
|
||||
serial_number TEXT DEFAULT NULL,
|
||||
characteristic_name TEXT DEFAULT NULL,
|
||||
observed_value TEXT DEFAULT NULL,
|
||||
|
||||
status TEXT DEFAULT NULL,
|
||||
inspection_status TEXT DEFAULT NULL,
|
||||
remark TEXT DEFAULT NULL,
|
||||
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
created_by TEXT DEFAULT NULL,
|
||||
updated_by TEXT DEFAULT NULL,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||
FOREIGN KEY (line_id) REFERENCES lines (id),
|
||||
FOREIGN KEY (item_id) REFERENCES items (id),
|
||||
FOREIGN KEY (machine_id) REFERENCES machines (id)
|
||||
);
|
||||
SQL;
|
||||
DB::statement($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('production_characteristics');
|
||||
}
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
<div>
|
||||
@livewire('production-check-list', [
|
||||
'records' => $existingRecords,
|
||||
'data' => $data
|
||||
])
|
||||
</div>
|
||||
@@ -1,126 +0,0 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="mb-8">
|
||||
<h1 class="text-4xl font-bold tracking-tight">
|
||||
CRI Digital Manufacturing IIoT Platform
|
||||
</h1>
|
||||
<p class="text-lg text-gray-600 mt-2">
|
||||
Complete visibility, traceability, and control across the manufacturing operations.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- BANNER -->
|
||||
{{-- <div class="w-full overflow-hidden rounded-2xl shadow mb-10"> --}}
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-72 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- INTRO -->
|
||||
<div class="max-w-4xl mb-10">
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
CRI Digital Manufacturing IIoT is built to deliver
|
||||
<strong>end-to-end traceability, real-time insights, and operational transparency</strong>
|
||||
across plants, lines, and production processes.
|
||||
</p>
|
||||
|
||||
<p class="text-lg text-gray-700">
|
||||
The platform ensures <strong>right quality and on-time delivery</strong> by enabling
|
||||
complete tracking of materials, production orders, and finished goods—helping teams
|
||||
make faster, data-driven decisions with confidence.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- KEY PILLARS -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-10">
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">🔍 Traceability</h3>
|
||||
<p class="text-gray-600">
|
||||
Track materials, batches, and serials from input to dispatch.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">✅ Quality Assurance</h3>
|
||||
<p class="text-gray-600">
|
||||
Validate process data and ensure first-time-right production.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">⏱ On-Time Delivery</h3>
|
||||
<p class="text-gray-600">
|
||||
Identify delays early and meet production commitments.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">📊 Real-Time Insights</h3>
|
||||
<p class="text-gray-600">
|
||||
Monitor performance and take quick corrective actions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SUPPORT -->
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-3">24×7 Support</h2>
|
||||
<p class="text-gray-700 mb-2">
|
||||
Our dedicated IIoT support team is available round-the-clock to ensure
|
||||
uninterrupted operations and quick issue resolution.
|
||||
</p>
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
📞 Support Landline: <span class="font-semibold">0422 711 7179</span>
|
||||
</p>
|
||||
{{-- <p class="text-lg font-medium text-gray-900">
|
||||
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p> --}}
|
||||
</div>
|
||||
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">24×7 Support</h2>
|
||||
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
Our support structure is designed to ensure quick resolution based on the type
|
||||
of issue — whether it is on-site, application-related, or infrastructure-related.
|
||||
</p>
|
||||
|
||||
<div class="space-y-3">
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
🏭 <strong>Plant & On-Site Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For plant visits, industry-level issues, and on-ground validation
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">8925899458 / 8925899459</span>
|
||||
</p>
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
💻 <strong>Application & Logic Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For website errors, logic issues, and application-level problems
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
|
||||
<!-- TEAM -->
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">IIOT Team Members</h2>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 text-gray-700">
|
||||
<div class="flex items-center gap-2">👤 Jothikumar</div>
|
||||
<div class="flex items-center gap-2">👤 Jeithef Shibu</div>
|
||||
<div class="flex items-center gap-2">👤 Dhanabalan</div>
|
||||
<div class="flex items-center gap-2">👤 Ranjith</div>
|
||||
<div class="flex items-center gap-2">👤 Srimathy</div>
|
||||
<div class="flex items-center gap-2">👤 Gokul</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
</x-filament-panels::page>
|
||||
@@ -1,13 +1,126 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2 sm:gap-4 md:gap-4 p-2 md:p-4 items-start">
|
||||
{{-- Filters form --}}
|
||||
<div class="space-y-4 w-full max-w-full col-span-1">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="mb-8">
|
||||
<h1 class="text-4xl font-bold tracking-tight">
|
||||
CRI Digital Manufacturing IIoT Platform
|
||||
</h1>
|
||||
<p class="text-lg text-gray-600 mt-2">
|
||||
Complete visibility, traceability, and control across your manufacturing operations.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- BANNER -->
|
||||
{{-- <div class="w-full overflow-hidden rounded-2xl shadow mb-10"> --}}
|
||||
<div class="w-full overflow-hidden rounded-xl shadow">
|
||||
<img
|
||||
src="{{ asset('images/iiot-banner.jpg') }}"
|
||||
alt="CRI Digital Manufacturing IIoT"
|
||||
class="w-full h-72 object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- INTRO -->
|
||||
<div class="max-w-4xl mb-10">
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
CRI Digital Manufacturing IIoT is built to deliver
|
||||
<strong>end-to-end traceability, real-time insights, and operational transparency</strong>
|
||||
across plants, lines, and production processes.
|
||||
</p>
|
||||
|
||||
<p class="text-lg text-gray-700">
|
||||
The platform ensures <strong>right quality and on-time delivery</strong> by enabling
|
||||
complete tracking of materials, production orders, and finished goods—helping teams
|
||||
make faster, data-driven decisions with confidence.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- KEY PILLARS -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-10">
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">🔍 Traceability</h3>
|
||||
<p class="text-gray-600">
|
||||
Track materials, batches, and serials from input to dispatch.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{-- Stat widget --}}
|
||||
<div class="w-full max-w-full col-span-1 sm:col-span-1 lg:col-span-2">
|
||||
@livewire(\App\Filament\Widgets\CumulativeChart::class)
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">✅ Quality Assurance</h3>
|
||||
<p class="text-gray-600">
|
||||
Validate process data and ensure first-time-right production.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">⏱ On-Time Delivery</h3>
|
||||
<p class="text-gray-600">
|
||||
Identify delays early and meet production commitments.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h3 class="text-lg font-semibold mb-2">📊 Real-Time Insights</h3>
|
||||
<p class="text-gray-600">
|
||||
Monitor performance and take quick corrective actions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SUPPORT -->
|
||||
<div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-3">24×7 Support</h2>
|
||||
<p class="text-gray-700 mb-2">
|
||||
Our dedicated IIoT support team is available round-the-clock to ensure
|
||||
uninterrupted operations and quick issue resolution.
|
||||
</p>
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
📞 Support Landline: <span class="font-semibold">0422 711 7179</span>
|
||||
</p>
|
||||
{{-- <p class="text-lg font-medium text-gray-900">
|
||||
📞 Technical Support Contact: <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p> --}}
|
||||
</div>
|
||||
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">24×7 Support</h2>
|
||||
|
||||
<p class="text-lg text-gray-700 mb-4">
|
||||
Our support structure is designed to ensure quick resolution based on the type
|
||||
of issue — whether it is on-site, application-related, or infrastructure-related.
|
||||
</p>
|
||||
|
||||
<div class="space-y-3">
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
🏭 <strong>Plant & On-Site Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For plant visits, industry-level issues, and on-ground validation
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">8925899458 / 8925899459</span>
|
||||
</p>
|
||||
|
||||
<p class="text-lg font-medium text-gray-900">
|
||||
💻 <strong>Application & Logic Support</strong> <br>
|
||||
<span class="text-gray-700">
|
||||
For website errors, logic issues, and application-level problems
|
||||
</span><br>
|
||||
📞 <span class="font-semibold">9952468104 / 9100832269</span>
|
||||
</p>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
|
||||
<!-- TEAM -->
|
||||
{{-- <div class="bg-white rounded-xl border p-6 shadow-sm">
|
||||
<h2 class="text-2xl font-semibold mb-4">IIOT Team Members</h2>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 text-gray-700">
|
||||
<div class="flex items-center gap-2">👤 Jothikumar</div>
|
||||
<div class="flex items-center gap-2">👤 Jeithef Shibu</div>
|
||||
<div class="flex items-center gap-2">👤 Dhanabalan</div>
|
||||
<div class="flex items-center gap-2">👤 Ranjith</div>
|
||||
<div class="flex items-center gap-2">👤 Srimathy</div>
|
||||
<div class="flex items-center gap-2">👤 Gokul</div>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
</x-filament-panels::page>
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
<div class="fixed inset-0 flex items-center justify-center z-50">
|
||||
|
||||
<div class="bg-white max-h-[80vh] overflow-hidden p-6 rounded-lg shadow-lg pointer-events-auto"
|
||||
style="width:30vw !important; max-width:none !important;">
|
||||
|
||||
@if($records && $records->count())
|
||||
<div style="max-height:250px; overflow-y:auto; border:1px solid #ccc;">
|
||||
|
||||
{{-- <table class="min-w-full border"> --}}
|
||||
<table class="w-full table-fixed border text-sm">
|
||||
<thead>
|
||||
<tr class="bg-gray-100">
|
||||
<th class="border px-2 py-1 w-2/3">Characteristics</th>
|
||||
<th class="border px-2 py-1 w-1/6">OK</th>
|
||||
<th class="border px-2 py-1 w-1/6">Not OK</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($records as $record)
|
||||
<tr>
|
||||
<td class="border p-2">
|
||||
{{ $record['name'] }}
|
||||
</td>
|
||||
|
||||
<td class="border text-center">
|
||||
<input type="radio"
|
||||
wire:model="checklist.{{ $record['id'] }}"
|
||||
value="ok">
|
||||
</td>
|
||||
|
||||
<td class="border text-center">
|
||||
<input type="radio"
|
||||
wire:model="checklist.{{ $record['id'] }}"
|
||||
value="not_ok">
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@else
|
||||
<p>No records found.</p>
|
||||
@endif
|
||||
<div class="border-t mt-6 pt-4 flex justify-end gap-3">
|
||||
|
||||
<button
|
||||
type="button"
|
||||
wire:click="cancel"
|
||||
style="background-color:#dc2626; color:white;"
|
||||
class="px-6 py-2 rounded-lg shadow-md"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
wire:click="saveChecklist"
|
||||
style="background-color:#16a34a; color:white;"
|
||||
class="px-6 py-2 rounded-lg shadow-md"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user