From 5c6cf90d8bb914c21d651c97f2054db8966b3e5f Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Thu, 12 Feb 2026 16:42:56 +0530 Subject: [PATCH 1/3] FIX_Tracker Issues --- app/Controllers/ClientController.php | 144 ++++++++++++++++++++------- app/Controllers/LeadsController.php | 6 +- app/Controllers/TicketController.php | 24 ++--- app/Views/ticket_form_handler.php | 29 ++++++ 4 files changed, 150 insertions(+), 53 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 36e86924..2343b08d 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -992,7 +992,7 @@ class ClientController extends AdminController 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[2]|max_length[45]', 'errors' => [ 'required' => 'Client Name is required', - 'regex_match' => 'Client Name can only contain letters, numbers, spaces, hyphens(-) and underscores(_).', + 'regex_match' => 'Client Name can only contain letters, numbers, spaces, hyphens and underscores.', 'min_length' => 'Client Name must be at least 2 characters.', 'max_length' => 'Client Name must not exceed 45 characters.', ] @@ -1001,7 +1001,7 @@ class ClientController extends AdminController 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]|min_length[2]|max_length[15]', 'errors' => [ 'required' => 'Client Short Name is required', - 'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens(-) and underscores(_).', + 'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.', 'min_length' => 'Client Short Name must be at least 2 characters.', 'max_length' => 'Client Short Name must not exceed 15 characters.', ] @@ -1019,21 +1019,30 @@ class ClientController extends AdminController 'required' => 'HR File Processed By is required.', ] ], + // 'client_logo' => [ + // 'rules' => [ + // 'uploaded[client_logo]', // Add this to check if a file was actually sent + // 'is_image[client_logo]', + // 'max_size[client_logo,200]', + // 'ext_in[client_logo,jpg,jpeg,png]', + // 'max_dims[client_logo,100,100]', + // ], + // 'errors' => [ + // 'uploaded' => 'Please upload a client logo', + // 'is_image' => 'The uploaded file must be an image', + // 'max_size' => 'File size should not exceed 200 KB', + // 'ext_in' => 'Allowed file types: jpg, jpeg, png', + // 'max_dims' => 'Image dimensions must be 100 x 100 pixels', + // ] + // ], 'client_logo' => [ - 'rules' => [ - 'uploaded[client_logo]', // Add this to check if a file was actually sent - 'is_image[client_logo]', - 'max_size[client_logo,200]', - 'ext_in[client_logo,jpg,jpeg,png]', - 'max_dims[client_logo,100,100]', - ], - 'errors' => [ - 'uploaded' => 'Please upload a client logo', - 'is_image' => 'The uploaded file must be an image', - 'max_size' => 'File size should not exceed 200 KB', - 'ext_in' => 'Allowed file types: jpg, jpeg, png', - 'max_dims' => 'Image dimensions must be 100 x 100 pixels', - ] + 'rules' => 'permit_empty|is_image[client_logo]|max_size[client_logo,200]|ext_in[client_logo,jpg,jpeg,png]|max_dims[client_logo,100,100]', + 'errors' => [ + 'is_image' => 'The uploaded file must be an image', + 'max_size' => 'File size should not exceed 200 KB', + 'ext_in' => 'Allowed file types: jpg, jpeg, png', + 'max_dims' => 'Image dimensions must be 100 x 100 pixels', + ] ], ]; @@ -1086,6 +1095,65 @@ class ClientController extends AdminController public function editClientGeneralInfo() { + $rules = [ + 'entity_type_id' => [ + 'rules' => 'required|numeric', + 'errors' => [ + 'required' => 'Entity Type is required', + 'numeric' => 'Invalid Entity Type selected' + ] + ], + 'client_name' => [ + 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]', + 'errors' => [ + 'required' => 'Client Name is required', + 'regex_match' => 'Client Name can only contain letters, numbers, spaces, hyphens and underscores.', + 'min_length' => 'Client Name must be at least 2 characters.', + 'max_length' => 'Client Name must not exceed 45 characters.', + ] + ], + 'short_name' => [ + 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', + 'errors' => [ + 'required' => 'Client Short Name is required', + 'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.', + 'min_length' => 'Client Short Name must be at least 2 characters.', + 'max_length' => 'Client Short Name must not exceed 15 characters.', + ] + ], + 'pan' => [ + 'rules' => 'required|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]', + 'errors' => [ + 'required' => 'PAN Number is required.', + 'regex_match' => 'Invalid PAN format. Example: ABCDE1234F' + ] + ], + 'hr_file_processed_by' => [ + 'rules' => 'required', + 'errors' => [ + 'required' => 'HR File Processed By is required.', + ] + ], + 'client_logo' => [ + 'rules' => 'permit_empty|is_image[client_logo]|max_size[client_logo,200]|ext_in[client_logo,jpg,jpeg,png]|max_dims[client_logo,100,100]', + 'errors' => [ + 'is_image' => 'The uploaded file must be an image', + 'max_size' => 'File size should not exceed 200 KB', + 'ext_in' => 'Allowed file types: jpg, jpeg, png', + 'max_dims' => 'Image dimensions must be 100 x 100 pixels', + ] + ], + ]; + + if (!$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } + $this->myLogger->logme('error', 'edit client general info function called'); $uploadFilePath = ROOTPATH . 'public/uploads/logo/'; $file_name = file_Upload($this->request->getFile('client_logo'), $uploadFilePath); @@ -1568,14 +1636,14 @@ class ClientController extends AdminController ] ], ]; - if (!$this->validate($rules)) { - return $this->response->setStatusCode(400)->setJSON([ - 'status' => false, - 'message' => 'Input validation failed', - 'code' => 400, - 'errors' => $this->validator->getErrors() - ]); - } + // if (!$this->validate($rules)) { + // return $this->response->setStatusCode(400)->setJSON([ + // 'status' => false, + // 'message' => 'Input validation failed', + // 'code' => 400, + // 'errors' => $this->validator->getErrors() + // ]); + // } $data['client_id'] = $this->request->getPost('client_id'); $data['created_by'] = get_session_userid(); @@ -1738,14 +1806,14 @@ class ClientController extends AdminController 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[3]', 'errors' => [ 'required' => 'Branch Name is required', - 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens(-) and underscores(_).', + 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores.', ] ], 'branch_code' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', 'errors' => [ 'required' => 'Branch Code is required', - 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens(-) and underscores(_).', + 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores.', ] ], 'address1' => [ @@ -1757,11 +1825,13 @@ class ClientController extends AdminController ], 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', - 'errors' => [ - 'required' => 'State is required.', - 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' - ] + 'rules' => 'required', + 'errors' => ['required' => 'State is required.'] + // 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + // 'errors' => [ + // 'required' => 'State is required.', + // 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' + // ] ], 'district' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]', @@ -2142,7 +2212,7 @@ class ClientController extends AdminController 'errors' => [ 'required' => 'Branch Name is required', 'min_length' => 'Branch Name must be at least 3 characters long', - 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens(-) and underscores(_).' + 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores.' ] ], 'branch_code' => [ @@ -2151,7 +2221,7 @@ class ClientController extends AdminController 'errors' => [ 'required' => 'Branch Code is required', 'min_length' => 'Branch Code must be at least 2 characters long', - 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens(-) and underscores(_).' + 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores.' ] ], 'address1' => [ @@ -2201,7 +2271,7 @@ class ClientController extends AdminController 'errors' => [ 'required' => 'Contact name is required', 'min_length' => 'Contact name must be at least 3 characters long', - 'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens(-) and underscores(_).' + 'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens and underscores.' ] ], 'designation.*' => [ @@ -2329,7 +2399,7 @@ class ClientController extends AdminController 'errors' => [ 'required' => 'Branch Name is required', 'min_length' => 'Branch Name must be at least 3 characters long', - 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens(-) and underscores(_).' + 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores.' ] ], 'branch_code' => [ @@ -2338,7 +2408,7 @@ class ClientController extends AdminController 'errors' => [ 'required' => 'Branch Code is required', 'min_length' => 'Branch Code must be at least 2 characters long', - 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens(-) and underscores(_).' + 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores.' ] ], 'address1' => [ @@ -2388,7 +2458,7 @@ class ClientController extends AdminController 'errors' => [ 'required' => 'Contact name is required', 'min_length' => 'Contact name must be at least 3 characters long', - 'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens(-) and underscores(_).' + 'regex_match' => 'Contact name can only contain letters, numbers, spaces, hyphens and underscores.' ] ], 'designation.*' => [ diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 6521effa..958d7eba 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -418,7 +418,7 @@ class LeadsController extends BaseController 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]|min_length[3]', 'errors' => [ 'required' => 'Branch Name is required.', - 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens(-) and underscores(_)..', + 'regex_match' => 'Branch Name can only contain letters, numbers, spaces, hyphens and underscores..', 'min_length' => 'Branch Name must be at least 3 characters long.' ] ], @@ -426,14 +426,14 @@ class LeadsController extends BaseController 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', 'errors' => [ 'required' => 'Branch Code is required.', - 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens(-) and underscores(_)..' + 'regex_match' => 'Branch Code can only contain letters, numbers, hyphens and underscores..' ] ], 'contact_person_name' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]', 'errors' => [ 'required' => 'Contact Person Name is required', - 'regex_match' => 'Contact person name only letters, numbers and spaces, hyphens(-) and underscores(_)..' + 'regex_match' => 'Contact person name only letters, numbers and spaces, hyphens and underscores..' ] ], 'contact_person_mobile' => [ diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 562fe5e3..59a2b22a 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1140,7 +1140,7 @@ class TicketController extends BaseController 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'errors' => [ 'required' => 'Employee Code is required.', - 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens(-) and underscores(_). allowed).' + 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).' ] ], 'emp_name' => [ @@ -1173,7 +1173,9 @@ class TicketController extends BaseController 'regex_match' => 'Policy Number can only contain letters, numbers, spaces, hyphens(-) underscores(_), and slashes(/).' ] ], - 'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty','errors' => []], + 'tpa_no' => ['label' => 'TPA ID','rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9]+$/]','errors' => [ + 'regex_match' => 'TPA ID can only contain letters and numbers.' + ]], 'emp_mobile' => ['label' => 'Employee Mobile No','rules' => 'required|numeric|exact_length[10]', 'errors' => [ 'required' => 'Mobile number is required', @@ -1189,9 +1191,8 @@ class TicketController extends BaseController ] ], 'emp_personal_mail' => ['label' => 'Personal Mail ID', - 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'errors' => [ - 'required' => 'Personal Email address is required.', 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' ] ], @@ -1335,7 +1336,7 @@ class TicketController extends BaseController 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'errors' => [ 'required' => 'Employee Code is required.', - 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens(-) and underscores(_). allowed).', + 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).', ] ], 'emp_name' => [ @@ -1362,9 +1363,8 @@ class TicketController extends BaseController ] ], 'emp_personal_mail' => ['label' => 'Personal Mail ID', - 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'errors' => [ - 'required' => 'Personal Email address is required.', 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' ] ], @@ -1475,7 +1475,7 @@ class TicketController extends BaseController 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'errors' => [ 'required' => 'Employee Code is required.', - 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens(-) and underscores(_). allowed).', + 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).', ] ], 'emp_name' => [ @@ -1526,9 +1526,8 @@ class TicketController extends BaseController ] ], 'emp_personal_mail' => ['label' => 'Personal Mail ID', - 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'errors' => [ - 'required' => 'Personal Email address is required.', 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' ] ], @@ -1687,7 +1686,7 @@ class TicketController extends BaseController 'rules' => 'required|min_length[2]|max_length[20]|regex_match[/^[a-zA-Z0-9_-]+$/]', 'errors' => [ 'required' => 'Employee Code is required.', - 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens(-) and underscores(_). allowed).', + 'regex_match' => 'Employee Code cannot contain spaces or special characters (only letters, numbers, hyphens and underscores. allowed).', ] ], 'emp_name' => [ @@ -1714,9 +1713,8 @@ class TicketController extends BaseController ] ], 'emp_personal_mail' => ['label' => 'Personal Mail ID', - 'rules' => 'required|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/]', 'errors' => [ - 'required' => 'Personal Email address is required.', 'regex_match' => 'Please enter a valid email format (e.g., name@domain.com).' ] ], diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index d744931e..268a25d2 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -383,12 +383,23 @@ let $label = $('#employee_data_points_label'); let $input = $('#emp_mobile_number_for_claim'); + // Remove old attributes but DO NOT clear the .val() + $input.removeAttr('onkeypress maxlength oninput'); + if (value == "mobile") { $label.text('Employee Mobile Number'); $input.attr('onkeypress', 'return onlyNumbers(event)').attr('maxlength', '10'); + + $input.val($input.val().replace(/[^0-9]/g, '').substring(0, 10)); + $input.attr('oninput', "this.value = this.value.replace(/[^0-9]/g, '').substring(0, 10)"); } else { $label.text('Employee ID'); $input.removeAttr('onkeypress maxlength'); + + $input.attr('onkeypress', 'return onlyEmployee(event)'); + $input.val($input.val().replace(/[^a-zA-Z0-9\s\-_/]/g, '')); + $input.attr('oninput', "this.value = this.value.replace(/[^a-zA-Z0-9\\s\\-_/]/g, '')"); + } }); @@ -1069,6 +1080,24 @@ return false; } + function onlyEmployee(event) { + var charCode = (event.which) ? event.which : event.keyCode; + + // Allow Numbers (48-57) + // Allow Uppercase (65-90) + // Allow Lowercase (97-122) + // Allow Space (32), Hyphen (45), Underscore (95), Forward Slash (47) + if ( + (charCode >= 48 && charCode <= 57) || + (charCode >= 65 && charCode <= 90) || + (charCode >= 97 && charCode <= 122) || + [32, 45, 95, 47].includes(charCode) + ) { + return true; + } + return false; + } + function setClientPolicyData(input) { // console.log('policy_value ',input); From afaa70a3a078561561a13fc5983122ab1f47ed65 Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Thu, 12 Feb 2026 16:51:02 +0530 Subject: [PATCH 2/3] FIX_ClaimsEditSection --- app/Controllers/TicketController.php | 29 ---------------------------- 1 file changed, 29 deletions(-) diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 59a2b22a..076d1303 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1566,35 +1566,6 @@ class TicketController extends BaseController 'hospital_pin_code' => ['label' => 'Hospital Pincode','rules' => 'required|numeric|exact_length[6]', 'errors' => ['exact_length' => 'Pincode must be 6 digits'] ], - 'state' => [ - 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', - 'errors' => [ - 'required' => 'State is required.', - 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' - ] - ], - 'district' => [ - 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]', - 'errors' => [ - 'required' => 'District is required.', - 'regex_match' => 'District can contain letters, numbers, spaces, and hyphens.' - ] - ], - 'city' => [ - 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]', - 'errors' => [ - 'regex_match' => 'City can contain letters, numbers, spaces, and hyphens.' - ] - ], - 'pincode' => [ - 'rules' => 'required|numeric|exact_length[6]', - 'errors' => [ - 'required' => 'Pincode is required.', - 'numeric' => 'Pincode must be digits only.', - 'exact_length' => 'Pincode must be exactly 6 digits.' - ] - ], 'hospital_phone_no' => ['label' => 'Hospital Phone','rules' => 'required|numeric|min_length[10]', 'errors' => ['min_length' => 'Phone number too short'] ], From 0f7258a0ee605a0aad2e85012504b74e0227054e Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Thu, 12 Feb 2026 16:58:29 +0530 Subject: [PATCH 3/3] FIX_BranchState --- app/Controllers/ClientController.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 2343b08d..af024fd7 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2232,10 +2232,11 @@ class ClientController extends AdminController ], 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + // 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', + 'rules' => 'required', 'errors' => [ 'required' => 'State is required.', - 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' + // 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' ] ], 'district' => [ @@ -2419,11 +2420,8 @@ class ClientController extends AdminController ], 'state' => [ 'label' => 'State', - 'rules' => 'required|regex_match[/^[a-zA-Z\s\-]+$/]', - 'errors' => [ - 'required' => 'State is required.', - 'regex_match' => 'State name can only contain letters, spaces, and hyphens.' - ] + 'rules' => 'required', + 'errors' => ['required' => 'State is required.'] ], 'district' => [ 'rules' => 'required|regex_match[/^[a-zA-Z0-9\s\-]+$/]',