351 Commits

Author SHA1 Message Date
dhanabalan
c070c9763e Added commented line 2025-08-12 17:55:03 +05:30
dhanabalan
2116ea422e Added unnecessary blank line in QualityValidationResource.php 2025-08-12 17:44:58 +05:30
dhanabalan
acc98ad876 Add EbReadingPolicy.php from master branch 2025-08-12 17:33:11 +05:30
dhanabalan
45898b2fa2 removed unwanted space from quality validation 2025-08-12 16:59:51 +05:30
dhanabalan
390e013ccb Add TimescaleDB migration for QDS 2025-08-12 16:14:41 +05:30
dhanabalan
dc9f929fa2 Update sequences column logic in guard patrol entry table for accurate display 2025-08-07 10:50:00 +05:30
dhanabalan
e58dbfbebd Added sticker reprint updated logic and added blade file 2025-08-07 09:25:25 +05:30
dhanabalan
15af1edb8f Rename identification fields to Aadhar Number and PAN Number for clarity 2025-08-07 09:20:53 +05:30
dhanabalan
705cc8c3a4 Added blank line for improved readability 2025-08-05 12:09:44 +05:30
dhanabalan
6e61f83e3a Validate production order length to be between 7 and 14 digits in both ProductionQuantityImporter and QualityValidationImporter 2025-08-05 12:03:49 +05:30
dhanabalan
197184e2ed Refactor Invoice Validation Logic and Update UI for Serial and Material Invoices
- Improved conditional checks for invoice processing in InvoiceValidationResource on completion (or pending).
- Enhanced notifications for completed scanning processes for both serial and material invoices.
- Updated CreateInvoiceValidation page to pass invoice type to serial and material invoice on completion (or pending).
- Modified InvoiceDataTable to include a new property for serial/material invoice handling.
- Adjusted Blade view to dynamically display the correct title and messages based on invoice type (serial/material).
2025-08-05 12:00:26 +05:30
dhanabalan
d6c77bd6c3 Enhance production order validation to require numeric values with 7 to 14 digits across multiple resources 2025-08-04 19:35:50 +05:30
dhanabalan
68d4240ab0 Add removed all line for production line stop count and production order count 2025-08-04 18:23:51 +05:30
dhanabalan
68ba8fa89d Added Serial Invoice Api for invoice validation 2025-08-04 12:26:49 +05:30
dhanabalan
8c84e48f8e Refactor pallet number generation to include LocatorInvoiceValidation for improved uniqueness 2025-08-02 12:49:26 +05:30
dhanabalan
2e7859656a Disablked the delete at for export page 2025-07-31 18:21:11 +05:30
dhanabalan
4bfbebb254 Added No column for all resource tables page 2025-07-31 18:16:51 +05:30
dhanabalan
1ea00b6901 Added device name column for mfm parameter resource and import and export 2025-07-31 18:14:02 +05:30
dhanabalan
5084aa9c0e Added import and export in device master resource page 2025-07-31 18:05:06 +05:30
dhanabalan
c844a23556 Added device master importer and exporter 2025-07-31 18:04:21 +05:30
dhanabalan
76649651f1 Added line type column in production mail table 2025-07-31 17:32:26 +05:30
dhanabalan
e15c866078 Add column for table line type 2025-07-31 17:26:00 +05:30
dhanabalan
04af1c7c34 modified names of live reading for view page 2025-07-31 17:22:00 +05:30
dhanabalan
8871389fe3 chngaed name of edit live readings page 2025-07-31 17:20:32 +05:30
dhanabalan
ec2fd4d3ca modifiednavigation names for live readings page 2025-07-31 17:18:44 +05:30
dhanabalan
5c1f77796f Arranged text input box for mfm parameter page 2025-07-31 17:09:16 +05:30
dhanabalan
530bca4c4b Added required for trend line analysis page 2025-07-31 17:07:02 +05:30
dhanabalan
ccceff9edc Added required for trend chart analysis chart page 2025-07-31 17:05:22 +05:30
dhanabalan
c53f40d8a0 Added module for trend line analysis chart 2025-07-31 17:02:56 +05:30
dhanabalan
6b67d94476 Added permissions for ems trend line and trend chart page 2025-07-31 16:59:12 +05:30
dhanabalan
b2d2ab7e05 Added trend line analysis page and blade file 2025-07-31 16:57:51 +05:30
dhanabalan
573b02a97a Added trend line chart analysis chart page 2025-07-31 16:57:08 +05:30
dhanabalan
96a5dacf95 Add trend chart analysis page and blade file 2025-07-31 16:56:01 +05:30
dhanabalan
58cdcec6ed Added trend chart analysis chart file 2025-07-31 16:52:58 +05:30
dhanabalan
c67e8fcc59 Added device master logic for mfm parameter controller 2025-07-31 16:43:53 +05:30
dhanabalan
d5588e0b25 modified logic for mfm parameter resource page 2025-07-31 16:43:07 +05:30
dhanabalan
9ff7f88840 modified logic for mfm meter resource file 2025-07-31 16:42:36 +05:30
dhanabalan
03e53e0bb1 Added mfm parameter exporter file 2025-07-31 16:41:13 +05:30
dhanabalan
33b2b6399d Added mfm meter importer and exporter file 2025-07-31 16:38:23 +05:30
dhanabalan
2437bdf85f added column device_master_id for mfm_parameter model file 2025-07-31 16:35:51 +05:30
dhanabalan
f51aea626b Added foreign key device_master_id for mfm_parameter table 2025-07-31 16:33:58 +05:30
dhanabalan
77129cb70b Added mfm meter model file 2025-07-31 16:30:59 +05:30
dhanabalan
bb462a6c45 Added foreign and unique key for mfm_meters table 2025-07-31 16:30:04 +05:30
dhanabalan
9a2a6bdd9b Add device master policy file 2025-07-31 16:21:14 +05:30
dhanabalan
0a414a6804 Added device master resource file 2025-07-31 16:18:25 +05:30
dhanabalan
f4bb7a7a78 Added device master model file 2025-07-31 16:17:35 +05:30
dhanabalan
8aad6cf1e6 Add device master migration file 2025-07-31 16:14:47 +05:30
dhanabalan
3b18411141 Added logic for invoice report for daily report 2025-07-31 15:00:03 +05:30
dhanabalan
162eaa0c9c added unwanted line 2025-07-31 13:59:14 +05:30
dhanabalan
d5f55fbf98 added commented line for git checking 2025-07-31 13:58:18 +05:30
dhanabalan
cf5cfac555 Removed unwanted lines for production send report 2025-07-31 13:53:41 +05:30
dhanabalan
7bf2e8182b Updated QR validation functionality to allow with and without item code 2025-07-31 12:26:16 +05:30
dhanabalan
216b62f8bf Added notification for missing invoice type in filter options 2025-07-31 12:22:23 +05:30
dhanabalan
cad7f19ab5 Added invoice_type radio filter and scanned_status select filter to Invoice Validation 2025-07-31 08:53:40 +05:30
dhanabalan
ca9695c922 Added operator_id and scanned_status filter fields to Invoice validaitons resources and Alignment changed in filter option for Production Quantity / Quality Validation 2025-07-30 15:18:26 +05:30
dhanabalan
d1f9a3176f Added operator_id field to ProductionQuantity and QualityValidation in report filter 2025-07-30 12:32:17 +05:30
dhanabalan
0b9d0f9995 modified size of the qr code of scan pallet 2025-07-29 18:02:42 +05:30
dhanabalan
897aa77217 Modified qr code size for pallet 2025-07-29 15:52:44 +05:30
dhanabalan
000533ef7c Added scan pallet print pdf 2025-07-29 15:36:29 +05:30
dhanabalan
a78cb75bdd Added reprint for scan pallet 2025-07-29 13:56:30 +05:30
dhanabalan
ab769d2287 Added 2 copies of pallet number print for scan pallet 2025-07-29 13:26:13 +05:30
dhanabalan
0bde54cf1a removed logic against the production order 2025-07-29 11:47:26 +05:30
dhanabalan
48942307e1 modified sticker reprint controller logic 2025-07-29 11:46:44 +05:30
dhanabalan
8c5f2b5b39 commented production order text input box as mandatory 2025-07-29 11:35:13 +05:30
dhanabalan
b1df9f8b87 Added production sticker reprint page 2025-07-29 11:33:28 +05:30
dhanabalan
c0d13db2f3 Added created_at, updated_at, email while data response with roles 2025-07-28 18:33:15 +05:30
dhanabalan
b4bf170c89 Added kiosk for scan pallet 2025-07-28 18:10:54 +05:30
dhanabalan
b0d2132e25 Refactor QR code PDF generation to improve layout and add automatic print functionality 2025-07-28 18:01:50 +05:30
dhanabalan
83f98d9e83 Added import / export permissions to mfm meter and create permission to production sticker reprint page 2025-07-25 12:34:01 +05:30
dhanabalan
3d84661640 removed unwanted notification for production quantity 2025-07-25 11:43:26 +05:30
dhanabalan
26ecaf49ef Added sticker master get controller production reprint 2025-07-24 18:03:00 +05:30
dhanabalan
5fe2b74174 Aded filter list api for invoice 2025-07-22 11:11:26 +05:30
dhanabalan
ce901e3b78 Added scan_quantity and pend_quantity fields with respective validations 2025-07-18 20:37:11 +05:30
dhanabalan
31ad036d0e Updated duration for failure messages to 5 seconds and label changed for total sno quantity field 2025-07-18 19:11:51 +05:30
dhanabalan
c363faa357 Updated duration for failure messages to 5 seconds 2025-07-18 19:06:42 +05:30
dhanabalan
a71864905e Updated validation functionality on import 2025-07-18 19:04:30 +05:30
dhanabalan
c75ac4781f Updated duration for success message to 600 ms 2025-07-18 18:57:48 +05:30
dhanabalan
c76cf1fb98 Added permission for import and export file 2025-07-18 18:26:39 +05:30
dhanabalan
95a4ddf11e Added mfm parameter api controller 2025-07-18 18:25:32 +05:30
dhanabalan
c309bed7d9 Added mfm reading policy file 2025-07-18 18:24:15 +05:30
dhanabalan
b2dc9e7024 Added mfm reading resource file 2025-07-18 18:23:57 +05:30
dhanabalan
bff2601ddc Added Mfm reading model file 2025-07-18 18:22:54 +05:30
dhanabalan
e80812b82e Added mfm reading migration file 2025-07-18 18:22:31 +05:30
dhanabalan
81c7812ef6 Added mfm parameter exporter file 2025-07-18 18:18:59 +05:30
dhanabalan
14b5f4ae8b Added importer file for mfm parameter 2025-07-18 18:18:37 +05:30
dhanabalan
eb31e6a406 Added mfm parameter policy 2025-07-18 18:16:45 +05:30
dhanabalan
740ceff0f8 Added mfm parameter resource page 2025-07-18 18:16:15 +05:30
dhanabalan
ea1261fb01 Added mfm parameter model file 2025-07-18 18:15:13 +05:30
dhanabalan
74ad73622d Added mfm parameter migration file 2025-07-18 18:14:35 +05:30
dhanabalan
a62220c9d0 Added temp live reading policy 2025-07-18 18:06:04 +05:30
dhanabalan
a5036b7d6f Added temp live reading resource files 2025-07-18 18:05:27 +05:30
dhanabalan
27b8058ba8 Added templivereading model file 2025-07-18 18:03:55 +05:30
dhanabalan
58091726a4 Added temp live readings migration file 2025-07-18 18:02:55 +05:30
dhanabalan
6bdd210162 Added mfm meter policy file 2025-07-18 17:57:48 +05:30
dhanabalan
b9e3d463ed Added mfm meter resource file 2025-07-18 17:57:30 +05:30
dhanabalan
418e4fcf79 Added mfm meter model file 2025-07-18 17:56:34 +05:30
dhanabalan
33881a3978 Added mfm meter migration file 2025-07-18 17:55:52 +05:30
dhanabalan
9d4cf0e3d9 Increased font size and qr code size 2025-07-18 16:33:02 +05:30
dhanabalan
72704a4a3f Added focusing for capacitor input box in invoice validation 2025-07-16 18:20:31 +05:30
dhanabalan
a34b55267d Changed design in production quantity page 2025-07-16 17:39:15 +05:30
dhanabalan
b6dcb93402 Set duration for success message in production quantity page 2025-07-16 11:34:43 +05:30
dhanabalan
313dc012d5 issue solve for slow going process of item code in production quantity 2025-07-15 13:57:01 +05:30
dhanabalan
2541300910 removed live () in production quantity page 2025-07-15 13:48:30 +05:30
dhanabalan
d1894e0d35 Added logic for fg line concept in production mail alert 2025-07-15 10:56:14 +05:30
dhanabalan
e5143a0ce8 removed fg line in plnt line controller 2025-07-15 09:39:22 +05:30
dhanabalan
b1674bba53 Added FGnames list out api 2025-07-14 12:15:27 +05:30
dhanabalan
52a25fec8e Added FG Line in plant line controller 2025-07-14 11:20:56 +05:30
dhanabalan
dafe1ca458 Added gurad names get api for guard dashboard 2025-07-12 16:20:00 +05:30
dhanabalan
af384faa7c Added guard day count get api 2025-07-12 15:08:29 +05:30
dhanabalan
c6f61fa19a Added unique constraint fro invoice mail report 2025-07-12 14:35:29 +05:30
dhanabalan
aaa93e740b Added get api for invoice quantity for invoice module 2025-07-12 14:31:40 +05:30
dhanabalan
33acf73b5e Added invoice dashboard module get api 2025-07-12 14:03:12 +05:30
dhanabalan
ea5af41f7f Removed unwanted lines in final filter data in production dashboard 2025-07-12 11:36:24 +05:30
dhanabalan
c8ea502833 removed all lines options in production hourly chart 2025-07-12 11:35:30 +05:30
dhanabalan
7e317f6e5f Added status_description in production dashboard 2025-07-12 11:12:47 +05:30
dhanabalan
1465734acd Added all modules with fg count logic 2025-07-12 11:04:31 +05:30
dhanabalan
642053653c Added module production order controller get api 2025-07-12 09:15:42 +05:30
dhanabalan
27524c4d62 Updated validations and success durations and added serial_number maximum length should be 20 digit and clear field if invalid input 2025-07-11 18:23:52 +05:30
dhanabalan
9fa4c0dd49 Added this week nd this month and yesterday and today filter logic for hourly chart in production module 2025-07-11 17:47:09 +05:30
dhanabalan
4d5b14fe69 Added hourly chart logic for production in modules 2025-07-11 17:26:46 +05:30
dhanabalan
b4ca4a9fcd Added hourly data in production quantity in modules 2025-07-11 17:18:01 +05:30
dhanabalan
484bc6d070 Added proper status code for all the api modules 2025-07-11 16:01:37 +05:30
dhanabalan
b153a53f4b Added logic for all lines in modulefilterdataController and changed logic in module controller 2025-07-11 15:51:09 +05:30
dhanabalan
658dea8e72 Added all get api for modules data 2025-07-11 15:32:53 +05:30
dhanabalan
e934cdb193 Added module controller and api logic 2025-07-11 12:30:00 +05:30
dhanabalan
d61c61879f Added module list policy file 2025-07-11 12:27:33 +05:30
dhanabalan
4b597629aa Added module list resource page 2025-07-11 12:26:44 +05:30
dhanabalan
9173dcb50a Added module list model file 2025-07-11 12:26:17 +05:30
dhanabalan
4a17892865 Added module list migration file 2025-07-11 12:25:49 +05:30
dhanabalan
e9d967e2c2 Added logic for all plants in production report 2025-07-11 09:16:32 +05:30
dhanabalan
215e1302cc Added 0 instead of all plamnts in alert mail 2025-07-10 18:26:15 +05:30
dhanabalan
1f085b3f91 solved logic for invalid data type for all plants in alert mail 2025-07-10 18:25:45 +05:30
dhanabalan
ab9c3a80db Added logic in edit page for alert mail 2025-07-10 18:23:48 +05:30
dhanabalan
5f0c01176a Added logic for all plants in invoice report 2025-07-10 17:58:30 +05:30
dhanabalan
b73202e03f resolved logic invoice report 2025-07-10 17:46:34 +05:30
dhanabalan
6a8978f676 commented unwanted lines in production report 2025-07-10 17:07:46 +05:30
dhanabalan
61320dfae8 issue solved for production pln in production report 2025-07-10 17:06:59 +05:30
dhanabalan
7715a20c19 issue solved in qulaity data send to sap page 2025-07-10 16:54:35 +05:30
dhanabalan
bb41d72701 Added production sap data of filament page 2025-07-10 16:39:49 +05:30
dhanabalan
fcb6a945ff Added quality data sap of filament page 2025-07-10 16:39:05 +05:30
dhanabalan
2d2f0d3662 Added production data sap livewire page 2025-07-10 16:38:28 +05:30
dhanabalan
cb4605221c Added quality sap data livewire page 2025-07-10 16:36:55 +05:30
dhanabalan
5a8775c092 Added production data send to sap page 2025-07-10 16:36:00 +05:30
dhanabalan
bef0c986b2 Added Quality data send to sap page 2025-07-10 16:35:16 +05:30
dhanabalan
80163fb0ff Updated validation functionality on import 2025-07-10 16:20:07 +05:30
dhanabalan
170b784a9b Added plant in model file 2025-07-10 15:12:01 +05:30
dhanabalan
4311c64531 changed logici n production mail report 2025-07-10 15:08:32 +05:30
dhanabalan
3c9cc702d4 added plant column in alert mail rules migration file 2025-07-10 15:06:02 +05:30
dhanabalan
752c3cb0da changed logic for sending mails for only have schedule types in production report 2025-07-10 11:21:53 +05:30
dhanabalan
1597795c74 Commented success message 2025-07-10 10:21:53 +05:30
dhanabalan
d75dcdfdd1 Updated validation on import rework data 2025-07-09 21:03:46 +05:30
dhanabalan
b8738a2f6a Added serial_number minimum length should be 9 digit and notification display duration and updated validations 2025-07-09 20:57:06 +05:30
dhanabalan
4ac1823e5b Added serial_number minimum length should be 9 digit and notification display duration and updated validations 2025-07-09 19:35:39 +05:30
dhanabalan
eb2b857aa7 Updated column position in view report 2025-07-09 18:05:11 +05:30
dhanabalan
693e3a23a4 Added serial_number minimum length should be 9 digit and notification display duration 2025-07-09 17:27:41 +05:30
dhanabalan
49d2f1088f Removed colon symbol in notifications 2025-07-09 17:03:09 +05:30
dhanabalan
34b2a05166 Added serial_number minimum length should be 9 digit 2025-07-09 16:16:47 +05:30
dhanabalan
ee99ada3e7 Added notification display duration 2025-07-09 16:15:44 +05:30
dhanabalan
3665b63ff9 Commented scheduler run commands 2025-07-09 11:02:19 +05:30
dhanabalan
aeb3b694e4 Added filter functionality on view report 2025-07-09 11:00:31 +05:30
dhanabalan
a4d2c20451 Removed unwanted space line and updated indentations 2025-07-09 11:00:04 +05:30
dhanabalan
15849fc543 issue solve din production report send mail 2025-07-09 10:32:45 +05:30
dhanabalan
fec85824c2 changed logic for only production mail alert only 2025-07-09 10:30:06 +05:30
dhanabalan
6d6d3f2d60 chnaged logic for prooduction mail report 2025-07-09 10:18:57 +05:30
dhanabalan
29de91e03d Added logic for production mail report 2025-07-09 10:04:54 +05:30
dhanabalan
5ab109006e Added production mail and invoice mail report 2025-07-08 19:42:12 +05:30
dhanabalan
35aa2fab56 Added alert mail rule policy file 2025-07-08 19:03:22 +05:30
dhanabalan
a87bc6e909 Removed unwanted space line 2025-07-08 19:00:23 +05:30
dhanabalan
3818fa612e Updated navigation list order and import, export button color and navigation label 2025-07-08 18:59:23 +05:30
dhanabalan
0f6b62b47a Updated navigation list order 2025-07-08 18:58:11 +05:30
dhanabalan
656dd17603 Added validation functionality on import 2025-07-08 18:56:22 +05:30
dhanabalan
0c27bd4cfd Updated plant code instead of name on export 2025-07-08 18:56:09 +05:30
dhanabalan
c7779f49b7 Added validation functionality on import 2025-07-08 18:55:48 +05:30
dhanabalan
49c4f25c79 Updated plant code instead of name on export 2025-07-08 18:55:15 +05:30
dhanabalan
f37f62be46 Updated validation functionality on import 2025-07-08 18:54:50 +05:30
dhanabalan
5465364ffd Added validation functionality on import 2025-07-08 18:54:17 +05:30
dhanabalan
75963b3ce6 Updated plant code instead of name on export 2025-07-08 18:52:56 +05:30
dhanabalan
b36700af92 removed run in background for mail report 2025-07-08 18:08:47 +05:30
dhanabalan
5a654d1d40 Added custom logic in for mail report 2025-07-08 17:47:32 +05:30
dhanabalan
2f3b028b17 Commented schedule report lines 2025-07-08 17:27:05 +05:30
dhanabalan
904d850638 Issue resolved houlrly mail report 2025-07-08 17:09:59 +05:30
dhanabalan
f5e7bcb348 Added view reprint pallet number and send to sap permissions 2025-07-07 18:32:38 +05:30
dhanabalan
171c675014 issue solved in production report 2025-07-07 18:19:17 +05:30
dhanabalan
bd5bb7f54c Schedule List issues resolved 2025-07-07 17:58:46 +05:30
dhanabalan
74c3243c06 Added reprint functionality in pallet validation 2025-07-07 17:35:58 +05:30
dhanabalan
bd0eed07ac Added reprint functionality in pallet validation resource page 2025-07-07 17:22:34 +05:30
dhanabalan
b564e2debe Added mpdf storage in pallet controller 2025-07-07 14:39:29 +05:30
dhanabalan
4c8fa0bdd6 Updated plant code instead of plant name on export 2025-07-07 13:46:41 +05:30
dhanabalan
48ce6681ac Updated plant code instead of plant name on import 2025-07-07 13:43:11 +05:30
dhanabalan
cefebd9f86 Updated get latest update_count in post method functionality 2025-07-05 21:15:50 +05:30
dhanabalan
3a0185391a removed quality validation option from the form 2025-07-05 21:02:59 +05:30
dhanabalan
c38a417b85 Added navigation group for alert mail resource page 2025-07-05 21:01:08 +05:30
dhanabalan
cfe8ac3496 Added invoicemail ad productionmail report views pages and commands pages 2025-07-05 20:53:31 +05:30
dhanabalan
be79dcdc45 Added alertmailrule resource pages 2025-07-05 20:51:07 +05:30
dhanabalan
9398374f88 Added Alertmailrule model page 2025-07-05 20:50:26 +05:30
dhanabalan
43edf2ec5a Added alret mail rules migration file 2025-07-05 20:50:00 +05:30
dhanabalan
08b142e70f Commented unwanted lines 2025-07-05 18:33:42 +05:30
dhanabalan
de0de426f0 Updated validation functionality and failure messages in controller files 2025-07-05 18:25:11 +05:30
dhanabalan
3eb9f64fca Updated hv_test label in form design and report page 2025-07-05 17:06:51 +05:30
dhanabalan
7ff55f0b25 Updated locator_quantity validation on filter report 2025-07-04 18:07:34 +05:30
dhanabalan
3e0633def2 Updated generate pallet number functionality globally instead of plant wise 2025-07-04 17:45:16 +05:30
dhanabalan
cea7f86fed Removed unwanted line 2025-07-04 17:39:57 +05:30
dhanabalan
af3ae0803c Added locator validation functionality on resource page and importer file 2025-07-04 17:39:30 +05:30
dhanabalan
10b439f8e3 Added validation functionality on importer file 2025-07-03 17:01:50 +05:30
dhanabalan
fc6b3efd0a Updated machine label in exporter 2025-07-03 16:05:35 +05:30
dhanabalan
6372e293e2 Updated machine label header in importer 2025-07-03 16:03:21 +05:30
dhanabalan
c2817aefe4 Updated machine label in importer 2025-07-03 16:01:14 +05:30
dhanabalan
40ad560bca Uncommented user, plant, machine, sticker master controllers api path 2025-07-03 15:51:43 +05:30
dhanabalan
a5bc41beda Commented unwanted line 2025-07-03 15:20:12 +05:30
dhanabalan
ba48c1307e Added machine controller file 2025-07-03 15:13:59 +05:30
dhanabalan
d222fe5a3b Added laser_part_validation1 and laser_part_validation2 column in importer and exporter file 2025-07-03 14:42:13 +05:30
dhanabalan
aa4cec997d Added laser_part_validation1, laser_part_validation2 column and clear fields while plant change in resource file and display material type like Individual, Bundle, Quantity instead of 1, 2, 3 in view report 2025-07-03 14:18:39 +05:30
dhanabalan
c2c9470979 Added laser_part_validation1 and laser_part_validation2 column in model file 2025-07-03 13:52:16 +05:30
dhanabalan
6ea2fc3d23 Added work_center column in importer and exporter file 2025-07-03 13:49:03 +05:30
dhanabalan
04da674868 Added work_center column in resource file 2025-07-03 13:40:52 +05:30
dhanabalan
0174a8494d Added work_center column in model file 2025-07-03 13:38:05 +05:30
dhanabalan
bff1cb0d28 Removed pds_status and pds_description column in importer and exporter file 2025-07-03 13:36:59 +05:30
dhanabalan
5543938eae Added group_work_center column in importer and exporter file 2025-07-03 13:34:35 +05:30
dhanabalan
4addab5573 Added group_work_center column in resource file and plant column position changed in view report 2025-07-03 13:32:16 +05:30
dhanabalan
000c80c1e6 Added group_work_center column in model file 2025-07-03 13:26:23 +05:30
dhanabalan
aae2fafc1f Added laser_part_validation1 and laser_part_validation2 column in sticker_masters table 2025-07-03 12:25:08 +05:30
dhanabalan
e958a036c7 Added work_center column in machines table 2025-07-03 12:21:23 +05:30
dhanabalan
710ff318ef Added group_work_center column in lines table 2025-07-03 12:10:21 +05:30
dhanabalan
5ec4be082d Added output_flag column on view report 2025-07-03 11:42:33 +05:30
dhanabalan
955d143f52 Updated space alignment in testing panel readings migration 2025-07-03 11:08:08 +05:30
dhanabalan
5b287f974d Removed unwanted enter line space 2025-07-02 18:42:17 +05:30
dhanabalan
f5345fc2b8 Added policy files 2025-07-02 18:07:09 +05:30
dhanabalan
cd09b912ee Added hasMany relations for guard patrol entry 2025-07-02 18:03:26 +05:30
dhanabalan
008e9ff791 Added view invoice serial quantity dashboard permission 2025-07-02 17:58:58 +05:30
dhanabalan
a0c0588e49 Removed unwanted enter line space 2025-07-02 17:44:27 +05:30
dhanabalan
137341fc6c Added sticker master controller file 2025-07-02 17:43:30 +05:30
dhanabalan
33d22dec5b Added plant controller file 2025-07-02 17:26:33 +05:30
dhanabalan
231b65ff7a Added mpdf temp storage code 2025-07-02 17:24:19 +05:30
dhanabalan
102d9af638 Added invoice rework blade file 2025-07-02 17:22:35 +05:30
dhanabalan
b20bff9003 Updated colspan on empty data 2025-07-02 17:20:14 +05:30
dhanabalan
c8ad6f3dda Added generate pallet number api function 2025-07-02 17:10:59 +05:30
dhanabalan
062ab6d8a1 Added pallet controller file 2025-07-02 17:07:32 +05:30
dhanabalan
4d4414ffa7 Removed generate pallet number functionality 2025-07-02 17:06:29 +05:30
dhanabalan
4f87a0d318 Removed generate pallet pdf from testing panel controlled and added into api 2025-07-02 17:02:08 +05:30
dhanabalan
33f787c6ad Added filter functionality 2025-07-02 16:39:36 +05:30
dhanabalan
bf6874fe96 Added autofocus and ignore unique record checking on update 2025-07-02 16:28:38 +05:30
dhanabalan
3406dbc1c7 Removed unwanted enter line space 2025-07-02 16:23:23 +05:30
dhanabalan
e20ebfe667 Removed unwanted enter line space on filter report 2025-07-02 16:22:38 +05:30
dhanabalan
3012dd61bb Removed searchable functionality 2025-07-02 16:20:55 +05:30
dhanabalan
cdc8a5ce54 Updated from_datetime validation 2025-07-02 16:20:18 +05:30
dhanabalan
f3a4aa7411 Added unique validation rule 2025-07-02 16:14:07 +05:30
dhanabalan
2ae71b9bb8 Removed searchable functionality 2025-07-02 16:12:34 +05:30
dhanabalan
58fc922f24 Updated plant and item code position 2025-07-02 16:10:45 +05:30
dhanabalan
68c5c88fc8 Updated warning message to display unique codes only 2025-07-02 16:09:50 +05:30
dhanabalan
c4b4993e1d Updated readonly rule 2025-07-02 16:05:25 +05:30
dhanabalan
fd3ef4656c Added indentations 2025-07-02 16:04:47 +05:30
dhanabalan
6e7b847e89 Updated plant and line position 2025-07-02 16:03:29 +05:30
dhanabalan
0fbe279bf9 Added rework locator invoice validation importer 2025-07-02 16:02:23 +05:30
dhanabalan
8188cd6cef Updated block and plant position 2025-07-02 16:02:00 +05:30
dhanabalan
bdbfc8e024 Updated plant position 2025-07-02 16:01:41 +05:30
dhanabalan
c3f9c9f2c4 Updated plant and line position 2025-07-02 16:00:43 +05:30
dhanabalan
5cb2842954 Updated company position 2025-07-02 15:59:47 +05:30
dhanabalan
6a0f5b57a6 Added pallet validation importer 2025-07-02 15:59:15 +05:30
dhanabalan
690a6f8026 Updated plant position 2025-07-02 15:57:36 +05:30
dhanabalan
4392123c6a Added new column and updated exist column and changed its position 2025-07-02 15:57:10 +05:30
dhanabalan
008cb5d82b Updated plant position 2025-07-02 15:41:30 +05:30
dhanabalan
12169a1276 Updated plant and line position 2025-07-02 15:40:24 +05:30
dhanabalan
14a1909163 Updated operator_id position 2025-07-02 15:38:39 +05:30
dhanabalan
51e9c6ba90 Added rework locator invoice validation exporter 2025-07-02 15:30:39 +05:30
dhanabalan
88bc62c8f2 Added pallet validation exporter 2025-07-02 15:21:45 +05:30
dhanabalan
0cb0758f67 Updated lable names and changed its position 2025-07-02 15:20:33 +05:30
dhanabalan
123f67d9bc Updated plant name position to start 2025-07-02 15:14:27 +05:30
dhanabalan
85746af6f7 Updated operator_id position to end 2025-07-02 15:13:47 +05:30
dhanabalan
8f95147a30 Updated warning message if locator serial numbers not exist 2025-07-02 15:12:53 +05:30
dhanabalan
a33c73c2f2 Updated success and failure messages and notifications display seconds 2025-07-02 15:03:50 +05:30
dhanabalan
017088c380 Added create pallet from locator page and livewire pages and table 2025-07-02 13:06:00 +05:30
dhanabalan
148b6444b6 Added filter functionalty in rework locator invoice validation page 2025-07-02 11:20:56 +05:30
dhanabalan
49dbd357aa issue in passing id value instead of column name in pallet validation filter 2025-07-02 11:03:59 +05:30
dhanabalan
4a8802060a Added filter functionality in locator invoice validation page 2025-07-02 11:03:12 +05:30
dhanabalan
4d153fcfa7 Added filter functionality in pallet validation page 2025-07-02 10:25:17 +05:30
dhanabalan
a0db69a4c8 Added rework locator invoice validation livewire page and table 2025-07-01 15:12:12 +05:30
dhanabalan
b13b5dbb05 Added rework locator invoice validation resource pages 2025-07-01 15:10:35 +05:30
dhanabalan
fcf1fed70d Added rework locator invoice validation model file 2025-07-01 15:08:58 +05:30
dhanabalan
bdb9d9b9c3 Added rework locator invoice validation migration file 2025-07-01 15:05:28 +05:30
dhanabalan
5435261e40 Added invoice finder view page 2025-07-01 14:56:21 +05:30
dhanabalan
45d426b6b8 Added invoice finder pages and livewire pages 2025-07-01 14:54:52 +05:30
dhanabalan
2de993c6d0 Added locator invoice validation importer and exporter file 2025-07-01 14:44:08 +05:30
dhanabalan
95436af7da Added locator invoice validation livewire page and table 2025-07-01 14:42:55 +05:30
dhanabalan
d3ebee5020 Added locatorinvoicevalidation resource pages 2025-07-01 14:39:51 +05:30
dhanabalan
f3c3dff6a0 Added locator invoice validation model file 2025-07-01 14:37:03 +05:30
dhanabalan
829f5670ad Added locator invoice validation migration file 2025-07-01 14:35:06 +05:30
dhanabalan
b4a0893bfc Added Upload serial locator pages and livewire 2025-07-01 14:31:46 +05:30
dhanabalan
98c445a98a Added locator validation page and locator data table 2025-07-01 14:15:10 +05:30
dhanabalan
789bc6a173 Added mpdf permission 2025-07-01 14:04:34 +05:30
dhanabalan
6904a03e1f Add mpdf/qrcode for QR code support 2025-07-01 13:51:54 +05:30
dhanabalan
fb29148011 pallet pdf issue solved package 2025-07-01 13:47:52 +05:30
dhanabalan
e083c0e4a5 Added pallet data tables 2025-07-01 13:16:32 +05:30
dhanabalan
c2b193c5b8 Added pdf file for pallet validation resource page 2025-07-01 13:10:38 +05:30
dhanabalan
dde57f31c3 Added pallet validation resource pages 2025-07-01 13:07:40 +05:30
dhanabalan
62e66bf0c7 Added pallet validation model file 2025-07-01 13:04:20 +05:30
dhanabalan
33d78861fb Added pallet validation table migration file 2025-07-01 13:02:10 +05:30
dhanabalan
23fb2eed4d Added locator importer and exporter file 2025-07-01 12:49:27 +05:30
dhanabalan
0199c8977c Added locators resource file 2025-07-01 12:48:25 +05:30
dhanabalan
7d2ed7aff5 Added locators model file 2025-07-01 12:45:52 +05:30
dhanabalan
f52a38c133 Added locators table migration 2025-07-01 12:41:46 +05:30
dhanabalan
5fd8b7e6bf issue solved in invoice chart setted data label 2025-06-29 16:26:20 +05:30
dhanabalan
61973a424e Added dashboard blade page for invoice quantity 2025-06-29 16:19:13 +05:30
dhanabalan
ced01440f5 Added chart for invoice quantity 2025-06-29 16:17:44 +05:30
dhanabalan
cc48e4ae3d solvd issue for cumulative chart 2025-06-27 16:46:34 +05:30
dhanabalan
eb93a8602f solved total count issue in cumulative chart 2025-06-27 16:28:43 +05:30
dhanabalan
b798cbcbfd adjusted label position of the x axis bar in hourly production chart 2025-06-27 15:45:37 +05:30
dhanabalan
630b921a37 adjust position of label for day chart of patrol 2025-06-27 15:37:01 +05:30
dhanabalan
1945e71ae1 chenged label position of the x axis in production order count 2025-06-27 15:24:18 +05:30
dhanabalan
72a1eca400 Changed data label position of the production line count chart 2025-06-27 14:44:23 +05:30
dhanabalan
82b56c6cc9 adjusted positon of the label in hourly production chart 2025-06-27 14:31:20 +05:30
dhanabalan
04ed10d9e1 Added manifest file into production 2025-06-27 13:39:26 +05:30
dhanabalan
0fc1852ea2 Added chart js plugin package and sets static label 2025-06-27 12:46:29 +05:30
dhanabalan
fea6573a7a issue solved in hourly chart patrol 2025-06-27 08:43:47 +05:30
dhanabalan
723d424b88 Updated view guard patrol entry dashboard name into view guard patrol entry status dashboard 2025-06-26 16:27:09 +05:30
dhanabalan
f9a0aa9fa0 Updated dynamic sequence minutes calculation functionality and table design load functionality from fixed sequence 2025-06-26 16:25:56 +05:30
dhanabalan
934d449a6b Removed searchable functionality and Added created_by drop-down list on report page 2025-06-26 16:16:51 +05:30
dhanabalan
cf1387db7f Added redirect to create page url function 2025-06-26 15:55:35 +05:30
dhanabalan
a9af944c27 Updated permission name to view 2025-06-26 14:57:44 +05:30
dhanabalan
32313c0609 solved logic in hourly guard patrol 2025-06-25 17:50:55 +05:30
dhanabalan
b418e780b0 issue solved for multiple charts displayed in production line count 2025-06-25 15:38:11 +05:30
dhanabalan
edc8a8f37b Added dashboard for patrol day count 2025-06-25 14:29:46 +05:30
dhanabalan
cbfe7a56bb Added guard hourly patrol chart 2025-06-25 14:23:52 +05:30
dhanabalan
3a796857b0 Added guard patrol day count chart 2025-06-25 10:34:11 +05:30
dhanabalan
88cde40215 Added report filter functionality and removed reader_code on report 2025-06-24 17:41:44 +05:30
dhanabalan
97d43ac8cf Added from-to patrol time within sequence title on guard_patrol_entry_data_table 2025-06-24 17:32:00 +05:30
dhanabalan
be466cfdc2 Removed session functionality and Updated page heading 2025-06-24 17:20:00 +05:30
dhanabalan
932488fdc3 Removed reader_code on import / export and disabled created at/by, updated at/by 2025-06-24 17:18:11 +05:30
dhanabalan
ad5f52c72b Updated permission seeder 2025-06-23 19:07:18 +05:30
dhanabalan
19510d8348 Added GuardPatrolEntry Dashboard and Added masters with transaction Policy 2025-06-23 18:57:05 +05:30
dhanabalan
ecf6d494de Added guard_patrol_entry importer and exporter file 2025-06-23 18:43:05 +05:30
dhanabalan
21c1d097aa Added guard_patrol_entry resource files 2025-06-23 18:41:46 +05:30
dhanabalan
1ea961a3b8 Added guard_patrol_entry model file 2025-06-23 18:39:22 +05:30
dhanabalan
72df3fe3c3 Added guard_patrol_entries table migration 2025-06-23 18:38:32 +05:30
dhanabalan
ea4e2c929f Updated passing checkPointNames 'id' instead of 'name' 2025-06-23 18:36:11 +05:30
dhanabalan
09b69b9aa3 Added check_point_time importer and exporter file 2025-06-23 18:28:19 +05:30
dhanabalan
56a8058094 Added check_point_time resource files 2025-06-23 18:27:25 +05:30
dhanabalan
30c8804127 Added check_point_time model file 2025-06-23 18:24:26 +05:30
dhanabalan
eae2d49e25 Added check_point_times table migration 2025-06-23 18:23:09 +05:30
dhanabalan
be6b20fb26 Updated exampleHeader on importer file 2025-06-23 18:20:47 +05:30
dhanabalan
2492564c7a Updated CheckPointNameImporter from CheckPointNameExporter on ImportAction 2025-06-23 18:17:10 +05:30
dhanabalan
a205762649 Added check_point_name importer and exporter file 2025-06-23 18:09:07 +05:30
dhanabalan
40a9f14c53 Added check_point_name resource files 2025-06-23 18:07:02 +05:30
dhanabalan
0193298675 Added check_point_name model file 2025-06-23 18:05:28 +05:30
dhanabalan
48b6a0e839 Added check_point_names table migration 2025-06-23 18:01:59 +05:30
dhanabalan
16d559683a Added guard_name importer and exporter file 2025-06-23 17:49:04 +05:30
dhanabalan
5eba607944 Added guard_name resource files 2025-06-23 17:48:18 +05:30
dhanabalan
7510fc3d77 Added guard_name model file 2025-06-23 17:45:41 +05:30
dhanabalan
c39bcaee02 Updated label and variable declarion for default zero 2025-06-23 17:44:20 +05:30
dhanabalan
4f2e811abb Added guard_names table migration 2025-06-23 17:42:38 +05:30
dhanabalan
05ac6c7712 Added block name column on report view 2025-06-21 10:36:31 +05:30
dhanabalan
5f7911b5c2 Added block name column and changed operator_id position on export 2025-06-21 10:35:10 +05:30
341 changed files with 46666 additions and 1785 deletions

