120 Commits

Author SHA1 Message Date
e501e91673 Update dependency althinect/filament-spatie-roles-permissions to v3
Some checks failed
renovate/artifacts Artifact file update failure
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Laravel Pint / pint (pull_request) Failing after 1m57s
Laravel Larastan / larastan (pull_request) Failing after 2m5s
2026-02-22 08:38:36 +00:00
8a0e7d6878 Merge pull request 'Updated scrap_quantity as '0' when rework_status is 'No'' (#367) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Reviewed-on: #367
2026-02-21 13:21:19 +00:00
dhanabalan
81d2f4bd2c Updated scrap_quantity as '0' when rework_status is 'No'
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 23s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Pint / pint (pull_request) Successful in 2m52s
Laravel Larastan / larastan (pull_request) Failing after 3m46s
2026-02-21 18:50:58 +05:30
d1031d8a6e Merge pull request 'Updated validation logic while create and update' (#366) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #366
2026-02-21 11:25:40 +00:00
dhanabalan
c3d4a97277 Updated validation logic while create and update
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 2m39s
Laravel Larastan / larastan (pull_request) Failing after 3m46s
2026-02-21 16:54:30 +05:30
fa06c2c6cb Merge pull request 'Updated laser part validation import / create page / report view function' (#365) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #365
2026-02-20 19:02:15 +00:00
dhanabalan
d243f53f2f Updated laser part validation import / create page / report view function
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-21 00:31:45 +05:30
e06a458fc0 Merge pull request 'Updated default plant load logic against resource files' (#364) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #364
2026-02-20 16:01:58 +00:00
dhanabalan
878e12eff5 Updated default plant load logic against resource files
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 21:31:41 +05:30
36dd07817b Merge pull request 'Updated validation logic against created_by and updated_by columns on importer' (#363) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #363
2026-02-20 15:36:02 +00:00
dhanabalan
cddc8a1b70 Updated validation logic against created_by and updated_by columns on importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 21:04:41 +05:30
51a20219db Merge pull request 'Updated validation logic if coil_number is 0 on importer' (#362) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #362
2026-02-20 15:25:46 +00:00
dhanabalan
95217ce722 Updated validation logic if coil_number is 0 on importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 20:55:27 +05:30
dc564f9c28 Merge pull request 'ranjith-dev' (#361) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #361
2026-02-20 14:27:16 +00:00
dhanabalan
9ba54dabf1 Updated validation logic on importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 19:55:34 +05:30
dhanabalan
3c4a4bf136 Updated validation logic on importer file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-20 19:18:37 +05:30
dhanabalan
0e651e8bcc Updated column order on exporter file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-20 18:44:01 +05:30
bab5b879e6 Merge pull request 'Updated validation logic on importer and exporter' (#360) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #360
2026-02-20 11:41:24 +00:00
dhanabalan
c3a4985f45 Updated validation logic on importer and exporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 17:11:05 +05:30
a09264a053 Merge pull request 'Changed label name of machine' (#359) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #359
2026-02-20 10:04:10 +00:00
dhanabalan
95c27d6821 Changed label name of machine
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 15:33:56 +05:30
82f776ef41 Merge pull request 'Changed logic in process order importer' (#358) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #358
2026-02-20 10:02:56 +00:00
dhanabalan
8fedc01efd Changed logic in process order importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 15:32:42 +05:30
952b9a01a5 Merge pull request 'Updated validation logic on inmporter and exporter' (#357) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #357
2026-02-20 09:39:29 +00:00
dhanabalan
4abdd1b81e Updated validation logic on inmporter and exporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 14:35:59 +05:30
2b8a3a2838 Merge pull request 'ranjith-dev' (#356) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #356
2026-02-20 09:02:18 +00:00
dhanabalan
10c2abb881 Changed logic in process order importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-20 14:31:06 +05:30
dhanabalan
934447d0b2 Changed logic in process order importer and exporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-20 13:06:06 +05:30
4acb66c464 Merge pull request 'Added migration file for allowing null value in shift_id column in table production plans' (#355) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #355
2026-02-19 07:03:07 +00:00
dhanabalan
b4acea8144 Added migration file for allowing null value in shift_id column in table production plans
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 12:32:47 +05:30
ea64aea9ce Merge pull request 'Added sub group name of production' (#354) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #354
2026-02-19 06:31:05 +00:00
dhanabalan
9e59f3d0fb Added sub group name of production
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 12:00:45 +05:30
72e6621cc0 Merge pull request 'Added save button and calender script file' (#353) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #353
2026-02-19 06:28:11 +00:00
dhanabalan
e6bf48055f Added save button and calender script file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 11:57:51 +05:30
2c49e6b272 Merge pull request 'Added production calendar and production target permission' (#352) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #352
2026-02-19 06:24:12 +00:00
dhanabalan
c3fa25090d Added production calendar and production target permission
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 11:53:45 +05:30
d6ec50c20e Merge pull request 'Added production plan export page' (#351) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #351
2026-02-19 06:20:40 +00:00
dhanabalan
14da244965 Added production plan export page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 11:50:16 +05:30
19382d0644 Merge pull request 'ranjith-dev' (#350) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #350
2026-02-19 06:20:04 +00:00
dhanabalan
8d1e1e6e53 Added production target plan live wire page and blade file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 11:49:06 +05:30
dhanabalan
58e6e9df56 Added production target page and blade file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-19 11:47:51 +05:30
dhanabalan
bec1a17970 Added production calender and blade file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-19 11:45:30 +05:30
408e426545 Merge pull request 'ranjith-dev' (#349) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #349
2026-02-19 06:13:05 +00:00
dhanabalan
3c971e2ce7 Removed custom last scanned qr code
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 11:42:25 +05:30
dhanabalan
7793477c2d Added mahcine id in production quantity page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-19 11:35:38 +05:30
dhanabalan
8204043122 removed required for block in line resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-19 11:34:22 +05:30
dhanabalan
fd1c3a8094 Added block select box and line capacity in resource file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-19 11:33:07 +05:30
dhanabalan
8f34ec0d86 Added production plan importer and resource file with updated logic
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-19 11:31:59 +05:30
62b338be22 Merge pull request 'Added columns in model files of Item and line and production plan and production quantity' (#348) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #348
2026-02-19 06:00:20 +00:00
dhanabalan
5ba59e10bd Added columns in model files of Item and line and production plan and production quantity
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 11:29:02 +05:30
c407f9c6c2 Merge pull request 'Added columns in production plan and lines and items and production quantities migration file' (#347) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #347
2026-02-19 05:50:36 +00:00
dhanabalan
b9812cbe32 Added columns in production plan and lines and items and production quantities migration file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-19 11:19:45 +05:30
a09adf0ea5 Merge pull request 'ranjith-dev' (#346) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #346
2026-02-18 05:23:05 +00:00
dhanabalan
a297734bad Added searchable option for plant_id and line_id
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-18 10:48:39 +05:30
dhanabalan
20b02bfd7a Added searchable option for plant_id
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-18 10:40:27 +05:30
b864bda85e Merge pull request 'Refactor characteristic value form validation' (#345) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #345
2026-02-18 04:47:00 +00:00
dhanabalan
87cfe556ae Refactor characteristic value form validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-18 10:14:52 +05:30
734ab9dfdc Merge pull request 'Added status column auto updation logic based on observed_value' (#344) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #344
2026-02-17 12:13:58 +00:00
dhanabalan
b9a9a2fd5f Added status column auto updation logic based on observed_value
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-17 17:42:50 +05:30
6907083ec0 Merge pull request 'Updated plant label on report view' (#343) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #343
2026-02-17 04:18:35 +00:00
dhanabalan
e07bdb3310 Updated plant label on report view
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-17 09:47:57 +05:30
bd7e0422e6 Merge pull request 'Updated capacitor focus logic' (#342) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #342
2026-02-17 04:14:22 +00:00
dhanabalan
84e547ec4b Updated capacitor focus logic
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-17 09:43:53 +05:30
53f14711b2 Merge pull request 'ranjith-dev' (#341) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #341
2026-02-17 03:27:38 +00:00
dhanabalan
0dd49c2ebf Added searchable to respective columns and created_by column added on report view
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-17 08:56:12 +05:30
dhanabalan
db15039d81 Updated fillable order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-17 08:51:50 +05:30
a39a10d104 Merge pull request 'ranjith-dev' (#340) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #340
2026-02-17 03:10:13 +00:00
dhanabalan
8d2489b16f Added updated_by column on view report and create_at column position changed
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-17 08:38:57 +05:30
dhanabalan
4a0be04a22 Added searchable to created_by and updated_by column
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-17 08:35:55 +05:30
17bca76d06 Merge pull request 'ranjith-dev' (#339) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #339
2026-02-16 09:15:53 +00:00
dhanabalan
0938f0955d Updated plant null exception and strict xlsx file allow logic on invoice import
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-16 14:41:39 +05:30
dhanabalan
ab70705e5a Updated material invoice upload logic
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-16 14:30:28 +05:30
500a2ae3ca Merge pull request 'ranjith-dev' (#338) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #338
2026-02-16 08:49:55 +00:00
dhanabalan
20dac4a9bf Updated default value as logged user name in updated_by column
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-16 14:19:15 +05:30
dhanabalan
a54ddb2f55 Updated created_at column visible by default on report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-16 12:44:00 +05:30
0adb82afcf Merge pull request 'ranjith-dev' (#337) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #337
2026-02-16 07:09:49 +00:00
dhanabalan
018c51b75b Added id column in hidden and updated_by name updated on every control afterStateUpdated and searchable() method added on select controls
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-16 12:39:29 +05:30
dhanabalan
7c086ceb28 Commented unwanted mount function
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-16 12:22:23 +05:30
dhanabalan
67ffbf68fd Updated fillable order in model file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-16 12:21:36 +05:30
cc7fd5b16d Merge pull request 'ranjith-dev' (#336) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #336
2026-02-16 04:54:24 +00:00
dhanabalan
f5d9adb516 Enhance approval email view logic and update HTML templates for better user feedback
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-16 10:20:18 +05:30
dhanabalan
787296abf9 Enhance request approval email design logic
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-16 10:16:44 +05:30
dhanabalan
ea39fb92de Enhance approval email logic and update HTML templates for better user feedback
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-16 10:14:25 +05:30
70d38c7a7b Merge pull request 'Updated machine work_center from machine name on export' (#335) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #335
2026-02-16 04:35:52 +00:00
dhanabalan
9212e2f937 Updated machine work_center from machine name on export
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-16 10:05:30 +05:30
efba8af539 Merge pull request 'ranjith-dev' (#334) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #334
2026-02-14 07:44:54 +00:00
dhanabalan
2acd3c8bb4 Add 'Spec. Value' column to CharacteristicValueResource table using ProductCharacteristicsMaster
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-14 13:07:31 +05:30
dhanabalan
d511b915e2 Refactor CharacteristicApprovalMail to include additional properties for pending approvers and subject line
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-13 19:52:21 +05:30
dhanabalan
8315b835b1 Updated alignment on GET and POST structure
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-13 19:49:50 +05:30
caac5ad7eb Merge pull request 'Updated order_quantity validation against process_order' (#333) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #333
2026-02-12 14:06:03 +00:00
dhanabalan
55a16800f8 Updated order_quantity validation against process_order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-12 19:35:43 +05:30
7e799d507a Merge pull request 'Updated rework coil functionality' (#332) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #332
2026-02-12 13:29:23 +00:00
dhanabalan
56a5e40ec0 Updated rework coil functionality
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-12 18:58:59 +05:30
358d31cb71 Merge pull request 'Added coil_number and rework_status on advanced filters' (#331) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #331
2026-02-12 12:41:32 +00:00
dhanabalan
e20132d1f6 Added coil_number and rework_status on advanced filters
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-12 17:37:30 +05:30
4ffc2d7a92 Merge pull request 'ranjith-dev' (#330) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #330
2026-02-12 05:41:41 +00:00
dhanabalan
96aca2697f Changed logic in get api of process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-12 11:11:22 +05:30
dhanabalan
21ffd1763e Added default '-' for characteristic_name, current_value, update_value on quantity request type
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-11 14:30:30 +05:30
be5d02bc50 Merge pull request 'ranjith-dev' (#329) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #329
2026-02-11 08:57:40 +00:00
dhanabalan
bd0e6b7c2e Removed commented code
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-11 14:27:14 +05:30
dhanabalan
fcb88cef80 Updated table alignment towards center and display quantity value as integer for individual or bundle material type
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-11 14:25:28 +05:30
eff0da491c Merge pull request 'Added import and export permission for characteristic values' (#328) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #328
2026-02-11 07:12:29 +00:00
dhanabalan
a79555feb6 Added import and export permission for characteristic values
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-11 12:42:16 +05:30
2e0ccd7c34 Merge pull request 'ranjith-dev' (#327) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #327
2026-02-11 04:48:25 +00:00
dhanabalan
da178087ea Removed duplicate where condition on generate workFlowId and updated quality approval pending condition and Refactor document retrieval function
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-11 10:03:25 +05:30
dhanabalan
3dd5b30070 Uncommented code (skip mail if already hold) and update trigger_at null on approved or rejected
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-11 10:00:55 +05:30
dhanabalan
6cb67362d5 Removed duplicate where condition on generate workFlowId
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-11 09:55:28 +05:30
2a2bf8db4c Merge pull request 'ranjith-dev' (#326) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #326
2026-02-10 10:52:08 +00:00
dhanabalan
d885af0843 Updated item code validations and warning messages on import
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-10 16:03:36 +05:30
dhanabalan
54e1404ff7 Refactor approval process: enhance hold and reject forms, improve status messages, and add approveSave method
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 14:38:38 +05:30
dhanabalan
4da20051f6 Added request-type parameter and some validation on GET and POST
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 14:36:49 +05:30
c2c50eb451 Merge pull request 'ranjith-dev' (#325) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #325
2026-02-10 08:49:34 +00:00
dhanabalan
87a8102d79 Updated machine name column position and label changed from AUFNR to JOB NUMBER
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
2026-02-10 14:19:02 +05:30
dhanabalan
4c21f2544e Added approver_type column using foreign key on resource file and updated some validations
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 14:17:55 +05:30
dhanabalan
0b231390e3 Added approver_type column on resource file and updated some validations
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 14:12:09 +05:30
dhanabalan
48768fbac9 Added request characteristic has many relation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 13:03:24 +05:30
dhanabalan
2663e1e4bc Added approver_type column using foreign key on exporter file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 12:54:00 +05:30
dhanabalan
601c70518c Added approver_type column on exporter file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 12:51:25 +05:30
dhanabalan
f00ea207ae Added approver_type column on model file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 12:48:19 +05:30
dhanabalan
aaa9c17e66 Updated alignments and added orderby query while load plant
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-02-10 12:45:54 +05:30
95 changed files with 7837 additions and 4602 deletions

View File

@@ -38,15 +38,40 @@ class TriggerPendingApprovalMails extends Command
public $pdfPath;
public $subjectLine;
public $wfId;
public function handle()
{
$this->info('Approval mail job started');
$records = RequestCharacteristic::whereNull('approver_status1')
->whereNull('approver_status2')
->whereNull('approver_status3')
->get();
// .. Characteristic Mail trigger logic
// $records = RequestCharacteristic::whereNull('approver_status1')
// ->whereNull('approver_status2')
// ->whereNull('approver_status3')
// ->get();
$records = RequestCharacteristic::where(function ($q) {
$q->whereNull('approver_status1')
->orWhere('approver_status1', 'Hold');
})
->where(function ($q) {
$q->whereNull('approver_status2')
->orWhere('approver_status2', 'Hold');
})
->where(function ($q) {
$q->whereNull('approver_status3')
->orWhere('approver_status3', 'Hold');
})
->get();
$records = $records->filter(function ($item) {
$approver = CharacteristicApproverMaster::find($item->characteristic_approver_master_id);
return $approver && $approver->approver_type == 'Characteristic';
});
if ($records->isEmpty()) {
$this->info('No pending approvals');
@@ -54,9 +79,20 @@ class TriggerPendingApprovalMails extends Command
}
$grouped = $records->groupBy(function ($item) {
$this->wfId = $item->work_flow_id;
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
});
$pendingApprovers = RequestCharacteristic::where('work_flow_id', $this->wfId)->latest()->first();
$this->info($pendingApprovers->approver_status1, $pendingApprovers->approver_status2);
$approverNameFromMaster = null;
if ($pendingApprovers && $pendingApprovers->characteristic_approver_master_id) {
$approverNameFromMaster = CharacteristicApproverMaster::find($pendingApprovers->characteristic_approver_master_id);
}
$rows = [];
foreach ($grouped as $groupRecords) {
@@ -92,9 +128,6 @@ class TriggerPendingApprovalMails extends Command
$name = $approver->name1;
$updateData['mail_status'] = 'Sent';
// $updateData['trigger_at'] = $approver->duration1 > 0
// ? $now->copy()->addMinutes($approver->duration1 * 10)
// : null;
if ($approver->duration1 > 0)
{
@@ -118,19 +151,184 @@ class TriggerPendingApprovalMails extends Command
// --- SECOND MAIL ---
elseif (
$first->mail_status == 'Sent' &&
is_null($first->approver_status1) &&
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
$first->trigger_at &&
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
) {
$this->info(
"mail_status: {$first->mail_status}, ".
"approver_status1: {$first->approver_status1}, ".
"trigger_at: {$first->trigger_at}, ".
"now: {$now}"
);
$level = 2;
$mail = $approver->mail2;
$name = $approver->name2;
if ($approver->duration2 > 0) {
$duration = number_format((float)$approver->duration2, 2, '.', '');
[$hours, $minutes] = explode('.', $duration);
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
$updateData['trigger_at'] = $now->copy()->addMinutes($totalMinutes);
} else {
$updateData['trigger_at'] = null;
}
$updateData['mail_status'] = 'Sent-Mail2';
}
// --- THIRD MAIL ---
elseif (
$first->mail_status == 'Sent-Mail2' &&
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
$first->trigger_at &&
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
) {
$level = 3;
$mail = $approver->mail3;
$name = $approver->name3;
$updateData['trigger_at'] = null;
$updateData['mail_status'] = 'Sent-Mail3';
}
if (!$level || !$mail) {
continue;
}
$pdfPath = 'uploads/LaserDocs/' . $first->work_flow_id . '.pdf';
$subjectLine = 'Characteristic Approval Mail';
Mail::to($mail)->send(
new CharacteristicApprovalMail(
$first,
$name,
$level,
$pdfPath,
$pendingApprovers,
$approverNameFromMaster,
$subjectLine,
$characteristics
)
);
RequestCharacteristic::whereIn('id', $groupRecords->pluck('id'))
->update($updateData);
$rows[] = [
$first->id,
$first->plant_id,
$first->machine_id,
"Level $level",
$mail,
'SENT'
];
}
// .. Quality Mail trigger logic
$qualityRecords = RequestCharacteristic::where(function ($q) {
$q->whereNull('approver_status1')
->orWhere('approver_status1', 'Hold');
})
->where(function ($q) {
$q->whereNull('approver_status2')
->orWhere('approver_status2', 'Hold');
})
->where(function ($q) {
$q->whereNull('approver_status3')
->orWhere('approver_status3', 'Hold');
})
->get();
$qualityRecords = $qualityRecords->filter(function ($item) {
$approver = CharacteristicApproverMaster::find($item->characteristic_approver_master_id);
return $approver && $approver->approver_type == 'Quality';
});
if ($qualityRecords->isEmpty()) {
$this->info('No quality pending approvals');
return;
}
$grouped = $qualityRecords->groupBy(function ($item) {
$this->wfId = $item->work_flow_id;
return $item->plant_id . '|' . $item->machine_id . '|' . $item->aufnr . '|' . $item->work_flow_id;
});
$pendingApprovers = RequestCharacteristic::where('work_flow_id', $this->wfId)->latest()->first();
$approverNameFromMaster = null;
if ($pendingApprovers && $pendingApprovers->characteristic_approver_master_id) {
$approverNameFromMaster = CharacteristicApproverMaster::find($pendingApprovers->characteristic_approver_master_id);
}
$rows = [];
foreach ($grouped as $groupRecords) {
$first = $groupRecords->first();
$approver = CharacteristicApproverMaster::where('plant_id', $first->plant_id)
->where('machine_id', $first->machine_id)
->where('id', $first->characteristic_approver_master_id)
->first();
if (!$approver) {
continue;
}
$level = null;
$mail = null;
$name = null;
$updateData = [];
$now = Carbon::now();
// --- FIRST MAIL ---
if (is_null($first->mail_status)){
$level = 1;
$mail = $approver->mail1;
$name = $approver->name1;
$updateData['mail_status'] = 'Sent';
if ($approver->duration1 > 0)
{
$duration = number_format((float)$approver->duration1, 2, '.', '');
[$hours, $minutes] = explode('.', $duration);
$totalMinutes = ((int)$hours * 60) + (int)$minutes;
$updateData['trigger_at'] = $now
->copy()
->addMinutes($totalMinutes)
->startOfMinute();
}
else
{
$updateData['trigger_at'] = null;
}
}
// --- SECOND MAIL ---
elseif (
$first->mail_status == 'Sent' &&
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
$first->trigger_at &&
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
// $first->trigger_at <= $now
) {
$level = 2;
$mail = $approver->mail2;
$name = $approver->name2;
// $updateData['trigger_at'] = $approver->duration2 > 0
// ? $now->copy()->addMinutes($approver->duration2 * 10)
// : null;
// $updateData['mail_status'] = 'Sent-Mail2';
if ($approver->duration2 > 0) {
@@ -151,10 +349,9 @@ class TriggerPendingApprovalMails extends Command
// --- THIRD MAIL ---
elseif (
$first->mail_status == 'Sent-Mail2' &&
is_null($first->approver_status1) &&
is_null($first->approver_status2) &&
(is_null($first->approver_status1) || $first->approver_status1 == 'Hold') &&
(is_null($first->approver_status2) || $first->approver_status2 == 'Hold') &&
$first->trigger_at &&
// $first->trigger_at <= $now
\Carbon\Carbon::parse($first->trigger_at)->lte($now)
) {
$level = 3;
@@ -169,7 +366,13 @@ class TriggerPendingApprovalMails extends Command
continue;
}
$pdfPath = 'uploads/LaserDocs/' . $first->work_flow_id . '.pdf';
$pdfPath = ($f = glob(storage_path('app/private/uploads/LaserDocs/' . $first->work_flow_id . '.*')))
? 'uploads/LaserDocs/' . basename($f[0])
: null;
$this->info( $pdfPath);
$subjectLine = 'Quality Approval Mail';
Mail::to($mail)->send(
new CharacteristicApprovalMail(
@@ -177,6 +380,9 @@ class TriggerPendingApprovalMails extends Command
$name,
$level,
$pdfPath,
$pendingApprovers,
$approverNameFromMaster,
$subjectLine,
$characteristics
)
);

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class ProductionPlanExport implements FromArray, WithHeadings, WithMapping
{
protected array $data;
protected array $dates;
public function __construct(array $data, array $dates)
{
$this->data = $data;
$this->dates = $dates;
}
public function array(): array
{
return $this->data;
}
public function headings(): array
{
$headings = [
'Plant Name',
'Line Name',
'Item Code',
];
// Add dynamic headings for each date: Target / Produced
foreach ($this->dates as $date) {
$headings[] = $date . ' - Line Capacity';
$headings[] = $date . ' - Target Plan';
$headings[] = $date . ' - Produced Quantity';
}
return $headings;
}
public function map($row): array
{
$mapped = [
$row['plant_name'] ?? '',
$row['line_name'] ?? '',
$row['item_code'] ?? '',
];
foreach ($this->dates as $date) {
$mapped[] = $row['daily_line_capacity'][$date] ?? '-';
$mapped[] = $row['daily_target_dynamic'][$date] ?? '-';
$mapped[] = $row['produced_quantity'][$date] ?? '-';
}
return $mapped;
}
}

View File

@@ -30,6 +30,8 @@ class CharacteristicApproverMasterExporter extends Exporter
->label('WORK CENTER'),
ExportColumn::make('machine_name')
->label('MACHINE NAME'),
ExportColumn::make('approver_type')
->label('APPROVER TYPE'),
ExportColumn::make('characteristic_field')
->label('MASTER CHARACTERISTIC FIELD'),
ExportColumn::make('name1')

View File

@@ -28,7 +28,7 @@ class CharacteristicValueExporter extends Exporter
->label('LINE NAME'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('machine.name')
ExportColumn::make('machine.work_center')
->label('WORK CENTER'),
ExportColumn::make('process_order')
->label('PROCESS ORDER'),
@@ -36,12 +36,14 @@ class CharacteristicValueExporter extends Exporter
->label('COIL NUMBER'),
ExportColumn::make('status')
->label('STATUS'),
ExportColumn::make('observed_value')
->label('OBSERVED VALUE'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED 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')

View File

@@ -24,6 +24,8 @@ class ProcessOrderExporter extends Exporter
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('line.name')
->label('LINE NAME'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('process_order')
@@ -37,13 +39,17 @@ class ProcessOrderExporter extends Exporter
ExportColumn::make('sfg_number')
->label('SFG NUMBER'),
ExportColumn::make('machine_name')
->label('MACHINE ID'),
->label('MACHINE NAME'),
ExportColumn::make('scrap_quantity')
->label('SCRAP QUANTITY'),
ExportColumn::make('rework_status')
->label('REWORK STATUS'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')

View File

@@ -29,7 +29,7 @@ class ProductCharacteristicsMasterExporter extends Exporter
ExportColumn::make('line.name')
->label('LINE NAME'), // machine.workGroupMaster.name
ExportColumn::make('machine.workGroupMaster.name')
->label('WORK GROUP MASTER'),
->label('GROUP WORK CENTER'),
ExportColumn::make('machine.work_center')
->label('WORK CENTER'),
ExportColumn::make('characteristics_type')

View File

@@ -30,12 +30,14 @@ class RequestCharacteristicExporter extends Exporter
->label('WORK CENTER'),
ExportColumn::make('work_flow_id')
->label('WORK FLOW ID'),
ExportColumn::make('characteristicApproverMaster.machine_name')
->label('MACHINE NAME'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('aufnr')
->label('AUFNR'),
ExportColumn::make('characteristicApproverMaster.machine_name')
->label('MACHINE NAME'),
->label('JOB NUMBER'),
ExportColumn::make('characteristicApproverMaster.approver_type')
->label('APPROVER TYPE'),
ExportColumn::make('characteristicApproverMaster.characteristic_field')
->label('MASTER CHARACTERISTIC FIELD'),
ExportColumn::make('characteristic_name')

View File

@@ -8,10 +8,14 @@ use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use App\Models\ProcessOrder;
use App\Models\ProductCharacteristicsMaster;
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 CharacteristicValueImporter extends Importer
@@ -64,11 +68,28 @@ class CharacteristicValueImporter extends Importer
->exampleHeader('Status')
->example('Ok')
->label('Status'),
ImportColumn::make('observed_value')
->requiredMapping()
->exampleHeader('Observed Value')
->example('RAW01234')
->label('Observed Value'),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('RAW01234')
->label('Created By'),
ImportColumn::make('created_at')
->requiredMapping()
->exampleHeader('Created DateTime')
->example('01-01-2025 08:00:00')
->label('Created DateTime')
->rules(['required']),
ImportColumn::make('updated_at')
->requiredMapping()
->exampleHeader('Updated DateTime')
->example('01-01-2025 08:00:00')
->label('Updated DateTime')
->rules(['required']),
];
}
@@ -82,30 +103,39 @@ class CharacteristicValueImporter extends Importer
$warnMsg = [];
$plantId = null;
$itemId = null;
$LineId = null;
$lineId = null;
$machineId = null;
$itemAgainstPlant = null;
// $itemAgainstPlant = null;
$plantCode = $this->data['plant'];
$processOrder = trim($this->data['process_order'] ?? '');
$iCode = trim($this->data['item']);
$workCenter = trim($this->data['machine']);
$lineName = trim($this->data['line']);
$coilNo = trim($this->data['coil_number']);
$obserVal = trim($this->data['observed_value']);
$status = trim($this->data['status']);
$createdBy = trim($this->data['created_by']);
$coilNo = trim($this->data['coil_number']);
if ($plantCode == null || $plantCode == '') {
$warnMsg[] = 'Plant code cannot be empty';
} elseif ($iCode == null || $iCode == '') {
} elseif ($iCode == null || $iCode == '') {// process_order
$warnMsg[] = 'Item code cannot be empty';
} elseif ($processOrder == null || $processOrder == '') {//
$warnMsg[] = 'Process Order cannot be empty';
} elseif ($workCenter == null || $workCenter == '') {
$warnMsg[] = 'Work center cannot be empty';
} elseif ($lineName == null || $lineName == '') {
$warnMsg[] = 'Line cannot be empty';
$warnMsg[] = 'Line name cannot be empty';
} elseif ($coilNo == null || $coilNo == '') {
$warnMsg[] = 'Coil number cannot be empty';
} elseif ($obserVal == null || $obserVal == '') {
$warnMsg[] = 'Observed value cannot be empty';
} elseif ($status == null || $status == '') {
$warnMsg[] = 'Status cannot be empty';
}
if (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
if (Str::length($plantCode) > 0 && (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode))) {
$warnMsg[] = 'Invalid plant code found';
} else {
$plant = Plant::where('code', $plantCode)->first();
@@ -116,7 +146,7 @@ class CharacteristicValueImporter extends Importer
}
}
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
$warnMsg[] = 'Invalid item code found';
} else {
$itemCode = Item::where('code', $iCode)->first();
@@ -124,11 +154,11 @@ class CharacteristicValueImporter extends Importer
$warnMsg[] = 'Item code not found';
} else {
if ($plantId) {
$itemAgainstPlant = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
if (! $itemAgainstPlant) {
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
if (! $itemCode) {
$warnMsg[] = 'Item code not found for the given plant';
} else {
$itemId = $itemAgainstPlant->id;
$itemId = $itemCode->id;
}
}
}
@@ -143,7 +173,7 @@ class CharacteristicValueImporter extends Importer
if (! $lineAgainstPlant) {
$warnMsg[] = 'Line name not found for the given plant';
} else {
$LineId = $lineAgainstPlant->id;
$lineId = $lineAgainstPlant->id;
}
}
}
@@ -163,9 +193,9 @@ class CharacteristicValueImporter extends Importer
// $MachineId = $workCenterAgainstPlant->id;
// }
if ($plantId != null && $LineId != null) {
if ($plantId != null && $lineId != null) {
$machineAgaPlantLine = Machine::where('plant_id', $plantId)
->where('line_id', $LineId)
->where('line_id', $lineId)
->where('work_center', $workCenter)
->first();
@@ -176,34 +206,66 @@ class CharacteristicValueImporter extends Importer
}
}
if ($processOrder == null || $processOrder == '') {
$warnMsg[] = 'Process Order cannot be empty';
}
if ($coilNo == null || $coilNo == '') {
$warnMsg[] = 'Coil No cannot be empty';
} elseif (! is_numeric($coilNo)) {
if (Str::length($coilNo) > 0 && ! is_numeric($coilNo)) {
$warnMsg[] = 'Coil number should contain only numeric values!';
}
if ($status == null || $status == '' || ! $status) {
$warnMsg[] = 'Status cannot be empty';
} elseif (! in_array($status, ['Ok', 'NotOk'], true)) {
if (Str::length($obserVal) > 0 && ! is_numeric($obserVal)) {
$warnMsg[] = 'Observed value should contain only numeric values!';
}
if (Str::length($status) > 0 && ! in_array($status, ['Ok', 'NotOk'], true)) {
$warnMsg[] = "Status must be either 'Ok' or 'NotOk'!";
}
// else {
// if (Str::length($status) <= 0 || ! is_numeric($status) || ! preg_match('/^\d+(\.\d+)?$/', $status)
// ) {
// $status = 'NotOk';
// } else {
// $specVal = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $itemId)->where('line_id', $lineId)->where('machine_id', $machineId)->first();
// if (! $specVal) {
// $status = 'NotOk';
// }
// $lowLimit = $specVal?->lower ?? 0;
// $uppLimit = $specVal?->upper ?? 0;
// if (Str::length($lowLimit) <= 0 || ! is_numeric($lowLimit) || ! preg_match('/^\d+(\.\d+)?$/', $lowLimit)
// ) {
// $status = 'NotOk';
// } elseif (Str::length($uppLimit) <= 0 || ! is_numeric($uppLimit) || ! preg_match('/^\d+(\.\d+)?$/', $uppLimit)
// ) {
// $status = 'NotOk';
// }
// if (($lowLimit == 0 && $uppLimit == 0) || ($uppLimit == 0)) {
// $status = 'NotOk';
// }
// if ($lowLimit > $obserVal || $uppLimit < $obserVal) {
// $status = 'NotOk';
// }
// $status = 'Ok';
// }
// }
if ($createdBy == null || $createdBy == '' || ! $createdBy) {
$warnMsg[] = 'Created By cannot be empty';
}
// $existing = CharacteristicValue::where('plant_id', $plantId)
// ->where('process_order', $processOrder)
// ->where('coil_number', $coilNo)
// ->first();
if ($plantId) {
$user = User::where('name', $createdBy)->first();
// if ($existing) {
// $warnMsg[] = "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!";
// }
$userPlant = User::where('name', $createdBy)->where('plant_id', $plantId)->first();
if (! $user) {
$warnMsg[] = 'Created By user name not found!';
} elseif (! $userPlant && ! $user->hasRole('Super Admin')) {
$warnMsg[] = "Created By user '{$createdBy}' not found for Plant '{$plantCode}'!";
} elseif (! $user->hasRole(['Super Admin', 'Process Quality Manager', 'Process Manager', 'Process Supervisor', 'Process Employee'])) {
$warnMsg[] = 'Created By user does not have rights!';
}
}
if ($plantId && $processOrder) {
$existing = CharacteristicValue::where('plant_id', $plantId)
@@ -216,31 +278,81 @@ class CharacteristicValueImporter extends Importer
}
}
if ($plant && $itemCode && $processOrder != '') {
if ($plant && $itemCode && $processOrder != '' && $processOrder != null) {
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
$existingOrder = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->first();
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
}
}
$updatedBy = Filament::auth()->user()->name; // ?? 'Admin'
if (! $updatedBy) {
$warnMsg[] = 'Invalid updated by user name 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) {
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
foreach ($formats as $format) {
try {
$tdateTime = Carbon::createFromFormat($format, $toDate);
break;
} catch (\Exception $e) {
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (! isset($fdateTime)) {
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
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 (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return CharacteristicValue::create([
return CharacteristicValue::updateOrCreate([
'plant_id' => $plantId,
'item_id' => $itemId,
'line_id' => $LineId,
'machine_id' => $machineId,
'process_order' => trim($this->data['process_order']),
'coil_number' => trim($this->data['coil_number']),
'status' => trim($this->data['status']),
'created_by' => trim($this->data['created_by']),
]);
'process_order' => $processOrder,
'coil_number' => $coilNo,
],
[
'item_id' => $itemId,
'line_id' => $lineId,
'machine_id' => $machineId,
'status' => $status,
'observed_value' => $obserVal,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
'created_at' => $fdateTime->format('Y-m-d H:i:s'),
'updated_at' => $tdateTime->format('Y-m-d H:i:s'),
]);
// return null;

View File

@@ -3,6 +3,7 @@
namespace App\Filament\Imports;
use App\Models\Item;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProcessOrder;
use App\Models\User;
@@ -27,6 +28,11 @@ class ProcessOrderImporter extends Importer
->label('PLANT CODE')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('line')
->exampleHeader('LINE NAME')
->example(' Polywrapped line')
->label('LINE NAME')
->relationship(resolveUsing: 'name'),
ImportColumn::make('item')
->requiredMapping()
->exampleHeader('ITEM CODE')
@@ -35,20 +41,57 @@ class ProcessOrderImporter extends Importer
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('process_order')
->requiredMapping()
->exampleHeader('PROCESS ORDER')
->example('202500123456')
->label('PROCESS ORDER')
->rules(['required']),
ImportColumn::make('coil_number')
->exampleHeader('COIL NUMBER')
->example('01')
->label('COIL NUMBER'),
ImportColumn::make('order_quantity')
->requiredMapping()
->exampleHeader('ORDER QUANTITY')
->example('100')
->label('ORDER QUANTITY')
->rules(['required']),
// ImportColumn::make('created_by')
// ->exampleHeader('CREATED BY')
// ->example('RAW01234')
// ->label('CREATED BY')
// ->rules(['required']),
ImportColumn::make('received_quantity')
->exampleHeader('RECEIVED QUANTITY')
->example('01')
->label('RECEIVED QUANTITY'),
ImportColumn::make('sfg_number')
->exampleHeader('SFG NUMBER')
->example('200000220613-72')
->label('SFG NUMBER'),
ImportColumn::make('machine_name')
->exampleHeader('MACHINE NAME')
->example('WMIWRM13 - 2-L2')
->label('MACHINE NAME'),
ImportColumn::make('scrap_quantity')
->exampleHeader('SCRAP QUANTITY')
->example('0')
->label('SCRAP QUANTITY'),
ImportColumn::make('rework_status')
->exampleHeader('REWORK STATUS')
->example('0')
->label('REWORK STATUS'),
ImportColumn::make('created_at')
->exampleHeader('CREATED AT')
->example('2026-02-20 13:00:00')
->label('CREATED AT'),
ImportColumn::make('updated_at')
->exampleHeader('UPDATED AT')
->example('2026-02-20 13:00:00')
->label('UPDATED AT'),
ImportColumn::make('created_by')
->exampleHeader('CREATED BY')
->example('RAW01234')
->label('CREATED BY'),
ImportColumn::make('updated_by')
->exampleHeader('UPDATED BY')
->example('RAW01234')
->label('UPDATED BY'),
];
}
@@ -57,10 +100,56 @@ class ProcessOrderImporter extends Importer
$warnMsg = [];
$plantCod = $this->data['plant'];
$plant = null;
$plantId = null;
$itemId = null;
$iCode = trim($this->data['item']);
$lineName = trim($this->data['line']);
$processOrder = trim($this->data['process_order'] ?? '');
$user = Filament::auth()->user();
$operatorName = $user->name;
$coilNo = trim($this->data['coil_number'] ?? '');
$sfgNo = trim($this->data['sfg_number'] ?? '');
$machineName = trim($this->data['machine_name'] ?? '');
$orderQuan = trim($this->data['order_quantity'] ?? '');
$scrapQuan = trim($this->data['scrap_quantity'] ?? '');
$reworkStatus = trim($this->data['rework_status'] ?? '');
$recQuan = trim($this->data['received_quantity'] ?? '');
$createdAt = trim($this->data['created_at'] ?? '');
$createdBy = trim($this->data['created_by'] ?? '');
$updatedAt = trim($this->data['updated_at'] ?? '');
$updatedBy = trim($this->data['updated_by'] ?? '');
// $user = Filament::auth()->user();
// $operatorName = $user->name;
if ($plantCod == null || $plantCod == '') {
$warnMsg[] = 'Plant code cannot be empty';
}
if ($iCode == null || $iCode == '') {
$warnMsg[] = 'Item code cannot be empty';
}
if ($processOrder == null || $processOrder == '') {
$warnMsg[] = 'Process order cannot be empty';
}
if ($orderQuan == null || $orderQuan == '') {
$warnMsg[] = 'Order quantity cannot be empty';
} elseif ($orderQuan == 0 || $orderQuan == '0') {
$warnMsg[] = 'Order quantity cannot be zero';
}
if ($coilNo == null || $coilNo == '') {
$coilNo = '0';
}
if ($scrapQuan == null || $scrapQuan == '') {
$scrapQuan = 0;
}
if ($recQuan == null || $recQuan == '') {
$recQuan = 0;
}
if ($reworkStatus == null || $reworkStatus = '') {
$reworkStatus = 0;
}
if ($createdBy == null || $createdBy == '') {
$createdBy = Filament::auth()->user()?->name;
$updatedBy = $createdBy;
}
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = 'Invalid plant code found';
@@ -68,6 +157,8 @@ class ProcessOrderImporter extends Importer
$plant = Plant::where('code', $plantCod)->first();
if (! $plant) {
$warnMsg[] = 'Plant not found';
} else {
$plantId = $plant->id;
}
}
@@ -76,43 +167,169 @@ class ProcessOrderImporter extends Importer
} else {
$itemCode = Item::where('code', $iCode)->first();
if (! $itemCode) {
$warnMsg[] = 'Item Code not found';
$warnMsg[] = 'Item code not found';
} else {
if ($plantId) {
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
if (! $itemCode) {
$warnMsg[] = 'Item code not found for the given plant';
} else {
$itemId = $itemCode->id;
}
}
}
}
if ($processOrder == '') {
$warnMsg[] = 'Process Order cannot be empty';
}
// $user = User::where('name', $this->data['created_by'])->first();
// if (! $user) {
// $warnMsg[] = 'User not found';
// }
if ($plant && $itemCode && $processOrder != '') {
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
$existingOrder = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->first();
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
}
}
if ($lineName != null && $lineName != '') {
$lineExists = Line::where('name', $lineName)->first();
if (! $lineExists) {
$warnMsg[] = 'Line name not found';
} else {
if ($plantId) {
$lineAgainstPlant = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
if (! $lineAgainstPlant) {
$warnMsg[] = 'Line name not found for the given plant';
} else {
$lineId = $lineAgainstPlant->id;
}
}
}
} else {
$lineId = null;
}
if ($createdBy != null && $createdBy != '') {
if ($plantId) {
$user = User::where('name', $createdBy)->first();
$userPlant = User::where('name', $createdBy)->where('plant_id', $plantId)->first();
if (! $user) {
$warnMsg[] = 'Created By user name not found!';
} elseif (! $userPlant && ! $user->hasRole('Super Admin')) {
$warnMsg[] = "Created By user '{$createdBy}' not found for Plant '{$plantCod}'!";
} elseif (! $user->hasRole(['Super Admin', 'Process Quality Manager', 'Process Manager', 'Process Supervisor', 'Process Employee'])) {
$warnMsg[] = 'Created By user does not have rights!';
}
}
$updatedBy = Filament::auth()->user()?->name;
}
if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return ProcessOrder::create([
'plant_id' => $plant->id,
'item_id' => $itemCode->id,
'process_order' => trim($this->data['process_order']),
'coil_number' => '0',
'order_quantity' => 0,
'received_quantity' => 0,
'created_by' => $operatorName,
]);
if ($lineName != null && $lineName != '') {
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineId)
->where('coil_number', $coilNo)
->first();
if (! $existingCoil) {
ProcessOrder::Create(
[
'plant_id' => $plantId,
'line_id' => $lineId,
'process_order' => $processOrder,
'item_id' => $itemId,
'coil_number' => $coilNo,
'order_quantity' => $orderQuan,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan,
'sfg_number' => $sfgNo,
'machine_name' => $machineName,
'rework_status' => $reworkStatus,
'created_at' => $createdAt,
'updated_at' => $updatedAt,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]
);
} else {
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineId)
->where('coil_number', $coilNo)
->update([
// 'order_quantity' => $orderQty,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan,
// 'sfg_number' => $sfgNo,
// 'machine_name' => $machineId,
'rework_status' => $reworkStatus,
'updated_by' => $updatedBy,
'updated_at' => $updatedAt,
]);
}
} elseif ($lineName == null || $lineName == '') {
$existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if (! $existing && $coilNo == '0' || $coilNo == 0) {
ProcessOrder::create([
'plant_id' => $plantId,
'item_id' => $itemId,
'process_order' => $processOrder,
'coil_number' => '0',
'order_quantity' => $orderQuan,
'received_quantity' => 0,
'scrap_quantity' => 0,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]);
} elseif (! $existing) {
ProcessOrder::Create(
[
'plant_id' => $plantId,
'line_id' => $lineId,
'process_order' => $processOrder,
'item_id' => $itemId,
'coil_number' => $coilNo,
'order_quantity' => $orderQuan,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan ?? 0,
'sfg_number' => $sfgNo,
'machine_name' => $machineName,
'rework_status' => $reworkStatus,
'created_at' => $createdAt,
'updated_at' => $updatedAt,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]
);
} else {// $coilNo = '0'
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->update([
// 'order_quantity' => $orderQty,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan,
// 'sfg_number' => $sfgNo,
// 'machine_name' => $machineId,
'rework_status' => $reworkStatus,
'updated_by' => $updatedBy,
'updated_at' => $updatedAt,
]);
}
}
return null;
// return new ProcessOrder();
}

View File

@@ -13,7 +13,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Illuminate\Support\Facades\Auth;
use Filament\Facades\Filament;
use Str;
class ProductCharacteristicsMasterImporter extends Importer
@@ -75,7 +75,7 @@ class ProductCharacteristicsMasterImporter extends Importer
->rules(['required']),
ImportColumn::make('lower')
->exampleHeader('Lower')
->example('-0.2')
->example('0')
->label('Lower')
->rules(['numeric']),
ImportColumn::make('middle')
@@ -86,7 +86,7 @@ class ProductCharacteristicsMasterImporter extends Importer
->rules(['numeric']),
ImportColumn::make('upper')
->exampleHeader('Upper')
->example('0.2')
->example('2')
->label('Upper')
->rules(['numeric']),
ImportColumn::make('created_by')
@@ -103,7 +103,12 @@ class ProductCharacteristicsMasterImporter extends Importer
$warnMsg = [];
$plantCod = $this->data['plant'];
$plant = null;
$updatedBy = Filament::auth()->user()->name; // ?? 'Admin'
$lower = null;
$middle = null;
$upper = null;
$plantId = null;
$name = trim($this->data['name']);
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = 'Invalid plant code found';
} else {
@@ -111,13 +116,14 @@ class ProductCharacteristicsMasterImporter extends Importer
if (! $plant) {
$warnMsg[] = 'Plant not found';
} else {
$plantId = $plant->id;
$itemExists = Item::where('code', $this->data['item'])->first();
if (! $itemExists) {
$warnMsg[] = 'Item not found';
}
$itemAgainstPlant = Item::where('code', $this->data['item'])
->where('plant_id', $plant->id)
->where('plant_id', $plantId)
->first();
if (! $itemAgainstPlant) {
$warnMsg[] = 'Item code not found for the given plant';
@@ -131,7 +137,7 @@ class ProductCharacteristicsMasterImporter extends Importer
}
$lineAgainstPlant = Line::where('name', $this->data['line'])
->where('plant_id', $plant->id)
->where('plant_id', $plantId)
->first();
if (! $lineAgainstPlant) {
@@ -140,7 +146,7 @@ class ProductCharacteristicsMasterImporter extends Importer
$LineId = $lineAgainstPlant->id;
}
$WorkgroupMaster = WorkGroupMaster::where('name', $this->data['work_group_master_id'])->where('plant_id', $plant->id)->first();
$WorkgroupMaster = WorkGroupMaster::where('name', $this->data['work_group_master_id'])->where('plant_id', $plantId)->first();
if (! $WorkgroupMaster) {
$warnMsg[] = 'Work Group Master value not found';
} else {
@@ -148,7 +154,7 @@ class ProductCharacteristicsMasterImporter extends Importer
$workGroupMasterId = $WorkgroupMaster->id;
// 2. Now check if this WorkGroupMaster id exists in ANY of the 10 columns
$existsInLine = Line::where('plant_id', $plant->id)
$existsInLine = Line::where('plant_id', $plantId)
->where(function ($q) use ($workGroupMasterId) {
for ($i = 1; $i <= 10; $i++) {
$q->orWhere("work_group{$i}_id", $workGroupMasterId);
@@ -171,7 +177,7 @@ class ProductCharacteristicsMasterImporter extends Importer
}
$machineAgainstPlant = Machine::where('work_center', $this->data['machine'])
->where('plant_id', $plant->id)
->where('plant_id', $plantId)
->first();
if (! $machineAgainstPlant) {
@@ -180,15 +186,24 @@ class ProductCharacteristicsMasterImporter extends Importer
$machineId = $machineAgainstPlant->id;
}
if ($name == null || $name == '') {
$warnMsg[] = "Name can't be empty";
}
$user = User::where('name', $this->data['created_by'])->first();
if (! $user) {
$warnMsg[] = 'Operator ID not found';
}
$updatedBy = Filament::auth()->user()->name; // ?? 'Admin'
if (! $updatedBy) {
$warnMsg[] = 'Invalid updated by user name found';
}
if (($this->data['inspection_type'] ?? null) == 'Value') {
$upper = $this->data['upper'] ?? null;
$lower = $this->data['lower'] ?? null;
$middle = $this->data['middle'] ?? null;
$upper = $this->data['upper'] ?? null;
if (is_null($upper) || is_null($lower) || is_null($middle)) {
$warnMsg[] = "For 'Value' inspection type, Upper, Lower, and Middle values are required.";
@@ -203,64 +218,55 @@ class ProductCharacteristicsMasterImporter extends Importer
if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
} else {
$record = ProductCharacteristicsMaster::firstOrNew([
'plant_id' => $plant->id,
}
// $record = ProductCharacteristicsMaster::firstOrNew([
// 'plant_id' => $plantId,
// 'item_id' => $itemId,
// 'line_id' => $LineId,
// 'work_group_master_id' => $workGroupMasterId,
// 'machine_id' => $machineId,
// ]);
// // If record is new, fill all fields
// if (! $record->exists) {
// $record->name = $name;
// $record->characteristics_type = $this->data['characteristics_type'];
// $record->inspection_type = $this->data['inspection_type'];
// $record->lower = $this->data['lower'] ?? null;
// $record->upper = $this->data['upper'] ?? null;
// $record->middle = $this->data['middle'] ?? null;
// $record->created_by = $this->data['created_by'] ?? null;
// $record->updated_by = $updatedBy ?? null;
// } else {
// // Record exists → update only updated_by and updated_at
// $record->updated_by = $updatedBy ?? null;
// $record->touch();
// }
// $record->save();
ProductCharacteristicsMaster::updateOrCreate(
[
'plant_id' => $plantId,
'item_id' => $itemId,
'line_id' => $LineId,
'work_group_master_id' => $workGroupMasterId,
'machine_id' => $machineId,
],
[
'name' => $name,
'characteristics_type' => $this->data['characteristics_type'],
'inspection_type' => $this->data['inspection_type'],
'lower' => $lower,
'middle' => $middle,
'upper' => $upper,
// 'created_by' => user ?? $this->data['created_by'],
'created_by' => $this->data['created_by'] ?? null,
'updated_by' => $updatedBy ?? null,
]);
$currentUser = Auth::check() ? Auth::user()->name : ($this->data['created_by'] ?? 'System');
// If record is new, fill all fields
if (! $record->exists) {
$record->name = $this->data['name'];
$record->characteristics_type = $this->data['characteristics_type'];
$record->inspection_type = $this->data['inspection_type'];
$record->upper = $this->data['upper'] ?? null;
$record->lower = $this->data['lower'] ?? null;
$record->middle = $this->data['middle'] ?? null;
$record->created_by = $currentUser;
} else {
// Record exists → update only updated_by and updated_at
$record->updated_by = $currentUser;
$record->touch();
}
$record->save();
return null;
}
// else
// {
// ProductCharacteristicsMaster::updateOrCreate(
// [
// 'plant_id' => $plant->id,
// 'item_id' => $itemId,
// 'line_id' => $LineId,
// 'work_group_master_id' => $workGroupMasterId,
// 'machine_id'=> $machineId,
// ],
// [
// 'name' => $this->data['name'],
// 'characteristics_type' => $this->data['characteristics_type'],
// 'inspection_type' => $this->data['inspection_type'],
// 'upper' => $this->data['upper'] ?? null,
// 'lower' => $this->data['lower'] ?? null,
// 'middle' => $this->data['middle'] ?? null,
// //'created_by' => user ?? $this->data['created_by'],
// 'created_by' => Auth::check() ? Auth::user()->name :($this->data['created_by'] ?? null)
// ]
// );
// return null;
// }
return null;
// return new WorkGroupMaster();
// return new ProductCharacteristicsMaster();
}

View File

@@ -3,6 +3,7 @@
namespace App\Filament\Imports;
use App\Models\Block;
use App\Models\Item;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProductionPlan;
@@ -23,11 +24,33 @@ class ProductionPlanImporter extends Importer
public static function getColumns(): array
{
return [
ImportColumn::make('created_at')
// 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('plant')
->requiredMapping()
->exampleHeader('Created DateTime')
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
->label('Created DateTime')
->exampleHeader('Plant Code')
->example(['1000', '1000'])
->label('Plant 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('item')
->requiredMapping()
->exampleHeader('Item Code')
->example(['123456', '210987'])
->label('Item Code')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('plan_quantity')
->requiredMapping()
@@ -36,52 +59,40 @@ class ProductionPlanImporter extends Importer
->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') // ID
->example(['Day', 'Night']) // '2', '7'
->label('Shift Name') // ID
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Code')
->example(['1000', '1000'])
->label('Plant Code')
->relationship(resolveUsing: 'code')
->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']),
// ImportColumn::make('production_quantity')
// ->requiredMapping()
// ->exampleHeader('Production Quantity')
// ->example(['0', '0'])
// ->label('Production Quantity')
// ->numeric()
// ->rules(['required', 'integer']),
// 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') // ID
// ->example(['Day', 'Night']) // '2', '7'
// ->label('Shift Name') // ID
// ->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']),
];
}
@@ -89,6 +100,7 @@ class ProductionPlanImporter extends Importer
{
$warnMsg = [];
$plantCod = $this->data['plant'];
$itemCod = $this->data['item'];
$plant = null;
$line = null;
$block = null;
@@ -103,113 +115,52 @@ class ProductionPlanImporter extends Importer
$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';
} elseif ($plant) {
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) {
$warnMsg[] = 'Invalid item code found';
} else {
$item = Item::where('code', $itemCod)->first();
}
// $shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
if (! $shift) {
$warnMsg[] = 'Shift not found';
if (! $item) {
$warnMsg[] = 'Item not found';
}
$plantId = $plant->id;
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first();
if(!$itemAgaPlant){
$warnMsg[] = 'Item not found against plant code';
}
$user = Filament::auth()->user();
$operatorName = $user->name;
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))
} else {
$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)
->where('item_id', $itemAgaPlant->id)
->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'],
'operator_id' => $operatorName,
]);
$productionPlan->save();
@@ -220,21 +171,15 @@ class ProductionPlanImporter extends Importer
ProductionPlan::updateOrCreate([
'plant_id' => $plant->id,
'line_id' => $line->id,
'shift_id' => $shift->id,
'item_id' => $itemAgaPlant->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'],
'created_at' =>now(),
'updated_at' => now(),
'operator_id' => $operatorName,
]);
return null;
// return ProductionPlan::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
// return new ProductionPlan();
}
public static function getCompletedNotificationBody(Import $import): string

View File

@@ -205,7 +205,7 @@ class StickerMasterImporter extends Importer
} else {
$itemId = $item->id;
if (! $laserPart1) {
if (! $laserPart1 && ! (Str::length($laserPart2) == 1 && is_numeric($laserPart2))) {
$laserPart1 = $laserPart2;
$laserPart2 = null;
}

View File

@@ -0,0 +1,171 @@
<?php
namespace App\Filament\Pages;
use App\Models\CustomerPoMaster;
use App\Models\Plant;
use App\Models\ProductionPlan;
use App\Models\WireMasterPacking;
use Filament\Facades\Filament;
use Filament\Pages\Page;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ViewField;
use Filament\Notifications\Notification;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Hidden;
use Illuminate\Support\Facades\Auth;
class ProductionCalender extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.production-calender';
protected static ?string $navigationGroup = 'Production';
use InteractsWithForms;
protected $listeners = ['setWorkingDays'];
public $pId;
public array $filters = [];
public function setWorkingDays($days = null)
{
$this->form->fill([
'working_days' => $days ?? 0,
]);
}
public function form(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Section::make('')
->schema([
Select::make('plant_id')
->label('Plant')
->reactive()
//->options(Plant::pluck('name', 'id'))
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->columnSpan(['default' => 10, 'sm' => 7])
->required()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('working_days', null);
}),
TextInput::make('working_days')
->label('No. of Working Days')
->numeric()
->readOnly()
->columnSpan(['default' => 10, 'sm' => 2])
->required()
->minValue(0)
->maxValue(31)
->placeholder('Enter working days')
->id('working_days'),
Hidden::make('month')
->label('Month')
->id('month'),
Hidden::make('year')
->label('Year')
->id('year'),
Hidden::make('selected_dates')
->label('Selected Dates')
->id('selected_dates'),
ViewField::make('save')
->view('forms.save')
->columnSpan(['default' => 10, 'sm' => 1]),
ViewField::make('calendar')
->view('forms.calendar')
->columnspan(10),
])
->columns(10)
]);
}
public function saveWorkingDays(){
$plantId = $this->filters['plant_id'] ?? null;
$workingDays = $this->filters['working_days'] ?? null;
$month = $this->filters['month'] ?? null;
$year = $this->filters['year'] ?? null;
$dates = $this->filters['selected_dates'] ?? null;
if (!$plantId) {
Notification::make()
->title('Unknown Plant')
->body("Please select a plant first!")
->danger()
->send();
return;
}
else if (!$workingDays) {
Notification::make()
->title('Unknown Working Days')
->body("Working days can't be empty!")
->danger()
->send();
return;
}
else if (!$month) {
Notification::make()
->title('Unknown Month')
->body("month can't be empty!")
->danger()
->send();
return;
}
else if (!$year) {
Notification::make()
->title('Unknown Year')
->body("Year can't be empty!")
->danger()
->send();
return;
}
$updated = ProductionPlan::where('plant_id', $plantId)
->whereMonth('created_at', $month)
->whereYear('created_at', $year)
->update([
'working_days' => $workingDays,
'leave_dates' => $dates,
'updated_at' => now(),
]);
if ($updated) {
Notification::make()
->title('Success')
->body("Working days updated successfully!")
->success()
->send();
} else {
Notification::make()
->title('No Records Updated')
->body("No production plans found for this plant and month.")
->warning()
->send();
}
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production calender page');
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,191 @@
<?php
namespace App\Filament\Pages;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms\Components\DatePicker;
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;
use Illuminate\Support\Facades\Auth;
class ProductionTarget extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.production-target';
protected static ?string $navigationGroup = 'Production';
public array $filters = [];
public function form(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Section::make('')
->schema([
Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
// ->searchable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->required()
->afterStateUpdated(function ($state, callable $get, $set) {
// dd($state);
$set('line_id', null);
$set('year', null);
$set('month', null);
$this->dispatch('loadData',$state, '', '', '');
}),
Select::make('line_id')
->label('Line')
->required()
->relationship('line', 'name')
// ->searchable()
->columnSpan(1)
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
return \App\Models\Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $get, $set) {
$plantId = $get('plant_id');
$set('year', null);
$set('month', null);
$this->dispatch('loadData',$plantId, $state, '', '');
}),
Select::make('year')
->label('Year')
->reactive()
// ->searchable()
->options([
'2025' => '2025',
'2026' => '2026',
'2027' => '2027',
'2028' => '2028',
'2029' => '2029',
'2030' => '2030',
'2031' => '2031',
'2032' => '2032',
'2033' => '2033',
'2034' => '2034',
'2035' => '2035',
'2036' => '2036',
'2037' => '2037',
'2038' => '2038',
'2039' => '2039',
'2040' => '2040',
])
->required()
->afterStateUpdated(function ($state, callable $get, $set) {
$set('month', null);
$plantId = $get('plant_id');
$lineId = $get('line_id');
$this->dispatch('loadData',$plantId, $lineId, $state, '');
}),
Select::make('month')
->label('Month')
->reactive()
// ->searchable()
->options([
'01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'September',
'10' => 'October',
'11' => 'November',
'12' => 'December',
])
->required()
->afterStateUpdated(function ($state, callable $get) {
$plantId = $get('plant_id');
$lineId = $get('line_id');
// $month = $get('month');
$year = $get('year');
$month = (int) $get('month');
if (!$month) {
return;
}
$this->dispatch('loadData', $plantId, $lineId, $month, $year);
}),
])
->columns(4)
]);
}
public function export(){
$plantId = $this->filters['plant_id'] ?? null;
$lineId = $this->filters['line_id'] ?? null;
$year = $this->filters['year'] ?? null;
$month = $this->filters['month'] ?? null;
if (! $plantId) {
Notification::make()
->title('Plant')
->body("please select plant to export data..!")
->danger()
->send();
return;
}
else if (! $lineId) {
Notification::make()
->title('Line')
->body("please select line to export data..!")
->danger()
->send();
return;
}
else if (! $year) {
Notification::make()
->title('Year')
->body("please select year to export data..!")
->danger()
->send();
return;
}
else if (! $month) {
Notification::make()
->title('Month')
->body("please select month to export data..!")
->danger()
->send();
return;
}
$this->dispatch('loadData1' ,$plantId, $lineId, $year, $month);
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production target page');
}
}

View File

@@ -5,155 +5,152 @@ namespace App\Filament\Resources;
use App\Filament\Exports\AlertMailRuleExporter;
use App\Filament\Imports\AlertMailRuleImporter;
use App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
use App\Models\AlertMailRule;
use App\Models\InvoiceMaster;
use App\Models\Plant;
use Dotenv\Exception\ValidationException;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
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 Filament\Forms\Components\Section;
use Filament\Forms\Components\Actions\Action;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException as ValidationValidationException;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class AlertMailRuleResource extends Resource
{
protected static ?string $model = AlertMailRule::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-m-bell-alert';
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(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->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',
'InvoiceDataReport' => 'InvoiceDataReport',
'ProductionQuantities' => 'ProductionQuantities',
'QualityValidation' => 'QualityValidation',
'InvoiceTransit' => 'InvoiceTransit',
]),
Forms\Components\Select::make('rule_name')
->label('Rule Name')
->options([
'InvoiceMail' => 'Invoice Mail',
'SerialInvoiceMail' => 'Serial Invoice Mail',
'MaterialInvoiceMail' => 'Material Invoice Mail',
'ProductionMail' => 'Production Mail',
'InvoiceDataMail' => 'Invoice Data Mail',
'QualityMail' => 'Quality Mail',
'InvoiceTransitMail' => 'Invoice Transit Mail',
Section::make('')
->schema([
Forms\Components\Select::make('plant')
->label('Plant')
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->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',
'InvoiceDataReport' => 'InvoiceDataReport',
'ProductionQuantities' => 'ProductionQuantities',
'QualityValidation' => 'QualityValidation',
'InvoiceTransit' => 'InvoiceTransit',
]),
Forms\Components\Select::make('rule_name')
->label('Rule Name')
->options([
'InvoiceMail' => 'Invoice Mail',
'SerialInvoiceMail' => 'Serial Invoice Mail',
'MaterialInvoiceMail' => 'Material Invoice Mail',
'ProductionMail' => 'Production Mail',
'InvoiceDataMail' => 'Invoice Data Mail',
'QualityMail' => 'Quality Mail',
'InvoiceTransitMail' => 'Invoice Transit Mail',
])
->required(),
Forms\Components\TextInput::make('email')
->label('Email')
->required(),
Forms\Components\Textarea::make('cc_emails')
->label('CC Emails'),
Forms\Components\Select::make('schedule_type')
->label('Schedule Type')
->options([
'Live' => 'Live',
'Hourly' => 'Hourly',
'Daily' => 'Daily',
]),
Forms\Components\Select::make('receiving_plant_name')
->label('Receiving Plant')
->options(
InvoiceMaster::query()
->whereNotNull('receiving_plant_name')
->select('receiving_plant_name')
->distinct()
->pluck('receiving_plant_name', 'receiving_plant_name')
)
->searchable()
->reactive()
->afterStateUpdated(function (callable $set) {
$set('invoice_master_id', null);
}),
Forms\Components\Select::make('invoice_master_id')
->label('Transporter Name')
->options(function (callable $get) {
$recPlant = $get('receiving_plant_name');
if (! $recPlant) {
return [];
}
return InvoiceMaster::query()
->where('receiving_plant_name', $recPlant)
->whereNotNull('transport_name')
->where('transport_name', '!=', '')
->orderBy('transport_name')
->pluck('transport_name', 'id')
->toArray();
})
->searchable(),
Checkbox::make('is_active')
->label('All Plants Reports')
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
->reactive(),
// Forms\Components\Actions::make([
// Action::make('sendInvoiceData')
// ->label('Invoice Data Report')
// ->action(function ($get) {
// $plantIds = AlertMailRule::where('module', 'InvoiceDataReport')
// ->orderBy('plant')
// ->pluck('plant')
// ->toArray();
// foreach ($plantIds as $plantId) {
// Artisan::call('send:invoice-data-report', [
// 'schedule_type' => 'Daily',
// 'plant' => $plantId,
// ]);
// }
// // Notify user in Filament
// Notification::make()
// ->title('Invoice data report sent successfully!')
// ->success()
// ->send();
// }),
// ]),
Forms\Components\Hidden::make('created_by')
->default(fn () => Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->default(fn () => Filament::auth()->user()?->name),
])
->required(),
Forms\Components\TextInput::make('email')
->label('Email')
->required(),
Forms\Components\Textarea::make('cc_emails')
->label('CC Emails'),
Forms\Components\Select::make('schedule_type')
->label('Schedule Type')
->options([
'Live' => 'Live',
'Hourly' => 'Hourly',
'Daily' => 'Daily',
]),
Forms\Components\Select::make('receiving_plant_name')
->label('Receiving Plant')
->options(
InvoiceMaster::query()
->whereNotNull('receiving_plant_name')
->select('receiving_plant_name')
->distinct()
->pluck('receiving_plant_name', 'receiving_plant_name')
)
->searchable()
->reactive()
->afterStateUpdated(function (callable $set) {
$set('invoice_master_id', null);
}),
Forms\Components\Select::make('invoice_master_id')
->label('Transporter Name')
->options(function (callable $get) {
$recPlant = $get('receiving_plant_name');
if (! $recPlant) {
return [];
}
return InvoiceMaster::query()
->where('receiving_plant_name', $recPlant)
->whereNotNull('transport_name')
->where('transport_name', '!=', '')
->orderBy('transport_name')
->pluck('transport_name', 'id')
->toArray();
})
->searchable(),
Checkbox::make('is_active')
->label('All Plants Reports')
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
->reactive(),
// Forms\Components\Actions::make([
// Action::make('sendInvoiceData')
// ->label('Invoice Data Report')
// ->action(function ($get) {
// $plantIds = AlertMailRule::where('module', 'InvoiceDataReport')
// ->orderBy('plant')
// ->pluck('plant')
// ->toArray();
// foreach ($plantIds as $plantId) {
// Artisan::call('send:invoice-data-report', [
// 'schedule_type' => 'Daily',
// 'plant' => $plantId,
// ]);
// }
// // Notify user in Filament
// Notification::make()
// ->title('Invoice data report sent successfully!')
// ->success()
// ->send();
// }),
// ]),
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(2),
]);
->columns(2),
]);
}
public static function table(Table $table): Table
@@ -166,6 +163,7 @@ class AlertMailRuleResource extends Resource
$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')
@@ -178,6 +176,7 @@ class AlertMailRuleResource extends Resource
if (! $plants) {
$plants = Plant::pluck('name', 'id')->toArray();
}
return $plants[$state] ?? 'All Plants';
}),
Tables\Columns\TextColumn::make('module')
@@ -260,14 +259,14 @@ class AlertMailRuleResource extends Resource
->label('Import Alert Mail Rule')
->color('warning')
->importer(AlertMailRuleImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import alert mail rule');
}),
ExportAction::make()
->label('Export Alert Mail Rule')
->color('warning')
->exporter(AlertMailRuleExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export alert mail rule');
}),
]);

View File

@@ -9,16 +9,16 @@ use App\Models\Block;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
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 Filament\Forms\Components\Section;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule;
class BlockResource extends Resource
@@ -46,12 +46,11 @@ class BlockResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('name');
// Ensure `linestop_id` is not cleared
if (!$nameId) {
if (! $nameId) {
$set('bNameError', 'Scan the valid name.');
return;
}
else
{
} else {
$set('bNameError', null);
}
})
@@ -72,21 +71,21 @@ class BlockResource extends Resource
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Block::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('plant_id');
// Ensure `linestop_id` is not cleared
if (!$nameId) {
if (! $nameId) {
$set('bPlantError', 'Please select a plant first.');
return;
}
else
{
} else {
$set('bPlantError', null);
}
})
@@ -98,7 +97,7 @@ class BlockResource extends Resource
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
])
->columns(2),
]);
}
@@ -117,10 +116,11 @@ class BlockResource extends Resource
$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)
// ->unique(ignoreRecord: true)
->label('Block')
->alignCenter()
->sortable()
@@ -167,14 +167,14 @@ class BlockResource extends Resource
->label('Import Blocks')
->color('warning')
->importer(BlockImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import block');
}),
ExportAction::make()
->label('Export Blocks')
->color('warning')
->exporter(BlockExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export block');
}),
]);

View File

@@ -6,6 +6,7 @@ use App\Filament\Exports\CharacteristicApproverMasterExporter;
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
use App\Models\CharacteristicApproverMaster;
use App\Models\Machine;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
@@ -33,26 +34,38 @@ class CharacteristicApproverMasterResource extends Resource
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->columnSpan(2)
->reactive()
->label('Plant Name')
->relationship('plant', 'name')
->columnSpan(1)
->reactive()
->searchable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required()
->default(function () {
return optional(CharacteristicApproverMaster::latest()->first())->plant_id;
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : optional(CharacteristicApproverMaster::latest()->first())->plant_id ?? null;
})
->afterStateUpdated(function ($state, callable $set) {
$set('machine_id', null);
$set('machine_name', null);
$set('approver_type', null);
$set('characteristic_field', null);
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\Select::make('machine_id')
->label('Work Center')
->columnSpan(2)
->columnSpan(1)
// ->relationship('machine', 'name')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
if (! $plantId) {
return [];
}
@@ -60,30 +73,76 @@ class CharacteristicApproverMasterResource extends Resource
})
->required()
->default(function () {
return optional(CharacteristicApproverMaster::latest()->first())->machine_id ?? [];
return optional(CharacteristicApproverMaster::latest()->first())->machine_id ?? null;
})
->afterStateUpdated(function ($state, callable $set) {
$set('machine_name', null);
$set('approver_type', null);
$set('characteristic_field', null);
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('machine_name')
->label('Machine')
->columnSpan(2)
->columnSpan(1)
->reactive()
->required()
->minLength(5)
->default(function () {
return optional(CharacteristicApproverMaster::latest()->first())->machine_name ?? '';
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : optional(CharacteristicApproverMaster::latest()->first())->machine_name ?? null;
})
->afterStateUpdated(function ($state, callable $set) {
if (! $state) {
$set('approver_type', null);
$set('characteristic_field', null);
}
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\Select::make('approver_type')
->label('Request Type')
->columnSpan(1)
->reactive()
->nullable()
->searchable()
->required()
->options(function (callable $set, callable $get) {
$plantId = $get('plant_id');
$machineId = $get('machine_id');
$machineName = $get('machine_name');
if (! $plantId || ! $machineId || ! $machineName) {
$set('characteristic_field', null);
return [];
}
return [
'Characteristic' => 'Characteristic',
'Quality' => 'Quality',
];
})
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic';
// return optional(CharacteristicApproverMaster::latest()->first())->approver_type ?? null;
})
->afterStateUpdated(function ($state, callable $set) {
$set('characteristic_field', null);
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('characteristic_field')
->label('Master Characteristic Field')
->columnSpan(2)
->columnSpan(4)
->reactive()
->required()
->minLength(1)
->default('NIL')
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : 'NIL';
})
->afterStateUpdated(function ($state, callable $set) {
if (strtolower($state) == 'nil' || $state == '' || $state == null) {
$set('characteristic_field', 'NIL');
@@ -233,6 +292,11 @@ class CharacteristicApproverMasterResource extends Resource
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('approver_type')
->label('Approver Type')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('characteristic_field')
->label('Master Characteristic Field')
->alignCenter()

View File

@@ -10,6 +10,7 @@ use App\Models\Item;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use App\Models\ProductCharacteristicsMaster;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\DateTimePicker;
@@ -24,6 +25,8 @@ use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
use Str;
class CharacteristicValueResource extends Resource
{
@@ -39,18 +42,29 @@ class CharacteristicValueResource extends Resource
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->searchable()
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(CharacteristicValue::latest()->first())->plant_id;
})
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('item_id', null);
$set('line_id', null);
$set('item_id', null);
$set('machine_id', null);
$set('process_order', null);
$set('coil_number', null);
$set('observed_value', null);
$set('status', 'NotOk');
$set('updated_by', Filament::auth()->user()?->name);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
}
@@ -63,6 +77,7 @@ class CharacteristicValueResource extends Resource
->required(),
Forms\Components\Select::make('line_id')
->label('Line')
->searchable()
->options(function (callable $get) {
if (! $get('plant_id')) {
return [];
@@ -76,7 +91,13 @@ class CharacteristicValueResource extends Resource
$plantId = $get('plant_id');
$set('item_id', null);
$set('machine_id', null);
$set('process_order', null);
$set('coil_number', null);
$set('observed_value', null);
$set('status', 'NotOk');
$set('updated_by', Filament::auth()->user()?->name);
if (! $plantId) {
$set('line_id', null);
$set('poPlantError', 'Please select a plant first.');
}
})
@@ -84,6 +105,7 @@ class CharacteristicValueResource extends Resource
->required(),
Forms\Components\Select::make('item_id')
->label('Item')
->searchable()
->options(function (callable $get) {
if (! $get('plant_id') || ! $get('line_id')) {
return [];
@@ -96,15 +118,21 @@ class CharacteristicValueResource extends Resource
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('machine_id', null);
$set('process_order', null);
$set('coil_number', null);
$set('observed_value', null);
$set('status', 'NotOk');
$set('updated_by', Filament::auth()->user()?->name);
if (! $plantId) {
$set('item_id', null);
$set('poPlantError', 'Please select a plant first.');
}
})
->reactive()
->required()
->searchable(),
->required(),
Forms\Components\Select::make('machine_id')
->label('Machine')
->searchable()
->options(function (callable $get) {
if (! $get('plant_id') || ! $get('line_id') || ! $get('item_id')) {
return [];
@@ -119,8 +147,11 @@ class CharacteristicValueResource extends Resource
$plantId = $get('plant_id');
$set('process_order', null);
$set('coil_number', null);
$set('status', null);
$set('observed_value', null);
$set('status', 'NotOk');
$set('updated_by', Filament::auth()->user()?->name);
if (! $plantId) {
$set('machine_id', null);
$set('poPlantError', 'Please select a plant first.');
}
})
@@ -132,8 +163,11 @@ class CharacteristicValueResource extends Resource
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$set('coil_number', null);
$set('status', null);
$set('observed_value', null);
$set('status', 'NotOk');
$set('updated_by', Filament::auth()->user()?->name);
if (! $plantId) {
$set('process_order', null);
$set('poPlantError', 'Please select a plant first.');
}
})
@@ -143,7 +177,7 @@ class CharacteristicValueResource extends Resource
// ->reactive()
// ->afterStateUpdated(function ($state, $set, callable $get) {
// $plantId = $get('plant_id');
// $set('status', null);
// $set('status', 'NotOk');
// if (! $plantId) {
// $set('poPlantError', 'Please select a plant first.');
// }
@@ -151,49 +185,119 @@ class CharacteristicValueResource extends Resource
// ->required(),
->label('Coil Number')
->default('0')
->numeric()
->reactive()
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$processOrder = $get('process_order');
$coilNo = $get('coil_number');
// $coilNo = $get('coil_number');
$set('poPlantError', null);
$set('observed_value', null);
$set('status', 'NotOk');
$set('coilNumberError', null);
$set('updated_by', Filament::auth()->user()?->name);
if (! $plantId) {
$set('coil_number', null);
$set('poPlantError', 'Please select a plant first.');
} elseif (! $processOrder) {
$set('coil_number', null);
$set('poPlantError', null);
} elseif ($coilNo || $coilNo == '0') {
$existing = CharacteristicValue::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if ($existing) {
$set('poPlantError', null);
$set('coil_number', null);
$set('coilNumberError', "Duplicate Coil : '{$coilNo}' found!");
} else {
$set('poPlantError', null);
$set('coilNumberError', null);
}
}
// elseif ($coilNo || $coilNo == '0') {
// $existing = CharacteristicValue::where('plant_id', $plantId)
// ->where('process_order', $processOrder)
// ->where('coil_number', $coilNo)
// ->first();
// if ($existing && ! $get('id')) {
// // $set('coil_number', null);
// $set('coilNumberError', "Duplicate Coil : '{$coilNo}' found!");
// } else {
// $set('coilNumberError', null);
// }
// }
})
->extraAttributes(fn ($get) => [
'class' => $get('coilNumberError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('coilNumberError') ? $get('coilNumberError') : null)
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('characteristic_values', 'coil_number')
->where('plant_id', $get('plant_id'))
->where('process_order', $get('process_order'))
->ignore($get('id')); // Ignore current record during updates
})
->required(),
Forms\Components\TextInput::make('observed_value')
->label('Observed Value')
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
$lineId = $get('line_id');
$machineId = $get('machine_id');
$set('updated_by', Filament::auth()->user()?->name);
if (! $plantId || ! $itemId || ! $lineId || ! $machineId) {
$set('observed_value', null);
$set('status', 'NotOk');
return;
}
if (Str::length($state) <= 0 || ! is_numeric($state) || ! preg_match('/^\d+(\.\d+)?$/', $state)
) {
$set('status', 'NotOk');
return;
}
$specVal = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $itemId)->where('line_id', $lineId)->where('machine_id', $machineId)->first();
if (! $specVal) {
$set('status', 'NotOk');
return;
}
$lowLimit = $specVal?->lower ?? 0;
$uppLimit = $specVal?->upper ?? 0;
if (Str::length($lowLimit) <= 0 || ! is_numeric($lowLimit) || ! preg_match('/^\d+(\.\d+)?$/', $lowLimit)
) {
$set('status', 'NotOk');
return;
} elseif (Str::length($uppLimit) <= 0 || ! is_numeric($uppLimit) || ! preg_match('/^\d+(\.\d+)?$/', $uppLimit)
) {
$set('status', 'NotOk');
return;
}
if (($lowLimit == 0 && $uppLimit == 0) || ($uppLimit == 0)) {
$set('status', 'NotOk');
return;
}
if ($lowLimit > $state || $uppLimit < $state) {
$set('status', 'NotOk');
return;
}
$set('status', 'Ok');
})
->required(),
Forms\Components\Select::make('status')
Forms\Components\TextInput::make('status')// Select
->label('Status')
->options([
'Ok' => 'OK',
'NotOk' => 'Not Ok',
])
// ->options([
// 'Ok' => 'OK',
// 'NotOk' => 'Not Ok',
// ])
->reactive()
->default('NotOk')
->readOnly()
->required(),
Forms\Components\Hidden::make('created_by')
->label('Created By')
@@ -201,6 +305,9 @@ class CharacteristicValueResource extends Resource
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]);
}
@@ -228,7 +335,7 @@ class CharacteristicValueResource extends Resource
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item')
->label('Item Code')
->searchable()
->alignCenter()
->sortable(),
@@ -247,6 +354,17 @@ class CharacteristicValueResource extends Resource
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('machine.name')
->label('Spec. Value')
// ->searchable()
->formatStateUsing(function ($record) {
$specVal = ProductCharacteristicsMaster::where('plant_id', $record->plant_id)->where('item_id', $record->item_id)->where('line_id', $record->line_id)->where('machine_id', $record->machine_id)->first();
// return $record?->plant_id.'-'.$record?->item_id.'-'.$record->line_id.'-'.$record?->machine_id;
return $specVal?->lower.' - '.$specVal?->upper;
})
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('observed_value')
->label('Observed value')
->searchable()
@@ -255,25 +373,39 @@ class CharacteristicValueResource extends Resource
Tables\Columns\TextColumn::make('status')
->label('Status')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
// ->formatStateUsing(function ($record) {
// return empty($record->status == 'Ok') ? 'Ok' : 'Not Ok';
// })
->color(fn (string $state): string => match ($state) {
'Ok' => 'success',
'Not Ok' => 'danger',
'NotOk' => 'danger',
default => 'gray',
})
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->searchable()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
@@ -285,7 +417,6 @@ class CharacteristicValueResource extends Resource
// Tables\Filters\TrashedFilter::make(),
// ])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
@@ -296,7 +427,7 @@ class CharacteristicValueResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -5,7 +5,6 @@ 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 App\Models\Plant;
use Filament\Facades\Filament;
@@ -42,20 +41,20 @@ class CheckPointNameResource extends Resource
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(CheckPointName::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
if (! $plantId) {
$set('cPnPlantError', 'Please select a plant first.');
return;
}
else
{
} else {
$set('cPnPlantError', null);
$set('created_by', Filament::auth()->user()?->name);
}
@@ -100,6 +99,7 @@ class CheckPointNameResource extends Resource
$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')
@@ -156,14 +156,14 @@ class CheckPointNameResource extends Resource
->label('Import Check Point Names')
->color('warning')
->importer(CheckPointNameImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import check point name');
}),
ExportAction::make()
->label('Export Check Point Names')
->color('warning')
->exporter(CheckPointNameExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export check point name');
}),
]);

View File

@@ -5,7 +5,6 @@ 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 App\Models\Plant;
@@ -43,20 +42,20 @@ class CheckPointTimeResource extends Resource
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
if (! $plantId) {
$set('cPtPlantError', 'Please select a plant first.');
return;
}
else
{
} else {
$set('cPtPlantError', null);
$set('created_by', Filament::auth()->user()?->name);
}
@@ -78,17 +77,17 @@ class CheckPointTimeResource extends Resource
})
->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'))
->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) {
if (! $plantId) {
return [];
}
@@ -101,19 +100,19 @@ class CheckPointTimeResource extends Resource
->default(function () {
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point1_id;
})
->disabled(fn (Get $get) => !empty($get('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) {
if (! $checkPoint1) {
$set('cPtCheckPoint1Error', 'Please select a check point 1 first.');
return;
}
else
{
} else {
if ($checkPoint2 && $checkPoint1 == $checkPoint2) {
$set('cPtCheckPoint1Error', 'Duplicate check point 2 found.');
$set('check_point2_id', null);
return;
}
$set('cPtCheckPoint1Error', null);
@@ -131,7 +130,7 @@ class CheckPointTimeResource extends Resource
// ->relationship('checkPointNames', 'name')
->options(function (callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
if (! $plantId) {
return [];
}
@@ -144,19 +143,19 @@ class CheckPointTimeResource extends Resource
->default(function () {
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point2_id;
})
->disabled(fn (Get $get) => !empty($get('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) {
if (! $checkPoint2) {
$set('cPtCheckPoint2Error', 'Please select a check point 2 first.');
return;
}
else
{
} else {
if ($checkPoint1 && $checkPoint1 == $checkPoint2) {
$set('cPtCheckPoint2Error', 'Duplicate check point 2 found.');
$set('check_point2_id', null);
return;
}
$set('cPtCheckPoint1Error', null);
@@ -185,32 +184,30 @@ class CheckPointTimeResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) {
$timeLapse = $state;
$timeLapseCushioning = $get('time_lapse_cushioning');
if (!$timeLapse) {
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)
{
} 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) {
} 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
{
} else {
$set('cPtTimeLapseError', null);
$set('cPtTimeLapseCushError', null);
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
@@ -233,32 +230,30 @@ class CheckPointTimeResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) {
$timeLapse = $get('time_lapse');
$timeLapseCushioning = $state;
if (!$timeLapse) {
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)
{
} 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) {
} 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
{
} else {
$set('cPtTimeLapseError', null);
$set('cPtTimeLapseCushError', null);
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
@@ -308,6 +303,7 @@ class CheckPointTimeResource extends Resource
$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')
@@ -387,14 +383,14 @@ class CheckPointTimeResource extends Resource
->label('Import Check Point Times')
->color('warning')
->importer(CheckPointTimeImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import check point time');
}),
ExportAction::make()
->label('Export Check Point Times')
->color('warning')
->exporter(CheckPointTimeExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export check point time');
}),
]);

View File

@@ -37,7 +37,7 @@ class ClassCharacteristicResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\Select::make('item_id')

View File

@@ -5,7 +5,6 @@ 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 App\Models\Plant;
@@ -15,18 +14,20 @@ 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 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
@@ -40,20 +41,20 @@ class ConfigurationResource extends Resource
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Configuration::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
if (! $plantId) {
$set('cPlantError', 'Please select a plant first.');
return;
}
else
{
} else {
$set('cPlantError', null);
}
})
@@ -68,7 +69,7 @@ class ConfigurationResource extends Resource
->required()
->reactive()
->options(function (callable $get) {
if (!$get('plant_id')) {
if (! $get('plant_id')) {
return [];
}
@@ -79,15 +80,14 @@ class ConfigurationResource extends Resource
->default(function () {
return optional(Configuration::latest()->first())->line_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$lineId = $get('line_id');
if (!$lineId) {
if (! $lineId) {
$set('cLineError', 'Please select a line first.');
return;
}
else
{
} else {
$set('cLineError', null);
}
})
@@ -124,6 +124,7 @@ class ConfigurationResource extends Resource
$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')
@@ -186,14 +187,14 @@ class ConfigurationResource extends Resource
->label('Import Configurations')
->color('warning')
->importer(ConfigurationImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import configuration');
}),
ExportAction::make()
->label('Export Configurations')
->color('warning')
->exporter(ConfigurationExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export configuration');
}),
]);

View File

@@ -5,53 +5,54 @@ namespace App\Filament\Resources;
use App\Filament\Exports\DeviceMasterExporter;
use App\Filament\Imports\DeviceMasterImporter;
use App\Filament\Resources\DeviceMasterResource\Pages;
use App\Filament\Resources\DeviceMasterResource\RelationManagers;
use App\Models\DeviceMaster;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class DeviceMasterResource extends Resource
{
protected static ?string $model = DeviceMaster::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Power House';
protected static ?string $navigationGroup = 'Power House';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\TextInput::make('name')
->label('Device Name')
->required(),
Forms\Components\TextInput::make('mac_address')
->label('MAC Address'),
Forms\Components\TextInput::make('ip_address')
->label('IP Address'),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
])
->columns(4),
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\TextInput::make('name')
->label('Device Name')
->required(),
Forms\Components\TextInput::make('mac_address')
->label('MAC Address'),
Forms\Components\TextInput::make('ip_address')
->label('IP Address'),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
])
->columns(4),
]);
}
@@ -65,6 +66,7 @@ class DeviceMasterResource extends Resource
$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')
@@ -120,14 +122,14 @@ class DeviceMasterResource extends Resource
->label('Import Device Masters')
->color('warning')
->importer(DeviceMasterImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import device master');
}),
ExportAction::make()
->label('Export Device Masters')
->color('warning')
->exporter(DeviceMasterExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export device master');
}),
]);

View File

@@ -39,7 +39,7 @@ class EbReadingResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\TextInput::make('lcd_segment_check')
@@ -336,7 +336,7 @@ class EbReadingResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -5,25 +5,24 @@ namespace App\Filament\Resources;
use App\Filament\Exports\EquipmentMasterExporter;
use App\Filament\Imports\EquipmentMasterImporter;
use App\Filament\Resources\EquipmentMasterResource\Pages;
use App\Filament\Resources\EquipmentMasterResource\RelationManagers;
use App\Models\EquipmentMaster;
use App\Models\Plant;
use Carbon\Carbon;
use Filament\Forms\Components\Actions\Action;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
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 Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Storage;
use Illuminate\Validation\Rule;
class EquipmentMasterResource extends Resource
{
@@ -45,11 +44,12 @@ class EquipmentMasterResource extends Resource
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\Select::make('machine_id')
//->relationship('machine', 'name')
// ->relationship('machine', 'name')
->label('Work Center')
->reactive()
->options(function (callable $get) {
@@ -57,6 +57,7 @@ class EquipmentMasterResource extends Resource
if (empty($plantId)) {
return [];
}
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
})
->required(),
@@ -93,19 +94,19 @@ class EquipmentMasterResource extends Resource
$set('attachment', null);
}
}),
//->afterStateUpdated(function ($state, callable $set) {
// if (! $state) {
// return;
// }
// ->afterStateUpdated(function ($state, callable $set) {
// if (! $state) {
// return;
// }
// $model = EquipmentMaster::where('equipment_number', $state)->first();
// $model = EquipmentMaster::where('equipment_number', $state)->first();
// if ($model?->attachment) {
// $set('attachment', $model->attachment);
// } else {
// $set('attachment', null);
// }
// }),
// if ($model?->attachment) {
// $set('attachment', $model->attachment);
// } else {
// $set('attachment', null);
// }
// }),
Forms\Components\TextInput::make('instrument_serial_number')
->label('Instrument Serial Number'),
// Forms\Components\DateTimePicker::make('calibrated_on')
@@ -128,17 +129,17 @@ class EquipmentMasterResource extends Resource
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
$set('next_calibration_date', $nextDate);
}),
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
// $frequency = (int) $get('frequency');
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
// $frequency = (int) $get('frequency');
// if ($state && $frequency != 0) {
// $calibratedOn = $state instanceof Carbon ? $state : Carbon::parse($state);
// $nextDate = $calibratedOn->copy()->addDays($frequency);
// $set('next_calibration_date', $nextDate);
// } else {
// $set('next_calibration_date', null);
// }
// }),
// if ($state && $frequency != 0) {
// $calibratedOn = $state instanceof Carbon ? $state : Carbon::parse($state);
// $nextDate = $calibratedOn->copy()->addDays($frequency);
// $set('next_calibration_date', $nextDate);
// } else {
// $set('next_calibration_date', null);
// }
// }),
Forms\Components\TextInput::make('frequency')
->label('Frequency (days)')
@@ -152,20 +153,20 @@ class EquipmentMasterResource extends Resource
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
$set('next_calibration_date', $nextDate);
}),
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
// $calibratedOn = $get('calibrated_on');
// $frequency = (int) $state;
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
// $calibratedOn = $get('calibrated_on');
// $frequency = (int) $state;
// if ($calibratedOn && $frequency !== 0) {
// $calibratedOn = $calibratedOn instanceof Carbon ? $calibratedOn : Carbon::parse($calibratedOn);
// $nextDate = $calibratedOn->copy()->addDays($frequency);
// $set('next_calibration_date', $nextDate);
// }
// else
// {
// $set('next_calibration_date', null);
// }
// }),
// if ($calibratedOn && $frequency !== 0) {
// $calibratedOn = $calibratedOn instanceof Carbon ? $calibratedOn : Carbon::parse($calibratedOn);
// $nextDate = $calibratedOn->copy()->addDays($frequency);
// $set('next_calibration_date', $nextDate);
// }
// else
// {
// $set('next_calibration_date', null);
// }
// }),
Forms\Components\DateTimePicker::make('next_calibration_date')
->label('Next Calibration Date')
@@ -266,7 +267,7 @@ class EquipmentMasterResource extends Resource
// }
// }
// }),
->action(function ($get, callable $set) {
->action(function ($get, callable $set) {
$uploadedFiles = $get('attachment');
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
@@ -285,16 +286,16 @@ class EquipmentMasterResource extends Resource
->title('PDF uploaded successfully')
->success()
->send();
return;
return;
}
}
else
{
} else {
Notification::make()
->title('No file selected to upload')
->warning()
->send();
return;
return;
}
}),
@@ -303,11 +304,12 @@ class EquipmentMasterResource extends Resource
->action(function ($get) {
$equipmentNumber = $get('equipment_number');
if (!$equipmentNumber) {
if (! $equipmentNumber) {
Notification::make()
->title('No equipment number entered')
->danger()
->send();
return;
}
@@ -321,18 +323,19 @@ class EquipmentMasterResource extends Resource
}
}
if (!$fileToDownload) {
if (! $fileToDownload) {
Notification::make()
->title('PDF not found for this equipment')
->danger()
->send();
return;
}
return response()->download(Storage::disk('local')->path($fileToDownload));
}),
])
->columns(2),
->columns(2),
Forms\Components\Hidden::make('created_by')
->label('Created By')
@@ -342,17 +345,17 @@ class EquipmentMasterResource extends Resource
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
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')
@@ -449,14 +452,14 @@ class EquipmentMasterResource extends Resource
->label('Import Equipment Masters')
->color('warning')
->importer(EquipmentMasterImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import equipment master');
}),
ExportAction::make()
->label('Export Equipment Masters')
->color('warning')
->exporter(EquipmentMasterExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export equipment master');
}),
]);
@@ -489,25 +492,22 @@ class EquipmentMasterResource extends Resource
protected static function calculateNextCalibrationDate(?string $startDateTime, ?string $durationDays): ?string
{
if (!$startDateTime || !$durationDays) {
if (! $startDateTime || ! $durationDays) {
return null;
}
try
{
try {
$startDateTimeCarbon = Carbon::parse($startDateTime);
$durationDays = str_replace(',', '.', $durationDays);
if(!is_numeric($durationDays))
{
if (! is_numeric($durationDays)) {
return null;
}
$nextCalibrationDate = $startDateTimeCarbon->addDays(floatval($durationDays));
return $nextCalibrationDate->format('Y-m-d H:i:s');
}
catch (\Exception $e)
{
} catch (\Exception $e) {
return null;
}
}

View File

@@ -5,33 +5,28 @@ namespace App\Filament\Resources;
use App\Filament\Exports\GrMasterExporter;
use App\Filament\Imports\GrMasterImporter;
use App\Filament\Resources\GrMasterResource\Pages;
use App\Filament\Resources\GrMasterResource\RelationManagers;
use App\Models\GrMaster;
use App\Models\Item;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
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 Filament\Notifications\Notification;
use Filament\Forms\Components\Actions\Action;
use Storage;
use Smalot\PdfParser\Parser;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule;
use thiagoalessio\TesseractOCR\TesseractOCR;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use setasign\Fpdi\Fpdi;
use setasign\Fpdi\PdfReader;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use Smalot\PdfParser\Parser;
use Storage;
use thiagoalessio\TesseractOCR\TesseractOCR;
class GrMasterResource extends Resource
{
@@ -39,6 +34,8 @@ class GrMasterResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Process Order';
public static function form(Form $form): Form
{
return $form
@@ -46,15 +43,17 @@ class GrMasterResource extends Resource
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->searchable()
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
//->relationship('item', 'id')
// ->relationship('item', 'id')
->reactive()
->searchable()
->options(function (callable $get) {
@@ -62,6 +61,7 @@ class GrMasterResource extends Resource
if (empty($plantId)) {
return [];
}
return Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->required(),
@@ -72,9 +72,9 @@ class GrMasterResource extends Resource
Forms\Components\TextInput::make('serial_number')
->label('Serial Number')
->rule(function (callable $get) {
return Rule::unique('gr_masters', 'serial_number')
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
return Rule::unique('gr_masters', 'serial_number')
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\FileUpload::make('attachment')
@@ -91,8 +91,7 @@ class GrMasterResource extends Resource
->action(function ($get, callable $set) {
$uploadedFiles = $get('attachment');
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
{
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
$uploaded = reset($uploadedFiles);
if ($uploaded instanceof TemporaryUploadedFile) {
@@ -100,8 +99,8 @@ class GrMasterResource extends Resource
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
// $originalName = $uploaded->getClientOriginalName();
// $path = 'uploads/GRNumber/' . $originalName;
$finalFileName = $safeName . '.pdf';
$finalPath = 'uploads/GRNumber/' . $finalFileName;
$finalFileName = $safeName.'.pdf';
$finalPath = 'uploads/GRNumber/'.$finalFileName;
if (Storage::disk('local')->exists($finalPath)) {
Notification::make()
@@ -109,6 +108,7 @@ class GrMasterResource extends Resource
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
->warning()
->send();
return; // Stop here
}
@@ -118,15 +118,14 @@ class GrMasterResource extends Resource
'local'
);
// $fullPath = storage_path('app/' . $storedPath);
$fullPath = storage_path('app/private/' . $storedPath);
$parser = new Parser();
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
// $fullPath = storage_path('app/' . $storedPath);
$fullPath = storage_path('app/private/'.$storedPath);
$parser = new Parser;
// $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
$pdf = $parser->parseFile($fullPath);
$text = $pdf->getText();
//dd($text);
// dd($text);
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
$item1 = $matches[1];
@@ -136,8 +135,7 @@ class GrMasterResource extends Resource
// $item2 = $matches[1];
// dd($item2);
// }
else
{
else {
Notification::make()
->title('Item Code Not Found')
->body('Could not find Item code in uploaded PDF.')
@@ -147,6 +145,7 @@ class GrMasterResource extends Resource
if (Storage::disk('local')->exists($storedPath)) {
Storage::disk('local')->delete($storedPath);
}
return;
}
@@ -160,21 +159,19 @@ class GrMasterResource extends Resource
$plant = Plant::find($plant);
if ($item)
{
if ($item) {
$itemCode = $item->code;
}
else
{
} else {
$itemCode = null;
Notification::make()
->title('Item Not Found')
->body("Item not found in uploaded pdf.")
->body('Item not found in uploaded pdf.')
->warning()
->send();
if (Storage::disk('local')->exists($storedPath)) {
Storage::disk('local')->delete($storedPath);
}
return;
}
@@ -184,220 +181,219 @@ class GrMasterResource extends Resource
'local'
);
if($itemCode == $item1)
{
if ($itemCode == $item1) {
Notification::make()
->title('Success')
->body("Gr Number '$processOrder' PDF uploaded successfully.")
->success()
->send();
->title('Success')
->body("Gr Number '$processOrder' PDF uploaded successfully.")
->success()
->send();
return;
}
else
{
} else {
Notification::make()
->title('Item Code not matched')
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
->danger()
->send();
->title('Item Code not matched')
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
->danger()
->send();
if (Storage::disk('local')->exists($storedPath)) {
Storage::disk('local')->delete($storedPath);
}
return;
}
}
}
else
{
} else {
Notification::make()
->title('No file selected to upload')
->warning()
->send();
return;
return;
}
}),
// Action::make('uploadNow1')
// ->label('Upload OCR')
// ->action(function ($get, callable $set) {
// $uploadedFiles = $get('photo');
// Action::make('uploadNow1')
// ->label('Upload OCR')
// ->action(function ($get, callable $set) {
// $uploadedFiles = $get('photo');
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
// {
// $uploaded = reset($uploadedFiles);
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
// {
// $uploaded = reset($uploadedFiles);
// if ($uploaded instanceof TemporaryUploadedFile) {
// $grNumber = $get('gr_number');
// $safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
// // $originalName = $uploaded->getClientOriginalName();
// // $path = 'uploads/GRNumber/' . $originalName;
// $finalFileName = $safeName . '.jpg';
// $finalPath = 'uploads/OCR/' . $finalFileName;
// if ($uploaded instanceof TemporaryUploadedFile) {
// $grNumber = $get('gr_number');
// $safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
// // $originalName = $uploaded->getClientOriginalName();
// // $path = 'uploads/GRNumber/' . $originalName;
// $finalFileName = $safeName . '.jpg';
// $finalPath = 'uploads/OCR/' . $finalFileName;
// // if (Storage::disk('local')->exists($finalPath)) {
// // Notification::make()
// // ->title('Duplicate File')
// // ->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
// // ->warning()
// // ->send();
// // return; // Stop here
// // }
// // if (Storage::disk('local')->exists($finalPath)) {
// // Notification::make()
// // ->title('Duplicate File')
// // ->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
// // ->warning()
// // ->send();
// // return; // Stop here
// // }
// $storedPath = $uploaded->storeAs(
// 'uploads/OCR',
// $finalFileName,
// 'local'
// );
// $storedPath = $uploaded->storeAs(
// 'uploads/OCR',
// $finalFileName,
// 'local'
// );
// // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
// // $fullPath = storage_path('app/' . $storedPath);
// $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
// // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
// // $fullPath = storage_path('app/' . $storedPath);
// $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
// $fullPath = storage_path('app/private/' . $storedPath);
// $fullPath = storage_path('app/private/' . $storedPath);
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
// $rawText = $text;
// $rawText = $text;
// preg_match_all('/\d+/', $rawText, $matches);
// preg_match_all('/\d+/', $rawText, $matches);
// $serialNumbers = $matches[0];
// $serialNumbers = $matches[0];
// $serialNumbers = array_slice($serialNumbers, 0, 4);
// $serialNumbers = array_slice($serialNumbers, 0, 4);
// //dd($serialNumbers);
// //dd($serialNumbers);
// $processOrder = $get('gr_number');
// $processOrder = $get('gr_number');
// $itemId = $get('item_id');
// $itemId = $get('item_id');
// $plant = $get('plant_id');
// $plant = $get('plant_id');
// $item = Item::find($itemId);
// $item = Item::find($itemId);
// $plant = Plant::find($plant);
// $plant = Plant::find($plant);
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
// $storedPath = $uploaded->storeAs(
// 'uploads/GRNumber',
// $finalFileName,
// 'local'
// );
// $storedPath = $uploaded->storeAs(
// 'uploads/GRNumber',
// $finalFileName,
// 'local'
// );
// $pdf = new Fpdi('P', 'mm', [90, 90]);
// $pdf = new Fpdi('P', 'mm', [90, 90]);
// $templateId = $pdf->setSourceFile($templatePath);
// $templatePage = $pdf->importPage(1);
// $templateId = $pdf->setSourceFile($templatePath);
// $templatePage = $pdf->importPage(1);
// $pdf->AddPage();
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
// $pdf->AddPage();
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
// $pdf->SetFont('Helvetica', '', 10);
// $pdf->SetTextColor(0, 0, 0);
// $pdf->SetFont('Helvetica', '', 10);
// $pdf->SetTextColor(0, 0, 0);
// $slots = [
// ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial
// ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial
// ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial
// ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial
// ];
// $slots = [
// ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial
// ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial
// ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial
// ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial
// ];
// $qrSlots = [
// ['x' => 17.3, 'y' => 29.2, 'size' => 11.4],
// ['x' => 61.5, 'y' => 29, 'size' => 11.5],
// ['x' => 17.7, 'y' => 46.7, 'size' => 11.4],
// ['x' => 61.7, 'y' => 46.7, 'size' => 11.4],
// ];
// $qrSlots = [
// ['x' => 17.3, 'y' => 29.2, 'size' => 11.4],
// ['x' => 61.5, 'y' => 29, 'size' => 11.5],
// ['x' => 17.7, 'y' => 46.7, 'size' => 11.4],
// ['x' => 61.7, 'y' => 46.7, 'size' => 11.4],
// ];
// // foreach ($serialNumbers as $i => $serial) {
// // if (isset($slots[$i])) {
// // $pdf->SetFillColor(255, 255, 255); // erase old serial
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
// // // $pdf->Write(0, $serial);
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
// // }
// // }
// // foreach ($serialNumbers as $i => $serial) {
// // if (isset($slots[$i])) {
// // $pdf->SetFillColor(255, 255, 255); // erase old serial
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
// // // $pdf->Write(0, $serial);
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
// // }
// // }
// // $pdf->Output('F', $outputPath);
// // return response()->download($outputPath);
// // $pdf->Output('F', $outputPath);
// // return response()->download($outputPath);
// //
// //
// // foreach ($serialNumbers as $i => $serial) {
// // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
// // foreach ($serialNumbers as $i => $serial) {
// // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
// // //Generate QR code PNG temporarily
// // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
// // QrCode::format('png')->size(100)->generate($serial, $qrPath);
// // //Generate QR code PNG temporarily
// // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
// // QrCode::format('png')->size(100)->generate($serial, $qrPath);
// // //Place QR code above serial
// // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
// // //Place QR code above serial
// // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
// // //Erase old serial
// // $pdf->SetFillColor(255, 255, 255);
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
// // //Erase old serial
// // $pdf->SetFillColor(255, 255, 255);
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
// // //Write new serial number
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
// // }
// // //Write new serial number
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
// // }
// foreach ($serialNumbers as $i => $serial) {
// if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
// foreach ($serialNumbers as $i => $serial) {
// if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
// // Erase old QR completely (slightly larger)
// $pdf->SetFillColor(255, 255, 255);
// $pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
// // Erase old QR completely (slightly larger)
// $pdf->SetFillColor(255, 255, 255);
// $pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
// // Generate new QR code
// $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
// $qrDir = storage_path('app/private/uploads/QR');
// if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
// QrCode::format('png')->size(100)->generate($serial, $qrPath);
// // Generate new QR code
// $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
// $qrDir = storage_path('app/private/uploads/QR');
// if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
// QrCode::format('png')->size(100)->generate($serial, $qrPath);
// // Place QR code
// $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
// // Place QR code
// $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
// // Erase old serial
// $pdf->SetFillColor(255, 255, 255);
// $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
// // Erase old serial
// $pdf->SetFillColor(255, 255, 255);
// $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
// // Write new serial
// $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
// $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
// }
// // Write new serial
// $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
// $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
// }
// // Save the final PDF
// $pdf->Output('F', $outputPath);
// // Save the final PDF
// $pdf->Output('F', $outputPath);
// // Download
// return response()->download($outputPath);
// }
// }
// else
// {
// Notification::make()
// ->title('No file selected to upload')
// ->warning()
// ->send();
// return;
// }
// }),
// // Download
// return response()->download($outputPath);
// }
// }
// else
// {
// Notification::make()
// ->title('No file selected to upload')
// ->warning()
// ->send();
// return;
// }
// }),
Action::make('downloadAttachment')
->label('Download PDF')
->action(function ($get) {
$equipmentNumber = $get('gr_number');
if (!$equipmentNumber) {
if (! $equipmentNumber) {
Notification::make()
->title('No GR Number entered')
->danger()
->send();
return;
}
@@ -411,17 +407,18 @@ class GrMasterResource extends Resource
}
}
if (!$fileToDownload) {
if (! $fileToDownload) {
Notification::make()
->title('PDF not found for this process order')
->danger()
->send();
return;
}
return response()->download(Storage::disk('local')->path($fileToDownload));
}),
]),
]),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
@@ -440,10 +437,12 @@ class GrMasterResource extends Resource
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->label('Plant Name')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
@@ -453,33 +452,41 @@ class GrMasterResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('gr_number')
->label('GR Number')
->alignCenter()
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('serial_number')
->label('Serial Number')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('status')
->label('Status')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->searchable()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
@@ -506,14 +513,14 @@ class GrMasterResource extends Resource
->label('Import GR Masters')
->color('warning')
->importer(GrMasterImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import gr master');
}),
ExportAction::make()
->label('Export GR Masters')
->color('warning')
->exporter(GrMasterExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export gr master');
}),
]);

View File

@@ -5,7 +5,6 @@ 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 App\Models\Plant;
use Filament\Facades\Filament;
@@ -42,20 +41,20 @@ class GuardNameResource extends Resource
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(GuardName::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
if (! $plantId) {
$set('GnError', 'Please select a plant first.');
return;
}
else
{
} else {
$set('GnError', null);
$set('created_by', Filament::auth()->user()?->name);
}
@@ -113,6 +112,7 @@ class GuardNameResource extends Resource
$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')
@@ -169,14 +169,14 @@ class GuardNameResource extends Resource
->label('Import Guard Names')
->color('warning')
->importer(GuardNameImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import guard name');
}),
ExportAction::make()
->label('Export Guard Names')
->color('warning')
->exporter(GuardNameExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export guard name');
}),
]);

