From 8aa229a4e6169b43cd45a100d86c752239caa663 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 4 Mar 2024 10:24:28 +0530 Subject: [PATCH] FEAT_CLIENT_OPEN_ENROLLMENT : RV --- app/Config/Routes.php | 3 +- app/Controllers/ClientController.php | 156 ++-- app/Models/PolicesModel.php | 1 + app/Models/PolicyPremium2Model.php | 1 + app/Views/client_list.php | 6 +- app/Views/client_policy.php | 148 +-- app/Views/policy_gmc_terms.php | 23 +- app/Views/policy_gpa_terms.php | 21 +- app/Views/policy_grid.php | 1274 +++++++++++++------------- 9 files changed, 844 insertions(+), 789 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 02daae30..c588b97e 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -184,7 +184,8 @@ $routes->group("/util", ["filter" => "authMVC"], function($routes){ $routes->get("police-by-insurer/(:any)", "ClientController::getPolicesByInsurerId/$1"); $routes->get("get-file-error/(:any)", "EmployeeController::getUploadedFileError/$1"); $routes->get("kyc-other-docs-delete/(:any)", "ClientController::deleteClientKycOtherDocs/$1"); - $routes->get("policy-premium", "ClientController::getpolicyGridData/$1"); + $routes->get("policy-premium", "ClientController::getpolicyGridData/$1"); + $routes->get("update-policy-status/(:any)", "ClientController::updateClientPolicyStatus/$1"); }); $routes->cli('processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 5d5029bf..d324b789 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -121,81 +121,77 @@ class ClientController extends AdminController echo view('client_onboarding', $data); echo view('layout/footer'); - } - // In your controller - public function deposit($id = null) - { - $headerData['page_name'] = 'Client Deposit'; - - $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id); - $data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id); - - // Fetch associated insurer names and balances - $balances = $this->clientPolicyModel->getBalances($id); - $data['balances'] = $balances; - - echo view('layout/header', $headerData); - echo view('client_deposit_list', $data); - echo view('layout/footer'); - } - + } - -public function view_Deposit($insurerId) { - // Load your model to fetch data based on $clientId and $insurerId - $subTypeOptions = [ - 1 => 'Deposit', - 2 => 'Adjustment', - 3 => 'Deletion', - // Add more options as needed - ]; - $data['subTypeOptions'] = $subTypeOptions; + // In your controller + public function deposit($id = null) + { $headerData['page_name'] = 'Client Deposit'; - $data['insurerName']= $this->insurerModel->getInsurerName($insurerId); - $loggedInUserID = get_session_userid(); - // $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId); - $clientId = $this->request->getGet('client_id'); - $data['depositdata']= $this->clientPolicyModel->getdepositData($clientId,$insurerId); - $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); - $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); - - - // print_r($data['depositdata'] );die; - // Load the view for the new list page + + $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id); + $data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id); + + // Fetch associated insurer names and balances + $balances = $this->clientPolicyModel->getBalances($id); + $data['balances'] = $balances; + echo view('layout/header', $headerData); - echo view('view_deposit',$data); + echo view('client_deposit_list', $data); echo view('layout/footer'); -} + } + + public function view_Deposit($insurerId) + { + // Load your model to fetch data based on $clientId and $insurerId + $subTypeOptions = [ + 1 => 'Deposit', + 2 => 'Adjustment', + 3 => 'Deletion', + // Add more options as needed + ]; + $data['subTypeOptions'] = $subTypeOptions; + $headerData['page_name'] = 'Client Deposit'; + $data['insurerName']= $this->insurerModel->getInsurerName($insurerId); + $loggedInUserID = get_session_userid(); + // $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId); + $clientId = $this->request->getGet('client_id'); + $data['depositdata']= $this->clientPolicyModel->getdepositData($clientId,$insurerId); + $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); + $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId); + + + // print_r($data['depositdata'] );die; + // Load the view for the new list page + echo view('layout/header', $headerData); + echo view('view_deposit',$data); + echo view('layout/footer'); + } + public function saveDeposit() + { + // Retrieve form data from POST request + $loggedInUserID = get_session_userid(); + + // Prepare the array with data + $data = [ + 'amount' => $this->request->getPost('amount'), + 'sub_type_id' => $this->request->getPost('sub_type_id'), + 'client_id' => $this->request->getPost('client_id'), + 'insurer_id' => $this->request->getPost('insurer_id'), + 'description' => $this->request->getPost('description'), + 'transaction_type' => $this->request->getPost('transaction_type') ?: 'Credit', + 'updated_by' => 1, // You need to set the correct value for updated_by + ]; + + // Call the saveDeposit function from DepositHelper + $response = DepositHelper::saveDeposit($data, $loggedInUserID); + + // Return a boolean value based on success + return $this->response->setJSON(['success' => $response['success']]); + } -public function saveDeposit() -{ - // Retrieve form data from POST request - $loggedInUserID = get_session_userid(); - - // Prepare the array with data - $data = [ - 'amount' => $this->request->getPost('amount'), - 'sub_type_id' => $this->request->getPost('sub_type_id'), - 'client_id' => $this->request->getPost('client_id'), - 'insurer_id' => $this->request->getPost('insurer_id'), - 'description' => $this->request->getPost('description'), - 'transaction_type' => $this->request->getPost('transaction_type') ?: 'Credit', - 'updated_by' => 1, // You need to set the correct value for updated_by - ]; - - // Call the saveDeposit function from DepositHelper - $response = DepositHelper::saveDeposit($data, $loggedInUserID); - - // Return a boolean value based on success - return $this->response->setJSON(['success' => $response['success']]); -} - - - - public function editClientOnboarding($id = null) { @@ -616,11 +612,10 @@ public function saveDeposit() $si = $this->request->getPost('si'); } $age_from = isset($this->request->getPost('age_from')[$i]) ? $this->request->getPost('age_from')[$i] : null; - $age_to = isset($this->request->getPost('age_to')[$i]) ? $this->request->getPost('age_to')[$i] : null; - $premium = isset($premiumData[$i]) ? $premiumData[$i] : null; - $grade = isset($this->request->getPost('grade')[$i]) ? $this->request->getPost('grade')[$i] : null; - $max_si = isset($this->request->getPost('max_si')[$i]) ? $this->request->getPost('max_si')[$i] : null; - $created_by = get_session_userid(); + $age_to = isset($this->request->getPost('age_to')[$i]) ? $this->request->getPost('age_to')[$i] : null; + $premium = isset($premiumData[$i]) ? $premiumData[$i] : null; + $grade = isset($this->request->getPost('grade')[$i]) ? $this->request->getPost('grade')[$i] : null; + $max_si = isset($this->request->getPost('max_si')[$i]) ? $this->request->getPost('max_si')[$i] : null; if ($si !== null) { $data['si'] = $si; @@ -739,6 +734,7 @@ public function saveDeposit() $data = $this->policesModel->getPolicyPremium($policy_id); + $policy_name = $data[0]->policy_name; $pattern = '/gmc/i'; $subject = $data[0]->policy_type; if (preg_match($pattern, $subject)) { @@ -754,10 +750,11 @@ public function saveDeposit() $premiumData = $this->policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); } + // echo '
';
         // print_r($results);
         // print_r($data[0]->policy_type); die;
-        return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => $premiumData, 'count' => $emp_count], 200);
+        return $this->respond(['status' => true,'code' => 200,'data' => $results, 'premiumData' => $premiumData, 'count' => $emp_count, 'policy_name' => $policy_name], 200);
 
     }
 
