207 Commits

Author SHA1 Message Date
dhanabalan
71f29243e2 Add route for retrieving GR PDFs in api.php 2025-09-27 14:35:40 +05:30
dhanabalan
388d91f8a4 Add getGRPdf method to PdfController for retrieving GR PDFs with authorization 2025-09-27 14:35:19 +05:30
dhanabalan
be892cb662 Add GrMasterPolicy class to manage authorization for GrMaster actions 2025-09-27 14:01:48 +05:30
dhanabalan
584d4faa07 Add GrMaster importer and exporter classes with column definitions and notification messages 2025-09-27 14:01:25 +05:30
dhanabalan
3f1b46873e Add GrMaster resource with CRUD pages and functionality for managing GR records 2025-09-27 14:00:31 +05:30
dhanabalan
9d69ce89ae Add GrMaster model with fillable attributes and relationships to Plant and Item 2025-09-27 13:59:19 +05:30
dhanabalan
e14814e529 Add migration for creating gr_masters table with necessary fields and foreign keys 2025-09-27 13:58:41 +05:30
dhanabalan
98feb7bfc5 Remove user3 seeding from UserSeeder to streamline user creation process 2025-09-27 13:42:21 +05:30
dhanabalan
998fbf814c Refactor validation logic in CreateInvoiceValidation to include additional checks for package types (use pack_slip if tube_sticker does not exist) and streamline code structure 2025-09-26 18:59:33 +05:30
dhanabalan
d2c7f85917 Fix validation for 'No of Operation' in resolveRecord method to include actual value in error message 2025-09-26 16:30:53 +05:30
dhanabalan
5b8bb29aeb Add validation for serial numbers in readFiles method and return error response for invalid entries 2025-09-26 12:09:41 +05:30
dhanabalan
b2cf4dc18e Refactor readFiles method to streamline CSV row processing and ensure unique remaining row is returned 2025-09-26 11:57:28 +05:30
dhanabalan
9774cda2ad Refactor readFiles method to enhance CSV row validation and ensure unique remaining rows are collected 2025-09-26 11:49:31 +05:30
dhanabalan
bbe05d62b1 Enhance readFiles method to validate CSV row structure and return error response for insufficient columns 2025-09-26 11:40:00 +05:30
dhanabalan
f353a699a2 Refactor readFiles method to handle file content processing and return structured response with serial numbers and remaining rows 2025-09-26 11:38:14 +05:30
dhanabalan
956c282005 Add debug response for file reading in readFiles method and improve error handling for file accessibility 2025-09-26 11:22:52 +05:30
dhanabalan
c9b5a59bf2 Refactor readFiles method to dynamically set file path and improve file handling 2025-09-26 11:16:06 +05:30
dhanabalan
086910122e Implement file reading and database insertion in readFiles method 2025-09-26 11:13:38 +05:30
dhanabalan
92a3b5a448 Refactor error responses in readFiles method to standardize status descriptions 2025-09-26 10:48:52 +05:30
dhanabalan
64237c3da0 Improve error handling in readFiles method for directory access and readability 2025-09-26 10:47:35 +05:30
dhanabalan
3d21975096 Validate plant code in readFiles method and update response structure 2025-09-26 10:43:52 +05:30
dhanabalan
0710c3a7a1 Add authorization check to readFiles method in SapFileController 2025-09-26 10:35:22 +05:30
dhanabalan
18eb234df4 Fix readFiles method to correctly concatenate file path for reading file contents 2025-09-26 10:30:58 +05:30
dhanabalan
8a3c0639ad Refactor readFiles method to improve .txt file filtering logic 2025-09-26 10:26:04 +05:30
dhanabalan
f50fbf5771 Fix readFiles method to add missing slash in file path for correct .txt file filtering 2025-09-26 10:22:23 +05:30
dhanabalan
3a115241a9 Fix readFiles method to add missing slash in file path for correct .txt file filtering 2025-09-26 10:21:07 +05:30
dhanabalan
062f35cb4d Fix readFiles method to correctly filter .txt files by adding missing slash in path 2025-09-26 10:15:34 +05:30
dhanabalan
062f143dbb Refactor readFiles method in SapFileController to streamline file filtering logic 2025-09-26 10:13:41 +05:30
dhanabalan
7406f4c97e Update readFiles method in SapFileController to change directory path and improve debug information 2025-09-26 10:06:29 +05:30
dhanabalan
831c88f0fd Add migration to enforce unique constraint on plant_id and serial_number in quality_validations table 2025-09-25 11:00:56 +05:30
dhanabalan
733cc45e60 Update readFiles method in SapFileController to change the directory path for file access 2025-09-23 12:17:23 +05:30
dhanabalan
0f3b516614 Update readFiles method in SapFileController to improve user identification in error responses 2025-09-23 10:55:56 +05:30
dhanabalan
8187aca5d4 Update readFiles method in SapFileController to enhance error reporting and adjust file path 2025-09-23 10:46:24 +05:30
dhanabalan
1d998d6478 Enhance readFiles method in SapFileController with improved error handling and debugging information 2025-09-23 09:48:24 +05:30
dhanabalan
86ad06def7 Refactor readFiles method in SapFileController for improved error handling and code clarity 2025-09-23 09:42:57 +05:30
dhanabalan
6a70b45f4f Refactor readFiles method in SapFileController for improved file handling and readability 2025-09-23 09:38:47 +05:30
dhanabalan
7e1852cfed Add SapFileController and route for reading SAP files 2025-09-23 09:34:17 +05:30
dhanabalan
7ca806449c Update export and import columns in TestingPanelReadingExporter and TestingPanelReadingImporter for improved data mapping 2025-09-21 16:00:08 +05:30
dhanabalan
90899c87f5 Remove commented-out route for characteristics master data in api.php 2025-09-21 15:50:18 +05:30
dhanabalan
fad3cf4ed6 Add relationships for equipment masters in Machine and Plant models 2025-09-21 15:46:01 +05:30
dhanabalan
2e7c37c6f1 Refactor export actions in TestingPanelReadingResource for improved readability and maintainability 2025-09-21 15:40:47 +05:30
dhanabalan
4c1950bf29 Fix indentation for dispatching warning sound in processInvoice method 2025-09-21 15:38:19 +05:30
dhanabalan
d13f502db8 Update ProcessOrderResource form fields and notification message 2025-09-21 15:35:25 +05:30
dhanabalan
4da6e97e6e Add EquipmentMasterController with authorization and equipment retrieval logic with relevant API 2025-09-21 15:32:18 +05:30
dhanabalan
f670793ff5 Add importer and exporter file for Equipment Masters 2025-09-21 15:24:30 +05:30
dhanabalan
2abc5199eb Add policy class for EquipmentMaster with permission checks 2025-09-21 15:23:02 +05:30
dhanabalan
d4192d3002 Add resource file for Equipment Masters 2025-09-21 15:21:37 +05:30
dhanabalan
eaba6b8396 Add model file for Equipment Masters 2025-09-21 15:18:23 +05:30
dhanabalan
237fb1a7b3 Add migration file for equipment masters 2025-09-21 15:14:44 +05:30
dhanabalan
b178130e8d Add searchable functionality to WorkGroupMaster table columns 2025-09-18 17:11:57 +05:30
dhanabalan
4c1a0a0282 Add warning notification sound: warning.mp3 2025-09-16 15:10:08 +05:30
dhanabalan
af719c2d33 Add audio notification sounds: click.mp3, ding.mp3, and scanner-beep.mp3 2025-09-16 15:05:12 +05:30
dhanabalan
bbd192148c Add NotificationSound Livewire component to create-invoice-validation page for audio notifications 2025-09-16 15:04:46 +05:30
dhanabalan
93b1138752 Add NotificationSound component and associated Blade view for audio notifications 2025-09-16 15:04:20 +05:30
dhanabalan
40ef91a60b Add notification sound dispatches in processInvoice and processSerialNumber methods for better user feedback 2025-09-16 15:01:52 +05:30
dhanabalan
012ce6d865 Add winded_serial_number to fillable attributes in TestingPanelReading model 2025-09-16 12:40:16 +05:30
dhanabalan
e8637874f4 Add winded_serial_number field to TestingPanelReadingResource form and table for enhanced data tracking 2025-09-16 12:39:27 +05:30
dhanabalan
5a7050a5b4 Add winded_serial_number to store method in TestingPanelController for enhanced data tracking 2025-09-16 12:04:50 +05:30
dhanabalan
24b9b5194a Add winded_serial_number column to testing_panel_readings table 2025-09-16 11:58:15 +05:30
dhanabalan
9a6e364f52 Refactored store method in TestingPanelController to improve validation for line and machine names, replacing Line model with WorkGroupMaster for accurate data handling. 2025-09-15 17:40:52 +05:30
dhanabalan
d4582292a4 Updated validation checks in WorkGroupMasterImporter to ensure name and operation number are not empty 2025-09-15 15:55:29 +05:30
dhanabalan
b222c78d4b Removed redundant unique rule for 'name' in WorkGroupMasterResource form validation for improved clarity 2025-09-15 15:53:08 +05:30
dhanabalan
d827c9368f Updated MachineController to replace 'line' with 'workGroupMaster' for accurate data retrieval to get all group and individual work center 2025-09-15 14:42:26 +05:30
dhanabalan
b48392a40c Updated navigation sort order for GuardNameResource and TestingPanelReadingResource for consistent display in the Master Entries and Testing Panel groups 2025-09-15 14:26:33 +05:30
dhanabalan
dc0b4ea75e Updated navigation sort order for CheckPointNameResource and CheckPointTimeResource for consistent display in the Master Entries group 2025-09-15 13:24:55 +05:30
dhanabalan
49fea7fcdb Updated column headers in ProductionQuantityImporter for consistency and clarity 2025-09-15 13:23:05 +05:30
dhanabalan
3848898f37 Refactored PalletValidationImporter by commenting out unused methods for clarity and maintainability 2025-09-15 13:20:55 +05:30
dhanabalan
4bb3b60391 Added work group center foreign key column to Machine export and import functionality with validation and error handling 2025-09-15 13:18:23 +05:30
dhanabalan
0381530463 Enhanced Line export and import functionality by adding multiple work group foreign key columns and no_of_operation field with validation. 2025-09-15 13:15:06 +05:30
dhanabalan
2244d82af0 Added no_of_operation field and work group center foreign key with validation in Line resource file 2025-09-15 12:59:10 +05:30
dhanabalan
594cc252a9 Added validation error handling in CreateLine page before record creation 2025-09-15 12:54:11 +05:30
dhanabalan
21bbbb24c2 Added no_of_operation and foreign key constraints for work group columns in line model for enhanced data association 2025-09-15 12:37:36 +05:30
dhanabalan
3b0501ef9e Added no_of_operation and foreign key constraints for work group columns in lines table 2025-09-15 12:29:58 +05:30
dhanabalan
23fa24ca46 Added workGroupMaster functionality in resource and Updated navigation sort 2025-09-15 12:27:10 +05:30
dhanabalan
55c0ebfa6d Added workGroupMaster foreignKey and belongsTo relationship to Machine model 2025-09-15 12:20:59 +05:30
dhanabalan
db3a69d47f Add workGroupMasters hasMany relationship to Plant model and comment out rejectReasons method 2025-09-15 12:18:41 +05:30
dhanabalan
5ba9db0278 Added migration to create work_group_master_id foreign key and plant with work_center unique constraint for machines table 2025-09-15 12:14:25 +05:30
dhanabalan
6a195d00c5 Remove group_work_center column from lines table 2025-09-15 12:07:20 +05:30
dhanabalan
386b9c4a09 Added importer and exporter file for work group masters 2025-09-15 11:57:27 +05:30
dhanabalan
853a1542bb Add WorkGroupMasterPolicy to manage permissions for WorkGroupMaster models 2025-09-15 11:47:17 +05:30
dhanabalan
d3e9237bff Add ProcessOrderPolicy to manage permissions for ProcessOrder models 2025-09-15 11:46:46 +05:30
dhanabalan
c76ae58118 Added resource file for work group masters 2025-09-15 11:41:13 +05:30
dhanabalan
d2fc4e0b40 Added model file for work group masters 2025-09-15 11:05:50 +05:30
dhanabalan
bd1d7e61b4 Add migration file for work group masters 2025-09-15 10:50:58 +05:30
dhanabalan
bac7c610f8 Refactor QualityValidationImporter to improve record uniqueness on update logic 2025-09-13 11:16:22 +05:30
dhanabalan
36006e6e08 Uncomment testing routes for user data retrieval and machine data access 2025-09-10 16:59:23 +05:30
dhanabalan
319aea377a Update file path in getPdf method to use ProcessOrder directory for PDF retrieval 2025-09-10 15:59:42 +05:30
dhanabalan
444b4a4804 Add smalot/pdfparser dependency for PDF parsing functionality 2025-09-10 15:27:40 +05:30
dhanabalan
21e048549d Add PdfController with getPdf method for PDF retrieval and authorization handling 2025-09-10 15:24:54 +05:30
dhanabalan
ba453ef505 Add PDF retrieval route and clean up commented testing routes in api.php 2025-09-10 15:22:49 +05:30
dhanabalan
e5a3d212d0 Add ProcessOrder resource with CRUD pages and form handling 2025-09-10 15:18:17 +05:30
dhanabalan
367d103c75 Add ProcessOrder model with fillable attributes and relationships 2025-09-10 15:16:51 +05:30
dhanabalan
365d5b19ab Add migration for process_orders table with necessary fields and foreign keys 2025-09-10 15:14:39 +05:30
dhanabalan
8c488e1ced Enhance MotorTestingMasterResource with advanced filtering options and improved form validation 2025-09-10 10:30:09 +05:30
dhanabalan
1bd14d5f73 Update MotorTestingMasterExporter and MotorTestingMasterImporter to use plant code and improve validation logic 2025-09-10 10:24:07 +05:30
dhanabalan
aaa162a3f2 Remove commented-out 'asc' parameter from created_at orderBy in QualityValidationResource table query 2025-09-10 08:55:36 +05:30
dhanabalan
8813567f0b Add missing created_at and updated_at fields to fillable attributes in ProductionQuantity model 2025-09-09 19:03:13 +05:30
dhanabalan
ffa2b1f783 Remove redundant 'asc' parameter from created_at orderBy in QualityValidationResource table query 2025-09-09 18:01:19 +05:30
dhanabalan
e29c16c79a Add sorting by created_at in QualityValidationResource table query 2025-09-09 17:55:53 +05:30
dhanabalan
4d516e955c added created_at and updated_at column in quality validation model 2025-09-09 10:56:22 +05:30
dhanabalan
b0d73dbbc6 Add searchable functionality to line name column in QualityValidationResource table 2025-09-09 10:39:20 +05:30
dhanabalan
37c91afe25 Rename subassembly_code to mot_subassembly_code in get_motor_master method for clarity 2025-09-09 10:23:58 +05:30
dhanabalan
77064399cd Update example header for line column in ConfigurationImporter 2025-09-09 08:41:22 +05:30
dhanabalan
3398a60d1b Update label for laser part validation input in StickerMasterResource 2025-09-06 16:25:52 +05:30
dhanabalan
65aafbeb65 Add required validation to load rate input in StickerMasterResource resource 2025-09-06 16:16:35 +05:30
dhanabalan
ad72d38193 Update plant column references in ConfigurationExporter and ConfigurationImporter to use 'code' instead of 'name' 2025-09-06 11:30:07 +05:30
dhanabalan
cac91722c3 Refactor form schema in StickerMasterResource for improved clarity and organization 2025-09-05 17:27:24 +05:30
dhanabalan
bb2b81d0f2 updated header name for leak current limit in motor testing master 2025-09-05 14:41:27 +05:30
dhanabalan
2150f6098f Added required isi model column for motor testing importer and exporter 2025-09-05 14:32:47 +05:30
dhanabalan
a0a1e87440 Added subassembly code to motor master output in TestingPanelController 2025-09-05 14:03:54 +05:30
dhanabalan
8da3c746b9 Added sub assembly column in import and export 2025-09-05 09:35:06 +05:30
dhanabalan
d05623f920 Added subassembly code in resource page of motor testing master 2025-09-05 09:33:16 +05:30
dhanabalan
e3d29cba81 Added subassembly code in model file in motor testing master 2025-09-05 09:31:06 +05:30
dhanabalan
5cbae18532 Added subassembly code column motor testing master 2025-09-05 09:28:50 +05:30
dhanabalan
7e688683d7 corrected bundle logic for invoice quantity 2025-08-27 08:37:21 +05:30
dhanabalan
ab5a8c0874 Removed unwanted column in bundle data in invoice mail 2025-08-26 19:06:51 +05:30
dhanabalan
19e1f12f5d Refactor invoice report generation to include quantity metrics and enhance email content structure 2025-08-26 18:08:06 +05:30
dhanabalan
e57962f023 Merge branch 'master' of ssh://172.31.31.31:2222/poc/pds 2025-08-26 18:01:43 +05:30
dhanabalan
c5a730b71d Added roles column in view reports and Refactor User table columns for improved sorting and searching functionality 2025-08-26 17:57:16 +05:30
root
967a429595 Merge branch 'master' of https://git.iotsignin.com/poc/pds 2025-08-26 16:35:02 +05:30
root
7f0d138383 WIP: local changes before pull 2025-08-26 16:21:53 +05:30
dhanabalan
d5c0303be4 Merge branch 'master' of ssh://172.31.31.31:2222/poc/pds 2025-08-26 16:10:31 +05:30
dhanabalan
c2f9b77e1f Create motor_testing_masters table with comprehensive fields for motor testing data 2025-08-26 16:09:10 +05:30
3053098cfb Updated file name to work migration functionality in order 2025-08-26 10:32:46 +00:00
a5ded4a20a Added plant column with BIGINT type and its default value as 0 2025-08-26 10:25:05 +00:00
dhanabalan
d419973ab5 Add getRedirectUrl method to resource creation classes for consistent redirection 2025-08-26 15:44:51 +05:30
dhanabalan
86e458037f Removed unnecessary lines in alert_mail_rules table 2025-08-25 20:09:24 +05:30
dhanabalan
e6ba543589 Added roles on UserExporter and UserImporter for consistency and enhanced functionality 2025-08-25 17:00:00 +05:30
dhanabalan
1cee8dc71d Enhance item description field to auto-populate based on selected item ID 2025-08-25 12:17:49 +05:30
dhanabalan
3a009543ea Update MachineResource refine line selection logic 2025-08-25 11:43:09 +05:30
dhanabalan
d4045b7b0f Update validation for line stop code to require a minimum length of 3 characters 2025-08-22 14:47:01 +05:30
dhanabalan
a831f6e787 Testing 2025-08-21 18:07:08 +05:30
dhanabalan
b399141c7e Add UserExporter and UserImporter classes with export/import functionality 2025-08-21 17:07:34 +05:30
dhanabalan
8fd2212ec4 Refactor PermissionSeeder to update permissions for user, plant, and block views 2025-08-21 16:32:32 +05:30
dhanabalan
e6f78c60d5 Fix email address for admin in UserSeeder 2025-08-21 16:07:43 +05:30
dhanabalan
a3a421af88 Added logic in quality validation screen to scan capacitor qr code in part validation 5 2025-08-21 14:06:23 +05:30
dhanabalan
d4eeee7d05 Refactor root redirect logic to simplify default behavior 2025-08-20 19:53:01 +05:30
dhanabalan
bd17af8945 Update root redirect logic to handle specific host 2025-08-20 19:49:28 +05:30
dhanabalan
95f1e09304 Added policy file for eb reading 2025-08-12 17:27:36 +05:30
dhanabalan
fc42e7db6c Add TempLiveReadingResource files from qds branch 2025-08-12 17:21:22 +05:30
dhanabalan
0d3e58e7af Add EbReadingImporter and EbReadingExporter from qds branch 2025-08-12 17:18:02 +05:30
dhanabalan
658d7cb42c Add EbReadingResource related files from qds branch 2025-08-12 17:14:40 +05:30
dhanabalan
679d532b17 Add EbReading.php model file from qds branch 2025-08-12 17:07:54 +05:30
dhanabalan
50ddd51f04 Add eb_readings migration from qds branch 2025-08-12 16:52:39 +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
187 changed files with 14496 additions and 1923 deletions