View File

@@ -53,7 +53,7 @@ class GuardPatrolEntryResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(GuardPatrolEntry::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;

View File

@@ -4,24 +4,21 @@ namespace App\Filament\Resources;
use App\Filament\Exports\InvoiceInTransitExporter;
use App\Filament\Resources\InvoiceInTransitResource\Pages;
use App\Filament\Resources\InvoiceInTransitResource\RelationManagers;
use App\Models\InvoiceInTransit;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\FileUpload;
use Storage;
use Maatwebsite\Excel\Facades\Excel;
use Filament\Tables\Actions\ExportAction;
use Carbon\Carbon;
use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate;
use Storage;
class InvoiceInTransitResource extends Resource
{
@@ -37,6 +34,11 @@ class InvoiceInTransitResource extends Resource
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\TextInput::make('receiving_plant')
->label('Receiving Plant'),
@@ -272,8 +274,7 @@ class InvoiceInTransitResource extends Resource
$fullPath = Storage::disk('local')->path($path);
if ($fullPath && file_exists($fullPath))
{
if ($fullPath && file_exists($fullPath)) {
$rows = Excel::toArray(null, $fullPath)[0];
if ((count($rows) - 1) <= 0) {
@@ -305,7 +306,6 @@ class InvoiceInTransitResource extends Resource
$invalidLRBLAWDt = [];
$invalidPenDay = [];
foreach ($rows as $index => $row) {
if ($index == 0) {
continue;
@@ -369,7 +369,7 @@ class InvoiceInTransitResource extends Resource
$plant = Plant::where('code', $plantCode)->first();
//$plantId = $plant->id;
// $plantId = $plant->id;
}
@@ -470,8 +470,7 @@ class InvoiceInTransitResource extends Resource
return;
}
foreach ($rows as $index => $row)
{
foreach ($rows as $index => $row) {
if ($index == 0) {
continue;
}
@@ -504,8 +503,7 @@ class InvoiceInTransitResource extends Resource
throw new \Exception("Invalid plant code : '{$plantCode}'");
}
if (! empty($invoiceDt))
{
if (! empty($invoiceDt)) {
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $invoiceDt)) {
[$day, $month, $year] = preg_split('/[-\/]/', $invoiceDt);
$formattedDate = "{$year}-{$month}-{$day}";
@@ -517,8 +515,7 @@ class InvoiceInTransitResource extends Resource
} else {
$formattedDate = null;
}
if (! empty($LRBAWDt))
{
if (! empty($LRBAWDt)) {
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $LRBAWDt)) {
[$day, $month, $year] = preg_split('/[-\/]/', $LRBAWDt);
$formattedDt = "{$year}-{$month}-{$day}";
@@ -530,8 +527,7 @@ class InvoiceInTransitResource extends Resource
} else {
$formattedDt = null;
}
if (! empty($OBDDate))
{
if (! empty($OBDDate)) {
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $OBDDate)) {
[$day, $month, $year] = preg_split('/[-\/]/', $OBDDate);
$formattedDate = "{$year}-{$month}-{$day}";
@@ -577,15 +573,15 @@ class InvoiceInTransitResource extends Resource
->body('Invoice in transit uploaded successfully!')
->success()
->send();
return;
}
else
{
} else {
Notification::make()
->title('Insertion Failed')
->body('Invoice in transit upload failed!')
->success()
->send();
return;
}
}

View File

@@ -385,6 +385,11 @@ class InvoiceValidationResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('invoice_serial_number', null);
$plantId = $get('plant_id');
if (! $plantId) {
$set('invoice_serial_number', null);
return;
}
$plantCode = Plant::find($plantId)?->code ?? null;
$directory = "uploads/temp/{$plantCode}";
@@ -399,7 +404,7 @@ class InvoiceValidationResource extends Resource
->required()
->acceptedFileTypes([
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-excel', // Legacy .xls fallback if needed
// 'application/vnd.ms-excel', // Legacy .xls fallback if needed
])
->rules(['mimes:xlsx']) // Laravel validation: extension check
->preserveFilenames() // <- this keeps the original filename
@@ -624,9 +629,7 @@ class InvoiceValidationResource extends Resource
}
return;
}
if (! $validRowsFound) {
} elseif (! $validRowsFound) {
Notification::make()
->title('Invalid Serial Invoice')
->danger() // This makes the notification red to indicate an error
@@ -641,9 +644,9 @@ class InvoiceValidationResource extends Resource
$uniqueCodes = array_unique($materialCodes);
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
$matchedItems = StickerMaster::with('item')->where('plant_id', $plantId)
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
})
->get();
@@ -654,7 +657,7 @@ class InvoiceValidationResource extends Resource
if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>'.implode(', ', $missingCodes);
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in sticker master." : 'The following item codes are not found in sticker master:<br>'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown Item Codes')
@@ -678,7 +681,7 @@ class InvoiceValidationResource extends Resource
if (count($invalidCodes) > 10) {
Notification::make()
->title('Invalid item codes found')
->body(''.count($invalidCodes).'item codes found have material type.')
->body(''.count($invalidCodes).' item codes have material type.')
->danger()
->send();
@@ -731,6 +734,11 @@ class InvoiceValidationResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('invoice_material', null);
$plantId = $get('plant_id');
if (! $plantId) {
$set('invoice_material', null);
return;
}
$plantCode = Plant::find($plantId)?->code ?? null;
$directory = "uploads/temp/{$plantCode}";
@@ -743,10 +751,15 @@ class InvoiceValidationResource extends Resource
FileUpload::make('invoice_material')
->label('Invoice Material')
->required()
->acceptedFileTypes([
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
// 'application/vnd.ms-excel', // Legacy .xls fallback if needed
])
->rules(['mimes:xlsx']) // Laravel validation: extension check
->preserveFilenames() // <- this keeps the original filename
->reactive()
->storeFiles(false) // prevent auto-storing
->disk('local')
->storeFiles(false) // prevent auto-storing, we will store manually
->disk('local') // 'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app.
->visible(fn (Get $get) => ! empty($get('plant_id')))
->directory(function (callable $get) {
$plant = Plant::find($get('plant_id'));
@@ -754,6 +767,7 @@ class InvoiceValidationResource extends Resource
return "uploads/temp/{$plantCode}";
})
->uploadingMessage('Uploading...')
->helperText('Only .xlsx files are allowed (Excel files).'),
])
->action(function (array $data) {
@@ -920,9 +934,7 @@ class InvoiceValidationResource extends Resource
}
return;
}
if (! empty($uniqueaplhaMat)) {
} elseif (! empty($uniqueaplhaMat)) {
Notification::make()
->title('Invalid Material Quantity')
->body('The following item codes material quantity must be a numeric values :<br>'.implode(', ', $uniqueaplhaMat))
@@ -934,9 +946,7 @@ class InvoiceValidationResource extends Resource
}
return;
}
if (! empty($uniqueZeroMat)) {
} elseif (! empty($uniqueZeroMat)) {
Notification::make()
->title('Invalid Material Quantity')
->body('The following item codes material quantity should be greater than 0:<br>'.implode(', ', $uniqueZeroMat))
@@ -948,9 +958,7 @@ class InvoiceValidationResource extends Resource
}
return;
}
if (! empty($uniqueEmptyMat)) {
} elseif (! empty($uniqueEmptyMat)) {
Notification::make()
->title('Missing Material Quantity')
->body("The following item codes doesn't have valid material quantity:<br>".implode(', ', $uniqueEmptyMat))
@@ -962,9 +970,7 @@ class InvoiceValidationResource extends Resource
}
return;
}
if (! $validRowsFound) {
} elseif (! $validRowsFound) {
Notification::make()
->title('Invalid Material Invoice')
->danger() // This makes the notification red to indicate an error
@@ -980,9 +986,9 @@ class InvoiceValidationResource extends Resource
$uniqueCodes = array_unique($materialCodes);
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
$matchedItems = StickerMaster::with('item')->where('plant_id', $plantId)
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
})
->get();
@@ -993,9 +999,7 @@ class InvoiceValidationResource extends Resource
if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
$message = $missingCount > 10
? "'$missingCount' Item Codes are not found in sticker master."
: 'Item Codes are not found in sticker master:<br>'.implode(', ', $missingCodes);
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in sticker master." : 'The following item codes are not found in sticker master:<br>'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown Item Codes')
@@ -1019,7 +1023,7 @@ class InvoiceValidationResource extends Resource
$invalidCodes = array_unique($invalidCodes);
Notification::make()
->title('Invalid item codes found')
->body(''.count($invalidCodes).'invalid item codes found have serial number.')
->body(''.count($invalidCodes).' item codes have serial type.')
->danger()
->send();

