From e45959011db96bc375c3a0a8c55633c2e7a0c03a Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 10:23:14 +0530 Subject: [PATCH 01/16] GWM : sms integration --- app/Config/Autoload.php | 2 +- app/Controllers/ICICILombardController.php | 69 ++++++++++++++----- .../RestAuthenticationController.php | 40 +++++++++-- app/Helpers/sms_helper.php | 40 +++++++++++ 4 files changed, 127 insertions(+), 24 deletions(-) create mode 100644 app/Helpers/sms_helper.php diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index be0e2476..62b24b8d 100755 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -101,6 +101,6 @@ class Autoload extends AutoloadConfig * @phpstan-var list */ public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', - 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper', 'api_helper','exception' + 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper', 'api_helper','exception','sms_helper' ]; } diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php index 928fbc2f..5c5bc627 100644 --- a/app/Controllers/ICICILombardController.php +++ b/app/Controllers/ICICILombardController.php @@ -67,24 +67,57 @@ class ICICILombardController extends AdminController //Prepare body data - $db = \Config\Database::connect(); - $data = $db->table('employee_polices ep') - ->select('cp.policy_no as policyNumber, cp.cd_ac_no as CDBGAccountNumber, - e.id,e.emp_code as MemberEmpId, e.doj as DOJ, e.name as InsuredName, e.dob as DOB, e.relationship as Relationship, - e.gender as Gender, ep.date_coverage as DOC,ep.basic_cover_si as SumInsured, e.email_corporate as EmailId - ') - ->join('employees e', 'e.id = ep.employee_id') - ->join('client_policy cp', 'ep.client_policy_id = cp.id') - ->where('ep.client_policy_id', $policy_id) - ->where('ep.status', 'active') - ->where('ep.is_active', 1) - // ->where('ep.uhid', null) - ->get() - ->getResultArray(); + // $db = \Config\Database::connect(); + // $data = $db->table('employee_polices ep') + // ->select('cp.policy_no as policyNumber, cp.cd_ac_no as CDBGAccountNumber, + // e.id,e.emp_code as MemberEmpId, e.doj as DOJ, e.name as InsuredName, e.dob as DOB, e.relationship as Relationship, + // e.gender as Gender, ep.date_coverage as DOC,ep.basic_cover_si as SumInsured, e.email_corporate as EmailId + // ') + // ->join('employees e', 'e.id = ep.employee_id') + // ->join('client_policy cp', 'ep.client_policy_id = cp.id') + // ->where('ep.client_policy_id', $policy_id) + // ->where('ep.status', 'active') + // ->where('ep.is_active', 1) + // // ->where('ep.uhid', null) + // ->get() + // ->getResultArray(); - $body = $this->formatPolicyData($data); + // $body = $this->formatPolicyData($data); // dd($body); + + $body = [ + "PolicyNumber" => "4016/A/O/53130557/00/000", + "CDBGAccountNumber" => "CD-MUM-0026", + "CorrelationId" => "550e8400-e29b-41d4-a716-446655440010", + "MemberDetails" => [ + [ + "MemberEmpId" => "EMPID3625557", + "DOJ" => "21-MAR-2019", + "InsuredName" => "Kumar", + "DOB" => "7-JUL-1983", + "Relationship" => "SELF", + "Gender" => "MALE", + "DOC" => "05-SEP-2025", + "SumInsured" => "400000", + "EmailId" => "KUMAR@GMAIL.COM", + "FlagStatus" => "A" + ], + [ + "MemberEmpId" => "EMPID3625557", + "DOJ" => "21-MAR-2019", + "InsuredName" => "Saranya", + "DOB" => "8-AUG-1970", + "Relationship" => "MOTHER", + "Gender" => "FEMALE", + "DOC" => "05-SEP-2025", + "SumInsured" => "400000", + "EmailId" => "Saranya@GMAIL.COM", + "FlagStatus" => "A" + ], + ] + ]; + $response = call_third_party_api($url, 'POST', $headers, $body, true); // true = raw body mode // print_rr(json_encode($response));die(); return $this->response->setJSON($response); @@ -115,9 +148,9 @@ class ICICILombardController extends AdminController // dd($headers); $body = [ - "PolicyNumber" => "4016/A/O/53077718/00/000", - "BatchId" => "3646145", - "CorrelationId" => "550e8400-e29b-41d4-a716-446655440001" + "PolicyNumber" => "4016/A/O/53130557/00/000", + "BatchId" => "3658147", + "CorrelationId" => "550e8400-e29b-41d4-a716-446655440010" ]; $response = call_third_party_api($url, 'POST', $headers, $body, true); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 26c8aedc..aaa7c09e 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -112,12 +112,42 @@ class RestAuthenticationController extends AdminController if (isset($employeeData['employee_id'])) { - $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: Employee found: employee_id = " . $employeeData['employee_id']); + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: Employee verified with ID = " . $employeeData['employee_id']); log_message('error', ' '); - log_message('error', ' ************************************* POST END **************************************** '); - log_message('error', ' '); - $result = ['user_verification' => true ,'message' => "Verified Successfully"]; - return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + log_message('error', '************************ PRE END ********************************'); + + $otp = random_int(100000, 999999); + $sql = " + UPDATE employees + INNER JOIN employee_polices ON employee_polices.employee_id = employees.id + SET employees.otp = ? + WHERE employees.id = ? + AND employees.relationship = 'self' + AND employees.is_active = 1 + AND employee_polices.is_active = 1 + AND employee_polices.status IN ('draft', 'enrolled') + "; + + $db = db_connect(); + $update = $db->query($sql, [$otp, $employeeData['employee_id']]); + + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: OTP update query executed. SQL = " . $db->getLastQuery()); + + if($update) + { + //send sms + $SMSResult = sendOtpSms($mobile_number, $otp); + if ($SMSResult['status'] == 'success') + { + $result = ['user_verification' => true ,'message' => "Verified Successfully" ]; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + }else{ + $result = ['user_verification' => false, 'message' => "SMS sending failed , try again"]; + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); + } + + } + } else { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: No matching employee found"); log_message('error', ' '); diff --git a/app/Helpers/sms_helper.php b/app/Helpers/sms_helper.php new file mode 100644 index 00000000..c4fa87aa --- /dev/null +++ b/app/Helpers/sms_helper.php @@ -0,0 +1,40 @@ + $apiKey, + 'MobileNo' => $mobile, + 'SenderID' => $senderId, + 'Message' => $message, + 'ServiceName' => $serviceName, + 'DLTTemplateID' => $templateId, + ]); + + // Send request + $response = @file_get_contents($url); + + // If response failed + if ($response === FALSE) { + return ['status' => 'failed', 'message' => 'Failed to send SMS.']; + } + + + return ['status' => 'success', 'message' => 'OTP sent successfully', 'api_response' => $response]; + } +} From 54a99059b820ed01df27a2331938c5dee527742d Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Wed, 8 Oct 2025 11:24:41 +0530 Subject: [PATCH 02/16] FIX_passing client type --- app/Config/Routes.php | 2 + app/Controllers/ClientController.php | 25 ++++++- app/Models/ClientModel.php | 6 +- app/Views/client_list.php | 101 ++++++++++++++++++++++++++- 4 files changed, 129 insertions(+), 5 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9996931c..c54be9b2 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -90,11 +90,13 @@ $routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) { $routes->group("/client", ["filter" => "authMVC"], function ($routes) { $routes->get("list", "ClientController::index"); + $routes->get("type/(:any)", "ClientController::type/$1"); $routes->get("create", "ClientController::clientOnboarding"); $routes->get('deposit/(:num)', 'ClientController::deposit/$1'); $routes->get('remove/(:num)', 'ClientController::removeClient/$1'); $routes->get("list/(:any)", "ClientController::editClientOnboarding/$1"); $routes->post('wipe', 'ClientController::wipeDemoClient'); + $routes->get("typeList/(:any)", "ClientController::typeList/$1"); // application/config/routes.php diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 9baf11cd..3a149d37 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -471,7 +471,7 @@ class ClientController extends AdminController $this->myLogger->logme('error', 'Client list function called'); $headerData['tab_name'] = 'Client List'; $headerData['page_name'] = 'Clients'; // Both Browser Tab name And Page name are same. - $data['clientList'] = $this->clientModel->getCreatedByUserName(); + $data['clientList'] = $this->clientModel->getCreatedByUserName(1); // passing client_type $data['client_rm'] = $this->clientRMModel->getAllClientRM(); $data['lead_data'] = $this->leadsModel->getLeadForInsertClientList(); @@ -484,6 +484,29 @@ class ClientController extends AdminController // $this->loadLayout('client_onboarding', $data); } + + public function typeList($id = null) + { + try { + $data = $this->clientModel->getCreatedByUserName($id); // passing client_type + if (empty($data)) { + return $this->response + ->setJSON(['status' => 'error', 'message' => 'No Records found']) + ->setStatusCode(404); + } + + return $this->response + ->setJSON(['status' => 'success', 'data' => $data]) + ->setStatusCode(200); + + } catch (\Throwable $e) { + return $this->response + ->setJSON(['status' => 'error', 'message' => $e->getMessage()]) + ->setStatusCode(500); + } + } + + public function updateEmpAndPolicyStatus() { diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index e1407c2c..9abe8929 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -108,7 +108,7 @@ class ClientModel extends Model } - public function getCreatedByUserName(){ + public function getCreatedByUserName($client_type = null){ $role_id = get_role_id(); $user_id = get_session_userid(); @@ -118,6 +118,10 @@ class ClientModel extends Model ->join('client_rm', 'client_rm.client_id = clients.id','left') ->where('clients.is_active', 1); + if (!empty($client_type)) { + $query->where('clients.client_type', $client_type); + } + if (in_array($role_id, [2, 3])) { // If the user is a Account Manager or Manager, filter by user_id diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 8cacb6bc..4d7039b6 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -294,10 +294,10 @@ table.dataTable thead th { $(document).ready(function(){ $('#lead_id').select2(); }) - +var table; $(document).ready(function() { - $('#tickets-table').DataTable({ + table = $('#tickets-table').DataTable({ dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", @@ -340,13 +340,108 @@ $(document).ready(function() _INPUT_ `, - searchPlaceholder: "Search" + searchPlaceholder: "Search", + emptyTable: '
No Data found
' }, paging: true , // pagingType: 'full_numbers' }); + + // $(".datatable-buttons").prepend(` + // + // `); + + $(".datatable-buttons").prepend(` + + + + + + + `); + $("#toggleButtons").prop("checked", true); // default checked. + $('#toggleButtons').on('change', function() { + if ($(this).is(':checked')) { + console.log("Checked na gro"); + loadTableData(1); + } else { + console.log("UnChecked na indi"); + loadTableData(2); + } + }); + }) + function loadTableData(type) { + let url = '' + type + $.ajax({ + url: url, + method: 'GET', + success: function(response) { + if (response.status === "success" && Array.isArray(response.data)) { + renderRows(response.data); + } else { + renderRows([]); + } + }, + error: function(xhr, status, error) { + console.error("Error loading :", error); + renderRows([]); + } + }); + } + + function renderRows(data) { + table.clear(); + if (Array.isArray(data) && data.length) { + data.forEach((row, index) => { + let clientrm = ; + let account_managers = ""; + + clientrm.forEach(client => { + if (client.client_id == row.id) { + account_managers += client.account_manager + ", "; + } + }); + account_managers = account_managers.replace(/,\s*$/, ""); + if (account_managers === "") account_managers = "N/A"; + + let rowData = [ + index + 1, + `${row.client_name} (${row.short_name})`, + account_managers, + `` + ]; + + let newRow = table.row.add(rowData); + $(newRow.node()).find('td:eq(0)').addClass('text-center'); + $(newRow.node()).find('td:eq(1)').addClass('client_info').attr('data-id', row.id); + + }); + } + table.draw(); + } + //DO NOT REMOVE THIS FUNCTION >>> THI FUNCTION FOR CLIENT SOFT DELETE // function removeClient(element) // { From 9b7a67bda7876748b9e5e2d8eb06210d0b64ae26 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 15:32:12 +0530 Subject: [PATCH 03/16] GWM --- .../RestAuthenticationController.php | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 36477f9c..7424f7c1 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -93,6 +93,7 @@ class RestAuthenticationController extends AdminController try { $mobile_number = $this->request->getJSON()->mobile_number; + $otp = $this->request->getJSON()->otp; $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: Received mobile_number = " . $mobile_number); @@ -116,7 +117,7 @@ class RestAuthenticationController extends AdminController log_message('error', ' '); log_message('error', '************************ PRE END ********************************'); - $otp = random_int(100000, 999999); + $sql = " UPDATE employees INNER JOIN employee_polices ON employee_polices.employee_id = employees.id @@ -146,8 +147,15 @@ class RestAuthenticationController extends AdminController return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); } + }else{ + + $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: OTP update query Failed. SQL = " . $db->getLastQuery()); + + $result = ['user_verification' => false, 'message' => "Try again. , try again"]; + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); + } - + } else { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: No matching employee found"); log_message('error', ' '); @@ -296,6 +304,7 @@ class RestAuthenticationController extends AdminController $email = $this->request->getJSON()->email; + $mobile_number = $this->request->getJSON()->mobile_number; $otp = $this->request->getJSON()->otp; $client_id = $this->request->getJSON()->client_id ?? null; $employee_id = $this->request->getJSON()->employee_id ?? null; @@ -305,14 +314,13 @@ class RestAuthenticationController extends AdminController ->where('relationship', 'Self') ->where('is_active', 1); - // $builder = $this->employeeModel - // ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') - // ->where('employees.email_corporate', $email) - // ->where('employees.relationship', 'Self') - // ->where('employees.is_active', 1) - // ->whereIn('employees.emp_status', ['active', 'expired']) - // ->where('EP.is_active', 1) - // ->whereIn('EP.status', ['active', 'expired']); + if (!empty($email)) { + $builder->where('email_corporate', $email); + } + + if (!empty($mobile_number)) { + $builder->where('mobile', $mobile_number); + } if (!empty($client_id)) { @@ -445,17 +453,11 @@ class RestAuthenticationController extends AdminController try { - $otp_verification = isset($this->request->getJSON()->otp_verification) ? $this->request->getJSON()->otp_verification : null; $mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null; - - $otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null; $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; + $otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null; $client_id = $this->request->getJSON()->client_id ?? null; - if (isset($this->request->getJSON()->login_by_hr)) - { - $employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); - }else{ if (isset($mobile_number)) { // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); @@ -467,7 +469,8 @@ class RestAuthenticationController extends AdminController ->where('employee_polices.is_active', 1) ->whereIn('employee_polices.status', ['active', 'expired']) ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active', 'expired']); + ->whereIn('employees.emp_status', ['active', 'expired']) + ->where('otp', $otp); if (!empty($client_id)) { $builder->where('employees.client_id', $client_id); @@ -494,14 +497,15 @@ class RestAuthenticationController extends AdminController $employeeData = $builder->orderBy('employees.id', 'desc')->first(); } - } + $lastQuery = $this->employeeModel->db->getLastQuery(); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedUserData: Last Executed Query: " . $lastQuery); $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedUserData: employeeData: " . json_encode($employeeData ?? [])); - if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr) || $employeeData && isset($this->request->getJSON()->otp) ) { + if ($employeeData && isset($this->request->getJSON()->otp) ) + { $auth = HttpRequestHelper::getRequestInfo(); if ($auth) { $data = [ @@ -1424,6 +1428,10 @@ class RestAuthenticationController extends AdminController ->where('employees.mobile', $mobile_number) ->where('EP.is_active', 1) ->whereIn('EP.status', ['active', 'expired']); + + if (!empty($otp)) { + $builder->where('employees.otp', $otp); + } if (!empty($old_mpin)) { $builder->where('employees.mpin', $old_mpin); From cdb41721a055bcb19894fcd7f2864548613df542 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 15:42:34 +0530 Subject: [PATCH 04/16] GWM --- app/Helpers/sms_helper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Helpers/sms_helper.php b/app/Helpers/sms_helper.php index c4fa87aa..0045a61c 100644 --- a/app/Helpers/sms_helper.php +++ b/app/Helpers/sms_helper.php @@ -16,6 +16,8 @@ if (!function_exists('sendOtpSms')) { // Replace variables {#var#} $message = "Hi, Your One Time Code for logging into Nhance {$appName} App is {$otp}. Valid for 3 minutes. Please do not share this with anyone. -NHANCE"; + log_message('info' , 'SMS - Message '.$message); + // Build the API URL $url = "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?" . http_build_query([ 'APIKEY' => $apiKey, @@ -29,6 +31,8 @@ if (!function_exists('sendOtpSms')) { // Send request $response = @file_get_contents($url); + log_message('info' , 'SMS - Response '.$response); + // If response failed if ($response === FALSE) { return ['status' => 'failed', 'message' => 'Failed to send SMS.']; From 45c4c1aaaaf5d5f3840844bfaf2457212b17d26b Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 16:04:11 +0530 Subject: [PATCH 05/16] GWM : sms integration --- app/Controllers/RestAuthenticationController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 7424f7c1..263bc310 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -115,7 +115,7 @@ class RestAuthenticationController extends AdminController { $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - verifyEmployeeWithMobileNumber: Employee verified with ID = " . $employeeData['employee_id']); log_message('error', ' '); - log_message('error', '************************ PRE END ********************************'); + log_message('error', '************************ POST END ********************************'); $sql = " @@ -126,7 +126,7 @@ class RestAuthenticationController extends AdminController AND employees.relationship = 'self' AND employees.is_active = 1 AND employee_polices.is_active = 1 - AND employee_polices.status IN ('draft', 'enrolled') + AND employee_polices.status IN ('active') "; $db = db_connect(); From bef7d7f45f47c45c390086de35b6ea0eba48439b Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 16:21:31 +0530 Subject: [PATCH 06/16] GWM : sms integration --- app/Controllers/RestAuthenticationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 263bc310..7dcf2943 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -303,7 +303,7 @@ class RestAuthenticationController extends AdminController $this->myLogger->logme("error", "REST-AUTH-CONTROLLER - updateEmpOTP: Received payload = " . json_encode($this->request->getJSON() ?? [])); - $email = $this->request->getJSON()->email; + $email = $this->request->getJSON()->email ?? null; $mobile_number = $this->request->getJSON()->mobile_number; $otp = $this->request->getJSON()->otp; $client_id = $this->request->getJSON()->client_id ?? null; From 73a0a67fb0e3b2c7fef363a9bcc0f6756a2ab9b3 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 16:24:31 +0530 Subject: [PATCH 07/16] GWM : sms integration --- app/Controllers/RestAuthenticationController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 7dcf2943..a82320ef 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -310,7 +310,6 @@ class RestAuthenticationController extends AdminController $employee_id = $this->request->getJSON()->employee_id ?? null; $builder = $this->employeeModel - ->where('email_corporate', $email) ->where('relationship', 'Self') ->where('is_active', 1); From 7edeca4504c1d34a50a21b40409babe82a666a3a Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 17:06:45 +0530 Subject: [PATCH 08/16] GWM : sms integration --- app/Controllers/RestAuthenticationController.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index a82320ef..4aaf962d 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -186,6 +186,7 @@ class RestAuthenticationController extends AdminController try { $email = $this->request->getJSON()->email; + $otp = $this->request->getJSON()->otp; $client_id = $this->request->getJSON()->client_id ?? null; @@ -219,11 +220,6 @@ class RestAuthenticationController extends AdminController if (isset($employeeData['employee_id'])) { - $otp = random_int(100000, 999999); - - // $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self') - // ->where('is_active', 1)->set(array('otp' => $otp)) - // ->update(); $builder = $this->employeeModel ->where('email_corporate', $email) From 03608dbda418aaf63e8cc299d75d11d8724588f4 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 8 Oct 2025 17:12:24 +0530 Subject: [PATCH 09/16] GWM : sms integration --- app/Controllers/RestAuthenticationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 4aaf962d..6e3e3fb0 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -300,7 +300,7 @@ class RestAuthenticationController extends AdminController $email = $this->request->getJSON()->email ?? null; - $mobile_number = $this->request->getJSON()->mobile_number; + $mobile_number = $this->request->getJSON()->mobile_number ?? null; $otp = $this->request->getJSON()->otp; $client_id = $this->request->getJSON()->client_id ?? null; $employee_id = $this->request->getJSON()->employee_id ?? null; From 1fb60aece4711850d86681f79834cfa77066c90d Mon Sep 17 00:00:00 2001 From: venba-Inspriron-3558 Date: Wed, 8 Oct 2025 18:25:13 +0530 Subject: [PATCH 10/16] FIX_Minor issues --- app/Views/client_basic_info.php | 3 +- app/Views/client_branch.php | 77 +++++++++++++++++++++++++++++++++ app/Views/client_list.php | 61 +++++++++++++------------- app/Views/client_onboarding.php | 5 ++- app/Views/client_policy.php | 3 +- 5 files changed, 115 insertions(+), 34 deletions(-) diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php index f43c65ee..0af82f51 100755 --- a/app/Views/client_basic_info.php +++ b/app/Views/client_basic_info.php @@ -110,13 +110,14 @@ input:checked + .slider:before {
-
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 940cf017..038e9740 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -862,6 +862,83 @@ function checkMobileNumber(input) { } +// function generateShortName() { +// let clientName = $("#client_name").val().trim(); +// if (clientName.length > 0) { +// let shortName = clientName.substring(0, 10).replace(/\s+/g, '').toUpperCase(); // Take first 10 chars , space removed, converted caps +// $("#short_name").val(shortName); +// makeUniqueShortName(shortName); +// }else{ +// $("#short_name").val(''); +// } +// } + +let shortNameTimer; + +$("#client_name").on("input change keyup", function() { + clearTimeout(shortNameTimer); // cancel previous call + shortNameTimer = setTimeout(() => { + generateShortName(); // only runs after 200ms pause + }, 200); // adjust debounce delay as needed +}); + +function generateShortName() { + let clientInput = $("#client_name"); + let shortInput = $("#short_name"); + + let oldClientName = clientInput.data("old-name"); // from DB + let oldShortName = shortInput.data("old-short"); // from DB + let newClientName = clientInput.val().trim(); + console.log(`LN 882 : NEW - ${newClientName} | OLD - ${oldClientName} | OLD SN - ${oldShortName}`); + + if (newClientName.toUpperCase() === (oldClientName || '').toUpperCase()) { + shortInput.val(oldShortName); + return; + } + + if (newClientName.length == 0) { + shortInput.val(''); + return; + } + + if (newClientName.length > 0) { + let shortName = newClientName.substring(0, 10).replace(/\s+/g, '').toUpperCase(); + shortInput.val(shortName); + makeUniqueShortName(shortName); + } +} + + + +function makeUniqueShortName(baseName) { + let input = $("#short_name")[0]; // input element + checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) { + if (isDuplicate) { + // Append sequence until unique + let counter = 1; + function tryNext() { + let padded = String(counter).padStart(3, '0'); // 001, 002, 003 + let newName = baseName + padded; + + checkDuplicateTableFieldValue("clients", "short_name", newName, function(exists) { + if (exists) { + counter++; + tryNext(); // keep checking + } else { + $("#short_name").val(newName); + validateInput(input, "clients", "short_name", "clientBtnSubmit"); + } + }); + } + tryNext(); + } else { + $("#short_name").val(baseName); + validateInput(input, "clients", "short_name", "clientBtnSubmit"); + } + }); +} + + function validateInput(input, table, field, submitButId){ let value = $(input).val(); diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 4d7039b6..237c2752 100755 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -326,6 +326,11 @@ $(document).ready(function() extend: 'csv', text: ' CSV ', title: 'Client-List', + // title: function() { + // return $('#toggleButtons').is(':checked') + // ? 'GC-Client-List' + // : 'RC-Client-List'; + // }, className: 'app-btn-primary ', exportOptions: { columns: ':not(:last-child)' @@ -357,43 +362,39 @@ $(document).ready(function() $(".datatable-buttons").prepend(` - + `); - $("#toggleButtons").prop("checked", true); // default checked. - $('#toggleButtons').on('change', function() { - if ($(this).is(':checked')) { - console.log("Checked na gro"); - loadTableData(1); - } else { - console.log("UnChecked na indi"); - loadTableData(2); - } - }); + $('#toggleButtons').on('change', function() { + let type = $(this).is(':checked') ? 1 : 2; + // $('div.col-6 h4').text( + // $(this).is(':checked') + // ? "GC Client List" + // : "RC Client List" + // ); + let url = '' + type; + + $.ajax({ + url: url, + method: 'GET', + success: function(response) { + if (response.status === "success" && Array.isArray(response.data)) { + renderRows(response.data); + } else { + renderRows([]); + } + }, + error: function(xhr, status, error) { + console.error("Error loading:", error); + renderRows([]); + } + }); + }); }) - function loadTableData(type) { - let url = '' + type - $.ajax({ - url: url, - method: 'GET', - success: function(response) { - if (response.status === "success" && Array.isArray(response.data)) { - renderRows(response.data); - } else { - renderRows([]); - } - }, - error: function(xhr, status, error) { - console.error("Error loading :", error); - renderRows([]); - } - }); - } - function renderRows(data) { table.clear(); if (Array.isArray(data) && data.length) { diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php index e5da1242..567fc409 100755 --- a/app/Views/client_onboarding.php +++ b/app/Views/client_onboarding.php @@ -332,7 +332,8 @@