View File

@@ -30,258 +30,17 @@ class SendInvoiceReport extends Command
* Execute the console command.
*/
// public function handle()
// {
// $schedule = $this->argument('schedule_type');
// $plantid = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $plants = InvoiceValidation::select('plant_id')->distinct()->pluck('plant_id');
// $serialTableData = [];
// $materialTableData = [];
// $bundleTableData = [];
// $noSerial = 1;
// $noMaterial = 1;
// $noBundle = 1;
// foreach ($plants as $plantId) {
// $plant = Plant::find($plantId);
// $plantName = $plant ? $plant->name : $plantId;
// //..Serial Invoice
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
// )
// ->count();
// $serialTableData[] = [
// 'no' => $noSerial++,
// 'plant' => $plantName,
// 'totalInvoice' => $totalSerialCount,
// 'scannedInvoice' => $scannedSerialCount,
// ];
// //..Individual Invoice
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedMatCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $materialTableData[] = [
// 'no' => $noMaterial++,
// 'plant' => $plantName,
// 'totalInvoice' => $TotalMatCount,
// 'scannedInvoice' => $scannedMatCount,
// ];
// //..BUndle Invoice
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $bundleTableData[] = [
// 'no' => $noBundle++,
// 'plant' => $plantName,
// 'totalInvoice' => $totalBundleCount,
// 'scannedInvoice' => $scannedBundleCount,
// ];
// }
// // Send to SerialInvoiceMail recipients
// if ($mailRules->has('SerialInvoiceMail')) {
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, [], []));
// }
// }
// // Send to MaterialInvoiceMail recipients (material + bundle table)
// if ($mailRules->has('MaterialInvoiceMail')) {
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
// }
// }
// // Send to InvoiceMail recipients (all three tables)
// if ($mailRules->has('InvoiceMail')) {
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
// }
// }
// //$this->info(json_encode($materialTableData));
// }
// public function handle()
// {
// $schedule = $this->argument('schedule_type');
// $plantId = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $serialTableData = [];
// $materialTableData = [];
// $bundleTableData = [];
// $plant = Plant::find($plantId);
// $plantName = $plant ? $plant->name : $plantId;
// // Serial Invoice
// $totalSerialCount = InvoiceValidation::where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedSerialCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->whereNull('quantity')
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)"
// )
// ->count();
// $serialTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $totalSerialCount,
// 'scannedInvoice' => $scannedSerialCount,
// ];
// // Individual Material Invoice
// $TotalMatCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedMatCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $materialTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $TotalMatCount,
// 'scannedInvoice' => $scannedMatCount,
// ];
// // Bundle Invoice
// $totalBundleCount = InvoiceValidation::where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->distinct('invoice_number')
// ->count('invoice_number');
// $scannedBundleCount = InvoiceValidation::select('invoice_number')
// ->where('plant_id', $plantId)
// ->where('quantity', '>', 1)
// ->whereBetween('updated_at', [$startDate, $endDate])
// ->groupBy('invoice_number')
// ->havingRaw(
// "COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)"
// )
// ->count();
// $bundleTableData[] = [
// 'no' => 1,
// 'plant' => $plantName,
// 'totalInvoice' => $totalBundleCount,
// 'scannedInvoice' => $scannedBundleCount,
// ];
// // Send to SerialInvoiceMail recipients
// if ($mailRules->has('SerialInvoiceMail')) {
// $emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, [], []));
// }
// }
// // Send to MaterialInvoiceMail recipients (material + bundle table)
// if ($mailRules->has('MaterialInvoiceMail')) {
// $emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
// }
// }
// // Send to InvoiceMail recipients (all three tables)
// if ($mailRules->has('InvoiceMail')) {
// $emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
// foreach ($emails as $email) {
// Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
// }
// }
// // $this->table(
// // ['No', 'Plant', 'Total Invoice', 'Scanned Invoice'],
// // $serialTableData
// // );
// }
public function handle()
{
$schedule = $this->argument('schedule_type');
//$scheduleType = $this->argument('scheduleType');
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
$startDate = now()->setTime(8, 0, 0);
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
$serialTableData = [];
$materialTableData = [];
@@ -293,7 +52,18 @@ class SendInvoiceReport extends Command
: [$plantIdArg];
$no = 1;
foreach ($plantIds as $plantId) {
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;
@@ -312,11 +82,27 @@ class SendInvoiceReport extends Command
->havingRaw("COUNT(*) = SUM(CASE WHEN scanned_status = 'Scanned' THEN 1 ELSE 0 END)")
->count();
$serialInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', null)
->whereBetween('created_at', [$startDate, $endDate])
->count();
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('scanned_status', 'Scanned')
->where(function($query) {
$query->whereNull('quantity')
->orWhere('quantity', 0);
})
->whereBetween('updated_at', [$startDate, $endDate])
->count();
$serialTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalSerialCount,
'scannedInvoice' => $scannedSerialCount,
'totalInvoiceQuan' => $serialInvoiceQuan,
'scannedInvoiceQuan' => $scannedInvoiceQuan,
];
// Material Invoice
@@ -334,11 +120,25 @@ class SendInvoiceReport extends Command
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
->count();
$totalMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', 1)
->whereBetween('created_at', [$startDate, $endDate])
->count();
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', 1)
->whereNotNull('serial_number')
->where('serial_number','!=', '')
->whereBetween('updated_at', [$startDate, $endDate])
->count();
$materialTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalMatCount,
'scannedInvoice' => $scannedMatCount,
'totalInvoiceQuan' => $totalMatInvoiceQuan,
'scannedInvoiceQuan' => $scannedMatInvoiceQuan,
];
// Bundle Invoice
@@ -356,29 +156,49 @@ class SendInvoiceReport extends Command
->havingRaw("COUNT(*) = SUM(CASE WHEN serial_number IS NOT NULL AND serial_number != '' THEN 1 ELSE 0 END)")
->count();
$totalBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereBetween('created_at', [$startDate, $endDate])
->count();
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
->where('quantity', '>', 1)
->whereNotNull('serial_number')
->where('serial_number','!=', '')
->whereBetween('updated_at', [$startDate, $endDate])
->count();
$bundleTableData[] = [
'no' => $no,
'plant' => $plantName,
'totalInvoice' => $totalBundleCount,
'scannedInvoice' => $scannedBundleCount,
'totalInvoiceQuan' => $totalBundleInvoiceQuan,
'scannedInvoiceQuan' => $scannedBundleInvoiceQuan,
];
$no++;
}
$mail = new test($serialTableData, $materialTableData, $bundleTableData, $schedule);
$contentVars = $mail->content()->with;
$this->info($contentVars['greeting'] ?? 'Invoice Report');
// Send to SerialInvoiceMail recipients
if ($mailRules->has('SerialInvoiceMail')) {
$emails = $mailRules['SerialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, [], []));
Mail::to($email)->send(new test($serialTableData, [], [], $schedule));
}
}
// Send to MaterialInvoiceMail recipients (material + bundle table)
if ($mailRules->has('MaterialInvoiceMail')) {
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData));
Mail::to($email)->send(new test([], $materialTableData, $bundleTableData, $schedule));
}
}
@@ -386,19 +206,21 @@ class SendInvoiceReport extends Command
if ($mailRules->has('InvoiceMail')) {
$emails = $mailRules['InvoiceMail']->pluck('email')->unique()->toArray();
foreach ($emails as $email) {
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData));
Mail::to($email)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
}
}
// Show preview in console
$this->info('--- Serial Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $serialTableData);
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
$this->info('--- Material Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $materialTableData);
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
$this->info('--- Bundle Invoice Table ---');
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice'], $bundleTableData);
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
$this->info($contentVars['wishes'] ?? '');
}

View File

@@ -33,77 +33,6 @@ class SendProductionReport extends Command
* Execute the console command.
*/
// public function handle()
// {
// $scheduleType = $this->argument('schedule_type');
// $plantId = $this->argument('plant');
// $mailRules = \App\Models\AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->where('plant', $plantId)
// ->where('schedule_type', $scheduleType)
// ->get();
// $emails = $mailRules->pluck('email')->unique()->toArray();
// $plant = Plant::find($plantId);
// if (!$plant) {
// $this->error("Invalid plant ID: $plantId");
// return;
// }
// $lines = Line::where('plant_id', $plantId)->get();
// $startDate = now()->setTime(8, 0, 0);
// $endDate = now()->copy()->addDay()->setTime(8, 0, 0);
// $PlanstartDate = now()->setTime(8, 0, 0);
// $planendDate = now()->copy()->addDay()->setTime(7, 59, 00);
// $tableData = [];
// $no = 1;
// foreach ($lines as $line) {
// $lineId = $line->id;
// $lineName = $line->name;
// $targetQuantity = ProductionPlan::where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
// ->sum('plan_quantity');
// $productionQuantity = ProductionQuantity::where('plant_id', $plantId)
// ->where('line_id', $lineId)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $tableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $lineName,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $productionQuantity,
// ];
// }
// // $this->table(
// // ['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'],
// // $tableData
// // );
// if (!empty($emails)) {
// foreach ($emails as $email) {
// Mail::to($email)->send(new ProductionMail($tableData));
// }
// } else {
// $this->info('No recipients found for ProductionMailAlert.');
// }
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
// }
public function handle()
{
$scheduleType = $this->argument('schedule_type');
@@ -146,53 +75,7 @@ class SendProductionReport extends Command
$tableData = [];
$no = 1;
// foreach ($plants as $plant) {
// $lines = Line::where('plant_id', $plant->id)->get();
// foreach ($lines as $line) {
// $targetQuantity = ProductionPlan::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$PlanstartDate, $planendDate])
// ->sum('plan_quantity');
// $productionQuantity = ProductionQuantity::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $tableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $line->name,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $productionQuantity,
// ];
// }
// }
// $fgTableData = []; // store FG Line related data
// foreach ($plants as $plant) {
// // ✅ Only get FG Lines
// $fgLines = Line::where('plant_id', $plant->id)
// ->where('type', 'FG Line')
// ->get();
// foreach ($fgLines as $line) {
// $validationCount = \App\Models\QualityValidation::where('plant_id', $plant->id)
// ->where('line_id', $line->id)
// ->whereBetween('created_at', [$startDate, $endDate])
// ->count();
// $fgTableData[] = [
// 'no' => $no++,
// 'plant' => $plant->name,
// 'line' => $line->name,
// 'targetQuantity' => $targetQuantity,
// 'productionQuantity' => $validationCount,
// ];
// }
// }
//.
foreach ($plants as $plant)
{
@@ -204,7 +87,7 @@ class SendProductionReport extends Command
->whereBetween('created_at', [$PlanstartDate, $planendDate])
->sum('plan_quantity');
if (strtolower($line->type) === 'fg line') {
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])
@@ -220,6 +103,7 @@ class SendProductionReport extends Command
'no' => $no++,
'plant' => $plant->name,
'line' => $line->name,
'type' => $line->type,
'targetQuantity' => $targetQuantity,
'productionQuantity' => $productionQuantity,
];
@@ -228,20 +112,38 @@ class SendProductionReport extends Command
///$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
//$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $fgTableData);
$this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
// $this->table(['No', 'Plant', 'Line', 'Target Quantity', 'Production Quantity'], $tableData);
// if (!empty($emails)) {
// foreach ($emails as $email) {
// Mail::to($email)->send(new ProductionMail($tableData));
// }
// } else {
// $this->info('No recipients found for ProductionMailAlert.');
// }
// $this->info("Production report sent to " . count($emails) . " recipient(s).");
// Preview in console
$mail = new ProductionMail($scheduleType, $tableData);
$contentVars = $mail->content()->with;
$this->info($contentVars['greeting'] ?? 'Production Report');
$this->table(
['No', 'Plant', 'Line', 'Type', 'Target Quantity', 'Production Quantity'],
$tableData
);
$this->info($contentVars['wishes'] ?? '');
// Send mails
if (!empty($emails)) {
foreach ($emails as $email) {
Mail::to($email)->send(new ProductionMail($tableData));
Mail::to($email)->send(new ProductionMail($scheduleType, $tableData));
}
$this->info("Production report sent to " . count($emails) . " recipient(s).");
} else {
$this->info('No recipients found for ProductionMailAlert.');
$this->warn('No recipients found for ProductionMailAlert.');
}
$this->info("Production report sent to " . count($emails) . " recipient(s).");
}
}

View File