View File

@@ -56,7 +56,7 @@ class ItemResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Item::latest()->first())->plant_id;
@@ -251,7 +251,7 @@ class ItemResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {
@@ -394,7 +394,7 @@ class ItemResource extends Resource
// // ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
// ->options(function (callable $get) {
// $userHas = Filament::auth()->user()->plant_id;
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
// })
// ->label('Select Plant')
// ->required()

File diff suppressed because it is too large Load Diff

View File

@@ -48,7 +48,7 @@ class LocatorResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Locator::latest()->first())->plant_id;
@@ -194,7 +194,7 @@ class LocatorResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -45,7 +45,7 @@ class MachineResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Machine::latest()->first())->plant_id;

View File

@@ -5,21 +5,20 @@ namespace App\Filament\Resources;
use App\Filament\Exports\MfmMeterExporter;
use App\Filament\Imports\MfmMeterImporter;
use App\Filament\Resources\MfmMeterResource\Pages;
use App\Filament\Resources\MfmMeterResource\RelationManagers;
use App\Models\DeviceMaster;
use App\Models\MfmMeter;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class MfmMeterResource extends Resource
{
@@ -34,35 +33,37 @@ class MfmMeterResource extends Resource
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->label('Plant')
->reactive()
->required()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}),
Forms\Components\Select::make('device_master_id')
//->relationship('device', 'name')
->options(function ($get) {
$plantId = $get('plant_id');
if (!$plantId) {
return [];
}
return DeviceMaster::where('plant_id', $plantId)->pluck('name', 'id');
})
->label('Device Name')
->required(),
Forms\Components\TextInput::make('sequence')
->required(),
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
])
->columns(4),
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->label('Plant')
->reactive()
->required()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
}),
Forms\Components\Select::make('device_master_id')
// ->relationship('device', 'name')
->options(function ($get) {
$plantId = $get('plant_id');
if (! $plantId) {
return [];
}
return DeviceMaster::where('plant_id', $plantId)->pluck('name', 'id');
})
->label('Device Name')
->required(),
Forms\Components\TextInput::make('sequence')
->required(),
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
])
->columns(4),
]);
}
@@ -71,12 +72,13 @@ class MfmMeterResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
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')
@@ -121,19 +123,19 @@ class MfmMeterResource extends Resource
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
->headerActions([
ImportAction::make()
->label('Import MFM Meters')
->color('warning')
->importer(MfmMeterImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import mfm meter');
}),
ExportAction::make()
->label('Export MFM Meters')
->color('warning')
->exporter(MfmMeterExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export mfm meter');
}),
]);