@@ -864,6 +861,7 @@ public function saveDeposit()
     {
         $client_id = $this->request->getVar('client_id');
         $policy_id = $this->request->getVar('policy_id');
+        $policy_name = $this->policesModel->select('name')->where('id', $policy_id)->first();
         $record    = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
         $emp_count = $this->employeeModel ->join('client_policy cp',"employees.client_id = cp.client_id")
                                           ->join('employee_polices ep',"cp.id = ep.client_policy_id AND employees.id = ep.employee_id")
@@ -877,9 +875,9 @@ public function saveDeposit()
         }
 
         if ($record) {
-            return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count], 200);
+            return $this->respond(['Status' => true,'code' => 200,'data' => $record['policy_terms'], 'count' => $emp_count, 'policy_name' => $policy_name], 200);
         } else {
-            return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count], 200);
+            return $this->respond(['Status' => false,'code' => 200,'message' => 'Record not found.', 'count' => $emp_count, 'policy_name' => $policy_name], 200);
         }
 
     }
@@ -994,4 +992,12 @@ public function saveDeposit()
 
     }
 
+    public function updateClientPolicyStatus($id=null){
+
+
+        $policy_status = $this->clientPolicyModel->where('id', $id )->set('policy_status', 1)->update();
+        return $this->respond(['status' => true,'code' => 200,'data' => $id], 200);
+
+    }
+
 }
