diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 041caaa3..73ce3697 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -248,6 +248,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("check_policy_type/(:any)", "ClientController::checkPolicyType/$1"); $routes->get("getPolicyTerms/(:any)", "ClientController::getPolicyTerms/$1"); $routes->get("getPolicyTermsFormJson/(:any)", "ClientController::getPolicyTermsFormJson/$1"); + $routes->get("checkHRNumber/(:any)", "ClientController::checkHRNumber/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ba3da3d8..7b5c4e8d 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2283,4 +2283,16 @@ class ClientController extends AdminController } + public function checkHRNumber($mobileNumber) + { + try { + $mobileNumberCount = $this->levelContactModel->where('mobile', $mobileNumber)->countAllResults(); + return $this->respond(['status' => true, 'data' => $mobileNumberCount], 200); + } catch (\Exception $e) { + log_message('error', 'Error checking mobile number: ' . $e->getMessage()); + return $this->respond(['status' => false, 'data' => 0, 'message' => 'An error occurred while checking the mobile number. Please try again later.'], 500); + } + } + + } \ No newline at end of file diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 80571810..c2447397 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -79,13 +79,16 @@ class EmployeeController extends AdminController $data['employees'] = $this->employeePolicyModel->getEmployeePolicy( client_id: $filterData['client_id'], policy_id: $filterData['policy_id'], - status: $filterData['status'], - branch_id: $filterData['branch_id'] + branch_id: $filterData['branch_id'], + emp_code : $filterData['emp_code'], + emp_name : $filterData['emp_name'], + status : $filterData['status'], ); $data['getData'] = $filterData; } + // dd($this->request->getGet()); $this->myLogger->logme('error', 'list called'); $this->loadLayout('employee_list', $data); } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 2dcac592..15bf295d 100644 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -76,31 +76,68 @@ class EmployeePolicyModel extends Model } // ----------------------------------------------------------------------------------------------------- - public function getEmployeePolicy($client_id,$policy_id,$status,$branch_id) + public function getEmployeePolicy($client_id = 0, $policy_id=0, $status=0, $branch_id=0, $emp_code="", $emp_name="") { - $result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile']) - ->join('employees emp', 'employee_polices.employee_id = emp.id') - ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy - ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master - ->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master - ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch - ->join('tpa tpam', 'cp.tpa_id = tpam.id','left') //tpam - tpa master - ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id','left') //tpab - tpa brach - ->join('clients cm', 'cp.client_id = cm.id') //cm - client master - ->where('emp.client_id',$client_id) - ->where('emp.client_branch_id',$branch_id) - ->where('employee_polices.is_active',1) - ->where('emp.is_active',1) - ->where('employee_polices.client_policy_id',$policy_id) - ->orderBy('emp.emp_code','ASC')->orderBy('employee_polices.employee_id','ASC'); - - - if($status != 0 && !empty($status)){ + + $result = $this->select([ + 'employee_polices.*', + 'pm.name as policy_name', + 'im.short_name as insurer_short_name', + 'ib.branch_name as insurer_branch_name', + 'ib.branch_code as insurer_branch_code', + 'tpam.name as tpa_name', + 'tpam.short_name as tpa_short_name', + 'tpab.branch_code as tpa_branch_code', + 'cm.client_name', + 'cm.short_name as client_short_name', + 'emp.relationship', + 'emp.relationship_code', + 'emp.change_event', + 'emp.emp_code', + 'emp.name', + 'emp.email_corporate', + 'emp.dob', + 'emp.gender', + 'emp.emp_status', + 'emp.is_active as emp_is_active', + 'emp.mobile as mobile' + ]) + ->join('employees emp', 'employee_polices.employee_id = emp.id') + ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy + ->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master + ->join('insurers im', 'cp.insurer_id = im.id') //im - insurer master + ->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurer branch + ->join('tpa tpam', 'cp.tpa_id = tpam.id', 'left') //tpam - tpa master + ->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id', 'left') //tpab - tpa branch + ->join('clients cm', 'cp.client_id = cm.id') //cm - client master + ->orderBy('emp.emp_code', 'ASC') + ->orderBy('employee_polices.employee_id', 'ASC'); + + // Conditionally add where clauses + if ($client_id !=0 && !empty($client_id)) { + $result->where('emp.client_id', $client_id); + } + if ($branch_id !=0 && !empty($branch_id)) { + $result->where('emp.client_branch_id', $branch_id); + } + if ($policy_id !=0 && !empty($policy_id)) { + $result->where('employee_polices.client_policy_id', $policy_id); + } + if ($status !=0 && !empty($status)) { $result->where('employee_polices.status', $status); } + if (!empty($emp_code)) { + $result->where('emp.emp_code', $emp_code); + } + if (!empty($emp_name)) { + $result->like('emp.name', $emp_name); + } - $result = $result->findAll(); - return ($result); + // Always check these conditions + $result->where('employee_polices.is_active', 1) + ->where('emp.is_active', 1); + + return $result->findAll(); } diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 93ea7137..213f47c2 100644 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -89,7 +89,7 @@
- +
@@ -423,7 +423,7 @@ $(document).ready(function () {
- +
@@ -563,6 +563,33 @@ $(document).ready(function () { + function checkMobileNumber(input){ + + console.log('function called') + console.log(input); + console.log('Input Value', input.value); + + var mobileNumber = input.value; + var url = '' + mobileNumber; + + $.get(url, function(response){ + + console.log(response) + console.log(response.data) + + if(response.data > 0){ + toastr.warning('The Mobile Number Already Exist.', 'Warning'); + input.value = ""; + return; + } + + }).fail(function(xhr, status, error) { + console.error(xhr.responseText); + console.error(status, error); + }); + + } + \ No newline at end of file diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 479260a6..65b8285b 100644 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -59,6 +59,16 @@ table.dataTable tbody td {
+
+
+ +
+ +
+
+ +
+
@@ -318,18 +328,22 @@ function fetchEmpolyeeList(event) { var policy_id = $('#policies').val(); var status = $('#status2').val(); var branch_id = $('#branch_id').val(); + var emp_code = $('#emp_code').val(); + var emp_name = $('#emp_name').val(); // console.log(client_id + '-' + policy_id); - if (client_id == '0' || policy_id == '0') { - alert('Please select values in both dropdowns.'); - return; - } + // if (client_id == '0' || policy_id == '0') { + // alert('Please select values in both dropdowns.'); + // return; + // } var queryParams = { client_id: client_id, policy_id: policy_id, branch_id: branch_id, + emp_code : emp_code, + emp_name : emp_name, status : status, }; diff --git a/app/Views/endorsement_list.php b/app/Views/endorsement_list.php index 4fa12d55..45f7423b 100644 --- a/app/Views/endorsement_list.php +++ b/app/Views/endorsement_list.php @@ -587,16 +587,25 @@ dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", - "buttons": [{ - "extend": 'csv', - "text": 'CSV', - "title": 'Endorsement-List', - "className": 'my_class', - "exportOptions": { - "columns": ':not(:last-child)' - }, + buttons: [{ + extend: 'csv', + text: 'CSV', + title: 'Endorsement-List', + className: 'my_class', + exportOptions: { + columns: ':not(:last-child)', + format: { + body: function (data, row, column, node) { + // Convert data to string to avoid scientific notation in CSV + if (!isNaN(data) && parseFloat(data) > 1e20) { + return `'${data}`; + } + return data.toString();// Ensures all data is treated as strings + } + } + } }], - "initComplete": function(settings, json) { + initComplete: function(settings, json) { $('.my_class').css({ "position": "relative", "left": "79px" @@ -608,7 +617,12 @@ }, paging: true, // pagingType: 'full_numbers' + columnDefs: [ + { type: 'scientific', targets: 0 } // Apply custom sorting type to the first column + ], }); + + }); \ No newline at end of file diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index 11e7405f..f43042ed 100644 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -136,6 +136,7 @@ + \ No newline at end of file