View File

@@ -5,127 +5,128 @@ namespace App\Filament\Resources;
use App\Filament\Exports\MfmParameterExporter;
use App\Filament\Imports\MfmParameterImporter;
use App\Filament\Resources\MfmParameterResource\Pages;
use App\Filament\Resources\MfmParameterResource\RelationManagers;
use App\Models\MfmParameter;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class MfmParameterResource extends Resource
{
protected static ?string $model = MfmParameter::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Power House';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->afterStateUpdated(function (callable $set) {
$set('device_master_id', null);
$set('mfm_meter_id', null);
$set('name', null);
$set('register_id', null);
$set('identifier', null);
$set('byte_to_convert', null);
$set('type_to_convert', null);
$set('decimal_to_display', null);
})
->required(),
Forms\Components\Select::make('device_master_id')
->label('Device Master')
//->relationship('deviceName', 'name')
->options(function (callable $get) {
$plantId = $get('plant_id');
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
if (!$plantId) {
return [];
}
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->afterStateUpdated(function (callable $set) {
$set('device_master_id', null);
$set('mfm_meter_id', null);
$set('name', null);
$set('register_id', null);
$set('identifier', null);
$set('byte_to_convert', null);
$set('type_to_convert', null);
$set('decimal_to_display', null);
})
->required(),
Forms\Components\Select::make('device_master_id')
->label('Device Master')
// ->relationship('deviceName', 'name')
->options(function (callable $get) {
$plantId = $get('plant_id');
return \App\Models\DeviceMaster::where('plant_id', $plantId)
->pluck('name', 'id');
})
->afterStateUpdated(function (callable $set) {
$set('mfm_meter_id', null);
$set('name', null);
$set('register_id', null);
$set('identifier', null);
$set('byte_to_convert', null);
$set('type_to_convert', null);
$set('decimal_to_display', null);
})
->reactive()
->required(),
Forms\Components\Select::make('mfm_meter_id')
->label('Mfm Meter')
// ->relationship('mfmMeter', 'sequence')
->options(function (callable $get) {
$plantId = $get('plant_id');
if (! $plantId) {
return [];
}
if (!$plantId) {
return [];
}
return \App\Models\DeviceMaster::where('plant_id', $plantId)
->pluck('name', 'id');
})
->afterStateUpdated(function (callable $set) {
$set('mfm_meter_id', null);
$set('name', null);
$set('register_id', null);
$set('identifier', null);
$set('byte_to_convert', null);
$set('type_to_convert', null);
$set('decimal_to_display', null);
})
->reactive()
->required(),
Forms\Components\Select::make('mfm_meter_id')
->label('Mfm Meter')
// ->relationship('mfmMeter', 'sequence')
->options(function (callable $get) {
$plantId = $get('plant_id');
return \App\Models\MfmMeter::where('plant_id', $plantId)
->pluck('sequence', 'id');
})
->afterStateUpdated(function (callable $set) {
$set('name', null);
$set('register_id', null);
$set('identifier', null);
$set('byte_to_convert', null);
$set('type_to_convert', null);
$set('decimal_to_display', null);
})
->reactive()
->required(),
Forms\Components\TextInput::make('name')
->label('Parameter Name')
->reactive()
->required(),
Forms\Components\TextInput::make('register_id')
->label('Register ID')
->reactive()
->required(),
Forms\Components\TextInput::make('identifier')
->label('Identifier')
->reactive()
->required(),
Forms\Components\TextInput::make('byte_to_convert')
->label('Byte To Convert')
->reactive()
->default(2)
->required(),
Forms\Components\TextInput::make('type_to_convert')
->label('Type To Convert')
->required(),
Forms\Components\TextInput::make('decimal_to_display')
->label('Decimal To Display')
->reactive()
->default(1)
->required(),
if (! $plantId) {
return [];
}
return \App\Models\MfmMeter::where('plant_id', $plantId)
->pluck('sequence', 'id');
})
->afterStateUpdated(function (callable $set) {
$set('name', null);
$set('register_id', null);
$set('identifier', null);
$set('byte_to_convert', null);
$set('type_to_convert', null);
$set('decimal_to_display', null);
})
->reactive()
->required(),
Forms\Components\TextInput::make('name')
->label('Parameter Name')
->reactive()
->required(),
Forms\Components\TextInput::make('register_id')
->label('Register ID')
->reactive()
->required(),
Forms\Components\TextInput::make('identifier')
->label('Identifier')
->reactive()
->required(),
Forms\Components\TextInput::make('byte_to_convert')
->label('Byte To Convert')
->reactive()
->default(2)
->required(),
Forms\Components\TextInput::make('type_to_convert')
->label('Type To Convert')
->required(),
Forms\Components\TextInput::make('decimal_to_display')
->label('Decimal To Display')
->reactive()
->default(1)
->required(),
])
->columns(3),
->columns(3),
]);
}
@@ -139,6 +140,7 @@ class MfmParameterResource extends Resource
$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')
@@ -212,14 +214,14 @@ class MfmParameterResource extends Resource
->label('Import MFM Parameters')
->color('warning')
->importer(MfmParameterImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import mfm parameter');
}),
ExportAction::make()
->label('Export MFM Parameters')
->color('warning')
->exporter(MfmParameterExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export mfm parameter');
}),
]);

View File

@@ -3,7 +3,6 @@
namespace App\Filament\Resources;
use App\Filament\Resources\MfmReadingResource\Pages;
use App\Filament\Resources\MfmReadingResource\RelationManagers;
use App\Models\MfmReading;
use App\Models\Plant;
use Filament\Facades\Filament;
@@ -31,7 +30,8 @@ class MfmReadingResource extends Resource
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\Select::make('mfm_meter_id')
@@ -72,6 +72,7 @@ class MfmReadingResource extends Resource
$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')
@@ -127,9 +128,9 @@ class MfmReadingResource extends Resource
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('current_y')
->label('Current Y')
->alignCenter()
->sortable(),
->label('Current Y')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('current_b')
->label('Current B')
->alignCenter()

View File