\ No newline at end of file
diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php
index c9dc0015..23b47f0e 100644
--- a/app/Models/PolicesModel.php
+++ b/app/Models/PolicesModel.php
@@ -22,6 +22,7 @@ class PolicesModel extends Model
 
         return $this->db->table('policies')
         ->select('policy_type.*')
+        ->select('policies.name as policy_name')
         ->join('policy_type', 'policy_type.id = policies.policy_type_id')
         ->where('policies.id', $policy_id)
         ->get()
diff --git a/app/Models/PolicyPremium2Model.php b/app/Models/PolicyPremium2Model.php
index f7b861be..0ed2777b 100644
--- a/app/Models/PolicyPremium2Model.php
+++ b/app/Models/PolicyPremium2Model.php
@@ -18,6 +18,7 @@ class PolicyPremium2Model extends Model
         'age_to',
         'si',
         'premium',
+        'max_si',
         'grade',
         "created_by",
         "updated_by",
diff --git a/app/Views/client_list.php b/app/Views/client_list.php
index 09a34662..246a9126 100644
--- a/app/Views/client_list.php
+++ b/app/Views/client_list.php
@@ -38,11 +38,7 @@
                                     
                                     
                                 
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index 2dc48942..98e859e4 100644
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -91,7 +91,7 @@
                                 
                                 
                             
