From 89b555fc6677fa95ab9edbc146f02e16f313326d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 17 Mar 2026 17:01:40 +0530 Subject: [PATCH 1/5] FIX_LIVE_ISSUES_3 --- app/Config/Routes.php | 1 + app/Controllers/LeadsController.php | 43 ++++++++++++++++++----------- app/Controllers/UserController.php | 24 +++++++++++++++- app/Views/UserList.php | 34 +++++++++++++++++++++-- 4 files changed, 83 insertions(+), 19 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2325f818..09e6d227 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -100,6 +100,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->get("list", "UserController::list"); $routes->get("getuser/(:hash)", "UserController::getuser/$1"); $routes->get("deactive/(:hash)", "UserController::deactive/$1"); + $routes->get("activateUser/(:any)", "UserController::activateUser/$1"); $routes->get("rolesandteams", "UserController::getRolesAndTeams"); $routes->get("getUserActivityHistory", "UserController::getUserActivityHistory"); $routes->match(['get','post','put'], 'partner', 'UserController::partner'); diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index fd736c2a..95fe4d80 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -370,7 +370,9 @@ class LeadsController extends BaseController $actual_lead_id = ! empty($actual_lead_id) ? $actual_lead_id : null; $postData = $this->request->getPost(); $data = $this->prepareLeadData(); - $rules = [ + + + $rules = [ 'lead_type' => [ 'rules' => 'integer', @@ -380,21 +382,6 @@ class LeadsController extends BaseController 'rules' => 'required', 'errors' => ['required' => 'Issuer is required'], ], - 'entity_type_id' => [ - 'rules' => 'required', - 'errors' => ['required' => 'Entity Type is required'], - ], - 'client_name' => [ - 'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]', - 'errors' => [ - 'required' => 'Client Name is required', - 'regex_match' => 'Client Name only letters, numbers, space, hyphens and underscores are allowed', - ], - ], - 'client_short_name' => [ - 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', - 'errors' => ['required' => 'Client Short Name is required', 'regex_match' => 'Client Short Name only letters, numbers, hyphens and underscores are allowed'], - ], 'gst' => [ 'rules' => 'required|regex_match[/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/]', 'errors' => [ @@ -460,6 +447,30 @@ class LeadsController extends BaseController ], ]; + if (isset($postData['lead_type']) && $postData['lead_type'] == 1) { + + $rules['entity_type_id'] = [ + 'rules' => 'required', + 'errors' => ['required' => 'Entity Type is required'], + ]; + + $rules['client_name'] = [ + 'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]', + 'errors' => [ + 'required' => 'Client Name is required', + 'regex_match' => 'Client Name only letters, numbers, space, hyphens and underscores are allowed', + ], + ]; + + $rules['client_short_name'] = [ + 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', + 'errors' => [ + 'required' => 'Client Short Name is required', + 'regex_match' => 'Client Short Name only letters, numbers, hyphens and underscores are allowed' + ], + ]; + } + foreach ($postData as $key => $value) { // Check if the key starts with 'docs_name_' if (strpos($key, 'docs_name_') === 0) { diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 145ab807..bf6204e2 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -466,7 +466,29 @@ class UserController extends AdminController $emailToDelete = $model->where('id', $id)->first(); $deactive = $model->where('id', $id)->set(['is_active' => 0])->update(); - $this->bookStack->deleteUser($emailToDelete); + // $this->bookStack->deleteUser($emailToDelete); + if($deactive) + { + // $db = \Config\Database::connect(); + // $tableName = 'hdz_staff'; + + // $db->table($tableName)->insert($hdz_staff); + + + echo json_encode(array("status" => true)); + }else{ + echo json_encode(array("status" => false)); + } + } + + public function activateUser($id = null) + { + $model = new UserModel(); + + $emailToDelete = $model->where('id', $id)->first(); + $deactive = $model->where('id', $id)->set(['is_active' => 1])->update(); + + // $this->bookStack->deleteUser($emailToDelete); if($deactive) { // $db = \Config\Database::connect(); diff --git a/app/Views/UserList.php b/app/Views/UserList.php index 9659eaf4..bd898939 100755 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -389,7 +389,15 @@ table.dataTable tbody td { @@ -1201,7 +1209,29 @@ table.dataTable tbody td { }) } }); - }); + }); + + $('body').on('click', '.btnActivate', function () { + + Swal.fire({ + title: "Are you sure?", + text: "You need to active this user", + icon: "info", + showCancelButton: true, + confirmButtonColor: "#3085d6", + confirmButtonText: "Yes", + }).then((result) => { + if (result.isConfirmed) { + + var student_id = $(this).attr('data-id'); + $.get(''+student_id, function (data) { + console.log(data); + toastr.success('User actived successfully', 'Success'); + window.location.reload() + }) + } + }); + }); $('body').on('click', '.btnPartnerEdit', function () { let user = JSON.parse($(this).attr('data-obj')); // ✅ convert back to object From 948bde3e0badec070903864a38020d33cfaf8151 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 17 Mar 2026 21:57:46 +0530 Subject: [PATCH 2/5] FIX_LIVE_ISSUES_4 --- app/Controllers/ClientController.php | 103 ++++++++++++++++++++++++-- app/Controllers/TicketController.php | 16 +++- app/Views/cd_master_add_modal.php | 32 +++++++- app/Views/client_basic_info.php | 4 +- app/Views/newClientModal.php | 105 +++++++++++++++++++++++---- 5 files changed, 235 insertions(+), 25 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ee3a8098..7b570ae8 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1013,9 +1013,8 @@ class ClientController extends AdminController ] ], 'pan' => [ - 'rules' => 'required|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]', + 'rules' => 'permit_empty|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]', 'errors' => [ - 'required' => 'PAN Number is required.', 'regex_match' => 'Invalid PAN format. Example: ABCDE1234F' ] ], @@ -1129,9 +1128,8 @@ class ClientController extends AdminController ] ], 'pan' => [ - 'rules' => 'required|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]', + 'rules' => 'permit_empty|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]', 'errors' => [ - 'required' => 'PAN Number is required.', 'regex_match' => 'Invalid PAN format. Example: ABCDE1234F' ] ], @@ -5803,6 +5801,99 @@ class ClientController extends AdminController // print_r($postData); die; $client_type = $postData['client_type'] ?? null; + $from_modal = $postData['from_modal'] ?? null; + + $rules = [ + 'client_name' => [ + 'label' => 'Client Name', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9 ,\/_\-]+$/]', + 'errors' => [ + 'required' => 'Client Name is required.', + 'regex_match' => 'Client Name only allows letters, numbers, spaces, and , / _ -' + ] + ], + 'short_name' => [ + 'label' => 'Client Short Name', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9,\/_\-]+$/]|is_unique[clients.short_name]', + 'errors' => [ + 'required' => 'Short Name is required.', + 'regex_match' => 'Short Name only allows letters, numbers, and , / _ -', + 'is_unique' => 'This Short Name is already in use.' + ] + ], + 'pan' => [ + 'label' => 'PAN', + 'rules' => 'permit_empty|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]{1}$/]', + 'errors' => [ + 'regex_match' => 'Invalid PAN format (Example: ABCDE1234F).' + ] + ], + 'entity_type_id' => [ + 'label' => 'Entity Type', + 'rules' => 'required', + 'errors' => [ + 'required' => 'Please select an Entity Type.' + ] + ], + 'branch_name' => [ + 'label' => 'Branch Name', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9 ,\/_\-]+$/]', + 'errors' => [ + 'required' => 'Branch Name is required.', + 'regex_match' => 'Branch Name only allows letters, numbers, spaces, and , / _ -' + ] + ], + 'branch_code' => [ + 'label' => 'Branch Code', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9,\/_\-]+$/]', + 'errors' => [ + 'required' => 'Branch Code is required.', + 'regex_match' => 'Branch Code only allows letters, numbers, and , / _ -' + ] + ], + 'name' => [ + 'label' => 'Contact Person Name', + 'rules' => 'required|regex_match[/^[a-zA-Z0-9 ,\/_\-]+$/]', + 'errors' => [ + 'required' => 'Name is required.', + 'regex_match' => 'Name only allows letters, numbers, spaces, and , / _ -' + ] + ], + 'mobile' => [ + 'label' => 'Mobile', + 'rules' => 'required|numeric|exact_length[10]', + 'errors' => [ + 'required' => 'Mobile number is required.', + 'numeric' => 'Mobile must contain only digits.', + 'exact_length' => 'Mobile number must be exactly 10 digits.' + ] + ], + 'email' => [ + 'label' => 'Email', + 'rules' => 'required|valid_email', + 'errors' => [ + 'required' => 'Email is required.', + 'valid_email' => 'Please provide a valid email address.' + ] + ], + 'gst' => [ + 'label' => 'GST', + 'rules' => 'required|regex_match[/^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$/]', + 'errors' => [ + 'required' => 'GST Number is required.', + 'regex_match' => 'Invalid GST format (Example: 12ABCDE1234F5Z6).' + ] + ] + ]; + + if (isset($from_modal) && !$this->validate($rules)) { + return $this->response->setStatusCode(400)->setJSON([ + 'status' => false, + 'message' => 'Input validation failed', + 'code' => 400, + 'errors' => $this->validator->getErrors() + ]); + } $client_insert = null; if ($client_type == 2) { @@ -5928,7 +6019,8 @@ class ClientController extends AdminController ], ]; - if (!$this->validate($rules)) { + + if (!$this->validate($rules)) { return $this->response->setStatusCode(400)->setJSON([ 'status' => false, 'message' => 'Input validation failed', @@ -5936,6 +6028,7 @@ class ClientController extends AdminController 'errors' => $this->validator->getErrors() ]); } + $data = $this->request->getPost(); $sanitized_post_data = sanitizeInputArrayAdvanced($data); $id = $sanitized_post_data['vehicle_primary_key'] ?? null; diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index dfbac180..2d99b088 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -1290,7 +1290,13 @@ class TicketController extends BaseController ] ], // --- ADDITIONAL / CONDITIONAL FIELDS --- - 'claim_number' => ['label' => 'Claim Number','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'Invalid Claim Number.']], + 'claim_number' => [ + 'label' => 'Claim Number', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\/_-]+$/]', + 'errors' => [ + 'regex_match' => 'Claim Number only allows letters, numbers, slashes (/), hyphens (-), and underscores (_).' + ] + ], 'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']], 'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric', 'errors' => ['numeric' => 'Approved amount must be numeric'] @@ -1649,7 +1655,13 @@ class TicketController extends BaseController ], // --- ADDITIONAL / CONDITIONAL FIELDS --- - 'claim_number' => ['label' => 'Claim Number','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'Invalid Claim Number.']], + 'claim_number' => [ + 'label' => 'Claim Number', + 'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\/_-]+$/]', + 'errors' => [ + 'regex_match' => 'Claim Number only allows letters, numbers, slashes (/), hyphens (-), and underscores (_).' + ] + ], 'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']], 'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric', 'errors' => ['numeric' => 'Approved amount must be numeric'] diff --git a/app/Views/cd_master_add_modal.php b/app/Views/cd_master_add_modal.php index c8bf0f05..28579d01 100644 --- a/app/Views/cd_master_add_modal.php +++ b/app/Views/cd_master_add_modal.php @@ -67,8 +67,7 @@
- - +
@@ -366,4 +365,33 @@ } } + $(document).ready(function() { + // Target the input by its ID + $('#cd_ac_no_for_cd_master').on('keypress', function(e) { + // Get the character code + var keyCode = e.which || e.keyCode; + var char = String.fromCharCode(keyCode); + + // Regular Expression: allow a-z, A-Z, 0-9, /, -, _ + // If the character doesn't match, prevent it from being typed + var regex = /^[a-zA-Z0-9\/_-]+$/; + + if (!regex.test(char)) { + e.preventDefault(); + // Optional: Show a quick error message in your span + $('#cd_ac_no_for_cd_master_errorr').text('Character not allowed').fadeOut(2000, function() { + $(this).text('').show(); + }); + return false; + } + }); + + // Also handle "Paste" to ensure invalid data isn't pasted in + $('#cd_ac_no_for_cd_master').on('input', function() { + var value = $(this).val(); + var sanitized = value.replace(/[^a-zA-Z0-9\/_-]/g, ''); + $(this).val(sanitized); + }); + }); + \ No newline at end of file diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php index a8de6ec7..2227c841 100755 --- a/app/Views/client_basic_info.php +++ b/app/Views/client_basic_info.php @@ -124,8 +124,8 @@ input:checked + .slider:before {
- - + +