@@ -49,7 +49,7 @@ class MotorTestingMasterResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(MotorTestingMaster::latest()->first())->plant_id;
@@ -466,7 +466,7 @@ class MotorTestingMasterResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -3,36 +3,36 @@
namespace App\Filament\Resources;
use App\Filament\Resources\OcrValidationResource\Pages;
use App\Filament\Resources\OcrValidationResource\RelationManagers;
use App\Models\Item;
use App\Models\OcrValidation;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use thiagoalessio\TesseractOCR\TesseractOCR;
use setasign\Fpdi\Fpdi;
use Filament\Facades\Filament;
use Filament\Forms\Components\Actions\Action;
use Filament\Notifications\Notification;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use setasign\Fpdi\PdfReader;
use setasign\Fpdi\Fpdi;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use Storage;
use Filament\Forms\Concerns\InteractsWithForms;
use Smalot\PdfParser\Parser;
use Storage;
class OcrValidationResource extends Resource
{
protected static ?string $model = OcrValidation::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-s-qr-code';
protected static ?string $navigationGroup = 'OCR';
public $camera_capture;
public $serialNumbers = [];
use InteractsWithForms;
@@ -47,12 +47,13 @@ class OcrValidationResource extends Resource
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
//->relationship('item', 'id')
->label('Item Code')
// ->relationship('item', 'id')
->reactive()
->searchable()
->options(function (callable $get) {
@@ -60,6 +61,7 @@ class OcrValidationResource extends Resource
if (empty($plantId)) {
return [];
}
return Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->required(),
@@ -109,13 +111,12 @@ class OcrValidationResource extends Resource
->preserveFilenames()
->reactive(),
Forms\Components\Actions::make([
Action::make('uploadNow')
Action::make('uploadNow')
->label('Upload PDF Now')
->action(function ($get, callable $set) {
$uploadedFiles = $get('attachment');
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
{
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
$uploaded = reset($uploadedFiles);
if ($uploaded instanceof TemporaryUploadedFile) {
@@ -123,8 +124,8 @@ class OcrValidationResource extends Resource
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
// $originalName = $uploaded->getClientOriginalName();
// $path = 'uploads/GRNumber/' . $originalName;
$finalFileName = $safeName . '.pdf';
$finalPath = 'uploads/OcrGrNumber/' . $finalFileName;
$finalFileName = $safeName.'.pdf';
$finalPath = 'uploads/OcrGrNumber/'.$finalFileName;
if (Storage::disk('local')->exists($finalPath)) {
Notification::make()
@@ -132,6 +133,7 @@ class OcrValidationResource extends Resource
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
->warning()
->send();
return;
}
@@ -141,26 +143,22 @@ class OcrValidationResource extends Resource
'local'
);
// $fullPath = storage_path('app/' . $storedPath);
$fullPath = storage_path('app/private/' . $storedPath);
$parser = new Parser();
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
// $fullPath = storage_path('app/' . $storedPath);
$fullPath = storage_path('app/private/'.$storedPath);
$parser = new Parser;
// $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
$pdf = $parser->parseFile($fullPath);
$text = $pdf->getText();
// dd($text);
// dd($text);
//dd($text);
// dd($text);
$item1 = null;
$item2 = null;
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches))
{
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
$item1 = $matches[1];
}
else if (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches))
{
} elseif (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) {
$item2 = $matches[1];
}
@@ -174,21 +172,19 @@ class OcrValidationResource extends Resource
$plant = Plant::find($plant);
if ($item)
{
if ($item) {
$itemCode = $item->code;
}
else
{
} else {
$itemCode = null;
Notification::make()
->title('Item Not Found')
->body("Item not found in uploaded pdf.")
->body('Item not found in uploaded pdf.')
->warning()
->send();
if (Storage::disk('local')->exists($storedPath)) {
Storage::disk('local')->delete($storedPath);
}
return;
}
@@ -198,50 +194,48 @@ class OcrValidationResource extends Resource
'local'
);
if($itemCode == $item1)
{
if ($itemCode == $item1) {
Notification::make()
->title('Success')
->body("Gr Number '$processOrder' PDF uploaded successfully.")
->success()
->send();
->title('Success')
->body("Gr Number '$processOrder' PDF uploaded successfully.")
->success()
->send();
return;
}
if($itemCode == $item2)
{
if ($itemCode == $item2) {
Notification::make()
->title('Success')
->body("Gr Number '$processOrder' PDF uploaded successfully.")
->success()
->send();
->title('Success')
->body("Gr Number '$processOrder' PDF uploaded successfully.")
->success()
->send();
return;
}
else
{
} else {
Notification::make()
->title('Item Code not matched')
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
->danger()
->send();
->title('Item Code not matched')
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
->danger()
->send();
if (Storage::disk('local')->exists($storedPath)) {
Storage::disk('local')->delete($storedPath);
}
return;
}
}
}
else
{
} else {
Notification::make()
->title('No file selected to upload')
->warning()
->send();
return;
return;
}
}),
Action::make('uploadNow1')
Action::make('uploadNow1')
->label('Upload OCR')
->action(function ($get, callable $set) {
@@ -256,25 +250,25 @@ class OcrValidationResource extends Resource
->title('Serial numbers cannot be empty!')
->danger()
->send();
return;
}
//$serialNumbers = array_slice($serialNumbers, 0, 4);
// $serialNumbers = array_slice($serialNumbers, 0, 4);
if (count($serials) == 1)
{
if (count($serials) == 1) {
$serialNumbers = $serials;
$grNumber = trim($grNumber);
//$templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
if(!file_exists($templatePath))
{
if (! file_exists($templatePath)) {
Notification::make()
->title("Template PDF not found for the Gr Number $grNumber.")
->danger()
->send();
return;
}
@@ -300,17 +294,21 @@ class OcrValidationResource extends Resource
];
foreach ($serialNumbers as $i => $serial) {
if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
if (! isset($slots[$i]) || ! isset($qrSlots[$i])) {
continue;
}
// Erase old QR completely (slightly larger)
$pdf->SetFillColor(255, 255, 255);
$pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
$pdf->Rect($qrSlots[$i]['x'] - 1, $qrSlots[$i]['y'] - 1, $qrSlots[$i]['size'] + 2, $qrSlots[$i]['size'] + 2, 'F');
// Generate new QR code
$qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
$qrDir = storage_path('app/private/uploads/QR');
if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
//QrCode::format('svg')->size(100)->generate($serial, $qrPath);
if (! file_exists($qrDir)) {
mkdir($qrDir, 0777, true);
}
// QrCode::format('svg')->size(100)->generate($serial, $qrPath);
QrCode::format('png')->size(300)->errorCorrection('H')->generate($serial, $qrPath);
// Place QR code
@@ -331,12 +329,11 @@ class OcrValidationResource extends Resource
// Download
return response()->download($outputPath);
}
if(count($serials) == 4)
{
if (count($serials) == 4) {
$serialNumbers = array_slice($serials, 0, 4);
//dd($serialNumbers);
// dd($serialNumbers);
$itemId = $get('item_id');
@@ -348,19 +345,19 @@ class OcrValidationResource extends Resource
$grNumber = trim($grNumber);
//$templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
//$templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.pdf");
// $templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.pdf");
if(!file_exists($templatePath))
{
if (! file_exists($templatePath)) {
Notification::make()
->title("Template PDF not found for the Gr Number $grNumber.")
->danger()
->send();
return;
}
@@ -398,17 +395,21 @@ class OcrValidationResource extends Resource
];
foreach ($serialNumbers as $i => $serial) {
if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
if (! isset($slots[$i]) || ! isset($qrSlots[$i])) {
continue;
}
// Erase old QR completely (slightly larger)
$pdf->SetFillColor(255, 255, 255);
$pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
$pdf->Rect($qrSlots[$i]['x'] - 1, $qrSlots[$i]['y'] - 1, $qrSlots[$i]['size'] + 2, $qrSlots[$i]['size'] + 2, 'F');
// Generate new QR code
$qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
$qrDir = storage_path('app/private/uploads/QR');
if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
//QrCode::format('svg')->size(100)->generate($serial, $qrPath);
if (! file_exists($qrDir)) {
mkdir($qrDir, 0777, true);
}
// QrCode::format('svg')->size(100)->generate($serial, $qrPath);
QrCode::format('png')->size(300)->errorCorrection('H')->generate($serial, $qrPath);
// Place QR code
@@ -428,13 +429,12 @@ class OcrValidationResource extends Resource
// Download
return response()->download($outputPath);
}
else
{
} else {
Notification::make()
->title('Please capture either 1 or 4 serial numbers.')
->danger()
->send();
return;
}
}),
@@ -443,11 +443,12 @@ class OcrValidationResource extends Resource
->action(function ($get) {
$equipmentNumber = $get('gr_number');
if (!$equipmentNumber) {
if (! $equipmentNumber) {
Notification::make()
->title('No GR Number entered')
->danger()
->send();
return;
}
@@ -461,16 +462,18 @@ class OcrValidationResource extends Resource
}
}
if (!$fileToDownload) {
if (! $fileToDownload) {
Notification::make()
->title('PDF not found for this process order')
->danger()
->send();
return;
}
return response()->download(Storage::disk('local')->path($fileToDownload));
}),
]),
]),
Forms\Components\Field::make('camera_capture')
->view('fields.camera-capture'),
Forms\Components\Hidden::make('created_by')
@@ -481,7 +484,6 @@ class OcrValidationResource extends Resource
]);
}
public static function table(Table $table): Table
{
return $table

View File

@@ -49,7 +49,7 @@ class PalletValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->afterStateUpdated(function ($state, callable $set) {
$set('pallet_number', null);
@@ -279,7 +279,7 @@ class PalletValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {
@@ -529,7 +529,7 @@ class PalletValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required()
->reactive()

View File

@@ -9,6 +9,7 @@ use App\Models\Item;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProcessOrder;
use Closure;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action;
@@ -27,9 +28,11 @@ use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Smalot\PdfParser\Parser;
use Storage;
use Str;
// use App\Models\PalletValidation;
// use Dom\Text;
@@ -48,22 +51,38 @@ class ProcessOrderResource extends Resource
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->searchable()
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(ProcessOrder::latest()->first())->plant_id;
})
->reactive()
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$set('coil_number', null);
$set('item_id', null);
$set('line_id', null);
$set('item_description', null);
$set('item_uom', null);
$set('process_order', null);
$set('coil_number', '0');
$set('order_quantity', '0');
$set('received_quantity', '0');
$set('scrap_quantity', '0');
$set('sfg_number', null);
$set('machine_name', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
$set('coilNumberError', null);
$set('sfgNumberError', null);
} else {
$set('poPlantError', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
@@ -75,6 +94,7 @@ class ProcessOrderResource extends Resource
->required(),
Forms\Components\Select::make('line_id')
->label('Line')
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
@@ -89,8 +109,10 @@ class ProcessOrderResource extends Resource
$set('item_description', null);
$set('item_uom', null);
$set('process_order', null);
$set('order_quantity', null);
$set('received_quantity', null);
$set('coil_number', '0');
$set('order_quantity', '0');
$set('received_quantity', '0');
$set('scrap_quantity', '0');
$set('sfg_number', null);
$set('machine_name', null);
$set('updated_by', Filament::auth()->user()?->name);
@@ -113,7 +135,13 @@ class ProcessOrderResource extends Resource
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
// dd($plantId);
$set('process_order', null);
$set('coil_number', '0');
$set('order_quantity', '0');
$set('received_quantity', '0');
$set('scrap_quantity', '0');
$set('sfg_number', null);
$set('machine_name', null);
if ($plantId && $itemId) {
// Get the item code using item_id
@@ -141,6 +169,7 @@ class ProcessOrderResource extends Resource
Forms\Components\TextInput::make('item_description')
->label('Description')
->readOnly()
->required()
->reactive()
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
@@ -181,21 +210,42 @@ class ProcessOrderResource extends Resource
->reactive()
->numeric()
->length(12)
->readOnly(fn ($get) => ($get('plant_id') == null || $get('item_id') == null || $get('line_id') == null))
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$set('coil_number', null);
$set('coil_number', '0');
$set('order_quantity', '0');
$set('received_quantity', '0');
$set('scrap_quantity', '0');
$set('sfg_number', null);
$set('machine_name', null);
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
$set('process_order', null);
$set('coilNumberError', null);
$set('sfgNumberError', null);
// if (! $plantId) {
// $set('poPlantError', 'Please select a plant first.');
// $set('process_order', null);
// $set('coilNumberError', null);
// $set('sfgNumberError', null);
// return;
// }
$itemId = $get('item_id');
$processOrder = trim($get('process_order'));
if (! $itemId || ! $processOrder) {
return;
}
$orderExist = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)->latest()->first();
// ->value('order_quantity') ?? 0;
if ($orderExist) {
$set('order_quantity', $orderExist->order_quantity ?? 0);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->rule(function (callable $get) {
return function (string $attribute, $value, \Closure $fail) use ($get) {
return function (string $attribute, $value, Closure $fail) use ($get) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
@@ -226,54 +276,99 @@ class ProcessOrderResource extends Resource
Forms\Components\TextInput::make('coil_number')
->label('Coil Number')
->default('0')
->required()
->reactive()
->numeric()
->readOnly(fn ($get) => ($get('process_order') == null))
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$processOrder = $get('process_order');
$coilNo = $get('coil_number');
// $coilNo = $get('coil_number');
if (! $plantId) {
$set('poPlantError', 'Please select a plant first.');
$set('coil_number', null);
$set('sfg_number', null);
$set('machine_name', null);
$set('coilNumberError', null);
$set('sfgNumberError', null);
$set('coil_number', '0');
} elseif (! $processOrder) {
$set('coil_number', null);
$set('sfg_number', null);
$set('machine_name', null);
$set('poPlantError', null);
$set('coilNumberError', null);
$set('sfgNumberError', null);
} elseif ($coilNo || $coilNo == '0') {
$existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if ($existing) {
$set('poPlantError', null);
$set('coil_number', null);
$set('coilNumberError', "Duplicate Coil : '{$coilNo}' found!");
} else {
$set('poPlantError', null);
$set('coilNumberError', null);
}
$set('coil_number', '0');
}
$set('received_quantity', '0');
$set('scrap_quantity', '0');
$set('sfg_number', null);
$set('machine_name', null);
$set('coilNumberError', null);
$set('sfgNumberError', null);
// elseif ($coilNo || $coilNo == 0) {
// $existing = ProcessOrder::where('plant_id', $plantId)
// ->where('process_order', $processOrder)
// ->where('coil_number', $coilNo)
// ->first();
// if ($existing) {
// $set('poPlantError', null);
// $set('coil_number', '0');
// $set('coilNumberError', "Duplicate Coil : '{$coilNo}' found!");
// } else {
// $set('poPlantError', null);
// $set('coilNumberError', null);
// }
// }
$set('updated_by', Filament::auth()->user()?->name);
})
->rules([
function (callable $get) {
return Rule::unique('process_orders', 'coil_number')
->where('plant_id', $get('plant_id'))
->where('process_order', $get('process_order'))
->ignore($get('id'));
},
function (callable $get): Closure {
return function (string $attribute, $value, Closure $fail) use ($get) {
$rework = $get('rework_status');
if ($value && Str::contains($value, '.') && $rework == 0) {
$fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
}
};
},
])
// ->rule(function (callable $get) {
// return Rule::unique('process_orders', 'coil_number')
// ->where('plant_id', $get('plant_id'))
// ->where('process_order', $get('process_order'))
// ->ignore($get('id'));
// })
->extraAttributes(fn ($get) => [
'class' => $get('coilNumberError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('coilNumberError') ? $get('coilNumberError') : null)
->hintColor('danger')
->required(),
->hintColor('danger'),
Forms\Components\TextInput::make('order_quantity')
->label('Order Quantity')
->default('1.000')
->required()
->reactive()
->numeric()
->readOnly(fn ($get) => ($get('process_order') == null))
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
$processOrder = trim($get('process_order'));
$set('received_quantity', '0');
$set('scrap_quantity', '0');
if (! $plantId || ! $itemId || ! $processOrder) {
$set('order_quantity', '0');
}
$query = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId);
$orderExist = $query->latest()->first(); // Latest record (reuse base query)
if ($query->count() == 1 && $orderExist && ! $get('id')) {
$set('order_quantity', $orderExist->order_quantity ?? 0);
} elseif ($query->count() > 1 && $orderExist) {
$set('order_quantity', $orderExist->order_quantity ?? 0);
}
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('received_quantity')
@@ -281,19 +376,44 @@ class ProcessOrderResource extends Resource
->default('0.000')
->required()
->reactive()
->numeric()
->readOnly(fn ($get) => ($get('process_order') == null))
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('scrap_quantity', '0');
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('scrap_quantity')
->label('Scrap Quantity')
->default('0.000')
->required()
->readOnly(fn ($get) => ($get('rework_status') == 0 || $get('process_order') == null))
->reactive()
->numeric()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$rework = $get('rework_status');
if ($rework == 0) {
$set('scrap_quantity', '0');
}
$set('updated_by', Filament::auth()->user()?->name);
})
->rule(function (callable $get) {
return function (string $attribute, $value, Closure $fail) use ($get) {
$rework = $get('rework_status');
$scrapQty = $value;
// $currentId = $get('id'); // current editing record id
if ($rework == 0 && $scrapQty != 0) {
$fail("Scrap Quanity value should be '0'!");
return;
}
};
}),
Forms\Components\TextInput::make('sfg_number')
->label('SFG Number')
->reactive()
->readOnly(fn ($get) => ($get('process_order') == null))
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$sfgNo = $get('sfg_number');
@@ -327,6 +447,7 @@ class ProcessOrderResource extends Resource
Forms\Components\TextInput::make('machine_name')
->label('Machine ID')
->reactive()
->readOnly(fn ($get) => ($get('process_order') == null))
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('updated_by', Filament::auth()->user()?->name);
}),
@@ -337,11 +458,55 @@ class ProcessOrderResource extends Resource
->options([0 => 'No', 1 => 'Yes'])
->reactive()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// if ($get('id') && $get('rework_status') == 1) {
// $set('rework_status', 1);
// }
if ($state == 0) {
$set('scrap_quantity', '0');
}
$set('updated_by', Filament::auth()->user()?->name);
})
->rule(function (callable $get, callable $set) {
return function (string $attribute, $value, Closure $fail) use ($get, $set) {
$plantId = $get('plant_id');
$lineId = $get('line_id');
$processOrder = trim($get('process_order'));
$coilNo = trim($get('coil_number'));
$status = $value;
// $currentId = $get('id'); // current editing record id
if (! $plantId || ! $lineId || ! $processOrder || Str::length($coilNo) <= 0) {
$set('rework_status', 0);
return;
} elseif ($status == 0) {
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('line_id', $lineId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->first();
if ($existingCoil && $existingCoil->rework_status == 1 && $get('id')) {
$fail("Rework coil number '{$coilNo}' exist against plant and process order!");
return;
}
}
if (Str::length($coilNo) > 0 && ($status == 1 || Str::contains($coilNo, '.'))) {
$coilMain = explode('.', $coilNo)[0]; // 333
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('line_id', $lineId)
->where('process_order', $processOrder)
->where('coil_number', $coilMain)
->first();
if (! $existingCoil) {
$fail("Coil number '{$coilMain}' not exist against plant and process order!");
} elseif ($existingCoil->rework_status == 0 && ! $get('id')) {
$fail("Rework coil number '{$coilMain}' not exist against plant and process order!");
}
}
};
})
->visible(function () {
return Filament::auth()->user()->hasRole('Super Admin'); // || Filament::auth()->user()->can('update process order rework status')
})
@@ -613,7 +778,7 @@ class ProcessOrderResource extends Resource
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->label('Select Plant Name')
->nullable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
@@ -643,27 +808,46 @@ class ProcessOrderResource extends Resource
}),
TextInput::make('process_order')
->label('Process Order')
->placeholder('Enter Process Order'),
->reactive()
->placeholder('Enter Process Order')
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Rework', null);
}),
TextInput::make('coil_number')
->label('Coil Number')
->reactive()
->placeholder('Enter Coil Number'),
TextInput::make('sfg_number')
->label('Sfg Number')
->placeholder(placeholder: 'Enter Sfg Number'),
->label('SFG Number')
->reactive()
->placeholder('Enter SFG Number'),
TextInput::make('machine_name')
->label('Machine Name')
->placeholder(placeholder: 'Enter Machine Name'),
->reactive()
->placeholder('Enter Machine Name'),
Select::make('rework_status')
->label('Search by Rework Status')
->nullable()
->searchable()
->reactive()
->options([
1 => 'Yes',
0 => 'No',
]),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->placeholder('Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->placeholder('Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && empty($data['sfg_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['machine_name'])) {
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && Str::length($data['coil_number']) <= 0 && empty($data['sfg_number']) && empty($data['machine_name']) && ($data['rework_status'] == null || $data['rework_status'] == '') && empty($data['created_from']) && empty($data['created_to'])) {
return $query->whereRaw('1 = 0');
}
@@ -682,11 +866,16 @@ class ProcessOrderResource extends Resource
}
if (! empty($data['process_order'])) {
$query->where('process_order', $data['process_order']);
$query->where('process_order', 'like', '%'.$data['process_order'].'%');
}
if (Str::length($data['coil_number']) > 0) {
// $query->where('machine_name', $data['machine_name']);
$query->where('coil_number', 'like', '%'.$data['coil_number'].'%');
}
if (! empty($data['sfg_number'])) {
$query->where('sfg_number', $data['sfg_number']);
$query->where('sfg_number', 'like', '%'.$data['sfg_number'].'%');
}
if (! empty($data['machine_name'])) {
@@ -694,6 +883,10 @@ class ProcessOrderResource extends Resource
$query->where('machine_name', 'like', '%'.$data['machine_name'].'%');
}
if ($data['rework_status'] != null && $data['rework_status'] != '') {
$query->where('rework_status', $data['rework_status']);
}
if (! empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
@@ -724,14 +917,22 @@ class ProcessOrderResource extends Resource
$indicators[] = 'Process Order: '.$data['process_order'];
}
if (Str::length($data['coil_number']) > 0) {
$indicators[] = 'Coil Number: '.$data['coil_number'];
}
if (! empty($data['sfg_number'])) {
$indicators[] = 'Sfg Number: '.$data['sfg_number'];
$indicators[] = 'SFG Number: '.$data['sfg_number'];
}
if (! empty($data['machine_name'])) {
$indicators[] = 'Machine Name: '.$data['machine_name'];
}
if ($data['rework_status'] != null && $data['rework_status'] != '') {
$indicators[] = ($data['rework_status'] == 1) ? 'Rework Status: Yes' : 'Rework Status: No';
}
if (! empty($data['created_from'])) {
$indicators[] = 'From: '.$data['created_from'];
}

View File

@@ -43,11 +43,20 @@ class ProductCharacteristicsMasterResource extends Resource
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->searchable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(ProductCharacteristicsMaster::latest()->first())->plant_id;
})
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->reactive()
->required(),
Forms\Components\Select::make('item_id')
@@ -63,10 +72,14 @@ class ProductCharacteristicsMasterResource extends Resource
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Select::make('line_id')
->label('Line')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
@@ -77,10 +90,10 @@ class ProductCharacteristicsMasterResource extends Resource
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('machine_id', null);
if (! $get('work_group_master_id')) {
$set('machine_id', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
// ->relationship('line', 'name'),
@@ -88,6 +101,7 @@ class ProductCharacteristicsMasterResource extends Resource
->label('Group Work Center')
->required()
->reactive()
->searchable()
->options(function (callable $get) {
if (! $get('plant_id') || ! $get('line_id')) {
return [];
@@ -107,6 +121,7 @@ class ProductCharacteristicsMasterResource extends Resource
->disabled(fn (Get $get) => ! empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$lineId = $get('line_id');
$set('updated_by', Filament::auth()->user()?->name);
if (! $lineId) {
$set('mGroupWorkError', 'Please select a line first.');
$set('machine_id', null);
@@ -133,8 +148,8 @@ class ProductCharacteristicsMasterResource extends Resource
Forms\Components\Select::make('machine_id')
->label('Work Center')
// ->relationship('machine', 'name'),
->searchable()
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
$lineId = $get('line_id');
@@ -153,6 +168,7 @@ class ProductCharacteristicsMasterResource extends Resource
if (! $get('plant_id') || ! $get('line_id') || ! $get('work_group_master_id')) {
$set('machine_id', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Select::make('characteristics_type')
@@ -162,16 +178,30 @@ class ProductCharacteristicsMasterResource extends Resource
'Process' => 'Process',
])
->reactive()
->searchable()
// ->preload()
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('name')
->label('Name'),
->label('Name')
->reactive()
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\Select::make('inspection_type')
->label('Inspection Type')
->searchable()
->options([
'Visual' => 'Visual',
'Value' => 'Value',
])
->reactive()
// ->preload()
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
// Forms\Components\Select::make('result')
// ->label('Visual Type')
@@ -197,7 +227,11 @@ class ProductCharacteristicsMasterResource extends Resource
->default(0.0)
->minValue(0.0)
->maxValue(fn (Get $get) => $get('upper') ?? PHP_INT_MAX)
->afterStateUpdated(fn ($state, callable $set, callable $get) => $set('middle', ($state + $get('upper')) / 2))
// ->afterStateUpdated(fn ($state, callable $set, callable $get) => $set('middle', ($state + $get('upper')) / 2))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('middle', ($state + $get('upper')) / 2);
$set('updated_by', Filament::auth()->user()?->name);
})
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
Forms\Components\TextInput::make('upper')
->label('Upper')
@@ -206,7 +240,11 @@ class ProductCharacteristicsMasterResource extends Resource
->default(0.0)
->minValue(fn (Get $get) => $get('lower') ?? 0)
->maxValue(PHP_INT_MAX)
->afterStateUpdated(fn ($state, callable $set, callable $get) => $set('middle', ($get('lower') + $state) / 2))
// ->afterStateUpdated(fn ($state, callable $set, callable $get) => $set('middle', ($get('lower') + $state) / 2))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('middle', ($get('lower') + $state) / 2);
$set('updated_by', Filament::auth()->user()?->name);
})
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
Forms\Components\TextInput::make('middle')
->label('Middle')
@@ -228,12 +266,19 @@ class ProductCharacteristicsMasterResource extends Resource
// };
// })
->dehydrateStateUsing(fn ($state, Get $get) => ($get('lower') + $get('upper')) / 2)
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By'),
->label('Updated By')
->default(Filament::auth()->user()?->name),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]);
}
@@ -308,11 +353,11 @@ class ProductCharacteristicsMasterResource extends Resource
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
@@ -323,6 +368,7 @@ class ProductCharacteristicsMasterResource extends Resource
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->searchable()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')

View File

