Compare commits
566 Commits
da0c13b33a
...
gha-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfed40f535 | ||
|
|
83f98d9e83 | ||
|
|
3d84661640 | ||
|
|
26ecaf49ef | ||
|
|
5fe2b74174 | ||
|
|
ce901e3b78 | ||
|
|
31ad036d0e | ||
|
|
c363faa357 | ||
|
|
a71864905e | ||
|
|
c75ac4781f | ||
|
|
c76cf1fb98 | ||
|
|
95a4ddf11e | ||
|
|
c309bed7d9 | ||
|
|
b2dc9e7024 | ||
|
|
bff2601ddc | ||
|
|
e80812b82e | ||
|
|
81c7812ef6 | ||
|
|
14b5f4ae8b | ||
|
|
eb31e6a406 | ||
|
|
740ceff0f8 | ||
|
|
ea1261fb01 | ||
|
|
74ad73622d | ||
|
|
a62220c9d0 | ||
|
|
a5036b7d6f | ||
|
|
27b8058ba8 | ||
|
|
58091726a4 | ||
|
|
6bdd210162 | ||
|
|
b9e3d463ed | ||
|
|
418e4fcf79 | ||
|
|
33881a3978 | ||
|
|
9d4cf0e3d9 | ||
|
|
72704a4a3f | ||
|
|
a34b55267d | ||
|
|
b6dcb93402 | ||
|
|
313dc012d5 | ||
|
|
2541300910 | ||
|
|
d1894e0d35 | ||
|
|
e5143a0ce8 | ||
|
|
b1674bba53 | ||
|
|
52a25fec8e | ||
|
|
dafe1ca458 | ||
|
|
af384faa7c | ||
|
|
c6f61fa19a | ||
|
|
aaa93e740b | ||
|
|
33acf73b5e | ||
|
|
ea5af41f7f | ||
|
|
c8ea502833 | ||
|
|
7e317f6e5f | ||
|
|
1465734acd | ||
|
|
642053653c | ||
|
|
27524c4d62 | ||
|
|
9fa4c0dd49 | ||
|
|
4d5b14fe69 | ||
|
|
b4ca4a9fcd | ||
|
|
484bc6d070 | ||
|
|
b153a53f4b | ||
|
|
658dea8e72 | ||
|
|
e934cdb193 | ||
|
|
d61c61879f | ||
|
|
4b597629aa | ||
|
|
9173dcb50a | ||
|
|
4a17892865 | ||
|
|
e9d967e2c2 | ||
|
|
215e1302cc | ||
|
|
1f085b3f91 | ||
|
|
ab9c3a80db | ||
|
|
5f0c01176a | ||
|
|
b73202e03f | ||
|
|
6a8978f676 | ||
|
|
61320dfae8 | ||
|
|
7715a20c19 | ||
|
|
bb41d72701 | ||
|
|
fcb6a945ff | ||
|
|
2d2f0d3662 | ||
|
|
cb4605221c | ||
|
|
5a8775c092 | ||
|
|
bef0c986b2 | ||
|
|
80163fb0ff | ||
|
|
170b784a9b | ||
|
|
4311c64531 | ||
|
|
3c9cc702d4 | ||
|
|
752c3cb0da | ||
|
|
1597795c74 | ||
|
|
d75dcdfdd1 | ||
|
|
b8738a2f6a | ||
|
|
4ac1823e5b | ||
|
|
eb2b857aa7 | ||
|
|
693e3a23a4 | ||
|
|
49d2f1088f | ||
|
|
34b2a05166 | ||
|
|
ee99ada3e7 | ||
|
|
3665b63ff9 | ||
|
|
aeb3b694e4 | ||
|
|
a4d2c20451 | ||
|
|
15849fc543 | ||
|
|
fec85824c2 | ||
|
|
6d6d3f2d60 | ||
|
|
29de91e03d | ||
|
|
5ab109006e | ||
|
|
35aa2fab56 | ||
|
|
a87bc6e909 | ||
|
|
3818fa612e | ||
|
|
0f6b62b47a | ||
|
|
656dd17603 | ||
|
|
0c27bd4cfd | ||
|
|
c7779f49b7 | ||
|
|
49c4f25c79 | ||
|
|
f37f62be46 | ||
|
|
5465364ffd | ||
|
|
75963b3ce6 | ||
|
|
b36700af92 | ||
|
|
5a654d1d40 | ||
|
|
2f3b028b17 | ||
|
|
904d850638 | ||
|
|
f5e7bcb348 | ||
|
|
171c675014 | ||
|
|
bd5bb7f54c | ||
|
|
74c3243c06 | ||
|
|
bd0eed07ac | ||
|
|
b564e2debe | ||
|
|
4c8fa0bdd6 | ||
|
|
48ce6681ac | ||
|
|
cefebd9f86 | ||
|
|
3a0185391a | ||
|
|
c38a417b85 | ||
|
|
cfe8ac3496 | ||
|
|
be79dcdc45 | ||
|
|
9398374f88 | ||
|
|
43edf2ec5a | ||
|
|
08b142e70f | ||
|
|
de0de426f0 | ||
|
|
3eb9f64fca | ||
|
|
7ff55f0b25 | ||
|
|
3e0633def2 | ||
|
|
cea7f86fed | ||
|
|
af3ae0803c | ||
|
|
10b439f8e3 | ||
|
|
fc6b3efd0a | ||
|
|
6372e293e2 | ||
|
|
c2817aefe4 | ||
|
|
40ad560bca | ||
|
|
a5bc41beda | ||
|
|
ba48c1307e | ||
|
|
d222fe5a3b | ||
|
|
aa4cec997d | ||
|
|
c2c9470979 | ||
|
|
6ea2fc3d23 | ||
|
|
04da674868 | ||
|
|
0174a8494d | ||
|
|
bff1cb0d28 | ||
|
|
5543938eae | ||
|
|
4addab5573 | ||
|
|
000c80c1e6 | ||
|
|
aae2fafc1f | ||
|
|
e958a036c7 | ||
|
|
710ff318ef | ||
|
|
5ec4be082d | ||
|
|
955d143f52 | ||
|
|
5b287f974d | ||
|
|
f5345fc2b8 | ||
|
|
cd09b912ee | ||
|
|
008e9ff791 | ||
|
|
a0c0588e49 | ||
|
|
137341fc6c | ||
|
|
33d22dec5b | ||
|
|
231b65ff7a | ||
|
|
102d9af638 | ||
|
|
b20bff9003 | ||
|
|
c8ad6f3dda | ||
|
|
062ab6d8a1 | ||
|
|
4d4414ffa7 | ||
|
|
4f87a0d318 | ||
|
|
33f787c6ad | ||
|
|
bf6874fe96 | ||
|
|
3406dbc1c7 | ||
|
|
e20ebfe667 | ||
|
|
3012dd61bb | ||
|
|
cdc8a5ce54 | ||
|
|
f3a4aa7411 | ||
|
|
2ae71b9bb8 | ||
|
|
58fc922f24 | ||
|
|
68c5c88fc8 | ||
|
|
c4b4993e1d | ||
|
|
fd3ef4656c | ||
|
|
6e7b847e89 | ||
|
|
0fbe279bf9 | ||
|
|
8188cd6cef | ||
|
|
bdbfc8e024 | ||
|
|
c3f9c9f2c4 | ||
|
|
5cb2842954 | ||
|
|
6a0f5b57a6 | ||
|
|
690a6f8026 | ||
|
|
4392123c6a | ||
|
|
008cb5d82b | ||
|
|
12169a1276 | ||
|
|
14a1909163 | ||
|
|
51e9c6ba90 | ||
|
|
88bc62c8f2 | ||
|
|
0cb0758f67 | ||
|
|
123f67d9bc | ||
|
|
85746af6f7 | ||
|
|
8f95147a30 | ||
|
|
a33c73c2f2 | ||
|
|
017088c380 | ||
|
|
148b6444b6 | ||
|
|
49dbd357aa | ||
|
|
4a8802060a | ||
|
|
4d153fcfa7 | ||
|
|
a0db69a4c8 | ||
|
|
b13b5dbb05 | ||
|
|
fcf1fed70d | ||
|
|
bdb9d9b9c3 | ||
|
|
5435261e40 | ||
|
|
45d426b6b8 | ||
|
|
2de993c6d0 | ||
|
|
95436af7da | ||
|
|
d3ebee5020 | ||
|
|
f3c3dff6a0 | ||
|
|
829f5670ad | ||
|
|
b4a0893bfc | ||
|
|
98c445a98a | ||
|
|
789bc6a173 | ||
|
|
6904a03e1f | ||
|
|
fb29148011 | ||
|
|
e083c0e4a5 | ||
|
|
c2b193c5b8 | ||
|
|
dde57f31c3 | ||
|
|
62e66bf0c7 | ||
|
|
33d78861fb | ||
|
|
23fb2eed4d | ||
|
|
0199c8977c | ||
|
|
7d2ed7aff5 | ||
|
|
f52a38c133 | ||
|
|
5fd8b7e6bf | ||
|
|
61973a424e | ||
|
|
ced01440f5 | ||
|
|
cc48e4ae3d | ||
|
|
eb93a8602f | ||
|
|
b798cbcbfd | ||
|
|
630b921a37 | ||
|
|
1945e71ae1 | ||
|
|
72a1eca400 | ||
|
|
82b56c6cc9 | ||
|
|
04ed10d9e1 | ||
|
|
0fc1852ea2 | ||
|
|
fea6573a7a | ||
|
|
723d424b88 | ||
|
|
f9a0aa9fa0 | ||
|
|
934d449a6b | ||
|
|
cf1387db7f | ||
|
|
a9af944c27 | ||
|
|
32313c0609 | ||
|
|
b418e780b0 | ||
|
|
edc8a8f37b | ||
|
|
cbfe7a56bb | ||
|
|
3a796857b0 | ||
|
|
88cde40215 | ||
|
|
97d43ac8cf | ||
|
|
be466cfdc2 | ||
|
|
932488fdc3 | ||
|
|
ad5f52c72b | ||
|
|
19510d8348 | ||
|
|
ecf6d494de | ||
|
|
21c1d097aa | ||
|
|
1ea961a3b8 | ||
|
|
72df3fe3c3 | ||
|
|
ea4e2c929f | ||
|
|
09b69b9aa3 | ||
|
|
56a8058094 | ||
|
|
30c8804127 | ||
|
|
eae2d49e25 | ||
|
|
be6b20fb26 | ||
|
|
2492564c7a | ||
|
|
a205762649 | ||
|
|
40a9f14c53 | ||
|
|
0193298675 | ||
|
|
48b6a0e839 | ||
|
|
16d559683a | ||
|
|
5eba607944 | ||
|
|
7510fc3d77 | ||
|
|
c39bcaee02 | ||
|
|
4f2e811abb | ||
|
|
05ac6c7712 | ||
|
|
5f7911b5c2 | ||
|
|
0651ee40e9 | ||
|
|
c3cc345166 | ||
|
|
16aa118ef1 | ||
|
|
a46a5d437c | ||
|
|
08654025c6 | ||
|
|
809d31d7e7 | ||
|
|
cac691c82d | ||
|
|
88802d8a11 | ||
|
|
894f2a0e85 | ||
|
|
dec8a5b972 | ||
|
|
29c092a860 | ||
|
|
7760c64ed3 | ||
|
|
ce4f9d7246 | ||
|
|
22b653fc03 | ||
|
|
906e68e876 | ||
|
|
136ccffa5f | ||
|
|
c1985f11c3 | ||
|
|
98de344917 | ||
|
|
47d103659c | ||
|
|
38106496bc | ||
|
|
b74b362622 | ||
|
|
d99c8f2cb3 | ||
|
|
7d91e8976c | ||
|
|
c83be6936b | ||
|
|
5a850a11a9 | ||
|
|
35501f2bec | ||
|
|
be47d48931 | ||
|
|
5f79050b3f | ||
|
|
0fa0a9c128 | ||
|
|
bb019e0b13 | ||
|
|
abc50de038 | ||
|
|
044d27336d | ||
|
|
376d0800dd | ||
|
|
e8bac66e51 | ||
|
|
dc32cf623c | ||
|
|
4fa053e6e5 | ||
|
|
9201eae044 | ||
|
|
6dcc4def51 | ||
|
|
fc0963a3cb | ||
|
|
df6b5af920 | ||
|
|
26c76eb539 | ||
|
|
84ac80a18a | ||
|
|
c826a0da3d | ||
|
|
c60a78d85a | ||
|
|
5b450adbda | ||
|
|
8ebf76f91c | ||
|
|
21d70380a8 | ||
|
|
f3ffe4bff6 | ||
|
|
64af4215aa | ||
|
|
c2c91e1427 | ||
|
|
fd8f82c3b1 | ||
|
|
2bd69214d6 | ||
|
|
58f98c7632 | ||
|
|
ce80f8e7e5 | ||
|
|
37d6c174c3 | ||
|
|
7757347407 | ||
|
|
2b02e01cca | ||
|
|
390740bbd0 | ||
|
|
561c2d7bf2 | ||
|
|
9b1a0d5b58 | ||
|
|
580ca9d569 | ||
|
|
ad06e0d4d2 | ||
|
|
e3c651d22b | ||
|
|
75212ea2b1 | ||
|
|
670b47bc31 | ||
|
|
03cbd6f877 | ||
|
|
7bf910c800 | ||
|
|
bbdd05bed0 | ||
|
|
3ec4cd3c3b | ||
|
|
79ff0b10a7 | ||
|
|
2c90676f62 | ||
|
|
46eaa273c3 | ||
|
|
68060fe5fc | ||
|
|
5e2ecd2460 | ||
|
|
3c70cd0260 | ||
|
|
f641602533 | ||
|
|
fd6aea01ed | ||
|
|
f6d7394ebd | ||
|
|
6b39fc7236 | ||
|
|
2fbae54e6b | ||
|
|
6477c7d47a | ||
|
|
68dd7d2a7a | ||
|
|
37278f2754 | ||
|
|
a2972d5c6d | ||
|
|
01f2180fa9 | ||
|
|
569290658d | ||
|
|
bfbb9f98ea | ||
|
|
3ad53185d1 | ||
|
|
de6e38bc5f | ||
|
|
af5ede975b | ||
|
|
7ea8231c90 | ||
|
|
1bf5f0b31a | ||
|
|
9347dbf466 | ||
|
|
023d2e13fb | ||
|
|
af793faf0d | ||
|
|
ff75934526 | ||
|
|
338449f3f8 | ||
|
|
1af5a7d0b6 | ||
|
|
b4116c7492 | ||
|
|
6b17578f40 | ||
|
|
e64d1c982d | ||
|
|
23a258add9 | ||
|
|
55cecbc9ba | ||
|
|
524d9a1960 | ||
|
|
db9185f7e0 | ||
|
|
5718db1399 | ||
|
|
74ef122ee9 | ||
|
|
a72840d4a3 | ||
|
|
8368099b93 | ||
|
|
21ce9c76e8 | ||
|
|
e198b6e613 | ||
|
|
fe55962670 | ||
|
|
79be8aec91 | ||
|
|
25f13a6d49 | ||
|
|
1842b525a6 | ||
|
|
efde2c357a | ||
|
|
3f7d1b28f0 | ||
|
|
b81d0a0de0 | ||
|
|
fb3ce483c7 | ||
|
|
7d5371cac4 | ||
|
|
db08e07e48 | ||
|
|
6f22d0baf0 | ||
|
|
401edadee7 | ||
|
|
fe94bfa109 | ||
|
|
a57c53ae9f | ||
|
|
877a4a4696 | ||
|
|
76b17d4abc | ||
|
|
2855622746 | ||
|
|
956c3466f9 | ||
|
|
8d872498f4 | ||
|
|
96d6398f59 | ||
|
|
fce8620087 | ||
|
|
80c65e6a32 | ||
|
|
e6563c9e31 | ||
|
|
e86abbc88e | ||
|
|
bf4304cacf | ||
|
|
b062239007 | ||
|
|
6f5e1f708c | ||
|
|
ae902267ef | ||
|
|
0334adb52c | ||
|
|
0b82f33837 | ||
|
|
0ea9d49ead | ||
|
|
7c9c2672a2 | ||
|
|
6b057ed2c4 | ||
|
|
2dcb2ac227 | ||
|
|
64e74b8d67 | ||
|
|
e6438cf46d | ||
|
|
e6cc03aeef | ||
|
|
5609d6e381 | ||
|
|
73df86f269 | ||
|
|
b0149f6d61 | ||
|
|
eb81eed835 | ||
|
|
daf81cd0c0 | ||
|
|
4108a438c7 | ||
|
|
f698909cd2 | ||
|
|
75f97e7a2b | ||
|
|
a189c58352 | ||
|
|
43180d77b2 | ||
|
|
f08714e2a3 | ||
|
|
af5a107295 | ||
|
|
21b0276cfd | ||
|
|
504b110ff3 | ||
|
|
2477b88ea5 | ||
|
|
0a1c222372 | ||
|
|
ed97baae03 | ||
|
|
91580cacf1 | ||
|
|
fe53cb1bcd | ||
|
|
e5df28c85d | ||
|
|
cbbf35eec9 | ||
|
|
550792372a | ||
|
|
be9457c4e2 | ||
|
|
09acb4453c | ||
|
|
0971c25a5c | ||
|
|
04c44ae416 | ||
|
|
85329ff557 | ||
|
|
f014d9fd42 | ||
|
|
4633066b13 | ||
|
|
79b889ec39 | ||
|
|
a6b9f88101 | ||
|
|
a275e18d0b | ||
|
|
9aacf25eb5 | ||
|
|
2c1efb1bf0 | ||
|
|
c8e2a9c7b9 | ||
|
|
38c37c74ed | ||
|
|
e328569cc1 | ||
|
|
a8f717d99a | ||
|
|
480b1cc482 | ||
|
|
f6c3b230fb | ||
|
|
bc30503731 | ||
|
|
b5a5a68620 | ||
|
|
50e0e72c2b | ||
|
|
94653f738b | ||
|
|
9da458e3b6 | ||
|
|
79db0f03e5 | ||
|
|
b5ede7af73 | ||
|
|
c716a1fba9 | ||
|
|
2a17b020b4 | ||
|
|
e67e3710c5 | ||
|
|
64705ba2f0 | ||
|
|
716d2e48d7 | ||
|
|
b3c034a602 | ||
|
|
81640fda90 | ||
|
|
58a58f3d9b | ||
|
|
999228e272 | ||
|
|
0a1c5f6e4a | ||
|
|
411438d99d | ||
|
|
b2dc356aed | ||
|
|
617853cdf0 | ||
|
|
9c01a332a1 | ||
|
|
7078a99347 | ||
|
|
757d9db536 | ||
|
|
72d56af9eb | ||
|
|
3ca93bff1a | ||
|
|
5c3c374f80 | ||
|
|
b4ac08292f | ||
|
|
a4471c3c3b | ||
|
|
3d744e8183 | ||
|
|
6c119778c6 | ||
|
|
5425970fc2 | ||
|
|
2fa637bfab | ||
|
|
4b1a25ccbd | ||
|
|
88349309cd | ||
|
|
80d09b1780 | ||
|
|
d210bfebf9 | ||
|
|
3ac8c3c613 | ||
|
|
4cc0366fba | ||
|
|
71ac7b1611 | ||
|
|
12f2b25bcb | ||
|
|
e4ffddbbe3 | ||
|
|
34972c1422 | ||
|
|
701cc43283 | ||
|
|
488cfa3b61 | ||
|
|
26c3fee797 | ||
|
|
7fd2810278 | ||
|
|
01f8eae2f7 | ||
|
|
1872b037da | ||
|
|
99d4a816dd | ||
|
|
9102c7f219 | ||
|
|
b3d12b0a29 | ||
|
|
3878359f81 | ||
|
|
d2be234d44 | ||
|
|
f060341fae | ||
|
|
d9727cfb96 | ||
|
|
2711758e2e | ||
|
|
f303d7b31b | ||
|
|
282635dcd8 | ||
|
|
118339128a | ||
|
|
1db54593c8 | ||
|
|
43d38d7b88 | ||
|
|
89ffd958d9 | ||
|
|
257ea97e75 | ||
|
|
c8487a91ea | ||
|
|
5533a441c0 | ||
|
|
12d3ef3d20 | ||
|
|
7d3ae71b20 | ||
|
|
8d99ebc9d7 | ||
|
|
72060276c5 | ||
|
|
79b8ef3318 | ||
|
|
5da1683201 | ||
|
|
e7cecdf049 | ||
|
|
62397a1c5d | ||
|
|
eb72a0f564 | ||
|
|
0e2a6cfb2d | ||
|
|
3d50c67c6d | ||
|
|
283761003b | ||
|
|
1073a7cb0b | ||
|
|
700f4715f7 | ||
|
|
2cec2cb822 | ||
|
|
8980429b52 | ||
|
|
f1f9a2c5da | ||
|
|
978bff037d | ||
|
|
56a74e5f11 | ||
|
|
1232c7a549 | ||
|
|
6813c53d9f | ||
|
|
1dd5f3e103 | ||
|
|
af506b19fc | ||
|
|
f4fcc20a4f | ||
|
|
6dcb4f7460 | ||
|
|
5ccab502a4 | ||
|
|
0f5ab9e5ea | ||
|
|
d1cffac58b | ||
|
|
d9ba1d4330 |
30
.github/workflows/pint.yaml
vendored
Normal file
30
.github/workflows/pint.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Laravel Pint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
pint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Reinstall system libraries to ensure compatibility
|
||||
- name: Ensure system libraries are up-to-date
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --reinstall --yes git libc6
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "8.3"
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-interaction --prefer-dist --no-progress
|
||||
|
||||
# Run pint in test mode, check only files different from master branch
|
||||
- name: Run Laravel Pint in test mode
|
||||
run: vendor/bin/pint --test --diff=master
|
||||
164
app/Console/Commands/ScheduleList.php
Normal file
164
app/Console/Commands/ScheduleList.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\AlertMailRule;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
|
||||
class ScheduleList
|
||||
{
|
||||
// public function schedule(Schedule $schedule): void
|
||||
// {
|
||||
// // Invoice Report Scheduling
|
||||
// $scheduleType = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->where('rule_name', 'InvoiceMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($scheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// // case 'Daily':
|
||||
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
|
||||
// // break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
|
||||
// $SerialscheduleType = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->where('rule_name', 'SerialInvoiceMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($SerialscheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// // case 'Daily':
|
||||
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
|
||||
// // break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
// $materialscheduleType = AlertMailRule::where('module', 'InvoiceValidation')
|
||||
// ->where('rule_name', 'MaterialInvoiceMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($materialscheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// // case 'Daily':
|
||||
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
|
||||
// // break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
|
||||
// // Production Report Scheduling
|
||||
// $productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
// ->where('rule_name', 'ProductionMail')
|
||||
// ->value('schedule_type');
|
||||
|
||||
// switch ($productionScheduleType) {
|
||||
// case 'Live':
|
||||
// $schedule->command('send:production-report')->everyMinute()->runInBackground();
|
||||
// break;
|
||||
// case 'Hourly':
|
||||
// $schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// case 'Daily':
|
||||
// $schedule->command('send:production-report')->dailyAt('07:59')->runInBackground();
|
||||
// break;
|
||||
// default:
|
||||
// $schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function schedule(Schedule $schedule): void
|
||||
{
|
||||
// Define the rules you want to schedule
|
||||
$rules = [
|
||||
[
|
||||
'module' => 'InvoiceValidation',
|
||||
'rule_name' => 'InvoiceMail',
|
||||
'argument' => 'InvoiceMail',
|
||||
],
|
||||
[
|
||||
'module' => 'InvoiceValidation',
|
||||
'rule_name' => 'SerialInvoiceMail',
|
||||
'argument' => 'SerialInvoiceMail',
|
||||
],
|
||||
[
|
||||
'module' => 'InvoiceValidation',
|
||||
'rule_name' => 'MaterialInvoiceMail',
|
||||
'argument' => 'MaterialInvoiceMail',
|
||||
],
|
||||
];
|
||||
|
||||
// Loop through each rule and schedule accordingly
|
||||
foreach ($rules as $rule) {
|
||||
$scheduleType = AlertMailRule::where('module', $rule['module'])
|
||||
->where('rule_name', $rule['rule_name'])
|
||||
->value('schedule_type');
|
||||
|
||||
switch ($scheduleType) {
|
||||
case 'Live':
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->everyMinute()->runInBackground();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground();
|
||||
break;
|
||||
case 'Daily':
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->dailyAt('07:59')->runInBackground();
|
||||
break;
|
||||
default:
|
||||
$schedule->command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Production Report Scheduling
|
||||
$productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->value('schedule_type');
|
||||
|
||||
switch ($productionScheduleType) {
|
||||
case 'Live':
|
||||
$schedule->command('send:production-report')->everyMinute()->runInBackground();
|
||||
break;
|
||||
case 'Hourly':
|
||||
$schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
break;
|
||||
case 'Daily':
|
||||
$schedule->command('send:production-report')->dailyAt('07:59')->runInBackground();
|
||||
break;
|
||||
default:
|
||||
$schedule->command('send:production-report')->hourly()->runInBackground();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
405
app/Console/Commands/SendInvoiceReport.php
Normal file
405
app/Console/Commands/SendInvoiceReport.php
Normal file
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\test;
|
||||
|
||||
class SendInvoiceReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report{schedule_type} {plant}';
|
||||
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
// public function handle()
|
||||
// {
|
||||
|
||||
// $schedule = $this->argument('schedule_type');
|
||||
// $plantid = $this->argument('plant');
|
||||
|
||||
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
// $plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
|
||||
|
||||
// $serialTableData = [];
|
||||
// $materialTableData = [];
|
||||
// $bundleTableData = [];
|
||||
// $noSerial = 1;
|
||||
// $noMaterial = 1;
|
||||
// $noBundle = 1;
|
||||
|
||||
// foreach ($plants as $plantId) {
|
||||
// $plant = Plant::find($plantId);
|
||||
// $plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
// //..Serial Invoice
|
||||
|
||||
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $serialTableData[] = [
|
||||
// 'no' => $noSerial++,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalSerialCount,
|
||||
// 'scannedInvoice' => $scannedSerialCount,
|
||||
// ];
|
||||
|
||||
// //..Individual Invoice
|
||||
|
||||
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $materialTableData[] = [
|
||||
// 'no' => $noMaterial++,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $TotalMatCount,
|
||||
// 'scannedInvoice' => $scannedMatCount,
|
||||
// ];
|
||||
|
||||
// //..BUndle Invoice
|
||||
|
||||
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $bundleTableData[] = [
|
||||
// 'no' => $noBundle++,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalBundleCount,
|
||||
// 'scannedInvoice' => $scannedBundleCount,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// // Send to SerialInvoiceMail recipients
|
||||
// if ($mailRules->has('SerialInvoiceMail')) {
|
||||
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, [], []));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
// if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Send to InvoiceMail recipients (all three tables)
|
||||
// if ($mailRules->has('InvoiceMail')) {
|
||||
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
|
||||
// }
|
||||
// }
|
||||
// //$this->info(json_encode($materialTableData));
|
||||
// }
|
||||
|
||||
// public function handle()
|
||||
// {
|
||||
// $schedule = $this->argument('schedule_type');
|
||||
// $plantId = $this->argument('plant');
|
||||
|
||||
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
// $serialTableData = [];
|
||||
// $materialTableData = [];
|
||||
// $bundleTableData = [];
|
||||
|
||||
// $plant = Plant::find($plantId);
|
||||
// $plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
// // Serial Invoice
|
||||
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->whereNull('quantity')
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $serialTableData[] = [
|
||||
// 'no' => 1,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalSerialCount,
|
||||
// 'scannedInvoice' => $scannedSerialCount,
|
||||
// ];
|
||||
|
||||
// // Individual Material Invoice
|
||||
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $materialTableData[] = [
|
||||
// 'no' => 1,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $TotalMatCount,
|
||||
// 'scannedInvoice' => $scannedMatCount,
|
||||
// ];
|
||||
|
||||
// // Bundle Invoice
|
||||
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->distinct('invoice_number')
|
||||
// ->count('invoice_number');
|
||||
|
||||
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->where('quantity', '>', 1)
|
||||
// ->whereBetween('updated_at', [$startDate, $endDate])
|
||||
// ->groupBy('invoice_number')
|
||||
// ->havingRaw(
|
||||
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
|
||||
// )
|
||||
// ->count();
|
||||
|
||||
// $bundleTableData[] = [
|
||||
// 'no' => 1,
|
||||
// 'plant' => $plantName,
|
||||
// 'totalInvoice' => $totalBundleCount,
|
||||
// 'scannedInvoice' => $scannedBundleCount,
|
||||
// ];
|
||||
|
||||
// // Send to SerialInvoiceMail recipients
|
||||
// if ($mailRules->has('SerialInvoiceMail')) {
|
||||
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, [], []));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
// if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Send to InvoiceMail recipients (all three tables)
|
||||
// if ($mailRules->has('InvoiceMail')) {
|
||||
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
|
||||
// }
|
||||
// }
|
||||
|
||||
// // $this->table(
|
||||
// // ['No', 'Plant', 'Total Invoice', 'Scanned Invoice'],
|
||||
// // $serialTableData
|
||||
// // );
|
||||
// }
|
||||
public function handle()
|
||||
{
|
||||
$schedule = $this->argument('schedule_type');
|
||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
$serialTableData = [];
|
||||
$materialTableData = [];
|
||||
$bundleTableData = [];
|
||||
|
||||
// Get plant IDs: either one plant or all
|
||||
$plantIds = $plantIdArg == 0
|
||||
? InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id')->toArray()
|
||||
: [$plantIdArg];
|
||||
|
||||
$no = 1;
|
||||
foreach ($plantIds as $plantId) {
|
||||
$plant = Plant::find($plantId);
|
||||
$plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
// Serial Invoice
|
||||
$totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->distinct('invoice_number')
|
||||
->count('invoice_number');
|
||||
|
||||
$scannedSerialCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('quantity')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$serialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalSerialCount,
|
||||
'scannedInvoice' => $scannedSerialCount,
|
||||
];
|
||||
|
||||
// Material Invoice
|
||||
$totalMatCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->distinct('invoice_number')
|
||||
->count('invoice_number');
|
||||
|
||||
$scannedMatCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$materialTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalMatCount,
|
||||
'scannedInvoice' => $scannedMatCount,
|
||||
];
|
||||
|
||||
// Bundle Invoice
|
||||
$totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->distinct('invoice_number')
|
||||
->count('invoice_number');
|
||||
|
||||
$scannedBundleCount = InvoiceValidation::select('invoice_number')
|
||||
->where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->groupBy('invoice_number')
|
||||
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
|
||||
->count();
|
||||
|
||||
$bundleTableData[] = [
|
||||
'no' => $no,
|
||||
'plant' => $plantName,
|
||||
'totalInvoice' => $totalBundleCount,
|
||||
'scannedInvoice' => $scannedBundleCount,
|
||||
];
|
||||
|
||||
$no++;
|
||||
}
|
||||
|
||||
// Send to SerialInvoiceMail recipients
|
||||
if ($mailRules->has('SerialInvoiceMail')) {
|
||||
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, [], []));
|
||||
}
|
||||
}
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
|
||||
}
|
||||
}
|
||||
|
||||
// Send to InvoiceMail recipients (all three tables)
|
||||
if ($mailRules->has('InvoiceMail')) {
|
||||
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
|
||||
}
|
||||
}
|
||||
|
||||
// Show preview in console
|
||||
$this->info('--- Serial Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
|
||||
|
||||
$this->info('--- Material Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
|
||||
|
||||
$this->info('--- Bundle Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
247
app/Console/Commands/SendProductionReport.php
Normal file
247
app/Console/Commands/SendProductionReport.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ProductionMail;
|
||||
use App\Models\Line;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\ProductionQuantity;
|
||||
use DB;
|
||||
|
||||
class SendProductionReport extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
//protected $signature = 'send:production-report';
|
||||
protected $signature = 'send:production-report {schedule_type} {plant}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
// public function handle()
|
||||
// {
|
||||
// $scheduleType = $this->argument('schedule_type');
|
||||
// $plantId = $this->argument('plant');
|
||||
|
||||
// $mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
||||
// ->where('rule_name', 'ProductionMail')
|
||||
// ->where('plant', $plantId)
|
||||
// ->where('schedule_type', $scheduleType)
|
||||
// ->get();
|
||||
|
||||
// $emails = $mailRules->pluck('email')->unique()->toArray();
|
||||
|
||||
// $plant = Plant::find($plantId);
|
||||
|
||||
// if (!$plant) {
|
||||
// $this->error("Invalid plant ID: $plantId");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// $lines = Line::where('plant_id', $plantId)->get();
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
|
||||
// $PlanstartDate = now()->setTime(8, 0, 0);
|
||||
// $planendDate = now()->copy()->addDay()->setTime(7, 59, 00);
|
||||
|
||||
// $tableData = [];
|
||||
// $no = 1;
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
// $lineId = $line->id;
|
||||
// $lineName = $line->name;
|
||||
|
||||
// $targetQuantity = ProductionPlan::where('plant_id', $plantId)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
// ->sum('plan_quantity');
|
||||
|
||||
// $productionQuantity = ProductionQuantity::where('plant_id', $plantId)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $tableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $lineName,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $productionQuantity,
|
||||
// ];
|
||||
// }
|
||||
|
||||
// // $this->table(
|
||||
// // ['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'],
|
||||
// // $tableData
|
||||
// // );
|
||||
|
||||
// if (!empty($emails)) {
|
||||
// foreach ($emails as $email) {
|
||||
// Mail::to($email)->send(new ProductionMail($tableData));
|
||||
// }
|
||||
// } else {
|
||||
// $this->info('No recipients found for ProductionMailAlert.');
|
||||
// }
|
||||
|
||||
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
|
||||
// }
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$scheduleType = $this->argument('schedule_type');
|
||||
$plantId = (int) $this->argument('plant'); // cast to int for safety
|
||||
|
||||
// Fetch mail rules based on schedule type
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
|
||||
->where('rule_name', 'ProductionMail')
|
||||
->where('schedule_type', $scheduleType)
|
||||
->where('plant', $plantId)
|
||||
->get();
|
||||
|
||||
$emails = $mailRules->pluck('email')->unique()->toArray();
|
||||
|
||||
$plants = $plantId == 0
|
||||
? Plant::all()
|
||||
: Plant::where('id', $plantId)->get();
|
||||
|
||||
if ($plants->isEmpty()) {
|
||||
$this->error("No valid plant(s) found.");
|
||||
return;
|
||||
}
|
||||
|
||||
// $startDate = now()->setTime(8, 0, 0);
|
||||
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
if (strtolower($scheduleType) == 'daily')
|
||||
{
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
|
||||
$PlanstartDate = now()->setTime(8, 0, 0);
|
||||
$planendDate = now()->copy()->addDay()->setTime(7, 59, 0);
|
||||
|
||||
$tableData = [];
|
||||
$no = 1;
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// $lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
// foreach ($lines as $line) {
|
||||
// $targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
// ->sum('plan_quantity');
|
||||
|
||||
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $tableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $productionQuantity,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
// $fgTableData = []; // store FG Line related data
|
||||
|
||||
// foreach ($plants as $plant) {
|
||||
// // ✅ Only get FG Lines
|
||||
// $fgLines = Line::where('plant_id', $plant->id)
|
||||
// ->where('type', 'FG Line')
|
||||
// ->get();
|
||||
|
||||
// foreach ($fgLines as $line) {
|
||||
// $validationCount = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
// ->where('line_id', $line->id)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->count();
|
||||
|
||||
// $fgTableData[] = [
|
||||
// 'no' => $no++,
|
||||
// 'plant' => $plant->name,
|
||||
// 'line' => $line->name,
|
||||
// 'targetQuantity' => $targetQuantity,
|
||||
// 'productionQuantity' => $validationCount,
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
foreach ($plants as $plant)
|
||||
{
|
||||
$lines = Line::where('plant_id', $plant->id)->get();
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$targetQuantity = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$PlanstartDate, $planendDate])
|
||||
->sum('plan_quantity');
|
||||
|
||||
if (strtolower($line->type) === 'fg line') {
|
||||
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
} else {
|
||||
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->count();
|
||||
}
|
||||
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
'plant' => $plant->name,
|
||||
'line' => $line->name,
|
||||
'targetQuantity' => $targetQuantity,
|
||||
'productionQuantity' => $productionQuantity,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
|
||||
|
||||
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
|
||||
|
||||
if (!empty($emails)) {
|
||||
foreach ($emails as $email) {
|
||||
Mail::to($email)->send(new ProductionMail($tableData));
|
||||
}
|
||||
} else {
|
||||
$this->info('No recipients found for ProductionMailAlert.');
|
||||
}
|
||||
|
||||
$this->info("Production report sent to " . count($emails) . " recipient(s).");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
51
app/Filament/Exports/BlockExporter.php
Normal file
51
app/Filament/Exports/BlockExporter.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Block;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class BlockExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Block::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your block 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;
|
||||
}
|
||||
}
|
||||
53
app/Filament/Exports/CheckPointNameExporter.php
Normal file
53
app/Filament/Exports/CheckPointNameExporter.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CheckPointName;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CheckPointNameExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = CheckPointName::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('CHECK POINT NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your check point name 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;
|
||||
}
|
||||
}
|
||||
61
app/Filament/Exports/CheckPointTimeExporter.php
Normal file
61
app/Filament/Exports/CheckPointTimeExporter.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\CheckPointTime;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CheckPointTimeExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = CheckPointTime::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('checkPointNames1.name')
|
||||
->label('CHECK POINT 1'),
|
||||
ExportColumn::make('checkPointNames2.name')
|
||||
->label('CHECK POINT 2'),
|
||||
ExportColumn::make('sequence_number')
|
||||
->label('SEQUENCE NUMBER'),
|
||||
ExportColumn::make('time_lapse')
|
||||
->label('TIME LAPSE'),
|
||||
ExportColumn::make('time_lapse_cushioning')
|
||||
->label('TIME LAPSE CUSHIONING'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your check point time 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;
|
||||
}
|
||||
}
|
||||
49
app/Filament/Exports/CompanyExporter.php
Normal file
49
app/Filament/Exports/CompanyExporter.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Company;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class CompanyExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Company::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your company 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;
|
||||
}
|
||||
}
|
||||
57
app/Filament/Exports/ConfigurationExporter.php
Normal file
57
app/Filament/Exports/ConfigurationExporter.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Configuration;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ConfigurationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Configuration::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
ExportColumn::make('c_type')
|
||||
->label('TYPE'),
|
||||
ExportColumn::make('c_group')
|
||||
->label('GROUP'),
|
||||
ExportColumn::make('c_name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('c_value')
|
||||
->label('VALUE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your configuration 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;
|
||||
}
|
||||
}
|
||||
57
app/Filament/Exports/GuardNameExporter.php
Normal file
57
app/Filament/Exports/GuardNameExporter.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\GuardName;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class GuardNameExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = GuardName::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('GUARD NAME'),
|
||||
ExportColumn::make('identification1')
|
||||
->label('IDENTIFICATION 1'),
|
||||
ExportColumn::make('identification2')
|
||||
->label('IDENTIFICATION 2'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your guard name 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;
|
||||
}
|
||||
}
|
||||
65
app/Filament/Exports/GuardPatrolEntryExporter.php
Normal file
65
app/Filament/Exports/GuardPatrolEntryExporter.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class GuardPatrolEntryExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = GuardPatrolEntry::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('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('guardNames.name')
|
||||
->label('GUARD NAME'),
|
||||
ExportColumn::make('checkPointNames.name')
|
||||
->label('CHECK POINT NAME'),
|
||||
// ExportColumn::make('reader_code')
|
||||
// ->label('READER CODE'),
|
||||
ExportColumn::make('patrol_time')
|
||||
->label('PATROL TIME'),
|
||||
ExportColumn::make('created_at')
|
||||
->enabledByDefault(false)
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->enabledByDefault(false)
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->enabledByDefault(false)
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('Updated_by')
|
||||
->enabledByDefault(false)
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your guard patrol entry export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
82
app/Filament/Exports/InvoiceValidationExporter.php
Normal file
82
app/Filament/Exports/InvoiceValidationExporter.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\InvoiceValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class InvoiceValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = InvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('motor_scanned_status')
|
||||
->label('MOTOR SCANNED STATUS'),
|
||||
ExportColumn::make('pump_scanned_status')
|
||||
->label('PUMP SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_status_set')
|
||||
->label('PUMPSET SCANNED STATUS'),
|
||||
ExportColumn::make('capacitor_scanned_status')
|
||||
->label('CAPACITOR SCANNED STATUS'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('panel_box_supplier')
|
||||
->label('PANEL BOX SUPPLIER'),
|
||||
ExportColumn::make('panel_box_serial_number')
|
||||
->label('PANEL BOX SERIAL NUMBER'),
|
||||
ExportColumn::make('load_rate')
|
||||
->label('LOAD RATE'),
|
||||
ExportColumn::make('upload_status')
|
||||
->label('UPLOAD STATUS'),
|
||||
ExportColumn::make('batch_number')
|
||||
->label('BATCH NUMBER'),
|
||||
ExportColumn::make('quantity')
|
||||
->label('QUANTITY'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
//->dateTimeFormat('d-m-Y H:i:s'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your invoice validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -13,23 +13,35 @@ class ItemExporter extends Exporter
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('code')
|
||||
->label('CODE'),
|
||||
ExportColumn::make('description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('hourly_quantity')
|
||||
->label('HOURLY QUANTITY'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
// ->enabledByDefault(false)
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
55
app/Filament/Exports/LineExporter.php
Normal file
55
app/Filament/Exports/LineExporter.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Line;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class LineExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Line::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('type')
|
||||
->label('TYPE'),
|
||||
ExportColumn::make('group_work_center')
|
||||
->label('GROUP WORK CENTER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your line 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;
|
||||
}
|
||||
}
|
||||
51
app/Filament/Exports/LineStopExporter.php
Normal file
51
app/Filament/Exports/LineStopExporter.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\LineStop;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class LineStopExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = LineStop::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('code')
|
||||
->label('LINE STOP CODE'),
|
||||
ExportColumn::make('reason')
|
||||
->label('LINE STOP REASON'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your line stop 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;
|
||||
}
|
||||
}
|
||||
55
app/Filament/Exports/LocatorExporter.php
Normal file
55
app/Filament/Exports/LocatorExporter.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Locator;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class LocatorExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Locator::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('locator_number')
|
||||
->label('LOCATOR NUMBER'),
|
||||
ExportColumn::make('locator_quantity')
|
||||
->label('LOCATOR QUANTITY'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your locator 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;
|
||||
}
|
||||
}
|
||||
68
app/Filament/Exports/LocatorInvoiceValidationExporter.php
Normal file
68
app/Filament/Exports/LocatorInvoiceValidationExporter.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class LocatorInvoiceValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = LocatorInvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('pallet_number')
|
||||
->label('PALLET NUMBER'),
|
||||
ExportColumn::make('locator_number')
|
||||
->label('LOCATOR NUMBER'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('upload_status')
|
||||
->label('UPLOAD STATUS'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('scanned_by')
|
||||
->label('SCANNED BY'),
|
||||
ExportColumn::make('scanned_at')
|
||||
->label('SCANNED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your locator invoice validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
53
app/Filament/Exports/MachineExporter.php
Normal file
53
app/Filament/Exports/MachineExporter.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Machine;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MachineExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Machine::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
ExportColumn::make('name')
|
||||
->label('MACHINE'),
|
||||
ExportColumn::make('work_center')
|
||||
->label('WORK CENTER'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your machine 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;
|
||||
}
|
||||
}
|
||||
43
app/Filament/Exports/MfmParameterExporter.php
Normal file
43
app/Filament/Exports/MfmParameterExporter.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\MfmParameter;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MfmParameterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = MfmParameter::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
ExportColumn::make('plant.name'),
|
||||
ExportColumn::make('name'),
|
||||
ExportColumn::make('register_id'),
|
||||
ExportColumn::make('identifier'),
|
||||
ExportColumn::make('byte_to_convert'),
|
||||
ExportColumn::make('type_to_convert'),
|
||||
ExportColumn::make('decimal_to_display'),
|
||||
ExportColumn::make('created_at'),
|
||||
ExportColumn::make('updated_at'),
|
||||
ExportColumn::make('deleted_at'),
|
||||
ExportColumn::make('mfmMeter.name'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your mfm parameter export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
115
app/Filament/Exports/MotorTestingMasterExporter.php
Normal file
115
app/Filament/Exports/MotorTestingMasterExporter.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\MotorTestingMaster;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class MotorTestingMasterExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = MotorTestingMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.category')
|
||||
->label('CATEGORY'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('DESCRIPTION'),
|
||||
ExportColumn::make('isi_model')
|
||||
->label('ISI MODEL'),
|
||||
ExportColumn::make('phase')
|
||||
->label('PHASE'),
|
||||
ExportColumn::make('hp')
|
||||
->label('HP'),
|
||||
ExportColumn::make('kw')
|
||||
->label('KW'),
|
||||
ExportColumn::make('volt')
|
||||
->label('VOLT'),
|
||||
ExportColumn::make('current')
|
||||
->label('CURRENT'),
|
||||
ExportColumn::make('rpm')
|
||||
->label('RPM'),
|
||||
ExportColumn::make('torque')
|
||||
->label('TORQUE'),
|
||||
ExportColumn::make('frequency')
|
||||
->label('FREQUENCY'),
|
||||
ExportColumn::make('connection')
|
||||
->label('CONNECTION'),
|
||||
ExportColumn::make('ins_res_limit')
|
||||
->label('INSULATION RESISTANCE LIMIT'),
|
||||
ExportColumn::make('ins_res_type')
|
||||
->label('INSULATION RESISTANCE TYPE'),
|
||||
ExportColumn::make('routine_test_time')
|
||||
->label('ROUTINE TEST TIME'),
|
||||
ExportColumn::make('res_ry_ll')
|
||||
->label('RESISTANCE RY LL'),
|
||||
ExportColumn::make('res_ry_ul')
|
||||
->label('RESISTANCE RY UL'),
|
||||
ExportColumn::make('res_yb_ll')
|
||||
->label('RESISTANCE YB LL'),
|
||||
ExportColumn::make('res_yb_ul')
|
||||
->label('RESISTANCE YB UL'),
|
||||
ExportColumn::make('res_br_ll')
|
||||
->label('RESISTANCE BR LL'),
|
||||
ExportColumn::make('res_br_ul')
|
||||
->label('RESISTANCE BR UL'),
|
||||
ExportColumn::make('lock_volt_limit')
|
||||
->label('LOCK VOLT Limit'),
|
||||
ExportColumn::make('leak_cur_limit')
|
||||
->label('Leak CURRENT Limit'),
|
||||
ExportColumn::make('lock_cur_ll')
|
||||
->label('LOCK CURRENT LL'),
|
||||
ExportColumn::make('lock_cur_ul')
|
||||
->label('LOCK CURRENT UL'),
|
||||
ExportColumn::make('noload_cur_ll')
|
||||
->label('NO LOAD CURRENT LL'),
|
||||
ExportColumn::make('noload_cur_ul')
|
||||
->label('NO LOAD CURRENT UL'),
|
||||
ExportColumn::make('noload_pow_ll')
|
||||
->label('NO LOAD POWER LL'),
|
||||
ExportColumn::make('noload_pow_ul')
|
||||
->label('NO LOAD POWER UL'),
|
||||
ExportColumn::make('noload_spd_ll')
|
||||
->label('NO LOAD SPEED LL'),
|
||||
ExportColumn::make('noload_spd_ul')
|
||||
->label('NO LOAD SPEED UL'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your motor testing master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
67
app/Filament/Exports/PalletValidationExporter.php
Normal file
67
app/Filament/Exports/PalletValidationExporter.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\PalletValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class PalletValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = PalletValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('pallet_number')
|
||||
->label('PALLET NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('pallet_status')
|
||||
->label('PALLET STATUS'),
|
||||
ExportColumn::make('locator_number')
|
||||
->label('LOCATOR NUMBER'),
|
||||
ExportColumn::make('locator_quantity')
|
||||
->label('LOCATOR QUANTITY'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('scanned_by')
|
||||
->label('SCANNED BY'),
|
||||
ExportColumn::make('scanned_at')
|
||||
->label('SCANNED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your pallet validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
55
app/Filament/Exports/PlantExporter.php
Normal file
55
app/Filament/Exports/PlantExporter.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class PlantExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Plant::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('company.name')
|
||||
->label('COMPANY'),
|
||||
ExportColumn::make('code')
|
||||
->label('CODE'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('address')
|
||||
->label('ADDRESS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your plant export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,17 @@ class ProductionLineStopExporter extends Exporter
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('linestop.code')
|
||||
->label('CODE'),
|
||||
ExportColumn::make('linestop.reason')
|
||||
@@ -30,15 +38,20 @@ class ProductionLineStopExporter extends Exporter
|
||||
->label('STOP MINUTE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
ExportColumn::make('shift.block.name')
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('shift.name')
|
||||
->label('SHIFT'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -13,24 +13,37 @@ class ProductionPlanExporter extends Exporter
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plan_quantity')
|
||||
->label('PLAN QUANTITY'),
|
||||
ExportColumn::make('production_quantity')
|
||||
->label('PRODUCTION QUANTITY'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
ExportColumn::make('shift.block.name')
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('shift.name')
|
||||
->label('SHIFT'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -13,24 +13,45 @@ class ProductionQuantityExporter extends Exporter
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('id')
|
||||
->label('ID'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('CODE'),
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
ExportColumn::make('shift.block.name')
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('shift.name')
|
||||
->label('SHIFT'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('sap_msg_status')
|
||||
->label('SAP MESSAGE STATUS'),
|
||||
ExportColumn::make('sap_msg_description')
|
||||
->label('SAP MESSAGE DESCRIPTION'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
101
app/Filament/Exports/QualityValidationExporter.php
Normal file
101
app/Filament/Exports/QualityValidationExporter.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\QualityValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class QualityValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = QualityValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
ExportColumn::make('production_order')
|
||||
->label('PRODUCTION ORDER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('stickerMaster.item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('uom')
|
||||
->label('UNIT OF MEASURE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
->label('SERIAL NUMBER MOTOR'),
|
||||
ExportColumn::make('serial_number_pump')
|
||||
->label('SERIAL NUMBER PUMP'),
|
||||
ExportColumn::make('serial_number_pumpset')
|
||||
->label('SERIAL NUMBER PUMPSET'),
|
||||
ExportColumn::make('pack_slip_motor')
|
||||
->label('PACK SLIP MOTOR'),
|
||||
ExportColumn::make('pack_slip_pump')
|
||||
->label('PACK SLIP PUMP'),
|
||||
ExportColumn::make('pack_slip_pumpset')
|
||||
->label('PACK SLIP PUMPSET'),
|
||||
ExportColumn::make('name_plate_motor')
|
||||
->label('NAME PLATE MOTOR'),
|
||||
ExportColumn::make('name_plate_pump')
|
||||
->label('NAME PLATE PUMP'),
|
||||
ExportColumn::make('name_plate_pumpset')
|
||||
->label('NAME PLATE PUMPSET'),
|
||||
ExportColumn::make('tube_sticker_motor')
|
||||
->label('TUBE STICKER MOTOR'),
|
||||
ExportColumn::make('tube_sticker_pump')
|
||||
->label('TUBE STICKER PUMP'),
|
||||
ExportColumn::make('tube_sticker_pumpset')
|
||||
->label('TUBE STICKER PUMPSET'),
|
||||
ExportColumn::make('warranty_card')
|
||||
->label('WARRANTY CARD'),
|
||||
ExportColumn::make('part_validation1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation2')
|
||||
->label('PART VALIDATION 2'),
|
||||
ExportColumn::make('part_validation3')
|
||||
->label('PART VALIDATION 3'),
|
||||
ExportColumn::make('part_validation4')
|
||||
->label('PART VALIDATION 4'),
|
||||
ExportColumn::make('part_validation5')
|
||||
->label('PART VALIDATION 5'),
|
||||
ExportColumn::make('sap_msg_status')
|
||||
->label('SAP MESSAGE STATUS'),
|
||||
ExportColumn::make('sap_msg_description')
|
||||
->label('SAP MESSAGE DESCRIPTION'),
|
||||
ExportColumn::make('operator_id')
|
||||
->label('OPERATOR ID'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your quality validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\ReworkLocatorInvoiceValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ReworkLocatorInvoiceValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = ReworkLocatorInvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.code')
|
||||
->label('PLANT CODE'),
|
||||
ExportColumn::make('invoice_number')
|
||||
->label('INVOICE NUMBER'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('pallet_number')
|
||||
->label('PALLET NUMBER'),
|
||||
ExportColumn::make('locator_number')
|
||||
->label('LOCATOR NUMBER'),
|
||||
ExportColumn::make('scanned_status')
|
||||
->label('SCANNED STATUS'),
|
||||
ExportColumn::make('upload_status')
|
||||
->label('UPLOAD STATUS'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('scanned_by')
|
||||
->label('SCANNED BY'),
|
||||
ExportColumn::make('scanned_at')
|
||||
->label('SCANNED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('reworked_by')
|
||||
->label('REWORKED BY'),
|
||||
ExportColumn::make('reworked_at')
|
||||
->label('REWORKED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your rework locator invoice validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
61
app/Filament/Exports/ShiftExporter.php
Normal file
61
app/Filament/Exports/ShiftExporter.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\Shift;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class ShiftExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = Shift::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('block.name')
|
||||
->label('BLOCK'),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('name')
|
||||
->label('NAME'),
|
||||
ExportColumn::make('start_time')
|
||||
->label('START TIME'),
|
||||
ExportColumn::make('duration')
|
||||
->label('DURATION'),
|
||||
ExportColumn::make('end_time')
|
||||
->label('END TIME'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->label('DELETED AT')
|
||||
->enabledByDefault(false),
|
||||
ExportColumn::make('status')
|
||||
->label('STATUS'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your shift 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;
|
||||
}
|
||||
}
|
||||
@@ -13,36 +13,76 @@ class StickerMasterExporter extends Exporter
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('item.code'),
|
||||
ExportColumn::make('plant.name'),
|
||||
ExportColumn::make('serial_number_motor'),
|
||||
ExportColumn::make('serial_number_pump'),
|
||||
ExportColumn::make('serial_number_pumpset'),
|
||||
ExportColumn::make('pack_slip_motor'),
|
||||
ExportColumn::make('pack_slip_pump'),
|
||||
ExportColumn::make('pack_slip_pumpset'),
|
||||
ExportColumn::make('name_plate_motor'),
|
||||
ExportColumn::make('name_plate_pump'),
|
||||
ExportColumn::make('name_plate_pumpset'),
|
||||
ExportColumn::make('tube_sticker_motor'),
|
||||
ExportColumn::make('tube_sticker_pump'),
|
||||
ExportColumn::make('tube_sticker_pumpset'),
|
||||
ExportColumn::make('warranty_card'),
|
||||
ExportColumn::make('part_validation1'),
|
||||
ExportColumn::make('part_validation2'),
|
||||
ExportColumn::make('part_validation3'),
|
||||
ExportColumn::make('part_validation4'),
|
||||
ExportColumn::make('part_validation5'),
|
||||
ExportColumn::make('panel_box_code'),
|
||||
ExportColumn::make('load_rate'),
|
||||
ExportColumn::make('bundle_quantity'),
|
||||
ExportColumn::make('material_type'),
|
||||
ExportColumn::make('created_at'),
|
||||
ExportColumn::make('updated_at'),
|
||||
ExportColumn::make('deleted_at'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('serial_number_motor')
|
||||
->label('SERIAL NUMBER MOTOR'),
|
||||
ExportColumn::make('serial_number_pump')
|
||||
->label('SERIAL NUMBER PUMP'),
|
||||
ExportColumn::make('serial_number_pumpset')
|
||||
->label('SERIAL NUMBER PUMPSET'),
|
||||
ExportColumn::make('pack_slip_motor')
|
||||
->label('PACK SLIP MOTOR'),
|
||||
ExportColumn::make('pack_slip_pump')
|
||||
->label('PACK SLIP PUMP'),
|
||||
ExportColumn::make('pack_slip_pumpset')
|
||||
->label('PACK SLIP PUMPSET'),
|
||||
ExportColumn::make('name_plate_motor')
|
||||
->label('NAME PLATE MOTOR'),
|
||||
ExportColumn::make('name_plate_pump')
|
||||
->label('NAME PLATE PUMP'),
|
||||
ExportColumn::make('name_plate_pumpset')
|
||||
->label('NAME PLATE PUMPSET'),
|
||||
ExportColumn::make('tube_sticker_motor')
|
||||
->label('TUBE STICKER MOTOR'),
|
||||
ExportColumn::make('tube_sticker_pump')
|
||||
->label('TUBE STICKER PUMP'),
|
||||
ExportColumn::make('tube_sticker_pumpset')
|
||||
->label('TUBE STICKER PUMPSET'),
|
||||
ExportColumn::make('warranty_card')
|
||||
->label('WARRANTY CARD'),
|
||||
ExportColumn::make('part_validation1')
|
||||
->label('PART VALIDATION 1'),
|
||||
ExportColumn::make('part_validation2')
|
||||
->label('PART VALIDATION 2'),
|
||||
ExportColumn::make('part_validation3')
|
||||
->label('PART VALIDATION 3'),
|
||||
ExportColumn::make('part_validation4')
|
||||
->label('PART VALIDATION 4'),
|
||||
ExportColumn::make('part_validation5')
|
||||
->label('PART VALIDATION 5'),
|
||||
ExportColumn::make('laser_part_validation1')
|
||||
->label('LASER PART VALIDATION 1'),
|
||||
ExportColumn::make('laser_part_validation2')
|
||||
->label('LASER PART VALIDATION 2'),
|
||||
ExportColumn::make('panel_box_code')
|
||||
->label('PANEL BOX CODE'),
|
||||
ExportColumn::make('load_rate')
|
||||
->label('LOAD RATE'),
|
||||
ExportColumn::make('material_type')
|
||||
->label('MATERIAL TYPE'),
|
||||
ExportColumn::make('bundle_quantity')
|
||||
->label('BUNDLE QUANTITY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
155
app/Filament/Exports/TestingPanelReadingExporter.php
Normal file
155
app/Filament/Exports/TestingPanelReadingExporter.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\TestingPanelReading;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class TestingPanelReadingExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = TestingPanelReading::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('line.name')
|
||||
->label('LINE'),
|
||||
ExportColumn::make('machine.name')
|
||||
->label('MACHINE'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('item.description')
|
||||
->label('MODEL'),
|
||||
ExportColumn::make('output')
|
||||
->label('OUTPUT'),
|
||||
ExportColumn::make('serial_number')
|
||||
->label('SERIAL NUMBER'),
|
||||
ExportColumn::make('item.kw')
|
||||
->label('KW'),
|
||||
ExportColumn::make('item.hp')
|
||||
->label('HP'),
|
||||
ExportColumn::make('item.phase')
|
||||
->label('PHASE'),
|
||||
ExportColumn::make('item.connection')
|
||||
->label('CONNECTION'),
|
||||
ExportColumn::make('item.isi_model')
|
||||
->label('ISI MODEL'),
|
||||
ExportColumn::make('before_fr_volt')
|
||||
->label('BEFORE FR VOLT'),
|
||||
ExportColumn::make('before_fr_cur')
|
||||
->label('BEFORE FR CURRENT'),
|
||||
ExportColumn::make('before_fr_pow')
|
||||
->label('BEFORE FR POWER'),
|
||||
ExportColumn::make('before_fr_res_ry')
|
||||
->label('BEFORE FR RESISTANCE RY'),
|
||||
ExportColumn::make('before_fr_res_yb')
|
||||
->label('BEFORE FR RESISTANCE YB'),
|
||||
ExportColumn::make('before_fr_res_br')
|
||||
->label('BEFORE FR RESISTANCE BR'),
|
||||
ExportColumn::make('before_fr_ir')
|
||||
->label('BEFORE FR IR'),
|
||||
ExportColumn::make('before_fr_ir_r')
|
||||
->label('BEFORE FR IR R'),
|
||||
ExportColumn::make('before_fr_ir_y')
|
||||
->label('BEFORE FR IR Y'),
|
||||
ExportColumn::make('before_fr_ir_b')
|
||||
->label('BEFORE FR IR B'),
|
||||
ExportColumn::make('before_fr_freq')
|
||||
->label('BEFORE FR FREQUENCY'),
|
||||
ExportColumn::make('before_fr_speed')
|
||||
->label('BEFORE FR SPEED'),
|
||||
ExportColumn::make('after_fr_vol')
|
||||
->label('AFTER FR VOLT'),
|
||||
ExportColumn::make('after_fr_cur')
|
||||
->label('AFTER FR CURRENT'),
|
||||
ExportColumn::make('after_fr_pow')
|
||||
->label('AFTER FR POWER'),
|
||||
ExportColumn::make('after_fr_ir_hot')
|
||||
->label('AFTER FR IR HOT'),
|
||||
ExportColumn::make('after_fr_ir_hot_r')
|
||||
->label('AFTER FR IR HOT R'),
|
||||
ExportColumn::make('after_fr_ir_hot_y')
|
||||
->label('AFTER FR IR HOT Y'),
|
||||
ExportColumn::make('after_fr_ir_hot_b')
|
||||
->label('AFTER FR IR HOT B'),
|
||||
ExportColumn::make('after_fr_ir_cool')
|
||||
->label('AFTER FR IR COOL'),
|
||||
ExportColumn::make('after_fr_ir_cool_r')
|
||||
->label('AFTER FR IR COOL R'),
|
||||
ExportColumn::make('after_fr_ir_cool_y')
|
||||
->label('AFTER FR IR COOL Y'),
|
||||
ExportColumn::make('after_fr_ir_cool_b')
|
||||
->label('AFTER FR IR COOL B'),
|
||||
ExportColumn::make('after_fr_freq')
|
||||
->label('AFTER FR FREQUENCY'),
|
||||
ExportColumn::make('after_fr_speed')
|
||||
->label('AFTER FR SPEED'),
|
||||
ExportColumn::make('after_fr_leak_cur')
|
||||
->label('AFTER FR LEAK CURRENT'),
|
||||
ExportColumn::make('locked_rt_volt')
|
||||
->label('LOCKED RT VOLT'),
|
||||
ExportColumn::make('locked_rt_cur')
|
||||
->label('LOCKED RT CURRENT'),
|
||||
ExportColumn::make('locked_rt_pow')
|
||||
->label('LOCKED RT POWER'),
|
||||
ExportColumn::make('no_load_pickup_volt')
|
||||
->label('NO LOAD PICKUP VOLT'),
|
||||
ExportColumn::make('room_temperature')
|
||||
->label('ROOM TEMPERATURE'),
|
||||
ExportColumn::make('hv_test')
|
||||
->label('HIGH VOLTAGE TEST'),
|
||||
ExportColumn::make('batch_number')
|
||||
->label('BATCH NUMBER'),
|
||||
ExportColumn::make('batch_count')
|
||||
->label('BATCH COUNT'),
|
||||
ExportColumn::make('result')
|
||||
->label('RESULT'),
|
||||
ExportColumn::make('remark')
|
||||
->label('REMARK'),
|
||||
ExportColumn::make('rework_count')
|
||||
->label('REWORK COUNT'),
|
||||
ExportColumn::make('update_count')
|
||||
->label('UPDATE COUNT'),
|
||||
ExportColumn::make('output_flag')
|
||||
->label('OUTPUT FLAG'),
|
||||
ExportColumn::make('tested_by')
|
||||
->label('TESTED BY'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('scanned_at')
|
||||
->label('SCANNED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your testing panel reading export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
69
app/Filament/Exports/WeightValidationExporter.php
Normal file
69
app/Filament/Exports/WeightValidationExporter.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Exports;
|
||||
|
||||
use App\Models\WeightValidation;
|
||||
use Filament\Actions\Exports\ExportColumn;
|
||||
use Filament\Actions\Exports\Exporter;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
|
||||
class WeightValidationExporter extends Exporter
|
||||
{
|
||||
protected static ?string $model = WeightValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
// ExportColumn::make('id')
|
||||
// ->label('ID'),
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
->state(function ($record) use (&$rowNumber) {
|
||||
// Increment and return the row number
|
||||
return ++$rowNumber;
|
||||
}),
|
||||
ExportColumn::make('plant.name')
|
||||
->label('PLANT'),
|
||||
ExportColumn::make('item.code')
|
||||
->label('ITEM CODE'),
|
||||
ExportColumn::make('obd_number')
|
||||
->label('OBD NUMBER'),
|
||||
ExportColumn::make('line_number')
|
||||
->label('LINE NUMBER'),
|
||||
ExportColumn::make('batch_number')
|
||||
->label('BATCH NUMBER'),
|
||||
ExportColumn::make('heat_number')
|
||||
->label('HEAT NUMBER'),
|
||||
ExportColumn::make('obd_weight')
|
||||
->label('ACTUAL WEIGHT'),
|
||||
ExportColumn::make('vehicle_number')
|
||||
->label('VEHICLE NUMBER'),
|
||||
ExportColumn::make('bundle_number')
|
||||
->label('BUNDLE NUMBER'),
|
||||
ExportColumn::make('picked_weight')
|
||||
->label('PICKED WEIGHT'),
|
||||
ExportColumn::make('scanned_by')
|
||||
->label('SCANNED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
->enabledByDefault(false)
|
||||
->label('DELETED AT'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your weight validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,13 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Block;
|
||||
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 Notification;
|
||||
use Str;
|
||||
|
||||
class BlockImporter extends Importer
|
||||
{
|
||||
@@ -17,11 +21,13 @@ class BlockImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Block Name')
|
||||
->example('Block A')
|
||||
->label('Block Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
@@ -30,12 +36,29 @@ class BlockImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Block
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
// $warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
|
||||
}
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
$warnMsg[] = "Block name not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return Block::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
]);
|
||||
// return Block::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Block();
|
||||
// return new Block();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
87
app/Filament/Imports/CheckPointNameImporter.php
Normal file
87
app/Filament/Imports/CheckPointNameImporter.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CheckPointName;
|
||||
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 CheckPointNameImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CheckPointName::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Check Point Name')
|
||||
->example('STP BACKSIDE')
|
||||
->label('Check Point Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example(Filament::auth()->user()->name ?? 'Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?CheckPointName
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
if (Str::length($this->data['name']) < 3) { // || !ctype_alnum($this->data['name'])
|
||||
$warnMsg[] = "Invalid check point name found";
|
||||
}
|
||||
$createdBy = $this->data['created_by'];
|
||||
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return CheckPointName::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'created_by' => $this->data['created_by']
|
||||
]
|
||||
);
|
||||
// // return CheckPointName::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new CheckPointName();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your check point name 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;
|
||||
}
|
||||
}
|
||||
153
app/Filament/Imports/CheckPointTimeImporter.php
Normal file
153
app/Filament/Imports/CheckPointTimeImporter.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CheckPointName;
|
||||
use App\Models\CheckPointTime;
|
||||
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 CheckPointTimeImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = CheckPointTime::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('checkPointNames1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Check Point 1')
|
||||
->example('STP BACKSIDE')
|
||||
->label('Check Point 1')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('checkPointNames2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Check Point 2')
|
||||
->example('CANTEEN')
|
||||
->label('Check Point 2')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sequence_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Sequence Number')
|
||||
->example('1')
|
||||
->label('Sequence Number')
|
||||
->integer()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('time_lapse')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Time Lapse')
|
||||
->example('1')
|
||||
->label('Time Lapse')
|
||||
->integer()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('time_lapse_cushioning')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Time Lapse Cushioning')
|
||||
->example('1')
|
||||
->label('Time Lapse Cushioning')
|
||||
->integer()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example(Filament::auth()->user()->name ?? 'Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?CheckPointTime
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$checkPointNames1 = null;
|
||||
$checkPointNames2 = null;
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkPointNames1 = CheckPointName::where('name', $this->data['checkPointNames1'])->first();
|
||||
if (!$checkPointNames1) {
|
||||
$warnMsg[] = "Check point 1 not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkPointNames2 = CheckPointName::where('name', $this->data['checkPointNames2'])->first();
|
||||
if (!$checkPointNames2) {
|
||||
$warnMsg[] = "Check point 2 not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($checkPointNames1->id === $checkPointNames2->id) {
|
||||
$warnMsg[] = "Check point 1 and 2 can't be the same";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($this->data['sequence_number']) < 1 || !is_numeric($this->data['sequence_number']) || $this->data['sequence_number'] <= 0) {
|
||||
$warnMsg[] = "Invalid sequence number found";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['time_lapse']) < 1 || !is_numeric($this->data['time_lapse']) || $this->data['time_lapse'] <= 0) {
|
||||
$warnMsg[] = "Invalid time lapse found";
|
||||
}
|
||||
|
||||
if (Str::length($this->data['time_lapse_cushioning']) < 1 || !is_numeric($this->data['time_lapse_cushioning']) || $this->data['time_lapse_cushioning'] <= 0) {
|
||||
$warnMsg[] = "Invalid time lapse cushioning found";
|
||||
}
|
||||
|
||||
$createdBy = $this->data['created_by'];
|
||||
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return CheckPointTime::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'check_point1_id' => $checkPointNames1->id,
|
||||
'check_point2_id' => $checkPointNames2->id,
|
||||
'sequence_number' => $this->data['sequence_number']
|
||||
],
|
||||
[
|
||||
'time_lapse' => $this->data['time_lapse'],
|
||||
'time_lapse_cushioning' => $this->data['time_lapse_cushioning'],
|
||||
'created_by' => $this->data['created_by']
|
||||
]
|
||||
);
|
||||
// // return CheckPointTime::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new CheckPointTime();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your check point time import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Company;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class CompanyImporter extends Importer
|
||||
{
|
||||
@@ -17,6 +19,7 @@ class CompanyImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Company Name')
|
||||
->example('C.R.I. Pumps Private Limited')
|
||||
->label('Company Name')
|
||||
->rules(['required']),
|
||||
];
|
||||
@@ -24,12 +27,19 @@ class CompanyImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Company
|
||||
{
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
throw new RowImportFailedException("Company name not found");
|
||||
}
|
||||
return Company::updateOrCreate([
|
||||
'name' => $this->data['name']
|
||||
]
|
||||
);
|
||||
// return Company::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Company();
|
||||
// return new Company();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
78
app/Filament/Imports/ConfigurationImporter.php
Normal file
78
app/Filament/Imports/ConfigurationImporter.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Configuration;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class ConfigurationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = Configuration::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('c_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Type')
|
||||
->example(['Testing Panel Readings'])
|
||||
->label('Type')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('c_group')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Group')
|
||||
->example(['LMC_WINDED'])
|
||||
->label('Group')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('c_name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Name')
|
||||
->example(['MOTOR_PHASE'])
|
||||
->label('Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('c_value')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Value')
|
||||
->example(['Single'])
|
||||
->label('Value')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I'])
|
||||
->label('Plant')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?Configuration
|
||||
{
|
||||
// return Configuration::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Configuration();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your configuration 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;
|
||||
}
|
||||
}
|
||||
103
app/Filament/Imports/GuardNameImporter.php
Normal file
103
app/Filament/Imports/GuardNameImporter.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\GuardName;
|
||||
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 GuardNameImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = GuardName::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Guard Name')
|
||||
->example('Shivaram')
|
||||
->label('Guard Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('identification1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Identification 1')
|
||||
->example('1234567890123456')
|
||||
->label('Identification 1')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('identification2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Identification 2')
|
||||
->example('')
|
||||
->label('Identification 2'),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example(Filament::auth()->user()->name ?? 'Admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?GuardName
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
if (Str::length($this->data['name']) < 3) { // || !ctype_alnum($this->data['name'])
|
||||
$warnMsg[] = "Invalid guard name found";
|
||||
}
|
||||
if (Str::length($this->data['identification1']) < 5) {
|
||||
$warnMsg[] = "Invalid identification-1 found";
|
||||
}
|
||||
$createdBy = $this->data['created_by'];
|
||||
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return GuardName::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'identification1' => $this->data['identification1'],
|
||||
'identification2' => $this->data['identification2'],
|
||||
'created_by' => $this->data['created_by']
|
||||
]
|
||||
);
|
||||
|
||||
// // return GuardName::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
//return new GuardName();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your guard name 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;
|
||||
}
|
||||
}
|
||||
160
app/Filament/Imports/GuardPatrolEntryImporter.php
Normal file
160
app/Filament/Imports/GuardPatrolEntryImporter.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\CheckPointName;
|
||||
use App\Models\GuardName;
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use App\Models\Plant;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class GuardPatrolEntryImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = GuardPatrolEntry::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('guardNames')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Guard Name')
|
||||
->example('ARUMUGAM - HG')
|
||||
->label('Guard Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('checkPointNames')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Check Point Name')
|
||||
->example('STP BACKSIDE')
|
||||
->label('Check Point Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('reader_code')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Reader Code')
|
||||
// ->example('0C03-25010112')
|
||||
// ->label('Reader Code'),
|
||||
ImportColumn::make('patrol_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Patrol Time')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->label('Patrol Time')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('created_by')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Created By')
|
||||
// ->example(Filament::auth()->user()->name ?? 'Admin')
|
||||
// ->label('Created By')
|
||||
// ->rules(['required']),
|
||||
// ImportColumn::make('updated_by')
|
||||
// ->requiredMapping()
|
||||
// ->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?GuardPatrolEntry
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$guardNames = null;
|
||||
$checkPointNames = null;
|
||||
$patrolDateTime = null; //$fdateTime = null;
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
else
|
||||
{
|
||||
$guardNames = GuardName::where('plant_id', $plant->id)->where('name', $this->data['guardNames'])->first();
|
||||
if (!$guardNames) {
|
||||
$warnMsg[] = "Guard name not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$checkPointNames = CheckPointName::where('plant_id', $plant->id)->where('name', $this->data['checkPointNames'])->first();
|
||||
if (!$checkPointNames) {
|
||||
$warnMsg[] = "Check point name not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$patrolTime = $this->data['patrol_time'];//$fromDate = $this->data['from_datetime'];
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$patrolDateTime = Carbon::createFromFormat($format, $patrolTime);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($patrolDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Patrol DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
$guardEntryFound = GuardPatrolEntry::where('plant_id', $plant->id)->where('guard_name_id', $guardNames->id)->where('check_point_name_id', $checkPointNames->id)->where('patrol_time', $patrolDateTime->format('Y-m-d H:i:s'))->first();
|
||||
if ($guardEntryFound) {
|
||||
$warnMsg[] = "Duplicate guard patrol entry found";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$createdBy = Filament::auth()->user()->name;// ?? 'Admin'
|
||||
if (!$createdBy) {
|
||||
$warnMsg[] = "Invalid created by name found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
GuardPatrolEntry::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'guard_name_id' => $guardNames->id,
|
||||
'check_point_name_id' => $checkPointNames->id,
|
||||
'patrol_time' => $patrolDateTime->format('Y-m-d H:i:s')
|
||||
],
|
||||
[
|
||||
'reader_code' => null,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $createdBy
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return GuardPatrolEntry::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new GuardPatrolEntry();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your guard patrol entry import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class ItemImporter extends Importer
|
||||
{
|
||||
@@ -14,25 +17,39 @@ class ItemImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('category')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Category')
|
||||
->example('Submersible Motor')
|
||||
->label('Category'),
|
||||
ImportColumn::make('code')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('123456')
|
||||
->label('Item Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('description')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Description')
|
||||
->example('Testing Model Description 1')
|
||||
->label('Description')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('hourly_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Hourly Quantity')
|
||||
->example('25')
|
||||
->label('Hourly Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('uom')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Unit of Measure')
|
||||
->example('EA')
|
||||
->label('Unit of Measure'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
@@ -41,12 +58,40 @@ class ItemImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Item
|
||||
{
|
||||
// return Item::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Item;
|
||||
$warnMsg = [];
|
||||
$iCode = trim($this->data['code']);
|
||||
$description = trim($this->data['description']);
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
|
||||
}
|
||||
if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
// if (Str::length($this->data['uom']) <= 0) {
|
||||
// $warnMsg[] = "Invalid unit of measure found";
|
||||
// }
|
||||
if (Str::length($description) < 5) {
|
||||
$warnMsg[] = "Invalid description found";
|
||||
}
|
||||
if (Str::length($this->data['hourly_quantity']) < 0 || !is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
|
||||
$warnMsg[] = "Invalid hourly quantity found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return Item::updateOrCreate([
|
||||
'code' => $iCode,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'category' => trim($this->data['category']),
|
||||
'description' => $description,
|
||||
'hourly_quantity' => $this->data['hourly_quantity'],
|
||||
'uom' => trim($this->data['uom'])
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class LineImporter extends Importer
|
||||
{
|
||||
@@ -17,16 +20,24 @@ class LineImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Type')
|
||||
->example('Domestic Assembly')
|
||||
->label('Line Type')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('group_work_center')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Group Work Center')
|
||||
->example('RMGCEABC')
|
||||
->label('Group Work Center'),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
@@ -35,12 +46,35 @@ class LineImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Line
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
|
||||
}
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
$warnMsg[] = "Line name not found";
|
||||
}
|
||||
if (Str::length($this->data['type']) < 0) {
|
||||
$warnMsg[] = "Line type not found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return Line::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'type' => $this->data['type'],
|
||||
'group_work_center' => $this->data['group_work_center']
|
||||
]
|
||||
);
|
||||
// return Line::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Line();
|
||||
// return new Line();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\LineStop;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class LineStopImporter extends Importer
|
||||
{
|
||||
@@ -17,11 +20,13 @@ class LineStopImporter extends Importer
|
||||
ImportColumn::make('code')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Stop Code')
|
||||
->example('A1R')
|
||||
->label('Line Stop Code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('reason')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Stop Reason')
|
||||
->example('Power Shut Down')
|
||||
->label('Line Stop Reason')
|
||||
->rules(['required']),
|
||||
];
|
||||
@@ -29,12 +34,29 @@ class LineStopImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?LineStop
|
||||
{
|
||||
$warnMsg = [];
|
||||
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
|
||||
$warnMsg[] = "Invalid line stop code found";
|
||||
}
|
||||
if (Str::length($this->data['reason']) < 5) {
|
||||
$warnMsg[] = "Invalid line stop reason found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
return LineStop::updateOrCreate([
|
||||
'code' => $this->data['code']
|
||||
],
|
||||
[
|
||||
'reason' => $this->data['reason']
|
||||
]
|
||||
);
|
||||
// return LineStop::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new LineStop();
|
||||
// return new LineStop();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
125
app/Filament/Imports/LocatorImporter.php
Normal file
125
app/Filament/Imports/LocatorImporter.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Locator;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class LocatorImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = Locator::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Locator Number')
|
||||
->example(['W01-A1A'])
|
||||
->label('Locator Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('locator_quantity')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Locator Quantity')
|
||||
->example(['0'])
|
||||
->label('Locator Quantity')
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example(['Admin'])
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Code')
|
||||
->example(['1000'])
|
||||
->label('Plant Code')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?Locator
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$user = null;
|
||||
$locator = $this->data['locator_number'];
|
||||
// $locatorQuantity = $this->data['locator_quantity'];
|
||||
$palletQuantity = 0;
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$user = Filament::auth()->user()->name;
|
||||
if (Str::length($locator) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
else {
|
||||
// $locat = Locator::where('name', $locator)->where('plant_id', $plant->id)->first();
|
||||
$palletQuantity = PalletValidation::where('locator_number', $locator)->where('plant_id', $plant->id)->distinct('pallet_number')->count('pallet_number');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (Str::length($locatorQuantity) < 0 || !is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
// $user = User::where('name', $user)->first();
|
||||
// if (!$user) {
|
||||
// $warnMsg[] = "Operator ID not found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
Locator::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'locator_number' => $locator
|
||||
],
|
||||
[
|
||||
'locator_quantity' => $palletQuantity,
|
||||
'operator_id' => $user
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return Locator::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new Locator();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your locator 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;
|
||||
}
|
||||
}
|
||||
271
app/Filament/Imports/LocatorInvoiceValidationImporter.php
Normal file
271
app/Filament/Imports/LocatorInvoiceValidationImporter.php
Normal file
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class LocatorInvoiceValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = LocatorInvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Invoice Number')
|
||||
->example('3RA002514')
|
||||
->label('Invoice Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number')
|
||||
->example('2514121551420')
|
||||
->label('Serial Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('pallet_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Pallet Number')
|
||||
->example('EP-2506001')
|
||||
->label('Pallet Number'),
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Locator Number')
|
||||
->example('W05-D1B')
|
||||
->label('Locator Number'),
|
||||
ImportColumn::make('scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned Status')
|
||||
->example('')
|
||||
->label('Scanned Status'),
|
||||
ImportColumn::make('upload_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Upload Status')
|
||||
->example('Y')
|
||||
->label('Upload Status'),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created At')
|
||||
->example('2025-06-17 01:42:16')
|
||||
->label('Created At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Scanned At'),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Updated At'),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created by')
|
||||
->example('RAW012345')
|
||||
->label('Created by')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned by')
|
||||
->example('RAW012345')
|
||||
->label('Scanned by'),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated by')
|
||||
->example('RAW012345')
|
||||
->label('Updated by'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?LocatorInvoiceValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$invoiceNo = $this->data['invoice_number'];
|
||||
$serialNo = $this->data['serial_number'];
|
||||
$palletNo = $this->data['pallet_number'];
|
||||
$locatorNo = $this->data['locator_number'];
|
||||
$scannedStat = $this->data['scanned_status'];
|
||||
$uploadStat = $this->data['upload_status'];
|
||||
$createdAt = $this->data['created_at'];
|
||||
$scannedAt = $this->data['scanned_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
$cDateTime = null;
|
||||
$sDateTime = null;
|
||||
$uDateTime = null;
|
||||
$createdBy = $this->data['created_by'];
|
||||
$scannedBy = $this->data['scanned_by'];
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if (Str::length($scannedStat) > 0 && $scannedStat != 'Scanned') {
|
||||
$warnMsg[] = "Invalid scanned status found";
|
||||
}
|
||||
if ($uploadStat != 'Y' && $uploadStat != 'N') {
|
||||
$warnMsg[] = "Invalid upload status found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
if (Str::length($scannedBy) > 0) {
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
}
|
||||
if (Str::length($updatedBy) > 0) {
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (Str::length($scannedAt) > 0)
|
||||
{
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($sDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($updatedAt) > 0)
|
||||
{
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
LocatorInvoiceValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo
|
||||
],
|
||||
[
|
||||
'invoice_number' => $invoiceNo,
|
||||
'pallet_number' => $palletNo,
|
||||
'locator_number' => $locatorNo,
|
||||
'scanned_status' => $scannedStat,
|
||||
'upload_status' => $uploadStat,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'scanned_at' => (Str::length($scannedAt) > 0) ? $sDateTime->format('Y-m-d H:i:s') : null,
|
||||
'updated_at' => (Str::length($updatedAt) > 0) ? $uDateTime->format('Y-m-d H:i:s') : null,
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return LocatorInvoiceValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new LocatorInvoiceValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your locator invoice validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
111
app/Filament/Imports/MachineImporter.php
Normal file
111
app/Filament/Imports/MachineImporter.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Line;
|
||||
use App\Models\Machine;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class MachineImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = Machine::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Machine')
|
||||
->example(['1600251'])
|
||||
->label('Machine')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('work_center')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->example('RMGCE001')
|
||||
->label('Work Center'),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Line')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I'])
|
||||
->label('Plant')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?Machine
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$machine = $this->data['name'];
|
||||
$workCenter = $this->data['work_center'];
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
if ($line) {
|
||||
$grpWrkCnr = $line->group_work_center;
|
||||
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||
{
|
||||
$warnMsg[] = "Group work center line not found";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($machine) <= 0) {
|
||||
$warnMsg[] = "Machine name not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
Machine::updateOrCreate(
|
||||
[
|
||||
'name' => $machine,
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id
|
||||
],
|
||||
[
|
||||
'work_center' => $workCenter
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return Machine::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new Machine();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your machine 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;
|
||||
}
|
||||
}
|
||||
91
app/Filament/Imports/MfmParameterImporter.php
Normal file
91
app/Filament/Imports/MfmParameterImporter.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\MfmParameter;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class MfmParameterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = MfmParameter::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('mfmMeter')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Mfm Meter Sequence')
|
||||
->example('1')
|
||||
->label('Mfm Meter Sequence')
|
||||
->relationship(resolveUsing:'sequence')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Parameter Name')
|
||||
->example('apparent_energy_received')
|
||||
->label('Parameter Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('register_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Register ID')
|
||||
->example('2715')
|
||||
->label('Register ID')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('identifier')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Identifier')
|
||||
->example('Kvah')
|
||||
->label('Identifier')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('byte_to_convert')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Byte To Convert')
|
||||
->example('1')
|
||||
->label('Byte To Convert')
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('type_to_convert')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Type To Convert')
|
||||
->example('FLOAT32')
|
||||
->label('Type To Convert')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('decimal_to_display')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Decimal To Display')
|
||||
->example('2')
|
||||
->label('Decimal To Display')
|
||||
->rules(['required', 'integer']),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?MfmParameter
|
||||
{
|
||||
// return MfmParameter::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MfmParameter();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your mfm parameter import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
241
app/Filament/Imports/MotorTestingMasterImporter.php
Normal file
241
app/Filament/Imports/MotorTestingMasterImporter.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\MotorTestingMaster;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
class MotorTestingMasterImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = MotorTestingMaster::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example(['123456','123457','123458'])
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('isi_model')
|
||||
->boolean()
|
||||
->exampleHeader('ISI Model')
|
||||
->example(['Y','N','Y'])
|
||||
->label('ISI Model')
|
||||
->rules(['boolean']),
|
||||
ImportColumn::make('phase')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Phase')
|
||||
->example(['Single','Three','Single'])
|
||||
->label('Phase')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('hp')
|
||||
->requiredMapping()
|
||||
->exampleHeader('HP')
|
||||
->example(['5','10','5'])
|
||||
->label('HP')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('kw')
|
||||
->requiredMapping()
|
||||
->exampleHeader('KW')
|
||||
->example(['5','7.5','5'])
|
||||
->label('KW')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('volt')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Volt')
|
||||
->example(['230','380','230'])
|
||||
->label('Volt')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('current')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Current')
|
||||
->example(['7','21.8','7'])
|
||||
->label('Current')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('rpm')
|
||||
->requiredMapping()
|
||||
->exampleHeader('RPM')
|
||||
->example(['2500','3420','2500'])
|
||||
->label('RPM')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('torque')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Torque')
|
||||
->example(['0.5','1.25','0.5'])
|
||||
->label('Torque')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('frequency')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Frequency')
|
||||
->label('Frequency')
|
||||
->example(['50','60','50'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('connection')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Connection')
|
||||
->label('Connection')
|
||||
->example(['Star','Star-Delta','Delta'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('ins_res_limit')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Insulation Resistance Limit')
|
||||
->label('Insulation Resistance Limit')
|
||||
->example(['1000','2','1000'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('ins_res_type')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Insulation Resistance Type')
|
||||
->label('Insulation Resistance Type')
|
||||
->example(['O','G','O'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('routine_test_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Routine Test Time')
|
||||
->label('Routine Test Time')
|
||||
->example(['00:40:00','00:40:00','00:40:00'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('res_ry_ll')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Resistance RY LL')
|
||||
->label('Resistance RY LL')
|
||||
->example(['0.05','0.05','0.05'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('res_ry_ul')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Resistance RY UL')
|
||||
->label('Resistance RY UL')
|
||||
->example(['99','99','99'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('res_yb_ll')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Resistance YB LL')
|
||||
->label('Resistance YB LL')
|
||||
->example(['0.05','0.05','0.05'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('res_yb_ul')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Resistance YB UL')
|
||||
->label('Resistance YB UL')
|
||||
->example(['99','99','99'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('res_br_ll')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Resistance BR LL')
|
||||
->label('Resistance BR LL')
|
||||
->example(['0.05','0.05','0.05'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('res_br_ul')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Resistance BR UL')
|
||||
->label('Resistance BR UL')
|
||||
->example(['99','99','99'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lock_volt_limit')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Lock Volt Limit')
|
||||
->label('Lock Volt Limit')
|
||||
->example(['80','100','80'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('leak_cur_limit')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Leakage Current Limit')
|
||||
->label('Leakage Current Limit')
|
||||
->example(['50','50','50'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lock_cur_ll')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Lock Current LL')
|
||||
->label('Lock Current LL')
|
||||
->example(['10','12.5','10'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('lock_cur_ul')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Lock Current UL')
|
||||
->label('Lock Current UL')
|
||||
->example(['15','14.6','15'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('noload_cur_ll')
|
||||
->requiredMapping()
|
||||
->exampleHeader('No Load Current LL')
|
||||
->label('No Load Current LL')
|
||||
->example(['3','5.9','3'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('noload_cur_ul')
|
||||
->requiredMapping()
|
||||
->exampleHeader('No Load Current UL')
|
||||
->label('No Load Current UL')
|
||||
->example(['15','6.9','15'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('noload_pow_ll')
|
||||
->requiredMapping()
|
||||
->exampleHeader('No Load Power LL')
|
||||
->label('No Load Power LL')
|
||||
->example(['250','850','250'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('noload_pow_ul')
|
||||
->requiredMapping()
|
||||
->exampleHeader('No Load Power UL')
|
||||
->label('No Load Power UL')
|
||||
->example(['500','1200','500'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('noload_spd_ll')
|
||||
->requiredMapping()
|
||||
->exampleHeader('No Load Speed LL')
|
||||
->label('No Load Speed LL')
|
||||
->example(['2000','2500','2000'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('noload_spd_ul')
|
||||
->requiredMapping()
|
||||
->exampleHeader('No Load Speed UL')
|
||||
->label('No Load Speed UL')
|
||||
->example(['4000','3500','4000'])
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant')
|
||||
->example(['Ransar Industries-I','Ransar Industries-I','Ransar Industries-I'])
|
||||
->label('Plant')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated By')
|
||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
->label('Updated By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?MotorTestingMaster
|
||||
{
|
||||
// return MotorTestingMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new MotorTestingMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your motor testing master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
257
app/Filament/Imports/PalletValidationImporter.php
Normal file
257
app/Filament/Imports/PalletValidationImporter.php
Normal file
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class PalletValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = PalletValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->label('Plant Code')
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->label('Serial Number')
|
||||
->exampleHeader('Serial Number')
|
||||
->example('12345678901234')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('pallet_number')
|
||||
->requiredMapping()
|
||||
->label('Pallet Number')
|
||||
->exampleHeader('Pallet Number')
|
||||
->example('EP-2507001'),
|
||||
ImportColumn::make('pallet_status')
|
||||
->requiredMapping()
|
||||
->label('Pallet Status')
|
||||
->exampleHeader('Pallet Status')
|
||||
->example('Completed'),
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->label('Locator Number')
|
||||
->exampleHeader('Locator Number')
|
||||
->example('W05-D1B'),
|
||||
ImportColumn::make('locator_quantity')
|
||||
->requiredMapping()
|
||||
->label('Locator Quantity')
|
||||
->exampleHeader('Locator Quantity')
|
||||
->example(1)
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->label('Created At')
|
||||
->exampleHeader('Created At')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->label('Scanned At')
|
||||
->exampleHeader('Scanned At')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->label('Updated At')
|
||||
->exampleHeader('Updated At')
|
||||
->example('01-01-2025 08:00:00')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->label('Created By')
|
||||
->exampleHeader('Created By')
|
||||
->example('Admin')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->requiredMapping()
|
||||
->label('Scanned By')
|
||||
->exampleHeader('Scanned By')
|
||||
->example('Admin')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->label('Updated By')
|
||||
->exampleHeader('Updated By')
|
||||
->example('Admin'),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?PalletValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$serialNo = $this->data['serial_number'];
|
||||
$palletNo = $this->data['pallet_number'];
|
||||
$palletStat = $this->data['pallet_status'];
|
||||
$locatorNo = $this->data['locator_number'];
|
||||
$locatorQty = $this->data['locator_quantity'];
|
||||
$createdAt = $this->data['created_at'];
|
||||
$scannedAt = $this->data['scanned_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
$cDateTime = null;
|
||||
$sDateTime = null;
|
||||
$uDateTime = null;
|
||||
$createdBy = $this->data['created_by'];
|
||||
$scannedBy = $this->data['scanned_by'];
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($palletStat) > 0 && $palletStat != 'Completed') {
|
||||
$warnMsg[] = "Invalid pallet status found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if (Str::length($palletNo) <= 0 && Str::length($locatorNo) <= 0) {
|
||||
$warnMsg[] = "Pallet and locator number found";
|
||||
}
|
||||
if (Str::length($locatorQty) < 0 || !is_numeric($locatorQty) || $locatorQty < 0 || $locatorQty > 2) {
|
||||
$warnMsg[] = "Invalid locator quantity found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($sDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try
|
||||
{
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
PalletValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo
|
||||
],
|
||||
[
|
||||
'pallet_number' => $palletNo,
|
||||
'pallet_status' => $palletStat,
|
||||
'locator_number' => $locatorNo,
|
||||
'locator_quantity' => $locatorQty,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'scanned_at' => $sDateTime->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return PalletValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new PalletValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your pallet validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Plant;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class PlantImporter extends Importer
|
||||
{
|
||||
@@ -18,35 +21,78 @@ class PlantImporter extends Importer
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->rules(['required']), //, 'integer'
|
||||
ImportColumn::make('company')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Company Name')
|
||||
->label('Company Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('address')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Address')
|
||||
->example('7/51-A, Keeranatham Road, Saravanampatty, Coimbatore - 641035')
|
||||
->label('Plant Address')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('company')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Company Name')
|
||||
->example('C.R.I. Pumps Private Limited')
|
||||
->label('Company Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?Plant
|
||||
{
|
||||
$warnMsg = [];
|
||||
$company = Company::where('name', $this->data['company'])->first();
|
||||
if (!$company) {
|
||||
$warnMsg[] = "Company name not found";
|
||||
}
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
$warnMsg[] = "Plant name not found";
|
||||
}
|
||||
if (Str::length($this->data['code']) < 4 || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
if (Str::length($this->data['address']) < 3) {
|
||||
$warnMsg[] = "Invalid address found";
|
||||
}
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$plantCN = Plant::where('code', $this->data['code'])->where('name', $this->data['name'])->first();
|
||||
if (!$plantCN) {
|
||||
$plantCode = Plant::where('code', $this->data['code'])->first();
|
||||
$plantName = Plant::where('name', $this->data['name'])->first();
|
||||
if ($plantName) {
|
||||
throw new RowImportFailedException("Duplicate plant name found");
|
||||
}
|
||||
else if ($plantCode) {
|
||||
throw new RowImportFailedException("Duplicate plant code found");
|
||||
}
|
||||
}
|
||||
|
||||
return Plant::updateOrCreate([
|
||||
'code' => $this->data['code'],
|
||||
'name' => $this->data['name'],
|
||||
],
|
||||
[
|
||||
'address' => $this->data['address'],
|
||||
'company_id' => $company->id
|
||||
]
|
||||
);
|
||||
// return Plant::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Plant();
|
||||
// return new Plant();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -2,10 +2,19 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Block;
|
||||
use App\Models\Line;
|
||||
use App\Models\LineStop;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionLineStop;
|
||||
use App\Models\Shift;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
class ProductionLineStopImporter extends Importer
|
||||
{
|
||||
@@ -17,60 +26,206 @@ class ProductionLineStopImporter extends Importer
|
||||
ImportColumn::make('from_datetime')
|
||||
->requiredMapping()
|
||||
->exampleHeader('From DateTime')
|
||||
->example(['01-01-2025 00:00:00', '01-01-2025 20:00:00'])
|
||||
->label('From DateTime')
|
||||
->rules(['required', 'datetime']),
|
||||
->rules(['required']), //, 'date_format:"d-m-Y H:i:s"'
|
||||
ImportColumn::make('to_datetime')
|
||||
->requiredMapping()
|
||||
->exampleHeader('To DateTime')
|
||||
->example(['01-01-2025 01:25:00', '01-01-2025 21:00:00'])
|
||||
->label('To DateTime')
|
||||
->rules(['required', 'datetime']),
|
||||
->rules(['required']),
|
||||
ImportColumn::make('stop_hour')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Stop Hour')
|
||||
->example(['1', '1'])
|
||||
->label('Stop Hour')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('stop_min')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Stop Min')
|
||||
->example(['25','0'])
|
||||
->label('Stop Min')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('linestop')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Stop Code')
|
||||
->example(['A7R', 'A1R'])
|
||||
->label('Line Stop Code')
|
||||
->relationship(resolveUsing:'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example(['Day', 'Night'])
|
||||
->label('Shift Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionLineStop
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$block = null;
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
//block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$line) {
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
$shift = null;
|
||||
if (!$block) {
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
else {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
}
|
||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (!$shift) {
|
||||
$warnMsg[] = "Shift not found";
|
||||
}
|
||||
$linestop = LineStop::where('code', $this->data['linestop'])->first();
|
||||
if (!$linestop) {
|
||||
$warnMsg[] = "Line stop code not found";
|
||||
}
|
||||
$stophour = is_numeric($this->data['stop_hour']) && $this->data['stop_hour'] >= 0;
|
||||
$stopmin = is_numeric($this->data['stop_min']) && $this->data['stop_min'] >= 0 && $this->data['stop_min'] <= 60;
|
||||
if (!$stophour && !$stopmin) {
|
||||
$warnMsg[] = "Invalid stop hour/minute found";
|
||||
}
|
||||
else if (!$stophour) {
|
||||
$warnMsg[] = "Invalid stop hour found";
|
||||
}
|
||||
else if (!$stopmin) {
|
||||
$warnMsg[] = "Invalid stop min found";
|
||||
}
|
||||
else {
|
||||
$stophour = (int)$this->data['stop_hour'];
|
||||
$stopmin = (int)$this->data['stop_min'];
|
||||
if ($stophour == 0 && $stopmin == 0) {
|
||||
$warnMsg[] = "Invalid stop hour/minute found";
|
||||
}
|
||||
}
|
||||
$validHourMin = ($stophour == 0 && $stopmin == 0) ? false : true;
|
||||
if (!$validHourMin) {
|
||||
$warnMsg[] = "Invalid stop hour/minute found";
|
||||
}
|
||||
$fromDate = $this->data['from_datetime'];
|
||||
$toDate = $this->data['to_datetime'];
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
$fdateTime = null;
|
||||
$tdateTime = null;
|
||||
// Try parsing with multiple formats
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
// $fDateOnly = '';
|
||||
if (!isset($fdateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'From DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
// else {
|
||||
// $fDateOnly = $fdateTime->toDateString();
|
||||
// }
|
||||
if (!isset($tdateTime)) {
|
||||
$warnMsg[] = "Invalid 'To DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($fdateTime) && isset($tdateTime)) {
|
||||
if ($fdateTime->greaterThan($tdateTime)) {
|
||||
$warnMsg[] = "'From DataTime' is greater than 'To DateTime'.";
|
||||
}
|
||||
}
|
||||
|
||||
// if (!$fromDate) { // || $fromDate->format('d-m-Y H:i') !== $from)
|
||||
// $warnMsg[] = "Invalid 'From DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
// else if (!$toDate) { // || $toDate->format('d-m-Y H:i') !== $to
|
||||
// $warnMsg[] = "Invalid 'To DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
ProductionLineStop::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'shift_id' => $shift->id,
|
||||
'linestop_id' => $linestop->id,
|
||||
'from_datetime' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['from_datetime'],
|
||||
'to_datetime' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['to_datetime'],
|
||||
'stop_hour' => (int)$this->data['stop_hour'],
|
||||
'stop_min' => (int)$this->data['stop_min'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
return null;
|
||||
// return ProductionLineStop::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ProductionLineStop();
|
||||
// return new ProductionLineStop();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -2,10 +2,19 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Block;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\Shift;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class ProductionPlanImporter extends Importer
|
||||
{
|
||||
@@ -17,54 +26,206 @@ class ProductionPlanImporter extends Importer
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Created DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plan_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plan Quantity')
|
||||
->example(['500', '450'])
|
||||
->label('Plan Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('production_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Production Quantity')
|
||||
->example(['0', '0'])
|
||||
->label('Production Quantity')
|
||||
->numeric()
|
||||
->rules(['required', 'integer']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->label('Shift Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->exampleHeader('Shift Name') //ID
|
||||
->example(['Day', 'Night']) //'2', '7'
|
||||
->label('Shift Name') // ID
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionPlan
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$block = null;
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
//block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$line) {
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
$shift = null;
|
||||
if (!$block) {
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
else {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
}
|
||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (!$shift) {
|
||||
$warnMsg[] = "Shift not found";
|
||||
}
|
||||
if (Str::length($this->data['plan_quantity']) < 0 || !is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
||||
$warnMsg[] = "Invalid plan quantity found";
|
||||
}
|
||||
if (Str::length($this->data['production_quantity']) < 0 || !is_numeric($this->data['production_quantity']) || $this->data['production_quantity'] < 0) {
|
||||
$warnMsg[] = "Invalid production quantity found";
|
||||
}
|
||||
|
||||
$fromDate = $this->data['created_at'];
|
||||
$toDate = $this->data['updated_at'];
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
$fdateTime = null;
|
||||
$tdateTime = null;
|
||||
// Try parsing with multiple formats
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
$fDateOnly = '';
|
||||
if (!isset($fdateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else {
|
||||
$fDateOnly = $fdateTime->toDateString();
|
||||
}
|
||||
if (!isset($tdateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($fdateTime) && isset($tdateTime)) {
|
||||
if ($fdateTime->greaterThan($tdateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
|
||||
// if (!$fromDate) {
|
||||
// $warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
// else if (!$toDate) {
|
||||
// $warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
else { //if (empty($warnMsg))
|
||||
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('shift_id', $shift->id)
|
||||
->where('line_id', $line->id)
|
||||
->whereDate('created_at', $fDateOnly)
|
||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($productionPlan) {
|
||||
// if($productionPlan->production_quantity)
|
||||
// {
|
||||
// throw new RowImportFailedException("{$productionPlan->created_at}, {$productionPlan->production_quantity}");
|
||||
// }
|
||||
// $warnMsg[] = "Production plan already exist on '{$fDateOnly}'!";
|
||||
|
||||
$productionPlan->update([
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
// 'production_quantity' => $productionPlan->production_quantity,
|
||||
// 'created_at' => $productionPlan->created_at,//$fdateTime->format('Y-m-d H:i:s'),
|
||||
// 'updated_at' => $tdateTime->format('Y-m-d H:i:s'),
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
$productionPlan->save();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
ProductionPlan::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'shift_id' => $shift->id,
|
||||
'plan_quantity' => $this->data['plan_quantity'],
|
||||
'production_quantity' => $this->data['production_quantity'],
|
||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['created_at'],
|
||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
return null;
|
||||
// return ProductionPlan::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new ProductionPlan();
|
||||
// return new ProductionPlan();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -2,10 +2,21 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Block;
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\Shift;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Str;
|
||||
|
||||
class ProductionQuantityImporter extends Importer
|
||||
{
|
||||
@@ -17,59 +28,210 @@ class ProductionQuantityImporter extends Importer
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Created DateTime')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('hourly_quantity')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Hourly Quantity')
|
||||
// ->label('Hourly Quantity')
|
||||
// ->numeric()
|
||||
// ->rules(['required', 'integer']),
|
||||
ImportColumn::make('production_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Production Order')
|
||||
->example(['1234567', '1234567'])
|
||||
->label('Production Order')
|
||||
->numeric(),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example(['123456', '123456'])
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing:'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number')
|
||||
->example(['12345678901234', '12345678902234'])
|
||||
->label('Serial Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block_reference')
|
||||
->requiredMapping() // Or optionalMapping() if not always present
|
||||
->exampleHeader('Block Name')
|
||||
->example(['Block A', 'Block A'])
|
||||
->label('Block Name')
|
||||
->rules(['required']), // Or remove if not required
|
||||
ImportColumn::make('shift')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example(['Day', 'Night'])
|
||||
->label('Shift Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example(['Ransar Industries-I', 'Ransar Industries-I'])
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ProductionQuantity
|
||||
{
|
||||
// return ProductionQuantity::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$block = null;
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
//block_reference
|
||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$line) {
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
$shift = null;
|
||||
if (!$block) {
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
else {
|
||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
||||
}
|
||||
//$shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
||||
if (!$shift) {
|
||||
$warnMsg[] = "Shift not found";
|
||||
}
|
||||
$item = null;
|
||||
if ($plant) {
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
}
|
||||
if (!$item) {
|
||||
$warnMsg[] = "Item not found";
|
||||
}
|
||||
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || !is_numeric($this->data['production_order']))) {
|
||||
$warnMsg[] = "Invalid production order found";
|
||||
}
|
||||
|
||||
return new ProductionQuantity();
|
||||
$fromDate = $this->data['created_at'];
|
||||
$toDate = $this->data['updated_at'];
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
$fdateTime = null;
|
||||
$tdateTime = null;
|
||||
// Try parsing with multiple formats
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
// $fDateOnly = '';
|
||||
if (!isset($fdateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
// else {
|
||||
// $fDateOnly = $fdateTime->toDateString();
|
||||
// }
|
||||
if (!isset($tdateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($fdateTime) && isset($tdateTime)) {
|
||||
if ($fdateTime->greaterThan($tdateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
// if (!$fromDate) {
|
||||
// $warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
// else if (!$toDate) {
|
||||
// $warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
else { //if (empty($warnMsg))
|
||||
$productionQuan = ProductionQuantity::where('plant_id', $plant->id)
|
||||
->where('serial_number', $this->data['serial_number'])
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($productionQuan) {
|
||||
throw new RowImportFailedException("Serial number already exist!");
|
||||
}
|
||||
}
|
||||
|
||||
ProductionQuantity::updateOrCreate([
|
||||
'serial_number' => $this->data['serial_number'],
|
||||
'plant_id' => $plant->id,
|
||||
'shift_id' => $shift->id,
|
||||
'line_id' => $line->id,
|
||||
'item_id' => $item->id,
|
||||
'production_order' => $this->data['production_order'] ?? null,
|
||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['created_at'],
|
||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
// ProductionQuantity::updateOrCreate([
|
||||
// 'serial_number' => $this->data['serial_number'],
|
||||
// 'plant_id' => $plant->id,
|
||||
// ],
|
||||
// [
|
||||
// 'shift_id' => $shift->id,
|
||||
// 'line_id' => $line->id,
|
||||
// 'item_id' => $item->id,
|
||||
// 'production_order' => $this->data['production_order'] ?? null,
|
||||
// 'created_at' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['created_at'],
|
||||
// 'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
||||
// 'operator_id' => $this->data['operator_id'],
|
||||
// ]);
|
||||
return null;
|
||||
|
||||
// return new ProductionQuantity();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
@@ -82,4 +244,49 @@ class ProductionQuantityImporter extends Importer
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function processRow(array $row): Model
|
||||
{
|
||||
// Activate import flag
|
||||
ProductionQuantity::$importing = true;
|
||||
|
||||
try {
|
||||
// Create record with relationships
|
||||
$productionQuantity = ProductionQuantity::create([
|
||||
'created_at' => $row['created_at'],
|
||||
'item_id' => $this->resolveItemId($row['item']),
|
||||
'serial_number' => $row['serial_number'],
|
||||
'line_id' => $this->resolveLineId($row['line']),
|
||||
'shift_id' => $this->resolveShiftId($row['shift']),
|
||||
'plant_id' => $this->resolvePlantId($row['plant']),
|
||||
'updated_at' => $row['updated_at']
|
||||
]);
|
||||
} finally {
|
||||
// Always disable flag even if errors occur
|
||||
ProductionQuantity::$importing = false;
|
||||
}
|
||||
|
||||
return $productionQuantity;
|
||||
}
|
||||
|
||||
// Relationship resolvers
|
||||
private function resolveItemId(string $code): int
|
||||
{
|
||||
return Item::where('code', $code)->first()->id;
|
||||
}
|
||||
|
||||
private function resolveLineId(string $name): int
|
||||
{
|
||||
return Line::where('name', $name)->first()->id;
|
||||
}
|
||||
|
||||
private function resolveShiftId(string $name): int
|
||||
{
|
||||
return Shift::where('name', $name)->first()->id;
|
||||
}
|
||||
|
||||
private function resolvePlantId(string $name): int
|
||||
{
|
||||
return Plant::where('name', $name)->first()->id;
|
||||
}
|
||||
}
|
||||
|
||||
331
app/Filament/Imports/QualityValidationImporter.php
Normal file
331
app/Filament/Imports/QualityValidationImporter.php
Normal file
@@ -0,0 +1,331 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Str;
|
||||
|
||||
class QualityValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = QualityValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created DateTime')
|
||||
->example('12-02-2025 15:51:00')
|
||||
->label('Created DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('sticker_master_id_code') // stickerMaster.item
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('123456')
|
||||
->label('Item Code'),
|
||||
// ->relationship(
|
||||
// name: 'stickerMaster',
|
||||
// resolveUsing: function ($state) {
|
||||
// $state = trim($state);
|
||||
// $item = Item::where('code', $state)->first();
|
||||
// return $item
|
||||
// ? StickerMaster::where('item_id', $item->id)->value('id')
|
||||
// : null;
|
||||
// }
|
||||
// ),
|
||||
ImportColumn::make('production_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Production Order')
|
||||
->example('1234567')
|
||||
->label('Production Order')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number')
|
||||
->example('1234567890123')
|
||||
->label('Serial Number'),
|
||||
ImportColumn::make('serial_number_motor')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number Motor')
|
||||
->example('1')
|
||||
->label('Serial Number Motor'),
|
||||
ImportColumn::make('serial_number_pump')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number Pump')
|
||||
->example('1')
|
||||
->label('Serial Number Pump'),
|
||||
ImportColumn::make('serial_number_pumpset')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number PumpSet')
|
||||
->example('1')
|
||||
->label('Serial Number PumpSet'),
|
||||
ImportColumn::make('pack_slip_motor')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Pack Slip Motor')
|
||||
->example('1')
|
||||
->label('Pack Slip Motor'),
|
||||
ImportColumn::make('pack_slip_pump')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Pack Slip Pump')
|
||||
->example('1')
|
||||
->label('Pack Slip Pump'),
|
||||
ImportColumn::make('pack_slip_pumpset')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Pack Slip PumpSet')
|
||||
->example('1')
|
||||
->label('Pack Slip PumpSet'),
|
||||
ImportColumn::make('name_plate_motor')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Name Plate Motor')
|
||||
->example('1')
|
||||
->label('Name Plate Motor'),
|
||||
ImportColumn::make('name_plate_pump')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Name Plate Pump')
|
||||
->example('1')
|
||||
->label('Name Plate Pump'),
|
||||
ImportColumn::make('name_plate_pumpset')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Name Plate PumpSet')
|
||||
->example('1')
|
||||
->label('Name Plate PumpSet'),
|
||||
ImportColumn::make('tube_sticker_motor')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Motor')
|
||||
->example('1')
|
||||
->label('Tube Sticker Motor'),
|
||||
ImportColumn::make('tube_sticker_pump')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Pump')
|
||||
->example('1')
|
||||
->label('Tube Sticker Pump'),
|
||||
ImportColumn::make('tube_sticker_pumpset')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Tube Sticker PumpSet')
|
||||
->example('1')
|
||||
->label('Tube Sticker PumpSet'),
|
||||
ImportColumn::make('warranty_card')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Warranty Card')
|
||||
->example('1')
|
||||
->label('Warranty Card'),
|
||||
ImportColumn::make('part_validation1')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Part Validation 1')
|
||||
->example('12345')
|
||||
->label('Part Validation 1'),
|
||||
ImportColumn::make('part_validation2')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Part Validation 2')
|
||||
->example('54321')
|
||||
->label('Part Validation 2'),
|
||||
ImportColumn::make('part_validation3')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Part Validation 3')
|
||||
->example('12345')
|
||||
->label('Part Validation 3'),
|
||||
ImportColumn::make('part_validation4')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Part Validation 4')
|
||||
->example('')
|
||||
->label('Part Validation 4'),
|
||||
ImportColumn::make('part_validation5')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Part Validation 5')
|
||||
->example('')
|
||||
->label('Part Validation 5'),
|
||||
ImportColumn::make('uom')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Unit of Measure')
|
||||
->example('EA')
|
||||
->label('Unit of Measure'),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example('4 inch pump line')
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated DateTime')
|
||||
->example('12-02-2025 15:51:00')
|
||||
->label('Updated DateTime')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('operator_id')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Operator ID')
|
||||
->example(Filament::auth()->user()->name)
|
||||
->label('Operator ID')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?QualityValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
$line = null;
|
||||
$stickMaster = null;
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else {
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
$uniqueCode = trim($this->data['sticker_master_id_code']);// stickerMaster.item
|
||||
$stickMaster = StickerMaster::select('id')->with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCode, $plant) {
|
||||
$query->where('code', $uniqueCode)->where('plant_id', $plant->id);
|
||||
})->value('id');
|
||||
}
|
||||
|
||||
if (!$line) {
|
||||
$warnMsg[] = "Line not found";
|
||||
}
|
||||
|
||||
if (!$stickMaster) {
|
||||
$warnMsg[] = "Sticker item code not found";
|
||||
}
|
||||
|
||||
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7) {
|
||||
$warnMsg[] = "Invalid production order found";
|
||||
}
|
||||
|
||||
if (!ctype_alnum($this->data['serial_number']) || Str::length($this->data['serial_number']) < 9) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
// dd($stickMaster);
|
||||
|
||||
// if (Str::length($this->data['uom']) < 1) {
|
||||
// $warnMsg[] = "Invalid unit of measure found";
|
||||
// }
|
||||
|
||||
$user = User::where('name', $this->data['operator_id'])->first();
|
||||
if (!$user) {
|
||||
$warnMsg[] = "Operator ID not found";
|
||||
}
|
||||
$fromDate = $this->data['created_at'];
|
||||
$toDate = $this->data['updated_at'];
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
$fdateTime = null;
|
||||
$tdateTime = null;
|
||||
// Try parsing with multiple formats
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
// $fDateOnly = '';
|
||||
if (!isset($fdateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
// else {
|
||||
// $fDateOnly = $fdateTime->toDateString();
|
||||
// }
|
||||
if (!isset($tdateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
if (isset($fdateTime) && isset($tdateTime)) {
|
||||
if ($fdateTime->greaterThan($tdateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
// if (!$fromDate) {
|
||||
// $warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
// else if (!$toDate) {
|
||||
// $warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
QualityValidation::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'sticker_master_id' => $stickMaster,//->id
|
||||
'uom' => $this->data['uom'],
|
||||
'production_order' => $this->data['production_order'],
|
||||
'serial_number' => $this->data['serial_number'],
|
||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||
'serial_number_pump' => $this->data['serial_number_pump'],
|
||||
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
|
||||
'pack_slip_motor' => $this->data['pack_slip_motor'],
|
||||
'pack_slip_pump' => $this->data['pack_slip_pump'],
|
||||
'pack_slip_pumpset' => $this->data['pack_slip_pumpset'],
|
||||
'name_plate_motor' => $this->data['name_plate_motor'],
|
||||
'name_plate_pump' => $this->data['name_plate_pump'],
|
||||
'name_plate_pumpset' => $this->data['name_plate_pumpset'],
|
||||
'tube_sticker_motor' => $this->data['tube_sticker_motor'],
|
||||
'tube_sticker_pump' => $this->data['tube_sticker_pump'],
|
||||
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'],
|
||||
'warranty_card' => $this->data['warranty_card'],
|
||||
'part_validation1' => $this->data['part_validation1'],
|
||||
'part_validation2' => $this->data['part_validation2'],
|
||||
'part_validation3' => $this->data['part_validation3'],
|
||||
'part_validation4' => $this->data['part_validation4'],
|
||||
'part_validation5' => $this->data['part_validation5'],
|
||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'),//$this->data['created_at'],
|
||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),//$this->data['updated_at'],
|
||||
'operator_id' => $this->data['operator_id'],
|
||||
]);
|
||||
|
||||
return null;
|
||||
// return QualityValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
// return new QualityValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your quality validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
308
app/Filament/Imports/ReworkLocatorInvoiceValidationImporter.php
Normal file
308
app/Filament/Imports/ReworkLocatorInvoiceValidationImporter.php
Normal file
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Plant;
|
||||
use App\Models\ReworkLocatorInvoiceValidation;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class ReworkLocatorInvoiceValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ReworkLocatorInvoiceValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Code')
|
||||
->example('1000')
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('invoice_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Invoice Number')
|
||||
->example('3RA002514')
|
||||
->label('Invoice Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Serial Number')
|
||||
->example('25145441154545')
|
||||
->label('Serial Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('pallet_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Pallet Number')
|
||||
->example('')
|
||||
->label('Pallet Number'),
|
||||
ImportColumn::make('locator_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Locator Number')
|
||||
->example('')
|
||||
->label('Locator Number'),
|
||||
ImportColumn::make('scanned_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned Status')
|
||||
->example('')
|
||||
->label('Scanned Status')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('upload_status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Upload Status')
|
||||
->example('Y')
|
||||
->label('Upload Status')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Created At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Scanned At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Updated At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('reworked_at')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Reworked At')
|
||||
->example('2025-06-17 08:42:16')
|
||||
->label('Reworked At')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('created_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Created By')
|
||||
->example('admin')
|
||||
->label('Created By')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned By')
|
||||
->example('admin')
|
||||
->label('Scanned By')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Updated By')
|
||||
->example('admin')
|
||||
->label('Updated By'),
|
||||
ImportColumn::make('reworked_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Reworked By')
|
||||
->example('admin')
|
||||
->label('Reworked By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?ReworkLocatorInvoiceValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$invoiceNo = $this->data['invoice_number'];
|
||||
$serialNo = $this->data['serial_number'];
|
||||
$palletNo = $this->data['pallet_number'];
|
||||
$locatorNo = $this->data['locator_number'];
|
||||
$scannedStat = $this->data['scanned_status'];
|
||||
$uploadStat = $this->data['upload_status'];
|
||||
$createdAt = $this->data['created_at'];
|
||||
$scannedAt = $this->data['scanned_at'];
|
||||
$updatedAt = $this->data['updated_at'];
|
||||
$reworkedAt = $this->data['reworked_at'];
|
||||
$cDateTime = null;
|
||||
$sDateTime = null;
|
||||
$uDateTime = null;
|
||||
$rDateTime = null;
|
||||
$createdBy = $this->data['created_by'];
|
||||
$scannedBy = $this->data['scanned_by'];
|
||||
$updatedBy = $this->data['updated_by'];
|
||||
$reworkedBy = $this->data['reworked_by'];
|
||||
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
|
||||
$warnMsg[] = "Invalid invoice number found";
|
||||
}
|
||||
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
|
||||
$warnMsg[] = "Invalid serial number found";
|
||||
}
|
||||
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
|
||||
$warnMsg[] = "Invalid pallet number found";
|
||||
}
|
||||
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
if ($scannedStat != 'Scanned') {
|
||||
$warnMsg[] = "Invalid scanned status found";
|
||||
}
|
||||
if ($uploadStat != 'Y' && $uploadStat != 'N') {
|
||||
$warnMsg[] = "Invalid upload status found";
|
||||
}
|
||||
$created = User::where('name', $createdBy)->first();
|
||||
if (!$created) {
|
||||
$warnMsg[] = "Created by not found";
|
||||
}
|
||||
$scanned = User::where('name', $scannedBy)->first();
|
||||
if (!$scanned) {
|
||||
$warnMsg[] = "Scanned by not found";
|
||||
}
|
||||
if (Str::length($updatedBy) > 0) {
|
||||
$updated = User::where('name', $updatedBy)->first();
|
||||
if (!$updated) {
|
||||
$warnMsg[] = "Updated by not found";
|
||||
}
|
||||
}
|
||||
$reworked = User::where('name', $reworkedBy)->first();
|
||||
if (!$reworked) {
|
||||
$warnMsg[] = "Reworked by not found";
|
||||
}
|
||||
|
||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$cDateTime = Carbon::createFromFormat($format, $createdAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cDateTime)) {
|
||||
// throw new \Exception('Invalid date time format');
|
||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($sDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($uDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($uDateTime)) {
|
||||
if ($cDateTime->greaterThan($uDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($formats as $format) {
|
||||
try {
|
||||
$rDateTime = Carbon::createFromFormat($format, $reworkedAt);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// Optionally collect warning messages
|
||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($rDateTime)) {
|
||||
$warnMsg[] = "Invalid 'Reworked DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($cDateTime) && isset($rDateTime)) {
|
||||
if ($cDateTime->greaterThan($rDateTime)) {
|
||||
$warnMsg[] = "'Created DataTime' is greater than 'Reworked DateTime'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
// }
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
ReworkLocatorInvoiceValidation::updateOrCreate(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'serial_number' => $serialNo,
|
||||
'invoice_number' => $invoiceNo,
|
||||
'pallet_number' => $palletNo,
|
||||
'locator_number' => $locatorNo,
|
||||
'scanned_status' => $scannedStat,
|
||||
'upload_status' => $uploadStat,
|
||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||
'scanned_at' => $sDateTime->format('Y-m-d H:i:s'),
|
||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||
'reworked_at' => $rDateTime->format('Y-m-d H:i:s'),
|
||||
'created_by' => $createdBy,
|
||||
'scanned_by' => $scannedBy,
|
||||
'updated_by' => $updatedBy,
|
||||
'reworked_by' => $reworkedBy
|
||||
]
|
||||
);
|
||||
return null;
|
||||
// // return ReworkLocatorInvoiceValidation::firstOrNew([
|
||||
// // // Update existing records, matching them by `$this->data['column_name']`
|
||||
// // 'email' => $this->data['email'],
|
||||
// // ]);
|
||||
|
||||
// return new ReworkLocatorInvoiceValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your rework locator invoice validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Block;
|
||||
use App\Models\Plant;
|
||||
use App\Models\Shift;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class ShiftImporter extends Importer
|
||||
{
|
||||
@@ -17,39 +21,46 @@ class ShiftImporter extends Importer
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Shift Name')
|
||||
->example('Day')
|
||||
->label('Shift Name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Block Name')
|
||||
->label('Block Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('start_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Start Time')
|
||||
->example('08:00:00')
|
||||
->label('Start Time')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('duration')
|
||||
->requiredMapping()
|
||||
->numeric()
|
||||
->exampleHeader('Shift Duration')
|
||||
->example('11.30')
|
||||
->label('Shift Duration')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('end_time')
|
||||
->requiredMapping()
|
||||
->exampleHeader('End Time')
|
||||
->example('19:30:00')
|
||||
->label('End Time')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('block')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Block Name')
|
||||
->example('Block A')
|
||||
->label('Block Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing:'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('status')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Active Status')
|
||||
->example('Active')
|
||||
->label('Active Status')
|
||||
->rules(['required']),
|
||||
];
|
||||
@@ -57,12 +68,64 @@ class ShiftImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Shift
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
$block = Block::where('name', $this->data['block'])->where('plant_id', $plant->id)->first();
|
||||
if (!$block) {
|
||||
$warnMsg[] = "Block not found";
|
||||
}
|
||||
if (Str::length($this->data['duration']) < 0 || !is_numeric($this->data['duration'])) {
|
||||
$warnMsg[] = "Invalid duration found";
|
||||
}
|
||||
if (Str::length($this->data['start_time']) < 0) {
|
||||
$warnMsg[] = "Invalid start time found";
|
||||
}
|
||||
if (Str::length($this->data['end_time']) < 0) {
|
||||
$warnMsg[] = "Invalid end time found";
|
||||
}
|
||||
if (Str::length($this->data['status']) < 0 || $this->data['status'] != 'Active') {
|
||||
$warnMsg[] = "Invalid shift status found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$shift = Shift::where('name', $this->data['name'])
|
||||
->where('plant_id', $plant->id)
|
||||
->where('block_id', $block->id)
|
||||
->first();
|
||||
|
||||
if ($shift) {
|
||||
// Update only if necessary to avoid duplicate key error
|
||||
$shift->update([
|
||||
'start_time' => $this->data['start_time'],
|
||||
'duration' => $this->data['duration'],
|
||||
'end_time' => $this->data['end_time'],
|
||||
'status' => $this->data['status']
|
||||
]);
|
||||
return $shift;
|
||||
} else {
|
||||
// Safe to create new
|
||||
return Shift::create([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id,
|
||||
'block_id' => $block->id,
|
||||
'start_time' => $this->data['start_time'],
|
||||
'duration' => $this->data['duration'],
|
||||
'end_time' => $this->data['end_time'],
|
||||
'status' => $this->data['status']
|
||||
]);
|
||||
}
|
||||
// return Shift::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Shift();
|
||||
// return new Shift();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class StickerMasterImporter extends Importer
|
||||
{
|
||||
@@ -16,137 +20,256 @@ class StickerMasterImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->label('Item Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Item Code')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->label('Plant Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
|
||||
ImportColumn::make('serial_number_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Serial Number Motor'),
|
||||
|
||||
->exampleHeader('Serial Number Motor')
|
||||
->label('SERIAL NUMBER MOTOR')
|
||||
->example('1'),
|
||||
ImportColumn::make('serial_number_pump')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Serial Number Pump'),
|
||||
|
||||
->exampleHeader('Serial Number Pump')
|
||||
->label('SERIAL NUMBER PUMP')
|
||||
->example('1'),
|
||||
ImportColumn::make('serial_number_pumpset')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Serial Number PumpSet'),
|
||||
|
||||
->exampleHeader('Serial Number PumpSet')
|
||||
->label('SERIAL NUMBER PUMPSET')
|
||||
->example(''),
|
||||
ImportColumn::make('pack_slip_motor')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip Motor'),
|
||||
|
||||
->exampleHeader('Pack Slip Motor')
|
||||
->label('PACK SLIP MOTOR')
|
||||
->example('1'),
|
||||
ImportColumn::make('pack_slip_pump')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip Pump'),
|
||||
|
||||
->exampleHeader('Pack Slip Pump')
|
||||
->label('PACK SLIP PUMP')
|
||||
->example('1'),
|
||||
ImportColumn::make('pack_slip_pumpset')
|
||||
//->requiredMapping()
|
||||
->exampleHeader('Pack Slip PumpSet'),
|
||||
|
||||
->exampleHeader('Pack Slip PumpSet')
|
||||
->label('PACK SLIP PUMPSET')
|
||||
->example(''),
|
||||
ImportColumn::make('name_plate_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate Motor'),
|
||||
|
||||
->exampleHeader('Name Plate Motor')
|
||||
->label('NAME PLATE MOTOR')
|
||||
->example('1'),
|
||||
ImportColumn::make('name_plate_pump')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate Pump'),
|
||||
|
||||
->exampleHeader('Name Plate Pump')
|
||||
->label('NAME PLATE PUMP')
|
||||
->example('1'),
|
||||
ImportColumn::make('name_plate_pumpset')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Name Plate PumpSet'),
|
||||
|
||||
->exampleHeader('Name Plate PumpSet')
|
||||
->label('NAME PLATE PUMPSET')
|
||||
->example(''),
|
||||
ImportColumn::make('tube_sticker_motor')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Motor'),
|
||||
|
||||
->exampleHeader('Tube Sticker Motor')
|
||||
->label('TUBE STICKER MOTOR')
|
||||
->example('1'),
|
||||
ImportColumn::make('tube_sticker_pump')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker Pump'),
|
||||
|
||||
->exampleHeader('Tube Sticker Pump')
|
||||
->label('TUBE STICKER PUMP')
|
||||
->example('1'),
|
||||
ImportColumn::make('tube_sticker_pumpset')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Tube Sticker PumpSet'),
|
||||
|
||||
->exampleHeader('Tube Sticker PumpSet')
|
||||
->label('TUBE STICKER PUMPSET')
|
||||
->example(''),
|
||||
ImportColumn::make('warranty_card')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Warranty Card'),
|
||||
|
||||
->exampleHeader('Warranty Card')
|
||||
->label('WARRANTY CARD')
|
||||
->example('1'),
|
||||
ImportColumn::make('part_validation1')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 1')
|
||||
->exampleHeader('Part Validation 1'),
|
||||
|
||||
|
||||
->exampleHeader('Part Validation 1')
|
||||
->label('PART VALIDATION 1')
|
||||
->example('12345'),
|
||||
ImportColumn::make('part_validation2')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 2')
|
||||
->exampleHeader('Part Validation 2'),
|
||||
|
||||
|
||||
->exampleHeader('Part Validation 2')
|
||||
->label('PART VALIDATION 2')
|
||||
->example('23456'),
|
||||
ImportColumn::make('part_validation3')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 3')
|
||||
->exampleHeader('Part Validation 3'),
|
||||
|
||||
|
||||
->exampleHeader('Part Validation 3')
|
||||
->label('PART VALIDATION 3')
|
||||
->example('34567'),
|
||||
ImportColumn::make('part_validation4')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 4')
|
||||
->exampleHeader('Part Validation 4'),
|
||||
|
||||
|
||||
->exampleHeader('Part Validation 4')
|
||||
->label('PART VALIDATION 4')
|
||||
->example('45678'),
|
||||
ImportColumn::make('part_validation5')
|
||||
// ->requiredMapping()
|
||||
->label('Part Validation 5')
|
||||
->exampleHeader('Part Validation 5'),
|
||||
|
||||
|
||||
ImportColumn::make('panel_box_code')
|
||||
//->requiredMapping()
|
||||
->label('Panel Box Code')
|
||||
->exampleHeader('Panel Box Code'),
|
||||
|
||||
|
||||
ImportColumn::make('load_rate')
|
||||
// ->requiredMapping()
|
||||
->label('Load Rate')
|
||||
->integer()
|
||||
->exampleHeader('Load Rate'),
|
||||
|
||||
|
||||
ImportColumn::make('bundle_quantity')
|
||||
// ->requiredMapping()
|
||||
->label('Bundle Quantity')
|
||||
->integer()
|
||||
->exampleHeader('Bundle Quantity'),
|
||||
|
||||
|
||||
ImportColumn::make('material_type')
|
||||
->exampleHeader('Part Validation 5')
|
||||
->label('PART VALIDATION 5')
|
||||
->example('56789'),
|
||||
ImportColumn::make('laser_part_validation1')
|
||||
// ->requiredMapping()
|
||||
->label('Material Type')
|
||||
->exampleHeader('Laser Part Validation 1')
|
||||
->label('LASER PART VALIDATION 1')
|
||||
->example('67890'),
|
||||
ImportColumn::make('laser_part_validation2')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Laser Part Validation 2')
|
||||
->label('LASER PART VALIDATION 2')
|
||||
->example('78901'),
|
||||
ImportColumn::make('panel_box_code')
|
||||
// ->requiredMapping()
|
||||
->exampleHeader('Panel Box Code')
|
||||
->label('PANEL BOX CODE')
|
||||
->example('123456'),
|
||||
ImportColumn::make('load_rate')
|
||||
->requiredMapping()
|
||||
->integer()
|
||||
->exampleHeader('Material Type'),
|
||||
|
||||
->exampleHeader('Load Rate')
|
||||
->label('LOAD RATE')
|
||||
->example('0')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('material_type')
|
||||
// ->requiredMapping()
|
||||
->integer()
|
||||
->exampleHeader('Material Type')
|
||||
->label('MATERIAL TYPE')
|
||||
->example(''),
|
||||
ImportColumn::make('bundle_quantity')
|
||||
// ->requiredMapping()
|
||||
->integer()
|
||||
->exampleHeader('Bundle Quantity')
|
||||
->label('BUNDLE QUANTITY')
|
||||
->example(''),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('PLANT NAME')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?StickerMaster
|
||||
{
|
||||
$warnMsg = [];
|
||||
$item = null;
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
if (!$item) {
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
||||
$warnMsg[] = "Serial number motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = "Serial number pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
|
||||
$warnMsg[] = "Serial number pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = "Pack slip motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
|
||||
$warnMsg[] = "Pack slip pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = "Pack slip pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
|
||||
$warnMsg[] = "Name plate motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = "Name plate pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
|
||||
$warnMsg[] = "Name plate pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = "Tube sticker motor must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
|
||||
$warnMsg[] = "Tube sticker pump must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = "Tube sticker pumpset must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
|
||||
$warnMsg[] = "Warranty card must be 1 or empty";
|
||||
}
|
||||
if (Str::length($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || !ctype_alnum($this->data['panel_box_code']))) {
|
||||
$warnMsg[] = "Invalid panel box code found";
|
||||
}
|
||||
if (Str::length($this->data['load_rate']) < 0 || !is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
|
||||
$warnMsg[] = "Load rate must be greater than or equal to 0";
|
||||
}
|
||||
if (Str::length($this->data['bundle_quantity']) > 0 && (!is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
|
||||
}
|
||||
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { //($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = "Material type must be 1 or 2 or 3 or empty";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
StickerMaster::updateOrCreate([
|
||||
'item_id' => $item->id,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||
'serial_number_pump' => $this->data['serial_number_pump'],
|
||||
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
|
||||
'pack_slip_motor' => $this->data['pack_slip_motor'],
|
||||
'pack_slip_pump' => $this->data['pack_slip_pump'],
|
||||
'pack_slip_pumpset' => $this->data['pack_slip_pumpset'],
|
||||
'name_plate_motor' => $this->data['name_plate_motor'],
|
||||
'name_plate_pump' => $this->data['name_plate_pump'],
|
||||
'name_plate_pumpset' => $this->data['name_plate_pumpset'],
|
||||
'tube_sticker_motor' => $this->data['tube_sticker_motor'],
|
||||
'tube_sticker_pump' => $this->data['tube_sticker_pump'],
|
||||
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'],
|
||||
'warranty_card' => $this->data['warranty_card'],
|
||||
'part_validation1' => $this->data['part_validation1'],
|
||||
'part_validation2' => $this->data['part_validation2'],
|
||||
'part_validation3' => $this->data['part_validation3'],
|
||||
'part_validation4' => $this->data['part_validation4'],
|
||||
'part_validation5' => $this->data['part_validation5'],
|
||||
'laser_part_validation1' => $this->data['laser_part_validation1'],
|
||||
'laser_part_validation2' => $this->data['laser_part_validation2'],
|
||||
'panel_box_code' => $this->data['panel_box_code'],
|
||||
'load_rate' => $this->data['load_rate'],
|
||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||
'material_type' => $this->data['material_type']
|
||||
]);
|
||||
return null;
|
||||
// return StickerMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new StickerMaster();
|
||||
// return new StickerMaster();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
114
app/Filament/Imports/TestingPanelReadingImporter.php
Normal file
114
app/Filament/Imports/TestingPanelReadingImporter.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\TestingPanelReading;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
|
||||
class TestingPanelReadingImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = TestingPanelReading::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('machine')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('output')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('serial_number')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('before_fr_volt'),
|
||||
ImportColumn::make('before_fr_cur'),
|
||||
ImportColumn::make('before_fr_pow'),
|
||||
ImportColumn::make('before_fr_res_ry'),
|
||||
ImportColumn::make('before_fr_res_yb'),
|
||||
ImportColumn::make('before_fr_res_br'),
|
||||
ImportColumn::make('before_fr_ir'),
|
||||
ImportColumn::make('before_fr_ir_r'),
|
||||
ImportColumn::make('before_fr_ir_y'),
|
||||
ImportColumn::make('before_fr_ir_b'),
|
||||
ImportColumn::make('before_fr_freq'),
|
||||
ImportColumn::make('before_fr_speed'),
|
||||
ImportColumn::make('after_fr_vol'),
|
||||
ImportColumn::make('after_fr_cur'),
|
||||
ImportColumn::make('after_fr_pow'),
|
||||
ImportColumn::make('after_fr_ir_hot'),
|
||||
ImportColumn::make('after_fr_ir_hot_r'),
|
||||
ImportColumn::make('after_fr_ir_hot_y'),
|
||||
ImportColumn::make('after_fr_ir_hot_b'),
|
||||
ImportColumn::make('after_fr_ir_cool'),
|
||||
ImportColumn::make('after_fr_ir_cool_r'),
|
||||
ImportColumn::make('after_fr_ir_cool_y'),
|
||||
ImportColumn::make('after_fr_ir_cool_b'),
|
||||
ImportColumn::make('after_fr_freq'),
|
||||
ImportColumn::make('after_fr_speed'),
|
||||
ImportColumn::make('after_fr_leak_cur'),
|
||||
ImportColumn::make('locked_rt_volt'),
|
||||
ImportColumn::make('locked_rt_cur'),
|
||||
ImportColumn::make('locked_rt_pow'),
|
||||
ImportColumn::make('no_load_pickup_volt'),
|
||||
ImportColumn::make('room_temperature'),
|
||||
ImportColumn::make('hv_test'),
|
||||
ImportColumn::make('batch_number'),
|
||||
ImportColumn::make('batch_count')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('result'),
|
||||
ImportColumn::make('remark'),
|
||||
ImportColumn::make('rework_count')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('update_count')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('output_flag')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship()
|
||||
->rules(['required']),
|
||||
ImportColumn::make('tested_by'),
|
||||
ImportColumn::make('updated_by'),
|
||||
ImportColumn::make('scanned_at')
|
||||
->requiredMapping()
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?TestingPanelReading
|
||||
{
|
||||
// return TestingPanelReading::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new TestingPanelReading();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your testing panel reading import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
191
app/Filament/Imports/WeightValidationImporter.php
Normal file
191
app/Filament/Imports/WeightValidationImporter.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WeightValidation;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class WeightValidationImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = WeightValidation::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
->example('123456')
|
||||
->label('ITEM CODE')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('obd_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('OBD Number')
|
||||
->example('3RA00352')
|
||||
->label('OBD Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Number')
|
||||
->example('1')
|
||||
->label('Line Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('batch_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Batch Number')
|
||||
->example('2021217')
|
||||
->label('Batch Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('heat_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Heat Number')
|
||||
->example('RSL-D1390')
|
||||
->label('Heat Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('obd_weight')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Actual Weight')
|
||||
->example('3540.00')
|
||||
->label('Actual Weight')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('vehicle_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Vehicle Number')
|
||||
->example('TN54AB1234')
|
||||
->label('Vehicle Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('bundle_number')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Bundle Number')
|
||||
->example('1')
|
||||
->label('Bundle Number')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('picked_weight')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Picked Weight')
|
||||
->example('1')
|
||||
->label('Picked Weight')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('PLANT NAME')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('scanned_by')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Scanned By')
|
||||
->example('User-1')
|
||||
->label('Scanned By')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): ?WeightValidation
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
$item = null;
|
||||
if ($plant) {
|
||||
if (Str::length($this->data['item']) < 6 || !ctype_alnum($this->data['item'])) {
|
||||
$warnMsg[] = "Invalid item code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
if (!$item) {
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
}
|
||||
}
|
||||
else { //if (!$item)
|
||||
$warnMsg[] = "Item code not found";
|
||||
}
|
||||
|
||||
$obdNum = $this->data['obd_number'];
|
||||
if (Str::length($obdNum) < 8 || !ctype_alnum($obdNum)) {
|
||||
$warnMsg[] = "Invalid OBD number found";
|
||||
}
|
||||
$lineNum = $this->data['line_number'];
|
||||
if (Str::length($lineNum) < 1 || !is_numeric($lineNum)) {
|
||||
$warnMsg[] = "Invalid line number found";
|
||||
}
|
||||
$batchNum = $this->data['batch_number'];
|
||||
if (Str::length($batchNum) < 8 || !is_numeric($batchNum)) {
|
||||
$warnMsg[] = "Invalid batch number found";
|
||||
}
|
||||
$heatNum = $this->data['heat_number'];
|
||||
if (Str::length($heatNum) < 4) {
|
||||
$warnMsg[] = "Invalid heat number found";
|
||||
}
|
||||
$actWeight = $this->data['obd_weight'];
|
||||
if (Str::length($actWeight) < 1 || !is_numeric($actWeight)) {
|
||||
$warnMsg[] = "Invalid actual weight found";
|
||||
}
|
||||
$vehicleNum = $this->data['vehicle_number'];
|
||||
if (Str::length($vehicleNum) < 10 || !ctype_alnum($vehicleNum)) {
|
||||
$warnMsg[] = "Invalid vehicle number found";
|
||||
}
|
||||
$bundleNum = $this->data['bundle_number'];
|
||||
if (Str::length($bundleNum) < 1 || !is_numeric($bundleNum)) {
|
||||
$warnMsg[] = "Invalid bundle number found";
|
||||
}
|
||||
$pickWeight = $this->data['picked_weight'];
|
||||
if (Str::length($pickWeight) < 1 || !is_numeric($pickWeight)) {
|
||||
$warnMsg[] = "Invalid picked weight found";
|
||||
}
|
||||
$scanBy = $this->data['scanned_by'];
|
||||
if (Str::length($scanBy) < 3 || !ctype_alnum($scanBy)) {
|
||||
$warnMsg[] = "Invalid scanned by name found";
|
||||
}
|
||||
|
||||
if (!empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
return WeightValidation::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'obd_number' => $obdNum,
|
||||
'line_number' => $lineNum
|
||||
],
|
||||
[
|
||||
'item_id' => $item->id,
|
||||
'batch_number' => $batchNum,
|
||||
'heat_number' => $heatNum,
|
||||
'obd_weight' => $actWeight,
|
||||
'vehicle_number' => $vehicleNum,
|
||||
'bundle_number' => $bundleNum,
|
||||
'picked_weight' => $pickWeight,
|
||||
'scanned_by' => $scanBy
|
||||
]
|
||||
);
|
||||
// return WeightValidation::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
// return new WeightValidation();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your weight validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\CumulativeChart;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
@@ -8,43 +9,63 @@ use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Plant;
|
||||
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class Dashboard extends \Filament\Pages\Dashboard
|
||||
{
|
||||
use HasFiltersForm;
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
$selectedPlant = session('selected_plant', request()->input('filters.Plant'));
|
||||
return $form->schema([
|
||||
// Plant Filter
|
||||
Select::make('Plant')
|
||||
->options(Plant::pluck('name', 'id')) // Fetch plant names with their IDs
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) use ($selectedPlant) {
|
||||
// Update only in memory and not in the URL
|
||||
session(['selected_plant' => $state]); // Store in session
|
||||
session()->forget('selected_line'); // Reset line filter
|
||||
$set('Plant', $state);
|
||||
$set('Line', null);
|
||||
$this->dispatch('filtersUpdated'); // Notify chart to refresh
|
||||
}),
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
// Line Filter
|
||||
Select::make('Line')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('Plant');
|
||||
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Line')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_line' => $state]); // Store in session
|
||||
$this->dispatch('filtersUpdated'); // Notify chart to refresh
|
||||
}),
|
||||
]);
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => 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 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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
358
app/Filament/Pages/DataSendToSap.php
Normal file
358
app/Filament/Pages/DataSendToSap.php
Normal file
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class DataSendToSap extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
public $pId , $pOrder, $pUom, $pItem, $transHeadLog, $sNums = [];
|
||||
|
||||
public $scanned_quantity;
|
||||
|
||||
public array $data = []; //Required to back form state
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
protected static string $view = 'filament.pages.data-send-to-sap';
|
||||
|
||||
protected static ?string $navigationGroup = 'Send To SAP';
|
||||
|
||||
protected $listeners = ['updateScannedQuantity' => 'setScannedQuantity'];
|
||||
|
||||
|
||||
|
||||
public function setScannedQuantity($quantity)
|
||||
{
|
||||
// Set the scanned_quantity value in the Filament page/form
|
||||
$this->scanned_quantity = $quantity;
|
||||
$this->form->fill([
|
||||
'scanned_quantity' => $quantity,
|
||||
'production_order' => $this->pOrder,
|
||||
'plant_id' => $this->pId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('data')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pId = $plantId;
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$productionOrder = $get('production_order');
|
||||
|
||||
if (!$productionOrder) {
|
||||
$set('pqproducError', 'Please provide production order.');
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pOrder = null;
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqproducError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqproducError') ? $get('pqproducError') : null)
|
||||
->hintColor('danger')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processValues($event.target.value)',
|
||||
]),
|
||||
|
||||
TextInput::make('scanned_quantity')
|
||||
->reactive() // Make it reactive to update when changed
|
||||
->afterStateUpdated(function ($state, $set, $get) {
|
||||
$this->scanned_quantity = $state;
|
||||
})
|
||||
->readOnly(),
|
||||
|
||||
// Add your custom action button here
|
||||
Actions::make([
|
||||
Action::make('send_to_sap')
|
||||
->label('Send Data to SAP')
|
||||
->action(function ($set, $get) {
|
||||
$year = date('y'); // '25' for 2025
|
||||
$month = date('m'); // '05' for May
|
||||
$plantId = $get('plant_id');
|
||||
$code = Plant::where('id', $plantId)->value('code');
|
||||
$finalBatch = $year . $month . $code;
|
||||
$transHeadLogId = $this->transHeadLog; //'3256';
|
||||
$lineItemCnt = '1'; //1 hard code
|
||||
$sapOrder = $get('production_order');
|
||||
$itemCode = $this->pItem;
|
||||
$quantity = (string)$get('scanned_quantity');
|
||||
$UOM = $this->pUom;
|
||||
$batchNumber = $finalBatch;
|
||||
$locationName = '';
|
||||
$lamiCdate = $get('lami_cdate');
|
||||
$serialNumbers = $this->sNums;
|
||||
|
||||
// dd($batchNumber);
|
||||
|
||||
$currentDateTime = date('j/n/Y h:i:s A');
|
||||
|
||||
$header = [
|
||||
'Trans_Head_Log_Id' => $transHeadLogId, //'3256',
|
||||
'Line_Item_Count' => $lineItemCnt, //'1',
|
||||
'SAP_Order_Number' => $sapOrder, //'12345678'
|
||||
'Item_Code' => $itemCode, //'6458795'
|
||||
];
|
||||
// $serialNumbers = ['12024090000142', '12024090000142', '12024090000142'];
|
||||
$Receipt = [
|
||||
// 'Receipt' => [
|
||||
[
|
||||
'Quantity' => $quantity, //'1',
|
||||
'UOM' => $UOM,
|
||||
'Batch_Number' => $batchNumber,
|
||||
'Location_Name' => $locationName,
|
||||
'LAMI_Cdate' => $currentDateTime, //'9/9/2024 10:48:37 AM',
|
||||
'Serial_Number' => array_map(function ($serial) {
|
||||
return ['Serial_Number' => $serial];
|
||||
}, $serialNumbers)
|
||||
]
|
||||
// ]
|
||||
];
|
||||
|
||||
|
||||
$payload = [
|
||||
// ...$header,
|
||||
'Receipt' => $Receipt
|
||||
];
|
||||
// dd($payload);
|
||||
|
||||
// $header = [
|
||||
// 'Trans_Head_Log_Id' => '3256',
|
||||
// 'Line_Item_Count' => '1',
|
||||
// 'SAP_Order_Number' => '12345678',
|
||||
// 'Item_Code' => '6458795'
|
||||
// ];
|
||||
// $serialNumbers = ['12024090000142'];
|
||||
// $Receipt = [
|
||||
// // 'Receipt' => [
|
||||
// [
|
||||
// 'Quantity' => '1',
|
||||
// 'UOM' => 'EA',
|
||||
// 'Batch_Number' => '',
|
||||
// 'Location_Name' => '',
|
||||
// 'LAMI_Cdate' => '9/9/2024 10:48:37 AM',
|
||||
// 'Serial_Number' => array_map(function ($serial) {
|
||||
// return ['Serial_Number' => $serial];
|
||||
// }, $serialNumbers)
|
||||
// ]
|
||||
// // ]
|
||||
// ];
|
||||
|
||||
|
||||
// $payload = [
|
||||
// // ...$header,
|
||||
// 'Receipt' => $Receipt
|
||||
// ];
|
||||
// dd($payload);
|
||||
try {
|
||||
// $response = Http::withHeaders([
|
||||
// 'Content-Type' => 'application/json',
|
||||
// 'Trans_Head_Log_Id' => '3256',//$transHeadLogId,
|
||||
// 'Line_Item_Count' => '1', // $lineItemCnt,
|
||||
// 'SAP_Order_Number' => '12345678', //$sapOrder,
|
||||
// 'Item_Code' => '6458795', //$itemCode,
|
||||
// ])
|
||||
$response = Http::withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Trans_Head_Log_Id' => $transHeadLogId,
|
||||
'Line_Item_Count' => $lineItemCnt,
|
||||
'SAP_Order_Number' => $sapOrder,
|
||||
'Item_Code' => $itemCode,
|
||||
])
|
||||
|
||||
->withBasicAuth(
|
||||
env('SAP_API_USERNAME'),
|
||||
env('SAP_API_PASSWORD')
|
||||
)
|
||||
->withBody(json_encode($payload), 'application/json')
|
||||
->post(env('SAP_API_URL'), $payload);
|
||||
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
|
||||
if ($messageCode && str_starts_with($messageCode, 'ERROR')) {
|
||||
|
||||
$cleanError = str_replace('ERROR:|', '', $messageCode);
|
||||
|
||||
// Update rows where plant_id and production_order match
|
||||
QualityValidation::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'ERROR',
|
||||
'sap_msg_description' => $cleanError,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Error')
|
||||
->body($cleanError)
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
$sapSuccessMsg = str_replace('SUCCESS:|', '', $messageCode);
|
||||
|
||||
QualityValidation::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'SUCCESS',
|
||||
'sap_msg_description' => $sapSuccessMsg,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Success')
|
||||
->body($sapSuccessMsg)
|
||||
->success()
|
||||
->send();
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Exception')
|
||||
->body('Error sending data to SAP: ' . $e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
})
|
||||
->color('success')
|
||||
->outlined()
|
||||
->hidden(fn (callable $get) => (!$get('scanned_quantity'))) //!$get('plant_id') && !$get('production_order') &&
|
||||
->extraAttributes(['class' => 'align-to-input']),
|
||||
]),
|
||||
])
|
||||
->columns(4);
|
||||
}
|
||||
|
||||
public function processValues($value)
|
||||
{
|
||||
|
||||
$this->pOrder = $value;
|
||||
|
||||
$plantId = trim($this->form->getState()['plant_id']) ?? null;
|
||||
//$this->plantId = $plantId;
|
||||
|
||||
|
||||
// $this->pUom = QualityValidation::where('plant_id',$this->pId)
|
||||
// ->where('production_order',$this->pOrder)
|
||||
// ->latest()
|
||||
// ->first()
|
||||
// ->value('uom');
|
||||
|
||||
// $this->transHeadLog = QualityValidation::where('plant_id',$this->pId)
|
||||
// ->where('production_order',$this->pOrder)
|
||||
// ->latest()
|
||||
// ->value('id');
|
||||
|
||||
$latestValidation = QualityValidation::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$latestValidation) {
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body('No data found for the selected plant and production order.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
$this->pOrder = null;
|
||||
$this->form->fill([
|
||||
'plant_id' => $this->pId,
|
||||
'production_order' => null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->pUom = $latestValidation->uom;
|
||||
$this->transHeadLog = $latestValidation->id;
|
||||
|
||||
$this->sNums = [];
|
||||
|
||||
if(!$this->pUom)
|
||||
{
|
||||
Notification::make()
|
||||
->title('UOM Not Found')
|
||||
->body('UOM not found for the production order')
|
||||
->icon('heroicon-o-x-circle') // optional, to force red/error-style icon
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->pItem = Item::where('id', StickerMaster::where('id', QualityValidation::where('plant_id',$this->pId)->where('production_order',$this->pOrder)->latest()->first()->sticker_master_id)->value('item_id'))->value('code');
|
||||
|
||||
$this->sNums = QualityValidation::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->pluck('serial_number')
|
||||
->toArray();
|
||||
|
||||
//dd($this-> pItem);
|
||||
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
}
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view quality data send to sap');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Quality Data';
|
||||
}
|
||||
}
|
||||
71
app/Filament/Pages/GuardPatrolDayCount.php
Normal file
71
app/Filament/Pages/GuardPatrolDayCount.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\GuardPatrolDayChart;
|
||||
use App\Models\Plant;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class GuardPatrolDayCount extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.guard-patrol-day-count';
|
||||
|
||||
protected static ?string $navigationGroup = 'Guard DashBoard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]);
|
||||
$this->dispatch('patrolEntryChart');
|
||||
}),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Guard Patrol Day Count';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Guard Patrol Day Chart';
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
return [
|
||||
GuardPatrolDayChart::class,
|
||||
];
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view guard patrol day count dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
115
app/Filament/Pages/GuardPatrolEntryDashboard.php
Normal file
115
app/Filament/Pages/GuardPatrolEntryDashboard.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use App\Models\Plant;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class GuardPatrolEntryDashboard extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static ?string $navigationGroup = 'Guard DashBoard';
|
||||
|
||||
protected static string $view = 'filament.pages.guard-patrol-entry-dashboard';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
// session()->forget(['select_guard_plant', 'select_guard_date']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'date' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Explicitly set where to store form data
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get){
|
||||
// $this->dispatch('invoiceChart');
|
||||
if(!$state)
|
||||
{
|
||||
$set('date', now()->format('Y-m-d')); // H:i:s
|
||||
// session(['select_guard_plant' => $state]);
|
||||
// session(['select_guard_date' => $get('date')]);
|
||||
} else {
|
||||
if(!$get('date'))
|
||||
{
|
||||
$set('date', now()->format('Y-m-d'));
|
||||
// session(['select_guard_plant' => $state]);
|
||||
// session(['select_guard_date' => $get('date')]);
|
||||
}
|
||||
// else {
|
||||
// session(['select_guard_plant' => $state]);
|
||||
// session(['select_guard_date' => $get('date')]);
|
||||
// }
|
||||
}
|
||||
$this->dispatch('loadGuardData', $state, $get('date')); //->format('Y-m-d')
|
||||
}),
|
||||
DatePicker::make('date')
|
||||
->label('Select Date')
|
||||
->placeholder('Select Date')
|
||||
->reactive()
|
||||
->required()
|
||||
->beforeOrEqual(now())
|
||||
->default(now()->format('Y-m-d'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get){
|
||||
if(!$get('plant'))
|
||||
{
|
||||
$set('date', now()->format('Y-m-d'));
|
||||
// session(['select_guard_plant' => $get('plant')]);
|
||||
// session(['select_guard_date' => $state]);
|
||||
} else {
|
||||
if(!$get('date'))
|
||||
{
|
||||
$set('date', now()->format('Y-m-d'));
|
||||
// session(['select_guard_plant' => $get('plant')]);
|
||||
// session(['select_guard_date' => $state]);
|
||||
}
|
||||
// else {
|
||||
// $records = GuardPatrolEntry::whereDate('patrol_time', $state)->where('plant_id', $get('plant'))->orderBy('patrol_time', 'asc')->first(); //desc
|
||||
// //dd($get('plant'), $state, $records->patrol_time);//->toTimeString()
|
||||
// session(['select_guard_plant' => $get('plant')]);
|
||||
// session(['select_guard_date' => $state]);
|
||||
// }
|
||||
}
|
||||
// $this->dispatch('invoiceChart');
|
||||
$this->dispatch('loadGuardData', $get('plant'), $state);//->format('Y-m-d')
|
||||
})
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Guard Patrol Status Table';
|
||||
}
|
||||
|
||||
public function getHeading(): string
|
||||
{
|
||||
return 'Guard Patrol Entry Status';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view guard patrol entry status dashboard');
|
||||
}
|
||||
}
|
||||
266
app/Filament/Pages/GuardPatrolHourlyCount.php
Normal file
266
app/Filament/Pages/GuardPatrolHourlyCount.php
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\GuardPatrolHourlyChart;
|
||||
use App\Models\CheckPointName;
|
||||
use App\Models\CheckPointTime;
|
||||
use App\Models\GuardPatrolEntry;
|
||||
use App\Models\Plant;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class GuardPatrolHourlyCount extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.guard-patrol-hourly-count';
|
||||
|
||||
protected static ?string $navigationGroup = 'Guard DashBoard';
|
||||
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant']);
|
||||
session()->forget(['selected_date']);
|
||||
session()->forget(['selected_name']);
|
||||
session()->forget(['selected_time']);
|
||||
session()->forget(['valid_sessions']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'date' => null,
|
||||
'time_range' => null,
|
||||
'guard_name' => null
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
if (is_null($state)) {
|
||||
session()->forget('selected_plant');
|
||||
} else {
|
||||
session(['selected_plant' => $state]);
|
||||
}
|
||||
|
||||
session(['selected_plant' => $state]);
|
||||
|
||||
$set('date', null);
|
||||
session()->forget('selected_date');
|
||||
|
||||
$set('guard_name', null);
|
||||
session()->forget('selected_name');
|
||||
|
||||
$set('time_range', null);
|
||||
session()->forget('selected_time');
|
||||
session()->forget('valid_sessions');
|
||||
|
||||
// $this->dispatch('patrolEntryChart');
|
||||
}),
|
||||
DatePicker::make('date')
|
||||
->label('Select Date')
|
||||
->placeholder('Select Date')
|
||||
->reactive()
|
||||
->required()
|
||||
->beforeOrEqual(now())
|
||||
->default(now()->format('Y-m-d'))
|
||||
->afterStateUpdated(function ($state,callable $set) {
|
||||
session(['selected_date' => $state]);
|
||||
$set('guard_name', null);
|
||||
session()->forget('selected_name');
|
||||
$set('time_range', null);
|
||||
session()->forget('selected_time');
|
||||
session()->forget('valid_sessions');
|
||||
|
||||
// $this->dispatch('patrolEntryChart');
|
||||
}),
|
||||
Select::make('guard_name')
|
||||
->label('Guard Name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$Date = $get('date');
|
||||
if (!$plantId || !$Date) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return GuardPatrolEntry::with('guardNames')->where('plant_id', $plantId)
|
||||
->whereDate('patrol_time', $Date)->orderBy('patrol_time','asc')
|
||||
->get()
|
||||
->unique('guard_name_id')
|
||||
->pluck('guardNames.name', 'guard_name_id')
|
||||
->toArray();
|
||||
|
||||
})
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state,callable $set)
|
||||
{
|
||||
if (is_null($state))
|
||||
{
|
||||
session()->forget('selected_name');
|
||||
}
|
||||
else
|
||||
{
|
||||
session(['selected_name' => $state]);
|
||||
}
|
||||
|
||||
// Clear the time range field and its session
|
||||
$set('time_range', null);
|
||||
session()->forget('selected_time');
|
||||
session()->forget('valid_sessions');
|
||||
}),
|
||||
|
||||
// Select::make('time_range')
|
||||
// ->label('Patrol Time Range')
|
||||
// ->options(function (callable $get) {
|
||||
// $plantId = $get('plant');
|
||||
// $guardId = $get('guard_name');
|
||||
// $date = $get('date');
|
||||
|
||||
// if (!$plantId || !$guardId || !$date) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// $patrols = GuardPatrolEntry::where('plant_id', $plantId)
|
||||
// ->where('guard_name_id', $guardId)
|
||||
// ->whereDate('patrol_time', $date)
|
||||
// ->orderBy('patrol_time', 'asc')
|
||||
// ->get(['patrol_time']);
|
||||
|
||||
// if ($patrols->isEmpty())
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// $chunkSize = CheckPointTime::where('plant_id', $plantId)->count()+ 1;;
|
||||
// $chunks = $patrols->chunk($chunkSize);
|
||||
|
||||
// $options = [];
|
||||
// foreach ($chunks as $index => $chunk) {
|
||||
// $first = $chunk->first();
|
||||
// $last = $chunk->last();
|
||||
// $start = Carbon::parse($first->patrol_time)->format('H:i:s');
|
||||
// $end = Carbon::parse($last->patrol_time)->format('H:i:s');
|
||||
// $timeRange = "$start - $end";
|
||||
// $options[$timeRange] = $timeRange;
|
||||
// }
|
||||
|
||||
// return $options;
|
||||
// })
|
||||
// ->reactive()
|
||||
// ->required()
|
||||
// ->afterStateUpdated(function ($state) {
|
||||
// session(['selected_time' => $state]);
|
||||
// })
|
||||
Select::make('time_range')
|
||||
->label('Patrol Time Range')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$guardId = $get('guard_name');
|
||||
$date = $get('date');
|
||||
|
||||
if (!$plantId || !$guardId || !$date) {
|
||||
session(['valid_sessions' => []]);
|
||||
return [];
|
||||
}
|
||||
|
||||
// Get patrols with checkpoints
|
||||
$patrols = GuardPatrolEntry::where('plant_id', $plantId)
|
||||
->where('guard_name_id', $guardId)
|
||||
->whereDate('patrol_time', $date)
|
||||
->orderBy('patrol_time', 'asc')
|
||||
->get(['patrol_time', 'check_point_name_id']);
|
||||
|
||||
if ($patrols->isEmpty()) {
|
||||
session(['valid_sessions' => []]);
|
||||
return [];
|
||||
}
|
||||
|
||||
// Get checkpoint sequence
|
||||
$checkPointTimes = CheckPointTime::where('plant_id', $plantId)
|
||||
->orderBy('sequence_number')
|
||||
->get(['check_point1_id', 'check_point2_id']);
|
||||
|
||||
// Build expected sequence
|
||||
$expectedSequence = [];
|
||||
foreach ($checkPointTimes as $row) {
|
||||
$expectedSequence[] = $row->check_point1_id;
|
||||
}
|
||||
if ($checkPointTimes->isNotEmpty()) {
|
||||
$expectedSequence[] = $checkPointTimes->last()->check_point2_id;
|
||||
}
|
||||
|
||||
$chunkSize = $checkPointTimes->count() + 1;
|
||||
$chunks = $patrols->chunk($chunkSize);
|
||||
|
||||
$options = [];
|
||||
$validSessions = [];
|
||||
|
||||
foreach ($chunks as $index => $chunk) {
|
||||
$first = $chunk->first();
|
||||
$last = $chunk->last();
|
||||
$start = Carbon::parse($first->patrol_time)->format('H:i:s');
|
||||
$end = Carbon::parse($last->patrol_time)->format('H:i:s');
|
||||
$timeRange = "$start - $end";
|
||||
|
||||
// Validate sequence for this chunk
|
||||
$currentSeqIndex = 0;
|
||||
$isValid = true;
|
||||
$anyMatch = false;
|
||||
|
||||
foreach ($chunk as $patrol) {
|
||||
if ($currentSeqIndex < count($expectedSequence) &&
|
||||
$patrol->check_point_name_id == $expectedSequence[$currentSeqIndex]) {
|
||||
$currentSeqIndex++;
|
||||
$anyMatch = true;
|
||||
} else {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Consider valid only if at least one checkpoint matches
|
||||
$isValid = $isValid && $anyMatch;
|
||||
$validSessions[$timeRange] = $isValid;
|
||||
$options[$timeRange] = $timeRange;
|
||||
}
|
||||
|
||||
session(['valid_sessions' => $validSessions]);
|
||||
return $options;
|
||||
})
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_time' => $state]);
|
||||
})
|
||||
|
||||
])
|
||||
->columns(4);
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
return [
|
||||
GuardPatrolHourlyChart::class,
|
||||
];
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view guard patrol hourly count dashboard');
|
||||
}
|
||||
}
|
||||
95
app/Filament/Pages/HourlyProduction.php
Normal file
95
app/Filament/Pages/HourlyProduction.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Widgets\ItemOverview;
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Tables\Concerns\HasFilters;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Pages\Dashboard;
|
||||
|
||||
class HourlyProduction extends page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.hourly-production';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant', 'selected_line']);
|
||||
session()->forget(['select_plant', 'select_line']);
|
||||
$plantId = session('selected_plant', null); // Default to the first plant if not selected
|
||||
$lineId = session('selected_line', null);
|
||||
|
||||
$this->filtersForm->fill([
|
||||
//'plant' => Plant::first()?->id // Default to first plant
|
||||
'plant' => $plantId,
|
||||
'line' => $lineId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]);
|
||||
// Clear production quantity Dashboard session keys to avoid conflict
|
||||
//session()->forget(['select_plant', 'select_line']);
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
|
||||
// Line Filter
|
||||
Select::make('line')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Line')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_line' => $state]);
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
if (session()->has('selected_plant') && session()->has('selected_line')) {
|
||||
$this->dispatch('filtersUpdated');
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Hourly Count';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production hourly count dashboard');
|
||||
}
|
||||
|
||||
public function getWidgets(): array
|
||||
{
|
||||
return [
|
||||
ItemOverview::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
75
app/Filament/Pages/InvoiceDashboard.php
Normal file
75
app/Filament/Pages/InvoiceDashboard.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class InvoiceDashboard extends Page
|
||||
{
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static ?string $navigationGroup = 'Invoice DashBoard';
|
||||
|
||||
protected static string $view = 'filament.pages.invoice-dashboard';
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selec_plant', 'select_invoice']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'invoice' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Explicitly set where to store form data
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selec_plant' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
}),
|
||||
Select::make('invoice')
|
||||
->options([
|
||||
'serial_invoice' => 'Serial Invoice',
|
||||
'individual_material' => 'Individual Material Invoice',
|
||||
'bundle_material' => 'Bundle Material Invoice',
|
||||
])
|
||||
->label('Select Invoice')
|
||||
->reactive()
|
||||
->default(0)
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['select_invoice' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
})
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Invoice';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
220
app/Filament/Pages/InvoiceFinder.php
Normal file
220
app/Filament/Pages/InvoiceFinder.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\LocatorInvoiceValidation;
|
||||
use App\Models\PalletValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class InvoiceFinder extends Page implements HasForms
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.invoice-finder';
|
||||
|
||||
protected static ?string $navigationGroup = 'Export Dispatch';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
//use InteractsWithForms;
|
||||
|
||||
public $pId, $invoiceNumber;
|
||||
|
||||
public array $invoiceOverviewData = [];
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('') // You can give your section a title or leave it blank
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required(),
|
||||
TextInput::make('scan_invoice')
|
||||
->label('Scan Invoice')
|
||||
->required()
|
||||
->reactive()
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processInvoiceNo($event.target.value)',
|
||||
]),
|
||||
TextInput::make('scan_quantity')
|
||||
->label('Scanned Quantity ')
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
TextInput::make('pending_quantity')
|
||||
->label('Pending Quantity')
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
TextInput::make('total_sno_quantity')
|
||||
->label('Invoice Quantity')
|
||||
->readOnly()
|
||||
->reactive(),
|
||||
|
||||
])
|
||||
->columns(5)
|
||||
]);
|
||||
}
|
||||
|
||||
public function processInvoiceNo($invoiceNo)
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
if(!$invoiceNo)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'scan_invoice' => $invoiceNo,
|
||||
'total_sno_quantity' => 0,
|
||||
'pending_quantity' => 0,
|
||||
'scan_quantity' => 0
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$invoiceExists = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNo)
|
||||
->first();
|
||||
|
||||
if(!$invoiceExists)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' does not exist in locator invoice table!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'scan_invoice' => null,//$invoiceNo,
|
||||
'total_sno_quantity' => 0,
|
||||
'pending_quantity' => 0,
|
||||
'scan_quantity' => 0
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$invoiceCompleted = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNo)
|
||||
->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '=','')
|
||||
->first();
|
||||
|
||||
if(!$invoiceCompleted)
|
||||
{
|
||||
// $count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
|
||||
// ->where('plant_id', $plantId)
|
||||
// ->count();
|
||||
Notification::make()
|
||||
->title("Invoice number '$invoiceNo' already completed the scanning process..!")
|
||||
->success()
|
||||
->duration(5000)
|
||||
->send();
|
||||
$this->dispatch('loadData', '', [], [], [], [], $plantId);
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'scan_invoice' => null,//$invoiceNo,
|
||||
'total_sno_quantity' => 0,//$count,
|
||||
'pending_quantity' => 0,//0,
|
||||
'scan_quantity' => 0//$count
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$serialNumbers = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||
->where('invoice_number', $invoiceNo)
|
||||
->pluck('serial_number');
|
||||
|
||||
$notFoundSerials = [];
|
||||
$incompleteSerials = [];
|
||||
$scannedSerials = [];
|
||||
$foundSerials = [];
|
||||
|
||||
foreach ($serialNumbers as $serial)
|
||||
{
|
||||
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
//$scannedStatus = $locatorRecord->scanned_status ?? null;
|
||||
|
||||
if ($locatorRecord->scanned_status == 'Scanned')
|
||||
{
|
||||
$scannedSerials[] = $serial;
|
||||
continue;
|
||||
}
|
||||
|
||||
$palletRecord = palletValidation::where('serial_number', $serial)
|
||||
->where('plant_id', $plantId)
|
||||
->first();
|
||||
|
||||
if (!$palletRecord)
|
||||
{
|
||||
$notFoundSerials[] = $serial;
|
||||
continue;
|
||||
}
|
||||
|
||||
$palletStatus = $palletRecord->pallet_status ?? null;
|
||||
|
||||
if (strlen($palletRecord->pallet_number) > 1 && ($palletStatus == '' || $palletStatus == null))
|
||||
{
|
||||
$incompleteSerials[] = $serial;
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundSerials[] = $serial;
|
||||
}
|
||||
|
||||
$count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
|
||||
->where('plant_id', $plantId)
|
||||
->count();
|
||||
|
||||
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
|
||||
->where('plant_id', $plantId)
|
||||
->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '=', '')
|
||||
->count();
|
||||
|
||||
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
|
||||
->where('plant_id', $plantId)
|
||||
->where('scanned_status', '=', 'Scanned')
|
||||
->count();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'scan_invoice' => $invoiceNo,
|
||||
'total_sno_quantity' => $count,
|
||||
'pending_quantity' => $pendingCount,
|
||||
'scan_quantity' => $scannedCount,
|
||||
]);
|
||||
|
||||
$this->dispatch('loadData', $invoiceNo, $notFoundSerials, $incompleteSerials, $scannedSerials, $foundSerials, $plantId);
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice finder page');
|
||||
}
|
||||
|
||||
}
|
||||
70
app/Filament/Pages/InvoiceQuantityDashboard.php
Normal file
70
app/Filament/Pages/InvoiceQuantityDashboard.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class InvoiceQuantityDashboard extends Page
|
||||
{
|
||||
use HasFiltersForm;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static ?string $navigationGroup = 'Invoice DashBoard';
|
||||
|
||||
protected static string $view = 'filament.pages.invoice-quantity-dashboard';
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selec_plant', 'select_invoice']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'invoice' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Explicitly set where to store form data
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selec_plant' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
}),
|
||||
Select::make('invoice')
|
||||
->options([
|
||||
'serial_invoice' => 'Serial Invoice',
|
||||
'individual_material' => 'Individual Material Invoice',
|
||||
'bundle_material' => 'Bundle Material Invoice',
|
||||
])
|
||||
->label('Select Invoice')
|
||||
->reactive()
|
||||
->default(0)
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['select_invoice' => $state]);
|
||||
$this->dispatch('invoiceChart');
|
||||
})
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Invoice Quantity';
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view invoice serial quantity dashboard');
|
||||
}
|
||||
}
|
||||
1978
app/Filament/Pages/LocatorValidation.php
Normal file
1978
app/Filament/Pages/LocatorValidation.php
Normal file
File diff suppressed because it is too large
Load Diff
1022
app/Filament/Pages/PalletFromLocator.php
Normal file
1022
app/Filament/Pages/PalletFromLocator.php
Normal file
File diff suppressed because it is too large
Load Diff
370
app/Filament/Pages/ProductionDataSap.php
Normal file
370
app/Filament/Pages/ProductionDataSap.php
Normal file
@@ -0,0 +1,370 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionDataSap extends Page implements HasForms
|
||||
{
|
||||
use InteractsWithForms;
|
||||
|
||||
public $pId , $pOrder, $pUom, $pItem, $transHeadLog, $sNums = [];
|
||||
|
||||
public $scanned_quantity;
|
||||
|
||||
public array $data = []; //Required to back form state
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
protected static string $view = 'filament.pages.production-data-sap';
|
||||
|
||||
protected static ?string $navigationGroup = 'Send To SAP';
|
||||
|
||||
protected $listeners = ['updateScannedQuantity' => 'setScannedQuantity'];
|
||||
|
||||
|
||||
|
||||
public function setScannedQuantity($quantity)
|
||||
{
|
||||
// Set the scanned_quantity value in the Filament page/form
|
||||
$this->scanned_quantity = $quantity;
|
||||
$this->form->fill([
|
||||
'scanned_quantity' => $quantity,
|
||||
'production_order' => $this->pOrder,
|
||||
'plant_id' => $this->pId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('data')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('pqPlantError', 'Please select a plant first.');
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pId = $plantId;
|
||||
$set('production_order', null);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqPlantError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
|
||||
TextInput::make('production_order')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
$productionOrder = $get('production_order');
|
||||
|
||||
if (!$productionOrder) {
|
||||
$set('pqproducError', 'Please provide production order.');
|
||||
$set('scanned_quantity', null);
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->pOrder = null;
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
$set('scanned_quantity', null);
|
||||
$set('validationError', null);
|
||||
$set('pqproducError', null);
|
||||
}
|
||||
})
|
||||
->hint(fn ($get) => $get('pqproducError') ? $get('pqproducError') : null)
|
||||
->hintColor('danger')
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processValues($event.target.value)',
|
||||
]),
|
||||
|
||||
TextInput::make('scanned_quantity')
|
||||
->reactive() // Make it reactive to update when changed
|
||||
->afterStateUpdated(function ($state, $set, $get) {
|
||||
$this->scanned_quantity = $state;
|
||||
})
|
||||
->readOnly()
|
||||
->required(),
|
||||
|
||||
// Add your custom action button here
|
||||
Actions::make([
|
||||
Action::make('send_to_sap')
|
||||
->label('Send Data to SAP')
|
||||
->action(function ($set, $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$plantWarehouseCodes = [
|
||||
// plant_id => warehouse_code
|
||||
1 => '110', // Ransar I
|
||||
2 => '101', // Ransar II
|
||||
3 => '102', // Chola Pumps
|
||||
4 => '104', // Tuff Pumps
|
||||
//5 => '107', //WH-Nark
|
||||
5 => '200', // Go-flex
|
||||
//7 => '301', // Krisgo II
|
||||
];
|
||||
|
||||
$year = date('y'); // '25' for 2025
|
||||
$month = date('m'); // '05' for May
|
||||
$transHeadLogId = $this->transHeadLog; //'3256';
|
||||
$lineItemCnt = '1'; //1 hard code
|
||||
$sapOrder = $get('production_order');
|
||||
$itemCode = $this->pItem;
|
||||
$quantity = (string)$get('scanned_quantity');
|
||||
$UOM = $this->pUom;
|
||||
|
||||
$locationName = '';
|
||||
$lamiCdate = $get('lami_cdate');
|
||||
$serialNumbers = $this->sNums;
|
||||
|
||||
$warehouseCode = $plantWarehouseCodes[$plantId] ?? null;
|
||||
$finalBatch = $warehouseCode . $year . $month;
|
||||
|
||||
$batchNumber = $finalBatch;
|
||||
//dd($batchNumber);
|
||||
|
||||
$currentDateTime = date('j/n/Y h:i:s A');
|
||||
|
||||
$header = [
|
||||
'Trans_Head_Log_Id' => $transHeadLogId, //'3256',
|
||||
'Line_Item_Count' => $lineItemCnt, //'1',
|
||||
'SAP_Order_Number' => $sapOrder, //'12345678'
|
||||
'Item_Code' => $itemCode, //'6458795'
|
||||
];
|
||||
// $serialNumbers = ['12024090000142', '12024090000142', '12024090000142'];
|
||||
$Receipt = [
|
||||
// 'Receipt' => [
|
||||
[
|
||||
'Quantity' => $quantity, //'1',
|
||||
'UOM' => $UOM,
|
||||
'Batch_Number' => $batchNumber,
|
||||
'Location_Name' => $locationName,
|
||||
'LAMI_Cdate' => $currentDateTime, //'9/9/2024 10:48:37 AM',
|
||||
'Serial_Number' => array_map(function ($serial) {
|
||||
return ['Serial_Number' => $serial];
|
||||
}, $serialNumbers)
|
||||
]
|
||||
// ]
|
||||
];
|
||||
|
||||
|
||||
$payload = [
|
||||
// ...$header,
|
||||
'Receipt' => $Receipt
|
||||
];
|
||||
// dd($payload);
|
||||
|
||||
// $header = [
|
||||
// 'Trans_Head_Log_Id' => '3256',
|
||||
// 'Line_Item_Count' => '1',
|
||||
// 'SAP_Order_Number' => '12345678',
|
||||
// 'Item_Code' => '6458795'
|
||||
// ];
|
||||
// $serialNumbers = ['12024090000142'];
|
||||
// $Receipt = [
|
||||
// // 'Receipt' => [
|
||||
// [
|
||||
// 'Quantity' => '1',
|
||||
// 'UOM' => 'EA',
|
||||
// 'Batch_Number' => '',
|
||||
// 'Location_Name' => '',
|
||||
// 'LAMI_Cdate' => '9/9/2024 10:48:37 AM',
|
||||
// 'Serial_Number' => array_map(function ($serial) {
|
||||
// return ['Serial_Number' => $serial];
|
||||
// }, $serialNumbers)
|
||||
// ]
|
||||
// // ]
|
||||
// ];
|
||||
|
||||
|
||||
// $payload = [
|
||||
// // ...$header,
|
||||
// 'Receipt' => $Receipt
|
||||
// ];
|
||||
// dd($payload);
|
||||
try {
|
||||
// $response = Http::withHeaders([
|
||||
// 'Content-Type' => 'application/json',
|
||||
// 'Trans_Head_Log_Id' => '3256',//$transHeadLogId,
|
||||
// 'Line_Item_Count' => '1', // $lineItemCnt,
|
||||
// 'SAP_Order_Number' => '12345678', //$sapOrder,
|
||||
// 'Item_Code' => '6458795', //$itemCode,
|
||||
// ])
|
||||
$response = Http::withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Trans_Head_Log_Id' => $transHeadLogId,
|
||||
'Line_Item_Count' => $lineItemCnt,
|
||||
'SAP_Order_Number' => $sapOrder,
|
||||
'Item_Code' => $itemCode,
|
||||
])
|
||||
->withBasicAuth(
|
||||
'sb-eba140ab-74bb-44a4-8d92-70a636940def!b1182|it-rt-dev-cri-stjllphr!b68',
|
||||
'616d8991-307b-4ab1-be37-7894a8c6db9d$0p0fE2I7w1Ve23-lVSKQF0ka3mKrTVcKPJYELr-i4nE='
|
||||
)
|
||||
->withBody(json_encode($payload), 'application/json')
|
||||
//->dump()
|
||||
|
||||
->post('https://dev-cri-stjllphr.it-cpi004-rt.cfapps.ap11.hana.ondemand.com/http/LA2CRI/GoodsReceiptAgFG', $payload);
|
||||
|
||||
// dump($response->transferStats->getRequest());
|
||||
|
||||
// dd(json_encode($payload, JSON_PRETTY_PRINT));
|
||||
//dd($response->status(), $response->body());
|
||||
|
||||
// dump($response);
|
||||
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
|
||||
if ($messageCode && str_starts_with($messageCode, 'ERROR')) {
|
||||
|
||||
$cleanError = str_replace('ERROR:|', '', $messageCode);
|
||||
|
||||
// Update rows where plant_id and production_order match
|
||||
ProductionQuantity::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'ERROR',
|
||||
'sap_msg_description' => $cleanError,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Error')
|
||||
->body($cleanError)
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$messageCode = $response->headers()['messagecode'][0] ?? null;
|
||||
$sapSuccessMsg = str_replace('SUCCESS:|', '', $messageCode);
|
||||
|
||||
ProductionQuantity::where('plant_id', $get('plant_id'))
|
||||
->where('production_order', $get('production_order'))
|
||||
->update([
|
||||
'sap_msg_status' => 'SUCCESS',
|
||||
'sap_msg_description' => $sapSuccessMsg,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('SAP Success')
|
||||
->body($sapSuccessMsg)
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Exception')
|
||||
->body('Error sending data to SAP: ' . $e->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
})
|
||||
->color('success')
|
||||
->outlined()
|
||||
->hidden(fn (callable $get) => (!$get('scanned_quantity'))) //!$get('plant_id') && !$get('production_order') &&
|
||||
->extraAttributes(['class' => 'align-to-input']),
|
||||
]),
|
||||
])
|
||||
->columns(4);
|
||||
}
|
||||
|
||||
public function processValues($value)
|
||||
{
|
||||
|
||||
$this->pOrder = $value;
|
||||
|
||||
$latestValidation = ProductionQuantity::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if (!$latestValidation) {
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body('No data found for the selected plant and production order.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
return;
|
||||
}
|
||||
|
||||
// $this->pUom = $latestValidation->uom;
|
||||
$this->transHeadLog = $latestValidation->id;
|
||||
|
||||
$itemId = $latestValidation->item_id;
|
||||
|
||||
$this->pUom = Item::where('id', $itemId)->value('uom');
|
||||
|
||||
$this->sNums = [];
|
||||
|
||||
if(!$this->pUom)
|
||||
{
|
||||
Notification::make()
|
||||
->title('UOM Not Found')
|
||||
->body('UOM not found for the production order')
|
||||
->icon('heroicon-o-x-circle')
|
||||
->danger()
|
||||
->send();
|
||||
$this->dispatch('refreshed', $this->pId, $this->pOrder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$latestProduction = ProductionQuantity::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
$this->pItem = $latestProduction
|
||||
? Item::where('id', $latestProduction->item_id)->value('code')
|
||||
: null;
|
||||
|
||||
|
||||
$this->sNums = ProductionQuantity::where('plant_id', $this->pId)
|
||||
->where('production_order', $this->pOrder)
|
||||
->pluck('serial_number')
|
||||
->toArray();
|
||||
|
||||
$this->dispatch('loadItems', $this->pId, $this->pOrder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production data send to sap');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'Production Data';
|
||||
}
|
||||
}
|
||||
|
||||
69
app/Filament/Pages/ProductionLineStopCount.php
Normal file
69
app/Filament/Pages/ProductionLineStopCount.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionLineStopCount extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.production-line-stop-count';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant', 'selected_line']);
|
||||
$this->filtersForm->fill([
|
||||
//'plant' => Plant::first()?->id // Default to first plant
|
||||
'plant' => null,
|
||||
'line' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]);
|
||||
}),
|
||||
|
||||
// Line Filter
|
||||
Select::make('line')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Line')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_line' => $state]);
|
||||
}),
|
||||
])
|
||||
->columns(2);
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production line stop count dashboard');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
93
app/Filament/Pages/ProductionOrderCount.php
Normal file
93
app/Filament/Pages/ProductionOrderCount.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Plant;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Tables\Concerns\HasFilters;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProductionOrderCount extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.production-order-count';
|
||||
|
||||
protected static ?string $navigationGroup = 'Production DashBoard';
|
||||
|
||||
use HasFiltersForm;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
session()->forget(['selected_plant', 'selected_line', 'production_order']);
|
||||
$this->filtersForm->fill([
|
||||
'plant' => null,
|
||||
'line' => null,
|
||||
'production_order' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function filtersForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters') // Explicitly set where to store form data
|
||||
->schema([
|
||||
Select::make('plant')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Select Plant')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_plant' => $state]);
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
// Line Filter
|
||||
Select::make('line')
|
||||
->options(function ($get) {
|
||||
$plantId = $get('plant');
|
||||
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
|
||||
})
|
||||
->label('Select Line')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['selected_line' => $state]); // Store in session
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
|
||||
// Production Order Text Input
|
||||
TextInput::make('production_order')
|
||||
->label('Production Order')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state) {
|
||||
session(['production_order' => $state]);
|
||||
$this->triggerChartUpdate();
|
||||
}),
|
||||
])
|
||||
->columns(3);
|
||||
}
|
||||
|
||||
// public function triggerChartUpdate(): void
|
||||
// {
|
||||
// if (session()->has('selected_plant') && session()->has('selected_line') && session()->has('production_order')) {
|
||||
// $this->dispatch('productionOrderChart');
|
||||
// }
|
||||
// }
|
||||
|
||||
public function triggerChartUpdate(): void
|
||||
{
|
||||
$filters = $this->filtersForm->getState();
|
||||
|
||||
if (!empty($filters['plant']) && !empty($filters['line']) && !empty($filters['production_order'])) {
|
||||
$this->dispatch('productionOrderChart', filters: $filters);
|
||||
}
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view production order count dashboard');
|
||||
}
|
||||
}
|
||||
1337
app/Filament/Pages/ProductionQuantityPage.php
Normal file
1337
app/Filament/Pages/ProductionQuantityPage.php
Normal file
File diff suppressed because it is too large
Load Diff
1890
app/Filament/Pages/UploadSerialLocator.php
Normal file
1890
app/Filament/Pages/UploadSerialLocator.php
Normal file
File diff suppressed because it is too large
Load Diff
182
app/Filament/Resources/AlertMailRuleResource.php
Normal file
182
app/Filament/Resources/AlertMailRuleResource.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
|
||||
use App\Models\AlertMailRule;
|
||||
use App\Models\Plant;
|
||||
use Dotenv\Exception\ValidationException;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Illuminate\Validation\ValidationException as ValidationValidationException;
|
||||
|
||||
class AlertMailRuleResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AlertMailRule::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Alert Mail';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->options(fn () => Plant::pluck('name', 'id')->toArray())
|
||||
->required(fn ($get) => ! $get('is_active'))
|
||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
|
||||
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
|
||||
Forms\Components\Select::make('module')
|
||||
->label('Module')
|
||||
->required()
|
||||
->options([
|
||||
'InvoiceValidation' => 'InvoiceValidation',
|
||||
'ProductionQuantities' => 'ProductionQuantities',
|
||||
]),
|
||||
Forms\Components\Select::make('rule_name')
|
||||
->label('Rule Name')
|
||||
->options([
|
||||
'InvoiceMail' => 'Invoice Mail',
|
||||
'SerialInvoiceMail' => 'Serial Invoice Mail',
|
||||
'MaterialInvoiceMail' => 'Material Invoice Mail',
|
||||
'ProductionMail' => 'Production Mail',
|
||||
])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('email')
|
||||
->label('Email')
|
||||
->required(),
|
||||
Forms\Components\Select::make('schedule_type')
|
||||
->label('Schedule Type')
|
||||
->required()
|
||||
->options([
|
||||
'Live' => 'Live',
|
||||
'Hourly' => 'Hourly',
|
||||
'Daily' => 'Daily',
|
||||
]),
|
||||
Checkbox::make('is_active')
|
||||
->label('All Plants Reports')
|
||||
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
|
||||
->reactive(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->default(fn () => Filament::auth()->user()?->name),
|
||||
])
|
||||
->columns(5),
|
||||
]);
|
||||
}
|
||||
|
||||
// Optionally, also override for update/editing
|
||||
// public static function mutateFormDataBeforeSave(array $data): array
|
||||
// {
|
||||
// dd('test');
|
||||
// if ($data['is_active']) {
|
||||
// $data['plant'] = 'All Plants';
|
||||
// }
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant')
|
||||
->label('Plant')
|
||||
->sortable()
|
||||
->formatStateUsing(function ($state) {
|
||||
static $plants;
|
||||
if (! $plants) {
|
||||
$plants = Plant::pluck('name', 'id')->toArray();
|
||||
}
|
||||
return $plants[$state] ?? 'All Plants';
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('module')
|
||||
->label('Module')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('rule_name')
|
||||
->label('Rule Name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('email')
|
||||
->label('Email')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('schedule_type')
|
||||
->label('Schedule Type')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAlertMailRules::route('/'),
|
||||
'create' => Pages\CreateAlertMailRule::route('/create'),
|
||||
'view' => Pages\ViewAlertMailRule::route('/{record}'),
|
||||
'edit' => Pages\EditAlertMailRule::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAlertMailRule extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
|
||||
if ($data['is_active']) {
|
||||
$data['plant'] = 0;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAlertMailRule extends EditRecord
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
//dd('test');
|
||||
if ($data['is_active']) {
|
||||
$data['plant'] = 0;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAlertMailRules extends ListRecords
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AlertMailRuleResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewAlertMailRule extends ViewRecord
|
||||
{
|
||||
protected static string $resource = AlertMailRuleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\BlockExporter;
|
||||
use App\Filament\Imports\BlockImporter;
|
||||
use App\Filament\Resources\BlockResource\Pages;
|
||||
use App\Models\Block;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
@@ -15,6 +17,7 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class BlockResource extends Resource
|
||||
@@ -99,25 +102,44 @@ class BlockResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
//->unique(ignoreRecord: true)
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->label('Block')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -137,7 +159,15 @@ class BlockResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(BlockImporter::class),
|
||||
->importer(BlockImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import block');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(BlockExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export block');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
187
app/Filament/Resources/CheckPointNameResource.php
Normal file
187
app/Filament/Resources/CheckPointNameResource.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\CheckPointNameExporter;
|
||||
use App\Filament\Imports\CheckPointNameImporter;
|
||||
use App\Filament\Resources\CheckPointNameResource\Pages;
|
||||
use App\Filament\Resources\CheckPointNameResource\RelationManagers;
|
||||
use App\Models\CheckPointName;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CheckPointNameResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CheckPointName::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 14;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(CheckPointName::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('cPnPlantError', 'Please select a plant first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('cPnPlantError', null);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cPnPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cPnPlantError') ? $get('cPnPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('check_point_names', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
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('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Check Point Name')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(CheckPointNameImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import check point name');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(CheckPointNameExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export check point name');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCheckPointNames::route('/'),
|
||||
'create' => Pages\CreateCheckPointName::route('/create'),
|
||||
'view' => Pages\ViewCheckPointName::route('/{record}'),
|
||||
'edit' => Pages\EditCheckPointName::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCheckPointName extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CheckPointNameResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCheckPointName extends EditRecord
|
||||
{
|
||||
protected static string $resource = CheckPointNameResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCheckPointNames extends ListRecords
|
||||
{
|
||||
protected static string $resource = CheckPointNameResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewCheckPointName extends ViewRecord
|
||||
{
|
||||
protected static string $resource = CheckPointNameResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
418
app/Filament/Resources/CheckPointTimeResource.php
Normal file
418
app/Filament/Resources/CheckPointTimeResource.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\CheckPointTimeExporter;
|
||||
use App\Filament\Imports\CheckPointTimeImporter;
|
||||
use App\Filament\Resources\CheckPointTimeResource\Pages;
|
||||
use App\Filament\Resources\CheckPointTimeResource\RelationManagers;
|
||||
use App\Models\CheckPointName;
|
||||
use App\Models\CheckPointTime;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CheckPointTimeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CheckPointTime::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 15;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('cPtPlantError', 'Please select a plant first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('cPtPlantError', null);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cPtPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cPtPlantError') ? $get('cPtPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('sequence_number')
|
||||
->label('Sequence Number')
|
||||
->required()
|
||||
->reactive()
|
||||
->integer()
|
||||
->minValue(1)
|
||||
->default(1)
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('check_point_times', 'sequence_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
//->where('check_point1_id', $get('check_point1_id'))
|
||||
//->where('check_point2_id', $get('check_point2_id'))
|
||||
}),
|
||||
Forms\Components\Select::make('check_point1_id')
|
||||
->label('Check Point Name 1')
|
||||
// ->relationship('checkPointNames', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CheckPointName::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->required()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point1_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$checkPoint1 = $get('check_point1_id');
|
||||
$checkPoint2 = $get('check_point2_id');
|
||||
if (!$checkPoint1) {
|
||||
$set('cPtCheckPoint1Error', 'Please select a check point 1 first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($checkPoint2 && $checkPoint1 == $checkPoint2) {
|
||||
$set('cPtCheckPoint1Error', 'Duplicate check point 2 found.');
|
||||
$set('check_point2_id', null);
|
||||
return;
|
||||
}
|
||||
$set('cPtCheckPoint1Error', null);
|
||||
$set('cPtCheckPoint2Error', null);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cPtCheckPoint1Error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cPtCheckPoint1Error') ? $get('cPtCheckPoint1Error') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('check_point2_id')
|
||||
->label('Check Point Name 2')
|
||||
// ->relationship('checkPointNames', 'name')
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return CheckPointName::where('plant_id', $plantId)
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->required()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point2_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$checkPoint1 = $get('check_point1_id');
|
||||
$checkPoint2 = $get('check_point2_id');
|
||||
if (!$checkPoint2) {
|
||||
$set('cPtCheckPoint2Error', 'Please select a check point 2 first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($checkPoint1 && $checkPoint1 == $checkPoint2) {
|
||||
$set('cPtCheckPoint2Error', 'Duplicate check point 2 found.');
|
||||
$set('check_point2_id', null);
|
||||
return;
|
||||
}
|
||||
$set('cPtCheckPoint1Error', null);
|
||||
$set('cPtCheckPoint2Error', null);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cPtCheckPoint2Error') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cPtCheckPoint2Error') ? $get('cPtCheckPoint2Error') : null)
|
||||
->hintColor('danger')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('check_point_times', 'check_point2_id')
|
||||
->where('check_point1_id', $get('check_point1_id'))
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('time_lapse')
|
||||
->label('Time Lapse (in minutes)')
|
||||
->required()
|
||||
->integer()
|
||||
->minValue(1)
|
||||
->default(1)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$timeLapse = $state;
|
||||
$timeLapseCushioning = $get('time_lapse_cushioning');
|
||||
if (!$timeLapse) {
|
||||
$set('cPtTimeLapseError', 'Please enter a valid time lapse!');
|
||||
$set('time_lapse_cushioning', null);
|
||||
$set('min_cushioning', null);
|
||||
$set('max_cushioning', null);
|
||||
return;
|
||||
}
|
||||
elseif(!$timeLapseCushioning)
|
||||
{
|
||||
// $set('cPtTimeLapseError', 'Please enter a valid time lapse cushioning!');
|
||||
$set('time_lapse_cushioning', 1);
|
||||
$set('cPtTimeLapseError', null);
|
||||
$set('min_cushioning', $timeLapse - 1);
|
||||
$set('max_cushioning', $timeLapse + 1);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
return;
|
||||
}
|
||||
elseif ($timeLapseCushioning > $timeLapse) {
|
||||
$set('cPtTimeLapseError', 'Must be greater than or equal to time lapse cushioning!');
|
||||
$set('time_lapse_cushioning', null);
|
||||
$set('min_cushioning', null);
|
||||
$set('max_cushioning', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('cPtTimeLapseError', null);
|
||||
$set('cPtTimeLapseCushError', null);
|
||||
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
|
||||
$set('max_cushioning', $timeLapse + $timeLapseCushioning);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cPtTimeLapseError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cPtTimeLapseError') ? $get('cPtTimeLapseError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('time_lapse_cushioning')
|
||||
->label('Time Lapse Cushioning (in minutes)')
|
||||
->required()
|
||||
->integer()
|
||||
->minValue(1)
|
||||
->default(1)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$timeLapse = $get('time_lapse');
|
||||
$timeLapseCushioning = $state;
|
||||
if (!$timeLapse) {
|
||||
$set('cPtTimeLapseCushError', 'Please enter a valid time lapse first.');
|
||||
$set('time_lapse_cushioning', null);
|
||||
$set('min_cushioning', null);
|
||||
$set('max_cushioning', null);
|
||||
return;
|
||||
}
|
||||
elseif(!$timeLapseCushioning)
|
||||
{
|
||||
// $set('cPtTimeLapseCushError', 'Please enter a valid time lapse cushioning!');
|
||||
$set('time_lapse_cushioning', 1);
|
||||
$set('cPtTimeLapseCushError', null);
|
||||
$set('min_cushioning', $timeLapse - 1);
|
||||
$set('max_cushioning', $timeLapse + 1);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
return;
|
||||
}
|
||||
elseif ($timeLapseCushioning > $timeLapse) {
|
||||
$set('cPtTimeLapseCushError', 'Must be less than or equal to time lapse!');
|
||||
$set('time_lapse_cushioning', null);
|
||||
$set('min_cushioning', null);
|
||||
$set('max_cushioning', null);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('cPtTimeLapseError', null);
|
||||
$set('cPtTimeLapseCushError', null);
|
||||
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
|
||||
$set('max_cushioning', $timeLapse + $timeLapseCushioning);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cPtTimeLapseCushError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cPtTimeLapseCushError') ? $get('cPtTimeLapseCushError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Hidden::make('min_cushioning')
|
||||
->default(0)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('max_cushioning')
|
||||
->default(2)
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
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('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('checkPointNames1.name')
|
||||
->label('Check Point 1')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('checkPointNames2.name')
|
||||
->label('Check Point 2')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('sequence_number')
|
||||
->label('Sequence Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('time_lapse')
|
||||
->label('Time Lapse')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('time_lapse_cushioning')
|
||||
->label('Time Lapse Cushioning (±)')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(CheckPointTimeImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import check point time');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(CheckPointTimeExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export check point time');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCheckPointTimes::route('/'),
|
||||
'create' => Pages\CreateCheckPointTime::route('/create'),
|
||||
'view' => Pages\ViewCheckPointTime::route('/{record}'),
|
||||
'edit' => Pages\EditCheckPointTime::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointTimeResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCheckPointTime extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CheckPointTimeResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointTimeResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCheckPointTime extends EditRecord
|
||||
{
|
||||
protected static string $resource = CheckPointTimeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointTimeResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCheckPointTimes extends ListRecords
|
||||
{
|
||||
protected static string $resource = CheckPointTimeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CheckPointTimeResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewCheckPointTime extends ViewRecord
|
||||
{
|
||||
protected static string $resource = CheckPointTimeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\CompanyExporter;
|
||||
use App\Filament\Imports\CompanyImporter;
|
||||
use App\Filament\Resources\CompanyResource\Pages;
|
||||
use App\Filament\Resources\CompanyResource\RelationManagers\PlantsRelationManager;
|
||||
use App\Models\Company;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -16,6 +18,7 @@ use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class CompanyResource extends Resource
|
||||
{
|
||||
@@ -67,21 +70,38 @@ class CompanyResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
// Tables\Columns\TextColumn::make('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->sortable(),
|
||||
->label('Company')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -101,10 +121,17 @@ class CompanyResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(CompanyImporter::class)
|
||||
->importer(CompanyImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import company');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(CompanyExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export company');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
|
||||
217
app/Filament/Resources/ConfigurationResource.php
Normal file
217
app/Filament/Resources/ConfigurationResource.php
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\ConfigurationExporter;
|
||||
use App\Filament\Imports\ConfigurationImporter;
|
||||
use App\Filament\Resources\ConfigurationResource\Pages;
|
||||
use App\Filament\Resources\ConfigurationResource\RelationManagers;
|
||||
use App\Models\Configuration;
|
||||
use App\Models\Line;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
|
||||
class ConfigurationResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Configuration::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
protected static ?int $navigationSort = 10;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(Configuration::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('cPlantError', 'Please select a plant first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('cPlantError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cPlantError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cPlantError') ? $get('cPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('line_id')
|
||||
->label('Line')
|
||||
->relationship('line', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (!$get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Line::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Configuration::latest()->first())->line_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$lineId = $get('line_id');
|
||||
if (!$lineId) {
|
||||
$set('cLineError', 'Please select a line first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('cLineError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('cLineError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('cLineError') ? $get('cLineError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('c_type')
|
||||
->label('Type')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('c_group')
|
||||
->label('Group')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('c_name')
|
||||
->label('Name')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('c_value')
|
||||
->label('Value')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
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')
|
||||
->alignCenter()
|
||||
->label('Plant')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('line.name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('c_type')
|
||||
->label('Type')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('c_group')
|
||||
->label('Group')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('c_name')
|
||||
->label('Name')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('c_value')
|
||||
->label('Value')
|
||||
->alignCenter()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->label('Updated At')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->label('Deleted At')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(ConfigurationImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import configuration');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(ConfigurationExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export configuration');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListConfigurations::route('/'),
|
||||
'create' => Pages\CreateConfiguration::route('/create'),
|
||||
'view' => Pages\ViewConfiguration::route('/{record}'),
|
||||
'edit' => Pages\EditConfiguration::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ConfigurationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ConfigurationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateConfiguration extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ConfigurationResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ConfigurationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ConfigurationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditConfiguration extends EditRecord
|
||||
{
|
||||
protected static string $resource = ConfigurationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ConfigurationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ConfigurationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListConfigurations extends ListRecords
|
||||
{
|
||||
protected static string $resource = ConfigurationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ConfigurationResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ConfigurationResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewConfiguration extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ConfigurationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
200
app/Filament/Resources/GuardNameResource.php
Normal file
200
app/Filament/Resources/GuardNameResource.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\GuardNameExporter;
|
||||
use App\Filament\Imports\GuardNameImporter;
|
||||
use App\Filament\Resources\GuardNameResource\Pages;
|
||||
use App\Filament\Resources\GuardNameResource\RelationManagers;
|
||||
use App\Models\GuardName;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class GuardNameResource extends Resource
|
||||
{
|
||||
protected static ?string $model = GuardName::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Master Entries';
|
||||
|
||||
protected static ?int $navigationSort = 13;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(GuardName::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (!$plantId) {
|
||||
$set('GnError', 'Please select a plant first.');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$set('GnError', null);
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('GnError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('GnError') ? $get('GnError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('guard_names', 'name')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id'));
|
||||
}),
|
||||
Forms\Components\TextInput::make('identification1')
|
||||
->label('Identification-1')
|
||||
->required()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('identification2')
|
||||
->label('Identification-2')
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->default(fn () => Filament::auth()->user()?->name)
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('created_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->readOnly(),
|
||||
]);
|
||||
}
|
||||
|
||||
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('id')
|
||||
// ->label('ID')
|
||||
// ->numeric()
|
||||
// ->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Guard')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(GuardNameImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import guard name');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->exporter(GuardNameExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export guard name');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListGuardNames::route('/'),
|
||||
'create' => Pages\CreateGuardName::route('/create'),
|
||||
'view' => Pages\ViewGuardName::route('/{record}'),
|
||||
'edit' => Pages\EditGuardName::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\GuardNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GuardNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateGuardName extends CreateRecord
|
||||
{
|
||||
protected static string $resource = GuardNameResource::class;
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('create');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\GuardNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GuardNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditGuardName extends EditRecord
|
||||
{
|
||||
protected static string $resource = GuardNameResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\GuardNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GuardNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListGuardNames extends ListRecords
|
||||
{
|
||||
protected static string $resource = GuardNameResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\GuardNameResource\Pages;
|
||||
|
||||
use App\Filament\Resources\GuardNameResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewGuardName extends ViewRecord
|
||||
{
|
||||
protected static string $resource = GuardNameResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user