-                            
+
@@ -126,6 +126,8 @@ $(document).ready(function () { + $('#policy_status_field').hide() + // Get today's date var today = new Date(); @@ -198,9 +200,15 @@ ${rearrangeDateFormat(item.policy_start_date)} - ${rearrangeDateFormat(item.policy_end_date)} ${checkDateStatus(item.policy_end_date, 1)} -    - - + `; @@ -212,7 +220,6 @@ }); - /******** for form submit using AJAX *******/ $("#policy_form").submit(function(event) { @@ -297,7 +304,6 @@ }); }); - /********* To get th POLICY base on Insurer *******/ $('#insurer').change(function() { var id = $(this).val(); @@ -321,8 +327,7 @@ }); }); - - // set the Policy_Type_id for Form Submit + /********* set the Policy_Type_id for Form Submit *******/ $('#policy').change(function(){ var dataId = $(this).children('option:selected').attr('data-id'); @@ -337,7 +342,6 @@ }); - // get the client policy data for edit $('body').on('click', '.btnPolicyEdit', function () { @@ -354,7 +358,6 @@ success: function (res) { console.log('clientPolicy : ', res); - $('#policy_form_action').val(''); if (res.status === false) { @@ -375,12 +378,17 @@ $('#start_date').val(rearrangeDateFormat(res.data.policy_start_date)); $('#end_date').val(rearrangeDateFormat(res.data.policy_end_date)); $('#policy_status').val(checkDateStatus(res.data.policy_end_date)); + $('#policy_status_field').show(); - if(res.data.policy_type_id == 1){ - appendPolicyFormFields(1, res.data); - }else if(res.data.policy_type_id >= 2) { - appendPolicyFormFields(2, res.data); - } + /** do not delete this comment condition + + // if(res.data.policy_type_id == 1){ + // appendPolicyFormFields(1, res.data); + // }else if(res.data.policy_type_id >= 2) { + // appendPolicyFormFields(2, res.data); + // } + + do not delete this comment condition **/ var policeOptionHTML = ''; $.each(res.policy, function(index, item) { @@ -396,6 +404,26 @@ }); }); + $('body').on('click', '.btnOpenEnroll', function () { + + var policy_id = $(this).attr('data-id'); + console.log(policy_id) + if(policy_id){ + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + } + + $.get(''+policy_id, function (data) { + if(data){ + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + toastr.success('Policy Status Updated Successfully', 'Success'); + }, 1000); + } + }) + + }); function appendPolicyFormFields(policy_type, data = false){ @@ -571,57 +599,57 @@ } - // Function to convert numbers into Indian numbering system - function convertToIndianNumberingSystem(number) { - // Define Indian numbering system - var suffixes = ["", "Thousand", "Lakh", "Crore"]; - - // Split the number into groups of 3 digits each - var numberChunks = []; - while (number > 0) { - numberChunks.push(number % 1000); - number = Math.floor(number / 1000); + const numberWords = { + 0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine", + 10: "Ten", 11: "Eleven", 12: "Twelve", 13: "Thirteen", 14: "Fourteen", 15: "Fifteen", 16: "Sixteen", 17: "Seventeen", 18: "Eighteen", 19: "Nineteen", + 20: "Twenty", 30: "Thirty", 40: "Forty", 50: "Fifty", 60: "Sixty", 70: "Seventy", 80: "Eighty", 90: "Ninety" + }; + + function convertNumberToWords(number) { + if (number === 0) { + return numberWords[number]; } - // Convert each chunk into words - var result = ""; - for (var i = 0; i < numberChunks.length; i++) { - if (numberChunks[i] !== 0) { - result = convertThreeDigitNumberToWords(numberChunks[i]) + " " + suffixes[i] + " " + result; + let word = ''; + + if (number >= 10000000) { + word += convertNumberToWords(Math.floor(number / 10000000)) + " Crore "; + number %= 10000000; + } + + if (number >= 100000) { + word += convertNumberToWords(Math.floor(number / 100000)) + " Lakh "; + number %= 100000; + } + + if (number >= 1000) { + word += convertNumberToWords(Math.floor(number / 1000)) + " Thousand "; + number %= 1000; + } + + if (number >= 100) { + word += convertNumberToWords(Math.floor(number / 100)) + " Hundred "; + number %= 100; + } + + if (number > 0) { + if (word !== '') { + word += "and "; + } + if (number <= 20) { + word += numberWords[number]; + } else { + word += numberWords[Math.floor(number / 10) * 10] + " " + numberWords[number % 10]; } } - return result.trim(); + return word; } - // Function to convert a three-digit number into words - function convertThreeDigitNumberToWords(num) { - var ones = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]; - var tens = ["", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]; - var teens = ["", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"]; - - var words = ""; - - // Convert hundreds place - if (Math.floor(num / 100) > 0) { - words += ones[Math.floor(num / 100)] + " Hundred "; - num %= 100; - } - - // Convert tens and ones place - if (num >= 20) { - words += tens[Math.floor(num / 10)] + " "; - num %= 10; - } else if (num >= 11 && num <= 19) { - words += teens[num - 10] + " "; - num = 0; - } - - if (num > 0) { - words += ones[num] + " "; - } - - return words.trim(); + function onlyNumbers(event){ + var charcode; + charcode = event.which || event.keyCode; + if(charcode>= 48 && charcode <= 57)return true; + return false; } - \ No newline at end of file diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 4ac8c736..c999c85f 100644 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -75,7 +75,7 @@