@@ -15,27 +15,30 @@ class EditProductCharacteristicsMaster extends EditRecord
return 'Edit Characteristics'; // This will replace the "New product characteristics master"
}
public function mount(int|string $record): void
{
parent::mount($record);
// public function mount(int|string $record): void
// {
// parent::mount($record);
$model = $this->getRecord(); // actual model instance
// $model = $this->getRecord(); // actual model instance
// Step 1: Fill the actual saved fields first
$this->form->fill([
'plant_id' => $model->plant_id,
'line_id' => $model->line_id,
'item_id' => $model->item_id,
'machine_id' => $model->machine_id,
'name' => $model->name,
'type' => $model->type,
'upper' => $model->upper,
'lower' => $model->lower,
'middle' => $model->middle,
'work_group_master_id' => optional($model->machine)->work_group_master_id,
]);
}
// // Step 1: Fill the actual saved fields first
// $this->form->fill([
// 'plant_id' => $model->plant_id,
// 'item_id' => $model->item_id,
// 'line_id' => $model->line_id,
// 'machine_id' => $model->machine_id,
// 'name' => $model->name,
// 'characteristics_type' => $model->characteristics_type,
// 'inspection_type' => $model->inspection_type,
// // 'type' => $model->type,
// 'upper' => $model->upper,
// 'lower' => $model->lower,
// 'middle' => $model->middle,
// 'created_by' => $model->created_by,
// 'updated_by' => $model->updated_by,
// 'work_group_master_id' => optional($model->machine)->work_group_master_id,
// ]);
// }
protected function getHeaderActions(): array
{

View File

@@ -55,7 +55,7 @@ class ProductionLineStopResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(ProductionLineStop::latest()->first())->plant_id;
@@ -430,7 +430,7 @@ class ProductionLineStopResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -7,6 +7,7 @@ use App\Filament\Exports\ProductionPlanExporter;
use App\Filament\Imports\ProductionPlanImporter;
use App\Filament\Resources\ProductionPlanResource\Pages;
use App\Models\Block;
use App\Models\Item;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProductionPlan;
@@ -54,7 +55,7 @@ class ProductionPlanResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(ProductionPlan::latest()->first())->plant_id;
@@ -77,97 +78,6 @@ class ProductionPlanResource extends Resource
])
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
->hintColor('danger'),
Forms\Components\Select::make('block_name')
->required()
// ->nullable()
->label('Block')
->options(function (callable $get) {
if (! $get('plant_id')) {
return [];
}
return Block::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->default(function () {
$latestShiftId = optional(ProductionPlan::latest()->first())->shift_id;
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
})
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if ($get('id')) {
$getShift = ProductionPlan::where('id', $get('id'))->first();
$getBlock = Shift::where('id', $getShift->shift_id)->first();
if ($getBlock->block_id) {
$set('block_name', $getBlock->block_id);
$set('ppBlockError', null);
}
}
$blockId = $get('block_name');
$set('shift_id', null);
if (! $blockId) {
$set('ppBlockError', 'Please select a block first.');
return;
} else {
$set('ppBlockError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('ppBlockError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('ppBlockError') ? $get('ppBlockError') : null)
->hintColor('danger'),
Forms\Components\Select::make('shift_id')
->relationship('shift', 'name')
->required()
// ->nullable()
->autofocus(true)
->options(function (callable $get) {
if (! $get('plant_id') || ! $get('block_name')) {
return [];
}
return Shift::where('plant_id', $get('plant_id'))
->where('block_id', $get('block_name'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->default(function () {
return optional(ProductionPlan::latest()->first())->shift_id;
})
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if ($get('id')) {
$getShift = ProductionPlan::where('id', $get('id'))->first();
if ($getShift->shift_id) {
$set('shift_id', $getShift->shift_id);
$set('ppShiftError', null);
}
}
$curShiftId = $get('shift_id');
$set('line_id', null);
if (! $curShiftId) {
$set('ppShiftError', 'Please select a shift first.');
return;
} else {
$set('ppShiftError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('ppShiftError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('ppShiftError') ? $get('ppShiftError') : null)
->hintColor('danger'),
Forms\Components\Select::make('line_id')
->relationship('line', 'name')
->required()
@@ -178,7 +88,7 @@ class ProductionPlanResource extends Resource
// ->toArray() // Convert collection to array
// )
->options(function (callable $get) {
if (! $get('plant_id') || ! $get('block_name') || ! $get('shift_id')) {
if (! $get('plant_id')) {
return [];
}
@@ -190,239 +100,257 @@ class ProductionPlanResource extends Resource
// ->default(function () {
// return optional(ProductionPlan::latest()->first())->line_id;
// })
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
// if ($get('id')) {
// $getShift = ProductionPlan::where('id', $get('id'))->first();
// if ($getShift->line_id) {
// $set('line_id', $getShift->line_id);
// $set('ppLineError', null);
// }
// } else {
// $currentDT = Carbon::now()->toDateTimeString();
// $set('created_at', $currentDT);
// $set('update_date', null);
// }
// $lineId = $get('line_id');
// // $set('plan_quantity', null);
// if (! $lineId) {
// $set('ppLineError', 'Please select a line first.');
// return;
// } else {
// $isUpdate = ! empty($get('id'));
// if (! $isUpdate) {
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
// ->where('shift_id', $get('shift_id'))
// ->where('line_id', $get('line_id'))
// ->whereDate('created_at', today())
// ->latest()
// ->exists();
// if ($exists) {
// $set('line_id', null);
// $set('ppLineError', 'Production plan already updated.');
// return;
// } else {
// $existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
// ->where('shift_id', $get('shift_id'))
// ->where('line_id', $get('line_id'))
// ->whereDate('created_at', Carbon::yesterday())
// ->latest()
// ->exists();
// if ($existShifts) { // if ($existShifts->count() > 0)
// // $currentDate = date('Y-m-d');
// $yesterday = date('Y-m-d', strtotime('-1 days'));
// $shiftId = Shift::where('id', $get('shift_id'))
// ->first();
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
// $hRs = (int) $hRs;
// // $miNs = (int) $miNs;-*/
// $totalMinutes = $hRs * 60 + $miNs;
// $from_dt = $yesterday.' '.$shiftId->start_time;
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
// $currentDateTime = date('Y-m-d H:i:s');
// // Check if current date time is within the range
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
// // echo "Choosed a valid shift...";
// $set('line_id', null);
// $set('ppLineError', 'Production plan already updated.');
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
// return;
// } else {
// $currentDate = date('Y-m-d');
// $shiftId = Shift::where('id', $get('shift_id'))
// ->first();
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
// $hRs = (int) $hRs;
// // $miNs = (int) $miNs;-*/
// $totalMinutes = $hRs * 60 + $miNs;
// $from_dt = $currentDate.' '.$shiftId->start_time;
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
// $currentDateTime = date('Y-m-d H:i:s');
// // Check if current date time is within the range
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
// // echo "Choosed a valid shift...";
// $set('line_id', null);
// $set('ppLineError', 'Choosed a invalid shift.');
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
// return;
// }
// }
// $set('ppLineError', null);
// return;
// } else {
// // $currentDate = date('Y-m-d');
// $yesterday = date('Y-m-d', strtotime('-1 days'));
// $shiftId = Shift::where('id', $get('shift_id'))
// ->first();
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
// $hRs = (int) $hRs;
// // $miNs = (int) $miNs;-*/
// $totalMinutes = $hRs * 60 + $miNs;
// $from_dt = $yesterday.' '.$shiftId->start_time;
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
// $currentDateTime = date('Y-m-d H:i:s');
// // Check if current date time is within the range
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
// // echo "Choosed a valid shift...";
// // here i'm updating created as yesterday
// $set('created_at', $from_dt);
// $set('update_date', '1');
// $set('ppLineError', null);
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
// return;
// } else {
// $currentDate = date('Y-m-d');
// $shiftId = Shift::where('id', $get('shift_id'))
// ->first();
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
// $hRs = (int) $hRs;
// // $miNs = (int) $miNs;-*/
// $totalMinutes = $hRs * 60 + $miNs;
// $from_dt = $currentDate.' '.$shiftId->start_time;
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
// $currentDateTime = date('Y-m-d H:i:s');
// // Check if current date time is within the range
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
// // echo "Choosed a valid shift...";
// $set('line_id', null);
// $set('ppLineError', 'Choosed a invalid shift.');
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
// return;
// }
// }
// $set('ppLineError', null);
// return;
// }
// // $exists = ProductionPlan::where('plant_id', $get('plant_id'))
// // //->where('shift_id', $get('shift_id'))
// // ->where('line_id', $get('line_id'))
// // ->whereDate('created_at', today())
// // ->latest() // Orders by created_at DESC
// // ->first();
// // if ($exists)
// // {
// // $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
// // //->where('shift_id', $get('shift_id'))
// // ->where('line_id', $get('line_id'))
// // // ->whereDate('created_at', today())
// // ->whereDate('created_at', today())
// // ->get();
// // foreach ($existingShifts as $shift) {
// // $curShiftId = $shift->shift_id;
// // $currentDate = date('Y-m-d');
// // $shiftId = \App\Models\Shift::where('id', $curShiftId)
// // ->first();
// // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
// // $hRs = (int) $hRs;
// // // $miNs = (int) $miNs;-*/
// // $totalMinutes = $hRs * 60 + $miNs;
// // $from_dt = $currentDate . ' ' . $shiftId->start_time;
// // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
// // $currentDateTime = date('Y-m-d H:i:s');
// // // Check if current date time is within the range
// // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
// // //echo "Choosed a valid shift...";
// // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
// // $set('line_id', null);
// // $set('ppLineError', 'Production plan already updated.');
// // return;
// // }
// // // else {
// // // $set('ppLineError', 'Choosed a invalid shift...');
// // // return;
// // // }
// // }
// // $set('ppLineError', null);
// // return;
// // }
// }
// }
// $set('ppLineError', null);
// }
// })
->afterStateUpdated(function ($state, callable $set, callable $get) {
if ($get('id')) {
$getShift = ProductionPlan::where('id', $get('id'))->first();
if ($getShift->line_id) {
$set('line_id', $getShift->line_id);
$set('ppLineError', null);
}
} else {
$currentDT = Carbon::now()->toDateTimeString();
$set('created_at', $currentDT);
$set('update_date', null);
}
$lineId = $get('line_id');
// $set('plan_quantity', null);
if (! $lineId) {
$set('ppLineError', 'Please select a line first.');
return;
} else {
$isUpdate = ! empty($get('id'));
if (! $isUpdate) {
$exists = ProductionPlan::where('plant_id', $get('plant_id'))
->where('shift_id', $get('shift_id'))
->where('line_id', $get('line_id'))
->whereDate('created_at', today())
->latest()
->exists();
if ($exists) {
$set('line_id', null);
$set('ppLineError', 'Production plan already updated.');
return;
} else {
$existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
->where('shift_id', $get('shift_id'))
->where('line_id', $get('line_id'))
->whereDate('created_at', Carbon::yesterday())
->latest()
->exists();
if ($existShifts) { // if ($existShifts->count() > 0)
// $currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $yesterday.' '.$shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
// echo "Choosed a valid shift...";
$set('line_id', null);
$set('ppLineError', 'Production plan already updated.');
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
} else {
$currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate.' '.$shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
// echo "Choosed a valid shift...";
$set('line_id', null);
$set('ppLineError', 'Choosed a invalid shift.');
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
}
$set('ppLineError', null);
return;
} else {
// $currentDate = date('Y-m-d');
$yesterday = date('Y-m-d', strtotime('-1 days'));
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $yesterday.' '.$shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
// echo "Choosed a valid shift...";
// here i'm updating created as yesterday
$set('created_at', $from_dt);
$set('update_date', '1');
$set('ppLineError', null);
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
} else {
$currentDate = date('Y-m-d');
$shiftId = Shift::where('id', $get('shift_id'))
->first();
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
$hRs = (int) $hRs;
// $miNs = (int) $miNs;-*/
$totalMinutes = $hRs * 60 + $miNs;
$from_dt = $currentDate.' '.$shiftId->start_time;
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
$currentDateTime = date('Y-m-d H:i:s');
// Check if current date time is within the range
if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
// echo "Choosed a valid shift...";
$set('line_id', null);
$set('ppLineError', 'Choosed a invalid shift.');
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
return;
}
}
$set('ppLineError', null);
return;
}
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
// //->where('shift_id', $get('shift_id'))
// ->where('line_id', $get('line_id'))
// ->whereDate('created_at', today())
// ->latest() // Orders by created_at DESC
// ->first();
// if ($exists)
// {
// $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
// //->where('shift_id', $get('shift_id'))
// ->where('line_id', $get('line_id'))
// // ->whereDate('created_at', today())
// ->whereDate('created_at', today())
// ->get();
// foreach ($existingShifts as $shift) {
// $curShiftId = $shift->shift_id;
// $currentDate = date('Y-m-d');
// $shiftId = \App\Models\Shift::where('id', $curShiftId)
// ->first();
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
// $hRs = (int) $hRs;
// // $miNs = (int) $miNs;-*/
// $totalMinutes = $hRs * 60 + $miNs;
// $from_dt = $currentDate . ' ' . $shiftId->start_time;
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
// $currentDateTime = date('Y-m-d H:i:s');
// // Check if current date time is within the range
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
// //echo "Choosed a valid shift...";
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
// $set('line_id', null);
// $set('ppLineError', 'Production plan already updated.');
// return;
// }
// // else {
// // $set('ppLineError', 'Choosed a invalid shift...');
// // return;
// // }
// }
// $set('ppLineError', null);
// return;
// }
}
}
$set('ppLineError', null);
}
$set('item_id', null);
$set('plan_quantity', null);
})
->extraAttributes(fn ($get) => [
'class' => $get('ppLineError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('ppLineError') ? $get('ppLineError') : null)
->hintColor('danger'),
Forms\Components\Select::make('item_id')
->label('Item')
->reactive()
->searchable()
->required()
->options(function (callable $get) {
if (! $get('plant_id')) {
return [];
}
return Item::where('plant_id', $get('plant_id'))
->pluck('code', 'id')
->toArray();
}),
Forms\Components\TextInput::make('plan_quantity')
->required()
->integer()
@@ -453,29 +381,19 @@ class ProductionPlanResource extends Resource
])
->hint(fn ($get) => $get('ppPlanQuanError') ? $get('ppPlanQuanError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('production_quantity')
->required()
->integer()
->label('Production Quantity')
->readOnly(fn (callable $get) => ! $get('id'))
->default(0),
// Forms\Components\TextInput::make('production_quantity')
// ->required()
// ->integer()
// ->label('Production Quantity')
// ->readOnly(fn (callable $get) => ! $get('id'))
// ->default(0),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
Forms\Components\TextInput::make('update_date')
->hidden()
->reactive()
->readOnly(),
Forms\Components\DateTimePicker::make('created_at')
->label('Created DateTime')
->hidden()
->reactive()
->required()
->readOnly(),
Forms\Components\Hidden::make('operator_id')
->default(Filament::auth()->user()->name),
])
->columns(2),
->columns(4),
]);
}
@@ -513,32 +431,52 @@ class ProductionPlanResource extends Resource
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('line.name')
->label('Plant')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('plan_quantity')
->label('Plan Quantity')
->alignCenter()
->numeric()
->sortable(),
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('working_days')
->label('Working Days')
->alignCenter()
->numeric()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('production_quantity')
->label('Production Quantity')
->alignCenter()
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('line.name')
->label('Line')
->alignCenter()
->sortable(), // ->searchable(),
Tables\Columns\TextColumn::make('shift.block.name')
->label('Block')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('shift.name')
->label('Shift')
->alignCenter()
->sortable(), // ->searchable(),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(), // ->searchable(),
->sortable()
->searchable(),
// Tables\Columns\TextColumn::make('line.name')
// ->label('Line')
// ->alignCenter()
// ->sortable(), // ->searchable(),
// Tables\Columns\TextColumn::make('shift.block.name')
// ->label('Block')
// ->alignCenter()
// ->sortable(),
// Tables\Columns\TextColumn::make('shift.name')
// ->label('Shift')
// ->alignCenter()
// ->sortable(), // ->searchable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
@@ -576,7 +514,7 @@ class ProductionPlanResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -63,7 +63,7 @@ class ProductionQuantityResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
// ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id)
->default(function () {
@@ -1035,7 +1035,7 @@ class ProductionQuantityResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -56,7 +56,7 @@ class QualityValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->afterStateUpdated(function (callable $set, callable $get, $state) {
$set('item_id', null);
@@ -3015,7 +3015,7 @@ class QualityValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -7,6 +7,7 @@ use App\Filament\Resources\RequestCharacteristicResource\Pages;
use App\Models\CharacteristicApproverMaster;
use App\Models\Item;
use App\Models\Machine;
use App\Models\Plant;
use App\Models\RequestCharacteristic;
use Closure;
use Filament\Facades\Filament;
@@ -65,12 +66,20 @@ class RequestCharacteristicResource extends Resource
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->label('Plant Name')
->relationship('plant', 'name')
->reactive()
->searchable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required()
->default(function () {
return optional(RequestCharacteristic::latest()->first())->plant_id;
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->plant_id ?? null;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
@@ -80,8 +89,9 @@ class RequestCharacteristicResource extends Resource
$set('aufnr', null);
$set('machine_name', null);
$set('characteristic_approver_master_id', null);
if (! $updRec && $plantId) {
$set('work_flow_id', self::isNewWorkFlow($get));
$set('approver_type', null);
if (! $updRec) {
$set('work_flow_id', $plantId ? self::isNewWorkFlow($get) : null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
@@ -101,13 +111,16 @@ class RequestCharacteristicResource extends Resource
})
->required()
->default(function () {
return optional(RequestCharacteristic::latest()->first())->machine_id ?? [];
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->machine_id ?? null;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('item_id', null);
$set('aufnr', null);
$set('machine_name', null);
$set('characteristic_approver_master_id', null);
$set('approver_type', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->disabled(fn ($get) => self::isFieldDisabled($get)),
@@ -115,6 +128,7 @@ class RequestCharacteristicResource extends Resource
->label('Work Flow ID')
->readOnly()
->reactive()
->required()
->default(function ($state, callable $set, callable $get) {
$updRec = $get('id');
if (! $updRec) {
@@ -128,9 +142,10 @@ class RequestCharacteristicResource extends Resource
// ->ignore($get('id'));
// }),
Forms\Components\Select::make('item_id')
->label('Item')
->label('Item Code')
// ->relationship('item', 'id')
->reactive()
->required()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
@@ -140,44 +155,64 @@ class RequestCharacteristicResource extends Resource
return Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->required()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('aufnr', null);
if (! $state) {
$set('aufnr', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->default(function () {
return optional(RequestCharacteristic::latest()->first())->item_id ?? [];
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->item_id ?? null;
})
->disabled(fn ($get) => self::isFieldDisabled($get)),
Forms\Components\TextInput::make('aufnr')
->label('Aufnr')
->label('Job Number')
->reactive()
->required()
->required(function (callable $get) {
$item = $get('item_id');
if ($item) {
return true;
}
return false;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name);
})
->default(function () {
return optional(RequestCharacteristic::latest()->first())->aufnr ?? '';
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->aufnr ?? null;
})
->readOnly(fn ($get) => ($get('item_id') == null))
->disabled(fn ($get) => self::isFieldDisabled($get)),
Forms\Components\Select::make('machine_name')
->label('Machines')
->label('Machine Name')
->reactive()
->nullable()
->searchable()
->options(function (callable $get) {
->options(function (callable $set, callable $get) {
$plantId = $get('plant_id');
$machineId = $get('machine_id');
if (! $plantId || ! $machineId) {
$set('characteristic_name', null);
$set('current_value', null);
$set('update_value', null);
return [];
}
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->pluck('machine_name', 'machine_name')->unique();
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('approver_type', null); // dd($get('characteristic_approver_master_id'));
$set('characteristic_approver_master_id', null);
// dd($get('characteristic_approver_master_id'));
$set('characteristic_name', null);
$set('current_value', null);
$set('update_value', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->default(function () {
@@ -185,60 +220,121 @@ class RequestCharacteristicResource extends Resource
$reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
if ($reqId) {
$reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
if ($reqMac) {
$machineName = $reqMac;
} else {
$machineName = null;
}
$machineName = $reqMac ?? null;
} else {
$machineName = null;
}
// return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
return $machineName ?? [];
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : $machineName ?? null;
})
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
if ($get('id')) {
$reqId = RequestCharacteristic::where('id', $get('id'))->first()?->characteristic_approver_master_id;
if ($reqId) {
$reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
if ($reqMac) {
$set('machine_name', $reqMac);
} else {
$set('machine_name', null);
}
$set('machine_name', $reqMac ?? null);
} else {
$set('machine_name', null);
}
}
})
->required(),
Forms\Components\Select::make('characteristic_approver_master_id')
->label('Master Characteristic Field')
// ->relationship('characteristicApproverMaster', 'characteristic_field')
Forms\Components\Select::make('approver_type')
->label('Request Type')
// ->columnSpan(1)
->reactive()
->nullable()
->searchable()
->options(function (callable $get) {
->required()
->options(function (callable $set, callable $get) {
$plantId = $get('plant_id');
$machineId = $get('machine_id');
$machineName = $get('machine_name');
if (! $plantId || ! $machineId || ! $machineName) {
$set('characteristic_name', null);
$set('current_value', null);
$set('update_value', null);
return [];
}
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->where('machine_name', $machineName)->pluck('characteristic_field', 'id');
})
->default(function () {
return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
return [
'Characteristic' => 'Characteristic',
'Quality' => 'Quality',
];
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('characteristic_approver_master_id', null);
if ($get('approver_type') != 'Characteristic') {
$set('characteristic_name', null);
$set('current_value', null);
$set('update_value', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : 'Characteristic';
// $approverType = null;
// $reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
// if ($reqId) {
// $reqTyp = CharacteristicApproverMaster::where('id', $reqId)->first()?->approver_type;
// $approverType = $reqTyp ?? null;
// } else {
// $approverType = null;
// }
// // return optional(CharacteristicApproverMaster::latest()->first())->approver_type ?? null;
// return $approverType ?? null;
})
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
if ($get('id')) {
$reqId = RequestCharacteristic::where('id', $get('id'))->first()?->characteristic_approver_master_id;
if ($reqId) {
$reqTyp = CharacteristicApproverMaster::where('id', $reqId)->first()?->approver_type;
$set('approver_type', $reqTyp ?? null);
} else {
$set('approver_type', null);
}
}
}),
Forms\Components\Select::make('characteristic_approver_master_id')
->label('Master Characteristic Field')
// ->relationship('characteristicApproverMaster', 'characteristic_field')
->columnSpan(2)
->reactive()
->nullable()
->searchable()
->options(function (callable $set, callable $get) {
$plantId = $get('plant_id');
$machineId = $get('machine_id');
$machineName = $get('machine_name');
$reqTyp = $get('approver_type');
if (! $plantId || ! $machineId || ! $machineName || ! $reqTyp) {
return [];
}
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->where('machine_name', $machineName)->where('approver_type', $reqTyp)->pluck('characteristic_field', 'id');
})
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? null;
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('characteristic_name', null);
$set('current_value', null);
$set('update_value', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
// ->disabled(fn ($get) => self::isFieldDisabled($get))
Section::make('Request Characteristic Field')
Section::make('Request Characteristic Details')
// ->columnSpan(['default' => 2, 'sm' => 4])
->reactive()
->schema([
@@ -249,7 +345,14 @@ class RequestCharacteristicResource extends Resource
$set('characteristic_name', strtoupper($state));
$set('updated_by', Filament::auth()->user()?->name);
})
->required()
->required(function (callable $get) {
$reqTyp = $get('approver_type');
if ($reqTyp == 'Characteristic') {
return true;
}
return false;
})
->rules([
// function (callable $get) {
// return Rule::unique('request_characteristics', 'characteristic_name')
@@ -288,7 +391,7 @@ class RequestCharacteristicResource extends Resource
};
},
])
->readOnly(fn ($get) => self::isFieldDisabled($get)), // disabled
->readOnly(fn ($get) => ($get('approver_type') != 'Characteristic') ?? self::isFieldDisabled($get)),
Forms\Components\TextInput::make('current_value')
->label('Current Value')
->reactive()
@@ -296,14 +399,15 @@ class RequestCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name);
})
->required(function (callable $get) {
$reqTyp = $get('approver_type');
$updateVal = $get('update_value');
if ($updateVal == null || $updateVal == '') {
if ($reqTyp == 'Characteristic' && ($updateVal == null || $updateVal == '')) {
return true;
}
return false;
})
->readOnly(fn ($get) => self::isFieldDisabled($get)),
->readOnly(fn ($get) => ($get('approver_type') != 'Characteristic') ?? self::isFieldDisabled($get)),
Forms\Components\TextInput::make('update_value')
->label('Update Value')
->reactive()
@@ -321,9 +425,17 @@ class RequestCharacteristicResource extends Resource
};
},
])
->readOnly(fn ($get) => self::isFieldDisabled($get)),
->readOnly(fn ($get) => ($get('approver_type') != 'Characteristic') ?? self::isFieldDisabled($get)),
])
->collapsible()
// ->collapsed(function ($get): bool {
// $reqTyp = $get('approver_type');
// if ($reqTyp == 'Characteristic') {
// return true;
// }
// return false;
// })
->collapsed()
->columns(['default' => 1, 'sm' => 3]),
Section::make(function ($get): string {
$approverId = $get('characteristic_approver_master_id');
@@ -338,16 +450,19 @@ class RequestCharacteristicResource extends Resource
Forms\Components\Select::make('approver_status1')
->label('Approver Status')
->reactive()
->live()
// ->live()
->options([
'Approved' => 'Approved',
'Hold' => 'Hold',
'Rejected' => 'Rejected',
])
->afterStateUpdated(function ($state, callable $set, callable $get) {
if ($state && empty($get('approved1_at'))) {
$set('approved1_at', now());
if ($state) {// && empty($get('approved1_at'))
$set('approved1_at', now()->toDateTimeString()); // now()->format('d-m-Y H:i:s')
} else {
$set('approved1_at', null);
}
$set('approver_remark1', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->disabled(function ($get) {
@@ -377,10 +492,17 @@ class RequestCharacteristicResource extends Resource
}),
Forms\Components\TextInput::make('approver_remark1')
->label('Approver Remark')
->reactive()
->live()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$appStat = $get('approver_status1');
if ($appStat && $state) {
$set('approved1_at', now()->toDateTimeString()); // now()->format('d-m-Y H:i:s')
} else {
$set('approved1_at', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->readOnly(fn ($get) => ($get('approver_status1') == null))
->disabled(function ($get) {
$currentUser = Filament::auth()->user();
$updId = $get('id');
@@ -402,10 +524,12 @@ class RequestCharacteristicResource extends Resource
default => 'Updated At',
})
->reactive()
->live()
// ->live()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name);
})
// ->format('d-m-Y H:i:s')
->readOnly(fn ($get) => ($get('approver_status1') == null))
->disabled(function ($get) {
$currentUser = Filament::auth()->user(); // logged-in user
$approverId = $get('characteristic_approver_master_id');
@@ -448,9 +572,12 @@ class RequestCharacteristicResource extends Resource
'Rejected' => 'Rejected',
])
->afterStateUpdated(function ($state, callable $set, callable $get) {
if ($state && empty($get('approved2_at'))) {
$set('approved2_at', now());
if ($state) {
$set('approved2_at', now()->toDateTimeString());
} else {
$set('approved2_at', null);
}
$set('approver_remark2', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->disabled(function ($get) {
@@ -480,10 +607,17 @@ class RequestCharacteristicResource extends Resource
}),
Forms\Components\TextInput::make('approver_remark2')
->label('Approver Remark')
->reactive()
->live()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$appStat = $get('approver_status2');
if ($appStat && $state) {
$set('approved2_at', now()->toDateTimeString());
} else {
$set('approved2_at', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->readOnly(fn ($get) => ($get('approver_status2') == null))
->disabled(function ($get) {
$currentUser = Filament::auth()->user();
$updId = $get('id');
@@ -507,6 +641,7 @@ class RequestCharacteristicResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name);
})
->readOnly(fn ($get) => ($get('approver_status2') == null))
->disabled(function ($get) {
$currentUser = Filament::auth()->user(); // logged-in user
$approverId = $get('characteristic_approver_master_id');
@@ -550,9 +685,12 @@ class RequestCharacteristicResource extends Resource
'Rejected' => 'Rejected',
])
->afterStateUpdated(function ($state, callable $set, callable $get) {
if ($state && empty($get('approved3_at'))) {
$set('approved3_at', now());
if ($state) {
$set('approved3_at', now()->toDateTimeString());
} else {
$set('approved3_at', null);
}
$set('approver_remark3', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->disabled(function ($get) {
@@ -581,10 +719,17 @@ class RequestCharacteristicResource extends Resource
}),
Forms\Components\TextInput::make('approver_remark3')
->label('Approver Remark')
->reactive()
->live()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$appStat = $get('approver_status3');
if ($appStat && $state) {
$set('approved3_at', now()->toDateTimeString());
} else {
$set('approved3_at', null);
}
$set('updated_by', Filament::auth()->user()?->name);
})
->readOnly(fn ($get) => ($get('approver_status3') == null))
->disabled(function ($get) {
$currentUser = Filament::auth()->user();
$updId = $get('id');
@@ -608,6 +753,7 @@ class RequestCharacteristicResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name);
})
->readOnly(fn ($get) => ($get('approver_status3') == null))
->disabled(function ($get) {
$currentUser = Filament::auth()->user(); // logged-in user
$approverId = $get('characteristic_approver_master_id');
@@ -686,8 +832,8 @@ class RequestCharacteristicResource extends Resource
$prefix = "WF-{$year}{$month}{$date}-";
$lastWorkflow = RequestCharacteristic::where('work_flow_id', 'like', "{$prefix}%")
// ->where('plant_id', $plantId)
// ->where('machine_id', $MachineId)
->where('work_flow_id', 'like', "{$prefix}%")
->orderByDesc('work_flow_id')
->first();
@@ -695,12 +841,12 @@ class RequestCharacteristicResource extends Resource
$lastSerial = substr($lastWorkflow->work_flow_id, strlen($prefix));
$nextSerial = str_pad(
intval($lastSerial) + 1,
3,
4,
'0',
STR_PAD_LEFT
);
} else {
$nextSerial = '001';
$nextSerial = '0001';
}
$workFlowId = "{$prefix}{$nextSerial}";
@@ -726,7 +872,7 @@ class RequestCharacteristicResource extends Resource
->alignCenter()
->searchable(), // isIndividual: true
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->label('Plant Name')
->alignCenter()
->searchable()
->sortable(),
@@ -741,17 +887,22 @@ class RequestCharacteristicResource extends Resource
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('aufnr')
->label('Aufnr')
->label('Job Number')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('characteristicApproverMaster.machine_name')
->label('Machine')
->label('Machine Name')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('characteristicApproverMaster.approver_type')
->label('Request Type')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('characteristicApproverMaster.characteristic_field')
->label('Master Characteristic')
->label('Master Characteristic Field')
->alignCenter()
->searchable()
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
@@ -759,6 +910,7 @@ class RequestCharacteristicResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('characteristic_name')
->label('Characteristic Name')
->default('-')
->alignCenter()
->searchable()
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
@@ -766,13 +918,21 @@ class RequestCharacteristicResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('current_value')
->label('Current Value')
->default('-')
->alignCenter()
->searchable()
->formatStateUsing(function ($record) {
return empty($record->characteristic_name) ? '-' : $record->current_value;
})
->sortable(),
Tables\Columns\TextColumn::make('update_value')
->label('Update Value')
->default('-')
->alignCenter()
->searchable()
->formatStateUsing(function ($record) {
return empty($record->characteristic_name) ? '-' : $record->update_value;
})
->sortable(),
Tables\Columns\TextColumn::make('characteristicApproverMaster.name1')
->label('Approver Name 1')
@@ -860,8 +1020,21 @@ class RequestCharacteristicResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('mail_status')
->label('Mail Status')
->default('-')
->alignCenter()
->searchable()
->formatStateUsing(function ($state) {
if (! $state || $state == '' || $state == null) {
return '-';
}
return match ($state) {
'Sent' => 'Sent-Mail1',
'Sent-Mail2' => 'Sent-Mail2',
'Sent-Mail3' => 'Sent-Mail3',
default => '-',
};
})
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('trigger_at')

View File

@@ -53,7 +53,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
@@ -456,7 +456,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -55,7 +55,7 @@ class SerialValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(SerialValidation::latest()->first())->plant_id;
@@ -332,7 +332,7 @@ class SerialValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->label('Select Plant')
->required()
@@ -1038,7 +1038,7 @@ class SerialValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {

View File

@@ -10,16 +10,16 @@ use App\Models\Shift;
use Carbon\Carbon;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
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 Filament\Forms\Components\Section;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule;
class ShiftResource extends Resource
@@ -39,232 +39,229 @@ class ShiftResource extends Resource
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->required()
->relationship('plant', 'name')
->required()
// ->nullable()
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Shift::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Shift::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => ! empty($get('id')))
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
$set('block_id', null);
if (!$plantId) {
$set('sPlantError', 'Please select a plant first.');
return;
}
else
{
$set('sPlantError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sPlantError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sPlantError') ? $get('sPlantError') : null)
->hintColor('danger'),
Forms\Components\Select::make('block_id')
->relationship('block', 'name')
->required()
// ->nullable()
->reactive()
->default(function () {
return optional(Shift::latest()->first())->block_id;
})
// ->disabled(fn (Get $get) => !empty($get('id')))
// ->options(fn (callable $get) =>
// \App\Models\Block::where('plant_id', $get('plant_id'))
// ->pluck('name', 'id')
// ->toArray() // Convert collection to array
// )
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
$set('block_id', null);
if (! $plantId) {
$set('sPlantError', 'Please select a plant first.');
return \App\Models\Block::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
// ->afterStateUpdated(fn ($set) => $set('name', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$blockId = $get('block_id');
$set('name', null);
if (!$blockId) {
$set('sBlockError', 'Please select a block first.');
return;
}
else
{
$set('sBlockError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sBlockError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sBlockError') ? $get('sBlockError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('name')
->placeholder('Scan the valid name')
->autofocus(true)
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('name');
$set('start_time', null);
if (!$nameId) {
$set('sNameError', 'Scan the valid name.');
return;
}
else
{
// $exists = Shift::where('plant_id', $get('plant_id'))
// ->where('block_id', $get('block_id'))
// ->where('name', $nameId)
// ->latest()
// ->exists();
// if ($exists)
// {
// $set('start_time', null);
// $set('sNameError', 'Scanned name already exist.');
// return;
// }
$set('sNameError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sNameError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sNameError') ? $get('sNameError') : null)
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('shifts', 'name')
->where('plant_id', $get('plant_id'))
->where('block_id', $get('block_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TimePicker::make('start_time')
->required()
->label('Start Time')
->live()
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
// $set('end_time', self::calculateEndTime($state, $get('duration')))
// )
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$startTime = $get('start_time');
$set('duration', null);
$set('end_time', self::calculateEndTime($state, $get('duration')));
if (!$startTime) {
$set('sStartTimeError', 'Choose the valid start time.');
return;
}
else
{
// $exists = Shift::where('plant_id', $get('plant_id'))
// ->where('block_id', $get('block_id'))
// ->where('name', $get('name'))
// ->latest()
// ->exists();
// if ($exists)
// {
// $set('start_time', null);
// $set('sStartTimeError', null);
// $set('sNameError', 'Scanned name already exist.');
// return;
// }
$set('sStartTimeError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sStartTimeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sStartTimeError') ? $get('sStartTimeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('duration')
->required()
->placeholder('Scan the valid duration')
->numeric()
->inputMode('decimal')
->minValue(0.01) // Minimum valid duration
->lazy()
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
// $set('end_time', self::calculateEndTime($get('start_time'), $state))
// )
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$duration = $get('duration');
// $set('end_time', null);
$set('end_time', self::calculateEndTime($get('start_time'), $state));
if (!$duration) {
$set('sDurationError', 'Scan the valid duration.');
return;
}
else
{
[$hRs, $miNs] = explode('.', $duration) + [0, 0]; // Ensure two parts
$hRs = (int) $hRs;
$miNs = (int) $miNs;
$set('duration', $hRs.'.'.$miNs);
if ($miNs > 60) {
$set('sDurationError', 'Minutes exceeds 1 hour.');
$set('duration', null);
$set('end_time', null);
return;
} else {
$set('sPlantError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sPlantError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sPlantError') ? $get('sPlantError') : null)
->hintColor('danger'),
Forms\Components\Select::make('block_id')
->relationship('block', 'name')
->required()
// ->nullable()
->reactive()
->default(function () {
return optional(Shift::latest()->first())->block_id;
})
// ->disabled(fn (Get $get) => !empty($get('id')))
// ->options(fn (callable $get) =>
// \App\Models\Block::where('plant_id', $get('plant_id'))
// ->pluck('name', 'id')
// ->toArray() // Convert collection to array
// )
->options(function (callable $get) {
if (! $get('plant_id')) {
return [];
}
$totalMinutes = $hRs * 60 + $miNs;
return \App\Models\Block::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
// ->afterStateUpdated(fn ($set) => $set('name', null))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$blockId = $get('block_id');
$set('name', null);
if (! $blockId) {
$set('sBlockError', 'Please select a block first.');
if ($totalMinutes > 1440) {
$set('sDurationError', 'Duration exceeds 24 hours.');
$set('duration', null);
$set('end_time', null);
return;
} else {
$set('sBlockError', null);
}
$set('sDurationError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sDurationError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sDurationError') ? $get('sDurationError') : null)
->hintColor('danger'),
Forms\Components\TimePicker::make('end_time')
->required()
->label('End Time')
->readOnly()
// ->native(false),
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$endTime = $get('end_time');
$set('end_time', self::calculateEndTime($get('start_time'), $state));
if (!$endTime) {
$set('sEndTimeError', 'Choose the valid start time & duration.');
return;
}
else
{
$set('sEndTimeError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sEndTimeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
->columns(2),
})
->extraAttributes(fn ($get) => [
'class' => $get('sBlockError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sBlockError') ? $get('sBlockError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('name')
->placeholder('Scan the valid name')
->autofocus(true)
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('name');
$set('start_time', null);
if (! $nameId) {
$set('sNameError', 'Scan the valid name.');
return;
} else {
// $exists = Shift::where('plant_id', $get('plant_id'))
// ->where('block_id', $get('block_id'))
// ->where('name', $nameId)
// ->latest()
// ->exists();
// if ($exists)
// {
// $set('start_time', null);
// $set('sNameError', 'Scanned name already exist.');
// return;
// }
$set('sNameError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sNameError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sNameError') ? $get('sNameError') : null)
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('shifts', 'name')
->where('plant_id', $get('plant_id'))
->where('block_id', $get('block_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TimePicker::make('start_time')
->required()
->label('Start Time')
->live()
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
// $set('end_time', self::calculateEndTime($state, $get('duration')))
// )
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$startTime = $get('start_time');
$set('duration', null);
$set('end_time', self::calculateEndTime($state, $get('duration')));
if (! $startTime) {
$set('sStartTimeError', 'Choose the valid start time.');
return;
} else {
// $exists = Shift::where('plant_id', $get('plant_id'))
// ->where('block_id', $get('block_id'))
// ->where('name', $get('name'))
// ->latest()
// ->exists();
// if ($exists)
// {
// $set('start_time', null);
// $set('sStartTimeError', null);
// $set('sNameError', 'Scanned name already exist.');
// return;
// }
$set('sStartTimeError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sStartTimeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sStartTimeError') ? $get('sStartTimeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('duration')
->required()
->placeholder('Scan the valid duration')
->numeric()
->inputMode('decimal')
->minValue(0.01) // Minimum valid duration
->lazy()
// ->afterStateUpdated(fn (callable $set, callable $get, $state) =>
// $set('end_time', self::calculateEndTime($get('start_time'), $state))
// )
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$duration = $get('duration');
// $set('end_time', null);
$set('end_time', self::calculateEndTime($get('start_time'), $state));
if (! $duration) {
$set('sDurationError', 'Scan the valid duration.');
return;
} else {
[$hRs, $miNs] = explode('.', $duration) + [0, 0]; // Ensure two parts
$hRs = (int) $hRs;
$miNs = (int) $miNs;
$set('duration', $hRs.'.'.$miNs);
if ($miNs > 60) {
$set('sDurationError', 'Minutes exceeds 1 hour.');
$set('duration', null);
$set('end_time', null);
return;
}
$totalMinutes = $hRs * 60 + $miNs;
if ($totalMinutes > 1440) {
$set('sDurationError', 'Duration exceeds 24 hours.');
$set('duration', null);
$set('end_time', null);
return;
}
$set('sDurationError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sDurationError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sDurationError') ? $get('sDurationError') : null)
->hintColor('danger'),
Forms\Components\TimePicker::make('end_time')
->required()
->label('End Time')
->readOnly()
// ->native(false),
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$endTime = $get('end_time');
$set('end_time', self::calculateEndTime($get('start_time'), $state));
if (! $endTime) {
$set('sEndTimeError', 'Choose the valid start time & duration.');
return;
} else {
$set('sEndTimeError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('sEndTimeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('sEndTimeError') ? $get('sEndTimeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
->columns(2),
]);
}
@@ -282,6 +279,7 @@ class ShiftResource extends Resource
$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')
@@ -347,14 +345,14 @@ class ShiftResource extends Resource
->label('Import Shifts')
->color('warning')
->importer(ShiftImporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view import shift');
}),
ExportAction::make()
->label('Export Shifts')
->color('warning')
->exporter(ShiftExporter::class)
->visible(function() {
->visible(function () {
return Filament::auth()->user()->can('view export shift');
}),
]);
@@ -387,7 +385,7 @@ class ShiftResource extends Resource
protected static function calculateEndTime(?string $startTime, ?string $duration): ?string
{
if (!$startTime || !$duration) {
if (! $startTime || ! $duration) {
return null;
}
@@ -397,7 +395,7 @@ class ShiftResource extends Resource
// Ensure duration is in a valid numeric format
$duration = str_replace(',', '.', $duration); // Handle decimal formats
if (!is_numeric($duration)) {
if (! is_numeric($duration)) {
return null; // Invalid duration format
}

View File

@@ -264,7 +264,7 @@ class StickerMasterResource extends Resource
->label('Laser Part Validation 2')
->nullable()
->reactive()
->readOnly(fn (callable $get) => empty($get('laser_part_validation1')))
// ->readOnly(fn (callable $get) => empty($get('laser_part_validation1')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name);
}),
@@ -625,11 +625,13 @@ class StickerMasterResource extends Resource
Tables\Columns\TextColumn::make('laser_part_validation1')
->label('Laser Part Validation 1')
->default('-')
->alignCenter(),
->alignCenter()
->searchable(),
Tables\Columns\TextColumn::make('laser_part_validation2')
->label('Laser Part Validation 2')
->default('-')
->alignCenter(),
->alignCenter()
->searchable(),
Tables\Columns\TextColumn::make('panel_box_code')
->label('Panel Box Code')
->default('-')

View File

@@ -2,6 +2,8 @@
namespace App\Filament\Resources;
use App\Filament\Exports\StickerPrintingExporter;
use App\Filament\Imports\StickerPrintingImporter;
use App\Filament\Resources\StickerPrintingResource\Pages;
use App\Models\Plant;
use App\Models\StickerPrinting;
@@ -11,14 +13,11 @@ use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use App\Filament\Exports\StickerPrintingExporter;
use App\Filament\Imports\StickerPrintingImporter;
use Filament\Forms\Components\Actions\Action;
class StickerPrintingResource extends Resource
{
@@ -40,13 +39,14 @@ class StickerPrintingResource extends Resource
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
if (! $plantId) {
$set('reference_number', null);
$set('serial_number', null);
$set('ivPlantError', 'Please select a plant first.');
@@ -64,7 +64,7 @@ class StickerPrintingResource extends Resource
Forms\Components\TextInput::make('reference_number')
->label('Reference Number')
->reactive()
->readOnly(fn (callable $get) => !empty($get('serial_number')))
->readOnly(fn (callable $get) => ! empty($get('serial_number')))
->extraAttributes([
'id' => 'invoice_number_input',
'x-data' => '{ value: "" }',
@@ -82,9 +82,9 @@ class StickerPrintingResource extends Resource
'x-data' => '{ value: "" }',
'x-model' => 'value',
'wire:keydown.enter.prevent' => 'processSno(value)',
//'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)',
// 'x-on:keydown.enter.prevent' => '$wire.processInvoice(value)',
]),
//->required(),
// ->required(),
Forms\Components\View::make('forms.components.print-button'),
Forms\Components\Hidden::make('created_by')

View File

@@ -5,28 +5,27 @@ namespace App\Filament\Resources;
use App\Filament\Exports\TempLiveReadingExporter;
use App\Filament\Imports\TempLiveReadingImporter;
use App\Filament\Resources\TempLiveReadingResource\Pages;
use App\Filament\Resources\TempLiveReadingResource\RelationManagers;
use App\Models\MfmMeter;
use App\Models\Plant;
use App\Models\TempLiveReading;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class TempLiveReadingResource extends Resource
{
protected static ?string $model = TempLiveReading::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Power House';
public static function form(Form $form): Form
@@ -34,37 +33,38 @@ class TempLiveReadingResource extends Resource
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
->required()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}),
Forms\Components\Select::make('mfm_meter_id')
->label('MFM Meter ID')
->required()
->reactive()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
return [];
}
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
->required()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return MfmMeter::where('plant_id', $plantId)
->pluck('sequence', 'id')
->toArray();
}),
Forms\Components\TextInput::make('register_data')
->label('Register Data')
->required(),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
}),
Forms\Components\Select::make('mfm_meter_id')
->label('MFM Meter ID')
->required()
->reactive()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (! $plantId) {
return [];
}
return MfmMeter::where('plant_id', $plantId)
->pluck('sequence', 'id')
->toArray();
}),
Forms\Components\TextInput::make('register_data')
->label('Register Data')
->required(),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
])
->columns(3),
->columns(3),
]);
}
@@ -78,6 +78,7 @@ class TempLiveReadingResource extends Resource
$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')
@@ -119,18 +120,18 @@ class TempLiveReadingResource extends Resource
Tables\Actions\RestoreBulkAction::make(),
]),
]);
// ->headerActions([
// ImportAction::make()
// ->importer(TempLiveReadingImporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view import temp live reading');
// }),
// ExportAction::make()
// ->exporter(TempLiveReadingExporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view export temp live reading');
// }),
// ]);
// ->headerActions([
// ImportAction::make()
// ->importer(TempLiveReadingImporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view import temp live reading');
// }),
// ExportAction::make()
// ->exporter(TempLiveReadingExporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view export temp live reading');
// }),
// ]);
}
public static function getRelations(): array
@@ -139,6 +140,7 @@ class TempLiveReadingResource extends Resource
//
];
}
public static function getNavigationLabel(): string
{
return 'Live Readings';
@@ -149,7 +151,6 @@ class TempLiveReadingResource extends Resource
return 'Live Readings';
}
public static function getPages(): array
{
return [

View File

@@ -63,7 +63,7 @@ class TestingPanelReadingResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(TestingPanelReading::latest()->first())->plant_id;
@@ -480,7 +480,10 @@ class TestingPanelReadingResource extends Resource
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
// return Plant::pluck('name', 'id');
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {

View File

@@ -47,7 +47,7 @@ class WeightValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\Select::make('item_id')
@@ -168,7 +168,7 @@ class WeightValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->reactive(),
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
@@ -406,7 +406,7 @@ class WeightValidationResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->label('Select Plant')
->required()

View File

@@ -45,7 +45,7 @@ class WorkGroupMasterResource extends Resource
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');

View File

@@ -8,9 +8,6 @@ use Illuminate\Http\Request;
class CharacteristicApprovalController extends Controller
{
/**
* Display a listing of the resource.
*/
public function approve(Request $request)
{
return $this->updateStatus($request, 'Approved');
@@ -55,11 +52,31 @@ class CharacteristicApprovalController extends Controller
foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [
'status' => 'Already processed by another approver',
'status' => $record->$column,
'message' => 'Your request has already been processed by another approver',
]);
}
}
foreach ($levels as $lvl => $column)
{
if ($record->$column == 'Hold') {
if ($lvl == $level) {
return view('approval.already-processed', [
'status' => 'On Hold',
]);
}
// else
// {
// return view('approval.already-processed', [
// 'status' => 'Hold',
// 'message' => 'On Hold',
// ]);
// }
}
}
$allowedMailStatusByLevel = [
1 => 'Sent',
2 => 'Sent-Mail2',
@@ -69,8 +86,8 @@ class CharacteristicApprovalController extends Controller
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
if ($record->mail_status != $expectedMailStatus) {
return view('approval.already-processed', [
'status' => 'You are not authorized to act at this level',
return view('approval.approve-level', [
'status' => 'Your approval time limit has expired.',
]);
}
@@ -80,7 +97,6 @@ class CharacteristicApprovalController extends Controller
public function rejectForm(Request $request)
{
$id = $request->query('id');
// $level = $request->query('level');
$level = (int) $request->query('level');
$record = RequestCharacteristic::findOrFail($id);
@@ -111,11 +127,30 @@ class CharacteristicApprovalController extends Controller
foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [
'status' => 'Already processed by another approver',
'status' => $record->$column,
'message' => 'Your request has already been processed by another approver',
]);
}
}
// foreach ($levels as $lvl => $column) {
// if ($record->$column == 'Hold') {
// if ($lvl == $level) {
// return view('approval.reject-form', compact('id', 'level'));
// }
// else
// {
// return view('approval.already-processed', [
// 'status' => 'Hold',
// 'message' => 'On Hold',
// ]);
// }
// }
// }
$allowedMailStatusByLevel = [
1 => 'Sent',
2 => 'Sent-Mail2',
@@ -125,14 +160,90 @@ class CharacteristicApprovalController extends Controller
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
if ($record->mail_status != $expectedMailStatus) {
return view('approval.already-processed', [
'status' => 'You are not authorized to act at this level',
return view('approval.approve-level', [
'status'=> $currentStatus,
'message' => 'Your approval time limit has expired.',
]);
}
return view('approval.reject-form', compact('id', 'level'));
}
public function approveForm(Request $request)
{
$id = $request->query('id');
$level = (int) $request->query('level');
$record = RequestCharacteristic::findOrFail($id);
[$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
default => abort(403, 'Invalid approver level'),
};
$levels = [
1 => 'approver_status1',
2 => 'approver_status2',
3 => 'approver_status3',
];
$currentStatusColumn = $levels[$level];
$currentStatus = $record->$statusColumn;
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [
'status' => $currentStatus,
]);
}
foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [
'status' => $record->$column,
'message' => 'Your request has already been processed by another approver',
]);
}
}
// foreach ($levels as $lvl => $column) {
// if ($record->$column == 'Hold') {
// if ($lvl == $level) {
// return view('approval.reject-form', compact('id', 'level'));
// }
// else
// {
// return view('approval.already-processed', [
// 'status' => 'Hold',
// 'message' => 'On Hold',
// ]);
// }
// }
// }
$allowedMailStatusByLevel = [
1 => 'Sent',
2 => 'Sent-Mail2',
3 => 'Sent-Mail3',
];
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
if ($record->mail_status != $expectedMailStatus) {
return view('approval.approve-level', [
'status'=> $currentStatus,
'message' => 'Your approval time limit has expired.',
]);
}
return view('approval.approve-form', compact('id', 'level'));
}
public function holdSave(Request $request)
{
$request->validate([
@@ -155,6 +266,17 @@ class CharacteristicApprovalController extends Controller
return $this->updateStatus($request, 'Rejected', false);
}
public function approveSave(Request $request)
{
$request->validate([
'id' => 'required|integer',
'level' => 'required|integer',
'remark' => 'nullable|string',
]);
return $this->updateStatus($request, 'Approved', false);
}
protected function updateStatus(Request $request, string $status, bool $returnView = true)
{
$requestId = $request->input('id');
@@ -189,19 +311,27 @@ class CharacteristicApprovalController extends Controller
})
->get();
$alreadyProcessed = RequestCharacteristic::whereIn($statusColumn, ['Approved', 'Rejected'])->exists();
$currentStatus = $record->$statusColumn;
if ($alreadyProcessed) {
if ($returnView) {
$levels = [
1 => 'approver_status1',
2 => 'approver_status2',
3 => 'approver_status3',
];
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [
'status' => $currentStatus,
]);
}
foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [
'status' => 'Already processed',
'status' => $record->$column,
'message' => 'your request has already been processed by another approver',
]);
}
return response()->json([
'status' => false,
'message' => 'This request has already been processed.',
], 404);
}
$allowedMailStatusByLevel = [
@@ -214,8 +344,9 @@ class CharacteristicApprovalController extends Controller
if ($record->mail_status != $expectedMailStatus) {
if ($returnView) {
return view('approval.already-processed', [
'status' => 'You are not authorized to act at this level',
return view('approval.approve-level', [
'status' => $currentStatus,
'message' => 'Your approval time limit has expired.',
]);
}
@@ -225,15 +356,21 @@ class CharacteristicApprovalController extends Controller
], 403);
}
$workflowRecords = RequestCharacteristic::where('plant_id', $record->plant_id)
->where('machine_id', $record->machine_id)
->where('aufnr', $record->aufnr)
->where('work_flow_id', $record->work_flow_id)
->get();
$updateData = [
$statusColumn => $status,
$remarkColumn => $request->input('remark'),
$approvedAtColumn => Carbon::now(),
];
// if ($status == 'Approved') {
// $updateData[$approvedAtColumn] = Carbon::now();
// }
if (in_array($status, ['Approved', 'Rejected'])) {
$updateData['trigger_at'] = null;
}
foreach ($pendingRecords as $rec) {
$rec->update($updateData);
@@ -243,6 +380,10 @@ class CharacteristicApprovalController extends Controller
$recd->update($updateData);
}
foreach ($workflowRecords as $r) {
$r->update($updateData);
}
if ($returnView) {
return match ($status) {
'Approved' => view('approval.success'),

File diff suppressed because it is too large Load Diff

View File

@@ -590,6 +590,13 @@ class PdfController extends Controller
->orderBy('id', 'desc')
->first();
$lastRecord1 = ProcessOrder::with('item')
->where('plant_id', $plant->id)
->where('process_order', $processOrder)
->where('rework_status', 0)
->orderBy('id', 'desc')
->first();
$totalReceivedQty = $processOrderRecords->sum('received_quantity');
// $lastRecord = $processOrderRecords->first();
$item = $lastRecord->item;
@@ -612,12 +619,14 @@ class PdfController extends Controller
$notOkQty = CharacteristicValue::where('plant_id', $plant->id)->where('process_order', $processOrder)->where('status', 'NotOk')->get()->count();
$currentCoil = ($lastRecord->rework_status == 1) ? (string) $lastRecord1->coil_number : (string) $lastRecord->coil_number;
return response()->json([
'item_code' => $item?->code ?? '',
'description' => $item?->description ?? '',
// 'coil_number' => $proOrdAgPlant->coil_number ?? "",
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
'coil_number' => (string) $lastRecord->coil_number ?? '0',
'coil_number' => $currentCoil,
'order_quantity' => (string) $lastRecord->order_quantity ?? '0.000',
'ok_quantity' => (string) $okQty ?? '0',
'not_ok_quantity' => (string) $notOkQty ?? '0',
@@ -746,7 +755,7 @@ class PdfController extends Controller
'status_code' => 'ERROR',
'status_description' => "Coil number can't be empty!",
], 404);
} elseif (! is_numeric($coilNo) || Str::length($coilNo) <= 0 || !preg_match('/^\d+(\.\d+)?$/', $coilNo)
} elseif (! is_numeric($coilNo) || Str::length($coilNo) <= 0 || ! preg_match('/^\d+(\.\d+)?$/', $coilNo)
) { // !ctype_digit($data['plant_code'])
return response()->json([
'status_code' => 'ERROR',
@@ -853,10 +862,35 @@ class PdfController extends Controller
->sum('received_quantity');
if ($orderQty == 0) {
$orderQty = ProcessOrder::where('plant_id', $plantId)
$orderExist = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)
->value('order_quantity') ?? 0;
->where('item_id', $itemId)->latest()->first();
// ->value('order_quantity') ?? 0;
if ($orderExist) {
$orderQty = $orderExist->order_quantity ?? 0;
} else {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Order quantity can't be '0'",
], 404);
}
} else {
$orderExist = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)->latest()->first();
// ->value('order_quantity') ?? 0;
if ($orderExist) {
$existOrderQty = $orderExist->order_quantity ?? 0;
if ($existOrderQty != $orderQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Order quantity doesn't equal to exist process order '{$processOrder}'",
], 404);
}
}
}
$total = $alreadyReceived + $receivedQty;
@@ -871,7 +905,7 @@ class PdfController extends Controller
if ($rework == null || $rework == '' || ! $rework) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework can't be empty!",
'status_description' => "Rework value can't be empty!",
], 404);
}
@@ -889,35 +923,125 @@ class PdfController extends Controller
}
}
$coilNo = (string) $coilNo;
try {
if ($rework == 'Yes') {
$updated = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
->where('coil_number', $coilNo)
->update([
// 'order_quantity' => $orderQty,
'received_quantity' => $receivedQty,
'scrap_quantity' => $scrapQty,
// 'sfg_number' => $sfgNo,
// 'machine_name' => $machineId,
'rework_status' => 1,
'updated_by' => $createdBy,
'updated_at' => now(),
]);
if ($coilNo && Str::contains($coilNo, '.')) {
// Contains dot
$coilMain = explode('.', $coilNo)[0]; // 333
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
->where('coil_number', $coilMain)
->first();
if (! $existingCoil) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Coil number '{$coilMain}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
], 404);
} elseif ($existingCoil->rework_status == 0) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework coil number '{$coilMain}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
], 404);
}
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
->where('coil_number', $coilNo)
->first();
if (! $existingCoil) {
ProcessOrder::Create(
[
'plant_id' => $plantId,
'line_id' => $lineNamePlantId,
'process_order' => $processOrder,
'item_id' => $itemId,
'coil_number' => $coilNo,
'order_quantity' => $orderQty,
'received_quantity' => $receivedQty,
'scrap_quantity' => $scrapQty,
'sfg_number' => $sfgNo,
'machine_name' => $machineId,
'rework_status' => 1,
'created_by' => $createdBy,
]
);
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => 'Record Updated Successfully (Rework).',
]);
} else {
$updated = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
->where('coil_number', $coilNo)
->update([
// 'order_quantity' => $orderQty,
'received_quantity' => $receivedQty,
'scrap_quantity' => $scrapQty,
// 'sfg_number' => $sfgNo,
// 'machine_name' => $machineId,
'rework_status' => 1,
'updated_by' => $createdBy,
'updated_at' => now(),
]);
}
} else {
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
->where('coil_number', $coilNo)
->first();
if (! $existingCoil) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Coil number '{$coilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
], 404);
}
$updated = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
->where('coil_number', $coilNo)
->update([
// 'order_quantity' => $orderQty,
'received_quantity' => $receivedQty,
'scrap_quantity' => $scrapQty,
// 'sfg_number' => $sfgNo,
// 'machine_name' => $machineId,
'rework_status' => 1,
'updated_by' => $createdBy,
'updated_at' => now(),
]);
}
if ($updated == 0) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'No matching record found for rework coil number!',
'status_description' => "No matching record found for rework coil number '{$coilNo}'!",
], 404);
} else {
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => 'Record Updated Successfully (Rework)',
'status_description' => 'Record Updated Successfully (Rework).',
]);
}
} else {
if ($coilNo && Str::contains($coilNo, '.')) {
return response()->json([
'status_code' => 'ERROR',
'status_description1' => "Rework value should be 'Yes' for rework coil number '{$coilNo}'!",
], 404);
}
$existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
@@ -926,7 +1050,8 @@ class PdfController extends Controller
if ($existing) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
'status_description' => "Coil number '{$coilNo}' already exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
// "Process order '{$processOrder}' with coil number '{$coilNo}' already exist for the plant code '{$plantCode}'!",
], 404);
}
@@ -949,7 +1074,7 @@ class PdfController extends Controller
return response()->json([
'status_code' => 'SUCCESS',
'status_description' => 'Record Inserted Successfully',
'status_description' => 'Record Inserted Successfully.',
]);
}
} catch (\Exception $e) {

View File

@@ -0,0 +1,310 @@
<?php
namespace App\Livewire;
use App\Exports\ProductionPlanExport;
use App\Models\ProductionPlan;
use App\Models\ProductionQuantity;
use Livewire\Component;
use Carbon\Carbon;
use DB;
use Maatwebsite\Excel\Facades\Excel;
class ProductionTargetPlan extends Component
{
public $plantId, $lineId, $month, $year;
public $records = [];
public $dates = [];
public $leaveDates = [];
public $productionPlanDates = '';
protected $listeners = [
'loadData' => 'loadProductionData',
'loadData1' => 'exportProductionData',
];
public function getMonthDates($month, $year)
{
$start = Carbon::createFromDate($year, $month, 1);
$days = $start->daysInMonth;
$dates = [];
for ($i = 1; $i <= $days; $i++) {
$dates[] = Carbon::createFromDate($year, $month, $i)
->format('Y-m-d');
}
return $dates;
}
// public function loadProductionData($plantId, $lineId, $month, $year){
// if (!$plantId || !$lineId || !$month || !$year) {
// $this->records = [];
// $this->dates = [];
// $this->leaveDates = [];
// return;
// }
// $this->dates = $this->getMonthDates($month, $year);
// $data = ProductionPlan::query()
// ->join('items', 'items.id', '=', 'production_plans.item_id')
// ->join('lines', 'lines.id', '=', 'production_plans.line_id')
// ->join('plants', 'plants.id', '=', 'production_plans.plant_id')
// ->where('production_plans.plant_id', $plantId)
// ->where('production_plans.line_id', $lineId)
// ->whereMonth('production_plans.created_at', $month)
// ->whereYear('production_plans.created_at', $year)
// ->select(
// 'production_plans.created_at',
// 'production_plans.operator_id',
// 'plants.name as plant',
// 'items.code as item_code',
// 'items.description as item_description',
// 'lines.name as line_name',
// 'production_plans.leave_dates'
// )
// ->first();
// if ($data && $data->leave_dates) {
// $this->leaveDates = array_map('trim', explode(',', $data->leave_dates));
// }
// $producedData = ProductionQuantity::selectRaw("
// plant_id,
// line_id,
// item_id,
// DATE(created_at) as prod_date,
// COUNT(*) as total_qty
// ")
// ->where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereMonth('created_at', $month)
// ->whereYear('created_at', $year)
// ->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
// ->get()
// ->groupBy(function ($row) {
// return $row->plant_id . '_' . $row->line_id . '_' . $row->item_id;
// })
// ->map(function ($group) {
// return $group->keyBy('prod_date');
// });
// $this->records = ProductionPlan::query()
// ->join('items', 'items.id', '=', 'production_plans.item_id')
// ->join('lines', 'lines.id', '=', 'production_plans.line_id')
// ->join('plants', 'plants.id', '=', 'production_plans.plant_id')
// ->where('production_plans.plant_id', $plantId)
// ->where('production_plans.line_id', $lineId)
// ->whereMonth('production_plans.created_at', $month)
// ->whereYear('production_plans.created_at', $year)
// ->select(
// 'production_plans.item_id',
// 'production_plans.plant_id',
// 'production_plans.line_id',
// 'production_plans.plan_quantity',
// 'production_plans.working_days',
// 'items.code as item_code',
// 'items.description as item_description',
// 'lines.name as line_name',
// 'plants.name as plant_name'
// )
// ->get()
// ->map(function ($row) use ($producedData) {
// $row = $row->toArray();
// $remainingQty = $row['plan_quantity'];
// // $remainingDays = $row['working_days'];
// $remainingDays = (int) ($row['working_days'] ?? 0);
// $row['daily_target_dynamic'] = [];
// $row['produced_quantity'] = [];
// $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
// foreach ($this->dates as $date) {
// // Skip leave dates
// if (in_array($date, $this->leaveDates)) {
// $row['daily_target_dynamic'][$date] = '-';
// $row['produced_quantity'][$date] = '-';
// continue;
// }
// $todayTarget = $remainingDays > 0
// ? round($remainingQty / $remainingDays, 2)
// : 0;
// //$todayTarget = $remainingDays > 0
// // ? $remainingQty / $remainingDays
// // : 0;
// $producedQty = isset($producedData[$key][$date])
// ? $producedData[$key][$date]->total_qty
// : 0;
// $row['daily_target_dynamic'][$date] = $todayTarget;
// $row['produced_quantity'][$date] = $producedQty;
// // Carry forward pending
// $remainingQty -= $producedQty;
// if ($remainingQty < 0) {
// $remainingQty = 0;
// }
// if ($remainingDays > 0) {
// $remainingDays--;
// }
// // $remainingDays--;
// }
// return $row;
// })
// ->toArray();
// }
public function loadProductionData($plantId, $lineId, $month, $year)
{
if (!$plantId || !$lineId || !$month || !$year) {
$this->records = [];
$this->dates = [];
$this->leaveDates = [];
return;
}
$dates = $this->getMonthDates($month, $year);
$this->dates = $dates;
$plans = ProductionPlan::query()
->join('items', 'items.id', '=', 'production_plans.item_id')
->join('lines', 'lines.id', '=', 'production_plans.line_id')
->join('plants', 'plants.id', '=', 'production_plans.plant_id')
->where('production_plans.plant_id', $plantId)
->where('production_plans.line_id', $lineId)
->whereMonth('production_plans.created_at', $month)
->whereYear('production_plans.created_at', $year)
->select(
'production_plans.item_id',
'production_plans.plant_id',
'production_plans.line_id',
'production_plans.plan_quantity',
'production_plans.working_days',
'production_plans.leave_dates',
'items.code as item_code',
'items.description as item_description',
'lines.name as line_name',
'lines.line_capacity as line_capacity',
'plants.name as plant_name'
)
->get();
$leaveDates = [];
if ($plans->isNotEmpty() && $plans[0]->leave_dates) {
$leaveDates = array_map('trim', explode(',', $plans[0]->leave_dates));
}
$this->leaveDates = $leaveDates;
$producedData = ProductionQuantity::selectRaw("
plant_id,
line_id,
item_id,
DATE(created_at) as prod_date,
COUNT(*) as total_qty
")
->where('plant_id', $plantId)
->where('line_id', $lineId)
->whereMonth('created_at', $month)
->whereYear('created_at', $year)
->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
->get()
->groupBy(fn($row) =>
$row->plant_id . '_' . $row->line_id . '_' . $row->item_id
)
->map(fn($group) => $group->keyBy('prod_date'));
$records = [];
foreach ($plans as $plan) {
$row = $plan->toArray();
$remainingQty = (float) $row['plan_quantity'];
$remainingDays = (int) ($row['working_days'] ?? 0);
$lineCapacity = (float) ($row['line_capacity'] ?? 0);
$dailyLineCapacity = (float) ($row['line_capacity'] ?? 0);
$row['daily_line_capacity'] = [];
$row['daily_target_dynamic'] = [];
$row['produced_quantity'] = [];
$key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
foreach ($dates as $date) {
// Skip leave dates fast
if (isset($leaveDates) && in_array($date, $leaveDates)) {
$row['daily_line_capacity'][$date] = '-';
$row['daily_target_dynamic'][$date] = '-';
$row['produced_quantity'][$date] = '-';
continue;
}
$todayTarget = $remainingDays > 0
? round($remainingQty / $remainingDays, 2)
: 0;
$producedQty = $producedData[$key][$date]->total_qty ?? 0;
$row['daily_target_dynamic'][$date] = $todayTarget;
$row['produced_quantity'][$date] = $producedQty;
$row['daily_line_capacity'][$date] = $dailyLineCapacity;
// Carry forward remaining qty
$remainingQty = max(0, $remainingQty - $producedQty);
if ($remainingDays > 0) {
$remainingDays--;
}
}
$records[] = $row;
}
$this->records = $records;
}
public function exportProductionData()
{
return Excel::download(
new ProductionPlanExport($this->records, $this->dates),
'production_plan_data.xlsx'
);
}
public function render()
{
// return view('livewire.production-target-plan');
return view('livewire.production-target-plan', [
'records' => $this->records,
'dates' => $this->dates,
]);
}
}

View File

@@ -23,15 +23,24 @@ class CharacteristicApprovalMail extends Mailable
public $pdfPath;
public $tableData;
public $pendingApprovers;
public $approverNameFromMaster;
public $subjectLine;
/**
* Create a new message instance.
*/
public function __construct($request, $approverName, $level, $pdfPath = null, $characteristics = [])
public function __construct($request, $approverName, $level, $pdfPath = null, $pendingApprovers, $approverNameFromMaster, $subjectLine, $characteristics = [])
{
$this->request = $request;
$this->approverName = $approverName;
$this->level = $level;
$this->pdfPath = $pdfPath;
$this->pendingApprovers = $pendingApprovers;
$this->approverNameFromMaster = $approverNameFromMaster;
$this->subjectLine = $subjectLine;
$this->tableData = $characteristics;
}
@@ -41,7 +50,7 @@ class CharacteristicApprovalMail extends Mailable
public function envelope(): Envelope
{
return new Envelope(
subject: 'Characteristic Approval Mail',
subject: $this->subjectLine,
);
}
@@ -56,7 +65,10 @@ class CharacteristicApprovalMail extends Mailable
'company' => 'CRI Digital Manufacturing Solutions',
'greeting' => 'Dear ' . $this->approverName . ',',
'request' => $this->request,
'level' => $this->level,
'tableData' => $this->tableData,
'pendingApprovers' => $this->pendingApprovers,
'approverNameFromMaster' => $this->approverNameFromMaster,
'approveUrl' => $this->approveUrl(),
'holdUrl' => $this->holdUrl(),
'rejectUrl' => $this->rejectUrl(),
@@ -112,4 +124,7 @@ class CharacteristicApprovalMail extends Mailable
)->as(basename($this->pdfPath)),
];
}
}