View File

@@ -0,0 +1,164 @@
<?php
namespace App\Console\Commands;
use App\Models\AlertMailRule;
use Illuminate\Console\Scheduling\Schedule;
class ScheduleList
{
// public function schedule(Schedule $schedule): void
// {
// // Invoice Report Scheduling
// $scheduleType = AlertMailRule::where('module', 'InvoiceValidation')
// ->where('rule_name', 'InvoiceMail')
// ->value('schedule_type');
// switch ($scheduleType) {
// case 'Live':
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
// break;
// case 'Hourly':
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
// break;
// // case 'Daily':
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
// // break;
// case 'Daily':
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
// break;
// default:
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
// break;
// }
// $SerialscheduleType = AlertMailRule::where('module', 'InvoiceValidation')
// ->where('rule_name', 'SerialInvoiceMail')
// ->value('schedule_type');
// switch ($SerialscheduleType) {
// case 'Live':
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
// break;
// case 'Hourly':
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
// break;
// // case 'Daily':
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
// // break;
// case 'Daily':
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
// break;
// default:
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
// break;
// }
// $materialscheduleType = AlertMailRule::where('module', 'InvoiceValidation')
// ->where('rule_name', 'MaterialInvoiceMail')
// ->value('schedule_type');
// switch ($materialscheduleType) {
// case 'Live':
// $schedule->command('send:invoice-report')->everyMinute()->runInBackground();
// break;
// case 'Hourly':
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
// break;
// // case 'Daily':
// // $schedule->command('send:invoice-report')->daily()->runInBackground(); //->dailyAt('07:59')
// // break;
// case 'Daily':
// $schedule->command('send:invoice-report')->dailyAt('07:59')->runInBackground(); //->dailyAt('07:59')
// break;
// default:
// $schedule->command('send:invoice-report')->hourly()->runInBackground();
// break;
// }
// // Production Report Scheduling
// $productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->value('schedule_type');
// switch ($productionScheduleType) {
// case 'Live':
// $schedule->command('send:production-report')->everyMinute()->runInBackground();
// break;
// case 'Hourly':
// $schedule->command('send:production-report')->hourly()->runInBackground();
// break;
// case 'Daily':
// $schedule->command('send:production-report')->dailyAt('07:59')->runInBackground();
// break;
// default:
// $schedule->command('send:production-report')->hourly()->runInBackground();
// break;
// }
// }
public function schedule(Schedule $schedule): void
{
// Define the rules you want to schedule
$rules = [
[
'module' => 'InvoiceValidation',
'rule_name' => 'InvoiceMail',
'argument' => 'InvoiceMail',
],
[
'module' => 'InvoiceValidation',
'rule_name' => 'SerialInvoiceMail',
'argument' => 'SerialInvoiceMail',
],
[
'module' => 'InvoiceValidation',
'rule_name' => 'MaterialInvoiceMail',
'argument' => 'MaterialInvoiceMail',
],
];
// Loop through each rule and schedule accordingly
foreach ($rules as $rule) {
$scheduleType = AlertMailRule::where('module', $rule['module'])
->where('rule_name', $rule['rule_name'])
->value('schedule_type');
switch ($scheduleType) {
case 'Live':
$schedule->command("send:invoice-report {$rule['argument']}")->everyMinute()->runInBackground();
break;
case 'Hourly':
$schedule->command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground();
break;
case 'Daily':
$schedule->command("send:invoice-report {$rule['argument']}")->dailyAt('07:59')->runInBackground();
break;
default:
$schedule->command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground();
break;
}
}
// Production Report Scheduling
$productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->value('schedule_type');
switch ($productionScheduleType) {
case 'Live':
$schedule->command('send:production-report')->everyMinute()->runInBackground();
break;
case 'Hourly':
$schedule->command('send:production-report')->hourly()->runInBackground();
break;
case 'Daily':
$schedule->command('send:production-report')->dailyAt('07:59')->runInBackground();
break;
default:
$schedule->command('send:production-report')->hourly()->runInBackground();
break;
}
}
}

View File