@@ -22,7 +22,7 @@ class ConfigurationExporter extends Exporter
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
ExportColumn::make('plant.code')
->label('PLANT'),
ExportColumn::make('line.name')
->label('LINE'),

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,74 @@
<?php
namespace App\Filament\Exports;
use App\Models\EquipmentMaster;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class EquipmentMasterExporter extends Exporter
{
protected static ?string $model = EquipmentMaster::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('machine.name')
->label('MACHINE NAME'),
ExportColumn::make('name')
->label('NAME'),
ExportColumn::make('description')
->label('DESCRIPTION'),
ExportColumn::make('make')
->label('MAKE'),
ExportColumn::make('model')
->label('MODEL'),
ExportColumn::make('equipment_number')
->label('EQUIPMENT NUMBER'),
ExportColumn::make('instrument_serial_number')
->label('INSTRUMENT SERIAL NUMBER'),
ExportColumn::make('calibrated_on')
->label('CALIBRATED ON'),
ExportColumn::make('frequency')
->label('FREQUENCY'),
ExportColumn::make('next_calibration_date')
->label('NEXT CALIBRATION DATE'),
ExportColumn::make('calibrated_by')
->label('CALIBRATED BY'),
ExportColumn::make('calibration_certificate')
->label('CALIBRATION CERTIFICATE'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your equipment master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Filament\Exports;
use App\Models\GrMaster;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class GrMasterExporter extends Exporter
{
protected static ?string $model = GrMaster::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('item.code')
->label('ITEM'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('gr_number')
->label('GR NUMBER'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->label('DELETED AT')
->enabledByDefault(false),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your gr master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

@@ -30,8 +30,48 @@ class LineExporter extends Exporter
->label('NAME'),
ExportColumn::make('type')
->label('TYPE'),
ExportColumn::make('group_work_center')
->label('GROUP WORK CENTER'),
ExportColumn::make('no_of_operation')
->label('NO OF OPERATION'),
ExportColumn::make('workGroup1.name')
->label('WORK GROUP CENTER 1'),
ExportColumn::make('workGroup1.operation_number')
->label('OPERATION NUMBER 1'),
ExportColumn::make('workGroup2.name')
->label('WORK GROUP CENTER 2'),
ExportColumn::make('workGroup2.operation_number')
->label('OPERATION NUMBER 2'),
ExportColumn::make('workGroup3.name')
->label('WORK GROUP CENTER 3'),
ExportColumn::make('workGroup3.operation_number')
->label('OPERATION NUMBER 3'),
ExportColumn::make('workGroup4.name')
->label('WORK GROUP CENTER 4'),
ExportColumn::make('workGroup4.operation_number')
->label('OPERATION NUMBER 4'),
ExportColumn::make('workGroup5.name')
->label('WORK GROUP CENTER 5'),
ExportColumn::make('workGroup5.operation_number')
->label('OPERATION NUMBER 5'),
ExportColumn::make('workGroup6.name')
->label('WORK GROUP CENTER 6'),
ExportColumn::make('workGroup6.operation_number')
->label('OPERATION NUMBER 6'),
ExportColumn::make('workGroup7.name')
->label('WORK GROUP CENTER 7'),
ExportColumn::make('workGroup7.operation_number')
->label('OPERATION NUMBER 7'),
ExportColumn::make('workGroup8.name')
->label('WORK GROUP CENTER 8'),
ExportColumn::make('workGroup8.operation_number')
->label('OPERATION NUMBER 8'),
ExportColumn::make('workGroup9.name')
->label('WORK GROUP CENTER 9'),
ExportColumn::make('workGroup9.operation_number')
->label('OPERATION NUMBER 9'),
ExportColumn::make('workGroup10.name')
->label('WORK GROUP CENTER 10'),
ExportColumn::make('workGroup10.operation_number')
->label('OPERATION NUMBER 10'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')

View File

@@ -30,6 +30,8 @@ class MachineExporter extends Exporter
->label('MACHINE'),
ExportColumn::make('work_center')
->label('WORK CENTER'),
ExportColumn::make('workGroupMaster.name')
->label('WORK GROUP CENTER'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')

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

@@ -13,20 +13,40 @@ class MfmParameterExporter extends Exporter
public static function getColumns(): array
{
static $rowNumber = 0;
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('plant.name'),
ExportColumn::make('name'),
ExportColumn::make('register_id'),
ExportColumn::make('identifier'),
ExportColumn::make('byte_to_convert'),
ExportColumn::make('type_to_convert'),
ExportColumn::make('decimal_to_display'),
ExportColumn::make('created_at'),
ExportColumn::make('updated_at'),
ExportColumn::make('deleted_at'),
ExportColumn::make('mfmMeter.name'),
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),
];
}

View File

@@ -22,12 +22,14 @@ class MotorTestingMasterExporter extends Exporter
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('plant.name')
ExportColumn::make('plant.code')
->label('PLANT'),
ExportColumn::make('item.category')
->label('CATEGORY'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('subassembly_code')
->label('SUBASSEMBLY CODE'),
ExportColumn::make('item.description')
->label('DESCRIPTION'),
ExportColumn::make('isi_model')
@@ -69,9 +71,9 @@ class MotorTestingMasterExporter extends Exporter
ExportColumn::make('res_br_ul')
->label('RESISTANCE BR UL'),
ExportColumn::make('lock_volt_limit')
->label('LOCK VOLT Limit'),
->label('LOCK VOLT LIMIT'),
ExportColumn::make('leak_cur_limit')
->label('Leak CURRENT Limit'),
->label('LEAK CURRENT LIMIT'),
ExportColumn::make('lock_cur_ll')
->label('LOCK CURRENT LL'),
ExportColumn::make('lock_cur_ul')

View File

@@ -30,23 +30,25 @@ class TestingPanelReadingExporter extends Exporter
->label('LINE'),
ExportColumn::make('machine.name')
->label('MACHINE'),
ExportColumn::make('item.code')
ExportColumn::make('motorTestingMaster.item.code')
->label('ITEM CODE'),
ExportColumn::make('item.description')
ExportColumn::make('motorTestingMaster.item.description')
->label('MODEL'),
ExportColumn::make('output')
->label('OUTPUT'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('item.kw')
ExportColumn::make('winded_serial_number')
->label('WINDED SERIAL NUMBER'),
ExportColumn::make('motorTestingMaster.kw')
->label('KW'),
ExportColumn::make('item.hp')
ExportColumn::make('motorTestingMaster.hp')
->label('HP'),
ExportColumn::make('item.phase')
ExportColumn::make('motorTestingMaster.phase')
->label('PHASE'),
ExportColumn::make('item.connection')
ExportColumn::make('motorTestingMaster.connection')
->label('CONNECTION'),
ExportColumn::make('item.isi_model')
ExportColumn::make('motorTestingMaster.isi_model')
->label('ISI MODEL'),
ExportColumn::make('before_fr_volt')
->label('BEFORE FR VOLT'),

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Filament\Exports;
use App\Models\User;
use Filament\Actions\Exports\ExportColumn;
use Filament\Actions\Exports\Exporter;
use Filament\Actions\Exports\Models\Export;
class UserExporter extends Exporter
{
protected static ?string $model = User::class;
public static function getColumns(): array
{
static $rowNumber = 0;
return [
// ExportColumn::make('id')
// ->label('ID'),
ExportColumn::make('no')
->label('NO')
->state(function ($record) use (&$rowNumber) {
// Increment and return the row number
return ++$rowNumber;
}),
ExportColumn::make('name')
->label('NAME'),
ExportColumn::make('email')
->label('E-MAIL'),
ExportColumn::make('password')
->label('PASSWORD'),
ExportColumn::make('roles')
->label('ROLES')
->state(function ($record) {
// Assuming Spatie\Permission: roles() relationship
return $record->roles->pluck('name')->join(', ');
}),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}
public static function getCompletedNotificationBody(Export $export): string
{
$body = 'Your user export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
}
return $body;
}
}

View File

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

View File

@@ -41,15 +41,15 @@ class ConfigurationImporter extends Importer
ImportColumn::make('line')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Plant')
->exampleHeader('Line')
->example(['4 inch pump line'])
->label('Line')
->rules(['required']),
ImportColumn::make('plant')
->requiredMapping()
->relationship(resolveUsing: 'name')
->relationship(resolveUsing: 'code')
->exampleHeader('Plant')
->example(['Ransar Industries-I'])
->example(['1000'])
->label('Plant')
->rules(['required']),
];

View File

@@ -0,0 +1,69 @@
<?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')
->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,109 @@
<?php
namespace App\Filament\Imports;
use App\Models\EquipmentMaster;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class EquipmentMasterImporter extends Importer
{
protected static ?string $model = EquipmentMaster::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('machine')
->requiredMapping()
->exampleHeader('Machine Name')
->example('1006378')
->label('Machine Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('name')
->label('Name')
->exampleHeader('Name')
->example('463605 E-E-078'),
ImportColumn::make('description')
->label('Description')
->exampleHeader('Description')
->example('FIN.6INCH.HOUSING LOWER 150R3+ CI RUN-OUT CHECKING FIXTURE'),
ImportColumn::make('make')
->label('Make')
->exampleHeader('Make')
->example('Ok'),
ImportColumn::make('model')
->label('Model')
->exampleHeader('Model')
->example('Ok'),
ImportColumn::make('equipment_number')
->label('Equipment Number')
->exampleHeader('Equipment Number')
->example('463605 E-E-078'),
ImportColumn::make('instrument_serial_number')
->label('Instrument Serial Number')
->exampleHeader('Instrument Serial Number')
->example('131548498'),
ImportColumn::make('calibrated_on')
->label('Calibrated On')
->exampleHeader('Calibrated On')
->example('01-09-2025 08:00:00')
->requiredMapping()
->rules(['required', 'datetime']),
ImportColumn::make('frequency')
->label('Frequency')
->exampleHeader('Frequency')
->example('15')
->requiredMapping()
->numeric()
->rules(['required', 'integer']),
ImportColumn::make('next_calibration_date')
->label('Next Calibration Date')
->exampleHeader('Next Calibration Date')
->requiredMapping()
->example('16-09-2025 08:00:00')
->rules(['required', 'datetime']),
ImportColumn::make('calibrated_by')
->label('Calibration By')
->example('Sri Venkateswara Tools')
->exampleHeader('Calibration By'),
ImportColumn::make('calibration_certificate')
->label('Calibration Certificate')
->example('1231CRI651')
->exampleHeader('Calibration Certificate'),
ImportColumn::make('created_by')
->label('Created By')
->example('RAS00296')
->exampleHeader('Created By'),
];
}
public function resolveRecord(): ?EquipmentMaster
{
// return EquipmentMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new EquipmentMaster();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your equipment master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Filament\Imports;
use App\Models\GrMaster;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
class GrMasterImporter extends Importer
{
protected static ?string $model = GrMaster::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('item')
->requiredMapping()
->exampleHeader('Item Code')
->example('630214')
->label('Item Code')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('serial_number')
->requiredMapping()
->exampleHeader('Serial Number')
->example('11023567567567')
->label('Serial Number')
->rules(['required']),
ImportColumn::make('gr_number')
->requiredMapping()
->exampleHeader('GR Number')
->example('67345237')
->label('GR Number')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('Admin')
->label('Created By')
->rules(['required']),
//ImportColumn::make('updated_by'),
];
}
public function resolveRecord(): ?GrMaster
{
// return GrMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new GrMaster();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your gr master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Filament\Imports;
use App\Models\Line;
use App\Models\Plant;
use App\Models\WorkGroupMaster;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
@@ -29,11 +30,61 @@ class LineImporter extends Importer
->example('Domestic Assembly')
->label('Line Type')
->rules(['required']),
ImportColumn::make('group_work_center')
ImportColumn::make('no_of_operation')
->requiredMapping()
->exampleHeader('Group Work Center')
->example('RMGCEABC')
->label('Group Work Center'),
->exampleHeader('No of Operation')
->example('10')
->label('No of Operation'),
ImportColumn::make('work_group1_id')
->requiredMapping()
->exampleHeader('Work Group Center 1')
->example('RMGCGABC')
->label('Work Group Center 1'),
ImportColumn::make('work_group2_id')
->requiredMapping()
->exampleHeader('Work Group Center 2')
->example('RMGCGABC1')
->label('Work Group Center 2'),
ImportColumn::make('work_group3_id')
->requiredMapping()
->exampleHeader('Work Group Center 3')
->example('RMGCGABC2')
->label('Work Group Center 3'),
ImportColumn::make('work_group4_id')
->requiredMapping()
->exampleHeader('Work Group Center 4')
->example('RMGCGABC1')
->label('Work Group Center 4'),
ImportColumn::make('work_group5_id')
->requiredMapping()
->exampleHeader('Work Group Center 5')
->example('RMGCGABC5')
->label('Work Group Center 5'),
ImportColumn::make('work_group6_id')
->requiredMapping()
->exampleHeader('Work Group Center 6')
->example('RMGCGABC6')
->label('Work Group Center 6'),
ImportColumn::make('work_group7_id')
->requiredMapping()
->exampleHeader('Work Group Center 7')
->example('RMGCGABC7')
->label('Work Group Center 7'),
ImportColumn::make('work_group8_id')
->requiredMapping()
->exampleHeader('Work Group Center 8')
->example('RMGCGABC8')
->label('Work Group Center 8'),
ImportColumn::make('work_group9_id')
->requiredMapping()
->exampleHeader('Work Group Center 9')
->example('RMGCGABC9')
->label('Work Group Center 9'),
ImportColumn::make('work_group10_id')
->requiredMapping()
->exampleHeader('Work Group Center 10')
->example('RMGCGABC10')
->label('Work Group Center 10'),
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
@@ -47,34 +98,110 @@ class LineImporter extends Importer
public function resolveRecord(): ?Line
{
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
throw new RowImportFailedException("Plant '{$this->data['plant']}' not found");
}
if (Str::length($this->data['name']) < 0) {
$warnMsg[] = "Line name not found";
if (Str::length($this->data['name'] ?? '') <= 0) {
throw new RowImportFailedException("Line name not found");
}
if (Str::length($this->data['type']) < 0) {
$warnMsg[] = "Line type not found";
if (Str::length($this->data['type'] ?? '') <= 0) {
throw new RowImportFailedException("Line type not found");
}
if (!empty($warnMsg)) {
$noOfOps = (int) ($this->data['no_of_operation'] ?? 0);
if (($noOfOps == null || $noOfOps == '' || !is_numeric($noOfOps)) && $noOfOps != 0) {
throw new RowImportFailedException("'No of Operation' is required and must be a number $noOfOps");
}
if ($noOfOps > 10)
{
throw new RowImportFailedException("Invalid 'No Of Operation' value: {$noOfOps}, maximum allowed is 10");
}
// Validate required work groups
$missingGroups = [];
for ($i = 1; $i <= $noOfOps; $i++) {
if (empty($this->data["work_group{$i}_id"])) {
$missingGroups[] = "work_group{$i}_id";
}
}
if (!empty($missingGroups)) {
throw new RowImportFailedException(
"Invalid data: Required work groups missing values in: " . implode(', ', $missingGroups)
);
}
// Ensure no extra work groups are filled
$invalidGroups = [];
for ($i = $noOfOps + 1; $i <= 10; $i++) {
if (!empty($this->data["work_group{$i}_id"])) {
$invalidGroups[] = "work_group{$i}_id";
}
}
if (!empty($invalidGroups)) {
throw new RowImportFailedException(
"Invalid data: Only first {$noOfOps} work groups should be filled, but values found in: " . implode(', ', $invalidGroups)
);
}
for ($i = 1; $i <= 10; $i++) {
$workGroupName = $this->data["work_group{$i}_id"] ?? null;
if (!$workGroupName) {
continue;
}
$workGroupRecord = WorkGroupMaster::where('name', $workGroupName)
->where('plant_id', $plant->id)
->first();
if (!$workGroupRecord) {
throw new RowImportFailedException("Work group '{$workGroupName}' not found in plant '{$this->data['plant']}'");
}
$existsInLines = Line::where('plant_id', $plant->id)
->where('name', '!=', $this->data['name'])
->where("work_group{$i}_id", $workGroupRecord->id)
->first();
if ($existsInLines) {
$warnMsg[] = "Work group '{$workGroupName}' is already assigned to another line in plant '{$this->data['plant']}'";
}
$this->data["work_group{$i}_id"] = $workGroupRecord->id;
}
if (!empty($warnMsg))
{
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return Line::updateOrCreate([
Line::updateOrCreate(
[
'name' => $this->data['name'],
'plant_id' => $plant->id
],
[
'type' => $this->data['type'],
'group_work_center' => $this->data['group_work_center']
'no_of_operation' => $noOfOps,
'work_group1_id' => $this->data['work_group1_id'] ?? null,
'work_group2_id' => $this->data['work_group2_id'] ?? null,
'work_group3_id' => $this->data['work_group3_id'] ?? null,
'work_group4_id' => $this->data['work_group4_id'] ?? null,
'work_group5_id' => $this->data['work_group5_id'] ?? null,
'work_group6_id' => $this->data['work_group6_id'] ?? null,
'work_group7_id' => $this->data['work_group7_id'] ?? null,
'work_group8_id' => $this->data['work_group8_id'] ?? null,
'work_group9_id' => $this->data['work_group9_id'] ?? null,
'work_group10_id' => $this->data['work_group10_id'] ?? null,
]
);
// return Line::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
// return new Line();
return null;
}
public static function getCompletedNotificationBody(Import $import): string

View File

@@ -35,7 +35,7 @@ class LineStopImporter extends Importer
public function resolveRecord(): ?LineStop
{
$warnMsg = [];
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
if (Str::length($this->data['code']) < 3 || !ctype_alnum($this->data['code'])) {
$warnMsg[] = "Invalid line stop code found";
}
if (Str::length($this->data['reason']) < 5) {

View File

@@ -5,6 +5,7 @@ namespace App\Filament\Imports;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
use App\Models\WorkGroupMaster;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
@@ -28,7 +29,15 @@ class MachineImporter extends Importer
->requiredMapping()
->exampleHeader('Work Center')
->example('RMGCE001')
->label('Work Center'),
->label('Work Center')
->rules(['required']),
ImportColumn::make('workGroupMaster')
->requiredMapping()
->relationship(resolveUsing: 'name')
->exampleHeader('Work Group Center')
->example(['RMGCGABC'])
->label('Work Group Center')
->rules(['required']),
ImportColumn::make('line')
->requiredMapping()
->relationship(resolveUsing: 'name')
@@ -53,26 +62,52 @@ class MachineImporter extends Importer
$line = null;
$machine = $this->data['name'];
$workCenter = $this->data['work_center'];
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
$warnMsg[] = "Plant not found!";
}
else {
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
if ($line) {
$grpWrkCnr = $line->group_work_center;
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
$grpWrkCnr = $line->no_of_operation;
if (!$grpWrkCnr || $grpWrkCnr < 1)//Str::length($grpWrkCnr) < 1)
{
$warnMsg[] = "Group work center line not found";
$warnMsg[] = "Group work center line not found!";
}
else if (!$groupWorkCenter) {
$warnMsg[] = "Group work center not found!";
}
else {
$dupMachine = Machine::where('plant_id', $plant->id)->where('work_center', '!=', $workCenter)->where('name', $machine)->first();
if ($dupMachine) {
$warnMsg[] = "Duplicate machine name found!";
}
else {
$isValidGroupWork = false;
for ($i = 1; $i <= $line->no_of_operation; $i++) {
$column = "work_group{$i}_id";
if (!empty($line->$column)) {
if ($line->$column == $groupWorkCenter->id) {
$isValidGroupWork = true;
break;
}
}
}
if (!$isValidGroupWork) {
$warnMsg[] = "Group work center does not match with line!";
}
}
}
}
else
{
$warnMsg[] = "Line not found";
$warnMsg[] = "Line not found!";
}
}
if (Str::length($machine) <= 0) {
$warnMsg[] = "Machine name not found";
$warnMsg[] = "Machine name not found!";
}
if (!empty($warnMsg)) {
@@ -81,12 +116,13 @@ class MachineImporter extends Importer
Machine::updateOrCreate(
[
'name' => $machine,
'plant_id' => $plant->id,
'line_id' => $line->id
'work_center' => $workCenter
],
[
'work_center' => $workCenter
'line_id' => $line->id,
'name' => $machine,
'work_group_master_id' => $groupWorkCenter->id
]
);
return null;

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('Device Name')
->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

@@ -21,6 +21,13 @@ class MfmParameterImporter extends Importer
->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')

View File

@@ -2,11 +2,17 @@
namespace App\Filament\Imports;
use App\Models\Item;
use App\Models\MotorTestingMaster;
use App\Models\Plant;
use App\Models\User;
use DateTime;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class MotorTestingMasterImporter extends Importer
{
@@ -22,7 +28,14 @@ class MotorTestingMasterImporter extends Importer
->label('Item Code')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('subassembly_code')
->requiredMapping()
->exampleHeader('SubAssembly Code')
->example(['123456'])
->label('SubAssembly Code')
->rules(['required']),
ImportColumn::make('isi_model')
->requiredMapping()
->boolean()
->exampleHeader('ISI Model')
->example(['Y','N','Y'])
@@ -144,8 +157,8 @@ class MotorTestingMasterImporter extends Importer
->rules(['required']),
ImportColumn::make('leak_cur_limit')
->requiredMapping()
->exampleHeader('Leakage Current Limit')
->label('Leakage Current Limit')
->exampleHeader('Leak Current Limit')
->label('Leak Current Limit')
->example(['50','50','50'])
->rules(['required']),
ImportColumn::make('lock_cur_ll')
@@ -199,9 +212,9 @@ class MotorTestingMasterImporter extends Importer
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant')
->example(['Ransar Industries-I','Ransar Industries-I','Ransar Industries-I'])
->example(['1000','1010','1020'])
->label('Plant')
->relationship(resolveUsing: 'name')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
@@ -220,12 +233,245 @@ class MotorTestingMasterImporter extends Importer
public function resolveRecord(): ?MotorTestingMaster
{
// return MotorTestingMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
$warnMsg = [];
$plantCod = trim($this->data['plant']);
$iCode = trim($this->data['item']);
$sCode = trim($this->data['subassembly_code']);
$isiModel = (trim($this->data['isi_model']) == "1") ? true : false;
$phase = trim($this->data['phase']);
$kw = trim($this->data['kw']);
$hp = trim($this->data['hp']);
$volt = trim($this->data['volt']);
$current = trim($this->data['current']);
$rpm = trim($this->data['rpm']);
$torque = trim($this->data['torque']);
$frequency = trim($this->data['frequency']);
$connection = trim($this->data['connection']);
$insResType = trim($this->data['ins_res_type']);
$insResLimit = trim($this->data['ins_res_limit']);
$routineTestTime = trim($this->data['routine_test_time']);
$resRyLl = trim($this->data['res_ry_ll']);
$resRyUl = trim($this->data['res_ry_ul']);
$resYbLl = trim($this->data['res_yb_ll']);
$resYbUl = trim($this->data['res_yb_ul']);
$resBrLl = trim($this->data['res_br_ll']);
$resBrUl = trim($this->data['res_br_ul']);
$lockVoltLimit = trim($this->data['lock_volt_limit']);
$leakCurLimit = trim($this->data['leak_cur_limit']);
$lockCurLl = trim($this->data['lock_cur_ll']);
$lockCurUl = trim($this->data['lock_cur_ul']);
$noloadCurLl = trim($this->data['noload_cur_ll']);
$noloadCurUl = trim($this->data['noload_cur_ul']);
$noloadPowLl = trim($this->data['noload_pow_ll']);
$noloadPowUl = trim($this->data['noload_pow_ul']);
$noloadSpdLl = trim($this->data['noload_spd_ll']);
$noloadSpdUl = trim($this->data['noload_spd_ul']);
$createdBy = trim($this->data['created_by']);
$updatedBy = trim($this->data['updated_by']);
return new MotorTestingMaster();
$plant = null;
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod))
{
$warnMsg[] = "Invalid plant code found";
}
else if (Str::length($iCode) < 6 || !ctype_alnum($iCode))
{
$warnMsg[] = "Invalid item code found";
}
else if (Str::length($sCode) < 6 || !ctype_alnum($sCode))
{
$warnMsg[] = "Invalid sub-assembly code found";
}
else
{
$plant = Plant::where('code', $plantCod)->first();
$codeExist = Item::where('code', $iCode)->first();
if ($plant)
{
$iCode = Item::where('code', $iCode)->where('plant_id', $plant->id)->first();
}
if (!$plant)
{
$warnMsg[] = "Plant not found";
}
else if (!$codeExist)
{
$warnMsg[] = "Item code not found";
}
else if (!$iCode)
{
$warnMsg[] = "Item code not found for choosed plant";
}
else
{
// if (Str::length($isiModel) <= 0 || $isiModel == "0" || $isiModel == "1") {
// $warnMsg[] = "Invalid ISI Model found";
// }
// else
// {
// $isiModel = ($isiModel == "1");
// }
if (Str::length($phase) <= 0 || ($phase != "Single" && $phase != "Three")) {//!is_string($phase) ||
$warnMsg[] = "Invalid phase found";
}
if (Str::length($hp) <= 0 || !is_numeric($hp)) {
$warnMsg[] = "Invalid HP found";
}
if (Str::length($kw) <= 0 || !is_numeric($kw)) {
$warnMsg[] = "Invalid KW found";
}
if (Str::length($volt) <= 0 || !is_numeric($volt)) {
$warnMsg[] = "Invalid volt found";
}
if (Str::length($current) <= 0 || !is_numeric($current)) {
$warnMsg[] = "Invalid current found";
}
if (Str::length($rpm) <= 0 || !is_numeric($rpm)) {
$warnMsg[] = "Invalid RPM found";
}
if (Str::length($torque) <= 0 || !is_numeric($torque)) {
$warnMsg[] = "Invalid torque found";
}
if (Str::length($frequency) <= 0 || !is_numeric($frequency)) {
$warnMsg[] = "Invalid frequency found";
}
if (Str::length($connection) <= 0 || ($connection != "Star-Delta" && $connection != "Star" && $connection != "Delta")) {
$warnMsg[] = "Invalid connection found";
}
if (Str::length($insResLimit) <= 0 || !is_numeric($insResLimit)) {
$warnMsg[] = "Invalid insulation resistance limit found";
}
if (Str::length($insResType) <= 0 || ($insResType != "O" && $insResType != "M" && $insResType != "G")) {
$warnMsg[] = "Invalid insulation resistance type found";
}
if (Str::length($routineTestTime) <= 0 || !isValidTimeFormat($routineTestTime)) {
$warnMsg[] = "Invalid routine test time found";
}
if (Str::length($resRyLl) <= 0 || !is_numeric($resRyLl)) {
$warnMsg[] = "Invalid resistance RY lower limit found";
}
if (Str::length($resRyUl) <= 0 || !is_numeric($resRyUl)) {
$warnMsg[] = "Invalid resistance RY upper limit found";
}
if (Str::length($resYbLl) <= 0 || !is_numeric($resYbLl)) {
$warnMsg[] = "Invalid resistance YB lower limit found";
}
if (Str::length($resYbUl) <= 0 || !is_numeric($resYbUl)) {
$warnMsg[] = "Invalid resistance YB upper limit found";
}
if (Str::length($resBrLl) <= 0 || !is_numeric($resBrLl)) {
$warnMsg[] = "Invalid resistance BR lower limit found";
}
if (Str::length($resBrUl) <= 0 || !is_numeric($resBrUl)) {
$warnMsg[] = "Invalid resistance BR upper limit found";
}
if (Str::length($lockVoltLimit) <= 0 || !is_numeric($lockVoltLimit)) {
$warnMsg[] = "Invalid locked volt limit found";
}
if (Str::length($leakCurLimit) <= 0 || !is_numeric($leakCurLimit)) {
$warnMsg[] = "Invalid leakage current limit found";
}
if (Str::length($lockCurLl) <= 0 || !is_numeric($lockCurLl)) {
$warnMsg[] = "Invalid locked current lower limit found";
}
if (Str::length($lockCurUl) <= 0 || !is_numeric($lockCurUl)) {
$warnMsg[] = "Invalid locked current upper limit found";
}
if (Str::length($noloadCurLl) <= 0 || !is_numeric($noloadCurLl)) {
$warnMsg[] = "Invalid no load current lower limit found";
}
if (Str::length($noloadCurUl) <= 0 || !is_numeric($noloadCurUl)) {
$warnMsg[] = "Invalid no load current upper limit found";
}
if (Str::length($noloadPowLl) <= 0 || !is_numeric($noloadPowLl)) {
$warnMsg[] = "Invalid no load power lower limit found";
}
if (Str::length($noloadPowUl) <= 0 || !is_numeric($noloadPowUl)) {
$warnMsg[] = "Invalid no load power upper limit found";
}
if (Str::length($noloadSpdLl) <= 0 || !is_numeric($noloadSpdLl)) {
$warnMsg[] = "Invalid no load speed lower limit found";
}
if (Str::length($noloadSpdUl) <= 0 || !is_numeric($noloadSpdUl)) {
$warnMsg[] = "Invalid no load speed upper limit found";
}
$oldCode = MotorTestingMaster::where('item_id', $iCode->id)->where('plant_id', $plant->id)->first();
if ($oldCode) {
$created = $oldCode->created_by ? User::where('name', $oldCode->created_by)->first() : null;
if (!$created) {
$warnMsg[] = "Created by not found on update";
}
$updated = User::where('name', $updatedBy)->first();
if (!$updated) {
$warnMsg[] = "Updated by not found on update";
}
}
else
{
$created = User::where('name', $createdBy)->first();
if (!$created) {
$warnMsg[] = "Created by not found";
}
$updated = User::where('name', $updatedBy)->first();
if (!$updated) {
$warnMsg[] = "Updated by not found";
}
}
}
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
MotorTestingMaster::updateOrCreate([
'plant_id' => $plant->id,
'item_id' => $iCode->id
],
[
'subassembly_code' => $sCode,
'isi_model' => $isiModel,
'phase' => $phase,
'kw' => $kw,
'hp' => $hp,
'volt' => $volt,
'current' => $current,
'rpm' => $rpm,
'torque' => $torque,
'frequency' => $frequency,
'connection' => $connection,
'ins_res_limit' => $insResLimit,
'ins_res_type' => $insResType,
'routine_test_time' => $routineTestTime,
'res_ry_ll' => $resRyLl,
'res_ry_ul' => $resRyUl,
'res_yb_ll' => $resYbLl,
'res_yb_ul' => $resYbUl,
'res_br_ll' => $resBrLl,
'res_br_ul' => $resBrUl,
'lock_volt_limit' => $lockVoltLimit,
'leak_cur_limit' => $leakCurLimit,
'lock_cur_ll' => $lockCurLl,
'lock_cur_ul' => $lockCurUl,
'noload_cur_ll' => $noloadCurLl,
'noload_cur_ul' => $noloadCurUl,
'noload_pow_ll' => $noloadPowLl,
'noload_pow_ul' => $noloadPowUl,
'noload_spd_ll' => $noloadSpdLl,
'noload_spd_ul' => $noloadSpdUl,
'created_by' => $created->name,
'updated_by' => $updated->name,
]
);
return null;
// // return MotorTestingMaster::firstOrNew([
// // // Update existing records, matching them by `$this->data['column_name']`
// // 'email' => $this->data['email'],
// // ]);
// return new MotorTestingMaster();
}
public static function getCompletedNotificationBody(Import $import): string
@@ -239,3 +485,13 @@ class MotorTestingMasterImporter extends Importer
return $body;
}
}
function isValidTimeFormat($time) {
// If time starts with a single digit hour without leading zero, pad it
if (preg_match('/^\d(:\d{2}:\d{2})$/', $time, $matches)) {
$time = '0' . $time;
}
$dateTime = DateTime::createFromFormat('H:i:s', $time);
return $dateTime && $dateTime->format('H:i:s') === $time;
}

View File

@@ -12,10 +12,21 @@ use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class PalletValidationImporter extends Importer
{
protected static ?string $model = PalletValidation::class;
// public static function canQueue(): bool
// {
// return true; // allows this importer to be queued
// }
// public static function getChunkSize(): ?int
// {
// return 1000;
// }
public static function getColumns(): array
{
return [

View File

@@ -59,9 +59,9 @@ class ProductionQuantityImporter extends Importer
->rules(['required']),
ImportColumn::make('block_reference')
->requiredMapping() // Or optionalMapping() if not always present
->exampleHeader('Block Name')
->exampleHeader('Block')
->example(['Block A', 'Block A'])
->label('Block Name')
->label('Block')
->rules(['required']), // Or remove if not required
ImportColumn::make('shift')
->requiredMapping()
@@ -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

@@ -193,9 +193,9 @@ class QualityValidationImporter extends Importer
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
$uniqueCode = trim($this->data['sticker_master_id_code']);// stickerMaster.item
$stickMaster = StickerMaster::select('id')->with('item')
->whereHas('item', function ($query) use ($uniqueCode, $plant) {
$query->where('code', $uniqueCode)->where('plant_id', $plant->id);
})->value('id');
->whereHas('item', function ($query) use ($uniqueCode, $plant) {
$query->where('code', $uniqueCode)->where('plant_id', $plant->id);
})->value('id');
}
if (!$line) {
@@ -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";
}
@@ -281,11 +281,13 @@ class QualityValidationImporter extends Importer
QualityValidation::updateOrCreate([
'plant_id' => $plant->id,
'line_id' => $line->id,
'sticker_master_id' => $stickMaster,//->id
'serial_number' => $this->data['serial_number']
],
[
'line_id' => $line->id,
'uom' => $this->data['uom'],
'production_order' => $this->data['production_order'],
'serial_number' => $this->data['serial_number'],
'serial_number_motor' => $this->data['serial_number_motor'],
'serial_number_pump' => $this->data['serial_number_pump'],
'serial_number_pumpset' => $this->data['serial_number_pumpset'],

View File

@@ -14,11 +14,11 @@ class TestingPanelReadingImporter extends Importer
public static function getColumns(): array
{
return [
ImportColumn::make('item')
ImportColumn::make('machine')
->requiredMapping()
->relationship()
->rules(['required']),
ImportColumn::make('machine')
ImportColumn::make('motorTestingMaster.item.code')
->requiredMapping()
->relationship()
->rules(['required']),
@@ -28,6 +28,9 @@ class TestingPanelReadingImporter extends Importer
ImportColumn::make('serial_number')
->requiredMapping()
->rules(['required']),
ImportColumn::make('winded_serial_number')
->requiredMapping()
->rules(['required']),
ImportColumn::make('before_fr_volt'),
ImportColumn::make('before_fr_cur'),
ImportColumn::make('before_fr_pow'),

View File

@@ -0,0 +1,114 @@
<?php
namespace App\Filament\Imports;
use App\Models\User;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Spatie\Permission\Models\Role;
use Str;
class UserImporter extends Importer
{
protected static ?string $model = User::class;
public static function getColumns(): array
{
return [
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Name')
->example('RAW00001')
->label('Name')
->rules(['required']),//, 'max:255'
ImportColumn::make('email')
->requiredMapping()
->exampleHeader('E-mail')
->example('RAW00001@cripumps.com')
->label('E-mail')
->rules(['required', 'email']),//, 'max:255'
ImportColumn::make('password')
->requiredMapping()
->exampleHeader('Password')
->example('RAW00001')
->label('Password')
->rules(['required']),//, 'max:255'
ImportColumn::make('roles')
->requiredMapping()
->exampleHeader('Roles')
->example('Employee')
->label('Roles')
->rules(['nullable', 'string']), // Optional roles
];
}
public function resolveRecord(): ?User
{
$warnMsg = [];
if (Str::length($this->data['name']) < 1) {
$warnMsg[] = "User name not found!";
}
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
if (Str::length($this->data['email']) < 5) {
$warnMsg[] = "Invalid email found!";
}
if (Str::length($this->data['password']) < 3) {
$warnMsg[] = "Invalid password found!";
}
// Validate roles if provided
$roles = [];
if (!empty($this->data['roles'])) {
$roles = collect(explode(',', $this->data['roles']))
->map(fn($role) => trim($role))
->filter()
->toArray();
foreach ($roles as $roleName) {
if (!Role::where('name', $roleName)->exists()) {
$warnMsg[] = "Role : '{$roleName}' does not exist!";
}
}
}
else {
$warnMsg[] = "User roles not found!";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
$user = User::updateOrCreate([
'email' => $this->data['email'],
],
[
'name' => $this->data['name'],
'password' => $this->data['password'],
]);
// Assign roles
if (!empty($roles)) {
$user->syncRoles($roles);
}
return null;
// return User::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
//return new User();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your user import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -0,0 +1,154 @@
<?php
namespace App\Filament\Imports;
use App\Models\Plant;
use App\Models\User;
use App\Models\WorkGroupMaster;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class WorkGroupMasterImporter extends Importer
{
protected static ?string $model = WorkGroupMaster::class;
public static function getColumns(): array
{
return [
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('Plant Name')
->example('Ransar Industries-I')
->label('Plant Name')
->relationship(resolveUsing:'name')
->rules(['required']),
ImportColumn::make('name')
->requiredMapping()
->exampleHeader('Name')
->example('RMGCEABC')
->label('Name')
->rules(['required']),
ImportColumn::make('description')
->requiredMapping()
->exampleHeader('Description')
->example('Testing Model 1')
->label('Description')
->rules(['required']),
ImportColumn::make('operation_number')
->requiredMapping()
->exampleHeader('Operation Number')
->example('0020')
->label('Operation Number')
->rules(['required']),
ImportColumn::make('created_by')
->requiredMapping()
->exampleHeader('Created By')
->example('Admin')
->label('Created By')
->rules(['required']),
];
}
public function resolveRecord(): ?WorkGroupMaster
{
// return WorkGroupMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
if (Str::length($this->data['name']) <= 0) { //|| !ctype_alnum($this->data['description'])
$warnMsg[] = "Invalid name found";
}
if (Str::length(trim($this->data['description'])) <= 0) {
$warnMsg[] = "Invalid description found";
}
$desc = trim($this->data['description']);
if (Str::length($desc) > 44) {
$warnMsg[] = "Description should be less than 44 digits.";
}
if (Str::length($this->data['operation_number']) <= 0) {
$warnMsg[] = "Invalid operation number found";
}
if(!is_numeric($this->data['operation_number']))
{
$warnMsg[] = "Invalid operation number found must be numeric";
}
$user = User::where('name', $this->data['created_by'])->first();
if (!$user) {
$warnMsg[] = "Operator ID not found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
else
{
//Check (plant_id, name)
$existingByName = WorkGroupMaster::where('plant_id', $plant->id)
->where('name', $this->data['name'])
->first();
if ($existingByName) {
throw new RowImportFailedException("Work group name already exists for this plant!");
}
//Check (plant_id, operation_number)
$existingByOpNum = WorkGroupMaster::where('plant_id', $plant->id)
->where('operation_number', $this->data['operation_number'])
->where('name', $this->data['name'])
->first();
if ($existingByOpNum) {
throw new RowImportFailedException("Operation number already exists for this plant!");
}
//Check (plant_id)
$existingByOperator = WorkGroupMaster::where('plant_id', $plant->id)
->where('name', $this->data['name'])
->first();
if ($existingByOperator) {
throw new RowImportFailedException("Already work group name assigned to another plant!");
}
}
WorkGroupMaster::updateOrCreate([
'plant_id' => $plant->id,
'name' => $this->data['name'],
'description' => $this->data['description'],
'operation_number' => $this->data['operation_number'],
'created_by' => $this->data['created_by'],
]);
return null;
//return new WorkGroupMaster();
}
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your work group master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
}
return $body;
}
}

View File

@@ -53,6 +53,7 @@ class Dashboard extends \Filament\Pages\Dashboard
{
return 'Production Line Count';
}
public function getWidgets(): array
{
$widgets = [];

View File

@@ -726,13 +726,27 @@ class PalletFromLocator extends Page implements HasForms
$month = now()->format('m');
$prefix = "EP-{$year}{$month}";
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
$lastPallet1 = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
$lastPallet2 = LocatorInvoiceValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first();
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
if ($lastPallet) {
$serialPart = substr($lastPallet->pallet_number, strlen($prefix));
if ($lastPallet1 && $lastPallet2) {
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
if (intval($serialPart1) > intval($serialPart2)) {
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
} else {
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
}
}
else if ($lastPallet1) {
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
// OR
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
$newNumber = str_pad(intval($serialPart) + 1, strlen($serialPart), '0', STR_PAD_LEFT);
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
}
else if ($lastPallet2) {
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
}
$newPalletNumber = "{$prefix}{$newNumber}";

View File

@@ -320,23 +320,44 @@ class ProductionQuantityPage extends Page implements HasForms
->hintColor('danger'),
TextInput::make('production_order')
->label('Production Order')
->reactive()
->required()
//->columnSpan(1)
->columnSpan(['default' => 1, 'sm' => 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;
return;
// if (empty($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'),
// TextInput::make('item_code')
// ->label('Item Code')
@@ -592,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,
@@ -611,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;

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');
}
}

View File

@@ -12,11 +12,15 @@ class CreateAlertMailRule extends CreateRecord
protected function mutateFormDataBeforeCreate(array $data): array
{
if ($data['is_active']) {
$data['plant'] = 0;
}
return $data;
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateBlock extends CreateRecord
{
protected static string $resource = BlockResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -28,7 +28,7 @@ class CheckPointNameResource extends Resource
protected static ?string $navigationGroup = 'Master Entries';
protected static ?int $navigationSort = 14;
protected static ?int $navigationSort = 15;
public static function form(Form $form): Form
{

View File

@@ -29,7 +29,7 @@ class CheckPointTimeResource extends Resource
protected static ?string $navigationGroup = 'Master Entries';
protected static ?int $navigationSort = 15;
protected static ?int $navigationSort = 16;
public static function form(Form $form): Form
{

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateCompany extends CreateRecord
{
protected static string $resource = CompanyResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateConfiguration extends CreateRecord
{
protected static string $resource = ConfigurationResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

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,17 @@
<?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;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

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,17 @@
<?php
namespace App\Filament\Resources\EbReadingResource\Pages;
use App\Filament\Resources\EbReadingResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateEbReading extends CreateRecord
{
protected static string $resource = EbReadingResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

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,505 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\EquipmentMasterExporter;
use App\Filament\Imports\EquipmentMasterImporter;
use App\Filament\Resources\EquipmentMasterResource\Pages;
use App\Filament\Resources\EquipmentMasterResource\RelationManagers;
use App\Models\EquipmentMaster;
use Carbon\Carbon;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Storage;
use Illuminate\Validation\Rule;
class EquipmentMasterResource extends Resource
{
protected static ?string $model = EquipmentMaster::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Testing Panel';
protected static ?int $navigationSort = 2;
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->relationship('plant', 'name')
->required(),
Forms\Components\Select::make('machine_id')
//->relationship('machine', 'name')
->label('Work Center')
->reactive()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return \App\Models\Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
})
->required(),
Forms\Components\TextInput::make('name')
->label('Name'),
Forms\Components\TextInput::make('description')
->label('Description'),
Forms\Components\TextInput::make('make')
->label('Make'),
Forms\Components\TextInput::make('model')
->label('Model'),
Forms\Components\TextInput::make('equipment_number')
->label('Equipment Number')
->reactive()
->rules(function (callable $get) {
return [
Rule::unique('equipment_masters', 'equipment_number')
->where(function ($query) use ($get) {
return $query->where('plant_id', $get('plant_id'));
})
->ignore($get('id')),
];
})
->afterStateUpdated(function ($state, callable $set) {
if (! $state) {
return;
}
$model = EquipmentMaster::where('equipment_number', $state)->first();
if ($model?->attachment) {
$set('attachment', $model->attachment);
} else {
$set('attachment', null);
}
}),
//->afterStateUpdated(function ($state, callable $set) {
// if (! $state) {
// return;
// }
// $model = EquipmentMaster::where('equipment_number', $state)->first();
// if ($model?->attachment) {
// $set('attachment', $model->attachment);
// } else {
// $set('attachment', null);
// }
// }),
Forms\Components\TextInput::make('instrument_serial_number')
->label('Instrument Serial Number'),
// Forms\Components\DateTimePicker::make('calibrated_on')
// ->label('Calibrated On')
// ->required(),
// Forms\Components\TextInput::make('frequency')
// ->label('Frequency')
// ->required()
// ->numeric()
// ->default(1),
// Forms\Components\DateTimePicker::make('next_calibration_date')
// ->label('Next Calibration Date')
// ->required(),
Forms\Components\DateTimePicker::make('calibrated_on')
->label('Calibrated On')
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$frequency = $get('frequency') ?? '1';
$nextDate = self::calculateNextCalibrationDate($state, $frequency);
$set('next_calibration_date', $nextDate);
}),
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
// $frequency = (int) $get('frequency');
// if ($state && $frequency != 0) {
// $calibratedOn = $state instanceof Carbon ? $state : Carbon::parse($state);
// $nextDate = $calibratedOn->copy()->addDays($frequency);
// $set('next_calibration_date', $nextDate);
// } else {
// $set('next_calibration_date', null);
// }
// }),
Forms\Components\TextInput::make('frequency')
->label('Frequency (days)')
->required()
->numeric()
->minValue(1)
->default(1)
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$calibratedOn = $get('calibrated_on');
$nextDate = self::calculateNextCalibrationDate($calibratedOn, $state);
$set('next_calibration_date', $nextDate);
}),
// ->afterStateUpdated(function ($state, callable $get, callable $set) {
// $calibratedOn = $get('calibrated_on');
// $frequency = (int) $state;
// if ($calibratedOn && $frequency !== 0) {
// $calibratedOn = $calibratedOn instanceof Carbon ? $calibratedOn : Carbon::parse($calibratedOn);
// $nextDate = $calibratedOn->copy()->addDays($frequency);
// $set('next_calibration_date', $nextDate);
// }
// else
// {
// $set('next_calibration_date', null);
// }
// }),
Forms\Components\DateTimePicker::make('next_calibration_date')
->label('Next Calibration Date')
->readOnly()
->required(),
Forms\Components\TextInput::make('calibrated_by')
->label('Calibrated By'),
Forms\Components\Textarea::make('calibration_certificate')
->label('Calibration Certificate'),
Forms\Components\FileUpload::make('attachment')
->label('PDF Upload')
->acceptedFileTypes(['application/pdf'])
->storeFiles(false)
->disk('local')
->directory('uploads/temp')
->preserveFilenames()
->reactive(),
// Forms\Components\Actions::make([
// Action::make('uploadNow')
// ->label('Upload PDF Now')
// ->action(function ($get, callable $set) {
// $uploadedFiles = $get('attachment');
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
// $uploaded = reset($uploadedFiles);
// if ($uploaded instanceof TemporaryUploadedFile) {
// $originalName = $uploaded->getClientOriginalName();
// $storedPath = $uploaded->storeAs(
// 'uploads/temp',
// $originalName,
// 'local'
// );
// }
// }
// }),
// ]),
// Forms\Components\Actions::make([
// Action::make('downloadAttachment')
// ->label('Download PDF')
// ->action(function ($get) {
// $uploadedFiles = $get('attachment');
// $equipmentNumber = $get('equipment_number');
// if (!$equipmentNumber) {
// Notification::make()
// ->title('No equipment number entered')
// ->danger()
// ->send();
// return;
// }
// $files = Storage::disk('local')->files('uploads/temp');
// $fileToDownload = null;
// foreach ($files as $file) {
// if (str_contains($file, $equipmentNumber)) {
// $fileToDownload = $file;
// break;
// }
// }
// if (!$fileToDownload) {
// Notification::make()
// ->title('PDF not found for this equipment')
// ->danger()
// ->send();
// return;
// }
// return response()->download(Storage::disk('local')->path($fileToDownload));
// }),
// ]),
Forms\Components\Actions::make([
Action::make('uploadNow')
->label('Upload PDF Now')
// ->action(function ($get, callable $set) {
// $uploadedFiles = $get('attachment');
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
// $uploaded = reset($uploadedFiles);
// if ($uploaded instanceof TemporaryUploadedFile) {
// $originalName = $uploaded->getClientOriginalName();
// $storedPath = $uploaded->storeAs(
// 'uploads/temp',
// $originalName,
// 'local'
// );
// }
// }
// }),
->action(function ($get, callable $set) {
$uploadedFiles = $get('attachment');
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
$uploaded = reset($uploadedFiles);
if ($uploaded instanceof TemporaryUploadedFile) {
$originalName = $uploaded->getClientOriginalName();
$storedPath = $uploaded->storeAs(
'uploads/temp',
$originalName,
'local'
);
Notification::make()
->title('PDF uploaded successfully')
->success()
->send();
return;
}
}
else
{
Notification::make()
->title('No file selected to upload')
->warning()
->send();
return;
}
}),
Action::make('downloadAttachment')
->label('Download PDF')
->action(function ($get) {
$equipmentNumber = $get('equipment_number');
if (!$equipmentNumber) {
Notification::make()
->title('No equipment number entered')
->danger()
->send();
return;
}
$files = Storage::disk('local')->files('uploads/temp');
$fileToDownload = null;
foreach ($files as $file) {
if (str_contains($file, $equipmentNumber)) {
$fileToDownload = $file;
break;
}
}
if (!$fileToDownload) {
Notification::make()
->title('PDF not found for this equipment')
->danger()
->send();
return;
}
return response()->download(Storage::disk('local')->path($fileToDownload));
}),
])
->columns(2),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By'),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('machine.work_center')
->label('Work Center')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('name')
->label('Name')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('description')
->label('Description')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('make')
->label('Make')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('model')
->label('Model')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('equipment_number')
->label('Equipment Number')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('instrument_serial_number')
->label('Instrument Serial Number')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('calibrated_on')
->label('Calibrated On')
->alignCenter()
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('frequency')
->label('Frequency')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('next_calibration_date')
->label('Next Calibration Date')
->alignCenter()
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('calibrated_by')
->label('Calibrated By')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('calibration_certificate')
->label('Calibration Certificate')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created Bys')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->dateTime()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(EquipmentMasterImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import equipment master');
}),
ExportAction::make()
->exporter(EquipmentMasterExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export equipment master');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListEquipmentMasters::route('/'),
'create' => Pages\CreateEquipmentMaster::route('/create'),
'view' => Pages\ViewEquipmentMaster::route('/{record}'),
'edit' => Pages\EditEquipmentMaster::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
protected static function calculateNextCalibrationDate(?string $startDateTime, ?string $durationDays): ?string
{
if (!$startDateTime || !$durationDays) {
return null;
}
try
{
$startDateTimeCarbon = Carbon::parse($startDateTime);
$durationDays = str_replace(',', '.', $durationDays);
if(!is_numeric($durationDays))
{
return null;
}
$nextCalibrationDate = $startDateTimeCarbon->addDays(floatval($durationDays));
return $nextCalibrationDate->format('Y-m-d H:i:s');
}
catch (\Exception $e)
{
return null;
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,339 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Exports\GrMasterExporter;
use App\Filament\Imports\GrMasterImporter;
use App\Filament\Resources\GrMasterResource\Pages;
use App\Filament\Resources\GrMasterResource\RelationManagers;
use App\Models\GrMaster;
use App\Models\Item;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Notifications\Notification;
use Filament\Forms\Components\Actions\Action;
use Storage;
use Smalot\PdfParser\Parser;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Illuminate\Validation\Rule;
class GrMasterResource extends Resource
{
protected static ?string $model = GrMaster::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->relationship('plant', 'name')
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
//->relationship('item', 'id')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->required(),
Forms\Components\TextInput::make('gr_number')
->label('GR Number')
->required(),
Forms\Components\TextInput::make('serial_number')
->label('Serial Number')
->rule(function (callable $get) {
return Rule::unique('gr_masters', 'serial_number')
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\FileUpload::make('attachment')
->label('PDF Upload')
->acceptedFileTypes(['application/pdf'])
->storeFiles(false)
->disk('local')
->directory('uploads/temp')
->preserveFilenames()
->reactive(),
Forms\Components\Actions::make([
Action::make('uploadNow')
->label('Upload PDF Now')
->action(function ($get, callable $set) {
$uploadedFiles = $get('attachment');
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
{
$uploaded = reset($uploadedFiles);
if ($uploaded instanceof TemporaryUploadedFile) {
$grNumber = $get('gr_number');
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
// $originalName = $uploaded->getClientOriginalName();
// $path = 'uploads/GRNumber/' . $originalName;
$finalFileName = $safeName . '.pdf';
$finalPath = 'uploads/GRNumber/' . $finalFileName;
if (Storage::disk('local')->exists($finalPath)) {
Notification::make()
->title('Duplicate File')
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
->warning()
->send();
return; // Stop here
}
$storedPath = $uploaded->storeAs(
'uploads/GRNumber',
$finalFileName,
'local'
);
// $fullPath = storage_path('app/' . $storedPath);
$fullPath = storage_path('app/private/' . $storedPath);
$parser = new Parser();
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
$pdf = $parser->parseFile($fullPath);
$text = $pdf->getText();
//dd($text);
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
$item1 = $matches[1];
}
else
{
Notification::make()
->title('Item Code Not Found')
->body('Could not find Item code in uploaded PDF.')
->warning()
->send();
return;
}
$processOrder = $get('gr_number');
$itemId = $get('item_id');
$plant = $get('plant_id');
$item = Item::find($itemId);
$plant = Plant::find($plant);
if ($item)
{
$itemCode = $item->code;
}
else
{
$itemCode = null;
Notification::make()
->title('Item Not Found')
->body("Item not found in uploaded pdf.")
->warning()
->send();
return;
}
$storedPath = $uploaded->storeAs(
'uploads/GRNumber',
$finalFileName,
'local'
);
if($itemCode == $item1)
{
Notification::make()
->title('Success')
->body("Gr Number '$processOrder' PDF uploaded successfully.")
->success()
->send();
return;
}
else
{
if (Storage::disk('local')->exists($storedPath)) {
Storage::disk('local')->delete($storedPath);
}
Notification::make()
->title('Item Code not matched')
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
->danger()
->send();
return;
}
}
}
else
{
Notification::make()
->title('No file selected to upload')
->warning()
->send();
return;
}
}),
Action::make('downloadAttachment')
->label('Download PDF')
->action(function ($get) {
$equipmentNumber = $get('gr_number');
if (!$equipmentNumber) {
Notification::make()
->title('No GR Number entered')
->danger()
->send();
return;
}
$files = Storage::disk('local')->files('uploads/GRNumber');
$fileToDownload = null;
foreach ($files as $file) {
if (str_contains($file, $equipmentNumber)) {
$fileToDownload = $file;
break;
}
}
if (!$fileToDownload) {
Notification::make()
->title('PDF not found for this process order')
->danger()
->send();
return;
}
return response()->download(Storage::disk('local')->path($fileToDownload));
}),
]),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->default(Filament::auth()->user()?->name),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item Code')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('gr_number')
->label('GR Number')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('serial_number')
->label('Serial Number')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(GrMasterImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import gr master');
}),
ExportAction::make()
->exporter(GrMasterExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export gr master');
}),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListGrMasters::route('/'),
'create' => Pages\CreateGrMaster::route('/create'),
'view' => Pages\ViewGrMaster::route('/{record}'),
'edit' => Pages\EditGrMaster::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ class GuardNameResource extends Resource
protected static ?string $navigationGroup = 'Master Entries';
protected static ?int $navigationSort = 13;
protected static ?int $navigationSort = 14;
public static function form(Form $form): Form
{
@@ -73,14 +73,14 @@ class GuardNameResource extends Resource
->ignore($get('id'));
}),
Forms\Components\TextInput::make('identification1')
->label('Identification-1')
->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('Identification-2')
->label('PAN Number')
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('created_by', Filament::auth()->user()?->name);

View File

@@ -17,6 +17,7 @@ use Filament\Forms;
use Filament\Forms\Components\Actions\Action as ActionsAction;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
@@ -147,16 +148,16 @@ class InvoiceValidationResource extends Resource
->reactive()
->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || !empty($get('serial_number')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
if(!$get('plant_id'))
if (!$get('plant_id'))
{
$set('update_invoice', null);
return;
}
if($get('update_invoice') === "1")
if ($get('update_invoice') == "1")
{
$totQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count();
if($totQuan <= 0)
if ($totQuan <= 0)
{
$set('update_invoice', null);
return;
@@ -166,9 +167,9 @@ class InvoiceValidationResource extends Resource
$scanMQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count();
$scanSQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count();
if($totMQuan > 0)
if ($totMQuan > 0)
{
if ($totQuan === $scanMQuan)
if ($totQuan == $scanMQuan)
{
$set('update_invoice', null);
return;
@@ -176,7 +177,7 @@ class InvoiceValidationResource extends Resource
}
else
{
if ($totQuan === $scanSQuan)
if ($totQuan == $scanSQuan)
{
$set('update_invoice', null);
return;
@@ -342,15 +343,57 @@ class InvoiceValidationResource extends Resource
$fullPath = Storage::disk('local')->path($path);
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
if ($totQuan > 0)
{
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->count();
if ($totQuan == $scanSQuan)
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
Notification::make()
->title("Serial invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
else
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
$invoicePlantId = $invoiceFirst->plant_id;
if ($plantId != $invoicePlantId)
{
Notification::make()
->title("Serial invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
}
}
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
if($totQuan == $scanSQuan && $totQuan > 0)
if ($totQuan > 0 && $totQuan == $scanSQuan)
{
Notification::make()
->title('Serial invoice already completed the scanning process for selected plant.')
->danger()
->send();
->title('Serial invoice already completed the scanning process for selected plant.')
->danger()
->send();
if ($disk->exists($path))
{
@@ -363,7 +406,7 @@ class InvoiceValidationResource extends Resource
{
$rows = Excel::toArray(null, $fullPath)[0];
if((count($rows) - 1) <= 0)
if ((count($rows) - 1) <= 0)
{
Notification::make()
->title('Records Not Found')
@@ -387,7 +430,7 @@ class InvoiceValidationResource extends Resource
foreach ($rows as $index => $row)
{
if ($index === 0) continue; // Skip header
if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]);
$serialNumber = trim($row[1]);
@@ -398,19 +441,17 @@ class InvoiceValidationResource extends Resource
if (!empty($materialCode))
{
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
{
$invalidMatCodes[] = $materialCode;
}
else
{
if (empty($serialNumber)) {
$missingSerials[] = $materialCode;
}
else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
{
$invalidSerialCodes[] = $serialNumber;
}
@@ -440,7 +481,6 @@ class InvoiceValidationResource extends Resource
$duplicateSerialCodes = array_unique($duplicateSerials);
if (!empty($uniqueInvalidCodes)) {
Notification::make()
->title('Invalid Item Codes')
@@ -452,7 +492,6 @@ class InvoiceValidationResource extends Resource
}
return;
}
else if (!empty($uniqueMissingSerials)) {
Notification::make()
->title('Missing Serial Numbers')
@@ -478,7 +517,7 @@ class InvoiceValidationResource extends Resource
else if (!empty($duplicateSerialCodes)) {
Notification::make()
->title('Duplicate Serial Numbers')
->body('The following serial numbers are already exist in database:<br>' . implode(', ', $duplicateSerialCodes))
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
->danger()
->send();
if ($disk->exists($path)) {
@@ -499,17 +538,17 @@ class InvoiceValidationResource extends Resource
return;
}
$uniqueCodes = array_unique($materialCodes);
$uniqueCodes = array_unique($materialCodes);
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
})
->get();
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
})
->get();
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
if (!empty($missingCodes))
{
@@ -531,30 +570,30 @@ class InvoiceValidationResource extends Resource
// Check which codes have a material_type set (not null)
$invalidCodes = $matchedItems
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
->pluck('item.code')
->toArray();
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
->pluck('item.code')
->toArray();
if (count($invalidCodes) > 10)
{
Notification::make()
->title('Invalid item codes found')
->body('' . count($invalidCodes) . 'item codes found have material type.')
->danger()
->send();
->title('Invalid item codes found')
->body('' . count($invalidCodes) . 'item codes found have material type.')
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
}
return;
}
else if(count($invalidCodes) > 0)
else if (count($invalidCodes) > 0)
{
Notification::make()
->title('Invalid item codes found')
->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes))
->danger()
->send();
->title('Invalid item codes found')
->body('Material invoice Item Codes found : ' . implode(', ', $invalidCodes))
->danger()
->send();
if ($disk->exists($path)) {
$disk->delete($path);
@@ -566,7 +605,7 @@ class InvoiceValidationResource extends Resource
// Save full file path to session
session(['uploaded_invoice_path' => $fullPath]);
Notification::make()
->title('Serial invoice imported successfully.')
->title('Serial invoice imported successfully.')
->success()
->send();
}
@@ -575,7 +614,6 @@ class InvoiceValidationResource extends Resource
->visible(function() {
return Filament::auth()->user()->can('view import serial invoice');
}),
Tables\Actions\Action::make('Import Invoice Material')
->label('Import Material Invoice')
->form([
@@ -602,7 +640,6 @@ class InvoiceValidationResource extends Resource
->visible(fn (Get $get) => !empty($get('plant_id')))
->directory('uploads/temp'),
])
->action(function (array $data) {
$uploadedFile = $data['invoice_material'];
@@ -619,10 +656,52 @@ class InvoiceValidationResource extends Resource
$fullPath = Storage::disk('local')->path($path);
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
if ($totQuan > 0)
{
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->count();
if ($totQuan == $scanMQuan)
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
Notification::make()
->title("Material invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
else
{
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
$invoicePlantId = $invoiceFirst->plant_id;
if ($plantId != $invoicePlantId)
{
Notification::make()
->title("Material invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
->danger()
->send();
if ($disk->exists($path))
{
$disk->delete($path);
}
return;
}
}
}
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
if($totQuan == $scanMQuan && $totQuan > 0)
if ($totQuan > 0 && $totQuan == $scanMQuan)
{
Notification::make()
->title('Material invoice already completed the scanning process for selected plant.')
@@ -638,7 +717,7 @@ class InvoiceValidationResource extends Resource
{
$rows = Excel::toArray(null, $fullPath)[0];
if((count($rows) - 1) <= 0)
if ((count($rows) - 1) <= 0)
{
Notification::make()
->title('Records Not Found')
@@ -661,7 +740,7 @@ class InvoiceValidationResource extends Resource
foreach ($rows as $index => $row)
{
if ($index === 0) continue; // Skip header
if ($index == 0) continue; // Skip header
$materialCode = trim($row[0]);
$materialQuantity = trim($row[1]);
@@ -671,13 +750,13 @@ class InvoiceValidationResource extends Resource
}
if (!empty($materialCode)) {
if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
{
$invalidMatCodes[] = $materialCode;
}
else
{
if($materialQuantity == 0)
if ($materialQuantity == 0)
{
$invalidMaterialQuan[] = $materialCode;
}
@@ -685,7 +764,7 @@ class InvoiceValidationResource extends Resource
{
$missingQuantities[] = $materialCode;
}
else if(!is_numeric($materialQuantity))
else if (!is_numeric($materialQuantity))
{
$invalidMatQuan[] = $materialCode;
}
@@ -820,7 +899,7 @@ class InvoiceValidationResource extends Resource
}
return;
}
else if(count($invalidCodes) > 0)
else if (count($invalidCodes) > 0)
{
$invalidCodes = array_unique($invalidCodes);
Notification::make()
@@ -851,29 +930,29 @@ class InvoiceValidationResource extends Resource
foreach ($rows as $index => $row)
{
if ($index === 0) continue; // Skip header
if ($index == 0) continue; // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
if ($excelCode === $code && is_numeric($excelMatQty)) {
if ($excelCode == $code && is_numeric($excelMatQty)) {
$totalExcelQty += $excelMatQty; // Sum up the quantities
}
}
if ($totalExcelQty === 0) {
if ($totalExcelQty == 0) {
$zeroQtyCodes[] = $code;
} elseif (!is_numeric($totalExcelQty)) {
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty !== 0) {
} elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
$notDivisibleCodes[] = $code;
}
}
}
$showValidationNotification = function(array $codes, string $message) {
if (count($codes) === 0) return;
if (count($codes) == 0) return;
$uniqueCodes = array_unique($codes);
$codeList = implode(', ', $uniqueCodes);
@@ -929,6 +1008,16 @@ class InvoiceValidationResource extends Resource
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Radio::make('invoice_type')
->label('Type ?')
->boolean()
->options([
'Serial' => 'Serial',
'Material' => 'Material'
])
->default('Serial')
->inlineLabel(false)
->inline(),
Select::make('Plant')
->label('Select Plant')
->nullable()
@@ -938,6 +1027,7 @@ class InvoiceValidationResource extends Resource
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('sticker_master_id', null);
$set('operator_id', null);
}),
TextInput::make('invoice_number')
->label('Invoice Number')
@@ -962,6 +1052,31 @@ class InvoiceValidationResource extends Resource
})
->searchable()
->reactive(),
Select::make('scanned_status')
->label('Scanned Status')
->nullable()
->options([
'Scanned' => 'Scanned',
'Pending' => 'Pending',
])
->searchable()
->reactive(),
Select::make('operator_id')
->label('Created By')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if (!$plantId)
{
return InvoiceValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
else
{
return InvoiceValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
})
->searchable()
->reactive(),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
@@ -975,10 +1090,46 @@ class InvoiceValidationResource extends Resource
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
if (empty($data['invoice_type']))
{
Notification::make()
->title('Please, choose invoice type to filter.')
->danger()
->send();
}
return $query->whereRaw('1 = 0');
}
if ($data['invoice_type'] == 'Serial') {
$query->whereNull('quantity');
if (!empty($data['scanned_status'])) {
if ($data['scanned_status'] == 'Scanned') {
$query->whereNotNull('scanned_status')->where('scanned_status', '!=', '');
} elseif ($data['scanned_status'] == 'Pending') {
//$query->whereNull('scanned_status')->orWhere('scanned_status', '');
$query->where(function ($query) use ($data) {
// if (empty($data['scanned_status']) || $data['scanned_status'] == 'Pending') {
$query->whereNull('scanned_status')->orWhere('scanned_status', '!=', 'Scanned');
// }
});
}
}
} elseif ($data['invoice_type'] == 'Material') {
$query->whereNotNull('quantity');//->where('quantity', '>', 0)
if (!empty($data['scanned_status'])) {
if ($data['scanned_status'] == 'Scanned') {
$query->whereNotNull('serial_number')->where('serial_number', '!=', '');
} elseif ($data['scanned_status'] == 'Pending') {
$query->where(function ($query) use ($data) {
$query->whereNull('serial_number')->orWhere('serial_number', '=', '');
});
}
}
}
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
$query->where('plant_id', $data['Plant']);
}
@@ -999,6 +1150,10 @@ class InvoiceValidationResource extends Resource
$query->where('created_at', '<=', $data['created_to']);
}
if (!empty($data['operator_id'])) {
$query->where('operator_id', $data['operator_id']);
}
if (!empty($data['sticker_master_id'])) {
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
->pluck('id')
@@ -1024,6 +1179,15 @@ class InvoiceValidationResource extends Resource
$indicators[] = 'Serial Number: ' . $data['serial_number'];
}
if (!empty($data['sticker_master_id'])) {
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
$indicators[] = 'Item Code: ' . $itemCode;
}
if (!empty($data['operator_id'])) {
$indicators[] = 'Created By: ' . $data['operator_id'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
@@ -1032,9 +1196,8 @@ class InvoiceValidationResource extends Resource
$indicators[] = 'To: ' . $data['created_to'];
}
if (!empty($data['sticker_master_id'])) {
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
$indicators[] = 'Item Code: ' . $itemCode;
if (!empty($data['scanned_status'])) {
$indicators[] = 'Scanned Status: ' . $data['scanned_status'];
}
return $indicators;

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateItem extends CreateRecord
{
protected static string $resource = ItemResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -7,6 +7,7 @@ use App\Filament\Imports\LineImporter;
use App\Filament\Resources\LineResource\Pages;
use App\Filament\Resources\LineResource\RelationManagers;
use App\Models\Line;
use App\Models\WorkGroupMaster;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
@@ -175,12 +176,770 @@ class LineResource extends Resource
])
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('group_work_center')
->label('Group Work Center')
->placeholder('Scan the valid Group Work Center'),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
Forms\Components\TextInput::make('no_of_operation')
->label('No of Operation')
->required()
->numeric()
->reactive()
->minValue(0)
->maxValue(10)
->placeholder('Scan the valid No Of Operatrion')
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$partValidationColumns = [
'work_group1_id', 'work_group2_id', 'work_group3_id', 'work_group4_id',
'work_group5_id', 'work_group6_id', 'work_group7_id', 'work_group8_id',
'work_group9_id', 'work_group10_id',
];
foreach ($partValidationColumns as $column) {
$set($column . '_visible', false);
$set($column, null);
}
if (is_numeric($state) && $state > 0) {
for ($i = 1; $i <= (int) $state; $i++) {
$set("work_group{$i}_id_visible", true);
}
}
})
->afterStateHydrated(function (callable $set, $state) {
for ($i = 1; $i <= 10; $i++) {
$set("work_group{$i}_id_visible", $state >= $i);
}
}),
Forms\Components\Hidden::make('work_group1_id'),
Forms\Components\TextInput::make('work_group1_actual_id')
->label('Work Group Center 1')
->hidden(fn (callable $get) => !$get('work_group1_id_visible'))
->default('')
->reactive()
->required()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup1) {
$set('work_group1_actual_id', $record->workGroup1->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group1_id_error', null);
$set('work_group1_id', null);
return;
}
$set('work_group1_id_error', null);
$set('work_group1_id', null);
if (!$plantId) {
$set('work_group1_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group1_id_error', 'Work group does not exist for this plant in master.');
return;
}
// $existsInLines = Line::where(function ($query) use ($workGroupRecord) {
// for ($i = 1; $i <= 10; $i++) {
// $query->orWhere("work_group{$i}_id", $workGroupRecord->id);
// }
// })->count();
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group1_actual_id', '');
$set('work_group1_id', null);
return;
}
else
{
$set('work_group1_id_error', null);
$set('work_group1_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group1_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group1_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group2_id'),
Forms\Components\TextInput::make('work_group2_actual_id')
->label('Work Group Center 2')
->hidden(fn (callable $get) => !$get('work_group2_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup2) {
$set('work_group2_actual_id', $record->workGroup2->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group2_id_error', null);
$set('work_group2_id', null);
return;
}
$set('work_group2_id_error', null);
$set('work_group2_id', null);
if (!$plantId) {
$set('work_group2_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group2_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group2_actual_id', '');
$set('work_group2_id', null);
return;
}
else
{
$set('work_group2_id_error', null);
$set('work_group2_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group2_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group2_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group3_id'),
Forms\Components\TextInput::make('work_group3_actual_id')
->label('Work Group Center 3')
->hidden(fn (callable $get) => !$get('work_group3_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup3) {
$set('work_group3_actual_id', $record->workGroup3->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group3_id_error', null);
$set('work_group3_id', null);
return;
}
$set('work_group3_id_error', null);
$set('work_group3_id', null);
if (!$plantId) {
$set('work_group3_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group3_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group3_actual_id', '');
$set('work_group3_id', null);
return;
}
else
{
$set('work_group3_id_error', null);
$set('work_group3_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group3_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group3_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group4_id'),
Forms\Components\TextInput::make('work_group4_actual_id')
->label('Work Group Center 4')
->hidden(fn (callable $get) => !$get('work_group4_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup4) {
$set('work_group4_actual_id', $record->workGroup4->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group4_id_error', null);
$set('work_group4_id', null);
return;
}
$set('work_group4_id_error', null);
$set('work_group4_id', null);
if (!$plantId) {
$set('work_group4_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group4_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group4_actual_id', '');
$set('work_group4_id', null);
return;
}
else
{
$set('work_group4_id_error', null);
$set('work_group4_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group4_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group4_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group5_id'),
Forms\Components\TextInput::make('work_group5_actual_id')
->label('Work Group Center 5')
->hidden(fn (callable $get) => !$get('work_group5_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup5) {
$set('work_group5_actual_id', $record->workGroup5->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group5_id_error', null);
$set('work_group5_id', null);
return;
}
$set('work_group5_id_error', null);
$set('work_group5_id', null);
if (!$plantId) {
$set('work_group5_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group5_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group5_actual_id', '');
$set('work_group5_id', null);
return;
}
else
{
$set('work_group5_id_error', null);
$set('work_group5_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group5_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group5_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group6_id'),
Forms\Components\TextInput::make('work_group6_actual_id')
->label('Work Group Center 6')
->hidden(fn (callable $get) => !$get('work_group6_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup6) {
$set('work_group6_actual_id', $record->workGroup6->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group6_id_error', null);
$set('work_group6_id', null);
return;
}
$set('work_group6_id_error', null);
$set('work_group6_id', null);
if (!$plantId) {
$set('work_group6_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group6_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group6_actual_id', '');
$set('work_group6_id', null);
return;
}
else
{
$set('work_group6_id_error', null);
$set('work_group6_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group6_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group6_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group7_id'),
Forms\Components\TextInput::make('work_group7_actual_id')
->label('Work Group Center 7')
->hidden(fn (callable $get) => !$get('work_group7_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup7) {
$set('work_group7_actual_id', $record->workGroup7->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group7_id_error', null);
$set('work_group7_id', null);
return;
}
$set('work_group7_id_error', null);
$set('work_group7_id', null);
if (!$plantId) {
$set('work_group7_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group7_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group7_actual_id', '');
$set('work_group7_id', null);
return;
}
else
{
$set('work_group7_id_error', null);
$set('work_group7_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group7_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group7_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group8_id'),
Forms\Components\TextInput::make('work_group8_actual_id')
->label('Work Group Center 8')
->hidden(fn (callable $get) => !$get('work_group8_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup8) {
$set('work_group8_actual_id', $record->workGroup8->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group8_id_error', null);
$set('work_group8_id', null);
return;
}
$set('work_group8_id_error', null);
$set('work_group8_id', null);
if (!$plantId) {
$set('work_group8_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group8_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group8_actual_id', '');
$set('work_group8_id', null);
return;
}
else
{
$set('work_group8_id_error', null);
$set('work_group8_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group8_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group8_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group9_id'),
Forms\Components\TextInput::make('work_group9_actual_id')
->label('Work Group Center 9')
->hidden(fn (callable $get) => !$get('work_group9_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup9) {
$set('work_group9_actual_id', $record->workGroup9->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group9_id_error', null);
$set('work_group9_id', null);
return;
}
$set('work_group9_id_error', null);
$set('work_group9_id', null);
if (!$plantId) {
$set('work_group9_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group9_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group9_actual_id', '');
$set('work_group9_id', null);
return;
}
else
{
$set('work_group9_id_error', null);
$set('work_group9_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group9_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group9_id_error'))
->hintColor('danger'),
Forms\Components\Hidden::make('work_group10_id'),
Forms\Components\TextInput::make('work_group10_actual_id')
->label('Work Group Center 10')
->hidden(fn (callable $get) => !$get('work_group10_id_visible'))
->default('')
->required()
->reactive()
->afterStateHydrated(function (callable $set, $record) {
if ($record && $record->workGroup10) {
$set('work_group10_actual_id', $record->workGroup10->name);
}
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
// $workGroup1Id = $get('work_group1_actual_id');
$plantId = $get('plant_id');
$lineName = $get('name');
if ($state == null || trim($state) == '') {
$set('work_group10_id_error', null);
$set('work_group10_id', null);
return;
}
$set('work_group10_id_error', null);
$set('work_group10_id', null);
if (!$plantId) {
$set('work_group10_id_error', 'Invalid plant name.');
return;
}
$workGroupRecord = WorkGroupMaster::where('plant_id', $plantId)
->where('name', $state)
->first();
if (!$workGroupRecord) {
$set('work_group10_id_error', 'Work group does not exist for this plant in master.');
return;
}
$existsInLines = Line::where('plant_id', $plantId)
->where('name', '!=', $lineName) // Exclude current line
->where(function ($query) use ($workGroupRecord) {
for ($i = 1; $i <= 10; $i++) {
$query->orWhere("work_group{$i}_id", $workGroupRecord->id);
}
})
->count();
if ($existsInLines > 0) {
\Filament\Notifications\Notification::make()
->title('Work Group Already Assigned')
->body("The work group '{$state}' is already assigned to a line.")
->danger()
->send();
$set('work_group10_actual_id', '');
$set('work_group10_id', null);
return;
}
else
{
$set('work_group10_id_error', null);
$set('work_group10_id', $workGroupRecord->id);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('work_group10_id_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('work_group10_id_error'))
->hintColor('danger'),
// Forms\Components\TextInput::make('group_work_center')
// ->label('Group Work Center')
// ->placeholder('Scan the valid Group Work Center'),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
->columns(2),
]);
@@ -217,8 +976,107 @@ class LineResource extends Resource
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('group_work_center')
->label('Group Work Center')
Tables\Columns\TextColumn::make('no_of_operation')
->label('No of Operation')
->alignCenter()
->searchable(),
Tables\Columns\TextColumn::make('workGroup1.name')
->label('Work Group Center 1')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup1.operation_number')
->label('Operation Number 1')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup2.name')
->label('Work Group Center 2')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup2.operation_number')
->label('Operation Number 2')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup3.name')
->label('Work Group Center 3')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup3.operation_number')
->label('Operation Number 3')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup4.name')
->label('Work Group Center 4')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup4.operation_number')
->label('Operation Number 4')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup5.name')
->label('Work Group Center 5')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup5.operation_number')
->label('Operation Number 5')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup6.name')
->label('Work Group Center 6')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup6.operation_number')
->label('Operation Number 6')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup7.name')
->label('Work Group Center 7')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup7.operation_number')
->label('Operation Number 7')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup8.name')
->label('Work Group Center 8')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup8.operation_number')
->label('Operation Number 8')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup9.name')
->label('Work Group Center 9')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup9.operation_number')
->label('Operation Number 9')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup10.name')
->label('Work Group Center 10')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('workGroup10.operation_number')
->label('Operation Number 10')
->alignCenter()
->sortable()
->searchable(),

View File

@@ -5,8 +5,76 @@ namespace App\Filament\Resources\LineResource\Pages;
use App\Filament\Resources\LineResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Validation\ValidationException;
class CreateLine extends CreateRecord
{
protected static string $resource = LineResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
protected function beforeCreate(): void
{
$errors = [];
if (!empty($this->data['lPlantError'])) {
$errors['lPlantError'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['lNameError'])) {
$errors['lNameError'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['lTypeError'])) {
$errors['lTypeError'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group1_id_error'])) {
$errors['work_group1_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group2_id_error'])) {
$errors['work_group2_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group3_id_error'])) {
$errors['work_group1_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group4_id_error'])) {
$errors['work_group4_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group5_id_error'])) {
$errors['work_group5_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group6_id_error'])) {
$errors['work_group6_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group7_id_error'])) {
$errors['work_group7_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group8_id_error'])) {
$errors['work_group8_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($this->data['work_group9_id_error'])) {
$errors['work_group9_id_error'] = ['Fix the errors before submitting.'];
}
//..warranty
if (!empty($this->data['work_group10_id_error'])) {
$errors['work_group10_id_error'] = ['Fix the errors before submitting.'];
}
if (!empty($errors)) {
throw ValidationException::withMessages($errors);
}
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateLineStop extends CreateRecord
{
protected static string $resource = LineStopResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -21,7 +21,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-locator-invoice-validation';
public $plantId;
public $invoice_number;
public $pallet_number;
public $serial_number, $snoCount;
@@ -29,8 +31,13 @@ class CreateLocatorInvoiceValidation extends CreateRecord
public $locator_number;
public array $matchedSerialNumbersForRemoval = [];
public bool $showRemoveSerialsModal = false;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function processinvoiceSNo()
{

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateLocator extends CreateRecord
{
protected static string $resource = LocatorResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -8,6 +8,7 @@ use App\Filament\Resources\MachineResource\Pages;
use App\Filament\Resources\MachineResource\RelationManagers;
use App\Models\Line;
use App\Models\Machine;
use App\Models\WorkGroupMaster;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
@@ -30,7 +31,7 @@ class MachineResource extends Resource
protected static ?string $navigationGroup = 'Master Entries';
protected static ?int $navigationSort = 11;
protected static ?int $navigationSort = 12;
public static function form(Form $form): Form
{
@@ -49,6 +50,8 @@ class MachineResource extends Resource
$plantId = $get('plant_id');
if (!$plantId) {
$set('mPlantError', 'Please select a plant first.');
$set('line_id', null);
$set('work_group_master_id', null);
return;
}
else
@@ -71,9 +74,7 @@ class MachineResource extends Resource
return [];
}
return Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
return Line::where('plant_id', $get('plant_id'))->where('no_of_operation', '>', 0)->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Machine::latest()->first())->line_id;
@@ -83,17 +84,18 @@ class MachineResource extends Resource
$lineId = $get('line_id');
if (!$lineId) {
$set('mLineError', 'Please select a line first.');
$set('work_group_master_id', null);
return;
}
else
{
$grpWrkCnr = Line::find($lineId)->group_work_center;
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
{
$set('mLineError', 'Please select a group work center line.');
$set('line_id', null);
return;
}
// $grpWrkCnr = Line::find($lineId)->group_work_center;
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
// {
// $set('mLineError', 'Please select a group work center line.');
// $set('line_id', null);
// return;
// }
$set('mLineError', null);
}
})
@@ -102,19 +104,73 @@ class MachineResource extends Resource
])
->hint(fn ($get) => $get('mLineError') ? $get('mLineError') : null)
->hintColor('danger'),
Forms\Components\Select::make('work_group_master_id')
->label('Group Work Center')
->relationship('workGroupMaster', 'name')
->required()
->reactive()
->options(function (callable $get) {
if (!$get('plant_id') || !$get('line_id')) {
return [];
}
$line = Line::find($get('line_id'));
$workGroupIds = [];
for ($i = 1; $i <= $line->no_of_operation; $i++) {
$column = "work_group{$i}_id";
if (!empty($line->$column)) {
$workGroupIds[] = $line->$column;
}
}
return WorkGroupMaster::where('plant_id', $get('plant_id'))->whereIn('id', $workGroupIds)->pluck('name', 'id')->toArray();
})
->default(function () {
return optional(Machine::latest()->first())->work_group_master_id;
})
->disabled(fn (Get $get) => !empty($get('id')))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$lineId = $get('line_id');
if (!$lineId) {
$set('mGroupWorkError', 'Please select a line first.');
return;
}
else
{
// $grpWrkCnr = Line::find($lineId)->group_work_center;
// if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
// {
// $set('mGroupWorkError', 'Please select a group work center line.');
// $set('line_id', null);
// return;
// }
$set('mGroupWorkError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('mGroupWorkError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('mGroupWorkError') ? $get('mGroupWorkError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('name')
->label('Name')
->placeholder('Scan the valid Machine Name')
->required()
->rule(function (callable $get) {
return Rule::unique('machines', 'name')
->where('line_id', $get('line_id'))
//->where('line_id', $get('line_id'))
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TextInput::make('work_center')
->label('Work Center')
->placeholder('Scan the valid Work Center'),
->placeholder('Scan the valid Work Center')
->required()
->rule(function (callable $get) {
return Rule::unique('machines', 'work_center')
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
@@ -135,21 +191,26 @@ class MachineResource extends Resource
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->searchable()
->alignCenter(),
->alignCenter()
->searchable(),
Tables\Columns\TextColumn::make('line.name')
->label('Line')
->searchable()
->alignCenter(),
->alignCenter()
->searchable(),
Tables\Columns\TextColumn::make('name')
->label('Name')
->searchable()
->alignCenter(),
->alignCenter()
->searchable(),
Tables\Columns\TextColumn::make('work_center')
->label('Work Center')
->alignCenter()
->sortable()
->searchable(),
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('workGroupMaster.name')
->label('Work Group Center')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMachine extends CreateRecord
{
protected static string $resource = MachineResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -2,8 +2,11 @@
namespace App\Filament\Resources;
use App\Filament\Exports\MfmMeterExporter;
use App\Filament\Imports\MfmMeterImporter;
use App\Filament\Resources\MfmMeterResource\Pages;
use App\Filament\Resources\MfmMeterResource\RelationManagers;
use App\Models\DeviceMaster;
use App\Models\MfmMeter;
use Filament\Facades\Filament;
use Filament\Forms;
@@ -14,6 +17,8 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class MfmMeterResource extends Resource
{
@@ -32,6 +37,18 @@ class MfmMeterResource extends Resource
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->label('Plant')
->reactive()
->required(),
Forms\Components\Select::make('device_master_id')
//->relationship('device', 'name')
->options(function ($get) {
$plantId = $get('plant_id');
if (!$plantId) {
return [];
}
return DeviceMaster::where('plant_id', $plantId)->pluck('name', 'id');
})
->label('Device Name')
->required(),
Forms\Components\TextInput::make('sequence')
->required(),
@@ -49,13 +66,20 @@ class MfmMeterResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->sortable(),
Tables\Columns\TextColumn::make('devicemaster.name')
->label('Device Name')
->sortable(),
Tables\Columns\TextColumn::make('sequence')
->label('Sequence')
->sortable(),
@@ -91,6 +115,18 @@ class MfmMeterResource extends Resource
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->importer(MfmMeterImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import mfm meter');
}),
ExportAction::make()
->exporter(MfmMeterExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export mfm meter');
}),
]);
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMfmMeter extends CreateRecord
{
protected static string $resource = MfmMeterResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -36,6 +36,10 @@ class MfmParameterResource extends Resource
->label('Plant')
->relationship('plant', 'name')
->required(),
Forms\Components\Select::make('device_master_id')
->label('Device Master')
->relationship('deviceName', 'name')
->required(),
Forms\Components\Select::make('mfm_meter_id')
->label('Mfm Meter')
->relationship('mfmMeter', 'sequence')
@@ -61,7 +65,7 @@ class MfmParameterResource extends Resource
->default(1)
->required(),
])
->columns(8),
->columns(3),
]);
}
@@ -69,14 +73,22 @@ class MfmParameterResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('deviceName.name')
->label('Device Name')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('mfmMeter.name')
->label('Sequence')
->alignCenter()

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMfmParameter extends CreateRecord
{
protected static string $resource = MfmParameterResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -60,11 +60,14 @@ class MfmReadingResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->alignCenter()
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMfmReading extends CreateRecord
{
protected static string $resource = MfmReadingResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateModuleList extends CreateRecord
{
protected static string $resource = ModuleListResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -9,8 +9,13 @@ use App\Filament\Resources\MotorTestingMasterResource\RelationManagers;
use App\Models\Configuration;
use App\Models\Item;
use App\Models\MotorTestingMaster;
use App\Models\Plant;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
@@ -20,6 +25,7 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Filters\Filter;
use Illuminate\Validation\Rule;
class MotorTestingMasterResource extends Resource
@@ -28,9 +34,9 @@ class MotorTestingMasterResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Master Entries';
protected static ?string $navigationGroup = 'Testing Panel';
protected static ?int $navigationSort = 12;
protected static ?int $navigationSort = 1;
public static function form(Form $form): Form
{
@@ -61,6 +67,11 @@ class MotorTestingMasterResource extends Resource
])
->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null)
->hintColor('danger'),
Forms\Components\TimePicker::make('routine_test_time')
->label('Routine Test Time')
->default('00:40:00')
->required()
->reactive(),
Forms\Components\Select::make('item_id')
->label('Item Code')
//->relationship('item', 'name')
@@ -82,11 +93,39 @@ class MotorTestingMasterResource extends Resource
->where('plant_id', $get('plant_id'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TimePicker::make('routine_test_time')
->label('Routine Test Time')
->default('00:40:00')
Forms\Components\TextInput::make('subassembly_code')
->label('Subassembly Code')
->required()
->reactive(),
->placeholder('Scan the valid code')
->reactive()
->alphaNum()
->minLength(6)
->afterStateUpdated(function ($state, callable $set, callable $get) {
$code = $get('subassembly_code');
if (!$code) {
$set('iCodeError', 'Scan the valid Subassembly Code.');
return;
}
else
{
if (strlen($code) < 6) {
$set('iCodeError', 'Subassembly code must be at least 6 digits.');
return;
}
else if (!preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) {
$set('code',null);
$set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.');
return;
}
$set('iCodeError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('iCodeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null)
->hintColor('danger'),
Forms\Components\Select::make('isi_model')
->label('ISI Model')
->options([
@@ -102,11 +141,6 @@ class MotorTestingMasterResource extends Resource
->options(function (callable $get) {
$plantId = $get('plant_id');
// if (!$plantId || !$lineId)
// {
// return [];
// }
if ($plantId)
{
return Configuration::where('plant_id', $plantId)
@@ -283,26 +317,32 @@ class MotorTestingMasterResource extends Resource
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.category')
->label('Category')
->alignCenter()
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item Code')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('subassembly_code')
->label('Subassembly Code')
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.description')
->label('Model')
->alignCenter()
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\IconColumn::make('isi_model')
->label('ISI Model')
->searchable()
->alignCenter()
->boolean(),
Tables\Columns\TextColumn::make('phase')
@@ -332,6 +372,7 @@ class MotorTestingMasterResource extends Resource
->alignCenter(),
Tables\Columns\TextColumn::make('connection')
->label('Connection')
->searchable()
->alignCenter(),
Tables\Columns\TextColumn::make('ins_res_limit')
->label('Insulation Resistance Limit')
@@ -391,19 +432,25 @@ class MotorTestingMasterResource extends Resource
->label('No Load Speed UL')
->alignCenter(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter(),
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->dateTime()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter(),
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->alignCenter()
@@ -412,7 +459,287 @@ class MotorTestingMasterResource extends Resource
])
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Item', null);
$set('isi_type', null);
$set('created_by', null);
$set('updated_by', null);
}),
Select::make('Item')
->label('Search by Item Code')
->nullable()
->options(function (callable $get) {
$pId = $get('Plant');
return Item::whereHas('motorTestingMasters', function ($query) use ($pId) {
if ($pId) {
$query->where('plant_id', $pId);
}
})->pluck('code', 'id');
})
->searchable()
->reactive(),
TextInput::make('description')
->label('Description')
->placeholder('Enter Description'),
Radio::make('isi_type')
->label('ISI Model ?')
->boolean()
->options([
'All' => 'All',
'Y' => 'Y',
'N' => 'N'
])
->default(null)
->inlineLabel(false)
->inline(),
Select::make('phase_type')
->label('Select Phase')
->nullable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if ($plantId)
{
return Configuration::where('plant_id', $plantId)
->where('c_name', 'MOTOR_PHASE')
->orderBy('created_at')
->pluck('c_value', 'c_value')
->toArray();
}
else
{
return Configuration::where('c_name', 'MOTOR_PHASE')
->orderBy('created_at')
->pluck('c_value', 'c_value')
->toArray();
}
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
if ($state == 'Single' && $get('connection_type') == 'Star-Delta') {
$set('phase_type', 'Three');
}
})
->reactive(),
Select::make('connection_type')
->label('Select Connection')
->nullable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if ($plantId)
{
return Configuration::where('plant_id', $plantId)
->where('c_name', 'MOTOR_CONNECTION')
->orderBy('created_at')
->pluck('c_value', 'c_value')
->toArray();
}
else
{
return Configuration::where('c_name', 'MOTOR_CONNECTION')
->orderBy('created_at')
->pluck('c_value', 'c_value')
->toArray();
}
})
->afterStateUpdated(function ($state, callable $set) {
if ($state == 'Star-Delta') {
$set('phase_type', 'Three');
}
})
->reactive(),
Select::make('created_by')
->label('Created By')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if (!$plantId)
{
return MotorTestingMaster::whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
}
else
{
return MotorTestingMaster::where('plant_id', $plantId)->whereNotNull('created_by')->select('created_by')->distinct()->pluck('created_by', 'created_by');
}
})
->searchable()
->reactive(),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
Select::make('updated_by')
->label('Updated By')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
if (!$plantId)
{
return MotorTestingMaster::whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
}
else
{
return MotorTestingMaster::where('plant_id', $plantId)->whereNotNull('updated_by')->select('updated_by')->distinct()->pluck('updated_by', 'updated_by');
}
})
->searchable()
->reactive(),
DateTimePicker::make(name: 'updated_from')
->label('Updated From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('updated_to')
->label('Updated To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['Item']) && empty($data['description']) && empty($data['isi_type']) && empty($data['phase_type']) && empty($data['connection_type']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {// || $data['isi_type'] == 'All')
return $query->whereRaw('1 = 0');
}
if (!empty($data['Plant'])) {
$query->where('plant_id', $data['Plant']);
}
if (!empty($data['Item'])) {
$itemIds = Item::where('id', $data['Item'])
->pluck('id')
->toArray();
if (!empty($itemIds)) {
$query->whereIn('item_id', $itemIds);
}
}
if (!empty($data['description'])) {
$pId = $data['Plant'] ?? null;
$descIds = Item::where('description', 'like', '%' . $data['description'] . '%')->whereHas('motorTestingMasters', function ($query) use ($pId) {
if ($pId) { $query->where('plant_id', $pId); }
})->pluck('id')->toArray();
if (!empty($descIds)) {
$query->whereIn('item_id', $descIds);
}
}
if ($data['isi_type'] == 'Y') {
$query->where('isi_model', true);
}
else if ($data['isi_type'] == 'N') {
$query->where('isi_model', false);
}
if (!empty($data['phase_type'])) {
$query->where('phase', $data['phase_type']);
}
if (!empty($data['connection_type'])) {
$query->where('connection', $data['connection_type']);
}
if (!empty($data['created_by'])) {
$query->where('created_by', $data['created_by']);
}
if (!empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (!empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
if (!empty($data['updated_by'])) {
$query->where('updated_by', $data['updated_by']);
}
if (!empty($data['updated_from'])) {
$query->where('updated_at', '>=', $data['updated_from']);
}
if (!empty($data['updated_to'])) {
$query->where('updated_at', '<=', $data['updated_to']);
}
})
->indicateUsing(function (array $data) {
$indicators = [];
if (!empty($data['Plant'])) {
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
}
if (!empty($data['Item'])) {
$itemCode = Item::find($data['Item'])->code ?? 'Unknown';
$indicators[] = 'Item Codes: ' . $itemCode;
}
if (!empty($data['description'])) {
$indicators[] = 'Description: ' . $data['description'];
}
if ($data['isi_type'] == 'Y') {
$indicators[] = 'ISI Model: Yes';
}
else if ($data['isi_type'] == 'N') {
$indicators[] = 'ISI Model: No';
}
if (!empty($data['phase_type'])) {
$indicators[] = 'Phase: ' . $data['phase_type'];
}
if (!empty($data['connection_type'])) {
$indicators[] = 'Connection: ' . $data['connection_type'];
}
if (!empty($data['created_by'])) {
$indicators[] = 'Created By: ' . $data['created_by'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'Created From: ' . $data['created_from'];
}
if (!empty($data['created_to'])) {
$indicators[] = 'Created To: ' . $data['created_to'];
}
if (!empty($data['updated_by'])) {
$indicators[] = 'Updated By: ' . $data['updated_by'];
}
if (!empty($data['updated_from'])) {
$indicators[] = 'Updated From: ' . $data['updated_from'];
}
if (!empty($data['updated_to'])) {
$indicators[] = 'Updated To: ' . $data['updated_to'];
}
return $indicators;
})
])
->filtersFormMaxHeight('280px')
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateMotorTestingMaster extends CreateRecord
{
protected static string $resource = MotorTestingMasterResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -7,6 +7,7 @@ use App\Filament\Imports\PalletValidationImporter;
use App\Filament\Resources\PalletValidationResource\Pages;
use App\Filament\Resources\PalletValidationResource\RelationManagers;
use App\Models\Item;
use App\Models\LocatorInvoiceValidation;
use App\Models\PalletValidation;
use App\Models\Plant;
use App\Models\StickerMaster;
@@ -89,13 +90,29 @@ class PalletValidationResource extends Resource
$month = now()->format('m');
$prefix = "EP-{$year}{$month}";
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
$lastPallet1 = PalletValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first(); //->where('plant_id', $plantId)
$lastPallet2 = LocatorInvoiceValidation::where('pallet_number', 'like', "{$prefix}%")->orderByDesc('pallet_number')->first();
$newNumber = '001'; // $lastPallet ? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT) : '001';
if ($lastPallet) {
$serialPart = substr($lastPallet->pallet_number, strlen($prefix));
if ($lastPallet1 && $lastPallet2) {
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
if (intval($serialPart1) > intval($serialPart2)) {
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
} else {
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
}
}
else if ($lastPallet1) {
$serialPart1 = substr($lastPallet1->pallet_number, strlen($prefix));
// OR
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
$newNumber = str_pad(intval($serialPart) + 1, strlen($serialPart), '0', STR_PAD_LEFT);
$newNumber = str_pad(intval($serialPart1) + 1, strlen($serialPart1), '0', STR_PAD_LEFT);
}
else if ($lastPallet2) {
$serialPart2 = substr($lastPallet2->pallet_number, strlen($prefix));
// OR
// $serialPart = str_replace($prefix, '', $lastPallet->pallet_number);
$newNumber = str_pad(intval($serialPart2) + 1, strlen($serialPart2), '0', STR_PAD_LEFT);
}
$newPalletNumber = "{$prefix}{$newNumber}";
@@ -521,7 +538,7 @@ class PalletValidationResource extends Resource
])
->action(function (array $data) {
$selectedPalletNumber = $data['pallet_list'];
return redirect()->route('download-qr-pdf', ['palletNo' => $selectedPalletNumber]);
return redirect()->route('download-reprint-qr-pdf', ['palletNo' => $selectedPalletNumber]);
})
->visible(function() {

View File

@@ -14,17 +14,22 @@ use Illuminate\View\View;
class CreatePalletValidation extends CreateRecord
{
public $plantId;
public $pallet_number;
public $palletNo;
public $pendingPallet;
public $snoCount = 0;
public $pallet_number_locked = false;
public $serial_number;
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-pallet-validation';
protected static string $resource = PalletValidationResource::class;
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-pallet-validation';
protected static string $resource = PalletValidationResource::class;
protected $listeners = [
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
@@ -32,6 +37,10 @@ class CreatePalletValidation extends CreateRecord
public ?array $data = null;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function processPalletSNo()
{

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreatePlant extends CreateRecord
{
protected static string $resource = PlantResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -0,0 +1,360 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\ProcessOrderResource\Pages;
use App\Filament\Resources\ProcessOrderResource\RelationManagers;
use App\Models\ProcessOrder;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Storage;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Filament\Notifications\Notification;
use Filament\Forms\Components\Actions\Action;
use Filament\Facades\Filament;
use Smalot\PdfParser\Parser;
class ProcessOrderResource extends Resource
{
protected static ?string $model = ProcessOrder::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Process Order';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->relationship('plant', 'name')
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
// ->relationship('item', 'id')
// ->required(),
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
// dd($plantId);
if ($plantId && $itemId) {
// Get the item code using item_id
$itemCode = \App\Models\Item::where('id', $itemId)->value('code');
if ($itemCode) {
// Now get the item description using plant_id + code
$item = \App\Models\Item::where('plant_id', $plantId)
->where('code', $itemCode)
->first();
$set('item_description', $item?->description);
} else {
$set('item_description', null);
}
} else {
$set('item_description', null);
}
})
->required(),
Forms\Components\TextInput::make('item_description')
->label('Description')
->required()
->reactive(),
// ->readOnly(true),
Forms\Components\TextInput::make('process_order')
->label('Process Order')
->required(),
Forms\Components\FileUpload::make('attachment')
->label('PDF Upload')
->acceptedFileTypes(['application/pdf'])
->storeFiles(false)
->disk('local')
->directory('uploads/temp')
->preserveFilenames()
->reactive(),
Forms\Components\Actions::make([
Action::make('uploadNow')
->label('Upload PDF Now')
->action(function ($get, callable $set) {
$uploadedFiles = $get('attachment');
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
{
$uploaded = reset($uploadedFiles);
if ($uploaded instanceof TemporaryUploadedFile) {
$originalName = $uploaded->getClientOriginalName();
$path = 'uploads/ProcessOrder/' . $originalName;
// Check if file already exists
if (Storage::disk('local')->exists($path)) {
Notification::make()
->title('Duplicate File')
->body("The file '{$originalName}' already exists in uploads/ProcessOrder.")
->warning()
->send();
return; // Stop here
}
$storedPath = $uploaded->storeAs(
'uploads/ProcessOrder',
$originalName,
'local'
);
// $fullPath = storage_path('app/' . $storedPath);
$fullPath = storage_path('app/' . $storedPath);
// Parse PDF using smalot/pdfparser
$parser = new Parser();
$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
$text = $pdf->getText();
// if (preg_match('/Batch ID:\s*(\d+)\s*--/i', $text, $matches))
// {
// $batchId = $matches[1];
// }
if (preg_match('/Batch ID:\s*(\d+)(?:\s*--)?/i', $text, $matches)) {
$batchId = $matches[1];
}
else
{
$batchId = null;
}
// Get the value of process_order field
$processOrder = $get('process_order');
if ($batchId != $processOrder) {
Notification::make()
->title('Mismatch')
->body("Batch ID ($batchId) does not match Process Order ($processOrder)")
->danger()
->send();
return;
}
if ($batchId == $processOrder)
{
// If batch matches, store the PDF permanently
$storedPath = $uploaded->storeAs(
'uploads/ProcessOrder',
$originalName,
'local'
);
Notification::make()
->title('Success')
->body("Batch ID matches Process Order: $batchId. PDF uploaded successfully.")
->success()
->send();
return;
}
}
}
else
{
Notification::make()
->title('No file selected to upload')
->warning()
->send();
return;
}
}),
Action::make('downloadAttachment')
->label('Download PDF')
->action(function ($get) {
$equipmentNumber = $get('process_order');
if (!$equipmentNumber) {
Notification::make()
->title('No process order entered')
->danger()
->send();
return;
}
$files = Storage::disk('local')->files('uploads/ProcessOrder');
$fileToDownload = null;
foreach ($files as $file) {
if (str_contains($file, $equipmentNumber)) {
$fileToDownload = $file;
break;
}
}
if (!$fileToDownload) {
Notification::make()
->title('PDF not found for this process order')
->danger()
->send();
return;
}
return response()->download(Storage::disk('local')->path($fileToDownload));
}),
// Action::make('removeAttachment')
// ->label('Remove PDF')
// ->action(function ($get) {
// $equipmentNumber = $get('process_order');
// if (!$equipmentNumber) {
// Notification::make()
// ->title('No process order entered')
// ->danger()
// ->send();
// return;
// }
// // Get all files from uploads/temp
// $files = Storage::disk('local')->files('uploads/ProcessOrder');
// $fileToDelete = null;
// foreach ($files as $file) {
// if (str_contains($file, $equipmentNumber)) {
// $fileToDelete = $file;
// break;
// }
// }
// if (!$fileToDelete) {
// Notification::make()
// ->title('PDF not found for this process order')
// ->danger()
// ->send();
// return;
// }
// // Delete the matched file
// Storage::disk('local')->delete($fileToDelete);
// Notification::make()
// ->title('PDF removed successfully')
// ->body("File for process order {$equipmentNumber} has been deleted.")
// ->success()
// ->send();
// }),
]),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->default(Filament::auth()->user()?->name),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.description')
->label('Description')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListProcessOrders::route('/'),
'create' => Pages\CreateProcessOrder::route('/create'),
'view' => Pages\ViewProcessOrder::route('/{record}'),
'edit' => Pages\EditProcessOrder::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -319,8 +319,10 @@ class ProductionQuantityResource extends Resource
->label('Production Order')
->reactive()
->required()
->minLength(7)
->maxLength(14)
->columnSpan(2)
// ->rules(['regex:/^[1-9][0-9]{6,}$/'])
//->rules(['regex:/^[1-9][0-9]{6,}$/'])
// ->disabled(function ($get) {
// return $get('item_code');
// })
@@ -332,15 +334,35 @@ class ProductionQuantityResource extends Resource
return $latestProduction ? $latestProduction->production_order : null;
})
->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);
return;
// if (empty($state)) {
// }
}),
if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
{
$set('item_code', null);
$set('item_id', null);
$set('serial_number', null);
$set('production_order', null);
$set('prodOrdError', "Must be a numeric value with 7 to 14 digits.");
$set('validationError', null);
return;
}
else
{
$set('item_code', null);
$set('item_id', null);
// $set('item_description', null);
$set('serial_number', null);
$set('production_order', $state);
$set('prodOrdError', null);
$set('validationError', null);
return;
// if (empty($state)) {
// }
}
})
->extraAttributes(fn ($get) => [
'class' => $get('prodOrdError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('prodOrdError') ? $get('prodOrdError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('item_code')
->label('Item Code')
// ->required()
@@ -1035,6 +1057,7 @@ class ProductionQuantityResource extends Resource
$set('Shift', null);
$set('Item', null);
$set('sap_msg_status', null);
$set('operator_id', null);
}),
//line
@@ -1050,7 +1073,10 @@ class ProductionQuantityResource extends Resource
return Line::where('plant_id', $plantId)
->pluck('name', 'id');
})
->reactive(),
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('operator_id', null);
}),
//block
Select::make('Block')
@@ -1067,6 +1093,7 @@ class ProductionQuantityResource extends Resource
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('Shift', null);
$set('operator_id', null);
}),
//shift
@@ -1085,7 +1112,10 @@ class ProductionQuantityResource extends Resource
->where('block_id', $blockId)
->pluck('name', 'id');
})
->reactive(),
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('operator_id', null);
}),
TextInput::make('production_order')
->label('Production Order')
@@ -1133,6 +1163,37 @@ class ProductionQuantityResource extends Resource
// ->options(QualityValidation::whereNotNull('sap_msg_status')->select('sap_msg_status')->distinct()->pluck('sap_msg_status', 'sap_msg_status'))
->reactive(),
Select::make('operator_id')
->label('Created By')
->nullable()
->options(function (callable $get) {
$plantId = $get('Plant');
$lineId = $get('Line');
$shiftId = $get('Shift');
if (!$plantId && !$lineId && !$shiftId)
{
return ProductionQuantity::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
else if ($plantId && !$lineId && !$shiftId)
{
return ProductionQuantity::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
else if ($plantId && $lineId && !$shiftId)
{
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
else if ($plantId && !$lineId && $shiftId)
{
return ProductionQuantity::where('plant_id', $plantId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
else// if ($plantId && $lineId && $shiftId)
{
return ProductionQuantity::where('plant_id', $plantId)->where('line_id', $lineId)->where('shift_id', $shiftId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
}
})
->searchable()
->reactive(),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
@@ -1146,7 +1207,7 @@ class ProductionQuantityResource extends Resource
->native(false),
])
->query(function ($query, array $data) {
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
if (empty($data['Plant']) && empty($data['Shift']) && empty($data['Line']) && empty($data['production_order']) && empty($data['serial_number']) && empty($data['Item']) && empty($data['operator_id']) && empty($data['sap_msg_status']) && empty($data['created_from']) && empty($data['created_to'])) {
return $query->whereRaw('1 = 0');
}
@@ -1178,6 +1239,10 @@ class ProductionQuantityResource extends Resource
$query->where('sap_msg_status', $data['sap_msg_status']);
}
if (!empty($data['operator_id'])) {
$query->where('operator_id', $data['operator_id']);
}
if ($from = $data['created_from'] ?? null) {
$query->where('created_at', '>=', $from);
}
@@ -1185,6 +1250,7 @@ class ProductionQuantityResource extends Resource
if ($to = $data['created_to'] ?? null) {
$query->where('created_at', '<=', $to);
}
// return $query;
})
->indicateUsing(function (array $data) {
@@ -1218,6 +1284,10 @@ class ProductionQuantityResource extends Resource
$indicators[] = 'SAP Message Status: ' . $data['sap_msg_status'];
}
if (!empty($data['operator_id'])) {
$indicators[] = 'Created By: ' . $data['operator_id'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}

View File

@@ -335,7 +335,7 @@ class CreateProductionQuantity extends CreateRecord
->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,
@@ -354,7 +354,7 @@ class CreateProductionQuantity extends CreateRecord
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()
->seconds(2)
->send();

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,11 @@ class CreateReworkLocatorInvoiceValidation extends CreateRecord
protected static string $resource = ReworkLocatorInvoiceValidationResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
public function processInvoiceRework($invoiceNo)
{
$plantId = $this->form->getState()['plant'];

View File

@@ -9,4 +9,9 @@ use Filament\Resources\Pages\CreateRecord;
class CreateShift extends CreateRecord
{
protected static string $resource = ShiftResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -3,12 +3,12 @@
namespace App\Filament\Resources;
use App\Filament\Exports\StickerMasterExporter;
use App\Filament\Imports\ShiftImporter;
//use App\Filament\Imports\ShiftImporter;
use App\Filament\Imports\StickerMasterImporter;
use App\Filament\Resources\StickerMasterResource\Pages;
use App\Filament\Resources\StickerMasterResource\RelationManagers;
//use App\Filament\Resources\StickerMasterResource\RelationManagers;
use App\Models\StickerMaster;
use Closure;
//use Closure;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
@@ -18,6 +18,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Get;
use Filament\Forms\Set;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
// use Illuminate\Validation\Rule;
@@ -35,383 +36,401 @@ class StickerMasterResource extends Resource
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->reactive()
->nullable()
->default(function () {
return optional(StickerMaster::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
->afterStateUpdated(fn (callable $set) =>
$set('item_id', null) & //when plant changed remove all the data which is in text input box
$set('item_description', null) &
$set('item_error', null) &
$set('panel_box_code', null) &
$set('load_rate', null) &
$set('bundle_quantity', null) &
$set('material_type', null) &
$set('part_validation1', null) &
$set('part_validation2', null) &
$set('part_validation3', null) &
$set('part_validation4', null) &
$set('part_validation5', null) &
$set('laser_part_validation1', null) &
$set('laser_part_validation2', null) &
$set('serial_number_motor', false) &
$set('serial_number_pump', false) &
$set('serial_number_pumpset', false) &
$set('pack_slip_motor', false) &
$set('pack_slip_pump', false) &
$set('pack_slip_pumpset', false) &
$set('name_plate_motor', false) &
$set('name_plate_pump', false) &
$set('name_plate_pumpset', false) &
$set('tube_sticker_motor', false) &
$set('tube_sticker_pump', false) &
$set('tube_sticker_pumpset', false) &
$set('warranty_card', false)
)
->required(),
->schema([
Forms\Components\Select::make('plant_id')
->relationship('plant', 'name')
->reactive()
->nullable()
->default(function () {
return optional(StickerMaster::latest()->first())->plant_id;
})
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
->afterStateUpdated(fn (callable $set) =>
$set('item_id', null) & //when plant changed remove all the data which is in text input box
$set('item_description', null) &
$set('item_error', null) &
$set('panel_box_code', null) &
$set('load_rate', null) &
$set('bundle_quantity', null) &
$set('material_type', null) &
$set('part_validation1', null) &
$set('part_validation2', null) &
$set('part_validation3', null) &
$set('part_validation4', null) &
$set('part_validation5', null) &
$set('laser_part_validation1', null) &
$set('laser_part_validation2', null) &
$set('serial_number_motor', false) &
$set('serial_number_pump', false) &
$set('serial_number_pumpset', false) &
$set('pack_slip_motor', false) &
$set('pack_slip_pump', false) &
$set('pack_slip_pumpset', false) &
$set('name_plate_motor', false) &
$set('name_plate_pump', false) &
$set('name_plate_pumpset', false) &
$set('tube_sticker_motor', false) &
$set('tube_sticker_pump', false) &
$set('tube_sticker_pumpset', false) &
$set('warranty_card', false)
)
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
Forms\Components\Select::make('item_id')
->label('Item Code')
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
return \App\Models\Item::where('plant_id', $get('plant_id'))
->pluck('code', 'id')
->toArray();
})
// ->rule(function (callable $get) {
// return Rule::unique('items', 'code')
// ->where('plant_id', $get('plant_id'))
// ->ignore($get('id')); // Ignore current record during updates
// })
->required()
->nullable()
->searchable()
->reactive()
// ->disabled(fn (Get $get) => !empty($get('id')))
->live(debounce: 500) // Enable live updates
->afterStateUpdated(function ($state, callable $set, callable $get) {
return \App\Models\Item::where('plant_id', $get('plant_id'))
->pluck('code', 'id')
->toArray();
})
// ->rule(function (callable $get) {
// return Rule::unique('items', 'code')
// ->where('plant_id', $get('plant_id'))
// ->ignore($get('id')); // Ignore current record during updates
// })
->required()
->nullable()
->searchable()
->reactive()
// ->disabled(fn (Get $get) => !empty($get('id')))
->live(debounce: 500) // Enable live updates
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id');
$itemId = $get('item_id');
$plantId = $get('plant_id');
$itemId = $get('item_id');
//If plant_id is changed or empty, reset everything
if (blank($plantId)) {
$set('item_id', null);
$set('item_error', null);
$set('item_description', null);
return;
}
//If plant_id is changed or empty, reset everything
if (blank($plantId)) {
$set('item_id', null);
$set('item_error', null);
$set('item_description', null);
return;
}
if (blank($itemId)) {
$set('item_error', null);
$set('item_description', null);
return;
}
if (blank($itemId)) {
$set('item_error', null);
$set('item_description', null);
return;
}
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
if (!$availableItems) {
$set('item_error', null);
return;
}
$availableItems = \App\Models\Item::where('plant_id', $plantId)->exists();
if (!$availableItems) {
$set('item_error', null);
return;
}
// Ensure `item_id` is not cleared
if (!$plantId || !$itemId) {
$set('item_description', null);
return;
}
// Ensure `item_id` is not cleared
if (!$plantId || !$itemId) {
$set('item_description', null);
return;
}
// Check if item exists for the selected plant
$item = \App\Models\Item::where('plant_id', $plantId)
->where('id', $itemId)
->first();
// Check if item exists for the selected plant
$item = \App\Models\Item::where('plant_id', $plantId)
->where('id', $itemId)
->first();
if ($item) {
$set('item_description', $item->description);
} else {
$set('item_description', null);
}
if ($item) {
$set('item_description', $item->description);
} else {
$set('item_description', null);
}
$duplicateSticker = StickerMaster::where('plant_id', $plantId)
->where('item_id', $itemId)
->exists();
if(!$get('id'))
{
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('item_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('item_error') ? $get('item_error') : null)
->hintColor('danger'),
$duplicateSticker = StickerMaster::where('plant_id', $plantId)
->where('item_id', $itemId)
->exists();
if(!$get('id'))
{
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('item_error') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('item_error') ? $get('item_error') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('item_description')
->label('Description')
->required()
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
if ($get('id')) {
$itemId = StickerMaster::where('id', $get('id'))->first()?->item_id;
if ($itemId) {
$item = \App\Models\Item::where('id', $itemId)->first()?->description;
if ($item) {
$set('item_description', $item);
} else {
$set('item_description', null);
}
} else {
$set('item_description', null);
}
}
})
->reactive()
->readOnly(true),
Forms\Components\TextInput::make('part_validation1')
->label('Part Validation 1')
->nullable(),
Forms\Components\TextInput::make('item_description')
->label('Description')
->required()
->reactive()
->readOnly(true),
Forms\Components\TextInput::make('part_validation2')
->label('Part Validation 2')
->nullable(),
Forms\Components\TextInput::make('part_validation1')
->nullable(),
Forms\Components\TextInput::make('part_validation3')
->label('Part Validation 3')
->nullable(),
Forms\Components\TextInput::make('part_validation2')
->nullable(),
Forms\Components\TextInput::make('part_validation4')
->label('Part Validation 4')
->nullable(),
Forms\Components\TextInput::make('part_validation3')
->nullable(),
Forms\Components\TextInput::make('part_validation5')
->label('Part Validation 5 (Capacitor QR)')
->nullable(),
Forms\Components\TextInput::make('part_validation4')
->nullable(),
Forms\Components\TextInput::make('laser_part_validation1')
->label('Laser Part Validation 1')
->nullable(),
Forms\Components\TextInput::make('part_validation5')
->nullable(),
Forms\Components\TextInput::make('laser_part_validation2')
->label('Laser Part Validation 2')
->nullable(),
Forms\Components\TextInput::make('laser_part_validation1')
->nullable(),
Forms\Components\TextInput::make('panel_box_code')
->label('Panel Box Code')
->readOnly(fn (callable $get) => $get('material_type'))
->nullable(),
Forms\Components\TextInput::make('laser_part_validation2')
->nullable(),
Forms\Components\TextInput::make('load_rate')
->label('Load Rate')
->default(0)
->required()
->disabled(function ($get) {
return $get('material_type');
})
->integer(),
Forms\Components\TextInput::make('panel_box_code')
->label('Panel Box Code')
->readOnly(fn (callable $get) => $get('material_type'))
->nullable(),
Forms\Components\Select::make('material_type')
->label('Material Type')
->options([
'1' => 'Individual',
'2' => 'Bundle',
'3' => 'Quantity',
])
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
Forms\Components\TextInput::make('load_rate')
->label('Load Rate')
->default(0)
->disabled(function ($get) {
return $get('material_type');
})
->integer()
->nullable(),
if ($state)
{
$set('panel_box_code', null);
$set('load_rate', 0);
}
if ($state !== "2")
{
$set('bundle_quantity', null);
}
else
{
$set('bundle_quantity', 2);
}
//$plantId = $get('plant_id');
})
->nullable(),
Forms\Components\Select::make('material_type')
->label('Material Type')
->options([
'1' => 'Individual',
'2' => 'Bundle',
'3' => 'Quantity',
])
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
Forms\Components\TextInput::make('bundle_quantity')
->label('Bundle Quantity')
->integer()
->readOnly(fn (callable $get) => $get('material_type') !== "2")
->nullable()
->minValue(2)
->reactive()
->afterStateUpdated(function ($state, callable $set,callable $get) {
if($get('material_type') !== "2")
{
$set('bundle_quantity', null);
}
else if ($get('bundle_quantity') < 2)
{
$set('bundle_quantity', 2);
}
}),
if ($state)
{
$set('panel_box_code', null);
$set('load_rate', 0);
}
Forms\Components\Checkbox::make('serial_number_motor')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
}
})
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
if ($state !== "2")
{
$set('bundle_quantity', null);
}
else
{
$set('bundle_quantity', 2);
}
//$plantId = $get('plant_id');
})
->nullable(),
Forms\Components\Checkbox::make('serial_number_pump')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\TextInput::make('bundle_quantity')
->label('Bundle Quantity')
->integer()
->readOnly(fn (callable $get) => $get('material_type') !== "2")
->nullable()
->minValue(2)
->reactive()
->afterStateUpdated(function ($state, callable $set,callable $get) {
if($get('material_type') !== "2")
{
$set('bundle_quantity', null);
}
else if ($get('bundle_quantity') < 2)
{
$set('bundle_quantity', 2);
}
}),
Forms\Components\Checkbox::make('serial_number_pumpset')
->reactive()
->disabled(function ($get) {
return $get('serial_number_motor') || $get('serial_number_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_motor')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
}
})
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_motor')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_pump')
->reactive()
->disabled(function ($get) {
return $get('serial_number_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pump')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_pumpset')
->reactive()
->disabled(function ($get) {
return $get('serial_number_motor') || $get('serial_number_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('serial_number_pumpset'))
{
$set('serial_number_motor', false);
$set('serial_number_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pumpset')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_motor') || $get('pack_slip_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_motor')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_motor')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pump')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pump')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_pumpset')
->reactive()
->disabled(function ($get) {
return $get('pack_slip_motor') || $get('pack_slip_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('pack_slip_pumpset'))
{
$set('pack_slip_motor', false);
$set('pack_slip_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pumpset')
->reactive()
->disabled(function ($get) {
return $get('name_plate_motor') || $get('name_plate_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_motor')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_motor')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pump')
->reactive()
->disabled(function ($get) {
return $get('name_plate_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pump')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pumpset')
->reactive()
->disabled(function ($get) {
return $get('name_plate_motor') || $get('name_plate_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('name_plate_pumpset'))
{
$set('name_plate_motor', false);
$set('name_plate_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pumpset')
->nullable()
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_motor') || $get('tube_sticker_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
Forms\Components\Checkbox::make('tube_sticker_motor')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('warranty_card')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pump')
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_pumpset');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pumpset')
->nullable()
->reactive()
->disabled(function ($get) {
return $get('tube_sticker_motor') || $get('tube_sticker_pump');
})
->afterStateUpdated(function ($state, callable $set,callable $get) {
if ($get('tube_sticker_pumpset'))
{
$set('tube_sticker_motor', false);
$set('tube_sticker_pump', false);
}
})
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
Forms\Components\Checkbox::make('warranty_card')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]);
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]);
}
public static function table(Table $table): Table
@@ -424,13 +443,13 @@ class StickerMasterResource extends Resource
// ->numeric()
// ->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()

View File

@@ -21,4 +21,9 @@ class CreateStickerMaster extends CreateRecord
]);
}
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('create');
}
}

View File

@@ -2,6 +2,8 @@
namespace App\Filament\Resources;
use App\Filament\Exports\TempLiveReadingExporter;
use App\Filament\Imports\TempLiveReadingImporter;
use App\Filament\Resources\TempLiveReadingResource\Pages;
use App\Filament\Resources\TempLiveReadingResource\RelationManagers;
use App\Models\MfmMeter;
@@ -15,6 +17,9 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class TempLiveReadingResource extends Resource
{
@@ -62,10 +67,14 @@ class TempLiveReadingResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->numeric()
->sortable(),
@@ -105,6 +114,18 @@ class TempLiveReadingResource extends Resource
Tables\Actions\RestoreBulkAction::make(),
]),
]);
// ->headerActions([
// ImportAction::make()
// ->importer(TempLiveReadingImporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view import temp live reading');
// }),
// ExportAction::make()
// ->exporter(TempLiveReadingExporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view export temp live reading');
// }),
// ]);
}
public static function getRelations(): array
@@ -113,6 +134,16 @@ class TempLiveReadingResource extends Resource
//
];
}
public static function getNavigationLabel(): string
{
return 'Live Readings';
}
public static function getHeading(): string
{
return 'Live Readings';
}
public static function getPages(): array
{

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