View File

@@ -15,6 +15,7 @@ class CharacteristicApproverMaster extends Model
'machine_id',
'machine_name',
'characteristic_field',
'approver_type',
'name1',
'mail1',
'name2',
@@ -39,4 +40,9 @@ class CharacteristicApproverMaster extends Model
{
return $this->belongsTo(Machine::class);
}
public function requestCharacteristics()
{
return $this->hasMany(RequestCharacteristic::class, 'characteristic_approver_master_id');
}
}

View File

@@ -8,17 +8,17 @@ use Illuminate\Database\Eloquent\SoftDeletes;
class GrMaster extends Model
{
use SoftDeletes;
use SoftDeletes;
protected $fillable = [
"plant_id",
"item_id",
"serial_number",
"gr_number",
"created_at",
"created_by",
"updated_by",
"updated_at"
'plant_id',
'item_id',
'serial_number',
'gr_number',
'created_at',
'created_by',
'updated_at',
'updated_by',
];
public function plant(): BelongsTo
@@ -30,5 +30,4 @@ class GrMaster extends Model
{
return $this->belongsTo(Item::class);
}
}

View File

@@ -12,6 +12,7 @@ class Item extends Model
protected $fillable = [
'plant_id',
'line_id',
'category',
'code',
'description',
@@ -19,11 +20,16 @@ class Item extends Model
'uom',
];
public function plant(): BelongsTo
public function plant()
{
return $this->belongsTo(Plant::class);
}
public function item()
{
return $this->belongsTo(Item::class, 'item_id', 'id');
}
public function stickerMasters()
{
return $this->hasMany(StickerMaster::class, 'item_id', 'id');

View File

@@ -3,30 +3,32 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Line extends Model
{
use SoftDeletes;
protected $fillable = [
"plant_id",
"name",
"type",
"group_work_center",
"no_of_operation",
"work_group1_id",
"work_group2_id",
"work_group3_id",
"work_group4_id",
"work_group5_id",
"work_group6_id",
"work_group7_id",
"work_group8_id",
"work_group9_id",
"work_group10_id",
'plant_id',
'block_id',
'name',
'type',
'line_capacity',
'group_work_center',
'no_of_operation',
'work_group1_id',
'work_group2_id',
'work_group3_id',
'work_group4_id',
'work_group5_id',
'work_group6_id',
'work_group7_id',
'work_group8_id',
'work_group9_id',
'work_group10_id',
];
public function plant(): BelongsTo
@@ -34,6 +36,11 @@ class Line extends Model
return $this->belongsTo(Plant::class);
}
public function block(): BelongsTo
{
return $this->belongsTo(Block::class);
}
public function testingPanelReadings()
{
return $this->hasMany(TestingPanelReading::class);

View File

@@ -5,23 +5,22 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class ProductCharacteristicsMaster extends Model
{
use SoftDeletes;
use SoftDeletes;
protected $fillable = [
'plant_id',
'line_id',
'item_id',
'line_id',
'work_group_master_id',
'machine_id',
'characteristics_type',
'name',
'inspection_type',
'characteristics_type',
'upper',
'lower',
'upper',
'middle',
'created_at',
'updated_at',

View File

@@ -16,9 +16,12 @@ class ProductionPlan extends Model
protected $fillable = [
'plant_id',
'shift_id',
'item_id',
'line_id',
'plan_quantity',
'production_quantity',
'working_days',
'leave_dates',
'operator_id',
'created_at',
'updated_at',
@@ -39,6 +42,11 @@ class ProductionPlan extends Model
return $this->belongsTo(Line::class);
}
public function item(): BelongsTo
{
return $this->belongsTo(Item::class);
}
public function prunable(): Builder
{
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));

View File

@@ -22,6 +22,7 @@ class ProductionQuantity extends Model
'shift_id',
'line_id',
'item_id',
'machine_id',
'serial_number',
'production_order',
'operator_id',
@@ -53,6 +54,11 @@ class ProductionQuantity extends Model
return $this->belongsTo(Item::class);
}
public function machine(): BelongsTo
{
return $this->belongsTo(Machine::class);
}
protected static function booted()
{
static::created(function ($productionQuantity) {

View File

@@ -8,7 +8,7 @@
"require": {
"php": "^8.2",
"alperenersoy/filament-export": "^3.0",
"althinect/filament-spatie-roles-permissions": "^2.3",
"althinect/filament-spatie-roles-permissions": "^3.0",
"erag/laravel-pwa": "^1.9",
"filament/filament": "^3.3",
"intervention/image": "^3.11",

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
ALTER TABLE production_plans
ADD COLUMN item_id BIGINT DEFAULT NULL,
ADD CONSTRAINT production_plans_item_id_fkey
FOREIGN KEY (item_id) REFERENCES items(id);
SQL;
DB::statement($sql);
$sql1 = <<<'SQL'
ALTER TABLE production_plans
ADD COLUMN working_days TEXT DEFAULT NULL
SQL;
DB::statement($sql1);
$sql2 = <<<'SQL'
ALTER TABLE production_plans
ADD COLUMN leave_dates TEXT DEFAULT NULL
SQL;
DB::statement($sql2);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('production_plans', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
ALTER TABLE lines
ADD COLUMN block_id BIGINT DEFAULT NULL,
ADD CONSTRAINT lines_block_id_fkey
FOREIGN KEY (block_id) REFERENCES blocks(id);
SQL;
DB::statement($sql);
$sql1 = <<<'SQL'
ALTER TABLE lines
ADD COLUMN line_capacity TEXT DEFAULT NULL
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('lines', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql1 = <<<'SQL'
ALTER TABLE items
ADD COLUMN line_id BIGINT DEFAULT NULL,
ADD CONSTRAINT items_line_id_fkey
FOREIGN KEY (line_id) REFERENCES lines(id);
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('items', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
ALTER TABLE production_quantities
ADD COLUMN machine_id BIGINT DEFAULT NULL,
ADD CONSTRAINT production_quantities_machine_id_fkey
FOREIGN KEY (machine_id) REFERENCES machines(id);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('production_quantities', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::statement("
ALTER TABLE production_plans
ALTER COLUMN shift_id DROP NOT NULL
");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('production_plans', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -181,10 +181,16 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view import invoice in transit']);
Permission::updateOrCreate(['name' => 'view export invoice in transit']);
Permission::updateOrCreate(['name' => 'view import characteristic value']);
Permission::updateOrCreate(['name' => 'view export characteristic value']);
Permission::updateOrCreate(['name' => 'view import request characteristic']);
Permission::updateOrCreate(['name' => 'view export request characteristic']);
Permission::updateOrCreate(['name' => 'view import characteristic approver master']);
Permission::updateOrCreate(['name' => 'view export characteristic approver master']);
Permission::updateOrCreate(['name' => 'view production calender page']);
Permission::updateOrCreate(['name' => 'view production target page']);
}
}

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
{{-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
@@ -67,25 +67,149 @@
font-size: 14px;
color: #666;
}
.approvelevel {
/* color: red; */
font-size: 18px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="icon">⚠️</div>
<h2>Action Already Taken</h2>
<div class="card">
<div class="approvelevel">⚠️ Action Already Taken</div>
<div class="status {{ $status }}">
<div class="status {{ $status }}">
Status: {{ $status }}
</div>
</div>
<p class="note">
<div class="footer">
CRI Digital Manufacturing Solutions<br>
&copy; 2026 All Rights Reserved
</div>
</div>
</body>
</html> --}}
<!DOCTYPE html>
<html>
<head>
<title>Action Taken</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f6f6f6;
padding: 20px;
}
.card {
background: #ffffff;
padding: 20px;
max-width: 500px;
margin: 50px auto;
border-radius: 6px;
text-align: center;
box-shadow: 0 0 10px rgba(0,0,0,.1);
}
.success {
color: green;
font-size: 18px;
font-weight: bold;
}
.footer {
font-size: 12px;
color: #999999;
text-align: center;
margin-top: 20px;
}
.icon {
font-size: 30px;
margin-bottom: 10px;
color: #ff9800;
}
.approvelevel {
/* color: red; */
font-size: 18px;
font-weight: bold;
}
.status {
margin-top: 15px;
padding: 10px;
border-radius: 6px;
font-weight: bold;
font-size: 16px;
}
.status.Approved {
background-color: #e8f5e9;
color: #2e7d32;
}
.status.Hold {
background-color: #fff3e0;
color: #ef6c00;
}
.status.Rejected {
background-color: #fdecea;
color: #c62828;
}
.note {
margin-top: 15px;
font-size: 15px;
color: #666;
}
.pulse-darkred {
color: orange; /* #8B0000 */
background-color: #fff; /* White bg for contrast */
display: inline-block;
padding: 0.5em 0.75em;
border-radius: 4px;
font-size: 1em;
line-height: 1;
animation: pulse 1.5s ease-in-out infinite; /* Duration, easing, infinite loop */
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.2); /* Gentle 5% expansion */
}
}
</style>
</head>
<body>
<div class="card">
<div class="approvelevel"><span class="pulse-darkred">⚠️</span> Action Already Taken</div>
{{-- <div class="status {{ $status }}">
Status: {{ $status }}
</div> --}}
<div class="status {{ $status }}">
Status: {{ $message ?? $status }}
</div>
<p class="note">
This request has already been processed.<br>
No further action is required.
</p>
</p>
<div class="footer">
CRI Digital Manufacturing Solutions<br>
&copy; 2026 All Rights Reserved
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<title>Request On Approve</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; margin:0; padding:0;">
<table width="100%" cellpadding="0" cellspacing="0" style="padding: 20px 0;">
<tr>
<td align="center">
<!-- Card container -->
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); border: 1px solid #e0e0e0;">
<tr>
<td style="padding: 30px; text-align: center;">
<!-- Header -->
<div style="font-size: 35px;"></div>
<h2 style="color: Green; margin: 10px 0 20px; font-size: 24px;"> Request On Approve</h2>
<!-- Message -->
{{-- <p style="font-size: 16px; color: #555555; line-height: 1.5;">
Your request has been put on reject.
</p> --}}
<!-- Remark Textbox -->
<div style="margin-top: 20px; text-align: left;">
<label for="remark" style="font-size: 14px; color: #333;">Remark</label>
<textarea id="remark" style="width:100%; height:100px; padding:10px; margin-top:5px; border:1px solid #ddd; border-radius:5px;"></textarea>
</div>
<!-- Buttons -->
<div style="margin-top: 20px;">
{{-- <button onclick="holdRequest()" style="padding: 10px 20px; margin-right: 10px; background-color:#FF8800; color:#fff; border:none; border-radius:5px; cursor:pointer;">
Hold
</button> --}}
<input type="hidden" id="requestId" value="{{ request()->query('id') }}">
<input type="hidden" id="level" value="{{ request()->query('level') }}">
<button onclick="saveRemark()" style="padding: 10px 20px; background-color:#4CAF50; color:#fff; border:none; border-radius:5px; cursor:pointer;">
Save Remark
</button>
</div>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="padding: 15px; text-align: center; font-size: 12px; color: #999999;">
CRI Digital Manufacturing Solutions<br>
&copy; 2026 All Rights Reserved
</td>
</tr>
</table>
</td>
</tr>
</table>
<script>
function saveRemark() {
const remark = document.getElementById("remark").value.trim();
const id = document.getElementById("requestId").value;
const level = document.getElementById("level").value;
fetch('/characteristic/approve-save', {
method: 'POST',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
},
body: JSON.stringify({
id: id,
level: level,
remark: remark
})
})
.then(res => {
if (!res.ok) {
throw new Error("HTTP error " + res.status);
}
return res.json();
})
.then(data => {
alert('Approved saved successfully!');
window.location.href = "/approval/approve-success";
})
.catch(err => {
console.error(err);
alert('Error saving approve!');
});
}
</script>
</body>
</html>

View File

@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html>
<head>
<title>Action Time Reached</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f6f6f6;
padding: 20px;
}
.status {
margin-top: 15px;
padding: 10px;
border-radius: 6px;
font-weight: bold;
font-size: 16px;
}
.status.Approved {
background-color: #e8f5e9;
color: #2e7d32;
}
.status.Hold {
background-color: #fff3e0;
color: #ef6c00;
}
.status.Rejected {
background-color: #fdecea;
color: #c62828;
}
.approvelevel {
/* color: red; */
font-size: 18px;
font-weight: bold;
}
.card {
background: #ffffff;
padding: 20px;
max-width: 500px;
margin: 50px auto;
border-radius: 6px;
text-align: center;
box-shadow: 0 0 10px rgba(0,0,0,.1);
}
.success {
color: green;
font-size: 18px;
font-weight: bold;
}
.footer {
font-size: 12px;
color: #999999;
text-align: center;
margin-top: 20px;
}
.icon {
font-size: 30px;
margin-bottom: 10px;
color: #ff9800;
}
.approvelevel {
/* color: red; */
font-size: 18px;
font-weight: bold;
}
.status-message.expired {
color: #d84315;
font-weight: bold;
}
</style>
</head>
<body>
<div class="card">
<div class="approvelevel">⚠️ Action Expired</div>
<div class="status {{ $status }}">
Status:
<span class="status-message expired">
{{ $message ?? $status }}
</span>
</div>
{{-- <p>Your approval time limit has expired</p> --}}
<div class="footer">
CRI Digital Manufacturing Solutions<br>
&copy; 2026 All Rights Reserved
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<title>Approval</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f6f6f6;
padding: 20px;
}
.card {
background: #ffffff;
padding: 20px;
max-width: 500px;
margin: 50px auto;
border-radius: 6px;
text-align: center;
box-shadow: 0 0 10px rgba(0,0,0,.1);
}
.hold {
color: Green;
font-size: 18px;
font-weight: bold;
}
.footer {
font-size: 12px;
color: #999999;
text-align: center;
margin-top: 20px;
}
a.button {
display: inline-block;
margin-top: 15px;
padding: 10px 20px;
background-color: Green;
color: #ffffff;
text-decoration: none;
border-radius: 5px;
font-weight: bold;
}
.pulse-darkred {
color: Green; /* #8B0000 */
background-color: #fff; /* White bg for contrast */
display: inline-block;
padding: 0.5em 0.75em;
border-radius: 4px;
font-size: 1em;
line-height: 1;
animation: pulse 1.5s ease-in-out infinite; /* Duration, easing, infinite loop */
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.2); /* Gentle 5% expansion */
}
}
</style>
</head>
<body>
<div class="card">
<div class="hold"><span class="pulse-darkred">🟢</span> Approved Successfully</div>
<p>Your request has been approved.</p>
<!-- Footer -->
<div class="footer">
CRI Digital Manufacturing Solutions<br>
&copy; 2026 All Rights Reserved
</div>
</div>
</body>
</html>