@@ -0,0 +1,415 @@
<?php
namespace App\Console\Commands;
use App\Models\InvoiceValidation;
use App\Models\Plant;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use App\Mail\test;
class SendInvoiceReport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
// protected $signature = 'app:send-invoice-report';
protected $signature = 'send:invoice-report{schedule_type} {plant}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
// public function handle()
// {
// $schedule = $this->argument('schedule_type');
// $plantid = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
// $serialTableData = [];
// $materialTableData = [];
// $bundleTableData = [];
// $noSerial = 1;
// $noMaterial = 1;
// $noBundle = 1;
// foreach ($plants as $plantId) {
// $plant = Plant::find($plantId);
// $plantName = $plant ? $plant->name : $plantId;
// //..Serial Invoice
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
// )
// ->count();
// $serialTableData[] = [
// 'no' => $noSerial++,
// 'plant' => $plantName,
// 'totalInvoice' => $totalSerialCount,
// 'scannedInvoice' => $scannedSerialCount,
// ];
// //..Individual Invoice
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedMatCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $materialTableData[] = [
// 'no' => $noMaterial++,
// 'plant' => $plantName,
// 'totalInvoice' => $TotalMatCount,
// 'scannedInvoice' => $scannedMatCount,
// ];
// //..BUndle Invoice
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $bundleTableData[] = [
// 'no' => $noBundle++,
// 'plant' => $plantName,
// 'totalInvoice' => $totalBundleCount,
// 'scannedInvoice' => $scannedBundleCount,
// ];
// }
// // Send to SerialInvoiceMail recipients
// if ($mailRules->has('SerialInvoiceMail')) {
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, [], []));
// }
// }
// // Send to MaterialInvoiceMail recipients (material + bundle table)
// if ($mailRules->has('MaterialInvoiceMail')) {
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
// }
// }
// // Send to InvoiceMail recipients (all three tables)
// if ($mailRules->has('InvoiceMail')) {
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
// }
// }
// //$this->info(json_encode($materialTableData));
// }
// public function handle()
// {
// $schedule = $this->argument('schedule_type');
// $plantId = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $serialTableData = [];
// $materialTableData = [];
// $bundleTableData = [];
// $plant = Plant::find($plantId);
// $plantName = $plant ? $plant->name : $plantId;
// // Serial Invoice
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
// )
// ->count();
// $serialTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $totalSerialCount,
// 'scannedInvoice' => $scannedSerialCount,
// ];
// // Individual Material Invoice
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedMatCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $materialTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $TotalMatCount,
// 'scannedInvoice' => $scannedMatCount,
// ];
// // Bundle Invoice
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $bundleTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $totalBundleCount,
// 'scannedInvoice' => $scannedBundleCount,
// ];
// // Send to SerialInvoiceMail recipients
// if ($mailRules->has('SerialInvoiceMail')) {
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, [], []));
// }
// }
// // Send to MaterialInvoiceMail recipients (material + bundle table)
// if ($mailRules->has('MaterialInvoiceMail')) {
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
// }
// }
// // Send to InvoiceMail recipients (all three tables)
// if ($mailRules->has('InvoiceMail')) {
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
// }
// }
// // $this->table(
// // ['No', 'Plant', 'Total Invoice', 'Scanned Invoice'],
// // $serialTableData
// // );
// }
public function handle()
{
$schedule = $this->argument('schedule_type');
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
$serialTableData = [];
$materialTableData = [];
$bundleTableData = [];
// Get plant IDs: either one plant or all
$plantIds = $plantIdArg == 0
? InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id')->toArray()
: [$plantIdArg];
$no = 1;
if (strtolower($schedule) == 'daily')
{
$startDate = now()->subDay()->setTime(8, 0, 0);
$endDate = now()->setTime(8, 0, 0);
}
else
{
$startDate = now()->setTime(8, 0, 0);
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
}
foreach ($plantIds as $plantId) {
$plant = Plant::find($plantId);
$plantName = $plant ? $plant->name : $plantId;
// Serial Invoice
$totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
->whereNull('quantity')
->whereBetween('created_at', [$startDate, $endDate])
->distinct('invoice_number')
->count('invoice_number');
$scannedSerialCount = InvoiceValidation::select('invoice_number')
->where('plant_id', $plantId)
->whereNull('quantity')
->whereBetween('updated_at', [$startDate, $endDate])
->groupBy('invoice_number')
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
->count();
$serialTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalSerialCount,
'scannedInvoice' => $scannedSerialCount,
];
// Material Invoice
$totalMatCount = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', 1)
->whereBetween('created_at', [$startDate, $endDate])
->distinct('invoice_number')
->count('invoice_number');
$scannedMatCount = InvoiceValidation::select('invoice_number')
->where('plant_id', $plantId)
->where('quantity', 1)
->whereBetween('updated_at', [$startDate, $endDate])
->groupBy('invoice_number')
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
->count();
$materialTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalMatCount,
'scannedInvoice' => $scannedMatCount,
];
// Bundle Invoice
$totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereBetween('created_at', [$startDate, $endDate])
->distinct('invoice_number')
->count('invoice_number');
$scannedBundleCount = InvoiceValidation::select('invoice_number')
->where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereBetween('updated_at', [$startDate, $endDate])
->groupBy('invoice_number')
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
->count();
$bundleTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalBundleCount,
'scannedInvoice' => $scannedBundleCount,
];
$no++;
}
// Send to SerialInvoiceMail recipients
if ($mailRules->has('SerialInvoiceMail')) {
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, [], []));
}
}
// Send to MaterialInvoiceMail recipients (material + bundle table)
if ($mailRules->has('MaterialInvoiceMail')) {
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
}
}
// Send to InvoiceMail recipients (all three tables)
if ($mailRules->has('InvoiceMail')) {
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
}
}
// Show preview in console
$this->info('--- Serial Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
$this->info('--- Material Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
$this->info('--- Bundle Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
}
}

View File

@@ -0,0 +1,251 @@
<?php
namespace App\Console\Commands;
use App\Models\InvoiceValidation;
use App\Models\Plant;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use App\Mail\ProductionMail;
use App\Models\Line;
use App\Models\ProductionPlan;
use App\Models\ProductionQuantity;
use DB;
class SendProductionReport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
//protected $signature = 'send:production-report';
protected $signature = 'send:production-report {schedule_type} {plant}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
// public function handle()
// {
// $scheduleType = $this->argument('schedule_type');
// $plantId = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->where('plant', $plantId)
// ->where('schedule_type', $scheduleType)
// ->get();
// $emails = $mailRules->pluck('email')->unique()->toArray();
// $plant = Plant::find($plantId);
// if (!$plant) {
// $this->error("Invalid plant ID: $plantId");
// return;
// }
// $lines = Line::where('plant_id', $plantId)->get();
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $PlanstartDate = now()->setTime(8, 0, 0);
// $planendDate = now()->copy()->addDay()->setTime(7, 59, 00);
// $tableData = [];
// $no = 1;
// foreach ($lines as $line) {
// $lineId = $line->id;
// $lineName = $line->name;
// $targetQuantity = ProductionPlan::where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
// ->sum('plan_quantity');
// $productionQuantity = ProductionQuantity::where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $tableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $lineName,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $productionQuantity,
// ];
// }
// // $this->table(
// // ['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'],
// // $tableData
// // );
// if (!empty($emails)) {
// foreach ($emails as $email) {
// Mail::to($email)->send(new ProductionMail($tableData));
// }
// } else {
// $this->info('No recipients found for ProductionMailAlert.');
// }
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
// }
public function handle()
{
$scheduleType = $this->argument('schedule_type');
$plantId = (int) $this->argument('plant'); // cast to int for safety
// Fetch mail rules based on schedule type
$mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->where('schedule_type', $scheduleType)
->where('plant', $plantId)
->get();
$emails = $mailRules->pluck('email')->unique()->toArray();
$plants = $plantId == 0
? Plant::all()
: Plant::where('id', $plantId)->get();
if ($plants->isEmpty()) {
$this->error("No valid plant(s) found.");
return;
}
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
if (strtolower($scheduleType) == 'daily')
{
$startDate = now()->subDay()->setTime(8, 0, 0);
$endDate = now()->setTime(8, 0, 0);
}
else
{
$startDate = now()->setTime(8, 0, 0);
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
}
$PlanstartDate = now()->setTime(8, 0, 0);
$planendDate = now()->copy()->addDay()->setTime(7, 59, 0);
$tableData = [];
$no = 1;
// foreach ($plants as $plant) {
// $lines = Line::where('plant_id', $plant->id)->get();
// foreach ($lines as $line) {
// $targetQuantity = ProductionPlan::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
// ->sum('plan_quantity');
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $tableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $line->name,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $productionQuantity,
// ];
// }
// }
// $fgTableData = []; // store FG Line related data
// foreach ($plants as $plant) {
// // ✅ Only get FG Lines
// $fgLines = Line::where('plant_id', $plant->id)
// ->where('type', 'FG Line')
// ->get();
// foreach ($fgLines as $line) {
// $validationCount = \App\Models\QualityValidation::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $fgTableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $line->name,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $validationCount,
// ];
// }
// }
//..
//.
foreach ($plants as $plant)
{
$lines = Line::where('plant_id', $plant->id)->get();
foreach ($lines as $line) {
$targetQuantity = ProductionPlan::where('plant_id', $plant->id)
->where('line_id', $line->id)
->whereBetween('created_at', [$PlanstartDate, $planendDate])
->sum('plan_quantity');
if (strtolower($line->type) == 'fg line') {
$productionQuantity = \App\Models\QualityValidation::where('plant_id', $plant->id)
->where('line_id', $line->id)
->whereBetween('created_at', [$startDate, $endDate])
->count();
} else {
$productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
->where('line_id', $line->id)
->whereBetween('created_at', [$startDate, $endDate])
->count();
}
$tableData[] = [
'no' => $no++,
'plant' => $plant->name,
'line' => $line->name,
'type' => $line->type,
'targetQuantity' => $targetQuantity,
'productionQuantity' => $productionQuantity,
];
}
}
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
if (!empty($emails)) {
foreach ($emails as $email) {
Mail::to($email)->send(new ProductionMail($tableData));
}
} else {
$this->info('No recipients found for ProductionMailAlert.');
}
$this->info("Production report sent to " . count($emails) . " recipient(s).");
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace App\Filament\Exports;
use App\Models\CheckPointName;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class CheckPointNameExporter extends Exporter
{
protected static ?string $model = CheckPointName::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('name')
->label('CHECK POINT NAME'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your check point name export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Filament\Exports;
use App\Models\CheckPointTime;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class CheckPointTimeExporter extends Exporter
{
protected static ?string $model = CheckPointTime::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('checkPointNames1.name')
->label('CHECK POINT 1'),
ExportColumn::make('checkPointNames2.name')
->label('CHECK POINT 2'),
ExportColumn::make('sequence_number')
->label('SEQUENCE NUMBER'),
ExportColumn::make('time_lapse')
->label('TIME LAPSE'),
ExportColumn::make('time_lapse_cushioning')
->label('TIME LAPSE CUSHIONING'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your check point time export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -13,31 +13,34 @@ class ConfigurationExporter extends Exporter
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('No')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('Plant'),
->label('PLANT'),
ExportColumn::make('line.name')
->label('Line'),
->label('LINE'),
ExportColumn::make('c_type')
->label('Type'),
->label('TYPE'),
ExportColumn::make('c_group')
->label('Group'),
->label('GROUP'),
ExportColumn::make('c_name')
->label('Name'),
->label('NAME'),
ExportColumn::make('c_value')
->label('Value'),
->label('VALUE'),
ExportColumn::make('created_at')
->label('Created At'),
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('Updated At'),
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('Deleted At'),
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Filament\Exports;
use App\Models\DeviceMaster;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class DeviceMasterExporter extends Exporter
{
protected static ?string $model = DeviceMaster::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('name')
->label('DEVICE NAME'),
ExportColumn::make('mac_address')
->label('MAC ADDRESS'),
ExportColumn::make('ip_address')
->label('IP ADDRESS'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your device master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,140 @@
<?php
namespace App\Filament\Exports;
use App\Models\EbReading;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class EbReadingExporter extends Exporter
{
protected static ?string $model = EbReading::class;
static $rowNumber = 0;
public static function getColumns(): array
{
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('lcd_segment_check')
->label('LCD SEGMENT CHECK'),
ExportColumn::make('meter_serial_no')
->label('METER SERIAL NO'),
ExportColumn::make('eb_date_time')
->label('EB DATE TIME'),
ExportColumn::make('ph_seq_of_volt')
->label('PH SEQ OF VOLT'),
ExportColumn::make('ph_assoc_conn_check')
->label('PH ASSOC CONN CHECK'),
ExportColumn::make('instantaneous_ph_volt')
->label('INSTANTANEOUS PH VOLT'),
ExportColumn::make('instantaneous_curr')
->label('INSTANTANEOUS CURR'),
ExportColumn::make('instantaneous_freq')
->label('INSTANTANEOUS FREQ'),
ExportColumn::make('instantaneous_kw_with_sign')
->label('INSTANTANEOUS KW WITH SIGN'),
ExportColumn::make('instantaneous_kva')
->label('INSTANTANEOUS KVA'),
ExportColumn::make('instantaneous_kv_ar')
->label('INSTANTANEOUS KV AR'),
ExportColumn::make('instantaneous_pf_with_sign')
->label('INSTANTANEOUS PF WITH SIGN'),
ExportColumn::make('rd_with_elapsed_time_kva')
->label('RD WITH ELAPSED TIME KVA'),
ExportColumn::make('cum_active_import_energy')
->label('CUM ACTIVE IMPORT ENERGY'),
ExportColumn::make('tod1_active_energy_6_9')
->label('TOD1 ACTIVE ENERGY 6-9'),
ExportColumn::make('tod2_active_energy_18_21')
->label('TOD2 ACTIVE ENERGY 18-21'),
ExportColumn::make('tod3_active_energy_21_22')
->label('TOD3 ACTIVE ENERGY 21-22'),
ExportColumn::make('tod4_active_energy_5_6_9_18')
->label('TOD4 ACTIVE ENERGY 5-6-9-18'),
ExportColumn::make('tod5_active_energy_22_5')
->label('TOD5 ACTIVE ENERGY 22-5'),
ExportColumn::make('cum_reac_lag_energy')
->label('CUM REAC LAG ENERGY'),
ExportColumn::make('cum_reac_lead_energy')
->label('CUM REAC LEAD ENERGY'),
ExportColumn::make('cum_appar_energy')
->label('CUM APPAR ENERGY'),
ExportColumn::make('tod1_appar_energy_6_9')
->label('TOD1 APPAR ENERGY 6-9'),
ExportColumn::make('tod2_appar_energy_18_21')
->label('TOD2 APPAR ENERGY 18-21'),
ExportColumn::make('tod3_appar_energy_21_22')
->label('TOD3 APPAR ENERGY 21-22'),
ExportColumn::make('tod4_appar_energy_5_6_9_18')
->label('TOD4 APPAR ENERGY 5-6-9-18'),
ExportColumn::make('tod5_appar_energy_22_5')
->label('TOD5 APPAR ENERGY 22-5'),
ExportColumn::make('avg_pow_factor')
->label('AVG POW FACTOR'),
ExportColumn::make('avg_freq_15min_last_ip')
->label('AVG FREQ 15MIN LAST IP'),
ExportColumn::make('net_kv_arh_high')
->label('NET KV ARH HIGH'),
ExportColumn::make('net_kv_arh_low')
->label('NET KV ARH LOW'),
ExportColumn::make('cum_md_kva')
->label('CUM MD KVA'),
ExportColumn::make('present_md_kva')
->label('PRESENT MD KVA'),
ExportColumn::make('present_md_kva_date_time')
->label('PRESENT MD KVA DATE TIME'),
ExportColumn::make('tod1_md_kva_6_9')
->label('TOD1 MD KVA 6-9'),
ExportColumn::make('tod2_md_kva_18_21')
->label('TOD2 MD KVA 18-21'),
ExportColumn::make('tod3_md_kva_21_22')
->label('TOD3 MD KVA 21-22'),
ExportColumn::make('tod4_md_kva_5_6_9_18')
->label('TOD4 MD KVA 5-6-9-18'),
ExportColumn::make('tod5_md_kva_22_5')
->label('TOD5 MD KVA 22-5'),
ExportColumn::make('total_pow_off_hours')
->label('TOTAL POW OFF HOURS'),
ExportColumn::make('programming_count')
->label('PROGRAMMING COUNT'),
ExportColumn::make('last_occ_res_event_type')
->label('LAST OCC RES EVENT TYPE'),
ExportColumn::make('last_occ_res_event_date_time')
->label('LAST OCC RES EVENT DATE TIME'),
ExportColumn::make('tamper_count')
->label('TAMPER COUNT'),
ExportColumn::make('reset_count')
->label('RESET COUNT'),
ExportColumn::make('last_md_reset_date_time')
->label('LAST MD RESET DATE TIME'),
ExportColumn::make('electrician_sign')
->label('ELECTRICIAN SIGN'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your eb reading export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace App\Filament\Exports;
use App\Models\GuardName;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class GuardNameExporter extends Exporter
{
protected static ?string $model = GuardName::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('name')
->label('GUARD NAME'),
ExportColumn::make('identification1')
->label('IDENTIFICATION 1'),
ExportColumn::make('identification2')
->label('IDENTIFICATION 2'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your guard name export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Filament\Exports;
use App\Models\GuardPatrolEntry;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class GuardPatrolEntryExporter extends Exporter
{
protected static ?string $model = GuardPatrolEntry::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('guardNames.name')
->label('GUARD NAME'),
ExportColumn::make('checkPointNames.name')
->label('CHECK POINT NAME'),
// ExportColumn::make('reader_code')
// ->label('READER CODE'),
ExportColumn::make('patrol_time')
->label('PATROL TIME'),
ExportColumn::make('created_at')
->enabledByDefault(false)
->label('CREATED AT'),
ExportColumn::make('created_by')
->enabledByDefault(false)
->label('CREATED BY'),
ExportColumn::make('updated_at')
->enabledByDefault(false)
->label('UPDATED AT'),
ExportColumn::make('Updated_by')
->enabledByDefault(false)
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your guard patrol entry export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -54,6 +54,8 @@ class InvoiceValidationExporter extends Exporter
->label('BATCH NUMBER'),
ExportColumn::make('quantity')
->label('QUANTITY'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
ExportColumn::make('created_at')
->label('CREATED AT'),
//->dateTimeFormat('d-m-Y H:i:s'),
@@ -64,8 +66,6 @@ class InvoiceValidationExporter extends Exporter
->enabledByDefault(false)
->label('DELETED AT'),
//->dateTimeFormat('d-m-Y H:i:s'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
];
}

View File

@@ -24,6 +24,8 @@ class ItemExporter extends Exporter
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('category')
->label('CATEGORY'),
ExportColumn::make('code')
@@ -34,8 +36,6 @@ class ItemExporter extends Exporter
->label('HOURLY QUANTITY'),
ExportColumn::make('uom')
->label('UNIT OF MEASURE'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')

View File

@@ -30,6 +30,8 @@ class LineExporter extends Exporter
->label('NAME'),
ExportColumn::make('type')
->label('TYPE'),
ExportColumn::make('group_work_center')
->label('GROUP WORK CENTER'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Filament\Exports;
use App\Models\Locator;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class LocatorExporter extends Exporter
{
protected static ?string $model = Locator::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('locator_number')
->label('LOCATOR NUMBER'),
ExportColumn::make('locator_quantity')
->label('LOCATOR QUANTITY'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your locator export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Filament\Exports;
use App\Models\LocatorInvoiceValidation;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class LocatorInvoiceValidationExporter extends Exporter
{
protected static ?string $model = LocatorInvoiceValidation::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('invoice_number')
->label('INVOICE NUMBER'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('pallet_number')
->label('PALLET NUMBER'),
ExportColumn::make('locator_number')
->label('LOCATOR NUMBER'),
ExportColumn::make('scanned_status')
->label('SCANNED STATUS'),
ExportColumn::make('upload_status')
->label('UPLOAD STATUS'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('scanned_by')
->label('SCANNED BY'),
ExportColumn::make('scanned_at')
->label('SCANNED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your locator invoice validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -13,25 +13,30 @@ class MachineExporter extends Exporter
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('No')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('Plant'),
->label('PLANT'),
ExportColumn::make('line.name')
->label('Line'),
->label('LINE'),
ExportColumn::make('name')
->label('Name'),
->label('MACHINE'),
ExportColumn::make('work_center')
->label('WORK CENTER'),
ExportColumn::make('created_at')
->label('Created At'),
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('Updated At'),
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('Deleted At'),
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Filament\Exports;
use App\Models\MfmMeter;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class MfmMeterExporter extends Exporter
{
protected static ?string $model = MfmMeter::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('device.name')
->label('DEVICE NAME'),
ExportColumn::make('sequence')
->label('SEQUENCE'),
ExportColumn::make('name')
->label('NAME'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
ExportColumn::make('created_by')
->label('CREATED BY'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your mfm meter export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Filament\Exports;
use App\Models\MfmParameter;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class MfmParameterExporter extends Exporter
{
protected static ?string $model = MfmParameter::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('deviceName.name')
->label('Device Name'),
ExportColumn::make('name')
->label('NAME'),
ExportColumn::make('mfmMeter.name')
->label('MFM METER'),
ExportColumn::make('register_id')
->label('REGISTER ID'),
ExportColumn::make('identifier')
->label('IDENTIFIER'),
ExportColumn::make('byte_to_convert')
->label('BYTE TO CONVERT'),
ExportColumn::make('type_to_convert')
->label('TYPE TO CONVERT'),
ExportColumn::make('decimal_to_display')
->label('DECIMAL TO DISPLAY'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your mfm parameter export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,92 @@
<?php
namespace App\Filament\Exports;
use App\Models\MfmReading;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class MfmReadingExporter extends Exporter
{
protected static ?string $model = MfmReading::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('mfmMeter.name')
->label('MFM METER NAME'),
ExportColumn::make('apparent_energy_received')
->label('APPARENT ENERGY RECEIVED'),
ExportColumn::make('reactive_energy_received')
->label('REACTIVE ENERGY RECEIVED'),
ExportColumn::make('active_energy_received')
->label('ACTIVE ENERGY RECEIVED'),
ExportColumn::make('active_power_r')
->label('ACTIVE POWER R'),
ExportColumn::make('active_power_y')
->label('ACTIVE POWER Y'),
ExportColumn::make('active_power_b')
->label('ACTIVE POWER B'),
ExportColumn::make('active_power_total')
->label('ACTIVE POWER TOTAL'),
ExportColumn::make('voltage_ry')
->label('VOLTAGE RY'),
ExportColumn::make('voltage_yb')
->label('VOLTAGE YB'),
ExportColumn::make('voltage_br')
->label('VOLTAGE BR'),
ExportColumn::make('current_r')
->label('CURRENT R'),
ExportColumn::make('current_y')
->label('CURRENT Y'),
ExportColumn::make('current_b')
->label('CURRENT B'),
ExportColumn::make('current_n')
->label('CURRENT N'),
ExportColumn::make('voltage_r_n')
->label('VOLTAGE R N'),
ExportColumn::make('voltage_y_n')
->label('VOLTAGE Y N'),
ExportColumn::make('voltage_b_n')
->label('VOLTAGE B N'),
ExportColumn::make('frequency')
->label('FREQUENCY'),
ExportColumn::make('power_factor_r')
->label('POWER FACTOR R'),
ExportColumn::make('power_factor_y')
->label('POWER FACTOR Y'),
ExportColumn::make('power_factor_b')
->label('POWER FACTOR B'),
ExportColumn::make('power_factor_total')
->label('POWER FACTOR TOTAL'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your mfm reading export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -13,85 +13,92 @@ class MotorTestingMasterExporter extends Exporter
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('No')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('Plant'),
->label('PLANT'),
ExportColumn::make('item.category')
->label('CATEGORY'),
ExportColumn::make('item.code')
->label('Item Code'),
->label('ITEM CODE'),
ExportColumn::make('item.description')
->label('DESCRIPTION'),
ExportColumn::make('isi_model')
->label('ISI Model'),
->label('ISI MODEL'),
ExportColumn::make('phase')
->label('Phase'),
->label('PHASE'),
ExportColumn::make('hp')
->label('HP'),
ExportColumn::make('kw')
->label('KW'),
ExportColumn::make('volt')
->label('Volt'),
->label('VOLT'),
ExportColumn::make('current')
->label('Current'),
->label('CURRENT'),
ExportColumn::make('rpm')
->label('RPM'),
ExportColumn::make('torque')
->label('Torque'),
->label('TORQUE'),
ExportColumn::make('frequency')
->label('Frequency'),
->label('FREQUENCY'),
ExportColumn::make('connection')
->label('Connection'),
->label('CONNECTION'),
ExportColumn::make('ins_res_limit')
->label('Insulation Resistance Limit'),
->label('INSULATION RESISTANCE LIMIT'),
ExportColumn::make('ins_res_type')
->label('Insulation Resistance Type'),
->label('INSULATION RESISTANCE TYPE'),
ExportColumn::make('routine_test_time')
->label('Routine Test Time'),
->label('ROUTINE TEST TIME'),
ExportColumn::make('res_ry_ll')
->label('Resistance RY LL'),
->label('RESISTANCE RY LL'),
ExportColumn::make('res_ry_ul')
->label('Resistance RY UL'),
->label('RESISTANCE RY UL'),
ExportColumn::make('res_yb_ll')
->label('Resistance YB LL'),
->label('RESISTANCE YB LL'),
ExportColumn::make('res_yb_ul')
->label('Resistance YB UL'),
->label('RESISTANCE YB UL'),
ExportColumn::make('res_br_ll')
->label('Resistance BR LL'),
->label('RESISTANCE BR LL'),
ExportColumn::make('res_br_ul')
->label('Resistance BR UL'),
->label('RESISTANCE BR UL'),
ExportColumn::make('lock_volt_limit')
->label('Lock Volt Limit'),
->label('LOCK VOLT Limit'),
ExportColumn::make('leak_cur_limit')
->label('Leak Current Limit'),
->label('Leak CURRENT Limit'),
ExportColumn::make('lock_cur_ll')
->label('Lock Current LL'),
->label('LOCK CURRENT LL'),
ExportColumn::make('lock_cur_ul')
->label('Lock Current UL'),
->label('LOCK CURRENT UL'),
ExportColumn::make('noload_cur_ll')
->label('No Load Current LL'),
->label('NO LOAD CURRENT LL'),
ExportColumn::make('noload_cur_ul')
->label('No Load Current UL'),
->label('NO LOAD CURRENT UL'),
ExportColumn::make('noload_pow_ll')
->label('No Load Power LL'),
->label('NO LOAD POWER LL'),
ExportColumn::make('noload_pow_ul')
->label('No Load Power UL'),
->label('NO LOAD POWER UL'),
ExportColumn::make('noload_spd_ll')
->label('No Load Speed LL'),
->label('NO LOAD SPEED LL'),
ExportColumn::make('noload_spd_ul')
->label('No Load Speed UL'),
->label('NO LOAD SPEED UL'),
ExportColumn::make('created_at')
->label('Created At'),
ExportColumn::make('updated_at')
->label('Updated At'),
ExportColumn::make('deleted_at')
->label('Deleted At'),
->label('CREATED AT'),
ExportColumn::make('created_by')
->label('Created By'),
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('updated_by')
->label('Updated By'),
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -0,0 +1,67 @@
<?php
namespace App\Filament\Exports;
use App\Models\PalletValidation;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class PalletValidationExporter extends Exporter
{
protected static ?string $model = PalletValidation::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('pallet_number')
->label('PALLET NUMBER'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('pallet_status')
->label('PALLET STATUS'),
ExportColumn::make('locator_number')
->label('LOCATOR NUMBER'),
ExportColumn::make('locator_quantity')
->label('LOCATOR QUANTITY'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('scanned_by')
->label('SCANNED BY'),
ExportColumn::make('scanned_at')
->label('SCANNED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your pallet validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -38,10 +38,14 @@ class ProductionLineStopExporter extends Exporter
->label('STOP MINUTE'),
ExportColumn::make('line.name')
->label('LINE'),
ExportColumn::make('shift.block.name')
->label('BLOCK'),
ExportColumn::make('shift.name')
->label('SHIFT'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
@@ -49,8 +53,6 @@ class ProductionLineStopExporter extends Exporter
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
];
}

View File

@@ -30,10 +30,14 @@ class ProductionPlanExporter extends Exporter
->label('PRODUCTION QUANTITY'),
ExportColumn::make('line.name')
->label('LINE'),
ExportColumn::make('shift.block.name')
->label('BLOCK'),
ExportColumn::make('shift.name')
->label('SHIFT'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
@@ -41,8 +45,6 @@ class ProductionPlanExporter extends Exporter
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
];
}

View File

@@ -34,6 +34,8 @@ class ProductionQuantityExporter extends Exporter
->label('UNIT OF MEASURE'),
ExportColumn::make('line.name')
->label('LINE'),
ExportColumn::make('shift.block.name')
->label('BLOCK'),
ExportColumn::make('shift.name')
->label('SHIFT'),
ExportColumn::make('plant.name')
@@ -42,15 +44,15 @@ class ProductionQuantityExporter extends Exporter
->label('SAP MESSAGE STATUS'),
ExportColumn::make('sap_msg_description')
->label('SAP MESSAGE DESCRIPTION'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -76,6 +76,8 @@ class QualityValidationExporter extends Exporter
->label('SAP MESSAGE STATUS'),
ExportColumn::make('sap_msg_description')
->label('SAP MESSAGE DESCRIPTION'),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
@@ -83,8 +85,6 @@ class QualityValidationExporter extends Exporter
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
ExportColumn::make('operator_id')
->label('OPERATOR ID'),
];
}

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Filament\Exports;
use App\Models\ReworkLocatorInvoiceValidation;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class ReworkLocatorInvoiceValidationExporter extends Exporter
{
protected static ?string $model = ReworkLocatorInvoiceValidation::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('invoice_number')
->label('INVOICE NUMBER'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('pallet_number')
->label('PALLET NUMBER'),
ExportColumn::make('locator_number')
->label('LOCATOR NUMBER'),
ExportColumn::make('scanned_status')
->label('SCANNED STATUS'),
ExportColumn::make('upload_status')
->label('UPLOAD STATUS'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('scanned_by')
->label('SCANNED BY'),
ExportColumn::make('scanned_at')
->label('SCANNED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('reworked_by')
->label('REWORKED BY'),
ExportColumn::make('reworked_at')
->label('REWORKED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your rework locator invoice validation export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -64,14 +64,18 @@ class StickerMasterExporter extends Exporter
->label('PART VALIDATION 4'),
ExportColumn::make('part_validation5')
->label('PART VALIDATION 5'),
ExportColumn::make('laser_part_validation1')
->label('LASER PART VALIDATION 1'),
ExportColumn::make('laser_part_validation2')
->label('LASER PART VALIDATION 2'),
ExportColumn::make('panel_box_code')
->label('PANEL BOX CODE'),
ExportColumn::make('load_rate')
->label('LOAD RATE'),
ExportColumn::make('bundle_quantity')
->label('BUNDLE QUANTITY'),
ExportColumn::make('material_type')
->label('MATERIAL TYPE'),
ExportColumn::make('bundle_quantity')
->label('BUNDLE QUANTITY'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Filament\Exports;
use App\Models\TempLiveReading;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class TempLiveReadingExporter extends Exporter
{
protected static ?string $model = TempLiveReading::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('mfmMeter.name')
->label('MFM METER NAME'),
ExportColumn::make('register_data')
->label('REGISTER DATA'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
ExportColumn::make('created_by')
->label('CREATED BY'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your temp live reading export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -13,62 +13,132 @@ class TestingPanelReadingExporter extends Exporter
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('plant.name'),
ExportColumn::make('line.name'),
ExportColumn::make('item.id'),
ExportColumn::make('machine.name'),
ExportColumn::make('output'),
ExportColumn::make('serial_number'),
ExportColumn::make('before_fr_volt'),
ExportColumn::make('before_fr_cur'),
ExportColumn::make('before_fr_pow'),
ExportColumn::make('before_fr_res_ry'),
ExportColumn::make('before_fr_res_yb'),
ExportColumn::make('before_fr_res_br'),
ExportColumn::make('before_fr_ir'),
ExportColumn::make('before_fr_ir_r'),
ExportColumn::make('before_fr_ir_y'),
ExportColumn::make('before_fr_ir_b'),
ExportColumn::make('before_fr_freq'),
ExportColumn::make('before_fr_speed'),
ExportColumn::make('after_fr_vol'),
ExportColumn::make('after_fr_cur'),
ExportColumn::make('after_fr_pow'),
ExportColumn::make('after_fr_ir_hot'),
ExportColumn::make('after_fr_ir_hot_r'),
ExportColumn::make('after_fr_ir_hot_y'),
ExportColumn::make('after_fr_ir_hot_b'),
ExportColumn::make('after_fr_ir_cool'),
ExportColumn::make('after_fr_ir_cool_r'),
ExportColumn::make('after_fr_ir_cool_y'),
ExportColumn::make('after_fr_ir_cool_b'),
ExportColumn::make('after_fr_freq'),
ExportColumn::make('after_fr_speed'),
ExportColumn::make('after_fr_leak_cur'),
ExportColumn::make('locked_rt_volt'),
ExportColumn::make('locked_rt_cur'),
ExportColumn::make('locked_rt_pow'),
ExportColumn::make('no_load_pickup_volt'),
ExportColumn::make('room_temperature'),
ExportColumn::make('hv_test'),
ExportColumn::make('batch_number'),
ExportColumn::make('batch_count'),
ExportColumn::make('result'),
ExportColumn::make('remark'),
ExportColumn::make('rework_count'),
ExportColumn::make('update_count'),
ExportColumn::make('output_flag'),
ExportColumn::make('pds_status'),
ExportColumn::make('pds_description'),
ExportColumn::make('tested_by'),
ExportColumn::make('updated_by'),
ExportColumn::make('created_at'),
ExportColumn::make('updated_at'),
ExportColumn::make('scanned_at'),
ExportColumn::make('deleted_at'),
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('line.name')
->label('LINE'),
ExportColumn::make('machine.name')
->label('MACHINE'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('item.description')
->label('MODEL'),
ExportColumn::make('output')
->label('OUTPUT'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('item.kw')
->label('KW'),
ExportColumn::make('item.hp')
->label('HP'),
ExportColumn::make('item.phase')
->label('PHASE'),
ExportColumn::make('item.connection')
->label('CONNECTION'),
ExportColumn::make('item.isi_model')
->label('ISI MODEL'),
ExportColumn::make('before_fr_volt')
->label('BEFORE FR VOLT'),
ExportColumn::make('before_fr_cur')
->label('BEFORE FR CURRENT'),
ExportColumn::make('before_fr_pow')
->label('BEFORE FR POWER'),
ExportColumn::make('before_fr_res_ry')
->label('BEFORE FR RESISTANCE RY'),
ExportColumn::make('before_fr_res_yb')
->label('BEFORE FR RESISTANCE YB'),
ExportColumn::make('before_fr_res_br')
->label('BEFORE FR RESISTANCE BR'),
ExportColumn::make('before_fr_ir')
->label('BEFORE FR IR'),
ExportColumn::make('before_fr_ir_r')
->label('BEFORE FR IR R'),
ExportColumn::make('before_fr_ir_y')
->label('BEFORE FR IR Y'),
ExportColumn::make('before_fr_ir_b')
->label('BEFORE FR IR B'),
ExportColumn::make('before_fr_freq')
->label('BEFORE FR FREQUENCY'),
ExportColumn::make('before_fr_speed')
->label('BEFORE FR SPEED'),
ExportColumn::make('after_fr_vol')
->label('AFTER FR VOLT'),
ExportColumn::make('after_fr_cur')
->label('AFTER FR CURRENT'),
ExportColumn::make('after_fr_pow')
->label('AFTER FR POWER'),
ExportColumn::make('after_fr_ir_hot')
->label('AFTER FR IR HOT'),
ExportColumn::make('after_fr_ir_hot_r')
->label('AFTER FR IR HOT R'),
ExportColumn::make('after_fr_ir_hot_y')
->label('AFTER FR IR HOT Y'),
ExportColumn::make('after_fr_ir_hot_b')
->label('AFTER FR IR HOT B'),
ExportColumn::make('after_fr_ir_cool')
->label('AFTER FR IR COOL'),
ExportColumn::make('after_fr_ir_cool_r')
->label('AFTER FR IR COOL R'),
ExportColumn::make('after_fr_ir_cool_y')
->label('AFTER FR IR COOL Y'),
ExportColumn::make('after_fr_ir_cool_b')
->label('AFTER FR IR COOL B'),
ExportColumn::make('after_fr_freq')
->label('AFTER FR FREQUENCY'),
ExportColumn::make('after_fr_speed')
->label('AFTER FR SPEED'),
ExportColumn::make('after_fr_leak_cur')
->label('AFTER FR LEAK CURRENT'),
ExportColumn::make('locked_rt_volt')
->label('LOCKED RT VOLT'),
ExportColumn::make('locked_rt_cur')
->label('LOCKED RT CURRENT'),
ExportColumn::make('locked_rt_pow')
->label('LOCKED RT POWER'),
ExportColumn::make('no_load_pickup_volt')
->label('NO LOAD PICKUP VOLT'),
ExportColumn::make('room_temperature')
->label('ROOM TEMPERATURE'),
ExportColumn::make('hv_test')
->label('HIGH VOLTAGE TEST'),
ExportColumn::make('batch_number')
->label('BATCH NUMBER'),
ExportColumn::make('batch_count')
->label('BATCH COUNT'),
ExportColumn::make('result')
->label('RESULT'),
ExportColumn::make('remark')
->label('REMARK'),
ExportColumn::make('rework_count')
->label('REWORK COUNT'),
ExportColumn::make('update_count')
->label('UPDATE COUNT'),
ExportColumn::make('output_flag')
->label('OUTPUT FLAG'),
ExportColumn::make('tested_by')
->label('TESTED BY'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('scanned_at')
->label('SCANNED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -0,0 +1,87 @@
<?php
namespace App\Filament\Imports;
use App\Models\CheckPointName;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class CheckPointNameImporter extends Importer
{
protected static ?string $model = CheckPointName::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Check Point Name')
->example('STP BACKSIDE')
->label('Check Point Name')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example(Filament::auth()->user()->name ?? 'Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?CheckPointName
{
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
}
if (Str::length($this->data['name']) < 3) { // || !ctype_alnum($this->data['name'])
$warnMsg[] = "Invalid check point name found";
}
$createdBy = $this->data['created_by'];
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
$warnMsg[] = "Invalid created by name found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return CheckPointName::updateOrCreate([
'name' => $this->data['name'],
'plant_id' => $plant->id
],
[
'created_by' => $this->data['created_by']
]
);
// // return CheckPointName::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new CheckPointName();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your check point name import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,153 @@
<?php
namespace App\Filament\Imports;
use App\Models\CheckPointName;
use App\Models\CheckPointTime;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class CheckPointTimeImporter extends Importer
{
protected static ?string $model = CheckPointTime::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('checkPointNames1')
->requiredMapping()
->exampleHeader('Check Point 1')
->example('STP BACKSIDE')
->label('Check Point 1')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('checkPointNames2')
->requiredMapping()
->exampleHeader('Check Point 2')
->example('CANTEEN')
->label('Check Point 2')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('sequence_number')
->requiredMapping()
->exampleHeader('Sequence Number')
->example('1')
->label('Sequence Number')
->integer()
->rules(['required']),
ImportColumn::make('time_lapse')
->requiredMapping()
->exampleHeader('Time Lapse')
->example('1')
->label('Time Lapse')
->integer()
->rules(['required']),
ImportColumn::make('time_lapse_cushioning')
->requiredMapping()
->exampleHeader('Time Lapse Cushioning')
->example('1')
->label('Time Lapse Cushioning')
->integer()
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example(Filament::auth()->user()->name ?? 'Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?CheckPointTime
{
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
$checkPointNames1 = null;
$checkPointNames2 = null;
if (!$plant) {
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
}
else
{
$checkPointNames1 = CheckPointName::where('name', $this->data['checkPointNames1'])->first();
if (!$checkPointNames1) {
$warnMsg[] = "Check point 1 not found";
}
else
{
$checkPointNames2 = CheckPointName::where('name', $this->data['checkPointNames2'])->first();
if (!$checkPointNames2) {
$warnMsg[] = "Check point 2 not found";
}
else
{
if ($checkPointNames1->id === $checkPointNames2->id) {
$warnMsg[] = "Check point 1 and 2 can't be the same";
}
}
}
}
if (Str::length($this->data['sequence_number']) < 1 || !is_numeric($this->data['sequence_number']) || $this->data['sequence_number'] <= 0) {
$warnMsg[] = "Invalid sequence number found";
}
if (Str::length($this->data['time_lapse']) < 1 || !is_numeric($this->data['time_lapse']) || $this->data['time_lapse'] <= 0) {
$warnMsg[] = "Invalid time lapse found";
}
if (Str::length($this->data['time_lapse_cushioning']) < 1 || !is_numeric($this->data['time_lapse_cushioning']) || $this->data['time_lapse_cushioning'] <= 0) {
$warnMsg[] = "Invalid time lapse cushioning found";
}
$createdBy = $this->data['created_by'];
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
$warnMsg[] = "Invalid created by name found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return CheckPointTime::updateOrCreate([
'plant_id' => $plant->id,
'check_point1_id' => $checkPointNames1->id,
'check_point2_id' => $checkPointNames2->id,
'sequence_number' => $this->data['sequence_number']
],
[
'time_lapse' => $this->data['time_lapse'],
'time_lapse_cushioning' => $this->data['time_lapse_cushioning'],
'created_by' => $this->data['created_by']
]
);
// // return CheckPointTime::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new CheckPointTime();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your check point time import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -14,20 +14,6 @@ class ConfigurationImporter extends Importer
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->example(['Ransar Industries-I'])
->label('Plant')
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->example(['4 inch pump line'])
->label('Line')
->rules(['required']),
ImportColumn::make('c_type')
->requiredMapping()
->exampleHeader('Type')
@@ -52,6 +38,20 @@ class ConfigurationImporter extends Importer
->example(['Single'])
->label('Value')
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->example(['4 inch pump line'])
->label('Line')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->example(['Ransar Industries-I'])
->label('Plant')
->rules(['required']),
];
}

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Filament\Imports;
use App\Models\DeviceMaster;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class DeviceMasterImporter extends Importer
{
protected static ?string $model = DeviceMaster::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Device Name')
->label('Device Name')
->rules(['required']),
ImportColumn::make('mac_address')
->requiredMapping()
->exampleHeader('MAC Address')
->example('00:1A:2B:3C:4D:5E')
->label('MAC Address')
->rules(['required', 'mac_address']),
ImportColumn::make('ip_address')
->requiredMapping()
->exampleHeader('IP Address')
->label('IP Address')
->example('172.31.76.67')
->rules(['required', 'ip']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?DeviceMaster
{
// return DeviceMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new DeviceMaster();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your device master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,243 @@
<?php
namespace App\Filament\Imports;
use App\Models\EbReading;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class EbReadingImporter extends Importer
{
protected static ?string $model = EbReading::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('lcd_segment_check')
->label('LCD Segment Check')
->example('Ok')
->exampleHeader('LCD Segment Check'),
ImportColumn::make('meter_serial_no')
->label('Meter Serial No')
->example('572880')
->exampleHeader('Meter Serial No'),
ImportColumn::make('eb_date_time')
->label('EB Date Time')
->example('2025-08-05 08:32:58')
->exampleHeader('EB Date Time')
->requiredMapping()
->rules(['required', 'datetime']),
ImportColumn::make('ph_seq_of_volt')
->label('Phase Sequence of Volt')
->example('RYB')
->exampleHeader('Phase Sequence of Volt'),
ImportColumn::make('ph_assoc_conn_check')
->example('GOOD')
->exampleHeader('Phase Associated Connection Check')
->label('Phase Associated Connection Check'),
ImportColumn::make('instantaneous_ph_volt')
->exampleHeader('Instantaneous Phase Volt')
->example('64.35,64.91,64.93')
->label('Instantaneous Phase Volt'),
ImportColumn::make('instantaneous_curr')
->exampleHeader('Instantaneous Current')
->example('1.02,1.00,0.94')
->label('Instantaneous Current'),
ImportColumn::make('instantaneous_freq')
->exampleHeader('Instantaneous Frequency')
->example('50.07')
->label('Instantaneous Frequency'),
ImportColumn::make('instantaneous_kw_with_sign')
->exampleHeader('Instantaneous KW with Sign')
->example('0.176')
->label('Instantaneous KW with Sign'),
ImportColumn::make('instantaneous_kva')
->exampleHeader('Instantaneous KVA')
->example('0.176')
->label('Instantaneous KVA'),
ImportColumn::make('instantaneous_kv_ar')
->exampleHeader('Instantaneous KV AR')
->example('0.02')
->label('Instantaneous KV AR'),
ImportColumn::make('instantaneous_pf_with_sign')
->exampleHeader('Instantaneous PF with Sign')
->example('0.99')
->label('Instantaneous PF with Sign'),
ImportColumn::make('rd_with_elapsed_time_kva')
->exampleHeader('RD with Elapsed Time KVA')
->example('0.047')
->label('RD with Elapsed Time KVA'),
ImportColumn::make('cum_active_import_energy')
->exampleHeader('Cumulative Active Import Energy')
->example('13246.46')
->label('Cumulative Active Import Energy'),
ImportColumn::make('tod1_active_energy_6_9')
->exampleHeader('TOD1 Active Energy 6-9')
->example('1367.75')
->label('TOD1 Active Energy 6-9'),
ImportColumn::make('tod2_active_energy_18_21')
->exampleHeader('TOD2 Active Energy 18-21')
->example('1759.08')
->label('TOD2 Active Energy 18-21'),
ImportColumn::make('tod3_active_energy_21_22')
->exampleHeader('TOD3 Active Energy 21-22')
->example('457.67')
->label('TOD3 Active Energy 21-22'),
ImportColumn::make('tod4_active_energy_5_6_9_18')
->exampleHeader('TOD4 Active Energy 5-6-9-18')
->example('6253.85')
->label('TOD4 Active Energy 5-6-9-18'),
ImportColumn::make('tod5_active_energy_22_5')
->exampleHeader('TOD5 Active Energy 22-5')
->example('3408.11')
->label('TOD5 Active Energy 22-5'),
ImportColumn::make('cum_reac_lag_energy')
->exampleHeader('Cumulative Reactive Lag Energy')
->example('685.11')
->label('Cumulative Reactive Lag Energy'),
ImportColumn::make('cum_reac_lead_energy')
->exampleHeader('Cumulative Reactive Lead Energy')
->example('426.1')
->label('Cumulative Reactive Lead Energy'),
ImportColumn::make('cum_appar_energy')
->exampleHeader('Cumulative Apparent Energy')
->example('13306.57')
->label('Cumulative Apparent Energy'),
ImportColumn::make('tod1_appar_energy_6_9')
->exampleHeader('TOD1 Apparent Energy 6-9')
->example('1374.63')
->label('TOD1 Apparent Energy 6-9'),
ImportColumn::make('tod2_appar_energy_18_21')
->exampleHeader('TOD2 Apparent Energy 18-21')
->example('1766.61')
->label('TOD2 Apparent Energy 18-21'),
ImportColumn::make('tod3_appar_energy_21_22')
->exampleHeader('TOD3 Apparent Energy 21-22')
->example('459.47')
->label('TOD3 Apparent Energy 21-22'),
ImportColumn::make('tod4_appar_energy_5_6_9_18')
->exampleHeader('TOD4 Apparent Energy 5-6-9-18')
->example('6283.28')
->label('TOD4 Apparent Energy 5-6-9-18'),
ImportColumn::make('tod5_appar_energy_22_5')
->exampleHeader('TOD5 Apparent Energy 22-5')
->example('3422.56')
->label('TOD5 Apparent Energy 22-5'),
ImportColumn::make('avg_pow_factor')
->exampleHeader('Average Power Factor')
->example('0.98')
->label('Average Power Factor'),
ImportColumn::make('avg_freq_15min_last_ip')
->exampleHeader('Average Frequency 15min Last IP')
->example('50')
->label('Average Frequency 15min Last IP'),
ImportColumn::make('net_kv_arh_high')
->exampleHeader('Net KV ARH High')
->example('2.99')
->label('Net KV ARH High'),
ImportColumn::make('net_kv_arh_low')
->exampleHeader('Net KV ARH Low')
->example('143.14')
->label('Net KV ARH Low'),
ImportColumn::make('cum_md_kva')
->exampleHeader('Cumulative MD KVA')
->example('43.816')
->label('Cumulative MD KVA'),
ImportColumn::make('present_md_kva')
->exampleHeader('Present MD KVA')
->example('0.379')
->label('Present MD KVA'),
ImportColumn::make('present_md_kva_date_time')
->label('Present MD KVA Date Time')
->exampleHeader('Present MD KVA Date Time')
->example('2025-08-05 08:32:58')
->requiredMapping()
->rules(['required', 'datetime']),
ImportColumn::make('tod1_md_kva_6_9')
->exampleHeader('TOD1 MD KVA 6-9')
->example('0.282')
->label('TOD1 MD KVA 6-9'),
ImportColumn::make('tod2_md_kva_18_21')
->exampleHeader('TOD2 MD KVA 18-21')
->example('0.268')
->label('TOD2 MD KVA 18-21'),
ImportColumn::make('tod3_md_kva_21_22')
->exampleHeader('TOD3 MD KVA 21-22')
->example('0')
->label('TOD3 MD KVA 21-22'),
ImportColumn::make('tod4_md_kva_5_6_9_18')
->exampleHeader('TOD4 MD KVA 5-6-9-18')
->example('0.379')
->label('TOD4 MD KVA 5-6-9-18'),
ImportColumn::make('tod5_md_kva_22_5')
->exampleHeader('TOD5 MD KVA 22-5')
->example('0.379')
->label('TOD5 MD KVA 22-5'),
ImportColumn::make('total_pow_off_hours')
->exampleHeader('Total Power Off Hours')
->example('6480.56')
->label('Total Power Off Hours'),
ImportColumn::make('programming_count')
->exampleHeader('Programming Count')
->example('3')
->label('Programming Count'),
ImportColumn::make('last_occ_res_event_type')
->exampleHeader('Last Occurrence/Reset Event Type')
->example('-')
->label('Last Occurrence/Reset Event Type'),
ImportColumn::make('last_occ_res_event_date_time')
->label('Last Occurrence/Reset Event Date Time')
->example('2025-08-05 08:32:58')
->exampleHeader('Last Occurrence/Reset Event Date Time')
->requiredMapping()
->rules(['required', 'datetime']),
ImportColumn::make('tamper_count')
->exampleHeader('Tamper Count')
->example('24')
->label('Tamper Count'),
ImportColumn::make('reset_count')
->exampleHeader('Reset Count')
->example('108')
->label('Reset Count'),
ImportColumn::make('last_md_reset_date_time')
->exampleHeader('Last MD Reset Date Time')
->example('2025-08-05 08:32:58')
->label('Last MD Reset Date Time')
->requiredMapping()
->rules(['required', 'datetime']),
ImportColumn::make('electrician_sign')
->exampleHeader('Electrician Sign')
->example('Admin')
->label('Electrician Sign'),
];
}
public function resolveRecord(): ?EbReading
{
// return EbReading::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new EbReading();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your eb reading import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Filament\Imports;
use App\Models\GuardName;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class GuardNameImporter extends Importer
{
protected static ?string $model = GuardName::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Guard Name')
->example('Shivaram')
->label('Guard Name')
->rules(['required']),
ImportColumn::make('identification1')
->requiredMapping()
->exampleHeader('Identification 1')
->example('1234567890123456')
->label('Identification 1')
->rules(['required']),
ImportColumn::make('identification2')
->requiredMapping()
->exampleHeader('Identification 2')
->example('')
->label('Identification 2'),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example(Filament::auth()->user()->name ?? 'Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?GuardName
{
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
}
if (Str::length($this->data['name']) < 3) { // || !ctype_alnum($this->data['name'])
$warnMsg[] = "Invalid guard name found";
}
if (Str::length($this->data['identification1']) < 5) {
$warnMsg[] = "Invalid identification-1 found";
}
$createdBy = $this->data['created_by'];
if (Str::length($createdBy) < 3) { // || !ctype_alnum($createdBy)
$warnMsg[] = "Invalid created by name found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return GuardName::updateOrCreate([
'name' => $this->data['name'],
'plant_id' => $plant->id
],
[
'identification1' => $this->data['identification1'],
'identification2' => $this->data['identification2'],
'created_by' => $this->data['created_by']
]
);
// // return GuardName::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
//return new GuardName();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your guard name import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,160 @@
<?php
namespace App\Filament\Imports;
use App\Models\CheckPointName;
use App\Models\GuardName;
use App\Models\GuardPatrolEntry;
use App\Models\Plant;
use Carbon\Carbon;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class GuardPatrolEntryImporter extends Importer
{
protected static ?string $model = GuardPatrolEntry::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('guardNames')
->requiredMapping()
->exampleHeader('Guard Name')
->example('ARUMUGAM - HG')
->label('Guard Name')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('checkPointNames')
->requiredMapping()
->exampleHeader('Check Point Name')
->example('STP BACKSIDE')
->label('Check Point Name')
->relationship(resolveUsing: 'name')
->rules(['required']),
// ImportColumn::make('reader_code')
// ->requiredMapping()
// ->exampleHeader('Reader Code')
// ->example('0C03-25010112')
// ->label('Reader Code'),
ImportColumn::make('patrol_time')
->requiredMapping()
->exampleHeader('Patrol Time')
->example('01-01-2025 08:00:00')
->label('Patrol Time')
->rules(['required']),
// ImportColumn::make('created_by')
// ->requiredMapping()
// ->exampleHeader('Created By')
// ->example(Filament::auth()->user()->name ?? 'Admin')
// ->label('Created By')
// ->rules(['required']),
// ImportColumn::make('updated_by')
// ->requiredMapping()
// ->rules(['required']),
];
}
public function resolveRecord(): ?GuardPatrolEntry
{
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
$guardNames = null;
$checkPointNames = null;
$patrolDateTime = null; //$fdateTime = null;
if (!$plant) {
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
}
else
{
$guardNames = GuardName::where('plant_id', $plant->id)->where('name', $this->data['guardNames'])->first();
if (!$guardNames) {
$warnMsg[] = "Guard name not found";
}
else
{
$checkPointNames = CheckPointName::where('plant_id', $plant->id)->where('name', $this->data['checkPointNames'])->first();
if (!$checkPointNames) {
$warnMsg[] = "Check point name not found";
}
else
{
$patrolTime = $this->data['patrol_time'];//$fromDate = $this->data['from_datetime'];
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
foreach ($formats as $format) {
try {
$patrolDateTime = Carbon::createFromFormat($format, $patrolTime);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($patrolDateTime)) {
// throw new \Exception('Invalid date time format');
$warnMsg[] = "Invalid 'Patrol DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
else
{
$guardEntryFound = GuardPatrolEntry::where('plant_id', $plant->id)->where('guard_name_id', $guardNames->id)->where('check_point_name_id', $checkPointNames->id)->where('patrol_time', $patrolDateTime->format('Y-m-d H:i:s'))->first();
if ($guardEntryFound) {
$warnMsg[] = "Duplicate guard patrol entry found";
}
}
}
}
}
$createdBy = Filament::auth()->user()->name;// ?? 'Admin'
if (!$createdBy) {
$warnMsg[] = "Invalid created by name found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
GuardPatrolEntry::updateOrCreate([
'plant_id' => $plant->id,
'guard_name_id' => $guardNames->id,
'check_point_name_id' => $checkPointNames->id,
'patrol_time' => $patrolDateTime->format('Y-m-d H:i:s')
],
[
'reader_code' => null,
'created_by' => $createdBy,
'updated_by' => $createdBy
]
);
return null;
// // return GuardPatrolEntry::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new GuardPatrolEntry();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your guard patrol entry import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -59,17 +59,19 @@ class ItemImporter extends Importer
public function resolveRecord(): ?Item
{
$warnMsg = [];
$iCode = trim($this->data['code']);
$description = trim($this->data['description']);
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found"; // '" . $this->data['plant'] . "'
}
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
if (Str::length($iCode) < 6 || !ctype_alnum($iCode)) {
$warnMsg[] = "Invalid item code found";
}
// if (Str::length($this->data['uom']) <= 0) {
// $warnMsg[] = "Invalid unit of measure found";
// }
if (Str::length($this->data['description']) < 5) {
if (Str::length($description) < 5) {
$warnMsg[] = "Invalid description found";
}
if (Str::length($this->data['hourly_quantity']) < 0 || !is_numeric($this->data['hourly_quantity']) || $this->data['hourly_quantity'] <= 0) {
@@ -79,14 +81,14 @@ class ItemImporter extends Importer
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return Item::updateOrCreate([
'code' => $this->data['code'],
'code' => $iCode,
'plant_id' => $plant->id
],
[
'category' => $this->data['category'],
'description' => $this->data['description'],
'category' => trim($this->data['category']),
'description' => $description,
'hourly_quantity' => $this->data['hourly_quantity'],
'uom' => $this->data['uom']
'uom' => trim($this->data['uom'])
]
);
// return new Item;

View File

@@ -29,6 +29,11 @@ class LineImporter extends Importer
->example('Domestic Assembly')
->label('Line Type')
->rules(['required']),
ImportColumn::make('group_work_center')
->requiredMapping()
->exampleHeader('Group Work Center')
->example('RMGCEABC')
->label('Group Work Center'),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
@@ -60,7 +65,8 @@ class LineImporter extends Importer
'plant_id' => $plant->id
],
[
'type' => $this->data['type']
'type' => $this->data['type'],
'group_work_center' => $this->data['group_work_center']
]
);
// return Line::firstOrNew([

View File

@@ -0,0 +1,125 @@
<?php
namespace App\Filament\Imports;
use App\Models\Locator;
use App\Models\PalletValidation;
use App\Models\Plant;
use App\Models\User;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class LocatorImporter extends Importer
{
protected static ?string $model = Locator::class;
public static function getColumns(): array
{
return [
ImportColumn::make('locator_number')
->requiredMapping()
->exampleHeader('Locator Number')
->example(['W01-A1A'])
->label('Locator Number')
->rules(['required']),
ImportColumn::make('locator_quantity')
->requiredMapping()
->numeric()
->exampleHeader('Locator Quantity')
->example(['0'])
->label('Locator Quantity')
->rules(['required', 'integer']),
ImportColumn::make('operator_id')
->requiredMapping()
->exampleHeader('Operator ID')
->example(['Admin'])
->label('Operator ID')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->relationship(resolveUsing: 'code')
->exampleHeader('Plant Code')
->example(['1000'])
->label('Plant Code')
->rules(['required']),
];
}
public function resolveRecord(): ?Locator
{
$warnMsg = [];
$plantCod = $this->data['plant'];
$plant = null;
$user = null;
$locator = $this->data['locator_number'];
// $locatorQuantity = $this->data['locator_quantity'];
$palletQuantity = 0;
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = "Invalid plant code found";
}
else
{
$plant = Plant::where('code', $plantCod)->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
else
{
$user = Filament::auth()->user()->name;
if (Str::length($locator) < 7) {
$warnMsg[] = "Invalid locator number found";
}
else {
// $locat = Locator::where('name', $locator)->where('plant_id', $plant->id)->first();
$palletQuantity = PalletValidation::where('locator_number', $locator)->where('plant_id', $plant->id)->distinct('pallet_number')->count('pallet_number');
}
}
}
// if (Str::length($locatorQuantity) < 0 || !is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
// $warnMsg[] = "Invalid locator quantity found";
// }
// $user = User::where('name', $user)->first();
// if (!$user) {
// $warnMsg[] = "Operator ID not found";
// }
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
Locator::updateOrCreate(
[
'plant_id' => $plant->id,
'locator_number' => $locator
],
[
'locator_quantity' => $palletQuantity,
'operator_id' => $user
]
);
return null;
// // return Locator::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new Locator();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your locator import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,271 @@
<?php
namespace App\Filament\Imports;
use App\Models\LocatorInvoiceValidation;
use App\Models\Plant;
use App\Models\User;
use Carbon\Carbon;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class LocatorInvoiceValidationImporter extends Importer
{
protected static ?string $model = LocatorInvoiceValidation::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Code')
->example('1000')
->label('Plant Code')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('invoice_number')
->requiredMapping()
->exampleHeader('Invoice Number')
->example('3RA002514')
->label('Invoice Number')
->rules(['required']),
ImportColumn::make('serial_number')
->requiredMapping()
->exampleHeader('Serial Number')
->example('2514121551420')
->label('Serial Number')
->rules(['required']),
ImportColumn::make('pallet_number')
->requiredMapping()
->exampleHeader('Pallet Number')
->example('EP-2506001')
->label('Pallet Number'),
ImportColumn::make('locator_number')
->requiredMapping()
->exampleHeader('Locator Number')
->example('W05-D1B')
->label('Locator Number'),
ImportColumn::make('scanned_status')
->requiredMapping()
->exampleHeader('Scanned Status')
->example('')
->label('Scanned Status'),
ImportColumn::make('upload_status')
->requiredMapping()
->exampleHeader('Upload Status')
->example('Y')
->label('Upload Status'),
ImportColumn::make('created_at')
->requiredMapping()
->exampleHeader('Created At')
->example('2025-06-17 01:42:16')
->label('Created At')
->rules(['required']),
ImportColumn::make('scanned_at')
->requiredMapping()
->exampleHeader('Scanned At')
->example('2025-06-17 08:42:16')
->label('Scanned At'),
ImportColumn::make('updated_at')
->requiredMapping()
->exampleHeader('Updated At')
->example('2025-06-17 08:42:16')
->label('Updated At'),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created by')
->example('RAW012345')
->label('Created by')
->rules(['required']),
ImportColumn::make('scanned_by')
->requiredMapping()
->exampleHeader('Scanned by')
->example('RAW012345')
->label('Scanned by'),
ImportColumn::make('updated_by')
->requiredMapping()
->exampleHeader('Updated by')
->example('RAW012345')
->label('Updated by'),
];
}
public function resolveRecord(): ?LocatorInvoiceValidation
{
$warnMsg = [];
$plantCod = $this->data['plant'];
$plant = null;
$invoiceNo = $this->data['invoice_number'];
$serialNo = $this->data['serial_number'];
$palletNo = $this->data['pallet_number'];
$locatorNo = $this->data['locator_number'];
$scannedStat = $this->data['scanned_status'];
$uploadStat = $this->data['upload_status'];
$createdAt = $this->data['created_at'];
$scannedAt = $this->data['scanned_at'];
$updatedAt = $this->data['updated_at'];
$cDateTime = null;
$sDateTime = null;
$uDateTime = null;
$createdBy = $this->data['created_by'];
$scannedBy = $this->data['scanned_by'];
$updatedBy = $this->data['updated_by'];
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = "Invalid plant code found";
}
else
{
$plant = Plant::where('code', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
else
{
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
$warnMsg[] = "Invalid invoice number found";
}
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
$warnMsg[] = "Invalid serial number found";
}
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
$warnMsg[] = "Invalid pallet number found";
}
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
$warnMsg[] = "Invalid locator number found";
}
if (Str::length($scannedStat) > 0 && $scannedStat != 'Scanned') {
$warnMsg[] = "Invalid scanned status found";
}
if ($uploadStat != 'Y' && $uploadStat != 'N') {
$warnMsg[] = "Invalid upload status found";
}
$created = User::where('name', $createdBy)->first();
if (!$created) {
$warnMsg[] = "Created by not found";
}
if (Str::length($scannedBy) > 0) {
$scanned = User::where('name', $scannedBy)->first();
if (!$scanned) {
$warnMsg[] = "Scanned by not found";
}
}
if (Str::length($updatedBy) > 0) {
$updated = User::where('name', $updatedBy)->first();
if (!$updated) {
$warnMsg[] = "Updated by not found";
}
}
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
foreach ($formats as $format) {
try {
$cDateTime = Carbon::createFromFormat($format, $createdAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($cDateTime)) {
// throw new \Exception('Invalid date time format');
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
if (Str::length($scannedAt) > 0)
{
foreach ($formats as $format) {
try {
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($sDateTime)) {
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
}
if (Str::length($updatedAt) > 0)
{
foreach ($formats as $format) {
try {
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($uDateTime)) {
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
else
{
if (isset($cDateTime) && isset($uDateTime)) {
if ($cDateTime->greaterThan($uDateTime)) {
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
}
}
}
}
}
}
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
// $warnMsg[] = "Invalid locator quantity found";
// }
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
LocatorInvoiceValidation::updateOrCreate(
[
'plant_id' => $plant->id,
'serial_number' => $serialNo
],
[
'invoice_number' => $invoiceNo,
'pallet_number' => $palletNo,
'locator_number' => $locatorNo,
'scanned_status' => $scannedStat,
'upload_status' => $uploadStat,
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
'scanned_at' => (Str::length($scannedAt) > 0) ? $sDateTime->format('Y-m-d H:i:s') : null,
'updated_at' => (Str::length($updatedAt) > 0) ? $uDateTime->format('Y-m-d H:i:s') : null,
'created_by' => $createdBy,
'scanned_by' => $scannedBy,
'updated_by' => $updatedBy
]
);
return null;
// // return LocatorInvoiceValidation::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new LocatorInvoiceValidation();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your locator invoice validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -2,10 +2,14 @@
namespace App\Filament\Imports;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class MachineImporter extends Importer
{
@@ -14,13 +18,17 @@ class MachineImporter extends Importer
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
ImportColumn::make('name')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->example(['Ransar Industries-I'])
->label('Plant')
->exampleHeader('Machine')
->example(['1600251'])
->label('Machine')
->rules(['required']),
ImportColumn::make('work_center')
->requiredMapping()
->exampleHeader('Work Center')
->example('RMGCE001')
->label('Work Center'),
ImportColumn::make('line')
->requiredMapping()
->relationship(resolveUsing: 'name')
@@ -28,23 +36,66 @@ class MachineImporter extends Importer
->example(['4 inch pump line'])
->label('Line')
->rules(['required']),
ImportColumn::make('name')
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Name')
->example(['1600251'])
->label('Line')
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->example(['Ransar Industries-I'])
->label('Plant')
->rules(['required']),
];
}
public function resolveRecord(): ?Machine
{
// return Machine::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
$line = null;
$machine = $this->data['name'];
$workCenter = $this->data['work_center'];
if (!$plant) {
$warnMsg[] = "Plant not found";
}
else {
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
if ($line) {
$grpWrkCnr = $line->group_work_center;
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
{
$warnMsg[] = "Group work center line not found";
}
}
else
{
$warnMsg[] = "Line not found";
}
}
return new Machine();
if (Str::length($machine) <= 0) {
$warnMsg[] = "Machine name not found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
Machine::updateOrCreate(
[
'name' => $machine,
'plant_id' => $plant->id,
'line_id' => $line->id
],
[
'work_center' => $workCenter
]
);
return null;
// // return Machine::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new Machine();
}
public static function getCompletedNotificationBody(Import $import): string

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Filament\Imports;
use App\Models\MfmMeter;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class MfmMeterImporter extends Importer
{
protected static ?string $model = MfmMeter::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('devicemaster')
->requiredMapping()
->exampleHeader('Device Name')
->example('REG001')
->label('Device Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('sequence')
->requiredMapping()
->exampleHeader('Sequence')
->example('1')
->label('Sequence')
->rules(['required']),
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Meter Name')
->example('Display SSB')
->label('Meter Name')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?MfmMeter
{
// return MfmMeter::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new MfmMeter();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your mfm meter import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace App\Filament\Imports;
use App\Models\MfmParameter;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class MfmParameterImporter extends Importer
{
protected static ?string $model = MfmParameter::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('deviceName')
->requiredMapping()
->exampleHeader('Device Name')
->example('REG001')
->label('Device Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('mfmMeter')
->requiredMapping()
->exampleHeader('Mfm Meter Sequence')
->example('1')
->label('Mfm Meter Sequence')
->relationship(resolveUsing:'sequence')
->rules(['required']),
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Parameter Name')
->example('apparent_energy_received')
->label('Parameter Name')
->rules(['required']),
ImportColumn::make('register_id')
->requiredMapping()
->exampleHeader('Register ID')
->example('2715')
->label('Register ID')
->rules(['required']),
ImportColumn::make('identifier')
->requiredMapping()
->exampleHeader('Identifier')
->example('Kvah')
->label('Identifier')
->rules(['required']),
ImportColumn::make('byte_to_convert')
->requiredMapping()
->exampleHeader('Byte To Convert')
->example('1')
->label('Byte To Convert')
->rules(['required', 'integer']),
ImportColumn::make('type_to_convert')
->requiredMapping()
->exampleHeader('Type To Convert')
->example('FLOAT32')
->label('Type To Convert')
->rules(['required']),
ImportColumn::make('decimal_to_display')
->requiredMapping()
->exampleHeader('Decimal To Display')
->example('2')
->label('Decimal To Display')
->rules(['required', 'integer']),
];
}
public function resolveRecord(): ?MfmParameter
{
// return MfmParameter::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new MfmParameter();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your mfm parameter import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,186 @@
<?php
namespace App\Filament\Imports;
use App\Models\MfmReading;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class MfmReadingImporter extends Importer
{
protected static ?string $model = MfmReading::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('mfmMeter')
->requiredMapping()
->exampleHeader('Mfm Meter Name')
->example('Display SSB')
->label('Display SSB')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('apparent_energy_received')
->requiredMapping()
->exampleHeader('Apparent Energy Received')
->example('1084610')
->label('Apparent Energy Received')
->rules(['required']),
ImportColumn::make('reactive_energy_received')
->requiredMapping()
->exampleHeader('Reactive Energy Received')
->example('347496.9')
->label('Reactive Energy Received')
->rules(['required']),
ImportColumn::make('active_energy_received')
->requiredMapping()
->exampleHeader('Active Energy Received')
->example('611717.1')
->label('Active Energy Received')
->rules(['required']),
ImportColumn::make('active_power_r')
->requiredMapping()
->exampleHeader('Active Power R')
->example('3.974')
->label('Active Power R')
->rules(['required']),
ImportColumn::make('active_power_y')
->requiredMapping()
->exampleHeader('Active Power Y')
->example('0.796')
->label('Active Power Y')
->rules(['required']),
ImportColumn::make('active_power_b')
->requiredMapping()
->exampleHeader('Active Power B')
->example('1.397')
->label('Active Power B')
->rules(['required']),
ImportColumn::make('active_power_total')
->requiredMapping()
->exampleHeader('Active Power Total')
->example('6.433')
->label('Active Power Total')
->rules(['required']),
ImportColumn::make('voltage_ry')
->requiredMapping()
->exampleHeader('Voltage RY')
->example('413.308')
->label('Voltage RY')
->rules(['required']),
ImportColumn::make('voltage_yb')
->requiredMapping()
->exampleHeader('Voltage YB')
->example('415.305')
->label('Voltage YB')
->rules(['required']),
ImportColumn::make('voltage_br')
->requiredMapping()
->exampleHeader('Voltage BR')
->example('415.216')
->label('Voltage BR')
->rules(['required']),
ImportColumn::make('current_r')
->requiredMapping()
->exampleHeader('Current R')
->example('17.446')
->label('Current R')
->rules(['required']),
ImportColumn::make('current_y')
->requiredMapping()
->exampleHeader('Current Y')
->example('4.801')
->label('Current Y')
->rules(['required']),
ImportColumn::make('current_b')
->requiredMapping()
->exampleHeader('Current B')
->example('7.04')
->label('Current B')
->rules(['required']),
ImportColumn::make('current_n')
->requiredMapping()
->exampleHeader('Current N')
->example('14.063')
->label('Current N')
->rules(['required']),
ImportColumn::make('voltage_r_n')
->requiredMapping()
->exampleHeader('Voltage R N')
->example('237.898')
->label('Voltage R N')
->rules(['required']),
ImportColumn::make('voltage_y_n')
->requiredMapping()
->exampleHeader('Voltage Y N')
->example('239.518')
->label('Voltage Y N')
->rules(['required']),
ImportColumn::make('voltage_b_n')
->requiredMapping()
->exampleHeader('Voltage B N')
->example('240.798')
->label('Voltage B N')
->rules(['required']),
ImportColumn::make('frequency')
->requiredMapping()
->exampleHeader('Frequency')
->example('50.228')
->label('Frequency')
->rules(['required']),
ImportColumn::make('power_factor_r')
->requiredMapping()
->exampleHeader('Power Factor R')
->example('0.988')
->label('Power Factor R')
->rules(['required']),
ImportColumn::make('power_factor_y')
->requiredMapping()
->exampleHeader('Power Factor Y')
->example('0.764')
->label('Power Factor Y')
->rules(['required']),
ImportColumn::make('power_factor_b')
->requiredMapping()
->exampleHeader('Power Factor B')
->example('0.849')
->label('Power Factor B')
->rules(['required']),
ImportColumn::make('power_factor_total')
->requiredMapping()
->exampleHeader('Power Factor Total')
->example('0.919')
->label('Power Factor Total')
->rules(['required']),
];
}
public function resolveRecord(): ?MfmReading
{
// return MfmReading::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new MfmReading();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your mfm reading import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -15,13 +15,6 @@ class MotorTestingMasterImporter extends Importer
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant')
->example(['Ransar Industries-I','Ransar Industries-I','Ransar Industries-I'])
->label('Plant')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('item')
->requiredMapping()
->exampleHeader('Item Code')
@@ -203,6 +196,13 @@ class MotorTestingMasterImporter extends Importer
->label('No Load Speed UL')
->example(['4000','3500','4000'])
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant')
->example(['Ransar Industries-I','Ransar Industries-I','Ransar Industries-I'])
->label('Plant')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')

View File

@@ -0,0 +1,257 @@
<?php
namespace App\Filament\Imports;
use App\Models\PalletValidation;
use App\Models\Plant;
use App\Models\User;
use Carbon\Carbon;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class PalletValidationImporter extends Importer
{
protected static ?string $model = PalletValidation::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->label('Plant Code')
->exampleHeader('Plant Code')
->example('1000')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('serial_number')
->requiredMapping()
->label('Serial Number')
->exampleHeader('Serial Number')
->example('12345678901234')
->rules(['required']),
ImportColumn::make('pallet_number')
->requiredMapping()
->label('Pallet Number')
->exampleHeader('Pallet Number')
->example('EP-2507001'),
ImportColumn::make('pallet_status')
->requiredMapping()
->label('Pallet Status')
->exampleHeader('Pallet Status')
->example('Completed'),
ImportColumn::make('locator_number')
->requiredMapping()
->label('Locator Number')
->exampleHeader('Locator Number')
->example('W05-D1B'),
ImportColumn::make('locator_quantity')
->requiredMapping()
->label('Locator Quantity')
->exampleHeader('Locator Quantity')
->example(1)
->rules(['required']),
ImportColumn::make('created_at')
->requiredMapping()
->label('Created At')
->exampleHeader('Created At')
->example('01-01-2025 08:00:00')
->rules(['required']),
ImportColumn::make('scanned_at')
->requiredMapping()
->label('Scanned At')
->exampleHeader('Scanned At')
->example('01-01-2025 08:00:00')
->rules(['required']),
ImportColumn::make('updated_at')
->requiredMapping()
->label('Updated At')
->exampleHeader('Updated At')
->example('01-01-2025 08:00:00')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->label('Created By')
->exampleHeader('Created By')
->example('Admin')
->rules(['required']),
ImportColumn::make('scanned_by')
->requiredMapping()
->label('Scanned By')
->exampleHeader('Scanned By')
->example('Admin')
->rules(['required']),
ImportColumn::make('updated_by')
->requiredMapping()
->label('Updated By')
->exampleHeader('Updated By')
->example('Admin'),
];
}
public function resolveRecord(): ?PalletValidation
{
$warnMsg = [];
$plantCod = $this->data['plant'];
$plant = null;
$serialNo = $this->data['serial_number'];
$palletNo = $this->data['pallet_number'];
$palletStat = $this->data['pallet_status'];
$locatorNo = $this->data['locator_number'];
$locatorQty = $this->data['locator_quantity'];
$createdAt = $this->data['created_at'];
$scannedAt = $this->data['scanned_at'];
$updatedAt = $this->data['updated_at'];
$cDateTime = null;
$sDateTime = null;
$uDateTime = null;
$createdBy = $this->data['created_by'];
$scannedBy = $this->data['scanned_by'];
$updatedBy = $this->data['updated_by'];
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = "Invalid plant code found";
}
else
{
$plant = Plant::where('code', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
else
{
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
$warnMsg[] = "Invalid serial number found";
}
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
$warnMsg[] = "Invalid pallet number found";
}
if (Str::length($palletStat) > 0 && $palletStat != 'Completed') {
$warnMsg[] = "Invalid pallet status found";
}
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
$warnMsg[] = "Invalid locator number found";
}
if (Str::length($palletNo) <= 0 && Str::length($locatorNo) <= 0) {
$warnMsg[] = "Pallet and locator number found";
}
if (Str::length($locatorQty) < 0 || !is_numeric($locatorQty) || $locatorQty < 0 || $locatorQty > 2) {
$warnMsg[] = "Invalid locator quantity found";
}
$created = User::where('name', $createdBy)->first();
if (!$created) {
$warnMsg[] = "Created by not found";
}
$scanned = User::where('name', $scannedBy)->first();
if (!$scanned) {
$warnMsg[] = "Scanned by not found";
}
$updated = User::where('name', $updatedBy)->first();
if (!$updated) {
$warnMsg[] = "Updated by not found";
}
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
foreach ($formats as $format) {
try {
$cDateTime = Carbon::createFromFormat($format, $createdAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($cDateTime)) {
// throw new \Exception('Invalid date time format');
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
foreach ($formats as $format) {
try {
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($sDateTime)) {
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
foreach ($formats as $format) {
try
{
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($uDateTime)) {
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
else
{
if (isset($cDateTime) && isset($uDateTime)) {
if ($cDateTime->greaterThan($uDateTime)) {
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
}
}
}
}
}
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
// $warnMsg[] = "Invalid locator quantity found";
// }
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
PalletValidation::updateOrCreate(
[
'plant_id' => $plant->id,
'serial_number' => $serialNo
],
[
'pallet_number' => $palletNo,
'pallet_status' => $palletStat,
'locator_number' => $locatorNo,
'locator_quantity' => $locatorQty,
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
'scanned_at' => $sDateTime->format('Y-m-d H:i:s'),
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
'created_by' => $createdBy,
'scanned_by' => $scannedBy,
'updated_by' => $updatedBy
]
);
return null;
// // return PalletValidation::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new PalletValidation();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your pallet validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -24,13 +24,6 @@ class PlantImporter extends Importer
->example('1000')
->label('Plant Code')
->rules(['required']), //, 'integer'
ImportColumn::make('company')
->requiredMapping()
->exampleHeader('Company Name')
->example('C.R.I. Pumps Private Limited')
->label('Company Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Plant Name')
@@ -43,6 +36,13 @@ class PlantImporter extends Importer
->example('7/51-A, Keeranatham Road, Saravanampatty, Coimbatore - 641035')
->label('Plant Address')
->rules(['required']),
ImportColumn::make('company')
->requiredMapping()
->exampleHeader('Company Name')
->example('C.R.I. Pumps Private Limited')
->label('Company Name')
->relationship(resolveUsing:'name')
->rules(['required']),
];
}

View File

@@ -130,7 +130,7 @@ class ProductionQuantityImporter extends Importer
if (Str::length($this->data['serial_number']) < 9 || !ctype_alnum($this->data['serial_number'])) {
$warnMsg[] = "Invalid serial number found";
}
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || !is_numeric($this->data['production_order']))) {
if (Str::length($this->data['production_order']) > 0 && (Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14 || !is_numeric($this->data['production_order']))) {
$warnMsg[] = "Invalid production order found";
}

View File

@@ -30,20 +30,6 @@ class QualityValidationImporter extends Importer
->example('12-02-2025 15:51:00')
->label('Created DateTime')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->exampleHeader('Line Name')
->example('4 inch pump line')
->label('Line Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('sticker_master_id_code') // stickerMaster.item
->requiredMapping()
->exampleHeader('Item Code')
@@ -165,6 +151,20 @@ class QualityValidationImporter extends Importer
->exampleHeader('Unit of Measure')
->example('EA')
->label('Unit of Measure'),
ImportColumn::make('line')
->requiredMapping()
->exampleHeader('Line Name')
->example('4 inch pump line')
->label('Line Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('updated_at')
->requiredMapping()
->exampleHeader('Updated DateTime')
@@ -206,7 +206,7 @@ class QualityValidationImporter extends Importer
$warnMsg[] = "Sticker item code not found";
}
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7) {
if (!is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14) {
$warnMsg[] = "Invalid production order found";
}

View File

@@ -0,0 +1,308 @@
<?php
namespace App\Filament\Imports;
use App\Models\Plant;
use App\Models\ReworkLocatorInvoiceValidation;
use App\Models\User;
use Carbon\Carbon;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class ReworkLocatorInvoiceValidationImporter extends Importer
{
protected static ?string $model = ReworkLocatorInvoiceValidation::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Code')
->example('1000')
->label('Plant Code')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('invoice_number')
->requiredMapping()
->exampleHeader('Invoice Number')
->example('3RA002514')
->label('Invoice Number')
->rules(['required']),
ImportColumn::make('serial_number')
->requiredMapping()
->exampleHeader('Serial Number')
->example('25145441154545')
->label('Serial Number')
->rules(['required']),
ImportColumn::make('pallet_number')
->requiredMapping()
->exampleHeader('Pallet Number')
->example('')
->label('Pallet Number'),
ImportColumn::make('locator_number')
->requiredMapping()
->exampleHeader('Locator Number')
->example('')
->label('Locator Number'),
ImportColumn::make('scanned_status')
->requiredMapping()
->exampleHeader('Scanned Status')
->example('')
->label('Scanned Status')
->rules(['required']),
ImportColumn::make('upload_status')
->requiredMapping()
->exampleHeader('Upload Status')
->example('Y')
->label('Upload Status')
->rules(['required']),
ImportColumn::make('created_at')
->requiredMapping()
->exampleHeader('Created At')
->example('2025-06-17 08:42:16')
->label('Created At')
->rules(['required']),
ImportColumn::make('scanned_at')
->requiredMapping()
->exampleHeader('Scanned At')
->example('2025-06-17 08:42:16')
->label('Scanned At')
->rules(['required']),
ImportColumn::make('updated_at')
->requiredMapping()
->exampleHeader('Updated At')
->example('2025-06-17 08:42:16')
->label('Updated At')
->rules(['required']),
ImportColumn::make('reworked_at')
->requiredMapping()
->exampleHeader('Reworked At')
->example('2025-06-17 08:42:16')
->label('Reworked At')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('admin')
->label('Created By')
->rules(['required']),
ImportColumn::make('scanned_by')
->requiredMapping()
->exampleHeader('Scanned By')
->example('admin')
->label('Scanned By')
->rules(['required']),
ImportColumn::make('updated_by')
->requiredMapping()
->exampleHeader('Updated By')
->example('admin')
->label('Updated By'),
ImportColumn::make('reworked_by')
->requiredMapping()
->exampleHeader('Reworked By')
->example('admin')
->label('Reworked By')
->rules(['required']),
];
}
public function resolveRecord(): ?ReworkLocatorInvoiceValidation
{
$warnMsg = [];
$plantCod = $this->data['plant'];
$plant = null;
$invoiceNo = $this->data['invoice_number'];
$serialNo = $this->data['serial_number'];
$palletNo = $this->data['pallet_number'];
$locatorNo = $this->data['locator_number'];
$scannedStat = $this->data['scanned_status'];
$uploadStat = $this->data['upload_status'];
$createdAt = $this->data['created_at'];
$scannedAt = $this->data['scanned_at'];
$updatedAt = $this->data['updated_at'];
$reworkedAt = $this->data['reworked_at'];
$cDateTime = null;
$sDateTime = null;
$uDateTime = null;
$rDateTime = null;
$createdBy = $this->data['created_by'];
$scannedBy = $this->data['scanned_by'];
$updatedBy = $this->data['updated_by'];
$reworkedBy = $this->data['reworked_by'];
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = "Invalid plant code found";
}
else
{
$plant = Plant::where('code', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
else
{
if (Str::length($invoiceNo) < 5 || !ctype_alnum($invoiceNo)) {
$warnMsg[] = "Invalid invoice number found";
}
if (Str::length($serialNo) < 9 || Str::length($serialNo) > 20 || !ctype_alnum($serialNo)) {
$warnMsg[] = "Invalid serial number found";
}
if (Str::length($palletNo) > 0 && Str::length($palletNo) < 10) {
$warnMsg[] = "Invalid pallet number found";
}
if (Str::length($locatorNo) > 0 && Str::length($locatorNo) < 7) {
$warnMsg[] = "Invalid locator number found";
}
if ($scannedStat != 'Scanned') {
$warnMsg[] = "Invalid scanned status found";
}
if ($uploadStat != 'Y' && $uploadStat != 'N') {
$warnMsg[] = "Invalid upload status found";
}
$created = User::where('name', $createdBy)->first();
if (!$created) {
$warnMsg[] = "Created by not found";
}
$scanned = User::where('name', $scannedBy)->first();
if (!$scanned) {
$warnMsg[] = "Scanned by not found";
}
if (Str::length($updatedBy) > 0) {
$updated = User::where('name', $updatedBy)->first();
if (!$updated) {
$warnMsg[] = "Updated by not found";
}
}
$reworked = User::where('name', $reworkedBy)->first();
if (!$reworked) {
$warnMsg[] = "Reworked by not found";
}
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; //'07-05-2025 08:00' or '07-05-2025 08:00:00'
foreach ($formats as $format) {
try {
$cDateTime = Carbon::createFromFormat($format, $createdAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($cDateTime)) {
// throw new \Exception('Invalid date time format');
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
foreach ($formats as $format) {
try {
$sDateTime = Carbon::createFromFormat($format, $scannedAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($sDateTime)) {
$warnMsg[] = "Invalid 'Scanned DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
foreach ($formats as $format) {
try {
$uDateTime = Carbon::createFromFormat($format, $updatedAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($uDateTime)) {
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
else
{
if (isset($cDateTime) && isset($uDateTime)) {
if ($cDateTime->greaterThan($uDateTime)) {
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
}
}
}
foreach ($formats as $format) {
try {
$rDateTime = Carbon::createFromFormat($format, $reworkedAt);
break;
} catch (\Exception $e) {
// Optionally collect warning messages
// $warnMsg[] = "Date format mismatch with format: $format";
}
}
if (!isset($rDateTime)) {
$warnMsg[] = "Invalid 'Reworked DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
}
else
{
if (isset($cDateTime) && isset($rDateTime)) {
if ($cDateTime->greaterThan($rDateTime)) {
$warnMsg[] = "'Created DataTime' is greater than 'Reworked DateTime'.";
}
}
}
}
}
// if (!is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
// $warnMsg[] = "Invalid locator quantity found";
// }
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
ReworkLocatorInvoiceValidation::updateOrCreate(
[
'plant_id' => $plant->id,
'serial_number' => $serialNo,
'invoice_number' => $invoiceNo,
'pallet_number' => $palletNo,
'locator_number' => $locatorNo,
'scanned_status' => $scannedStat,
'upload_status' => $uploadStat,
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
'scanned_at' => $sDateTime->format('Y-m-d H:i:s'),
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
'reworked_at' => $rDateTime->format('Y-m-d H:i:s'),
'created_by' => $createdBy,
'scanned_by' => $scannedBy,
'updated_by' => $updatedBy,
'reworked_by' => $reworkedBy
]
);
return null;
// // return ReworkLocatorInvoiceValidation::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new ReworkLocatorInvoiceValidation();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your rework locator invoice validation import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -24,20 +24,6 @@ class ShiftImporter extends Importer
->example('Day')
->label('Shift Name')
->rules(['required']),
ImportColumn::make('block')
->requiredMapping()
->exampleHeader('Block Name')
->example('Block A')
->label('Block Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('start_time')
->requiredMapping()
->exampleHeader('Start Time')
@@ -57,6 +43,20 @@ class ShiftImporter extends Importer
->example('19:30:00')
->label('End Time')
->rules(['required']),
ImportColumn::make('block')
->requiredMapping()
->exampleHeader('Block Name')
->example('Block A')
->label('Block Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('status')
->requiredMapping()
->exampleHeader('Active Status')

View File

@@ -25,7 +25,130 @@ class StickerMasterImporter extends Importer
->label('ITEM CODE')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('serial_number_motor')
// ->requiredMapping()
->exampleHeader('Serial Number Motor')
->label('SERIAL NUMBER MOTOR')
->example('1'),
ImportColumn::make('serial_number_pump')
//->requiredMapping()
->exampleHeader('Serial Number Pump')
->label('SERIAL NUMBER PUMP')
->example('1'),
ImportColumn::make('serial_number_pumpset')
//->requiredMapping()
->exampleHeader('Serial Number PumpSet')
->label('SERIAL NUMBER PUMPSET')
->example(''),
ImportColumn::make('pack_slip_motor')
//->requiredMapping()
->exampleHeader('Pack Slip Motor')
->label('PACK SLIP MOTOR')
->example('1'),
ImportColumn::make('pack_slip_pump')
//->requiredMapping()
->exampleHeader('Pack Slip Pump')
->label('PACK SLIP PUMP')
->example('1'),
ImportColumn::make('pack_slip_pumpset')
//->requiredMapping()
->exampleHeader('Pack Slip PumpSet')
->label('PACK SLIP PUMPSET')
->example(''),
ImportColumn::make('name_plate_motor')
// ->requiredMapping()
->exampleHeader('Name Plate Motor')
->label('NAME PLATE MOTOR')
->example('1'),
ImportColumn::make('name_plate_pump')
// ->requiredMapping()
->exampleHeader('Name Plate Pump')
->label('NAME PLATE PUMP')
->example('1'),
ImportColumn::make('name_plate_pumpset')
// ->requiredMapping()
->exampleHeader('Name Plate PumpSet')
->label('NAME PLATE PUMPSET')
->example(''),
ImportColumn::make('tube_sticker_motor')
// ->requiredMapping()
->exampleHeader('Tube Sticker Motor')
->label('TUBE STICKER MOTOR')
->example('1'),
ImportColumn::make('tube_sticker_pump')
// ->requiredMapping()
->exampleHeader('Tube Sticker Pump')
->label('TUBE STICKER PUMP')
->example('1'),
ImportColumn::make('tube_sticker_pumpset')
// ->requiredMapping()
->exampleHeader('Tube Sticker PumpSet')
->label('TUBE STICKER PUMPSET')
->example(''),
ImportColumn::make('warranty_card')
// ->requiredMapping()
->exampleHeader('Warranty Card')
->label('WARRANTY CARD')
->example('1'),
ImportColumn::make('part_validation1')
// ->requiredMapping()
->exampleHeader('Part Validation 1')
->label('PART VALIDATION 1')
->example('12345'),
ImportColumn::make('part_validation2')
// ->requiredMapping()
->exampleHeader('Part Validation 2')
->label('PART VALIDATION 2')
->example('23456'),
ImportColumn::make('part_validation3')
// ->requiredMapping()
->exampleHeader('Part Validation 3')
->label('PART VALIDATION 3')
->example('34567'),
ImportColumn::make('part_validation4')
// ->requiredMapping()
->exampleHeader('Part Validation 4')
->label('PART VALIDATION 4')
->example('45678'),
ImportColumn::make('part_validation5')
// ->requiredMapping()
->exampleHeader('Part Validation 5')
->label('PART VALIDATION 5')
->example('56789'),
ImportColumn::make('laser_part_validation1')
// ->requiredMapping()
->exampleHeader('Laser Part Validation 1')
->label('LASER PART VALIDATION 1')
->example('67890'),
ImportColumn::make('laser_part_validation2')
// ->requiredMapping()
->exampleHeader('Laser Part Validation 2')
->label('LASER PART VALIDATION 2')
->example('78901'),
ImportColumn::make('panel_box_code')
// ->requiredMapping()
->exampleHeader('Panel Box Code')
->label('PANEL BOX CODE')
->example('123456'),
ImportColumn::make('load_rate')
->requiredMapping()
->integer()
->exampleHeader('Load Rate')
->label('LOAD RATE')
->example('0')
->rules(['required']),
ImportColumn::make('material_type')
// ->requiredMapping()
->integer()
->exampleHeader('Material Type')
->label('MATERIAL TYPE')
->example(''),
ImportColumn::make('bundle_quantity')
// ->requiredMapping()
->integer()
->exampleHeader('Bundle Quantity')
->label('BUNDLE QUANTITY')
->example(''),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
@@ -33,223 +156,84 @@ class StickerMasterImporter extends Importer
->label('PLANT NAME')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('serial_number_motor')
// ->requiredMapping()
->exampleHeader('Serial Number Motor')
->label('SERIAL NUMBER MOTOR')
->example('1'),
ImportColumn::make('serial_number_pump')
//->requiredMapping()
->exampleHeader('Serial Number Pump')
->label('SERIAL NUMBER PUMP')
->example('1'),
ImportColumn::make('serial_number_pumpset')
//->requiredMapping()
->exampleHeader('Serial Number PumpSet')
->label('SERIAL NUMBER PUMPSET')
->example(''),
ImportColumn::make('pack_slip_motor')
//->requiredMapping()
->exampleHeader('Pack Slip Motor')
->label('PACK SLIP MOTOR')
->example('1'),
ImportColumn::make('pack_slip_pump')
//->requiredMapping()
->exampleHeader('Pack Slip Pump')
->label('PACK SLIP PUMP')
->example('1'),
ImportColumn::make('pack_slip_pumpset')
//->requiredMapping()
->exampleHeader('Pack Slip PumpSet')
->label('PACK SLIP PUMPSET')
->example(''),
ImportColumn::make('name_plate_motor')
// ->requiredMapping()
->exampleHeader('Name Plate Motor')
->label('NAME PLATE MOTOR')
->example('1'),
ImportColumn::make('name_plate_pump')
// ->requiredMapping()
->exampleHeader('Name Plate Pump')
->label('NAME PLATE PUMP')
->example('1'),
ImportColumn::make('name_plate_pumpset')
// ->requiredMapping()
->exampleHeader('Name Plate PumpSet')
->label('NAME PLATE PUMPSET')
->example(''),
ImportColumn::make('tube_sticker_motor')
// ->requiredMapping()
->exampleHeader('Tube Sticker Motor')
->label('TUBE STICKER MOTOR')
->example('1'),
ImportColumn::make('tube_sticker_pump')
// ->requiredMapping()
->exampleHeader('Tube Sticker Pump')
->label('TUBE STICKER PUMP')
->example('1'),
ImportColumn::make('tube_sticker_pumpset')
// ->requiredMapping()
->exampleHeader('Tube Sticker PumpSet')
->label('TUBE STICKER PUMPSET')
->example(''),
ImportColumn::make('warranty_card')
// ->requiredMapping()
->exampleHeader('Warranty Card')
->label('WARRANTY CARD')
->example('1'),
ImportColumn::make('part_validation1')
// ->requiredMapping()
->exampleHeader('Part Validation 1')
->label('PART VALIDATION 1')
->example('12345'),
ImportColumn::make('part_validation2')
// ->requiredMapping()
->exampleHeader('Part Validation 2')
->label('PART VALIDATION 2')
->example('23456'),
ImportColumn::make('part_validation3')
// ->requiredMapping()
->exampleHeader('Part Validation 3')
->label('PART VALIDATION 3')
->example('34567'),
ImportColumn::make('part_validation4')
// ->requiredMapping()
->exampleHeader('Part Validation 4')
->label('PART VALIDATION 4')
->example('45678'),
ImportColumn::make('part_validation5')
// ->requiredMapping()
->exampleHeader('Part Validation 5')
->label('PART VALIDATION 5')
->example('56789'),
ImportColumn::make('panel_box_code')
//->requiredMapping()
->exampleHeader('Panel Box Code')
->label('PANEL BOX CODE')
->example('123456'),
ImportColumn::make('load_rate')
// ->requiredMapping()
->integer()
->exampleHeader('Load Rate')
->label('LOAD RATE')
->example('0'),
ImportColumn::make('bundle_quantity')
// ->requiredMapping()
->integer()
->exampleHeader('Bundle Quantity')
->label('BUNDLE QUANTITY')
->example(''),
ImportColumn::make('material_type')
// ->requiredMapping()
->integer()
->exampleHeader('Material Type')
->label('MATERIAL TYPE')
->example(''),
];
}
public function resolveRecord(): ?StickerMaster
{
$warnMsg = [];
$item = null;
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
$item = null;
if ($plant) {
else
{
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
}
if (!$item) {
$warnMsg[] = "Item code not found";
}
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
$warnMsg[] = "Serial number motor must be 1 or empty";
}
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
$warnMsg[] = "Serial number pump must be 1 or empty";
}
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
$warnMsg[] = "Serial number pumpset must be 1 or empty";
}
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
$warnMsg[] = "Pack slip motor must be 1 or empty";
}
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
$warnMsg[] = "Pack slip pump must be 1 or empty";
}
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
$warnMsg[] = "Pack slip pumpset must be 1 or empty";
}
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
$warnMsg[] = "Name plate motor must be 1 or empty";
}
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
$warnMsg[] = "Name plate pump must be 1 or empty";
}
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
$warnMsg[] = "Name plate pumpset must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
$warnMsg[] = "Tube sticker motor must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
$warnMsg[] = "Tube sticker pump must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
$warnMsg[] = "Tube sticker pumpset must be 1 or empty";
}
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
$warnMsg[] = "Warranty card must be 1 or empty";
}
if (Str::length($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || !ctype_alnum($this->data['panel_box_code']))) {
$warnMsg[] = "Invalid panel box code found";
}
if (!is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
$warnMsg[] = "Load rate must be greater than or equal to 0";
}
if (Str::length($this->data['bundle_quantity']) > 0 && (!is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
}
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { //($this->data['material_type'] != null) &&
$warnMsg[] = "Material type must be 1 or 2 or 3 or empty";
if (!$item) {
$warnMsg[] = "Item code not found";
}
else
{
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
$warnMsg[] = "Serial number motor must be 1 or empty";
}
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
$warnMsg[] = "Serial number pump must be 1 or empty";
}
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
$warnMsg[] = "Serial number pumpset must be 1 or empty";
}
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
$warnMsg[] = "Pack slip motor must be 1 or empty";
}
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
$warnMsg[] = "Pack slip pump must be 1 or empty";
}
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
$warnMsg[] = "Pack slip pumpset must be 1 or empty";
}
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
$warnMsg[] = "Name plate motor must be 1 or empty";
}
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
$warnMsg[] = "Name plate pump must be 1 or empty";
}
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
$warnMsg[] = "Name plate pumpset must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
$warnMsg[] = "Tube sticker motor must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
$warnMsg[] = "Tube sticker pump must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
$warnMsg[] = "Tube sticker pumpset must be 1 or empty";
}
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
$warnMsg[] = "Warranty card must be 1 or empty";
}
if (Str::length($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || !ctype_alnum($this->data['panel_box_code']))) {
$warnMsg[] = "Invalid panel box code found";
}
if (Str::length($this->data['load_rate']) < 0 || !is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
$warnMsg[] = "Load rate must be greater than or equal to 0";
}
if (Str::length($this->data['bundle_quantity']) > 0 && (!is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
}
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { //($this->data['material_type'] != null) &&
$warnMsg[] = "Material type must be 1 or 2 or 3 or empty";
}
}
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return StickerMaster::updateOrCreate([
StickerMaster::updateOrCreate([
'item_id' => $item->id,
'plant_id' => $plant->id
],
@@ -272,11 +256,14 @@ class StickerMasterImporter extends Importer
'part_validation3' => $this->data['part_validation3'],
'part_validation4' => $this->data['part_validation4'],
'part_validation5' => $this->data['part_validation5'],
'laser_part_validation1' => $this->data['laser_part_validation1'],
'laser_part_validation2' => $this->data['laser_part_validation2'],
'panel_box_code' => $this->data['panel_box_code'],
'load_rate' => $this->data['load_rate'],
'bundle_quantity' => $this->data['bundle_quantity'],
'material_type' => $this->data['material_type']
]);
return null;
// return StickerMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Filament\Imports;
use App\Models\TempLiveReading;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class TempLiveReadingImporter extends Importer
{
protected static ?string $model = TempLiveReading::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('mfmMeter')
->requiredMapping()
->exampleHeader('Mfm Meter Name')
->example('Display SSB')
->label('Mfm Meter Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('register_data')
->requiredMapping()
->exampleHeader('Register Data')
->example('65165,5646,561,561')
->label('Register Data')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?TempLiveReading
{
// return TempLiveReading::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new TempLiveReading();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your temp live reading import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -14,14 +14,6 @@ class TestingPanelReadingImporter extends Importer
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('item')
->requiredMapping()
->relationship()
@@ -83,13 +75,19 @@ class TestingPanelReadingImporter extends Importer
ImportColumn::make('output_flag')
->requiredMapping()
->rules(['required']),
ImportColumn::make('pds_status'),
ImportColumn::make('pds_description'),
ImportColumn::make('line')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('tested_by'),
ImportColumn::make('updated_by'),
ImportColumn::make('scanned_at')
->requiredMapping()
->rules(['required', 'datetime']),
->rules(['required']),
];
}

View File

@@ -25,13 +25,6 @@ class WeightValidationImporter extends Importer
->label('ITEM CODE')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('PLANT NAME')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('obd_number')
->requiredMapping()
->exampleHeader('OBD Number')
@@ -80,6 +73,13 @@ class WeightValidationImporter extends Importer
->example('1')
->label('Picked Weight')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('PLANT NAME')
->relationship(resolveUsing: 'name')
->rules(['required']),
ImportColumn::make('scanned_by')
->requiredMapping()
->exampleHeader('Scanned By')

View File

@@ -37,7 +37,7 @@ class Dashboard extends \Filament\Pages\Dashboard
->reactive()
->afterStateUpdated(function ($state) {
session(['selected_plant' => $state]); // fixed typo
$this->dispatch('cumulativeChart'); // custom Livewire event
//$this->dispatch('cumulativeChart'); // custom Livewire event
}),
]);
@@ -54,6 +54,16 @@ class Dashboard extends \Filament\Pages\Dashboard
return 'Production Line Count';
}
public function getWidgets(): array
{
$widgets = [];
if (CumulativeChart::canView()) {
$widgets[] = CumulativeChart::class;
}
return $widgets;
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production line count dashboard');

View File

@@ -0,0 +1,358 @@
<?php
namespace App\Filament\Pages;
use App\Models\Item;
use App\Models\Plant;
use App\Models\ProductionQuantity;
use App\Models\QualityValidation;
use App\Models\StickerMaster;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Form;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Auth;
class DataSendToSap extends Page implements HasForms
{
use InteractsWithForms;
public $pId , $pOrder, $pUom, $pItem, $transHeadLog, $sNums = [];
public $scanned_quantity;
public array $data = []; //Required to back form state
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.data-send-to-sap';
protected static ?string $navigationGroup = 'Send To SAP';
protected $listeners = ['updateScannedQuantity' => 'setScannedQuantity'];
public function setScannedQuantity($quantity)
{
// Set the scanned_quantity value in the Filament page/form
$this->scanned_quantity = $quantity;
$this->form->fill([
'scanned_quantity' => $quantity,
'production_order' => $this->pOrder,
'plant_id' => $this->pId,
]);
}
public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
Select::make('plant_id')
->options(Plant::pluck('name', 'id'))
->label('Plant')
->reactive()
->required()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
$set('pqPlantError', 'Please select a plant first.');
$set('production_order', null);
$set('scanned_quantity', null);
return;
}
else {
$this->pId = $plantId;
$set('production_order', null);
$set('scanned_quantity', null);
$set('validationError', null);
$set('pqPlantError', null);
}
})
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
->hintColor('danger'),
TextInput::make('production_order')
->required()
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$productionOrder = $get('production_order');
if (!$productionOrder) {
$set('pqproducError', 'Please provide production order.');
$set('production_order', null);
$set('scanned_quantity', null);
$this->dispatch('refreshed', $this->pId, $this->pOrder);
return;
}
else {
$this->pOrder = null;
$this->dispatch('refreshed', $this->pId, $this->pOrder);
$set('scanned_quantity', null);
$set('validationError', null);
$set('pqproducError', null);
}
})
->hint(fn ($get) => $get('pqproducError') ? $get('pqproducError') : null)
->hintColor('danger')
->extraAttributes([
'wire:keydown.enter' => 'processValues($event.target.value)',
]),
TextInput::make('scanned_quantity')
->reactive() // Make it reactive to update when changed
->afterStateUpdated(function ($state, $set, $get) {
$this->scanned_quantity = $state;
})
->readOnly(),
// Add your custom action button here
Actions::make([
Action::make('send_to_sap')
->label('Send Data to SAP')
->action(function ($set, $get) {
$year = date('y'); // '25' for 2025
$month = date('m'); // '05' for May
$plantId = $get('plant_id');
$code = Plant::where('id', $plantId)->value('code');
$finalBatch = $year . $month . $code;
$transHeadLogId = $this->transHeadLog; //'3256';
$lineItemCnt = '1'; //1 hard code
$sapOrder = $get('production_order');
$itemCode = $this->pItem;
$quantity = (string)$get('scanned_quantity');
$UOM = $this->pUom;
$batchNumber = $finalBatch;
$locationName = '';
$lamiCdate = $get('lami_cdate');
$serialNumbers = $this->sNums;
// dd($batchNumber);
$currentDateTime = date('j/n/Y h:i:s A');
$header = [
'Trans_Head_Log_Id' => $transHeadLogId, //'3256',
'Line_Item_Count' => $lineItemCnt, //'1',
'SAP_Order_Number' => $sapOrder, //'12345678'
'Item_Code' => $itemCode, //'6458795'
];
// $serialNumbers = ['12024090000142', '12024090000142', '12024090000142'];
$Receipt = [
// 'Receipt' => [
[
'Quantity' => $quantity, //'1',
'UOM' => $UOM,
'Batch_Number' => $batchNumber,
'Location_Name' => $locationName,
'LAMI_Cdate' => $currentDateTime, //'9/9/2024 10:48:37 AM',
'Serial_Number' => array_map(function ($serial) {
return ['Serial_Number' => $serial];
}, $serialNumbers)
]
// ]
];
$payload = [
// ...$header,
'Receipt' => $Receipt
];
// dd($payload);
// $header = [
// 'Trans_Head_Log_Id' => '3256',
// 'Line_Item_Count' => '1',
// 'SAP_Order_Number' => '12345678',
// 'Item_Code' => '6458795'
// ];
// $serialNumbers = ['12024090000142'];
// $Receipt = [
// // 'Receipt' => [
// [
// 'Quantity' => '1',
// 'UOM' => 'EA',
// 'Batch_Number' => '',
// 'Location_Name' => '',
// 'LAMI_Cdate' => '9/9/2024 10:48:37 AM',
// 'Serial_Number' => array_map(function ($serial) {
// return ['Serial_Number' => $serial];
// }, $serialNumbers)
// ]
// // ]
// ];
// $payload = [
// // ...$header,
// 'Receipt' => $Receipt
// ];
// dd($payload);
try {
// $response = Http::withHeaders([
// 'Content-Type' => 'application/json',
// 'Trans_Head_Log_Id' => '3256',//$transHeadLogId,
// 'Line_Item_Count' => '1', // $lineItemCnt,
// 'SAP_Order_Number' => '12345678', //$sapOrder,
// 'Item_Code' => '6458795', //$itemCode,
// ])
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Trans_Head_Log_Id' => $transHeadLogId,
'Line_Item_Count' => $lineItemCnt,
'SAP_Order_Number' => $sapOrder,
'Item_Code' => $itemCode,
])
->withBasicAuth(
env('SAP_API_USERNAME'),
env('SAP_API_PASSWORD')
)
->withBody(json_encode($payload), 'application/json')
->post(env('SAP_API_URL'), $payload);
$messageCode = $response->headers()['messagecode'][0] ?? null;
if ($messageCode && str_starts_with($messageCode, 'ERROR')) {
$cleanError = str_replace('ERROR:|', '', $messageCode);
// Update rows where plant_id and production_order match
QualityValidation::where('plant_id', $get('plant_id'))
->where('production_order', $get('production_order'))
->update([
'sap_msg_status' => 'ERROR',
'sap_msg_description' => $cleanError,
]);
Notification::make()
->title('SAP Error')
->body($cleanError)
->danger()
->send();
$this->dispatch('loadItems', $this->pId, $this->pOrder);
}
else
{
$messageCode = $response->headers()['messagecode'][0] ?? null;
$sapSuccessMsg = str_replace('SUCCESS:|', '', $messageCode);
QualityValidation::where('plant_id', $get('plant_id'))
->where('production_order', $get('production_order'))
->update([
'sap_msg_status' => 'SUCCESS',
'sap_msg_description' => $sapSuccessMsg,
]);
Notification::make()
->title('SAP Success')
->body($sapSuccessMsg)
->success()
->send();
$this->dispatch('loadItems', $this->pId, $this->pOrder);
}
} catch (\Exception $e) {
Notification::make()
->title('Exception')
->body('Error sending data to SAP: ' . $e->getMessage())
->danger()
->send();
}
})
->color('success')
->outlined()
->hidden(fn (callable $get) => (!$get('scanned_quantity'))) //!$get('plant_id') && !$get('production_order') &&
->extraAttributes(['class' => 'align-to-input']),
]),
])
->columns(4);
}
public function processValues($value)
{
$this->pOrder = $value;
$plantId = trim($this->form->getState()['plant_id']) ?? null;
//$this->plantId = $plantId;
// $this->pUom = QualityValidation::where('plant_id',$this->pId)
// ->where('production_order',$this->pOrder)
// ->latest()
// ->first()
// ->value('uom');
// $this->transHeadLog = QualityValidation::where('plant_id',$this->pId)
// ->where('production_order',$this->pOrder)
// ->latest()
// ->value('id');
$latestValidation = QualityValidation::where('plant_id', $this->pId)
->where('production_order', $this->pOrder)
->latest()
->first();
if (!$latestValidation) {
Notification::make()
->title('Invalid Production Order')
->body('No data found for the selected plant and production order.')
->danger()
->send();
$this->dispatch('refreshed', $this->pId, $this->pOrder);
$this->pOrder = null;
$this->form->fill([
'plant_id' => $this->pId,
'production_order' => null,
]);
return;
}
$this->pUom = $latestValidation->uom;
$this->transHeadLog = $latestValidation->id;
$this->sNums = [];
if(!$this->pUom)
{
Notification::make()
->title('UOM Not Found')
->body('UOM not found for the production order')
->icon('heroicon-o-x-circle') // optional, to force red/error-style icon
->danger()
->send();
$this->dispatch('refreshed', $this->pId, $this->pOrder);
}
else
{
$this->pItem = Item::where('id', StickerMaster::where('id', QualityValidation::where('plant_id',$this->pId)->where('production_order',$this->pOrder)->latest()->first()->sticker_master_id)->value('item_id'))->value('code');
$this->sNums = QualityValidation::where('plant_id', $this->pId)
->where('production_order', $this->pOrder)
->pluck('serial_number')
->toArray();
//dd($this-> pItem);
$this->dispatch('loadItems', $this->pId, $this->pOrder);
}
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view quality data send to sap');
}
public static function getNavigationLabel(): string
{
return 'Quality Data';
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace App\Filament\Pages;
use App\Filament\Widgets\GuardPatrolDayChart;
use App\Models\Plant;
use Filament\Pages\Page;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Forms\Form;
use Filament\Forms\Components\Select;
use Illuminate\Support\Facades\Auth;
class GuardPatrolDayCount extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.guard-patrol-day-count';
protected static ?string $navigationGroup = 'Guard DashBoard';
use HasFiltersForm;
public function mount(): void
{
session()->forget(['selected_plant']);
$this->filtersForm->fill([
'plant' => null
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Select::make('plant')
->options(Plant::pluck('name', 'id'))
->label('Select Plant')
->reactive()
->afterStateUpdated(function ($state) {
session(['selected_plant' => $state]);
$this->dispatch('patrolEntryChart');
}),
]);
}
public static function getNavigationLabel(): string
{
return 'Guard Patrol Day Count';
}
public function getHeading(): string
{
return 'Guard Patrol Day Chart';
}
public function getWidgets(): array
{
return [
GuardPatrolDayChart::class,
];
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view guard patrol day count dashboard');
}
}

View File

@@ -0,0 +1,115 @@
<?php
namespace App\Filament\Pages;
use App\Models\GuardPatrolEntry;
use App\Models\Plant;
use Carbon\Carbon;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
class GuardPatrolEntryDashboard extends Page
{
use HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static ?string $navigationGroup = 'Guard DashBoard';
protected static string $view = 'filament.pages.guard-patrol-entry-dashboard';
public function mount(): void
{
// session()->forget(['select_guard_plant', 'select_guard_date']);
$this->filtersForm->fill([
'plant' => null,
'date' => null,
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters') // Explicitly set where to store form data
->schema([
Select::make('plant')
->options(Plant::pluck('name', 'id'))
->label('Select Plant')
->reactive()
->required()
->afterStateUpdated(function ($state, callable $set, callable $get){
// $this->dispatch('invoiceChart');
if(!$state)
{
$set('date', now()->format('Y-m-d')); // H:i:s
// session(['select_guard_plant' => $state]);
// session(['select_guard_date' => $get('date')]);
} else {
if(!$get('date'))
{
$set('date', now()->format('Y-m-d'));
// session(['select_guard_plant' => $state]);
// session(['select_guard_date' => $get('date')]);
}
// else {
// session(['select_guard_plant' => $state]);
// session(['select_guard_date' => $get('date')]);
// }
}
$this->dispatch('loadGuardData', $state, $get('date')); //->format('Y-m-d')
}),
DatePicker::make('date')
->label('Select Date')
->placeholder('Select Date')
->reactive()
->required()
->beforeOrEqual(now())
->default(now()->format('Y-m-d'))
->afterStateUpdated(function ($state, callable $set, callable $get){
if(!$get('plant'))
{
$set('date', now()->format('Y-m-d'));
// session(['select_guard_plant' => $get('plant')]);
// session(['select_guard_date' => $state]);
} else {
if(!$get('date'))
{
$set('date', now()->format('Y-m-d'));
// session(['select_guard_plant' => $get('plant')]);
// session(['select_guard_date' => $state]);
}
// else {
// $records = GuardPatrolEntry::whereDate('patrol_time', $state)->where('plant_id', $get('plant'))->orderBy('patrol_time', 'asc')->first(); //desc
// //dd($get('plant'), $state, $records->patrol_time);//->toTimeString()
// session(['select_guard_plant' => $get('plant')]);
// session(['select_guard_date' => $state]);
// }
}
// $this->dispatch('invoiceChart');
$this->dispatch('loadGuardData', $get('plant'), $state);//->format('Y-m-d')
})
])
->columns(2);
}
public static function getNavigationLabel(): string
{
return 'Guard Patrol Status Table';
}
public function getHeading(): string
{
return 'Guard Patrol Entry Status';
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view guard patrol entry status dashboard');
}
}

View File

@@ -0,0 +1,266 @@
<?php
namespace App\Filament\Pages;
use App\Filament\Widgets\GuardPatrolHourlyChart;
use App\Models\CheckPointName;
use App\Models\CheckPointTime;
use App\Models\GuardPatrolEntry;
use App\Models\Plant;
use Carbon\Carbon;
use Filament\Pages\Page;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Forms\Form;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\DatePicker;
use Illuminate\Support\Facades\Auth;
class GuardPatrolHourlyCount extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.guard-patrol-hourly-count';
protected static ?string $navigationGroup = 'Guard DashBoard';
use HasFiltersForm;
public function mount(): void
{
session()->forget(['selected_plant']);
session()->forget(['selected_date']);
session()->forget(['selected_name']);
session()->forget(['selected_time']);
session()->forget(['valid_sessions']);
$this->filtersForm->fill([
'plant' => null,
'date' => null,
'time_range' => null,
'guard_name' => null
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Select::make('plant')
->options(Plant::pluck('name', 'id'))
->label('Select Plant')
->reactive()
->required()
->afterStateUpdated(function ($state,callable $set) {
if (is_null($state)) {
session()->forget('selected_plant');
} else {
session(['selected_plant' => $state]);
}
session(['selected_plant' => $state]);
$set('date', null);
session()->forget('selected_date');
$set('guard_name', null);
session()->forget('selected_name');
$set('time_range', null);
session()->forget('selected_time');
session()->forget('valid_sessions');
// $this->dispatch('patrolEntryChart');
}),
DatePicker::make('date')
->label('Select Date')
->placeholder('Select Date')
->reactive()
->required()
->beforeOrEqual(now())
->default(now()->format('Y-m-d'))
->afterStateUpdated(function ($state,callable $set) {
session(['selected_date' => $state]);
$set('guard_name', null);
session()->forget('selected_name');
$set('time_range', null);
session()->forget('selected_time');
session()->forget('valid_sessions');
// $this->dispatch('patrolEntryChart');
}),
Select::make('guard_name')
->label('Guard Name')
->options(function (callable $get) {
$plantId = $get('plant');
$Date = $get('date');
if (!$plantId || !$Date) {
return [];
}
return GuardPatrolEntry::with('guardNames')->where('plant_id', $plantId)
->whereDate('patrol_time', $Date)->orderBy('patrol_time','asc')
->get()
->unique('guard_name_id')
->pluck('guardNames.name', 'guard_name_id')
->toArray();
})
->reactive()
->required()
->afterStateUpdated(function ($state,callable $set)
{
if (is_null($state))
{
session()->forget('selected_name');
}
else
{
session(['selected_name' => $state]);
}
// Clear the time range field and its session
$set('time_range', null);
session()->forget('selected_time');
session()->forget('valid_sessions');
}),
// Select::make('time_range')
// ->label('Patrol Time Range')
// ->options(function (callable $get) {
// $plantId = $get('plant');
// $guardId = $get('guard_name');
// $date = $get('date');
// if (!$plantId || !$guardId || !$date) {
// return [];
// }
// $patrols = GuardPatrolEntry::where('plant_id', $plantId)
// ->where('guard_name_id', $guardId)
// ->whereDate('patrol_time', $date)
// ->orderBy('patrol_time', 'asc')
// ->get(['patrol_time']);
// if ($patrols->isEmpty())
// {
// return [];
// }
// $chunkSize = CheckPointTime::where('plant_id', $plantId)->count()+ 1;;
// $chunks = $patrols->chunk($chunkSize);
// $options = [];
// foreach ($chunks as $index => $chunk) {
// $first = $chunk->first();
// $last = $chunk->last();
// $start = Carbon::parse($first->patrol_time)->format('H:i:s');
// $end = Carbon::parse($last->patrol_time)->format('H:i:s');
// $timeRange = "$start - $end";
// $options[$timeRange] = $timeRange;
// }
// return $options;
// })
// ->reactive()
// ->required()
// ->afterStateUpdated(function ($state) {
// session(['selected_time' => $state]);
// })
Select::make('time_range')
->label('Patrol Time Range')
->options(function (callable $get) {
$plantId = $get('plant');
$guardId = $get('guard_name');
$date = $get('date');
if (!$plantId || !$guardId || !$date) {
session(['valid_sessions' => []]);
return [];
}
// Get patrols with checkpoints
$patrols = GuardPatrolEntry::where('plant_id', $plantId)
->where('guard_name_id', $guardId)
->whereDate('patrol_time', $date)
->orderBy('patrol_time', 'asc')
->get(['patrol_time', 'check_point_name_id']);
if ($patrols->isEmpty()) {
session(['valid_sessions' => []]);
return [];
}
// Get checkpoint sequence
$checkPointTimes = CheckPointTime::where('plant_id', $plantId)
->orderBy('sequence_number')
->get(['check_point1_id', 'check_point2_id']);
// Build expected sequence
$expectedSequence = [];
foreach ($checkPointTimes as $row) {
$expectedSequence[] = $row->check_point1_id;
}
if ($checkPointTimes->isNotEmpty()) {
$expectedSequence[] = $checkPointTimes->last()->check_point2_id;
}
$chunkSize = $checkPointTimes->count() + 1;
$chunks = $patrols->chunk($chunkSize);
$options = [];
$validSessions = [];
foreach ($chunks as $index => $chunk) {
$first = $chunk->first();
$last = $chunk->last();
$start = Carbon::parse($first->patrol_time)->format('H:i:s');
$end = Carbon::parse($last->patrol_time)->format('H:i:s');
$timeRange = "$start - $end";
// Validate sequence for this chunk
$currentSeqIndex = 0;
$isValid = true;
$anyMatch = false;
foreach ($chunk as $patrol) {
if ($currentSeqIndex < count($expectedSequence) &&
$patrol->check_point_name_id == $expectedSequence[$currentSeqIndex]) {
$currentSeqIndex++;
$anyMatch = true;
} else {
$isValid = false;
}
}
// Consider valid only if at least one checkpoint matches
$isValid = $isValid && $anyMatch;
$validSessions[$timeRange] = $isValid;
$options[$timeRange] = $timeRange;
}
session(['valid_sessions' => $validSessions]);
return $options;
})
->reactive()
->required()
->afterStateUpdated(function ($state) {
session(['selected_time' => $state]);
})
])
->columns(4);
}
public function getWidgets(): array
{
return [
GuardPatrolHourlyChart::class,
];
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view guard patrol hourly count dashboard');
}
}

View File

@@ -46,18 +46,18 @@ class InvoiceDashboard extends Page
$this->dispatch('invoiceChart');
}),
Select::make('invoice')
->options([
'serial_invoice' => 'Serial Invoice',
'individual_material' => 'Individual Material Invoice',
'bundle_material' => 'Bundle Material Invoice',
])
->label('Select Invoice')
->reactive()
->default(0)
->afterStateUpdated(function ($state) {
session(['select_invoice' => $state]);
$this->dispatch('invoiceChart');
})
->options([
'serial_invoice' => 'Serial Invoice',
'individual_material' => 'Individual Material Invoice',
'bundle_material' => 'Bundle Material Invoice',
])
->label('Select Invoice')
->reactive()
->default(0)
->afterStateUpdated(function ($state) {
session(['select_invoice' => $state]);
$this->dispatch('invoiceChart');
})
])
->columns(2);
}

View File

@@ -0,0 +1,220 @@
<?php
namespace App\Filament\Pages;
use App\Models\LocatorInvoiceValidation;
use App\Models\PalletValidation;
use App\Models\Plant;
use Illuminate\Support\Facades\Auth;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Pages\Page;
use Filament\Forms\Form;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
class InvoiceFinder extends Page implements HasForms
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.invoice-finder';
protected static ?string $navigationGroup = 'Export Dispatch';
protected static ?int $navigationSort = 6;
//use InteractsWithForms;
public $pId, $invoiceNumber;
public array $invoiceOverviewData = [];
public array $filters = [];
public function form(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Section::make('') // You can give your section a title or leave it blank
->schema([
Select::make('plant_id')
->options(Plant::pluck('name', 'id'))
->label('Plant')
->reactive()
->required(),
TextInput::make('scan_invoice')
->label('Scan Invoice')
->required()
->reactive()
->extraAttributes([
'wire:keydown.enter' => 'processInvoiceNo($event.target.value)',
]),
TextInput::make('scan_quantity')
->label('Scanned Quantity ')
->readOnly()
->reactive(),
TextInput::make('pending_quantity')
->label('Pending Quantity')
->readOnly()
->reactive(),
TextInput::make('total_sno_quantity')
->label('Invoice Quantity')
->readOnly()
->reactive(),
])
->columns(5)
]);
}
public function processInvoiceNo($invoiceNo)
{
$plantId = $this->form->getState()['plant_id'];
if(!$invoiceNo)
{
Notification::make()
->title("Invoice number '$invoiceNo' can't be empty!")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', '', [], [], [], [], $plantId);
$this->form->fill([
'plant_id' => $plantId,
'scan_invoice' => $invoiceNo,
'total_sno_quantity' => 0,
'pending_quantity' => 0,
'scan_quantity' => 0
]);
return;
}
$invoiceExists = LocatorInvoiceValidation::where('plant_id', $plantId)
->where('invoice_number', $invoiceNo)
->first();
if(!$invoiceExists)
{
Notification::make()
->title("Invoice number '$invoiceNo' does not exist in locator invoice table!")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', '', [], [], [], [], $plantId);
$this->form->fill([
'plant_id' => $plantId,
'scan_invoice' => null,//$invoiceNo,
'total_sno_quantity' => 0,
'pending_quantity' => 0,
'scan_quantity' => 0
]);
return;
}
$invoiceCompleted = LocatorInvoiceValidation::where('plant_id', $plantId)
->where('invoice_number', $invoiceNo)
->whereNull('scanned_status')
->orWhere('scanned_status', '=','')
->first();
if(!$invoiceCompleted)
{
// $count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
// ->where('plant_id', $plantId)
// ->count();
Notification::make()
->title("Invoice number '$invoiceNo' already completed the scanning process..!")
->success()
->duration(5000)
->send();
$this->dispatch('loadData', '', [], [], [], [], $plantId);
$this->form->fill([
'plant_id' => $plantId,
'scan_invoice' => null,//$invoiceNo,
'total_sno_quantity' => 0,//$count,
'pending_quantity' => 0,//0,
'scan_quantity' => 0//$count
]);
return;
}
$serialNumbers = LocatorInvoiceValidation::where('plant_id', $plantId)
->where('invoice_number', $invoiceNo)
->pluck('serial_number');
$notFoundSerials = [];
$incompleteSerials = [];
$scannedSerials = [];
$foundSerials = [];
foreach ($serialNumbers as $serial)
{
$locatorRecord = LocatorInvoiceValidation::where('serial_number', $serial)
->where('plant_id', $plantId)
->first();
//$scannedStatus = $locatorRecord->scanned_status ?? null;
if ($locatorRecord->scanned_status == 'Scanned')
{
$scannedSerials[] = $serial;
continue;
}
$palletRecord = palletValidation::where('serial_number', $serial)
->where('plant_id', $plantId)
->first();
if (!$palletRecord)
{
$notFoundSerials[] = $serial;
continue;
}
$palletStatus = $palletRecord->pallet_status ?? null;
if (strlen($palletRecord->pallet_number) > 1 && ($palletStatus == '' || $palletStatus == null))
{
$incompleteSerials[] = $serial;
continue;
}
$foundSerials[] = $serial;
}
$count = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
->where('plant_id', $plantId)
->count();
$pendingCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
->where('plant_id', $plantId)
->whereNull('scanned_status')
->orWhere('scanned_status', '=', '')
->count();
$scannedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNo)
->where('plant_id', $plantId)
->where('scanned_status', '=', 'Scanned')
->count();
$this->form->fill([
'plant_id' => $plantId,
'scan_invoice' => $invoiceNo,
'total_sno_quantity' => $count,
'pending_quantity' => $pendingCount,
'scan_quantity' => $scannedCount,
]);
$this->dispatch('loadData', $invoiceNo, $notFoundSerials, $incompleteSerials, $scannedSerials, $foundSerials, $plantId);
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view invoice finder page');
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Filament\Pages;
use App\Models\Plant;
use Filament\Pages\Page;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Forms\Form;
use Filament\Forms\Components\Select;
use Illuminate\Support\Facades\Auth;
class InvoiceQuantityDashboard extends Page
{
use HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static ?string $navigationGroup = 'Invoice DashBoard';
protected static string $view = 'filament.pages.invoice-quantity-dashboard';
public function mount(): void
{
session()->forget(['selec_plant', 'select_invoice']);
$this->filtersForm->fill([
'plant' => null,
'invoice' => null,
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters') // Explicitly set where to store form data
->schema([
Select::make('plant')
->options(Plant::pluck('name', 'id'))
->label('Select Plant')
->reactive()
->afterStateUpdated(function ($state) {
session(['selec_plant' => $state]);
$this->dispatch('invoiceChart');
}),
Select::make('invoice')
->options([
'serial_invoice' => 'Serial Invoice',
'individual_material' => 'Individual Material Invoice',
'bundle_material' => 'Bundle Material Invoice',
])
->label('Select Invoice')
->reactive()
->default(0)
->afterStateUpdated(function ($state) {
session(['select_invoice' => $state]);
$this->dispatch('invoiceChart');
})
])
->columns(2);
}
public static function getNavigationLabel(): string
{
return 'Invoice Quantity';
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view invoice serial quantity dashboard');
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,370 @@
<?php
namespace App\Filament\Pages;
use App\Models\Item;
use App\Models\Plant;
use App\Models\ProductionQuantity;
use App\Models\QualityValidation;
use App\Models\StickerMaster;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Form;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Page;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Auth;
class ProductionDataSap extends Page implements HasForms
{
use InteractsWithForms;
public $pId , $pOrder, $pUom, $pItem, $transHeadLog, $sNums = [];
public $scanned_quantity;
public array $data = []; //Required to back form state
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.production-data-sap';
protected static ?string $navigationGroup = 'Send To SAP';
protected $listeners = ['updateScannedQuantity' => 'setScannedQuantity'];
public function setScannedQuantity($quantity)
{
// Set the scanned_quantity value in the Filament page/form
$this->scanned_quantity = $quantity;
$this->form->fill([
'scanned_quantity' => $quantity,
'production_order' => $this->pOrder,
'plant_id' => $this->pId,
]);
}
public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
Select::make('plant_id')
->options(Plant::pluck('name', 'id'))
->label('Plant')
->reactive()
->required()
->afterStateUpdated(function ($state, $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
$set('pqPlantError', 'Please select a plant first.');
$set('production_order', null);
$set('scanned_quantity', null);
return;
}
else {
$this->pId = $plantId;
$set('production_order', null);
$set('scanned_quantity', null);
$set('validationError', null);
$set('pqPlantError', null);
}
})
->hint(fn ($get) => $get('pqPlantError') ? $get('pqPlantError') : null)
->hintColor('danger'),
TextInput::make('production_order')
->required()
->reactive()
->afterStateUpdated(function ($state, $set, callable $get) {
$productionOrder = $get('production_order');
if (!$productionOrder) {
$set('pqproducError', 'Please provide production order.');
$set('scanned_quantity', null);
$this->dispatch('refreshed', $this->pId, $this->pOrder);
return;
}
else {
$this->pOrder = null;
$this->dispatch('refreshed', $this->pId, $this->pOrder);
$set('scanned_quantity', null);
$set('validationError', null);
$set('pqproducError', null);
}
})
->hint(fn ($get) => $get('pqproducError') ? $get('pqproducError') : null)
->hintColor('danger')
->extraAttributes([
'wire:keydown.enter' => 'processValues($event.target.value)',
]),
TextInput::make('scanned_quantity')
->reactive() // Make it reactive to update when changed
->afterStateUpdated(function ($state, $set, $get) {
$this->scanned_quantity = $state;
})
->readOnly()
->required(),
// Add your custom action button here
Actions::make([
Action::make('send_to_sap')
->label('Send Data to SAP')
->action(function ($set, $get) {
$plantId = $get('plant_id');
$plantWarehouseCodes = [
// plant_id => warehouse_code
1 => '110', // Ransar I
2 => '101', // Ransar II
3 => '102', // Chola Pumps
4 => '104', // Tuff Pumps
//5 => '107', //WH-Nark
5 => '200', // Go-flex
//7 => '301', // Krisgo II
];
$year = date('y'); // '25' for 2025
$month = date('m'); // '05' for May
$transHeadLogId = $this->transHeadLog; //'3256';
$lineItemCnt = '1'; //1 hard code
$sapOrder = $get('production_order');
$itemCode = $this->pItem;
$quantity = (string)$get('scanned_quantity');
$UOM = $this->pUom;
$locationName = '';
$lamiCdate = $get('lami_cdate');
$serialNumbers = $this->sNums;
$warehouseCode = $plantWarehouseCodes[$plantId] ?? null;
$finalBatch = $warehouseCode . $year . $month;
$batchNumber = $finalBatch;
//dd($batchNumber);
$currentDateTime = date('j/n/Y h:i:s A');
$header = [
'Trans_Head_Log_Id' => $transHeadLogId, //'3256',
'Line_Item_Count' => $lineItemCnt, //'1',
'SAP_Order_Number' => $sapOrder, //'12345678'
'Item_Code' => $itemCode, //'6458795'
];
// $serialNumbers = ['12024090000142', '12024090000142', '12024090000142'];
$Receipt = [
// 'Receipt' => [
[
'Quantity' => $quantity, //'1',
'UOM' => $UOM,
'Batch_Number' => $batchNumber,
'Location_Name' => $locationName,
'LAMI_Cdate' => $currentDateTime, //'9/9/2024 10:48:37 AM',
'Serial_Number' => array_map(function ($serial) {
return ['Serial_Number' => $serial];
}, $serialNumbers)
]
// ]
];
$payload = [
// ...$header,
'Receipt' => $Receipt
];
// dd($payload);
// $header = [
// 'Trans_Head_Log_Id' => '3256',
// 'Line_Item_Count' => '1',
// 'SAP_Order_Number' => '12345678',
// 'Item_Code' => '6458795'
// ];
// $serialNumbers = ['12024090000142'];
// $Receipt = [
// // 'Receipt' => [
// [
// 'Quantity' => '1',
// 'UOM' => 'EA',
// 'Batch_Number' => '',
// 'Location_Name' => '',
// 'LAMI_Cdate' => '9/9/2024 10:48:37 AM',
// 'Serial_Number' => array_map(function ($serial) {
// return ['Serial_Number' => $serial];
// }, $serialNumbers)
// ]
// // ]
// ];
// $payload = [
// // ...$header,
// 'Receipt' => $Receipt
// ];
// dd($payload);
try {
// $response = Http::withHeaders([
// 'Content-Type' => 'application/json',
// 'Trans_Head_Log_Id' => '3256',//$transHeadLogId,
// 'Line_Item_Count' => '1', // $lineItemCnt,
// 'SAP_Order_Number' => '12345678', //$sapOrder,
// 'Item_Code' => '6458795', //$itemCode,
// ])
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Trans_Head_Log_Id' => $transHeadLogId,
'Line_Item_Count' => $lineItemCnt,
'SAP_Order_Number' => $sapOrder,
'Item_Code' => $itemCode,
])
->withBasicAuth(
'sb-eba140ab-74bb-44a4-8d92-70a636940def!b1182|it-rt-dev-cri-stjllphr!b68',
'616d8991-307b-4ab1-be37-7894a8c6db9d$0p0fE2I7w1Ve23-lVSKQF0ka3mKrTVcKPJYELr-i4nE='
)
->withBody(json_encode($payload), 'application/json')
//->dump()
->post('https://dev-cri-stjllphr.it-cpi004-rt.cfapps.ap11.hana.ondemand.com/http/LA2CRI/GoodsReceiptAgFG', $payload);
// dump($response->transferStats->getRequest());
// dd(json_encode($payload, JSON_PRETTY_PRINT));
//dd($response->status(), $response->body());
// dump($response);
$messageCode = $response->headers()['messagecode'][0] ?? null;
if ($messageCode && str_starts_with($messageCode, 'ERROR')) {
$cleanError = str_replace('ERROR:|', '', $messageCode);
// Update rows where plant_id and production_order match
ProductionQuantity::where('plant_id', $get('plant_id'))
->where('production_order', $get('production_order'))
->update([
'sap_msg_status' => 'ERROR',
'sap_msg_description' => $cleanError,
]);
Notification::make()
->title('SAP Error')
->body($cleanError)
->danger()
->send();
$this->dispatch('loadItems', $this->pId, $this->pOrder);
}
else
{
$messageCode = $response->headers()['messagecode'][0] ?? null;
$sapSuccessMsg = str_replace('SUCCESS:|', '', $messageCode);
ProductionQuantity::where('plant_id', $get('plant_id'))
->where('production_order', $get('production_order'))
->update([
'sap_msg_status' => 'SUCCESS',
'sap_msg_description' => $sapSuccessMsg,
]);
Notification::make()
->title('SAP Success')
->body($sapSuccessMsg)
->success()
->send();
}
} catch (\Exception $e) {
Notification::make()
->title('Exception')
->body('Error sending data to SAP: ' . $e->getMessage())
->danger()
->send();
}
})
->color('success')
->outlined()
->hidden(fn (callable $get) => (!$get('scanned_quantity'))) //!$get('plant_id') && !$get('production_order') &&
->extraAttributes(['class' => 'align-to-input']),
]),
])
->columns(4);
}
public function processValues($value)
{
$this->pOrder = $value;
$latestValidation = ProductionQuantity::where('plant_id', $this->pId)
->where('production_order', $this->pOrder)
->latest()
->first();
if (!$latestValidation) {
Notification::make()
->title('Invalid Production Order')
->body('No data found for the selected plant and production order.')
->danger()
->send();
$this->dispatch('refreshed', $this->pId, $this->pOrder);
return;
}
// $this->pUom = $latestValidation->uom;
$this->transHeadLog = $latestValidation->id;
$itemId = $latestValidation->item_id;
$this->pUom = Item::where('id', $itemId)->value('uom');
$this->sNums = [];
if(!$this->pUom)
{
Notification::make()
->title('UOM Not Found')
->body('UOM not found for the production order')
->icon('heroicon-o-x-circle')
->danger()
->send();
$this->dispatch('refreshed', $this->pId, $this->pOrder);
}
else
{
$latestProduction = ProductionQuantity::where('plant_id', $this->pId)
->where('production_order', $this->pOrder)
->latest()
->first();
$this->pItem = $latestProduction
? Item::where('id', $latestProduction->item_id)->value('code')
: null;
$this->sNums = ProductionQuantity::where('plant_id', $this->pId)
->where('production_order', $this->pOrder)
->pluck('serial_number')
->toArray();
$this->dispatch('loadItems', $this->pId, $this->pOrder);
}
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production data send to sap');
}
public static function getNavigationLabel(): string
{
return 'Production Data';
}
}

View File

@@ -20,6 +20,8 @@ use Route;
use Illuminate\Support\Facades\Request;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\On;
class ProductionQuantityPage extends Page implements HasForms
{
@@ -130,7 +132,6 @@ class ProductionQuantityPage extends Page implements HasForms
->options(Plant::pluck('name', 'id'))
->label('Plant')
->reactive()
->live()
->required()
->columnSpan(1)
->default(function () {
@@ -163,7 +164,7 @@ class ProductionQuantityPage extends Page implements HasForms
->label('Block')
->required()
// ->nullable()
->live()
->reactive()
->columnSpan(1)
->options(function (callable $get) {
if (!$get('plant_id')) {
@@ -174,7 +175,6 @@ class ProductionQuantityPage extends Page implements HasForms
->pluck('name', 'id')
->toArray();
})
->reactive()
->default(function () {
$latestShiftId = optional(ProductionQuantity::latest()->first())->shift_id;
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
@@ -276,7 +276,6 @@ class ProductionQuantityPage extends Page implements HasForms
->toArray();
})
->reactive()
->live()
->default(function () {
return optional(ProductionQuantity::latest()->first())->line_id;
})
@@ -321,34 +320,55 @@ class ProductionQuantityPage extends Page implements HasForms
->hintColor('danger'),
TextInput::make('production_order')
->label('Production Order')
->reactive()
->live()
->required()
->columnSpan(1)
->afterStateUpdated(function ($state, callable $get, callable $set): void {
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
$this->prodOrder = $state;
->label('Production Order')
->reactive()
->required()
->minLength(7)
->maxLength(14)
//->columnSpan(1)
->columnSpan(['default' => 1, 'sm' => 1])
->afterStateUpdated(function ($state, callable $get, callable $set): void {
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
{
$set('productionError', "Must be a numeric value with 7 to 14 digits.");
$set('production_order', null);
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
$this->prodOrder = null;
}
else
{
$set('productionError', null);
$set('production_order', $state);
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('validationError', null);
$this->prodOrder = $state;
// if (empty($state)) {
// }
}
})
->extraAttributes(fn ($get) => [
'class' => $get('productionError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
->hintColor('danger'),
return;
// if (empty($state)) {
// }
}),
TextInput::make('item_code')
->label('Item Code')
->columnSpan(1)
->autofocus(true)
->reactive()
->live()
->default(fn () => $this->clear_qr)
->extraAttributes([
'wire:keydown.enter' => 'processAllValues($event.target.value)',
]),
// TextInput::make('item_code')
// ->label('Item Code')
// ->columnSpan(1)
// ->autofocus(true)
// //->reactive()
// ->live(onBlur: true) // avoids per-keystroke triggering
// ->default(fn () => $this->clear_qr)
// ->extraAttributes([
// 'wire:keydown.enter' => 'processAllValues($event.target.value)',
// ]),
Hidden::make('serial_number')
->required(),
@@ -362,7 +382,8 @@ class ProductionQuantityPage extends Page implements HasForms
TextInput::make('recent_qr')
->label('Last scanned QR')
->reactive()
->columnSpan(1)
->columnSpan(['default' => 1, 'sm' => 2])
//->columnSpan(2)
// ->default(function () {
// // Get the latest 'item_id' foreign key from 'production_quantities' table
// $latestProductionQuantity = ProductionQuantity::latest()->first();
@@ -383,7 +404,6 @@ class ProductionQuantityPage extends Page implements HasForms
// })
->default(fn () => $this->recQr)
->readOnly(true),
TextInput::make('id')
@@ -392,11 +412,19 @@ class ProductionQuantityPage extends Page implements HasForms
Hidden::make('operator_id')
->default(Filament::auth()->user()->name),
])
->columns(7);
// ->columns(6);
->columns(['default' => 1, 'sm' => 7]);
}
// Method to process the value when Enter is pressed
#[On('handleQrScan')]
public function handleQrScan($value)
{
$this->processAllValues($value);
}
public function processAllValues($formQRData)
{
@@ -417,36 +445,6 @@ class ProductionQuantityPage extends Page implements HasForms
$user = Filament::auth()->user(); //->name
$operatorName = $user->name;
$this->qrData = $formQRData;
// dd($formData, $formQRData);
// dd($this->form->getState()['serial_number']);
// try {
// // Access the nested form data
// $componentData = json_decode($formValues['components'][0]['snapshot'], true);
// $formData = $componentData['data']['data'][0]; // Access first item in data array
// // Extract specific values
// $this->qrData = $formQRData ?? $formData['item_code'];
// $this->pId = $formData['plant_id'] ?? null;
// $this->bId = $formData['block_name'] ?? null;
// $this->sId = $formData['shift_id'] ?? null;
// $this->lId = $formData['line_id'] ?? null;
// $this->iId = $formData['item_id'] ?? null;
// $this->succId = $formData['success_msg'] ?? null;
// // $this->sNoId = $formData['serial_number'] ?? null;
// $this->prodOrder = $formData['production_order'] ?? null;
// $this->recQr = $formData['recent_qr'] ?? null;
// $this->dispatch('plant-line-updated', $this->pId,$this->lId);
// } catch (\Exception $e) {
// //dd('Error parsing form data:', $e->getMessage(), $formValues);
// Notification::make()
// ->title("Error Parsing Form Data") // {$operatorName}
// ->body($e->getMessage())
// ->danger()
// // ->persistent()
// ->send();
// return;
// }
$latestProductionQuantity = ProductionQuantity::latest()->first();
@@ -456,7 +454,6 @@ class ProductionQuantityPage extends Page implements HasForms
$this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
}
if (empty($formQRData)) {
$this->form->fill([
'plant_id'=> $this->pId,
@@ -616,7 +613,7 @@ class ProductionQuantityPage extends Page implements HasForms
->send();
return;
}
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
{
$this->form->fill([
'plant_id'=> $this->pId,
@@ -635,7 +632,7 @@ class ProductionQuantityPage extends Page implements HasForms
Notification::make()
->title('Invalid Production Order')
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
->body("Must be a numeric value with 7 to 14 digits.<br>Must start with a non-zero digit.")
->danger()
->send();
return;
@@ -1303,7 +1300,7 @@ class ProductionQuantityPage extends Page implements HasForms
'shift_id'=> $this->sId,
'line_id'=> $this->lId,
'item_id'=> null,
// 'item_code'=> null,
//'item_code'=> null,
'serial_number'=> null,
'success_msg'=> null,
'production_order'=> $this->prodOrder,
@@ -1317,6 +1314,7 @@ class ProductionQuantityPage extends Page implements HasForms
->title("Valid QR Found") // {$operatorName}
->body("Valid QR code scanned: {$this->qrData}.")
->success()
->duration(200)
->send();
}
}
@@ -1327,25 +1325,25 @@ class ProductionQuantityPage extends Page implements HasForms
// For example:
$model = ProductionQuantity::create($formValues);
// dd('Production Updated Event Dispatched');
// dd('Production Updated Event Dispatched');
$this->dispatch('productionUpdated');
// // Optionally, you can emit an event or perform a redirect after saving
// $this->emit('formSaved', $model->id);
}
public function triggerChartUpdate(): void
{
if (session()->has('select_plant') && session()->has('select_line')) {
$this->dispatch('filtersUpdated');
}
}
public function triggerChartUpdate(): void
{
if (session()->has('select_plant') && session()->has('select_line')) {
$this->dispatch('filtersUpdated');
}
}
// Override the getTitle method
public function getTitle(): string
{
return ''; // Return an empty string to remove the title
}
// Override the getTitle method
public function getTitle(): string
{
return ''; // Return an empty string to remove the title
}
public static function getNavigationLabel(): string
{

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,131 @@
<?php
namespace App\Filament\Pages;
use App\Filament\Widgets\TrendChartAnalysis;
use App\Models\MfmMeter;
use Filament\Pages\Page;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use App\Models\Plant;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Forms\Components\DateTimePicker;
use Illuminate\Support\Facades\Auth;
class TrendChartAnalys extends Page
{
use HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.trend-chart-analys';
protected static ?string $navigationGroup = 'EMS DashBoard';
// use HasFiltersForm;
public function mount(): void
{
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
$this->filtersForm->fill([
'selected_plant' => null,
'selected_meter' => null,
'from_datetime' => null,
'to_datetime' => null,
'parameter' => null,
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters')
->schema([
DateTimePicker::make('from_datetime')
->label('From DateTime')
->required()
->before('to_datetime')
->reactive()
->afterStateUpdated(function ($state) {
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
session(['from_datetime' => $formatted]);
}),
DateTimePicker::make('to_datetime')
->label('To DateTime')
->required()
->after('from_datetime')
->reactive()
->afterStateUpdated(function ($state) {
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
session(['to_datetime' => $formatted]);
}),
Select::make('plant')
->options(Plant::pluck('name', 'id'))
->label('Select Plant')
->reactive()
->required()
->afterStateUpdated(function ($state, callable $set) {
session(['selected_plant' => $state]);
// When plant changes, also reset meter_name
$set('meter_name', null);
session(['selected_meter' => null]);
// dd($state);
}),
Select::make('meter_name')
->options(function ($get) {
$plantId = $get('plant');
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
})
->label('Select Meter')
->reactive()
->required()
->afterStateUpdated(function ($state) {
session(['selected_meter' => $state]);
}),
Select::make('parameter')
->options([
'Phase Voltage' => 'Phase Voltage',
'Line Voltage' => 'Line Voltage',
'Current' => 'Current',
'Active Power' => 'Active Power',
'Power Factor' => 'Power Factor',
'Units' => 'Units',
])
->label('Select Parameter')
->reactive()
->required()
->afterStateUpdated(function ($state) {
session(['parameter' => $state]);
}),
])
->columns(5);
}
public static function getNavigationLabel(): string
{
return 'Trend Chart Analysis';
}
public function getHeading(): string
{
return 'Trend Chart Analysis';
}
public function getWidgets(): array
{
$widgets = [];
if (TrendChartAnalysis::canView()) {
$widgets[] = TrendChartAnalysis::class;
}
return $widgets;
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view ems trend chart analysis dashboard');
}
}

View File

@@ -0,0 +1,129 @@
<?php
namespace App\Filament\Pages;
use App\Filament\Widgets\TrendLineChart;
use Filament\Pages\Page;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use App\Models\Plant;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Forms\Components\DateTimePicker;
use App\Models\MfmMeter;
use Illuminate\Support\Facades\Auth;
class TrendLineAnalysis extends Page
{
use HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.trend-line-analysis';
protected static ?string $navigationGroup = 'EMS DashBoard';
public function mount(): void
{
session()->forget(['selected_plant', 'selected_meter', 'from_datetime', 'to_datetime', 'parameter']);
$this->filtersForm->fill([
'selected_plant' => null,
'selected_meter' => null,
'from_datetime' => null,
'to_datetime' => null,
'parameter' => null,
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters')
->schema([
DateTimePicker::make('from_datetime')
->label('From DateTime')
->required()
->before('to_datetime')
->reactive()
->afterStateUpdated(function ($state) {
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
session(['from_datetime' => $formatted]);
}),
DateTimePicker::make('to_datetime')
->label('To DateTime')
->required()
->after('from_datetime')
->reactive()
->afterStateUpdated(function ($state) {
$formatted = \Carbon\Carbon::parse($state)->format('Y-m-d H:i:s');
session(['to_datetime' => $formatted]);
}),
Select::make('plant')
->options(Plant::pluck('name', 'id'))
->label('Select Plant')
->reactive()
->required()
->afterStateUpdated(function ($state, callable $set) {
session(['selected_plant' => $state]);
// When plant changes, also reset meter_name
$set('meter_name', null);
session(['selected_meter' => null]);
// dd($state);
}),
Select::make('meter_name')
->options(function ($get) {
$plantId = $get('plant');
// Return meter name/id pairs from mfm_meters where plant_id matches selected plant
return $plantId ? MfmMeter::where('plant_id', $plantId)->pluck('name', 'id') : [];
})
->label('Select Meter')
->reactive()
->required()
->afterStateUpdated(function ($state) {
session(['selected_meter' => $state]);
}),
Select::make('parameter')
->options([
'Phase Voltage' => 'Phase Voltage',
'Line Voltage' => 'Line Voltage',
'Current' => 'Current',
'Active Power' => 'Active Power',
'Power Factor' => 'Power Factor',
'Units' => 'Units',
])
->label('Select Parameter')
->reactive()
->required()
->afterStateUpdated(function ($state) {
session(['parameter' => $state]);
}),
])
->columns(5);
}
// public static function getNavigationLabel(): string
// {
// return 'Trend Chart Analysis';
// }
// public function getHeading(): string
// {
// return 'Trend Chart Analysis';
// }
public function getWidgets(): array
{
$widgets = [];
if (TrendLineChart::canView()) {
$widgets[] = TrendLineChart::class;
}
return $widgets;
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view ems trend line analysis dashboard');
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,182 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource\RelationManagers;
use App\Models\AlertMailRule;
use App\Models\Plant;
use Dotenv\Exception\ValidationException;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Illuminate\Validation\ValidationException as ValidationValidationException;
class AlertMailRuleResource extends Resource
{
protected static ?string $model = AlertMailRule::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Alert Mail';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant')
->label('Plant')
->reactive()
->options(fn () => Plant::pluck('name', 'id')->toArray())
->required(fn ($get) => ! $get('is_active'))
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null),
// ->options(fn () => Plant::pluck('id', 'name')->toArray()),
Forms\Components\Select::make('module')
->label('Module')
->required()
->options([
'InvoiceValidation' => 'InvoiceValidation',
'ProductionQuantities' => 'ProductionQuantities',
]),
Forms\Components\Select::make('rule_name')
->label('Rule Name')
->options([
'InvoiceMail' => 'Invoice Mail',
'SerialInvoiceMail' => 'Serial Invoice Mail',
'MaterialInvoiceMail' => 'Material Invoice Mail',
'ProductionMail' => 'Production Mail',
])
->required(),
Forms\Components\TextInput::make('email')
->label('Email')
->required(),
Forms\Components\Select::make('schedule_type')
->label('Schedule Type')
->required()
->options([
'Live' => 'Live',
'Hourly' => 'Hourly',
'Daily' => 'Daily',
]),
Checkbox::make('is_active')
->label('All Plants Reports')
->afterStateUpdated(fn ($state, callable $set) => $state ? $set('plant', null) : null)
->reactive(),
Forms\Components\Hidden::make('created_by')
->default(fn () => Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->default(fn () => Filament::auth()->user()?->name),
])
->columns(5),
]);
}
// Optionally, also override for update/editing
// public static function mutateFormDataBeforeSave(array $data): array
// {
// dd('test');
// if ($data['is_active']) {
// $data['plant'] = 'All Plants';
// }
// return $data;
// }
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('plant')
->label('Plant')
->sortable()
->formatStateUsing(function ($state) {
static $plants;
if (! $plants) {
$plants = Plant::pluck('name', 'id')->toArray();
}
return $plants[$state] ?? 'All Plants';
}),
Tables\Columns\TextColumn::make('module')
->label('Module')
->sortable(),
Tables\Columns\TextColumn::make('rule_name')
->label('Rule Name')
->sortable(),
Tables\Columns\TextColumn::make('email')
->label('Email')
->sortable(),
Tables\Columns\TextColumn::make('schedule_type')
->label('Schedule Type')
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListAlertMailRules::route('/'),
'create' => Pages\CreateAlertMailRule::route('/create'),
'view' => Pages\ViewAlertMailRule::route('/{record}'),
'edit' => Pages\EditAlertMailRule::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateAlertMailRule extends CreateRecord
{
protected static string $resource = AlertMailRuleResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
if ($data['is_active']) {
$data['plant'] = 0;
}
return $data;
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditAlertMailRule extends EditRecord
{
protected static string $resource = AlertMailRuleResource::class;
protected function mutateFormDataBeforeSave(array $data): array
{
//dd('test');
if ($data['is_active']) {
$data['plant'] = 0;
}
return $data;
}
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListAlertMailRules extends ListRecords
{
protected static string $resource = AlertMailRuleResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\AlertMailRuleResource\Pages;
use App\Filament\Resources\AlertMailRuleResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewAlertMailRule extends ViewRecord
{
protected static string $resource = AlertMailRuleResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -0,0 +1,187 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\CheckPointNameExporter;
use App\Filament\Imports\CheckPointNameImporter;
use App\Filament\Resources\CheckPointNameResource\Pages;
use App\Filament\Resources\CheckPointNameResource\RelationManagers;
use App\Models\CheckPointName;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
class CheckPointNameResource extends Resource
{
protected static ?string $model = CheckPointName::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Master Entries';
protected static ?int $navigationSort = 14;
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->required()
->reactive()
->default(function () {
return optional(CheckPointName::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
$set('cPnPlantError', 'Please select a plant first.');
return;
}
else
{
$set('cPnPlantError', null);
$set('created_by', Filament::auth()->user()?->name);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('cPnPlantError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('cPnPlantError') ? $get('cPnPlantError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('name')
->label('Name')
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->rule(function (callable $get) {
return Rule::unique('check_point_names', 'name')
->where('plant_id', $get('plant_id'))
->ignore($get('id'));
}),
Forms\Components\Hidden::make('created_by')
->default(fn () => Filament::auth()->user()?->name)
->required(),
Forms\Components\TextInput::make('id')
->hidden()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->readOnly(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
// Tables\Columns\TextColumn::make('id')
// ->label('ID')
// ->numeric()
// ->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('name')
->label('Check Point Name')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(CheckPointNameImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import check point name');
}),
ExportAction::make()
->exporter(CheckPointNameExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export check point name');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListCheckPointNames::route('/'),
'create' => Pages\CreateCheckPointName::route('/create'),
'view' => Pages\ViewCheckPointName::route('/{record}'),
'edit' => Pages\EditCheckPointName::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Filament\Resources\CheckPointNameResource\Pages;
use App\Filament\Resources\CheckPointNameResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateCheckPointName extends CreateRecord
{
protected static string $resource = CheckPointNameResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\CheckPointNameResource\Pages;
use App\Filament\Resources\CheckPointNameResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditCheckPointName extends EditRecord
{
protected static string $resource = CheckPointNameResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\CheckPointNameResource\Pages;
use App\Filament\Resources\CheckPointNameResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListCheckPointNames extends ListRecords
{
protected static string $resource = CheckPointNameResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\CheckPointNameResource\Pages;
use App\Filament\Resources\CheckPointNameResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewCheckPointName extends ViewRecord
{
protected static string $resource = CheckPointNameResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -0,0 +1,418 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\CheckPointTimeExporter;
use App\Filament\Imports\CheckPointTimeImporter;
use App\Filament\Resources\CheckPointTimeResource\Pages;
use App\Filament\Resources\CheckPointTimeResource\RelationManagers;
use App\Models\CheckPointName;
use App\Models\CheckPointTime;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
class CheckPointTimeResource extends Resource
{
protected static ?string $model = CheckPointTime::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Master Entries';
protected static ?int $navigationSort = 15;
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->required()
->reactive()
->default(function () {
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
$set('cPtPlantError', 'Please select a plant first.');
return;
}
else
{
$set('cPtPlantError', null);
$set('created_by', Filament::auth()->user()?->name);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('cPtPlantError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('cPtPlantError') ? $get('cPtPlantError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('sequence_number')
->label('Sequence Number')
->required()
->reactive()
->integer()
->minValue(1)
->default(1)
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->rule(function (callable $get) {
return Rule::unique('check_point_times', 'sequence_number')
->where('plant_id', $get('plant_id'))
->ignore($get('id'));
//->where('check_point1_id', $get('check_point1_id'))
//->where('check_point2_id', $get('check_point2_id'))
}),
Forms\Components\Select::make('check_point1_id')
->label('Check Point Name 1')
// ->relationship('checkPointNames', 'name')
->options(function (callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
return [];
}
return CheckPointName::where('plant_id', $plantId)
->pluck('name', 'id')
->toArray();
})
->required()
->reactive()
->default(function () {
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point1_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$checkPoint1 = $get('check_point1_id');
$checkPoint2 = $get('check_point2_id');
if (!$checkPoint1) {
$set('cPtCheckPoint1Error', 'Please select a check point 1 first.');
return;
}
else
{
if ($checkPoint2 && $checkPoint1 == $checkPoint2) {
$set('cPtCheckPoint1Error', 'Duplicate check point 2 found.');
$set('check_point2_id', null);
return;
}
$set('cPtCheckPoint1Error', null);
$set('cPtCheckPoint2Error', null);
$set('created_by', Filament::auth()->user()?->name);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('cPtCheckPoint1Error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('cPtCheckPoint1Error') ? $get('cPtCheckPoint1Error') : null)
->hintColor('danger'),
Forms\Components\Select::make('check_point2_id')
->label('Check Point Name 2')
// ->relationship('checkPointNames', 'name')
->options(function (callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
return [];
}
return CheckPointName::where('plant_id', $plantId)
->pluck('name', 'id')
->toArray();
})
->required()
->reactive()
->default(function () {
return optional(CheckPointTime::where('created_by', Filament::auth()->user()?->name)->latest()->first())->check_point2_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$checkPoint1 = $get('check_point1_id');
$checkPoint2 = $get('check_point2_id');
if (!$checkPoint2) {
$set('cPtCheckPoint2Error', 'Please select a check point 2 first.');
return;
}
else
{
if ($checkPoint1 && $checkPoint1 == $checkPoint2) {
$set('cPtCheckPoint2Error', 'Duplicate check point 2 found.');
$set('check_point2_id', null);
return;
}
$set('cPtCheckPoint1Error', null);
$set('cPtCheckPoint2Error', null);
$set('created_by', Filament::auth()->user()?->name);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('cPtCheckPoint2Error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('cPtCheckPoint2Error') ? $get('cPtCheckPoint2Error') : null)
->hintColor('danger')
->rule(function (callable $get) {
return Rule::unique('check_point_times', 'check_point2_id')
->where('check_point1_id', $get('check_point1_id'))
->where('plant_id', $get('plant_id'))
->ignore($get('id'));
}),
Forms\Components\TextInput::make('time_lapse')
->label('Time Lapse (in minutes)')
->required()
->integer()
->minValue(1)
->default(1)
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$timeLapse = $state;
$timeLapseCushioning = $get('time_lapse_cushioning');
if (!$timeLapse) {
$set('cPtTimeLapseError', 'Please enter a valid time lapse!');
$set('time_lapse_cushioning', null);
$set('min_cushioning', null);
$set('max_cushioning', null);
return;
}
elseif(!$timeLapseCushioning)
{
// $set('cPtTimeLapseError', 'Please enter a valid time lapse cushioning!');
$set('time_lapse_cushioning', 1);
$set('cPtTimeLapseError', null);
$set('min_cushioning', $timeLapse - 1);
$set('max_cushioning', $timeLapse + 1);
$set('created_by', Filament::auth()->user()?->name);
return;
}
elseif ($timeLapseCushioning > $timeLapse) {
$set('cPtTimeLapseError', 'Must be greater than or equal to time lapse cushioning!');
$set('time_lapse_cushioning', null);
$set('min_cushioning', null);
$set('max_cushioning', null);
return;
}
else
{
$set('cPtTimeLapseError', null);
$set('cPtTimeLapseCushError', null);
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
$set('max_cushioning', $timeLapse + $timeLapseCushioning);
$set('created_by', Filament::auth()->user()?->name);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('cPtTimeLapseError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('cPtTimeLapseError') ? $get('cPtTimeLapseError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('time_lapse_cushioning')
->label('Time Lapse Cushioning (in minutes)')
->required()
->integer()
->minValue(1)
->default(1)
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$timeLapse = $get('time_lapse');
$timeLapseCushioning = $state;
if (!$timeLapse) {
$set('cPtTimeLapseCushError', 'Please enter a valid time lapse first.');
$set('time_lapse_cushioning', null);
$set('min_cushioning', null);
$set('max_cushioning', null);
return;
}
elseif(!$timeLapseCushioning)
{
// $set('cPtTimeLapseCushError', 'Please enter a valid time lapse cushioning!');
$set('time_lapse_cushioning', 1);
$set('cPtTimeLapseCushError', null);
$set('min_cushioning', $timeLapse - 1);
$set('max_cushioning', $timeLapse + 1);
$set('created_by', Filament::auth()->user()?->name);
return;
}
elseif ($timeLapseCushioning > $timeLapse) {
$set('cPtTimeLapseCushError', 'Must be less than or equal to time lapse!');
$set('time_lapse_cushioning', null);
$set('min_cushioning', null);
$set('max_cushioning', null);
return;
}
else
{
$set('cPtTimeLapseError', null);
$set('cPtTimeLapseCushError', null);
$set('min_cushioning', $timeLapse - $timeLapseCushioning);
$set('max_cushioning', $timeLapse + $timeLapseCushioning);
$set('created_by', Filament::auth()->user()?->name);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('cPtTimeLapseCushError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('cPtTimeLapseCushError') ? $get('cPtTimeLapseCushError') : null)
->hintColor('danger'),
Forms\Components\Hidden::make('min_cushioning')
->default(0)
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Hidden::make('max_cushioning')
->default(2)
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Hidden::make('created_by')
->default(fn () => Filament::auth()->user()?->name)
->required(),
Forms\Components\TextInput::make('id')
->hidden()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->readOnly(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
// Tables\Columns\TextColumn::make('id')
// ->label('ID')
// ->numeric()
// ->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('checkPointNames1.name')
->label('Check Point 1')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('checkPointNames2.name')
->label('Check Point 2')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('sequence_number')
->label('Sequence Number')
->alignCenter()
->searchable()
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('time_lapse')
->label('Time Lapse')
->alignCenter()
->searchable()
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('time_lapse_cushioning')
->label('Time Lapse Cushioning (±)')
->alignCenter()
->searchable()
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(CheckPointTimeImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import check point time');
}),
ExportAction::make()
->exporter(CheckPointTimeExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export check point time');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListCheckPointTimes::route('/'),
'create' => Pages\CreateCheckPointTime::route('/create'),
'view' => Pages\ViewCheckPointTime::route('/{record}'),
'edit' => Pages\EditCheckPointTime::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
use App\Filament\Resources\CheckPointTimeResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateCheckPointTime extends CreateRecord
{
protected static string $resource = CheckPointTimeResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
use App\Filament\Resources\CheckPointTimeResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditCheckPointTime extends EditRecord
{
protected static string $resource = CheckPointTimeResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
use App\Filament\Resources\CheckPointTimeResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListCheckPointTimes extends ListRecords
{
protected static string $resource = CheckPointTimeResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\CheckPointTimeResource\Pages;
use App\Filament\Resources\CheckPointTimeResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewCheckPointTime extends ViewRecord
{
protected static string $resource = CheckPointTimeResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -0,0 +1,151 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\DeviceMasterExporter;
use App\Filament\Imports\DeviceMasterImporter;
use App\Filament\Resources\DeviceMasterResource\Pages;
use App\Filament\Resources\DeviceMasterResource\RelationManagers;
use App\Models\DeviceMaster;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class DeviceMasterResource extends Resource
{
protected static ?string $model = DeviceMaster::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Power House';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->required(),
Forms\Components\TextInput::make('name')
->label('Device Name')
->required(),
Forms\Components\TextInput::make('mac_address')
->label('MAC Address'),
Forms\Components\TextInput::make('ip_address')
->label('IP Address'),
Forms\Components\Hidden::make('created_by')
->default(Filament::auth()->user()?->name),
])
->columns(4),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('name')
->label('Device Name')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('mac_address')
->label('MAC Address')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('ip_address')
->label('IP Address')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(DeviceMasterImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import device master');
}),
ExportAction::make()
->exporter(DeviceMasterExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export device master');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListDeviceMasters::route('/'),
'create' => Pages\CreateDeviceMaster::route('/create'),
'view' => Pages\ViewDeviceMaster::route('/{record}'),
'edit' => Pages\EditDeviceMaster::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\DeviceMasterResource\Pages;
use App\Filament\Resources\DeviceMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateDeviceMaster extends CreateRecord
{
protected static string $resource = DeviceMasterResource::class;
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\DeviceMasterResource\Pages;
use App\Filament\Resources\DeviceMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditDeviceMaster extends EditRecord
{
protected static string $resource = DeviceMasterResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\DeviceMasterResource\Pages;
use App\Filament\Resources\DeviceMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListDeviceMasters extends ListRecords
{
protected static string $resource = DeviceMasterResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\DeviceMasterResource\Pages;
use App\Filament\Resources\DeviceMasterResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewDeviceMaster extends ViewRecord
{
protected static string $resource = DeviceMasterResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -0,0 +1,443 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\EbReadingExporter;
use App\Filament\Imports\EbReadingImporter;
use App\Filament\Resources\EbReadingResource\Pages;
use App\Filament\Resources\EbReadingResource\RelationManagers;
use App\Models\EbReading;
use App\Models\Plant;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Filament\Facades\Filament;
use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\DateTimePicker;
class EbReadingResource extends Resource
{
protected static ?string $model = EbReading::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Power House';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->required(),
Forms\Components\TextInput::make('lcd_segment_check')
->label('LCD Segment Check'),
Forms\Components\TextInput::make('meter_serial_no')
->label('Meter Serial No'),
Forms\Components\DateTimePicker::make('eb_date_time')
->required()
->label('EB Date Time'),
Forms\Components\TextInput::make('ph_seq_of_volt')
->label('PH Sequence of Volt'),
Forms\Components\TextInput::make('ph_assoc_conn_check')
->label('PH Association Connection Check'),
Forms\Components\TextInput::make('instantaneous_ph_volt')
->label('Instantaneous PH Volt'),
Forms\Components\TextInput::make('instantaneous_curr')
->label('Instantaneous Current'),
Forms\Components\TextInput::make('instantaneous_freq')
->label('Instantaneous Frequency'),
Forms\Components\TextInput::make('instantaneous_kw_with_sign')
->label('Instantaneous KW with Sign'),
Forms\Components\TextInput::make('instantaneous_kva')
->label('Instantaneous KVA'),
Forms\Components\TextInput::make('instantaneous_kv_ar')
->label('Instantaneous KV AR'),
Forms\Components\TextInput::make('instantaneous_pf_with_sign')
->label('Instantaneous PF with Sign'),
Forms\Components\TextInput::make('rd_with_elapsed_time_kva')
->label('RD with Elapsed Time KVA'),
Forms\Components\TextInput::make('cum_active_import_energy')
->label('Cumulative Active Import Energy'),
Forms\Components\TextInput::make('tod1_active_energy_6_9')
->label('TOD1 Active Energy 6-9'),
Forms\Components\TextInput::make('tod2_active_energy_18_21')
->label('TOD2 Active Energy 18-21'),
Forms\Components\TextInput::make('tod3_active_energy_21_22')
->label('TOD3 Active Energy 21-22'),
Forms\Components\TextInput::make('tod4_active_energy_5_6_9_18')
->label('TOD4 Active Energy 5-6-9-18'),
Forms\Components\TextInput::make('tod5_active_energy_22_5')
->label('TOD5 Active Energy 22-5'),
Forms\Components\TextInput::make('cum_reac_lag_energy')
->label('Cumulative Reactive Lag Energy'),
Forms\Components\TextInput::make('cum_reac_lead_energy')
->label('Cumulative Reactive Lead Energy'),
Forms\Components\TextInput::make('cum_appar_energy')
->label('Cumulative Apparent Energy'),
Forms\Components\TextInput::make('tod1_appar_energy_6_9')
->label('TOD1 Apparent Energy 6-9'),
Forms\Components\TextInput::make('tod2_appar_energy_18_21')
->label('TOD2 Apparent Energy 18-21'),
Forms\Components\TextInput::make('tod3_appar_energy_21_22')
->label('TOD3 Apparent Energy 21-22'),
Forms\Components\TextInput::make('tod4_appar_energy_5_6_9_18')
->label('TOD4 Apparent Energy 5-6-9-18'),
Forms\Components\TextInput::make('tod5_appar_energy_22_5')
->label('TOD5 Apparent Energy 22-5'),
Forms\Components\TextInput::make('avg_pow_factor')
->label('Average Power Factor'),
Forms\Components\TextInput::make('avg_freq_15min_last_ip')
->label('Average Frequency 15min Last IP'),
Forms\Components\TextInput::make('net_kv_arh_high')
->label('Net KV ARH High'),
Forms\Components\TextInput::make('net_kv_arh_low')
->label('Net KV ARH Low'),
Forms\Components\TextInput::make('cum_md_kva')
->label('Cumulative MD KVA'),
Forms\Components\TextInput::make('present_md_kva')
->label('Present MD KVA'),
Forms\Components\DateTimePicker::make('present_md_kva_date_time')
->label('Present MD KVA Date Time')
->required(),
Forms\Components\TextInput::make('tod1_md_kva_6_9')
->label('TOD1 MD KVA 6-9'),
Forms\Components\TextInput::make('tod2_md_kva_18_21')
->label('TOD2 MD KVA 18-21'),
Forms\Components\TextInput::make('tod3_md_kva_21_22')
->label('TOD3 MD KVA 21-22'),
Forms\Components\TextInput::make('tod4_md_kva_5_6_9_18')
->label('TOD4 MD KVA 5-6-9-18'),
Forms\Components\TextInput::make('tod5_md_kva_22_5')
->label('TOD5 MD KVA 22-5'),
Forms\Components\TextInput::make('total_pow_off_hours')
->label('Total Power Off Hours'),
Forms\Components\TextInput::make('programming_count')
->label('Programming Count'),
Forms\Components\TextInput::make('last_occ_res_event_type')
->label('Last Occurrence/Reset Event Type'),
Forms\Components\DateTimePicker::make('last_occ_res_event_date_time')
->label('Last Occurrence/Reset Event Date Time')
->required(),
Forms\Components\TextInput::make('tamper_count')
->label('Tamper Count'),
Forms\Components\TextInput::make('reset_count')
->label('Reset Count'),
Forms\Components\DateTimePicker::make('last_md_reset_date_time')
->label('Last MD Reset Date Time')
->required(),
Forms\Components\Hidden::make('electrician_sign')
->default(Filament::auth()->user()?->name),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->alignCenter()
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('lcd_segment_check')
->alignCenter()
->label('LCD Segment Check'),
Tables\Columns\TextColumn::make('meter_serial_no')
->alignCenter()
->label('Meter Serial No'),
Tables\Columns\TextColumn::make('eb_date_time')
->alignCenter()
->label('EB Date Time'),
Tables\Columns\TextColumn::make('ph_seq_of_volt')
->alignCenter()
->label('PH Sequence of Volt'),
Tables\Columns\TextColumn::make('ph_assoc_conn_check')
->alignCenter()
->label('PH Association Connection Check'),
Tables\Columns\TextColumn::make('instantaneous_ph_volt')
->alignCenter()
->label('Instantaneous PH Volt'),
Tables\Columns\TextColumn::make('instantaneous_curr')
->alignCenter()
->label('Instantaneous Current'),
Tables\Columns\TextColumn::make('instantaneous_freq')
->alignCenter()
->label('Instantaneous Frequency'),
Tables\Columns\TextColumn::make('instantaneous_kw_with_sign')
->alignCenter()
->label('Instantaneous KW with Sign'),
Tables\Columns\TextColumn::make('instantaneous_kva')
->alignCenter()
->label('Instantaneous KVA'),
Tables\Columns\TextColumn::make('instantaneous_kv_ar')
->alignCenter()
->label('Instantaneous KV AR'),
Tables\Columns\TextColumn::make('instantaneous_pf_with_sign')
->alignCenter()
->label('Instantaneous PF with Sign'),
Tables\Columns\TextColumn::make('rd_with_elapsed_time_kva')
->alignCenter()
->label('RD with Elapsed Time KVA'),
Tables\Columns\TextColumn::make('cum_active_import_energy')
->alignCenter()
->label('Cumulative Active Import Energy'),
Tables\Columns\TextColumn::make('tod1_active_energy_6_9')
->alignCenter()
->label('TOD1 Active Energy 6-9'),
Tables\Columns\TextColumn::make('tod2_active_energy_18_21')
->alignCenter()
->label('TOD2 Active Energy 18-21'),
Tables\Columns\TextColumn::make('tod3_active_energy_21_22')
->alignCenter()
->label('TOD3 Active Energy 21-22'),
Tables\Columns\TextColumn::make('tod4_active_energy_5_6_9_18')
->alignCenter()
->label('TOD4 Active Energy 5-6-9-18'),
Tables\Columns\TextColumn::make('tod5_active_energy_22_5')
->alignCenter()
->label('TOD5 Active Energy 22-5'),
Tables\Columns\TextColumn::make('cum_reac_lag_energy')
->alignCenter()
->label('Cumulative Reactive Lag Energy'),
Tables\Columns\TextColumn::make('cum_reac_lead_energy')
->alignCenter()
->label('Cumulative Reactive Lead Energy'),
Tables\Columns\TextColumn::make('cum_appar_energy')
->alignCenter()
->label('Cumulative Apparent Energy'),
Tables\Columns\TextColumn::make('tod1_appar_energy_6_9')
->alignCenter()
->label('TOD1 Apparent Energy 6-9'),
Tables\Columns\TextColumn::make('tod2_appar_energy_18_21')
->alignCenter()
->label('TOD2 Apparent Energy 18-21'),
Tables\Columns\TextColumn::make('tod3_appar_energy_21_22')
->alignCenter()
->label('TOD3 Apparent Energy 21-22'),
Tables\Columns\TextColumn::make('tod4_appar_energy_5_6_9_18')
->alignCenter()
->label('TOD4 Apparent Energy 5-6-9-18'),
Tables\Columns\TextColumn::make('tod5_appar_energy_22_5')
->alignCenter()
->label('TOD5 Apparent Energy 22-5'),
Tables\Columns\TextColumn::make('avg_pow_factor')
->alignCenter()
->label('Average Power Factor'),
Tables\Columns\TextColumn::make('avg_freq_15min_last_ip')
->alignCenter()
->label('Average Frequency 15min Last IP'),
Tables\Columns\TextColumn::make('net_kv_arh_high')
->alignCenter()
->label('Net KV ARH High'),
Tables\Columns\TextColumn::make('net_kv_arh_low')
->alignCenter()
->label('Net KV ARH Low'),
Tables\Columns\TextColumn::make('cum_md_kva')
->alignCenter()
->label('Cumulative MD KVA'),
Tables\Columns\TextColumn::make('present_md_kva')
->alignCenter()
->label('Present MD KVA'),
Tables\Columns\TextColumn::make('present_md_kva_date_time')
->alignCenter()
->label('Present MD KVA Date Time'),
Tables\Columns\TextColumn::make('tod1_md_kva_6_9')
->alignCenter()
->label('TOD1 MD KVA 6-9'),
Tables\Columns\TextColumn::make('tod2_md_kva_18_21')
->alignCenter()
->label('TOD2 MD KVA 18-21'),
Tables\Columns\TextColumn::make('tod3_md_kva_21_22')
->alignCenter()
->label('TOD3 MD KVA 21-22'),
Tables\Columns\TextColumn::make('tod4_md_kva_5_6_9_18')
->alignCenter()
->label('TOD4 MD KVA 5-6-9-18'),
Tables\Columns\TextColumn::make('tod5_md_kva_22_5')
->alignCenter()
->label('TOD5 MD KVA 22-5'),
Tables\Columns\TextColumn::make('total_pow_off_hours')
->alignCenter()
->label('Total Power Off Hours'),
Tables\Columns\TextColumn::make('programming_count')
->alignCenter()
->label('Programming Count'),
Tables\Columns\TextColumn::make('last_occ_res_event_type')
->alignCenter()
->label('Last Occurrence/Reset Event Type'),
Tables\Columns\TextColumn::make('last_occ_res_event_date_time')
->alignCenter()
->label('Last Occurrence/Reset Event Date Time'),
Tables\Columns\TextColumn::make('tamper_count')
->alignCenter()
->label('Tamper Count'),
Tables\Columns\TextColumn::make('reset_count')
->alignCenter()
->label('Reset Count'),
Tables\Columns\TextColumn::make('last_md_reset_date_time')
->alignCenter()
->label('Last MD Reset Date Time'),
Tables\Columns\TextColumn::make('electrician_sign')
->alignCenter()
->label('Created By'),
Tables\Columns\TextColumn::make('created_at')
->alignCenter()
->label('Created At')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
// ->filters([
// Tables\Filters\TrashedFilter::make(),
// ])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('electrician_sign', null);
}),
TextInput::make('electrician_sign')
->label('Created By'),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['electrician_sign'])) {
return $query->whereRaw('1 = 0');
}
if (!empty($data['Plant'])) {
$query->where('plant_id', $data['Plant']);
}
if (!empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (!empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
if (!empty($data['electrician_sign'])) {
$query->where('electrician_sign', $data['electrician_sign']);
}
})
->indicateUsing(function (array $data) {
$indicators = [];
if (!empty($data['Plant'])) {
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
}
if (!empty($data['electrician_sign'])) {
$indicators[] = 'Created By: ' . $data['electrician_sign'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
if (!empty($data['created_to'])) {
$indicators[] = 'To: ' . $data['created_to'];
}
return $indicators;
})
])
->filtersFormMaxHeight('280px')
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(EbReadingImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import eb reading');
}),
ExportAction::make()
->exporter(EbReadingExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export eb reading');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListEbReadings::route('/'),
'create' => Pages\CreateEbReading::route('/create'),
'view' => Pages\ViewEbReading::route('/{record}'),
'edit' => Pages\EditEbReading::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\EbReadingResource\Pages;
use App\Filament\Resources\EbReadingResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateEbReading extends CreateRecord
{
protected static string $resource = EbReadingResource::class;
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\EbReadingResource\Pages;
use App\Filament\Resources\EbReadingResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditEbReading extends EditRecord
{
protected static string $resource = EbReadingResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\EbReadingResource\Pages;
use App\Filament\Resources\EbReadingResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListEbReadings extends ListRecords
{
protected static string $resource = EbReadingResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\EbReadingResource\Pages;
use App\Filament\Resources\EbReadingResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewEbReading extends ViewRecord
{
protected static string $resource = EbReadingResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

View File

@@ -0,0 +1,200 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\GuardNameExporter;
use App\Filament\Imports\GuardNameImporter;
use App\Filament\Resources\GuardNameResource\Pages;
use App\Filament\Resources\GuardNameResource\RelationManagers;
use App\Models\GuardName;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
class GuardNameResource extends Resource
{
protected static ?string $model = GuardName::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Master Entries';
protected static ?int $navigationSort = 13;
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->required()
->reactive()
->default(function () {
return optional(GuardName::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
$set('GnError', 'Please select a plant first.');
return;
}
else
{
$set('GnError', null);
$set('created_by', Filament::auth()->user()?->name);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('GnError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('GnError') ? $get('GnError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('name')
->label('Name')
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->rule(function (callable $get) {
return Rule::unique('guard_names', 'name')
->where('plant_id', $get('plant_id'))
->ignore($get('id'));
}),
Forms\Components\TextInput::make('identification1')
->label('Aadhar Number')
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('identification2')
->label('PAN Number')
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
}),
Forms\Components\Hidden::make('created_by')
->default(fn () => Filament::auth()->user()?->name)
->required(),
Forms\Components\TextInput::make('id')
->hidden()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);
})
->readOnly(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
// Tables\Columns\TextColumn::make('id')
// ->label('ID')
// ->numeric()
// ->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('name')
->label('Guard')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(GuardNameImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import guard name');
}),
ExportAction::make()
->exporter(GuardNameExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export guard name');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListGuardNames::route('/'),
'create' => Pages\CreateGuardName::route('/create'),
'view' => Pages\ViewGuardName::route('/{record}'),
'edit' => Pages\EditGuardName::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Filament\Resources\GuardNameResource\Pages;
use App\Filament\Resources\GuardNameResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateGuardName extends CreateRecord
{
protected static string $resource = GuardNameResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\GuardNameResource\Pages;
use App\Filament\Resources\GuardNameResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditGuardName extends EditRecord
{
protected static string $resource = GuardNameResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\GuardNameResource\Pages;
use App\Filament\Resources\GuardNameResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListGuardNames extends ListRecords
{
protected static string $resource = GuardNameResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

Some files were not shown because too many files have changed in this diff Show More