View File

@@ -13,13 +13,13 @@
<tr>
<td style="padding: 30px; text-align: center;">
<!-- Header -->
<div style="font-size: 40px;">🟠</div>
<h2 style="color: #FF8800; margin: 10px 0 20px; font-size: 24px;">Request On Hold</h2>
{{-- <div style="font-size: 40px;"></div> --}}
<h2 style="color: #FF8800; margin: 10px 0 20px; font-size: 24px;">🟠 Request On Hold</h2>
<!-- Message -->
<p style="font-size: 16px; color: #555555; line-height: 1.5;">
{{-- <p style="font-size: 16px; color: #555555; line-height: 1.5;">
Your request has been temporarily put on hold.
</p>
</p> --}}
<!-- Remark Textbox -->
<div style="margin-top: 20px; text-align: left;">

View File

@@ -1,36 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<title>Request On Hold</title>
<title>On Hold</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f6f6f6;
padding: 20px;
}
.card {
background: #ffffff;
padding: 20px;
max-width: 500px;
margin: 50px auto;
border-radius: 6px;
text-align: center;
box-shadow: 0 0 10px rgba(0,0,0,.1);
}
.hold {
color: #FF8800;
font-size: 18px;
font-weight: bold;
}
.footer {
font-size: 12px;
color: #999999;
text-align: center;
margin-top: 20px;
}
a.button {
display: inline-block;
margin-top: 15px;
padding: 10px 20px;
background-color: #FF8800;
color: #ffffff;
text-decoration: none;
border-radius: 5px;
font-weight: bold;
}
.pulse-darkred {
color: DarkRed; /* #8B0000 */
background-color: #fff; /* White bg for contrast */
display: inline-block;
padding: 0.5em 0.75em;
border-radius: 4px;
font-size: 1em;
line-height: 1;
animation: pulse 1.5s ease-in-out infinite; /* Duration, easing, infinite loop */
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.2); /* Gentle 5% expansion */
}
}
</style>
</head>
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; margin:0; padding:0;">
<table width="100%" cellpadding="0" cellspacing="0" style="padding: 20px 0;">
<tr>
<td align="center">
<!-- Card container -->
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); border: 1px solid #e0e0e0;">
<tr>
<td style="padding: 30px; text-align: center;">
<!-- Header -->
<div style="font-size: 40px;">🟠</div>
<h2 style="color: #FF8800; margin: 10px 0 20px; font-size: 24px;">Request On Hold</h2>
<!-- Message -->
<p style="font-size: 16px; color: #555555; line-height: 1.5;">
Your request has been temporarily put on hold.
</p>
</td>
</tr>
<!-- Footer -->
<tr>
<td style="padding: 15px; text-align: center; font-size: 12px; color: #999999;">
CRI Digital Manufacturing Solutions<br>
&copy; 2026 All Rights Reserved
</td>
</tr>
</table>
</td>
</tr>
</table>
<body>
<div class="card">
<div class="hold"><span class="pulse-darkred">🟠</span> Hold Successfully</div>
<p>Your request has been temporarily put on hold.</p>
<!-- Footer -->
<div class="footer">
CRI Digital Manufacturing Solutions<br>
&copy; 2026 All Rights Reserved
</div>
</div>
</body>
</html>

View File

@@ -13,13 +13,13 @@
<tr>
<td style="padding: 30px; text-align: center;">
<!-- Header -->
<div style="font-size: 40px;">🟠</div>
<h2 style="color: #FF0000; margin: 10px 0 20px; font-size: 24px;">Request On Reject</h2>
<div style="font-size: 35px;"></div>
<h2 style="color: #FF0000; margin: 10px 0 20px; font-size: 24px;"> Request On Reject</h2>
<!-- Message -->
<p style="font-size: 16px; color: #555555; line-height: 1.5;">
Your request has been temporarily put on reject.
</p>
{{-- <p style="font-size: 16px; color: #555555; line-height: 1.5;">
Your request has been put on reject.
</p> --}}
<!-- Remark Textbox -->
<div style="margin-top: 20px; text-align: left;">
@@ -42,7 +42,6 @@
Save Remark
</button>
</div>
</td>
</tr>

View File

@@ -19,7 +19,7 @@
}
.rejected {
color: red;
font-size: 20px;
font-size: 18px;
font-weight: bold;
}
.footer {
@@ -38,14 +38,33 @@
border-radius: 5px;
font-weight: bold;
}
.pulse-darkred {
color: DarkRed; /* #8B0000 */
background-color: #fff; /* White bg for contrast */
display: inline-block;
padding: 0.5em 0.75em;
border-radius: 4px;
font-size: 1em;
line-height: 1;
animation: pulse 1.5s ease-in-out infinite; /* Duration, easing, infinite loop */
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.2); /* Gentle 5% expansion */
}
}
</style>
</head>
<body>
<div class="card">
<div class="rejected"> Rejected Successfully</div>
<p>The rejection has been recorded.</p>
<p>You may now close this tab.</p>
<div class="rejected"><span class="pulse-darkred"></span> Rejected Successfully</div>
{{-- 🔴 --}}
<p>Your request has been rejected successfully.</p>
<!-- Footer -->
<div class="footer">

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Approval Recorded</title>
<title>Approved</title>
<style>
body {
font-family: Arial, sans-serif;
@@ -28,14 +28,33 @@
text-align: center;
margin-top: 20px;
}
.pulse-darkred {
color: Green; /* #8B0000 */
background-color: #fff; /* White bg for contrast */
display: inline-block;
padding: 0.5em 0.75em;
border-radius: 4px;
font-size: 1em;
line-height: 1;
animation: pulse 1.5s ease-in-out infinite; /* Duration, easing, infinite loop */
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(1.25); /* Gentle 5% expansion */
}
}
</style>
</head>
<body>
<div class="card">
<div class="success"> Approval Successful</div>
<p>Your action has been recorded.</p>
<p>You may now close this tab.</p>
<div class="success"><span class="pulse-darkred"></span> Approved Successfully</div>
{{-- 🟢 --}}
<p>Your request has been approved successfully.</p>
<!-- Footer -->
<div class="footer">

View File

@@ -0,0 +1,13 @@
<x-filament-panels::page>
<div class="space-y-4">
{{-- Render the Select form fields --}}
<div class="space-y-4">
{{ $this->form }}
</div>
</div>
</x-filament-panels::page>

View File

@@ -7,6 +7,8 @@
{{ $this->form }}
</div>
{{-- <livewire:notification-sound /> --}}
{{-- <input
type="text"
id="qr-scan-input"
@@ -15,7 +17,7 @@
autocomplete="off"
autofocus
/> --}}
<div class="mb-4">
{{-- <div class="mb-4">
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
SCAN QR CODE
</label>
@@ -27,11 +29,64 @@
autocomplete="off"
autofocus
/>
</div>
</div> --}}
{{-- <div class="mb-4">
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
SCAN QR CODE
</label>
<input
type="text"
id="qr-scan-input"
class="border border-gray-300 rounded px-4 py-2 text-sm w-1/2"
placeholder="Scan QR Code & Press Enter"
autocomplete="off"
autofocus
/>
</div> --}}
<div class="flex gap-6 -mt-6">
<!-- Scan QR Code -->
<div class="w-full">
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
SCAN QR CODE
</label>
<input
type="text"
id="qr-scan-input"
class="border border-gray-300 rounded px-4 py-2 text-sm w-full"
placeholder="Scan QR Code & Press Enter"
autocomplete="off"
autofocus
/>
</div>
<!-- Last Scanned QR -->
{{-- <div class="w-1/2">
<label for="recent-qr-input" class="block text-sm font-medium text-gray-700 mb-2">
LAST SCANNED QR
</label>
<input
type="text"
id="recent-qr-input"
class="border border-gray-300 rounded px-4 py-2 text-sm w-full bg-white-100 text-black"
readonly
wire:model="recent_qr"
/>
</div> --}}
</div>
@push('scripts')
<script>
window.addEventListener('focus-production-order', () => {
const wrapper = document.getElementById('production_order');
const input = wrapper?.querySelector('input,textarea');
if (input) {
input.focus();
input.select();
}
});
document.addEventListener('DOMContentLoaded', function () {
const scanInput = document.getElementById('qr-scan-input');
if (!scanInput) return;
@@ -48,6 +103,7 @@
}
}
});
});
</script>
@endpush

View File

@@ -0,0 +1,19 @@
<x-filament-panels::page>
<div class="space-y-4">
{{-- Render the Select form fields --}}
<div class="space-y-4">
{{ $this->form }}
</div>
<x-filament::button
wire:click="export"
color="primary"
class="mt-4"
>
Export
</x-filament::button>
<div class="bg-white shadow rounded-xl p-4 mt-6">
<livewire:production-target-plan />
</div>
</div>
</x-filament-panels::page>

View File

@@ -0,0 +1,121 @@
<!-- <select id="yearSelect">
<option value="">Select Year</option>
</select> -->
<div id="calendar" wire:ignore></div>
<!-- <input type="text" name="working_days" placeholder="Working Days"> -->
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
let selectedDates = [];
let calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
height: 600,
showNonCurrentDates: true,
datesSet: function(info) {
// Clear previous month selections
selectedDates = [];
// Remove background events
calendar.removeAllEvents();
// Recalculate working days for new month
updateWorkingDays(info.view.currentStart);
},
dateClick: function(info) {
let viewMonth = calendar.view.currentStart.getMonth();
let clickedMonth = info.date.getMonth();
if (viewMonth != clickedMonth) return;
let dateStr = info.dateStr;
if (selectedDates.includes(dateStr)) {
selectedDates = selectedDates.filter(d => d !== dateStr);
calendar.getEvents().forEach(event => {
if (event.startStr == dateStr) event.remove();
});
} else {
selectedDates.push(dateStr);
calendar.addEvent({
start: dateStr,
display: 'background',
color: '#f03f17'
});
}
updateWorkingDays(info.date);
}
});
// function updateWorkingDays(date) {
// let totalDays = new Date(
// date.getFullYear(),
// date.getMonth()+1,
// 0
// ).getDate();
// let workingDays = totalDays - selectedDates.length;
// // document.querySelector('input[name="working_days"]').value = workingDays;
// const input = document.querySelector('#working_days');
// input.value = workingDays;
// input.dispatchEvent(new Event('input'));
// const monthInput = document.querySelector('#month');
// monthInput.value = date.getMonth() + 1; // 112 month number
// monthInput.dispatchEvent(new Event('input'));
// const yearInput = document.querySelector('#year');
// yearInput.value = date.getFullYear();
// yearInput.dispatchEvent(new Event('input'));
// const selectedDatesInput = document.querySelector('#selected_dates');
// selectedDatesInput.value = selectedDates.join(',');
// selectedDatesInput.dispatchEvent(new Event('input'));
// }
function updateWorkingDays(date) {
let totalDays = new Date(
date.getFullYear(),
date.getMonth() + 1,
0
).getDate();
let workingDays = totalDays - selectedDates.length;
// Set values only
document.querySelector('#working_days').value = workingDays;
document.querySelector('#month').value = date.getMonth() + 1;
document.querySelector('#year').value = date.getFullYear();
document.querySelector('#selected_dates').value = selectedDates.join(',');
// Trigger only ONE update (important)
document
.querySelector('#selected_dates')
.dispatchEvent(new Event('input'));
}
calendar.render();
});
</script>

View File

@@ -0,0 +1,9 @@
<div class="flex space-x-2 items-center">
<button
type="button"
class="inline-flex items-center px-3 py-1 bg-primary-600 text-white rounded hover:bg-primary-700"
wire:click="saveWorkingDays"
>
Save
</button>
</div>

View File

@@ -220,10 +220,10 @@
{{-- Modal for material invoice--}}
@if($materialInvoice)
{{-- <div class="flex justify-center overflow-x-auto overflow-y-visible" style="height: 385px;"> --}}
<div class="overflow-x-auto overflow-y-visible" style="height: 385px;">
{{-- <table class="min-w-[1500px] text-sm text-center border border-gray-300"> --}}
{{-- <table class="table-fixed min-w-[1500px] text-sm text-center border border-gray-300"> --}}
<table class="min-w-full text-sm text-center border border-gray-300">
{{-- <table class="min-w-full text-sm text-center border border-gray-300"> --}}
<table class="min-w-full mx-auto text-sm text-center border border-gray-300">
<thead class="bg-gray-100 font-bold">
<tr>
<th class="border px-4 py-2">No</th>
@@ -242,7 +242,13 @@
<td class="border px-4 py-2">{{ $index + 1 }}</td>
<td class="border px-4 py-2">{{ $row['code'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['material_type'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['quantity'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">
@if(($row['material_type'] ?? '') === 'Individual' || ($row['material_type'] ?? '') === 'Bundle')
{{ number_format((float)($row['quantity'] ?? 0), 0) }}
@else
{{ $row['quantity'] ?? 'N/A' }}
@endif
</td>
<td class="border px-4 py-2">{{ $row['serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['batch_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['created_at'] ?? 'N/A' }}</td>

View File

@@ -0,0 +1,86 @@
<div class="p-4">
<h2 class="text-lg font-bold mb-4 text-gray-700 uppercase tracking-wider">
PRODUCTION PLAN TABLE:
</h2>
<div class="overflow-x-auto rounded-lg shadow">
<table class="w-full divide-y divide-gray-200 text-sm text-center">
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
<tr>
<th class="border px-4 py-2" rowspan="3">No</th>
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Plant</th>
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Line</th>
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Item Code</th>
<th class="border px-4 py-2 whitespace-nowrap" colspan="{{ count($dates) * 3 }}" class="text-center">
Production Plan Dates
</th>
</tr>
<tr>
@foreach($dates as $date)
{{-- <th colspan="3" class="text-center">
{{ $date }}
</th> --}}
<th colspan="3" class="text-center border-r-4 border-gray-400">
{{ $date }}
</th>
@endforeach
</tr>
<tr>
@foreach($dates as $date)
<th class="border px-4 py-2 whitespace-nowrap">Line Capacity</th>
<th class="border px-4 py-2 whitespace-nowrap">Target Plan</th>
<th class="border px-4 py-2 whitespace-nowrap border-r-4 border-gray-400">
Produced Quantity
</th>
{{-- <th class="border px-4 py-2 whitespace-nowrap">Produced Quantity</th> --}}
@endforeach
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse ($records as $index => $record)
<tr class="hover:bg-gray-50">
<td class="border px-4 py-2">{{ $index + 1 }}</td>
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['plant_name'] }}</td>
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['line_name'] }}</td>
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['item_code'] }}</td>
{{-- @foreach($dates as $date)
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['target_plan'][$date] ?? '-' }}</td>
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['production_plan'][$date] ?? '-' }}</td>
@endforeach --}}
@foreach($dates as $date)
@if(in_array($date, $leaveDates))
<td class="border px-4 py-2 whitespace-nowrap">-</td>
<td class="border px-4 py-2 whitespace-nowrap">-</td>
<td class="border px-4 py-2 whitespace-nowrap">-</td>
@else
{{-- <td class="border px-4 py-2 whitespace-nowrap">{{ $record['daily_target'] ?? '-' }}</td> --}}
<td class="border px-4 py-2 whitespace-nowrap">
{{ $record['daily_line_capacity'][$date] ?? '-' }}
</td>
<td class="border px-4 py-2 whitespace-nowrap">
{{ $record['daily_target_dynamic'][$date] ?? '-' }}
</td>
<td class="border px-4 py-2 whitespace-nowrap">
{{ $record['produced_quantity'][$date] ?? '-' }}
</td>
{{-- <td class="border px-4 py-2 whitespace-nowrap">{{ $record['produced_quantity'] ?? '-' }}</td> --}}
@endif
@endforeach
</tr>
@empty
<tr>
<td colspan="10" class="px-4 py-4 text-center text-gray-500">
No production plan data found.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>

View File

@@ -39,7 +39,7 @@
{{-- Modal for empty invoice--}}
@if ($emptyInvoice)
<div class="text-center text-red-500">
<p>No data found for invoice number <strong>{{ $invoiceNumber }}</strong>.</p>
<p>No data found for the invoice number <strong>{{ $invoiceNumber }}</strong>.</p>
</div>
@endif
@@ -84,7 +84,7 @@
@empty
<tr>
<td colspan="12" class="text-center py-4 text-gray-500">
No data found for invoice number <strong>{{ $invoiceNumber }}</strong>.
No data found for the invoice number <strong>{{ $invoiceNumber }}</strong>.
</td>
</tr>
@endforelse
@@ -164,7 +164,7 @@
@empty
<tr>
<td colspan="10" class="text-center py-4 text-gray-500">
No data found for invoice number <strong>{{ $invoiceNumber }}</strong>.
No data found for the invoice number <strong>{{ $invoiceNumber }}</strong>.
</td>
</tr>
@endforelse
@@ -182,15 +182,34 @@
});
</script> --}}
<script>
window.addEventListener('focus-capacitor-input', () => {
window.addEventListener('focus-capacitor-input', (event) => {
console.log('Item Code:', event.detail.itemCode);
const container = document.getElementById('focus-capacitor-input');
if (container) {
container.dataset.itemCode = event.detail.itemCode;
}
setTimeout(() => {
const input = document.getElementById('capacitorInput');
if (input) {
input.focus();
input.select();
}
}, 50);
// const container = document.getElementById('focus-capacitor-input');
const input = container?.querySelector('input'); // gets the actual input inside
if (input) {
input.focus();
input.select();
}
}, 50);
});
// window.addEventListener('focus-capacitor-input', (event) => {
// console.log('Item Code:', event.detail.itemCode);
// setTimeout(() => {
// const input = document.querySelector('#capacitorInput input');
// if (input) {
// input.focus();
// input.select();
// }
// }, 50);
// });
window.addEventListener('focus-serial-number', () => {
setTimeout(() => {

View File

@@ -7,57 +7,59 @@
<body>
<div style="text-align: center; font-weight: bold;">
{{ $company }}
</div>
<br>
<p>{!! $greeting !!}</p>
<table border="1" width="50%" cellpadding="6" cellspacing="0">
{{ $company }}
</div>
<br>
<p>{!! $greeting !!}</p>
<table style="margin-left: 3%" border="1" width="30%" cellpadding="6" cellspacing="0">
<tr>
<th width="30%">Title</th>
<th width="40%">Details</th>
</tr>
<tr>
<td>Requested DateTime</td>
<td>{{ $request->created_at->format('d-m-Y H:i:s') }}</td>
<td>Requested Date Time</td>
<td style="text-align: center;">{{ $request->created_at->format('d-m-Y H:i:s') }}</td>
</tr>
<tr>
<td>Plant</td>
<td>{{ $request->plant->name ?? $request->plant_id }}</td>
<td>Plant Name</td>
<td style="text-align: center;">{{ $request->plant->name ?? $request->plant_id }}</td>
</tr>
<tr>
<td>Item Code</td>
<td>{{ $request->item->code ?? $request->code }}</td>
<td style="text-align: center;">{{ $request->item->code ?? $request->code }}</td>
</tr>
<tr>
<td>Job Number</td>
<td>{{ $request->aufnr }}</td>
<td style="text-align: center;">{{ $request->aufnr }}</td>
</tr>
<tr>
<td>Work Flow ID</td>
<td style="text-align: center;">{{ $request->work_flow_id }}</td>
</tr>
</table>
<br>
<table border="1" width="50%" cellpadding="6" cellspacing="0">
@if($approverNameFromMaster && $approverNameFromMaster->approver_type == 'Characteristic')
<table style="margin-left: 3%" border="1" width="50%" cellpadding="6" cellspacing="0">
<tr>
<th>Characteristics Name</th>
<th>SAP Value</th>
<th>Update Value</th>
<th>WorkFlow ID</th>
{{-- <th>Work Flow ID</th> --}}
</tr>
@forelse ($tableData as $char)
<tr>
{{-- <td>{{ $char['characteristic_name'] ?? '-' }}</td> --}}
<td>{{ strtoupper($char['characteristic_name'] ?? '-') }}</td>
<td>{{ $char['current_value'] ?? '-' }}</td>
<td>{{ $char['update_value'] ?? '-' }}</td>
<td>{{ $char['work_flow_id'] ?? '-' }}</td>
<td style="text-align: center;">{{ strtoupper($char['characteristic_name'] ?? '-') }}</td>
<td style="text-align: center;">{{ $char['current_value'] ?? '-' }}</td>
<td style="text-align: center;">{{ $char['update_value'] ?? '-' }}</td>
{{-- <td style="text-align: center;">{{ $char['work_flow_id'] ?? '-' }}</td> --}}
{{-- @if ($loop->first)
<td rowspan="{{ count($tableData) }} "style="text-align: center; vertical-align: middle;">
{{ $char['work_flow_id'] ?? '-' }}
</td>
@endif --}}
</tr>
@empty
<tr>
@@ -66,21 +68,117 @@
@endforelse
</table>
<br>
<table border="1" width="50%" cellpadding="6" cellspacing="0">
<table style="margin-left: 3%" border="1" width="30%" cellpadding="6" cellspacing="0">
<tr>
<th>Approver Name</th>
<th>Approve Status</th>
</tr>
<tr>
<td>{{ $approverName }}</td>
<td style="text-align: center;">
<a href="{{ $approveUrl }}">Approve</a> |
<a href="{{ $holdUrl }}">Hold</a> |
<a href="{{ $rejectUrl }}">Reject</a>
</td>
</tr>
@if($level == 2)
<tr>
<td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
<td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
</tr>
<tr>
<td style="text-align: center;">{{ $approverName }}</td>
<td style="text-align: center;">
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
</td>
</tr>
@elseif ($level == 3)
<tr>
<td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
<td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
</tr>
<tr>
<td style="text-align: center;">{{ $approverNameFromMaster->name2 }}</td>
<td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status2 ?? '-') }}</td>
</tr>
<tr>
<td style="text-align: center;">{{ $approverName }}</td>
<td style="text-align: center;">
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
</td>
</tr>
@else
<tr>
<td style="text-align: center;">{{ $approverName }}</td>
<td style="text-align: center;">
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
</td>
</tr>
@endif
</table>
@elseif($approverNameFromMaster && $approverNameFromMaster->approver_type == 'Quality')
<br>
<table style="margin-left: 3%" border="1" width="50%" cellpadding="6" cellspacing="0">
<tr>
<th>Approver Name</th>
<th>Approve Status</th>
</tr>
@if($level == 2)
<tr>
<td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
<td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
</tr>
<tr>
<td style="text-align: center;">{{ $approverName }}</td>
<td style="text-align: center;">
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
</td>
</tr>
@elseif ($level == 3)
<tr>
<td style="text-align: center;">{{ $approverNameFromMaster->name1 }}</td>
<td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status1 ?? '-') }}</td>
</tr>
<tr>
<td style="text-align: center;">{{ $approverNameFromMaster->name2 }}</td>
<td style="text-align: center;">{{ ucfirst($pendingApprovers->approver_status2 ?? '-') }}</td>
</tr>
<tr>
<td style="text-align: center;">{{ $approverName }}</td>
<td style="text-align: center;">
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
</td>
</tr>
@else
<tr>
<td style="text-align: center;">{{ $approverName }}</td>
<td style="text-align: center;">
<a href="{{ $approveUrl }}" style="color: #28a745; font-weight: bold; text-decoration: underline;">Approve</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $holdUrl }}" style="color: #FF8800; font-weight: bold; text-decoration: underline;">Hold</a>
&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{{ $rejectUrl }}" style="color: #dc3545; font-weight: bold; text-decoration: underline;">Reject</a>
</td>
</tr>
@endif
</table>
@endif
<p>{!! $wishes !!}</p>
</div>