From 0126473c18761e4e91b841ac4ca1da7fa46ae460 Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 20 Jun 2025 15:55:38 +0530 Subject: [PATCH 01/40] FIX_INCEPTION&EXPORT_FILELIST_ISSUE --- app/Controllers/EmployeeController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 6541e011..28f3a010 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -344,9 +344,11 @@ class EmployeeController extends AdminController $query->where('cr.user_id', $user_id); } // ->where('files.created_by', get_session_userid()) - $data['fileList'] = $query->groupBy("c.id")->orderBy('files.created_at', 'desc') - ->limit(1500) + $data['fileList'] = $query->groupBy("files.id")->orderBy('files.created_at', 'desc') + // $data['fileList'] = $query + ->limit(2000) ->find(); + // dd($this->fileModel->getLastQuery()); // dd($data['fileList']); $query2 = $this->batchFileModel->select(" @@ -395,7 +397,7 @@ class EmployeeController extends AdminController $query2->where('cr.user_id', $user_id); } // ->where('files.created_by', get_session_userid()) - $data['batch_list'] = $query2->groupBy("clients.id")->orderBy('batch_files.id', 'desc') + $data['batch_list'] = $query2->groupBy("batch_files.id")->orderBy('batch_files.id', 'desc') ->limit(1500) ->find(); From ae18ed65c8b6c69bedaa879de29c4d578dfb7f05 Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 23 Jun 2025 17:10:21 +0530 Subject: [PATCH 02/40] FIX_INSURER_STMT_UPLOAD&BDS_EXPORT --- app/Controllers/EmpDataServiceController.php | 2 +- .../PolicyTransactionController.php | 21 ++++++++++++------- app/Views/report_bds.php | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 3dbf91d5..9d3eeecf 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -1918,7 +1918,7 @@ class EmpDataServiceController extends BaseController $result_for_employees_policy = $this->employeePolicyModel ->select('employee_polices.*') ->join('employees', 'employees.id = employee_polices.employee_id') - ->join('emp_endorsement', 'emp_endorsement.employee_id = employees.id') // assuming this is the correct join + ->join('emp_endorsement', 'emp_endorsement.pk = employees.id') // assuming this is the correct join ->where('employees.emp_code', $emp_code) ->where('employees.name', $name) ->where('employees.client_id', $client_id) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 6622d0fa..c00f2106 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -2037,8 +2037,8 @@ class PolicyTransactionController extends BaseController //insurer statement list page public function statementList() { - // dd($this->validateInsurerStatement(['file_id' => 30])); - // $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll(); + // dd($this->validateInsurerStatement(['file_id' => 49])); + $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll(); $today = date('Y-m-d'); $fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today))); // echo $fromday;die(); @@ -2261,13 +2261,13 @@ class PolicyTransactionController extends BaseController // dd($highestRowAndColumn); $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); unset($excel_data[0]); - // Kint::dump($excel_data); + // Kint::dump($excel_data);die(); //get no of line items and update in DB $line_items = 0; // get uploaded month transactions data $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']); // var_dump($source_data);die(); - // Kint::dump($source_data);//die(); + // Kint::dump($source_data);die(); // check policy no,insurer and etc in DB for this month @@ -2277,17 +2277,24 @@ class PolicyTransactionController extends BaseController if (!$is_row_empty) { // $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row); $is_source_found = 0; + // Kint::dump($excel_key,$excel_row[1],$excel_row[2]); $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel + $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel - $policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); //policy_end_date from excel + $policy_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_end_date from excel + $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel + $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel - // Kint::dump($policy_no); + $endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]); //policy_end_date from excel + + // Kint::dump($excel_key,$policy_no,$endorsement_no,$policy_start_date,$policy_end_date);//die(); foreach ($source_data as $source_key => $source_row) { $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; // Kint::dump($source_endorsement_no); - if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { + if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) // && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) + { $is_source_found = 1; $line_items = $line_items + 1; unset($source_data[$source_key]); diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index 815eecb5..d8c1145a 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -212,8 +212,8 @@ $(document).ready(function() { customizeData: function (data) { for (var i = 0; i < data.body.length; i++) { for (var j = 0; j < data.body[i].length; j++) { - // Check if the column is the 9th index (10th column) - if (j === 9) { + // Check if the column is the 9th index (10th column) and 10th index (11th column) + if (j === 9 || j === 10) { data.body[i][j] = '\u200C' + data.body[i][j]; } } From 37b310477257288608acf8de532c3989ed099c8c Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 23 Jun 2025 17:13:37 +0530 Subject: [PATCH 03/40] FIX_INS_STMT_UPLOAD --- app/Controllers/PolicyTransactionController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index c00f2106..0cb10174 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -2293,7 +2293,7 @@ class PolicyTransactionController extends BaseController foreach ($source_data as $source_key => $source_row) { $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; // Kint::dump($source_endorsement_no); - if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) // && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) + if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) { $is_source_found = 1; $line_items = $line_items + 1; From 72af4263868150beb0d5402d79b9b1978fc6f358 Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 23 Jun 2025 18:19:34 +0530 Subject: [PATCH 04/40] FIX_RR_DEFAULT_UNIT_NOT_SET --- app/Views/policy_grid.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index 06c945c6..d0e825f6 100755 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -1391,6 +1391,8 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false) console.log('appendGridtHtml function ui_type', ui_type); console.log('appendGridtHtml function secondary', secondary); console.log('appendGridtHtml function typeof secondary', typeof secondary); + var default_unit = $('#hidden_unit').val(); + // alert(default_unit); // console.log('appendGridtHtml function data.unit', data.unit); // console.log('appendGridtHtml function data.unit type',typeof data.unit); From 015f0068deb24acf8b7135c1ce6538f01963fad1 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 24 Jun 2025 11:53:42 +0530 Subject: [PATCH 05/40] FIX_POLICY_NO_IN_BDS ; RV --- app/Controllers/ClientController.php | 28 +++++++++++++++++-- .../policy_transaction_inception_form.php | 19 +++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index be5f2664..1d206b11 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4223,24 +4223,46 @@ class ClientController extends AdminController } public function get_client_policy_data_using_policy_no() - { + { + $received_data = $this->request->getGet(); $policy_no = $this->request->getGet('policy_no'); + $client_id = $this->request->getGet('client_id'); + $client_branch_id = $this->request->getGet('client_branch_id'); + $policy_type_id = $this->request->getGet('policy_type_id'); + $data = $this->clientPolicyModel ->select(" client_policy.*, + policy_type.policy_type, clients.client_type, + clients.client_name, DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date, DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date ") ->join('clients', 'client_policy.client_id = clients.id') + ->join('policy_type', 'client_policy.policy_type_id = policy_type.id') ->where('client_policy.policy_no', $policy_no) ->where('client_policy.is_active', 1) + ->where('client_policy.policy_status', 1) ->first(); if ($data) { - return $this->respond(['status' => true, 'data' => $data, 'code' => 200], 200); + if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) { + + if ($data['policy_type_id'] == $policy_type_id) { + return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); + } else { + $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); + $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; + return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); + } + + } else { + $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; + return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); + } } else { - return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404], 200); + return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200); } } diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index cc6415c1..b378d5cb 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -3838,6 +3838,15 @@ $('#policy_no').change(function(){ var policy_no = $(this).val(); policy_no = policy_no.trim(); + let client_id = $('#client_id').val()?.trim(); + let client_branch_id = $('#client_branch_id').val()?.trim(); + let policy_type_id = $('#policy_type_id').val()?.trim(); + + if (!client_id || !client_branch_id || !policy_type_id) { + toastr.warning('Please select the policy type, client and branch', "WARNING"); + $('#policy_no').val(''); + return; + } $pt_id = $('#policy_tranction_policy_number').val(); console.log('$pt_id', $pt_id); @@ -3846,13 +3855,19 @@ $('#policy_no').change(function(){ $.ajax({ url: '', type: "GET", - data : { policy_no : policy_no }, + data : { policy_no : policy_no, client_id : client_id, client_branch_id : client_branch_id, policy_type_id : policy_type_id}, dataType: 'json', success: function (res) { console.log('get_client_policy_data_using_policy_no response', res) - if(res.status == true){ + if(res.status == true && res.code == 409){ + toastr.warning(res.message,'WARNING'); + $('#policy_no').val(""); + return; + } + + if(res.status == true){ $('#ct_type').val(1); $('#client_policy_id').val(res.data.id); $('#policy_start_date').val(res.data.policy_start_date); From 37fce323730dc7a7d236217aced8176035bcfc92 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 24 Jun 2025 14:56:58 +0530 Subject: [PATCH 06/40] CHANGE_ICR_ACR_FORMULA_CHANGES : RV --- app/Views/leads_form.php | 16 ++++++++-------- app/Views/rfq/gmc.php | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 390fa7ee..472516f8 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -1423,7 +1423,7 @@ console.log('Policy Run Days (Final):', policy_run_days); let annualised_claims = policy_run_days > 0 ? (incurred_claims / policy_run_days) * 365 : 0; - let annualised_claims_roundoff = Math.round(annualised_claims); + let annualised_claims_roundoff = annualised_claims.toFixed(2); console.log('Annualised Claims:', annualised_claims); console.log('Annualised Claims (Rounded):', annualised_claims_roundoff); $('#annualised_claims').val(annualised_claims_roundoff); @@ -1431,22 +1431,22 @@ let premium_as_on_date = Number($('#premium_date').val()) || 0; console.log('Premium as on Date:', premium_as_on_date); - let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0) - ? (annualised_claims / premium_as_on_date) + let incurred_claim_ratio = (incurred_claims > 0 && premium_as_on_date > 0) + ? (incurred_claims / premium_as_on_date) * 100 : 0; - let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) ? Math.round(incurred_claim_ratio) : 0; + let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) ? incurred_claim_ratio.toFixed(2) : 0; console.log('Incurred Claim Ratio:', incurred_claim_ratio); console.log('Incurred Claim Ratio (Rounded):', incurred_claim_ratio_roundoff); $('#incurred_claims_ratio').val(incurred_claim_ratio_roundoff); - let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0; - let earned_premium_roundoff = Math.round(earned_premium); + let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * policy_run_days : 0; + let earned_premium_roundoff = earned_premium.toFixed(2); console.log('Earned Premium:', earned_premium); console.log('Earned Premium (Rounded):', earned_premium_roundoff); $('#earned_premium').val(earned_premium_roundoff); - let earnedClaimsRatio = earned_premium > 0 ? annualised_claims / earned_premium : 0; - let earnedClaimsRatioRounded = Math.round(earnedClaimsRatio); + let earnedClaimsRatio = premium_as_on_date > 0 ? (annualised_claims / premium_as_on_date) * 100 : 0; + let earnedClaimsRatioRounded = earnedClaimsRatio.toFixed(2); console.log('Earned Claims Ratio:', earnedClaimsRatio); console.log('Earned Claims Ratio (Rounded):', earnedClaimsRatioRounded); $('#earned_claims_ratio').val(earnedClaimsRatioRounded); diff --git a/app/Views/rfq/gmc.php b/app/Views/rfq/gmc.php index f8982fce..fe9b7c2d 100644 --- a/app/Views/rfq/gmc.php +++ b/app/Views/rfq/gmc.php @@ -78,12 +78,12 @@
Formulas:
- 1. Incurred Claims = Paid Claims + Outstanding Claims
- 2. Policy Run Days = Incurred Claim Date - Policy Start Date + 1
- 3. Earned Premium = (Premium as on Date / 365) × 364
- 4. Annualised Claims = (Incurred Claims / Policy Run Days) × 365
- 5. Incurred Claim Ratio = Annualised Claims / Premium as on Date
- 6. Earned Claims Ratio = Annualised Claims / Earned Premium + 1. Incurred Claims = Paid Claims + Outstanding Claims
+ 2. Policy Run Days = Incurred Claim Date - Policy Start Date + 1
+ 3. Earned Premium = (Premium as on Date / 365) × Policy Run Days
+ 4. Annualised Claims = (Incurred Claims / Policy Run Days) × 365
+ 5. Incurred Claim Ratio = Incurred Claims / Premium as on Date
+ 6. Earned Claims Ratio = Annualised Claims / Premium as on Date
From 11da48cc8387de7a162d0cbd388f11ebea64975d Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 25 Jun 2025 11:15:57 +0530 Subject: [PATCH 07/40] FEAT_HR_ACCESS_CONTROL_MODEL : RV --- app/Models/HRAccessControlModel.php | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 app/Models/HRAccessControlModel.php diff --git a/app/Models/HRAccessControlModel.php b/app/Models/HRAccessControlModel.php new file mode 100644 index 00000000..81f16f0e --- /dev/null +++ b/app/Models/HRAccessControlModel.php @@ -0,0 +1,59 @@ + Date: Thu, 26 Jun 2025 09:22:47 +0530 Subject: [PATCH 08/40] FIX_USER_TEAM_IN_VIEW_RFQ_AND_FORMAT_NO_IN_EXCEL_EARNEDPRE_ANULIZED : RV --- app/Controllers/LeadsController.php | 4 ++-- app/Models/UserModel.php | 1 + app/Views/leads_form.php | 8 ++++++-- app/Views/view_rfq.php | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index ee908837..8572a87b 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -1310,9 +1310,9 @@ class LeadsController extends BaseController 'Policy Run Days' => $rfq_data['policy_run_days'], 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']), 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']), - 'Earned Premium' => $rfq_data['earned_premium'], + 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])), 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']), - 'Annualised Claims' => formatIndianCurrency($rfq_data['annualised_claims']), + 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])), 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %", 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %", ]; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index ed5a8ace..8a5eff7d 100755 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -112,6 +112,7 @@ class UserModel extends Model ->join('user_teams', 'user_profiles.id = user_teams.user_id') ->where('user_profiles.id', $user_id) ->where('user_teams.is_active', 1) + ->where("user_profiles.is_active", 1) ->get() ->getResultArray(); diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 472516f8..01586d13 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -1423,7 +1423,9 @@ console.log('Policy Run Days (Final):', policy_run_days); let annualised_claims = policy_run_days > 0 ? (incurred_claims / policy_run_days) * 365 : 0; - let annualised_claims_roundoff = annualised_claims.toFixed(2); + // let annualised_claims_roundoff = annualised_claims.toFixed(2); + let annualised_claims_roundoff = Math.trunc(annualised_claims); + console.log('Annualised Claims:', annualised_claims); console.log('Annualised Claims (Rounded):', annualised_claims_roundoff); $('#annualised_claims').val(annualised_claims_roundoff); @@ -1440,7 +1442,9 @@ $('#incurred_claims_ratio').val(incurred_claim_ratio_roundoff); let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * policy_run_days : 0; - let earned_premium_roundoff = earned_premium.toFixed(2); + // let earned_premium_roundoff = earned_premium.toFixed(2); + let earned_premium_roundoff = Math.trunc(earned_premium); + console.log('Earned Premium:', earned_premium); console.log('Earned Premium (Rounded):', earned_premium_roundoff); $('#earned_premium').val(earned_premium_roundoff); diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index 4d3ee31e..845d7229 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -230,7 +230,7 @@       Export Excel - + From fa2b22a1e4ffae89140a8c150a3c269b73c1d7cb Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 26 Jun 2025 09:50:43 +0530 Subject: [PATCH 09/40] CHANGES_ icici lumbard started --- app/Config/Autoload.php | 2 +- app/Config/Routes.php | 6 ++ app/Controllers/ICICILombardController.php | 35 +++++++++++ app/Helpers/api_helper.php | 70 ++++++++++++++++++++++ 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 app/Controllers/ICICILombardController.php create mode 100644 app/Helpers/api_helper.php diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index c80f6c1c..9017581a 100755 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -99,5 +99,5 @@ class Autoload extends AutoloadConfig * @var string[] * @phpstan-var list */ - public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper']; + public $helpers = ['uuid','session','utility', 'form', 'url', 'oauth', 'fileupload', 'excel_import_export', 'file', 'drive','ExcelSanitizeHelper', 'api_helper']; } diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 80a25075..d0d6da5f 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -590,3 +590,9 @@ $routes->post("dispatchWebhookData/(:any)/(:any)",'ClientWebHooksController::pus $routes->post("retrieveWebhookDataEmp","ClientWebHooksController::pullData_emp"); $routes->post("retrieveWebhookDataClaim","ClientWebHooksController::pullData_claim"); + + + +//Third party Api Call + +$routes->get('testCall','ICICILombardController::testCall'); \ No newline at end of file diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php new file mode 100644 index 00000000..74a18bbe --- /dev/null +++ b/app/Controllers/ICICILombardController.php @@ -0,0 +1,35 @@ + 'password', + 'username' => 'Nhanceins', + 'password' => 'SSWW7bFNaLxxQyw', + 'scope' => $scope, + 'client_id' => 'Nhanceins', + 'client_secret' => 'P4W0G6TAYMa0MV8bbVSx4pTAqbCcUIg48kCWa6PJykAhGWzPmpPr0iLuNWtz5wqN' + ]; + + $response = call_third_party_api($url, $method, $headers, $body); + + if($response['status'] != false){ + + } + + return $this->response->setJSON($response); + } +} diff --git a/app/Helpers/api_helper.php b/app/Helpers/api_helper.php new file mode 100644 index 00000000..7dd13bd7 --- /dev/null +++ b/app/Helpers/api_helper.php @@ -0,0 +1,70 @@ +'; + // print_r($headers); + // print_r($body); + // die; + + + // Setup curl options + $options = [ + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_CUSTOMREQUEST => $method, + CURLOPT_HTTPHEADER => $headers, + ]; + + // Only include body for applicable methods + if (!empty($body) && in_array($method, ['POST', 'PUT', 'PATCH', 'DELETE'])) { + if (stripos($contentType, 'application/json') !== false) { + $options[CURLOPT_POSTFIELDS] = json_encode($body); + } elseif (stripos($contentType, 'application/x-www-form-urlencoded') !== false) { + $options[CURLOPT_POSTFIELDS] = http_build_query($body); + } elseif (stripos($contentType, 'multipart/form-data') !== false) { + $options[CURLOPT_POSTFIELDS] = $body; // For file uploads or multipart fields + } else { + // Default fallback + $options[CURLOPT_POSTFIELDS] = $body; + } + } + + curl_setopt_array($ch, $options); + + $response = curl_exec($ch); + $error = curl_error($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + curl_close($ch); + + if ($error) { + return [ + 'status' => false, + 'message' => 'Curl error: ' . $error + ]; + } + + $decoded = json_decode($response, true); + return [ + 'status' => ($httpCode >= 200 && $httpCode < 300), + 'data' => $decoded ?: $response, // fallback to raw response + 'code' => $httpCode + ]; + } +} From bbc3aa7e04af842d3c868b09247410dff7031ad0 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 26 Jun 2025 18:44:06 +0530 Subject: [PATCH 10/40] FIX_VEHICAL_MODAL_CLIENT_MODAL : RV --- .../policy_transaction_inception_form.php | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index b378d5cb..7de082a9 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1172,16 +1172,45 @@ $(document).ready(function(){ // keyboard: false // }) + isClientFormSubmitting = true; + $('#upload_enrollment_model').on('hide.bs.modal', function (e) { - if (!isClientFormSubmitting) { - // Ask for confirmation - if (confirm("Are you sure you want to close? Unsaved changes will be lost.")) { - // If confirmed, reset the form + console.log('Attempting to hide #upload_enrollment_model modal'); + + let policy_type_id = $('#policy_type_id').val(); + console.log('policy_type_id:', policy_type_id); + + // Only handle custom behavior for policy_type_id = 8 + if (policy_type_id == 8) { + console.log('policy_type_id is 8 — custom handling begins.'); + + const shouldClose = confirm("Are you sure you want to close? Unsaved changes will be lost."); + // const shouldClose = true; // Always true, can be changed to confirm() if needed + console.log('User confirmation result:', shouldClose); + + if (shouldClose) { + console.log('User confirmed closing. Resetting #client_form.'); + $('#client_form')[0].reset(); + console.log('#client_form reset successfully.'); + + $('#client_form').removeAttr('data-id'); + console.log('data-id attribute removed from #client_form.'); + + console.log('Opening #vehicle_modal.'); + const vehicleModal = new bootstrap.Modal(document.getElementById('vehicle_modal')); + vehicleModal.show(); + + console.log('Setting form data for #vehicle_form from localStorage.'); + setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData"); + } else { - // If not confirmed, prevent the modal from closing - e.preventDefault(); + console.log('User cancelled closing. Preventing modal from hiding.'); + e.preventDefault(); // stops modal from closing } + + } else { + console.log('policy_type_id is not 8 — proceeding with default modal behavior.'); } }); From 8b6bab2d4a0bbc2e28a9388583ac1a98315c6f93 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Fri, 27 Jun 2025 14:56:05 +0530 Subject: [PATCH 11/40] CHANGES_ HR api Hr access control change : GWM --- app/Config/Routes.php | 20 +++---- app/Controllers/ClientController.php | 8 ++- app/Controllers/EmployeeRestController.php | 48 ++++++++++++++-- .../RestAuthenticationController.php | 23 ++++++++ app/Models/ClientPolicyModel.php | 55 +++++++++++++------ 5 files changed, 121 insertions(+), 33 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index d0d6da5f..66ec5bb8 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -466,6 +466,7 @@ $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationContr $routes->post("/employeeRest/verifyHrWithEmail", "RestAuthenticationController::verifyHrWithEmail"); $routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData"); $routes->post("/employeeRest/updateHROTP", "RestAuthenticationController::updateHROTP"); +$routes->get("/employeeRest/getHRAccessData", "RestAuthenticationController::getHRAccessData"); // Test initiate Claim $routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); @@ -486,9 +487,6 @@ $routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin") $routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin"); - -$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); -$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); @@ -517,13 +515,6 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("exportDataByClientPolicyId", "EmployeeRestController::exportDataByClientPolicyId"); - $routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData"); - $routes->get("cdSummaryData", "EmployeeRestController::cdSummaryData"); - $routes->get("cdTransactionData", "EmployeeRestController::cdTransactionData"); - $routes->match( ['get', 'post'], 'claimsSearch','EmployeeRestController::claimsSearch'); - $routes->get("claimView", "EmployeeRestController::claimView"); - $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); - $routes->get("removeEmpAndEmpPolicyData", "EmployeeRestController::removeEmpAndEmpPolicyData"); $routes->post("calculatePremium", "EmployeeRestController::calculatePremium"); @@ -535,6 +526,15 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("getWellnessURL", "EmployeeRestController::getWellnessURL"); //$routes->post('postDataForTicket',"EmployeeRestController::postDataForTicket"); + + //hr api's + $routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData"); + $routes->get("cdSummaryData", "EmployeeRestController::cdSummaryData"); + $routes->get("cdTransactionData", "EmployeeRestController::cdTransactionData"); + $routes->match( ['get', 'post'], 'claimsSearch','EmployeeRestController::claimsSearch'); + $routes->get("claimView", "EmployeeRestController::claimView"); + $routes->get("exportCashDepositData", "EmployeeRestController::exportCashDepositData"); + }); $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 1d206b11..a2637b9e 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -618,12 +618,14 @@ class ClientController extends AdminController } // In your controller - public function deposit($id = null , $requestFrom = null ) + public function deposit($id = null , $requestFrom = null , $policyId = null) { + $headerData['page_name'] = 'Client Deposit'; - + $data['clientName'] = $this->clientModel->where('id', $id)->find(); - $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id); + $data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id,$policyId); + $data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id); // Fetch associated insurer names and balances diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index db9a0ea2..fac6b1c8 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -32,6 +32,7 @@ use App\Models\AuditHistoryModel; use App\Models\TicketClaimStatusModel; use App\Models\TicketMasterModel; use App\Models\TicketMessageModel; +use App\Models\HRAccessControlModel; @@ -83,6 +84,7 @@ class EmployeeRestController extends AdminController protected $ticketMessage; protected $ticketController; + protected $hrAccessControlModel; public function __construct() @@ -112,6 +114,7 @@ class EmployeeRestController extends AdminController $this->ticketMessage = new TicketMessageModel(); $this->ticketController = new TicketController(); + $this->hrAccessControlModel = new HRAccessControlModel(); } @@ -2276,16 +2279,45 @@ class EmployeeRestController extends AdminController } + + public function getHRAccessData( $hr_id = null , $request_for = 'post_enrollment') + { + $hr_id = $this->request->getGet('hr_id') ?? $hr_id; + $request_for = $this->request->getGet('request_for') ?? $request_for; + + if($request_for == 'pre_enrollment'){ $idField = 'pre_hr_id'; }else{ $idField = 'post_hr_id'; } + + $data = $this->hrAccessControlModel->where($idField , $hr_id)->where('is_active' , 1)->first(); + + if($request_for == 'post_enrollment'){ return $data ?? []; } + + return $this->respond(['status' => (($data) ? 'success' : 'failed'),'code' => (($data) ? 200 : 404),'data' => $data ], 200); + } + public function getPolicyLevelEmployeeSummaryData() { + $hr_id = $this->request->getGet('hr_id'); + $HRAccessData = $this->getHRAccessData($hr_id,'post_enrollment'); + + if(isset($HRAccessData['allowed_active_policies'])) + { + $policyId = json_decode($HRAccessData['allowed_active_policies'],true); + }else{ + $policyId = []; + } + + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type ') ->where('client_policy.client_id', $this->request->getGet('client_id') ) ->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') ) ->where('client_policy.is_active', 1 ) ->where('client_policy.policy_status', $this->request->getGet('policy_status')) + ->whereIn('client_policy.id', $policyId) ->findAll(); + + $result = []; // dd( $ClientPolicyData); foreach ($ClientPolicyData as $key => $value) @@ -2331,13 +2363,24 @@ class EmployeeRestController extends AdminController public function cdSummaryData() { + $hr_id = $this->request->getGet('hr_id'); + $HRAccessData = $this->getHRAccessData($hr_id,'post_enrollment'); + + if(isset($HRAccessData['allowed_active_policies'])) + { + $policyId = json_decode($HRAccessData['allowed_active_policies'],true); + }else{ + $policyId = []; + } + $clientId = $this->request->getGet('client_id'); $clientController = new ClientController; - $result = $clientController->deposit($clientId , $requestFrom = 'rest'); + $result = $clientController->deposit($clientId , $requestFrom = 'rest' , $policyId); $data = []; + foreach ($result['clientData'] as $key => $value) { $temp['client_id'] = $value->client_id; @@ -2539,9 +2582,6 @@ class EmployeeRestController extends AdminController } - - - public function exportCashDepositData() { diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index a31dabe7..de52b208 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -21,6 +21,7 @@ use CodeIgniter\API\ResponseTrait; use App\Models\EmployeeModel; use App\Models\AuthHistoryModel; use App\Models\LevelContactModel; +use App\Models\HRAccessControlModel; use Firebase\JWT\JWT; // require_once('../vendor/autoload.php'); @@ -35,6 +36,7 @@ class RestAuthenticationController extends AdminController protected $employeeModel; protected $authHistoryModel; protected $hrModel; + protected $hrAccessControlModel; public function __construct() @@ -45,6 +47,7 @@ class RestAuthenticationController extends AdminController $this->employeeModel = new EmployeeModel(); $this->authHistoryModel = new AuthHistoryModel(); $this->hrModel = new LevelContactModel(); + $this->hrAccessControlModel = new HRAccessControlModel(); } @@ -441,6 +444,11 @@ class RestAuthenticationController extends AdminController ->find(); } + $HRAccessData = $this->getHRAccessData( $hrData['0']['id'] , 'post_enrollment'); + + if(isset($HRAccessData['allowed_modules'])){ $hrData['0']['allowed_modules'] = json_decode($HRAccessData['allowed_modules'],true)['post']; }else{ $hrData['0']['allowed_modules'] = []; } + + $result = JWTToken::encode($hrData['0']); @@ -457,6 +465,21 @@ class RestAuthenticationController extends AdminController } + public function getHRAccessData( $hr_id = null , $request_for = 'post_enrollment') + { + $hr_id = $this->request->getGet('hr_id') ?? $hr_id; + $request_for = $this->request->getGet('request_for') ?? $request_for; + + if($request_for == 'pre_enrollment'){ $idField = 'pre_hr_id'; }else{ $idField = 'post_hr_id'; } + + $data = $this->hrAccessControlModel->where($idField , $hr_id)->where('is_active' , 1)->first(); + + if($request_for == 'post_enrollment'){ return $data ?? []; } + + return $this->respond(['status' => (($data) ? 'success' : 'failed'),'code' => (($data) ? 200 : 404),'data' => $data ], 200); + } + + public function getUserIdFromToken() { diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 59f05958..5c43b52e 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -168,25 +168,48 @@ class ClientPolicyModel extends Model } - public function getinsurerswithclientid($id) + public function getinsurerswithclientid($id, $policyId = null) { + // dd($policyId); - return $this->db->table('client_policy') - ->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no') - ->select('insurers.name as insurer_name, insurers.short_name as insurer_short') - ->select('clients.client_name as client_name') - ->join('clients', 'clients.id=client_policy.client_id') - ->join('insurers', 'insurers.id = client_policy.insurer_id') - ->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id') - ->where('client_policy.client_id', $id) - ->where('cd_master.id = client_policy.cd_ac_pk') - ->where('cd_master.is_active', 1) - ->groupBy('client_policy.client_id', $id) // Group by insurer_id - ->groupBy('client_policy.insurer_id') - ->groupBy('client_policy.cd_ac_pk') - ->get() - ->getResult(); + $builder = $this->db->table('client_policy') + ->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no') + ->select('insurers.name as insurer_name, insurers.short_name as insurer_short') + ->select('clients.client_name as client_name') + ->join('clients', 'clients.id = client_policy.client_id') + ->join('insurers', 'insurers.id = client_policy.insurer_id') + ->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id') + ->where('client_policy.client_id', $id) + ->where('cd_master.id = client_policy.cd_ac_pk') + ->where('cd_master.is_active', 1) + ->groupBy('client_policy.client_id') + ->groupBy('client_policy.insurer_id') + ->groupBy('client_policy.cd_ac_pk'); + if ($policyId != null) { + $builder->whereIn('client_policy.id', $policyId); + } + + return $builder->get()->getResult(); + + + + // return $this->db->table('client_policy') + // ->select('client_policy.*, cd_master.cd_ac_no as cd_master_account_no') + // ->select('insurers.name as insurer_name, insurers.short_name as insurer_short') + // ->select('clients.client_name as client_name') + // ->join('clients', 'clients.id=client_policy.client_id') + // ->join('insurers', 'insurers.id = client_policy.insurer_id') + // ->join('cd_master', 'cd_master.insurer_id = insurers.id AND cd_master.client_id = client_policy.client_id') + // ->where('client_policy.client_id', $id) + // ->where('cd_master.id = client_policy.cd_ac_pk') + // ->where('cd_master.is_active', 1) + // ->groupBy('client_policy.client_id', $id) // Group by insurer_id + // ->groupBy('client_policy.insurer_id') + // ->groupBy('client_policy.cd_ac_pk') + // ->get() + // ->getResult(); + // return $this->db->table('client_policy') // ->select('insurers.name as insurer_name, insurers.short_name as insurer_short') // ->select('clients.client_name as client_name') From 16d4af035d0e89ab91682bc22164ab456b8a5c03 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 30 Jun 2025 10:09:14 +0530 Subject: [PATCH 12/40] FIX_BDS_POPUP_AND OTHERS : RV --- app/Controllers/ClientController.php | 55 +++++++--- app/Controllers/LeadsController.php | 101 +++++++----------- app/Views/layout/footer.php | 6 +- app/Views/newClientModal.php | 8 +- .../policy_transaction_inception_form.php | 86 +++++++++++---- 5 files changed, 155 insertions(+), 101 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 1d206b11..9d04e991 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4229,6 +4229,7 @@ class ClientController extends AdminController $client_id = $this->request->getGet('client_id'); $client_branch_id = $this->request->getGet('client_branch_id'); $policy_type_id = $this->request->getGet('policy_type_id'); + $client_type = $this->request->getGet('client_type'); $data = $this->clientPolicyModel ->select(" @@ -4247,20 +4248,37 @@ class ClientController extends AdminController ->first(); if ($data) { - if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) { - if ($data['policy_type_id'] == $policy_type_id) { - return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); + if ($client_type == 1) { + if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) { + + if ($data['policy_type_id'] == $policy_type_id) { + return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); + } else { + $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); + $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; + return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); + } } else { - $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); - $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; - return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); + $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; + return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); } - } else { - $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; - return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); + if ($data['client_id'] == $client_id) { + + if ($data['policy_type_id'] == $policy_type_id) { + return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200); + } else { + $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first(); + $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.'; + return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200); + } + } else { + $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check'; + return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200); + } } + } else { return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200); } @@ -5082,6 +5100,17 @@ class ClientController extends AdminController // $return_value = check_cd_entry_exist($baseWhere); // dd($return_value); + + + + // $param = "533454"; + // $type = 'emp_code'; + // $client_policy_id = 64; + // $client_id = 51; + + // $result = $this->getTheEmpDataForClaimSearchByMobile($param, $type, $client_policy_id, $client_id); + // dd($result); + } // ------------------------------------------------------------------------------------------------------- @@ -5262,9 +5291,9 @@ class ClientController extends AdminController $query->where('employees.client_id', $client_id); } - if (!empty($client_policy_id)) { - $query->where('employee_polices.client_policy_id', $client_policy_id); - } + // if (!empty($client_policy_id)) { + // $query->where('employee_polices.client_policy_id', $client_policy_id); + // } $query->groupBy('employees.id') ->orderBy('employees.id', 'DESC'); @@ -5285,7 +5314,7 @@ class ClientController extends AdminController if(!empty($data) && count($data) > 0){ - $memberData = $this->employeeModel->getEmployeeByEmployeeCode($data['emp_code'], $data['policy_id'], $client_id); + $memberData = $this->employeeModel->getEmployeeByEmployeeCode($data['emp_code'], null, $client_id); $acms_datas = $this->employeeModel->getAcmUsingClientID($data['client_id']); // if(!empty($acms_datas)){ // $acms = $acms_datas; diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 8572a87b..59a9dea4 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -1360,7 +1360,7 @@ class LeadsController extends BaseController $rowNumber = 1; $mergeRange1 = "A{$rowNumber}:B{$rowNumber}"; - $sheet->mergeCells($mergeRange1); + // $sheet->mergeCells($mergeRange1); $sheet->setCellValue("A{$rowNumber}", "Nhance India Insurance Broking Pvt Ltd"); $sheet->getStyle("A{$rowNumber}")->applyFromArray([ 'font' => [ @@ -1374,9 +1374,8 @@ class LeadsController extends BaseController ]); // Apply center alignment to the cell - $sheet->getStyle("C{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); - $sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); - + // $sheet->getStyle("C{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); + // $sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); $rowNumber = $rowNumber + 1; @@ -1388,22 +1387,22 @@ class LeadsController extends BaseController // Merge A:B for key and C:D for value $mergeRangeKey = "A{$rowNumber}:B{$rowNumber}"; - $mergeRangeValue = "C{$rowNumber}"; + // $mergeRangeValue = "C{$rowNumber}"; $sheet->mergeCells($mergeRangeKey); - $sheet->mergeCells($mergeRangeValue); + // $sheet->mergeCells($mergeRangeValue); // Set values in merged cells $sheet->setCellValue("A{$rowNumber}", $key); $sheet->setCellValue("C{$rowNumber}", $value); - // Apply styles for alignment and bold text in A:B - $sheet->getStyle($mergeRangeKey)->applyFromArray([ - 'font' => ['bold' => true], - 'alignment' => [ - 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, - 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, - ], - ]); + // // Apply styles for alignment and bold text in A:B + // $sheet->getStyle($mergeRangeKey)->applyFromArray([ + // 'font' => ['bold' => true], + // 'alignment' => [ + // 'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, + // 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, + // ], + // ]); // Apply bold style to B column if the key is "Insured" if ($key == "Insured") { @@ -1419,7 +1418,7 @@ class LeadsController extends BaseController $rowNumber++; } - // // Set column width based on max content length (adjusted for padding) + // Set column width based on max content length (adjusted for padding) $sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2); // $sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.5); $sheet->getColumnDimension('C')->setWidth(35); @@ -1470,13 +1469,14 @@ class LeadsController extends BaseController $sheet->mergeCells($mergeRange); $rowNumber_for_remove_quote_asked = $rowNumber; $rowNumber = $rowNumber + 1; + if ($type == 2) { $subHeaderRow = $rowNumber + 1; } else { $subHeaderRow = $rowNumber_for_remove_quote_asked; } - $columnLetter = 'A'; + $columnLetter = 'A'; $header_actual_count = 0; foreach ($headers as $header) { // Kint::dump($header); @@ -1561,8 +1561,6 @@ class LeadsController extends BaseController $sheet->getColumnDimension('B')->setWidth(35); } - // die(); - // Apply border to the header range $prevColumn1 = $this->getPreviousColumn($columnLetter); $headerRange = "A{$rowNumber}:" . "{$prevColumn1}" . "{$subHeaderRow}"; @@ -1584,6 +1582,7 @@ class LeadsController extends BaseController } else { $rowNumber = $subHeaderRow + 2; } + // dd($rowNumber); $column_data = $data['table_data']['data']; $serial_no = 1; @@ -1627,36 +1626,37 @@ class LeadsController extends BaseController // Add premium data // dd($data); - $labelArray = ["Premium", "GST (%)", "GST Amount (₹)", "Total"]; + // $labelArray = ["Premium", "GST (%)", "GST Amount (₹)", "Total"]; + $labelArray = ["Premium", "GST Amount (₹)", "Total"]; $premiumData = $data['premium_data']['data']; - $premium = [$labelArray[0]]; - $gst = [$labelArray[1]]; - $gstAmt = [$labelArray[2]]; - $total = [$labelArray[3]]; + // $premium = [$labelArray[0]]; + // $gst = [$labelArray[1]]; + // $gstAmt = [$labelArray[1]]; + // $total = [$labelArray[2]]; foreach ($premiumData as $proposal => $insurers) { if ($proposal != 'Particulars') { foreach ($insurers as $insurer => $values) { if($insurer == 'Quote Asked'){ - $premium[] = ""; - $gst[] = ""; - $gstAmt[] = ""; - $total[] = ""; + $premium[] = $labelArray[0]; + // $gst[] = ""; + $gstAmt[] = $labelArray[1]; + $total[] = $labelArray[2]; }else{ $premium[] = formatIndianCurrency($values[$labelArray[0]]); - $gst[] = $values[$labelArray[1]]; - $gstAmt[] = formatIndianCurrency($values[$labelArray[2]]); - $total[] = formatIndianCurrency($values[$labelArray[3]]); + // $gst[] = $values[$labelArray[1]]; + $gstAmt[] = formatIndianCurrency($values[$labelArray[1]]); + $total[] = formatIndianCurrency($values[$labelArray[2]]); } } } } - foreach ([$premium, $gst, $gstAmt, $total] as $index => $rowData) { - $columnLetter = 'B'; + foreach ([$premium, $gstAmt, $total] as $index => $rowData) { + $columnLetter = 'C'; foreach ($rowData as $key => $value) { $sheet->setCellValue("{$columnLetter}{$rowNumber}", $value); - if ($key === 0) { + if (in_array($value, $labelArray)) { $sheet->getStyle("{$columnLetter}{$rowNumber}")->applyFromArray(['font' => ['bold' => true,],]); } $columnLetter++; @@ -1669,7 +1669,8 @@ class LeadsController extends BaseController } else { $prevColumn3 = $this->getPreviousColumn($columnLetter, 2); } - $premiumRange = "B" . ($rowNumber - 4) . ":" . "{$prevColumn3}" . ($rowNumber - 1); + + $premiumRange = "C" . ($rowNumber - 3) . ":" . "{$prevColumn3}" . ($rowNumber - 1); // dd($premiumRange); $sheet->getStyle($premiumRange)->applyFromArray([ @@ -1682,9 +1683,7 @@ class LeadsController extends BaseController ]); } - //set imgage and align the row and column - // Kint::dump($columnLetter); if ($type == 2) { if ($is_placement == true) { $columnLetter_img = $this->getPreviousColumn($columnLetter); @@ -1694,7 +1693,6 @@ class LeadsController extends BaseController } else { $columnLetter_img = $this->getPreviousColumn($columnLetter); } - // dd($columnLetter_img); $company_name = $this->getPreviousColumn($columnLetter_img); $mergeRange1 = "A1:{$company_name}1"; @@ -1722,39 +1720,19 @@ class LeadsController extends BaseController $drawing->setPath($path); $drawing->setCoordinates("{$columnLetter_img}1"); // Set position in column B $drawing->setHeight(35); // Adjust image - $columnWidth = $sheet->getColumnDimension("C")->getWidth(); // e.g., 20 - $cellPixelWidth = $columnWidth * 7; // Approximate conversion (1 unit ≈ 7 pixels) - $imagePixelWidth = 250; // Approximate width of your image (in pixels) - - $offsetX = max(0, ($cellPixelWidth - $imagePixelWidth) / 2); - $offsetX = $offsetX + 97; - // dd($length); - if ($length >= 4) { - $offsetX = 65; - } else if ($length == 3) { - $offsetX = 65; - } - - // Center align the image in the cell + $offsetX = 35; $drawing->setOffsetX($offsetX); // Adjust horizontal offset $drawing->setOffsetY(10); // Adjust vertical offset $drawing->setWorksheet($sheet); - //end - // Auto-size columns // foreach ($sheet->getColumnIterator() as $column) { // $sheet->getColumnDimension($column->getColumnIndex())->setAutoSize(true); // } $dataRange = $sheet->calculateWorksheetDimension(); - - $sheet->getStyle($dataRange)->getAlignment() - ->setHorizontal(Alignment::HORIZONTAL_CENTER) - ->setVertical(Alignment::VERTICAL_CENTER) - ->setWrapText(true); - + $sheet->getStyle($dataRange)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_CENTER)->setWrapText(true); $sheet->getStyle('A1')->applyFromArray([ 'alignment' => [ 'wrapText' => false, // Disables text wrapping for A1 @@ -1791,8 +1769,6 @@ class LeadsController extends BaseController ], ]); - - // Set filename $string = ($type == 2) ? ($is_placement == true ? 'Placement' : 'QCR') : 'RFQ'; $current_year = date('Y'); @@ -1809,7 +1785,6 @@ class LeadsController extends BaseController $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '_' . '.xlsx'; } - // Save to temporary location $uploadFilePath = WRITEPATH . 'tmp/' . $filename; $writer = new Xlsx($spreadsheet); @@ -4026,7 +4001,7 @@ class LeadsController extends BaseController $offsetX = max(0, ($cellPixelWidth - $imagePixelWidth) / 2); $offsetX = $offsetX + 97; if ($length >= 4) { - $offsetX = 50; + $offsetX = 35; } else if ($length == 3) { $offsetX = 140; } diff --git a/app/Views/layout/footer.php b/app/Views/layout/footer.php index c63f59f6..c150e074 100755 --- a/app/Views/layout/footer.php +++ b/app/Views/layout/footer.php @@ -302,9 +302,9 @@ }); - fetchMessages(); + // fetchMessages(); - setInterval(fetchMessages, 60000); // Fetch messages every sixty seconds + // setInterval(fetchMessages, 60000); // Fetch messages every sixty seconds }); $(document).ready(function() { @@ -823,6 +823,7 @@ \ No newline at end of file From c13ba6d3db29a76ca7aa26d973817f6a61037cd1 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 8 Jul 2025 09:38:52 +0530 Subject: [PATCH 31/40] FIX_CD_TRANSACTION_SUMMERY_QUERY : RV --- app/Models/ClientPolicyModel.php | 38 +++++++++++++++++++++++--------- app/Models/InsurerModel.php | 1 + 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 14d6b065..f571659e 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -281,7 +281,8 @@ class ClientPolicyModel extends Model ->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left') ->where('cash_deposit.client_id', $clientId) ->where('cash_deposit.insurer_id', $insurerId) - ->where('cash_deposit.is_active', 1); + ->where('cash_deposit.is_active', 1) + ->where('cd_master.is_active', 1); // ->where('cash_deposit.cd_ac_pk = cd_master.id') if(!empty($cd_ac_pk)){ $query->where('cash_deposit.cd_ac_pk', $cd_ac_pk); @@ -354,15 +355,32 @@ class ClientPolicyModel extends Model public function getDepositlistsummary($id) { - return $this->db->table('cash_deposit') - ->select('insurer_id, cd_ac_pk') - ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance') - ->where('client_id', $id) - ->where('is_active', 1) - ->groupBy('insurer_id') - // ->groupBy('cd_ac_pk') - ->get() - ->getResult(); + // return $this->db->table('cash_deposit') + // ->select('insurer_id, cd_ac_pk, balance') + // // ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance') + // ->where('client_id', $id) + // ->where('is_active', 1) + // ->orderBy('id', 'desc') + // ->groupBy('insurer_id') + // // ->groupBy('cd_ac_pk') + // ->get() + // ->getResult(); + + $sql = " + SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance + FROM cash_deposit cd + INNER JOIN ( + SELECT insurer_id, MAX(id) AS max_id + FROM cash_deposit + WHERE client_id = ? + AND is_active = 1 + GROUP BY insurer_id + ) latest ON cd.insurer_id = latest.insurer_id AND cd.id = latest.max_id + ORDER BY cd.id DESC + "; + + return $this->db->query($sql, [$id])->getResult(); + } diff --git a/app/Models/InsurerModel.php b/app/Models/InsurerModel.php index e24dd00a..dcb7fe8b 100755 --- a/app/Models/InsurerModel.php +++ b/app/Models/InsurerModel.php @@ -47,6 +47,7 @@ class InsurerModel extends Model ->where('client_policy.insurer_id', $insurerId) ->where('client_policy.client_id', $client_id) ->where('cd_master.id = client_policy.cd_ac_pk') + ->where('cd_master.is_active', 1) ->get(); if ($query->resultID->num_rows > 0) { From a4595c36e7261278d88feb86b09944b6b82ada8b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 9 Jul 2025 09:53:28 +0530 Subject: [PATCH 32/40] CHANGE_MPIN_ISSUE : RV --- app/Config/Routes.php | 1 + .../RestAuthenticationController.php | 321 ++++++++++++++---- 2 files changed, 258 insertions(+), 64 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 457388ff..ddb9af3f 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -488,6 +488,7 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin"); $routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin"); +$routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth"); $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index e31ecb2a..2e234f5c 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -22,6 +22,7 @@ use App\Models\EmployeeModel; use App\Models\AuthHistoryModel; use App\Models\LevelContactModel; use App\Models\HRAccessControlModel; +use App\Models\ClientModel; use Firebase\JWT\JWT; // require_once('../vendor/autoload.php'); @@ -37,6 +38,7 @@ class RestAuthenticationController extends AdminController protected $authHistoryModel; protected $hrModel; protected $hrAccessControlModel; + protected $clientModel; public function __construct() @@ -48,6 +50,7 @@ class RestAuthenticationController extends AdminController $this->authHistoryModel = new AuthHistoryModel(); $this->hrModel = new LevelContactModel(); $this->hrAccessControlModel = new HRAccessControlModel(); + $this->clientModel = new ClientModel(); } @@ -103,6 +106,7 @@ class RestAuthenticationController extends AdminController } } catch (\Throwable $th) { + $this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine())); return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); } } @@ -110,10 +114,13 @@ class RestAuthenticationController extends AdminController public function verifyEmployeeWithEmailId() { try { + + log_message('error', json_encode($this->request->getJSON())); $email = $this->request->getJSON()->email; + $client_id = $this->request->getJSON()->client_id ?? null; - $employeeData = $this->employeeModel->select(' + $builder = $this->employeeModel->select(' employees.relationship, EP.employee_id, employees.client_id, @@ -124,19 +131,38 @@ class RestAuthenticationController extends AdminController ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') ->where('employees.is_active', 1) ->where('employees.relationship', 'Self') - ->where('employees.emp_status !=', 'truncated') + ->whereIn('employees.emp_status', ['active', 'expired']) ->where('employees.email_corporate', $email) ->where('EP.is_active', 1) - ->whereIn('EP.status', ['active', 'expired']) - ->first(); + ->whereIn('EP.status', ['active', 'expired']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $builder->orderBy('employees.id', 'desc'); + $employeeData = $builder->first(); 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(); + // $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) + ->where('relationship', 'Self') + ->where('is_active', 1) + ->where('id', $employeeData['employee_id']); + + if (!empty($client_id)) { + $builder->where('client_id', $client_id); + } + + $update = $builder->set(['otp' => $otp])->update(); + if ($update) { $common = [ @@ -164,11 +190,14 @@ class RestAuthenticationController extends AdminController $result = ['user_verification' => false, 'message' => "Verification failed , try again"]; return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); } + } else { $result = ['user_verification' => false, 'message' => "User not found"]; return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200); } + } catch (\Throwable $th) { + $this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine())); return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500); } } @@ -178,10 +207,24 @@ class RestAuthenticationController extends AdminController $email = $this->request->getJSON()->email; $otp = $this->request->getJSON()->otp; - - $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self') - ->where('is_active', 1)->set(array('otp' => $otp)) - ->update(); + $client_id = $this->request->getJSON()->client_id ?? null; + $employee_id = $this->request->getJSON()->employee_id ?? null; + + $builder = $this->employeeModel + ->where('email_corporate', $email) + ->where('relationship', 'Self') + ->where('is_active', 1); + + if (!empty($client_id)) { + $builder->where('client_id', $client_id); + } + + if (!empty($employee_id)) { + $builder->where('id', $employee_id); + } + + $builder->set(['otp' => $otp])->update(); + return true; @@ -333,6 +376,7 @@ class RestAuthenticationController extends AdminController $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; + $client_id = $this->request->getJSON()->client_id ?? null; if (isset($this->request->getJSON()->login_by_hr)) { @@ -341,7 +385,7 @@ class RestAuthenticationController extends AdminController if (isset($mobile_number)) { // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.mobile', $mobile_number) @@ -349,22 +393,32 @@ 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']) - ->where('employees.emp_status !=', 'truncated') - ->first(); + ->whereIn('employees.emp_status', ['active', 'expired']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } else { // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first(); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.email_corporate', $email_id) + ->where('employees.email_corporate', $email_id) ->where('employees.relationship', 'Self') ->where('employee_polices.is_active', 1) ->whereIn('employee_polices.status', ['active', 'expired']) ->where('employees.is_active', 1) ->whereIn('employees.emp_status', ['active', 'expired']) - ->where('otp', $otp) - ->first(); + ->where('otp', $otp); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); } } @@ -622,23 +676,29 @@ class RestAuthenticationController extends AdminController $mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null; $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; + $client_id = $this->request->getJSON()->client_id ?? null; if (isset($mobile_number)) { // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); - $employeeData = $this->employeeModel - ->select('employees.*') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.mobile', $mobile_number) - ->where('employees.relationship', 'Self') - ->where('employee_polices.is_active', 1) - ->whereIn('employee_polices.status', ['active', 'expired']) - ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active', 'expired']) - ->orderBy('id', 'desc') - ->first(); + $builder = $this->employeeModel + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.mobile', $mobile_number) + ->where('employees.relationship', 'Self') + ->where('employee_polices.is_active', 1) + ->whereIn('employee_polices.status', ['active', 'expired']) + ->where('employees.is_active', 1) + ->whereIn('employees.emp_status', ['active', 'expired']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } else { // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.email_corporate', $email_id) @@ -646,9 +706,13 @@ 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']) - ->orderBy('id', 'desc') - ->first(); + ->whereIn('employees.emp_status', ['active', 'expired']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); } $mpin = $this->request->getJSON()->mpin; @@ -681,6 +745,7 @@ class RestAuthenticationController extends AdminController } } catch (\Throwable $th) { + $this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine())); return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); } } @@ -693,6 +758,7 @@ class RestAuthenticationController extends AdminController $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; $old_mpin = $this->request->getJSON()->old_mpin; $mpin = $this->request->getJSON()->new_mpin; + $client_id = $this->request->getJSON()->client_id ?? null; // if (isset($mobile_number)) // { @@ -703,7 +769,7 @@ class RestAuthenticationController extends AdminController if (isset($mobile_number)) { // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.mobile', $mobile_number) @@ -712,12 +778,17 @@ class RestAuthenticationController extends AdminController ->whereIn('employee_polices.status', ['active']) ->where('employees.is_active', 1) ->whereIn('employees.emp_status', ['active']) - ->where('employees.mpin', $old_mpin) - ->orderBy('id', 'desc') - ->first(); + ->where('employees.mpin', $old_mpin); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } else { // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first(); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.email_corporate', $email_id) @@ -726,9 +797,13 @@ class RestAuthenticationController extends AdminController ->whereIn('employee_polices.status', ['active']) ->where('employees.is_active', 1) ->whereIn('employees.emp_status', ['active']) - ->where('employees.mpin', $old_mpin) - ->orderBy('id', 'desc') - ->first(); + ->where('employees.mpin', $old_mpin); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); } @@ -750,6 +825,7 @@ class RestAuthenticationController extends AdminController } } catch (\Throwable $th) { + $this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine())); return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500); } } @@ -823,6 +899,7 @@ class RestAuthenticationController extends AdminController $mobile_number = $requestData['mobile_number'] ?? null; $email_id = $requestData['email_id'] ?? null; $mpin = $requestData['mpin'] ?? null; + $client_id = $requestData['client_id'] ?? null; // print_r($mpin); if (!$mpin) { @@ -830,7 +907,8 @@ class RestAuthenticationController extends AdminController } if ($mobile_number) { - $employeeData = $this->employeeModel + + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.mobile', $mobile_number) @@ -838,10 +916,18 @@ class RestAuthenticationController extends AdminController ->where('employee_polices.is_active', 1) ->whereIn('employee_polices.status', ['active']) ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active']) - ->first(); + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } elseif ($email_id) { - $employeeData = $this->employeeModel + + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.email_corporate', $email_id) @@ -849,8 +935,14 @@ class RestAuthenticationController extends AdminController ->where('employee_polices.is_active', 1) ->whereIn('employee_polices.status', ['active']) ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['active']) - ->first(); + ->whereIn('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } else { return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Mobile number or Email ID is required'], 400); } @@ -885,6 +977,7 @@ class RestAuthenticationController extends AdminController ], 200); } } catch (\Exception $e) { + $this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine())); return $this->respond([ 'status' => 'failed', 'code' => 500, @@ -899,11 +992,13 @@ class RestAuthenticationController extends AdminController $mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null; $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; // $mpin = $this->request->getJSON()->mpin; + $client_id = $this->request->getJSON()->client_id ?? null; + if (isset($mobile_number)) { // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.mobile', $mobile_number) @@ -911,12 +1006,16 @@ 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']) - ->orderBy('id', 'desc') - ->first(); + ->whereIn('employees.emp_status', ['active', 'expired']); + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + }else{ // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.email_corporate', $email_id) @@ -924,9 +1023,13 @@ 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']) - ->orderBy('id', 'desc') - ->first(); + ->whereIn('employees.emp_status', ['active', 'expired']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); } @@ -937,6 +1040,7 @@ class RestAuthenticationController extends AdminController return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200); } } catch (\Exception $e) { + $this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine())); return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500); } } @@ -949,6 +1053,7 @@ class RestAuthenticationController extends AdminController $json = $this->request->getJSON(); $mobile_number = $json->mobile_number ?? null; $email_id = $json->email_id ?? null; + $client_id = $json->client_id ?? null; log_message('info', 'Received input - Mobile: ' . var_export($mobile_number, true) . ', Email: ' . var_export($email_id, true)); @@ -964,20 +1069,28 @@ class RestAuthenticationController extends AdminController // Step 2: Fetch employee data if ($mobile_number) { + log_message('info', 'Looking up employee by mobile number: ' . $mobile_number); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->where('employees.mobile', $mobile_number) + ->where('employees.mobile', $mobile_number) ->where('employees.relationship', 'Self') ->where('employee_polices.is_active', 1) ->where('employee_polices.status', ['active']) ->where('employees.is_active', 1) - ->where('employees.emp_status', ['active']) - ->first(); + ->where('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } else { + log_message('info', 'Looking up employee by email: ' . $email_id); - $employeeData = $this->employeeModel + $builder = $this->employeeModel ->select('employees.*') ->join('employee_polices', 'employees.id = employee_polices.employee_id') ->where('employees.email_corporate', $email_id) @@ -985,8 +1098,13 @@ class RestAuthenticationController extends AdminController ->where('employee_polices.is_active', 1) ->where('employee_polices.status', ['active']) ->where('employees.is_active', 1) - ->where('employees.emp_status', ['active']) - ->first(); + ->where('employees.emp_status', ['active']); + + if (!empty($client_id)) { + $builder->where('employees.client_id', $client_id); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); } log_message('info', '$employeeData : ' . json_encode($employeeData)); @@ -1028,7 +1146,7 @@ class RestAuthenticationController extends AdminController log_message('warning', 'Employee not found locally. Falling back to third-party API.'); return $this->respond(['status' => 'failed','code' => 404,'data' => "Employee not found"],200); } } catch (\Throwable $e) { - log_message('error', 'Exception in forgotMPIN(): ' . $e->getMessage()); + $this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine())); return $this->respond([ 'status' => 'failed', 'code' => 500, @@ -1063,6 +1181,81 @@ class RestAuthenticationController extends AdminController return redirect()->to($url); } + public function getPostEmployeeDataForAuth() + { + $params = $this->request->getJSON(true); + // print_r( $params); die; + + $mobile_number = $params['mobile_number'] ?? null; + $email_id = $params['email_id'] ?? null; + $otp = $params['otp'] ?? null; + $old_mpin = $params['old_mpin'] ?? null; + + if (empty($mobile_number) && empty($email_id)) { + return $this->respond([ + 'status' => 'failed', + 'message' => 'Mobile number or Email ID is required.', + 'data' => [], + ], 400); + } + + if (!empty($mobile_number)) { + + $builder = $this->employeeModel + ->select('employees.id as employee_id, employees.*') + ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') + ->where('employees.is_active', 1) + ->where("TRIM(employees.relationship) = 'self'", null, false) + ->whereIn('employees.emp_status', ['active', 'expired']) + ->where('employees.mobile', $mobile_number) + ->where('EP.is_active', 1) + ->whereIn('EP.status', ['active', 'expired']); + + if (!empty($old_mpin)) { + $builder->where('employees.mpin', $old_mpin); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + + } else { + $builder = $this->employeeModel + ->select('employees.id as employee_id, employees.*') + ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') + ->where('employees.is_active', 1) + ->where("TRIM(employees.relationship) = 'self'", null, false) + ->whereIn('employees.emp_status', ['active', 'expired']) + ->where('employees.email_corporate', $email_id) + ->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); + } + + $employeeData = $builder->orderBy('employees.id', 'desc')->first(); + } + + if ($employeeData) { + + $client_data = $this->clientModel->where('is_active', 1)->where('id', $employeeData['client_id'])->first(); + $employeeData['client_short_name'] = $client_data['short_name']; + + return $this->respond([ + 'status' => 'success', + 'data' => $employeeData, + ], 200); + } + + return $this->respond([ + 'status' => 'failed', + 'message' => 'No employee found.', + 'data' => [], + ], 404); + } From 9db59e70ed50eaad40889edbcc10224f57d14b5d Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 9 Jul 2025 10:21:06 +0530 Subject: [PATCH 33/40] FIX_CDMASTER_DUP_ISSUE --- app/Config/Autoload.php | 3 +- app/Config/Routes.php | 4 +- app/Controllers/ICICILombardController.php | 21 ++-- app/Controllers/TestBusinessController.php | 30 +++++ app/Controllers/TicketController.php | 112 ++++++++++++++++-- app/Controllers/TraceableController.php | 127 +++++++++++++++++++++ app/Libraries/CustomTraceLogger.php | 42 +++++++ app/Traits/Traceable.php | 23 ++++ app/Views/cd_master_list.php | 9 +- 9 files changed, 345 insertions(+), 26 deletions(-) create mode 100644 app/Controllers/TestBusinessController.php create mode 100644 app/Controllers/TraceableController.php create mode 100644 app/Libraries/CustomTraceLogger.php create mode 100644 app/Traits/Traceable.php diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index 9017581a..a1a4356c 100755 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -47,7 +47,8 @@ class Autoload extends AutoloadConfig public $psr4 = [ APP_NAMESPACE => APPPATH, // For custom app namespace 'Config' => APPPATH . 'Config', - 'Helpers' => APPPATH . 'Helpers' + 'Helpers' => APPPATH . 'Helpers', + 'App\\Libraries' => APPPATH . 'Libraries', ]; /** diff --git a/app/Config/Routes.php b/app/Config/Routes.php index cc54d104..de19fd7a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -601,4 +601,6 @@ $routes->post("retrieveWebhookDataClaim","ClientWebHooksController::pullData_cla $routes->get('generateAuthToken','ICICILombardController::generateAuthToken'); $routes->get('createEnrollmentBatch','ICICILombardController::createEnrollmentBatch'); $routes->get('getEnrollmentBatchStatus','ICICILombardController::getEnrollmentBatchStatus'); -$routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails'); \ No newline at end of file +$routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails'); + +$routes->get('testTracelog','TestBusinessController::a'); \ No newline at end of file diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php index 75205f74..e1c09e30 100644 --- a/app/Controllers/ICICILombardController.php +++ b/app/Controllers/ICICILombardController.php @@ -10,7 +10,7 @@ class ICICILombardController extends AdminController public function generateAuthToken($scope = 'esbhealth') { helper('api'); - + // dd($scope); $url = 'https://ilesbapigee.insurancearticlez.com/generate-jwt-token'; $method = 'POST'; $headers = [ @@ -24,10 +24,10 @@ class ICICILombardController extends AdminController 'client_id' => 'Nhanceins', 'client_secret' => 'P4W0G6TAYMa0MV8bbVSx4pTAqbCcUIg48kCWa6PJykAhGWzPmpPr0iLuNWtz5wqN' ]; - + print_rr(json_encode($body));//die; $response = call_third_party_api($url, $method, $headers, $body); - + print_rr(json_encode($response));//die; if($response['status'] != true){ return $this->response->setJSON([ 'status' => false, @@ -44,7 +44,7 @@ class ICICILombardController extends AdminController helper('api'); //fetch token - $tokenResponse = $this->generateAuthToken('esbgpabatchcreation'); + $tokenResponse = $this->generateAuthToken(); if (!$tokenResponse || empty($tokenResponse['data']['access_token'])) { return $this->response->setJSON([ 'status' => false, @@ -53,12 +53,13 @@ class ICICILombardController extends AdminController ]); } $token = $tokenResponse['data']['access_token']; - + // dd($token); $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/batchcreation'; $headers = [ 'Authorization: Bearer ' . $token, - 'Content-Type: application/json' + 'Content-Type: application/json', + //'Scope: esbgpabatchcreation' ]; $body = [ @@ -107,9 +108,11 @@ class ICICILombardController extends AdminController ] ] ]; - - $response = call_third_party_api($url, 'POST', $headers, json_encode($body), true); // true = raw body mode - + // Kint::dump($body); + print_rr(json_encode($body)); + // dd(); + $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); } diff --git a/app/Controllers/TestBusinessController.php b/app/Controllers/TestBusinessController.php new file mode 100644 index 00000000..7f317fb2 --- /dev/null +++ b/app/Controllers/TestBusinessController.php @@ -0,0 +1,30 @@ +callWithTrace('b',50,10); + $r = $this->b(50,10); + + return json_encode(['a' => $r]); + // return view('welcome_message'); + } + + public function b($x, $y) + { + // print_rr(debug_backtrace(0)); + return $x + $y; + } +} + + diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index 1cc20a2e..139b63e1 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -152,6 +152,88 @@ class TicketController extends BaseController 53 => ['cancel_remark'], 58 => ['cancel_remark'], ]; + + $this->extraFieldsDisplayForFrontend = [ + 1 => [ 'non_id_reason' => 'Non ID Reason' ], + 10 => [ 'pay_initiate_date' => 'Payment Initiated Date' ], + 3 => [ 'raised_date' => 'Raised Date' ], + 4 => [ 'raised_date' => 'Raised Date' ], + 5 => [ + 'claim_number' => 'Claim Number', + 'registration_date' => 'Registration Date' + ], + 7 => [ 'query_received_date' => 'Query Received Date' ], + 8 => [ + 'denial_reason' => 'Denial Reason', + 'denial_date' => 'Denial Date' + ], + 9 => [ + 'approved_amount' => 'Approved Amount', + 'approved_date' => 'Approved Date', + 'approved_letter' => 'Approved Letter', + 'approved_description' => 'Approved Description' + ], + 11 => [ + 'utr_details' => 'UTR Details', + 'settled_date' => 'Settled Date', + 'settle_letter' => 'Settle Letter' + ], + 40 => [ + 'approved_amount' => 'Approved Amount', + 'approved_date' => 'Approved Date', + 'approved_letter' => 'Approved Letter', + 'approved_description' => 'Approved Description' + ], + 44 => [ + 'utr_details' => 'UTR Details', + 'settled_date' => 'Settled Date', + 'settle_letter' => 'Settle Letter' + ], + 30 => [ + 'approved_amount' => 'Approved Amount', + 'approved_date' => 'Approved Date', + 'approved_letter' => 'Approved Letter', + 'approved_description' => 'Approved Description' + ], + 34 => [ + 'utr_details' => 'UTR Details', + 'settled_date' => 'Settled Date', + 'settle_letter' => 'Settle Letter' + ], + 20 => [ + 'approved_amount' => 'Approved Amount', + 'approved_date' => 'Approved Date', + 'approved_letter' => 'Approved Letter', + 'approved_description' => 'Approved Description' + ], + 24 => [ + 'utr_details' => 'UTR Details', + 'settled_date' => 'Settled Date', + 'settle_letter' => 'Settle Letter' + ], + 14 => [ + 'return_remark' => 'Return Remark', + 'awb_no_courier_name' => 'AWB No Courier Name' + ], + 48 => [ + 'return_remark' => 'Return Remark', + 'awb_no_courier_name' => 'AWB No Courier Name' + ], + 59 => [ + 'return_remark' => 'Return Remark', + 'awb_no_courier_name' => 'AWB No Courier Name' + ], + 54 => [ + 'return_remark' => 'Return Remark', + 'awb_no_courier_name' => 'AWB No Courier Name' + ], + 13 => [ 'cancel_remark' => 'Cancel Remark' ], + 47 => [ 'cancel_remark' => 'Cancel Remark' ], + 53 => [ 'cancel_remark' => 'Cancel Remark' ], + 58 => [ 'cancel_remark' => 'Cancel Remark' ] +]; + + $this->nonIDReason = [ "Newborn Baby" => "Newborn Baby", "Newly Wedded Spouse" => "Newly Wedded Spouse", @@ -1863,6 +1945,7 @@ class TicketController extends BaseController $this->myLogger->logme("error", "Ticket ID : " . $ticket_id); $fields = $this->extraFields; + $displayFields = $this->extraFieldsDisplayForFrontend; $data_to_send = []; // Get ticket data @@ -1878,16 +1961,18 @@ class TicketController extends BaseController ->groupBy("th.old_value, tcs.claim_status") ->get() ->getResultArray(); - + // dd($ticket_previous_status); // Loop through previous status and gather the required data foreach ($ticket_previous_status as $status) { - $this->myLogger->logme("error", "Status : " . json_encode($status)); + // $this->myLogger->logme("error", "Status : " . json_encode($status)); if (isset($fields[$status['old_value']])) { $field = $fields[$status['old_value']]; - + // print_r($field); // Ensure claim_status is a scalar value (string or int) $claim_status = (string)$status['claim_status']; // Cast to string to avoid issues + // echo $claim_status; + // dd($displayFields[$status['old_value']]); // Initialize claim_status if it doesn't exist in the array if (!isset($data_to_send[$claim_status])) { @@ -1897,31 +1982,34 @@ class TicketController extends BaseController // Handle case where $field is an array if (is_array($field)) { foreach ($field as $f) { + // dd($displayFields[$status['old_value']]); // Check if the field exists in the ticket data - $data_to_send[$claim_status][$f] = isset($ticket_data[$f]) ? $ticket_data[$f] : null; - + $data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => isset($ticket_data[$f]) ? $ticket_data[$f] : null]; + // dd($data_to_send); // Check if the field contains a date and format it - if ($this->isDate($data_to_send[$claim_status][$f])) { - $data_to_send[$claim_status][$f] = date('d-m-Y', strtotime($data_to_send[$claim_status][$f])); + if ($this->isDate($data_to_send[$claim_status][$f]['display_value'])) { + $data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => date('d-m-Y', strtotime($data_to_send[$claim_status][$f]['display_value']))]; + // $data_to_send[$claim_status][$f] = date('d-m-Y', strtotime($data_to_send[$claim_status][$f])); } - $this->myLogger->logme("error", "Data for field {$f}: " . json_encode($data_to_send[$claim_status][$f])); + // $this->myLogger->logme("error", "Data for field {$f}: " . json_encode($data_to_send[$claim_status][$f])); } } else { // If field is not an array, handle it as a single field - $data_to_send[$claim_status][$field] = isset($ticket_data[$field]) ? $ticket_data[$field] : null; + // Check if the field exists in the ticket data + $data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => isset($ticket_data[$f]) ? $ticket_data[$f] : null]; // Check if the field contains a date and format it if ($this->isDate($data_to_send[$claim_status][$field])) { - $data_to_send[$claim_status][$field] = date('d-m-Y', strtotime($data_to_send[$claim_status][$field])); + $data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => date('d-m-Y', strtotime($data_to_send[$claim_status][$f]['display_value']))]; } - $this->myLogger->logme("error", "Data for field {$field}: " . json_encode($data_to_send[$claim_status][$field])); + // $this->myLogger->logme("error", "Data for field {$field}: " . json_encode($data_to_send[$claim_status][$field])); } } } - $this->myLogger->logme('error', "Total data: " . json_encode($data_to_send)); + // $this->myLogger->logme('error', "Total data: " . json_encode($data_to_send)); if($requestFrom == 'rest'){ return $data_to_send; diff --git a/app/Controllers/TraceableController.php b/app/Controllers/TraceableController.php new file mode 100644 index 00000000..e1562c93 --- /dev/null +++ b/app/Controllers/TraceableController.php @@ -0,0 +1,127 @@ +logFile = $logFile; + } + + public function wrap($instance) + { + $handler = $this; + $class = new ReflectionClass($instance); + + foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { + if ($method->isConstructor() || $method->isStatic()) continue; + + $methodName = $method->getName(); + $instance->$methodName = function(...$args) use ($handler, $instance, $methodName) { + return $handler->logCall($instance, $methodName, $args); + }; + } + + return $instance; + } + + public function logCall($instance, $method, $args) + { + $isRootCall = (self::$callDepth === 0); + if ($isRootCall) { + self::$currentUuid = $this->generateUuid(); + } + self::$callDepth++; + + $reflection = new ReflectionMethod($instance, $method); + + // Log IN + $this->writeLog([ + 'timestamp' => date('Y-m-d H:i:s'), + 'uuid' => self::$currentUuid, + 'direction' => 'IN', + 'function' => get_class($instance) . '::' . $method, + 'line' => $reflection->getStartLine(), + 'params' => $this->getParameterValues($reflection, $args) + ]); + + try { + $result = $reflection->invokeArgs($instance, $args); + + // Log OUT + $this->writeLog([ + 'timestamp' => date('Y-m-d H:i:s'), + 'uuid' => self::$currentUuid, + 'direction' => 'OUT', + 'function' => get_class($instance) . '::' . $method, + 'line' => $reflection->getEndLine(), + 'result' => $result + ]); + + return $result; + } finally { + self::$callDepth--; + if ($isRootCall) { + self::$currentUuid = null; + } + } + } + + private function getParameterValues($reflection, $args) + { + $params = []; + foreach ($reflection->getParameters() as $i => $param) { + $params[$param->name] = $args[$i] ?? ($param->isDefaultValueAvailable() + ? $param->getDefaultValue() + : null); + } + return $params; + } + + private function writeLog($data) + { + file_put_contents($this->logFile, json_encode($data) . PHP_EOL, FILE_APPEND); + } + + private function generateUuid() + { + return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} + +class TestBusinessController +{ + public function a($a = 10) + { + $r = $this->b(50, $a); + return json_encode(['a' => $r]); + } + + public function b($x, $y) + { + $r = $this->c($x + $y); + return $r; + } + + public function c($x) + { + return $x * 2; + } +} + +// Usage: +$logger = new DeepLogger(); +$controller = new TestBusinessController(); +$loggedController = $logger->wrap($controller); + +// This will now log all calls (a, b, and c) +echo $loggedController->a(10); \ No newline at end of file diff --git a/app/Libraries/CustomTraceLogger.php b/app/Libraries/CustomTraceLogger.php new file mode 100644 index 00000000..7ca66b28 --- /dev/null +++ b/app/Libraries/CustomTraceLogger.php @@ -0,0 +1,42 @@ +logFile = $logDir . 'trace-' . date('Y-m-d') . '.log'; + } + + public function log($direction, $functionName, $lineNo, $params = []) + { + try { + $uuid = get_session_uuid(); + + $logEntry = [ + 'timestamp' => date('c'), + 'uuid' => $uuid, + 'direction' => $direction, // IN or OUT + 'function' => $functionName, + 'line' => $lineNo, + 'params' => $params, + ]; + + file_put_contents( + $this->logFile, + json_encode($logEntry) . PHP_EOL, + FILE_APPEND | LOCK_EX + ); + } catch (Throwable $e) { + // Don’t break anything if logging fails + } + } +} diff --git a/app/Traits/Traceable.php b/app/Traits/Traceable.php new file mode 100644 index 00000000..b2fa930d --- /dev/null +++ b/app/Traits/Traceable.php @@ -0,0 +1,23 @@ +getMethod($method); + $line = $function->getStartLine(); + + $logger->log('IN', get_class($this) . "::$method", $line, $params); + + $result = $function->invokeArgs($this, $params); + + $logger->log('OUT', get_class($this) . "::$method", $line, $result); + + return $result; + } +} diff --git a/app/Views/cd_master_list.php b/app/Views/cd_master_list.php index 92bde594..67ac08a0 100755 --- a/app/Views/cd_master_list.php +++ b/app/Views/cd_master_list.php @@ -394,8 +394,8 @@ document.addEventListener("DOMContentLoaded", function () { }); }); - $('#cd_ac_no').change(function(){ - + $('#cd_ac_no').keyup(function(){ + console.log('key chnage detected'); var cd_ac_no = $(this).val(); console.log(cd_ac_no +'-'+cd_ac_no.length); cd_ac_no = cd_ac_no.trim(); @@ -411,8 +411,11 @@ document.addEventListener("DOMContentLoaded", function () { console.log(res) if(res.status == true){ toastr.warning(res.message, 'warning'); - $('#cd_ac_no').val(''); + // $('#cd_ac_no').val(''); + $('#btnSubmit').prop('disabled',true); + return; } + $('#btnSubmit').prop('disabled',false); }, error: function (xhr, status, error) { console.error(xhr.responseText); From a5d2cd2623c8f3d572001945545d81afd12c9c4c Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 9 Jul 2025 16:53:12 +0530 Subject: [PATCH 34/40] FIX_MPIN_UPDATE : RV --- app/Controllers/EmployeeRestController.php | 10 +++- .../RestAuthenticationController.php | 57 ++++--------------- 2 files changed, 19 insertions(+), 48 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index e8cb43c7..23ea2fcf 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2774,7 +2774,8 @@ class EmployeeRestController extends AdminController //for get the pre enrollment policy count $empMobileNo = $this->request->getGet('mobile_no'); - $prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo); + $clientId = $this->request->getGet('client_id'); + $prePolicyCount = $this->getPreEmployeePolicyCount($empMobileNo, $clientId); $whereArrayForId = []; foreach ( $employeeData as $key => $value) { array_push($whereArrayForId, $value['id']); } @@ -3625,7 +3626,7 @@ class EmployeeRestController extends AdminController ], 200); } - public function getPreEmployeePolicyCount($mobile_no) + public function getPreEmployeePolicyCount($mobile_no, $clientId) { log_message('error', 'getPreEmployeePolicyCount called with mobile: ' . var_export($mobile_no, true)); @@ -3656,7 +3657,12 @@ class EmployeeRestController extends AdminController ->where('cp.open_for_enrollment', 1) ->whereIn('cp.policy_type_id', [1,2,6,7]) ->where('employees.mobile', $mobile_no) + ->orderBy('employees.created_at', 'desc') ->groupBy('employee_polices.client_policy_id'); + + if(!empty($clientId)){ + $builder->where('employees.client_id', $clientId); + } log_message('error', 'Executing policy count query...'); $query = $builder->get(); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 2e234f5c..339f353d 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -290,65 +290,30 @@ class RestAuthenticationController extends AdminController $requestData = $this->request->getJSON(); log_message('debug', 'Request data: ' . json_encode($requestData)); - $mobile_number = $requestData->mobile_number ?? null; - $email_id = $requestData->email_id ?? null; - $new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null; - $old_mpin = $requestData->old_mpin ?? null; - $is_mpin_skipped = $requestData->is_mpin_skipped ?? null; - $is_biometric_enabled = $requestData->is_biometric_enabled ?? null; + $client_id = $requestData->client_id ?? null; + $employee_id = $requestData->employee_id ?? null; + $mpin = $requestData->mpin ?? null; - if (!$new_mpin) { - log_message('warning', 'MPIN is missing.'); + if (!$mpin) { + log_message('error', 'MPIN is missing.'); return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']); } - $query = $this->employeeModel->where('relationship', 'self'); - log_message('info', 'Query initialized with relationship=self'); - - if ($mobile_number) { - $query->where('mobile', $mobile_number); - log_message('info', "Filtering by mobile number: {$mobile_number}"); - } elseif ($email_id) { - $query->where('email_corporate', $email_id); - log_message('info', "Filtering by email ID: {$email_id}"); - } else { - log_message('warning', 'Neither mobile number nor email ID provided.'); - return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']); + if (!$employee_id) { + log_message('error', 'employee_id is missing.'); + return $this->response->setJSON(['status' => false, 'message' => 'employee_id is required.']); } - if (!empty($old_mpin)) { - $query->where('mpin', $old_mpin); - log_message('info', "Verifying old MPIN: {$old_mpin}"); - } - - $employeeData = $query->first(); - log_message('debug', 'Employee lookup result: ' . json_encode($employeeData)); - - if (!$employeeData) { - log_message('warning', 'Employee not found or invalid old MPIN.'); - return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']); - } - - $mpin_data_to_update = ['mpin' => $new_mpin]; - - if ($is_mpin_skipped != null && $is_biometric_enabled != null) { - $mpin_data_to_update['is_mpin_skipped'] = $is_mpin_skipped; - $mpin_data_to_update['is_biometric_enabled'] = $is_biometric_enabled; - log_message('info', 'Updating MPIN, MPIN skip flag, and biometric flag.'); - } else { - log_message('info', 'Updating MPIN only.'); - } - - $updated = $this->employeeModel->update($employeeData['id'], $mpin_data_to_update); + $updated = $this->employeeModel->where('id', $employee_id)->set(['mpin' => $mpin])->update(); if ($updated) { - log_message('info', "MPIN updated successfully for employee ID: {$employeeData['id']}"); + log_message('info', "MPIN updated successfully for employee ID: {$employee_id}"); return $this->response->setJSON([ 'status' => true, 'message' => 'MPIN updated successfully.' ]); } else { - log_message('error', "Failed to update MPIN for employee ID: {$employeeData['id']}"); + log_message('error', "Failed to update MPIN for employee ID: {$employee_id}"); return $this->response->setJSON([ 'status' => false, 'message' => 'Failed to update MPIN.' From 23967167b03f79c6be73c6f7617866c6027299a4 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 9 Jul 2025 17:22:37 +0530 Subject: [PATCH 35/40] FIX_FILEHISTORY --- app/Controllers/EmployeeController.php | 6 +++--- app/Models/FileModel.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 28f3a010..512122c6 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1390,7 +1390,7 @@ class EmployeeController extends AdminController } //STEP:3 - Update files table status - $this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update(); + $this->fileModel->where('id', $file_id)->set(['status' => 'truncated','updated_by' => $loggedInUserID])->update(); $this->myLogger->logme('error', '---- files table updated ----'); //FINAL STEP - Update reverse entry in cash_deposite table @@ -1479,7 +1479,7 @@ class EmployeeController extends AdminController // dd($affectedRows); $affectedRows = $affectedRows * 2; - $this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update(); + $this->fileModel->where('id', $file_id)->set(['status' => 'truncated','updated_by' => $loggedInUserID])->update(); } @@ -1546,7 +1546,7 @@ class EmployeeController extends AdminController // STEP 3: //update files table status to "truncated" - $this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update(); + $this->fileModel->where('id', $file_id)->set(['status' => 'truncated','updated_by' => $loggedInUserID])->update(); $this->myLogger->logme('error', 'files table updated'); diff --git a/app/Models/FileModel.php b/app/Models/FileModel.php index c6f04f63..5b27a7d4 100755 --- a/app/Models/FileModel.php +++ b/app/Models/FileModel.php @@ -19,7 +19,8 @@ class FileModel extends Model "client_id", "policy_id", "client_branch_id", - "uploaded_by" + "uploaded_by", + "updated_by" ]; From 8c4fcfbf50914c1d38fbb58cfa5775d51991f3e7 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 9 Jul 2025 17:38:42 +0530 Subject: [PATCH 36/40] FIX_CLAIMAPI_FOR_HR --- app/Controllers/EmployeeRestController.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 23ea2fcf..1efbc94e 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2595,6 +2595,25 @@ class EmployeeRestController extends AdminController $data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id); $data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id); + + // $data = $response['data']; // Assuming your full array is stored in $response + // $ticketData = $data['ticket_data']; + // $ticketHistory = $data['ticket_history']; + + // Loop through ticket_data + foreach ($data['ticket_data'] as $status => &$fields) { + // Search ticket_history for matching old_status_value + foreach ($data['ticket_history'] as $history) { + if ($history['old_status_value'] === $status) { + // Attach modified_by and created_at + $fields['modified_by'] = $history['modified_by']; + $fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at'])); + // Break after first match (assuming latest entry is enough) + break; + } + } + } + return $this->respond(['status' => (count($data) ? 'success' : 'failed'),'code' => (count($data) ? 200 : 404),'data' => $data ], 200); From d2361cdaf56ceb0be18ae75b38e46de0e1ac199f Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 10 Jul 2025 11:36:13 +0530 Subject: [PATCH 37/40] FIX_COUNT_API_CHANGE : RV --- app/Controllers/EmployeeRestController.php | 145 ++++++++++++++++----- 1 file changed, 112 insertions(+), 33 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 23ea2fcf..8f8e0e8f 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3626,56 +3626,135 @@ class EmployeeRestController extends AdminController ], 200); } - public function getPreEmployeePolicyCount($mobile_no, $clientId) + // public function getPreEmployeePolicyCount($mobile_no, $clientId = null) + // { + // log_message('error', 'getPreEmployeePolicyCount called with params : ' . json_encode(['mobile_no' => $mobile_no, 'client_id' => $clientId], true)); + + // if (empty($mobile_no)) { + // log_message('error', 'Mobile number is empty or null.'); + // return 0; + // } + + // $client_short_name = []; + // if(!empty($clientId)){ + // $client_data = $this->clientModel->where('is_active', 1)->where('id', $clientId)->first(); + // $client_short_name = $client_data['short_name'] ?? null; + // } + + // $post_data = [ + // 'mobile_number' => $mobile_no, + // 'client_data' => $client_short_name + // ]; + + // $response = $this->callThirdPartyAPI($post_data, 'getPreEmployeePolicyCount'); + // print_r( $response); die; + + // return $response['data'] ?? 0 ; + + + // try { + // log_message('error', 'Attempting to connect to preDB...'); + // $db2 = \Config\Database::connect('preDB'); + // log_message('error', 'Connection to preDB successful.'); + // } catch (\Throwable $e) { + // log_message('error', 'DB connection to preDB failed: ' . $e->getMessage()); + // return 0; + // } + + // try { + // log_message('error', 'Building query to count employee policies...'); + // $builder = $db2->table('employees') + // ->join('employee_polices', 'employees.id = employee_polices.employee_id') + // ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') + // ->where('employees.is_active', 1) + // ->whereIn('employees.emp_status', ['draft', 'enrolled']) + // ->where('employee_polices.is_active', 1) + // ->whereIn('employee_polices.status', ['draft', 'enrolled']) + // ->where('cp.enrolment_visibility', 1) + // ->where('cp.open_for_enrollment', 1) + // ->whereIn('cp.policy_type_id', [1,2,6,7]) + // ->where('employees.mobile', $mobile_no) + // ->orderBy('employees.created_at', 'desc') + // ->groupBy('employee_polices.client_policy_id'); + + // if(!empty($clientId)){ + // $builder->where('employees.client_id', $clientId); + // } + + // log_message('error', 'Executing policy count query...'); + // $query = $builder->get(); + // $count = $query->getNumRows(); + // // dd($db2->getLastQuery()); + + // log_message('error', 'Policy count result: ' . $count); + // return $count; + + // } catch (\Throwable $e) { + // log_message('error', 'Query failed in getPreEmployeePolicyCount: ' . $e->getMessage()); + // return 0; + // } + // } + + public function getPreEmployeePolicyCount($mobile_no, $clientId = null) { - log_message('error', 'getPreEmployeePolicyCount called with mobile: ' . var_export($mobile_no, true)); + log_message('error', 'STEP 1: getPreEmployeePolicyCount called with params: ' . json_encode(['mobile_no' => $mobile_no, 'client_id' => $clientId])); if (empty($mobile_no)) { - log_message('error', 'Mobile number is empty or null.'); + log_message('error', 'STEP 2: Mobile number is empty or null. Returning 0.'); return 0; } - try { - log_message('error', 'Attempting to connect to preDB...'); - $db2 = \Config\Database::connect('preDB'); - log_message('error', 'Connection to preDB successful.'); - } catch (\Throwable $e) { - log_message('error', 'DB connection to preDB failed: ' . $e->getMessage()); - return 0; + $client_short_name = null; + + if (!empty($clientId)) { + log_message('error', 'STEP 3: Fetching client short name for client ID: ' . $clientId); + $client_data = $this->clientModel->where('is_active', 1)->where('id', $clientId)->first(); + + if ($client_data) { + $client_short_name = $client_data['short_name'] ?? null; + log_message('error', 'STEP 4: Found client short name: ' . $client_short_name); + } else { + log_message('error', 'STEP 4: No client found for ID: ' . $clientId); + } + } else { + log_message('error', 'STEP 3: No clientId provided. Skipping client lookup.'); } + $post_data = [ + 'mobile_number' => $mobile_no, + 'client_short_name' => $client_short_name + ]; + + log_message('error', 'STEP 5: Calling third-party API with payload: ' . json_encode($post_data)); + try { - log_message('error', 'Building query to count employee policies...'); - $builder = $db2->table('employees') - ->join('employee_polices', 'employees.id = employee_polices.employee_id') - ->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') - ->where('employees.is_active', 1) - ->whereIn('employees.emp_status', ['draft', 'enrolled']) - ->where('employee_polices.is_active', 1) - ->whereIn('employee_polices.status', ['draft', 'enrolled']) - ->where('cp.enrolment_visibility', 1) - ->where('cp.open_for_enrollment', 1) - ->whereIn('cp.policy_type_id', [1,2,6,7]) - ->where('employees.mobile', $mobile_no) - ->orderBy('employees.created_at', 'desc') - ->groupBy('employee_polices.client_policy_id'); - - if(!empty($clientId)){ - $builder->where('employees.client_id', $clientId); + $response = $this->callThirdPartyAPI($post_data, 'getPreEmployeePolicyCount'); + log_message('error', 'STEP 6: API raw response: ' . $response); + + $response = json_decode($response, true); + + if (json_last_error() !== JSON_ERROR_NONE) { + log_message('error', 'STEP 7: JSON decoding failed: ' . json_last_error_msg()); + return 0; } - log_message('error', 'Executing policy count query...'); - $query = $builder->get(); - $count = $query->getNumRows(); + $count = $response['data'] ?? 0; + log_message('error', 'STEP 8: Final count extracted: ' . $count); - log_message('error', 'Policy count result: ' . $count); return $count; - } catch (\Throwable $e) { - log_message('error', 'Query failed in getPreEmployeePolicyCount: ' . $e->getMessage()); + log_message('error', 'STEP 6: API call failed: ' . $e->getMessage()); return 0; } } + private function callThirdPartyAPI($postData , $endPoint) + { + $client = \Config\Services::curlrequest(); + $url = env('PRE_ENROLLMENT_BASEURL').$endPoint; + $response = $client->post( $url, ['json' => $postData, 'http_errors' => false ] ); + // return json_decode($response->getBody(), true); + return $response->getBody(); + } } \ No newline at end of file From 42dfdc5e762728de272f9833afe13fb0beaad686 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 10 Jul 2025 14:46:14 +0530 Subject: [PATCH 38/40] RV --- .../RestAuthenticationController.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 339f353d..abdffbdf 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -210,10 +210,20 @@ class RestAuthenticationController extends AdminController $client_id = $this->request->getJSON()->client_id ?? null; $employee_id = $this->request->getJSON()->employee_id ?? null; + // $builder = $this->employeeModel + // ->where('email_corporate', $email) + // ->where('relationship', 'Self') + // ->where('is_active', 1); + $builder = $this->employeeModel - ->where('email_corporate', $email) - ->where('relationship', 'Self') - ->where('is_active', 1); + ->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($client_id)) { $builder->where('client_id', $client_id); @@ -225,7 +235,6 @@ class RestAuthenticationController extends AdminController $builder->set(['otp' => $otp])->update(); - return true; } @@ -585,7 +594,7 @@ class RestAuthenticationController extends AdminController if(isset($HRAccessData['allowed_modules'])){ $hrData['0']['allowed_modules'] = json_decode($HRAccessData['allowed_modules'],true)['post']; }else{ $hrData['0']['allowed_modules'] = []; } - + $hrData['0']['token_type'] = 'post'; $result = JWTToken::encode($hrData['0']); From bb78dada40d27b190b90afc6612990bc4b295595 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 10 Jul 2025 18:15:47 +0530 Subject: [PATCH 39/40] FEAT_HR_ACCESS_CONTROL_AND_LEVEL_CONTECT_SAVE_ISSUE_AND_OTHERS : RV --- app/Controllers/ClientController.php | 410 +++++++++-- .../RestAuthenticationController.php | 4 +- app/Models/HRAccessControlModel.php | 1 + app/Views/client_basic_info.php | 4 +- app/Views/client_branch.php | 90 ++- app/Views/client_onboarding.php | 637 +++++++++++++++++- app/Views/hr_access_controll.php | 178 +++++ 7 files changed, 1230 insertions(+), 94 deletions(-) create mode 100644 app/Views/hr_access_controll.php diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 3c2af991..4b09e9ae 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -41,6 +41,7 @@ use App\Models\PolicyTransactionStatusModel; use App\Models\VehicleModel; use App\Models\LeadsModel; use App\Models\ClientApiModel; +use App\Models\HRAccessControlModel; use App\Controllers\EmpDataServiceController; use App\Controllers\GoogleDriveController; @@ -88,6 +89,7 @@ class ClientController extends AdminController protected $leadsModel; protected $clientApi; protected $PTCOShareDetailsModel; + protected $HRAccessControlModel; public function __construct() @@ -125,6 +127,7 @@ class ClientController extends AdminController $this->leadsModel = new LeadsModel(); $this->clientApi = new ClientApiModel(); $this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); + $this->HRAccessControlModel = new HRAccessControlModel(); } //-------------------------------------------------------------------------------------------------------- @@ -674,7 +677,7 @@ class ClientController extends AdminController } $data['insurerName'] = $this->insurerModel->getInsurerName($insurerId, $clientId); - $data['depositdata'] = $this->clientPolicyModel->getdepositData($clientId, $insurerId, $cd_ac_pk); + $data['depositdata'] = $this->clientPolicyModel->getdepositData($clientId, $insurerId, $cd_ac_pk, $subTypeOptions); $data['clientData'] = $this->clientPolicyModel->getClientById($clientId); $data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId, $cd_ac_pk); $data['cd_ac_pk'] = $cd_ac_pk; @@ -1031,19 +1034,9 @@ class ClientController extends AdminController $insert = $this->clientBranchModel->insert($data); if ($insert) { - for ($i = 0; $i < count($this->request->getPost('name')); $i++) { - // Prepare data to insert - $data = [ - 'contact_type' => 'client', - 'ref_id' => $insert, - 'created_by' => get_session_userid(), - 'name' => $this->request->getPost('name')[$i], - 'email' => $this->request->getPost('email')[$i], - 'mobile' => $this->request->getPost('mobile')[$i], - 'designation' => $this->request->getPost('designation')[$i] - ]; - $contacts = $this->levelContactModel->insert($data); - } + $level_contact_data = $this->request->getPost('level_contect_data'); + $level_contact_data = !empty($level_contact_data) ? json_decode($level_contact_data, true) : null; + $this->saveLevelContacts($level_contact_data, $insert); } if ($insert) { @@ -1135,19 +1128,9 @@ class ClientController extends AdminController if ($insert) { - $this->levelContactModel->where('ref_id', $id)->where('contact_type', 'client')->delete(); - for ($i = 0; $i < count($this->request->getPost('name')); $i++) { - $data = [ - 'contact_type' => 'client', - 'ref_id' => $id, - 'updated_by' => get_session_userid(), - 'name' => $this->request->getPost('name')[$i], - 'email' => $this->request->getPost('email')[$i], - 'mobile' => $this->request->getPost('mobile')[$i], - 'designation' => $this->request->getPost('designation')[$i] - ]; - $contacts = $this->levelContactModel->insert($data); - } + $level_contact_data = $this->request->getPost('level_contect_data'); + $level_contact_data = !empty($level_contact_data) ? json_decode($level_contact_data, true) : null; + $this->saveLevelContacts($level_contact_data, $id); } if ($insert) { @@ -1161,7 +1144,8 @@ class ClientController extends AdminController 'list_of_branch_units' => $list_of_branch_units, 'total_count' => $total_count, 'uncommonValues' => $uncommonValues, - 'message' => 'Client branch updated successfully' + 'message' => 'Client branch updated successfully', + 'response_data' => $this->request->getPost() ], 200); } else { @@ -1169,6 +1153,24 @@ class ClientController extends AdminController } } + public function saveLevelContacts($level_contact_data, $branch_id) + { + if (!empty($level_contact_data) && is_array($level_contact_data)) { + foreach ($level_contact_data as $value) { + if (!empty($value['id'])) { + $id = $value['id']; + unset($value['id']); + $this->levelContactModel->update($id, $value); + } else { + unset($value['id']); + $value['contact_type'] = "client"; + $value['ref_id'] = $branch_id ?? null; + $this->levelContactModel->insert($value); + } + } + } + } + public function createClientPolicy() @@ -4869,7 +4871,7 @@ class ClientController extends AdminController // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $employeeRestController = new EmployeeServiceController(); - // $employeeRestController->excelFileDataValidation(['file_id' => 823]); + // $employeeRestController->excelFileDataValidation(['file_id' => 1629]); die; // $employeeRestController->employeesOnboardPreprocess(['file_id' => 726]); // $employeeRestController->employeesOnboardProcess(['file_id' => 835]); // $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]); @@ -4888,18 +4890,20 @@ class ClientController extends AdminController // ----------EMP DATA SERVICE CONTROLLER-------------------------------------------------------------------------------- + $batch_data = [ + 'client_id' => 97, + 'client_policy_id' => 6174, + 'client_branch_id' => 73, + 'insurer_or_tpa' => "insurer", + 'event_type' => "deletion", + 'actions' => "export", + 'file_name' => "deletion_enhancement_test_file.xlsx", + ]; + // $batch_data = [ // 'client_id' => 29, - // 'client_policy_id' => 17, - // 'client_branch_id' => 15, - // 'insurer_or_tpa' => "insurer", - // 'event_type' => "deletion", - // ]; - - // $batch_data = [ - // 'client_id' => 89, - // 'client_policy_id' => 328, - // 'client_branch_id' => 88, + // 'client_policy_id' => 77, + // 'client_branch_id' => 45, // 'insurer_or_tpa' => "insurer", // // 'insurer_or_tpa' => "tpa", // 'event_type' => "si_enhancement", @@ -4920,11 +4924,12 @@ class ClientController extends AdminController // $EmpDataServiceController->sendMailForDownloadingECard($ids); $EmpDataServiceController = new EmpDataServiceController(); + // $return = $EmpDataServiceController->generateExcelForDeletion($batch_data); dd($return); die; // $EmpDataServiceController->generateExcelForSIEnhancement($batch_data); die; // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 1932]); die; // $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live // $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live - // $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 1205]); //for live + // $result = $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 2496]); //for live // $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live // $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data); @@ -5105,12 +5110,19 @@ class ClientController extends AdminController - // $param = "533454"; + // $param = 9715454901; // $type = 'emp_code'; // $client_policy_id = 64; - // $client_id = 51; + // $client_id = 3927; // $result = $this->getTheEmpDataForClaimSearchByMobile($param, $type, $client_policy_id, $client_id); + // $result = $this->employeePolicyModel->getEmployeePolicy(); + // $result = $this->getHrAccessData($client_id); + // $html = view('hr_access_controll', $result); + // dd($html); + + // $employeeRestController = new EmployeeRestController(); + // $result = $employeeRestController->getPreEmployeePolicyCount($param, $client_id); // dd($result); } @@ -5207,7 +5219,8 @@ class ClientController extends AdminController ->where('employees.relationship', "Self") ->where('employee_polices.is_active', 1) ->where('client_policy.id', $param) - ->findAll(); + ->get() + ->getResultArray(); $dataForClientAndInsurer = $this->clientPolicyModel ->select(" @@ -5293,9 +5306,9 @@ class ClientController extends AdminController $query->where('employees.client_id', $client_id); } - // if (!empty($client_policy_id)) { - // $query->where('employee_polices.client_policy_id', $client_policy_id); - // } + if (!empty($client_policy_id)) { + $query->where('employee_polices.client_policy_id', $client_policy_id); + } $query->groupBy('employees.id') ->orderBy('employees.id', 'DESC'); @@ -5316,7 +5329,7 @@ class ClientController extends AdminController if(!empty($data) && count($data) > 0){ - $memberData = $this->employeeModel->getEmployeeByEmployeeCode($data['emp_code'], null, $client_id); + $memberData = $this->employeeModel->getEmployeeByEmployeeCode($data['emp_code'], $client_policy_id, $client_id); $acms_datas = $this->employeeModel->getAcmUsingClientID($data['client_id']); // if(!empty($acms_datas)){ // $acms = $acms_datas; @@ -6063,9 +6076,13 @@ class ClientController extends AdminController // --------------------------------------------------------------------------------------------------- - public function constructHrAccessData() + public function viewHrAccessData() { - $html = view('hr_access_controll'); + $client_id = $this->request->getGet('client_id'); + $data = $this->getHrAccessData($client_id); + // $data = []; + + $html = view('hr_access_controll', $data); return $this->respond([ 'status' => true, 'code' => 200, @@ -6073,6 +6090,301 @@ class ClientController extends AdminController ], 200); } + public function getHrAccessData($client_id) + { + $hrAccessData = []; + + $post_client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first(); + + $hrAccessData['post_hr_data'] = $this->clientBranchModel + ->select('lc.id as post_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail') + ->join('level_contacts lc', 'client_branch.id = lc.ref_id') + ->where('client_branch.is_active', 1) + ->where('lc.is_active', 1) + ->where('lc.contact_type', 'client') + ->where('client_branch.client_id', $client_id) + ->findAll(); + + $hrAccessData['post_policy_data'] = $this->clientPolicyModel + ->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status') + ->join('policy_type', 'client_policy.policy_type_id = policy_type.id') + ->where('client_policy.is_active', 1) + ->where('client_policy.client_id', $client_id) + // ->orderBy('client_policy_id', 'desc') + ->orderBy('client_policy.policy_status', 'desc') + ->findAll(); + + $hrAccessData['post_cd_data'] = $this->CDMasterModel + ->select('cd_master.id as cd_master_pk, cd_master.cd_ac_no as cd_account_no, insurers.name as insurer_name, insurers.short_name as insurer_short_name') + ->join('insurers', 'cd_master.insurer_id = insurers.id') + ->where('cd_master.is_active', 1) + ->where('cd_master.client_id', $client_id) + ->findAll(); + + $hrAccessData['hr_access_table_data'] = $this->HRAccessControlModel + ->where('is_active', 1) + ->where('post_client_id', $client_id) + ->findAll(); + + try { + log_message('error', 'Attempting to connect to preDB...'); + $db2 = \Config\Database::connect('preDB'); + log_message('error', 'Connection to preDB successful.'); + } catch (\Throwable $e) { + log_message('error', 'DB connection to preDB failed: ' . $e->getMessage()); + + $hrAccessData['pre_hr_data'] = []; + $hrAccessData['pre_policy_data'] = []; + $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id); + return $combinedHrAccessData; + } + + $pre_client_data = $db2->table('clients')->where('is_active', 1)->where('short_name', $post_client_data['short_name'])->get()->getRowArray(); + + $hrAccessData['pre_hr_data'] = $db2->table('client_branch') + ->select('lc.id as pre_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail') + ->join('level_contacts lc', 'client_branch.id = lc.ref_id') + ->where('client_branch.is_active', 1) + ->where('lc.is_active', 1) + ->where('lc.contact_type', 'client') + ->where('client_branch.client_id', $pre_client_data['id']) + ->get() + ->getResultArray(); + + $hrAccessData['pre_policy_data'] = $db2->table('client_policy') + ->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status') + ->join('policy_type', 'client_policy.policy_type_id = policy_type.id') + ->where('client_policy.is_active', 1) + ->where('client_policy.client_id', $pre_client_data['id']) + // ->orderBy('client_policy_id', 'desc') + ->orderBy('client_policy.policy_status', 'desc') + ->get() + ->getResultArray(); + + // dd($hrAccessData); + + $combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id); + return $combinedHrAccessData; + } + + public function constructHrAccessData($data, $client_id) + { + // dd($data); + $preHrs = $data['pre_hr_data']; + $postHrs = $data['post_hr_data']; + $hrAccessTableData = $data['hr_access_table_data']; + $merged = []; + + // Merge based on mobile and email + foreach ($postHrs as $post) { + $found = false; + foreach ($preHrs as $index => $pre) { + if ($post['hr_mobile'] === $pre['hr_mobile'] && $post['hr_mail'] === $pre['hr_mail']) { + $merged[] = [ + 'pre_hr_id' => $pre['pre_hr_id'], + 'post_hr_id' => $post['post_hr_id'], + 'hr_name' => $post['hr_name'], + 'hr_mobile' => $post['hr_mobile'], + 'hr_mail' => $post['hr_mail'] + ]; + unset($preHrs[$index]); // remove matched pre_hr + $found = true; + break; + } + } + + if (!$found) { + $merged[] = [ + 'pre_hr_id' => null, + 'post_hr_id' => $post['post_hr_id'], + 'hr_name' => $post['hr_name'], + 'hr_mobile' => $post['hr_mobile'], + 'hr_mail' => $post['hr_mail'] + ]; + } + } + + // Remaining preHrs (not matched) + foreach ($preHrs as $pre) { + $merged[] = [ + 'pre_hr_id' => $pre['pre_hr_id'], + 'post_hr_id' => null, + 'hr_name' => $pre['hr_name'], + 'hr_mobile' => $pre['hr_mobile'], + 'hr_mail' => $pre['hr_mail'] + ]; + } + + // dd($merged); + + $result = []; + + if (empty($hrAccessTableData)) { + + // No access data — fill result with hr data and other fields as null + foreach ($merged as $hr) { + $result[] = [ + 'hr_access_table_pk' => null, + 'post_client_id' => $client_id ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => [], + 'allowed_post_modules' => [], + 'allowed_pre_policies' => [], + 'allowed_active_policies' => [], + 'allowed_cd' => [], + 'hr_name' => $hr['hr_name'] ?? null, + 'hr_mobile' => $hr['hr_mobile'] ?? null, + 'hr_mail' => $hr['hr_mail'] ?? null, + ]; + } + + } else { + foreach ($hrAccessTableData as $access) { + foreach ($merged as $hr) { + if ($hr['post_hr_id'] == $access['post_hr_id']) { + + $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; + if ($allowed_modules == null) { + $allowed_pre_modules = null; + $allowed_post_modules = null; + } else { + $allowed_pre_modules = $allowed_modules['pre'] ?? []; + $allowed_post_modules = $allowed_modules['post'] ?? []; + } + + $result[] = [ + 'hr_access_table_pk' => $access['id'] ?? null, + 'post_client_id' => $access['post_client_id'] ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => $allowed_pre_modules, + 'allowed_post_modules' => $allowed_post_modules, + 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + 'allowed_active_policies' => json_decode($access['allowed_active_policies']) ?? [], + 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + 'hr_name' => $hr['hr_name'], + 'hr_mobile' => $hr['hr_mobile'], + 'hr_mail' => $hr['hr_mail'] + ]; + break; + } + } + } + } + + $resultData['hr_access_data'] = $result; + $resultData['pre_policy_data'] = $data['pre_policy_data']; + $resultData['post_policy_data'] = $data['post_policy_data']; + $resultData['post_cd_data'] = $data['post_cd_data']; + + // dd($resultData); + + return $resultData; + } + + public function saveHrAccessData() + { + try { + // Step 1: Fetch and decode the JSON data + $client_id = $this->request->getPost('client_id'); + $jsonData = $this->request->getPost('json'); + $data = json_decode($jsonData, true); + + if (!$data || !is_array($data)) { + log_message('error', 'Invalid or empty JSON in saveHrAccessData: ' . $jsonData); + return $this->respond([ + 'status' => false, + 'code' => 400, + 'message' => 'Invalid JSON data provided.', + ], 400); + } + + $success = []; + $errors = []; + $skippedCount = 0; + + // Step 2: Loop and insert/update + foreach ($data as $index => $value) { + try { + // Decode allowed_modules and validate + $allowed_modules = json_decode($value['allowed_modules'], true); + if (empty($allowed_modules)) { + $skippedCount++; + continue; // Skip this record + } + + // Format allowed_modules: { pre: [1], post: [2,3,4] } + $pre = in_array(1, $allowed_modules) ? [1] : []; + $post = array_values(array_filter($allowed_modules, fn($v) => $v !== 1)); + $value['allowed_modules'] = json_encode(['pre' => $pre, 'post' => $post]); + + // INSERT or UPDATE + if (empty($value['pk']) || (int)$value['pk'] === 0) { + unset($value['pk']); // Prevent insert error + $insertedId = $this->HRAccessControlModel->insert($value); + if ($insertedId === false) { + throw new \Exception('Insert failed: ' . json_encode($this->HRAccessControlModel->errors())); + } + $success[] = "Inserted row at index {$index} with ID {$insertedId}."; + } else { + $update = $this->HRAccessControlModel->update($value['pk'], $value); + if ($update === false) { + throw new \Exception('Update failed for ID ' . $value['pk'] . ': ' . json_encode($this->HRAccessControlModel->errors())); + } + $success[] = "Updated row with ID {$value['pk']}."; + } + } catch (\Exception $e) { + log_message('error', 'HRAccess Save Error at index ' . $index . ': ' . $e->getMessage()); + $errors[] = "Error at index {$index}: " . $e->getMessage(); + } + } + + // Step 3: If all rows were skipped (no allowed_modules) + if (count($data) === $skippedCount) { + return $this->respond([ + 'status' => false, + 'code' => 422, + 'message' => 'Please select at least one module for any user.', + ], 422); + } + + // Step 4: Final response + if (empty($errors)) { + + $data = $this->getHrAccessData($client_id); + $html = view('hr_access_controll', $data); + + return $this->respond([ + 'status' => true, + 'code' => 200, + 'message' => 'All records processed successfully.', + 'details' => $success, + 'data' => $html, + ], 200); + + } else { + return $this->respond([ + 'status' => false, + 'code' => 207, + 'message' => 'Some records failed to save.', + 'success' => $success, + 'errors' => $errors + ], 207); + } + } catch (\Exception $e) { + log_message('critical', 'Fatal error in saveHrAccessData: ' . $e->getMessage()); + return $this->respond([ + 'status' => false, + 'code' => 500, + 'message' => 'Unexpected server error.', + 'error' => $e->getMessage() + ], 500); + } + } + + + } diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index abdffbdf..4aa0d89d 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -541,7 +541,7 @@ class RestAuthenticationController extends AdminController try { // mobile number $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; + $mobile_number = isset($this->request->getJSON()->mobile_no) ? $this->request->getJSON()->mobile_no : null; // email id $otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null; $email = isset($this->request->getJSON()->email) ? $this->request->getJSON()->email : null; @@ -571,7 +571,7 @@ class RestAuthenticationController extends AdminController } - if(isset($this->request->getJSON()->mobile_number)){ + if(isset($this->request->getJSON()->mobile_no)){ $hrData = $this->hrModel ->select('level_contacts.* , client_branch.client_id as client_id') ->join('client_branch', 'level_contacts.ref_id = client_branch.id', 'left') diff --git a/app/Models/HRAccessControlModel.php b/app/Models/HRAccessControlModel.php index 81f16f0e..a9a4e2c7 100644 --- a/app/Models/HRAccessControlModel.php +++ b/app/Models/HRAccessControlModel.php @@ -12,6 +12,7 @@ class HRAccessControlModel extends Model 'id', 'pre_hr_id', 'post_hr_id', + 'post_client_id', 'allowed_modules', 'allowed_pre_policies', 'allowed_active_policies', diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php index 220164b8..32420ed2 100755 --- a/app/Views/client_basic_info.php +++ b/app/Views/client_basic_info.php @@ -98,7 +98,7 @@ input:checked + .slider:before { + placeholder="Enter Short Name" value="" name="short_name" onkeyup="validateInput(this, 'clients', 'short_name', 'clientBtnSubmit')" required> @@ -137,7 +137,7 @@ input:checked + .slider:before {
+ id="clientBtnSubmit">Submit
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php index 40e04f54..708a66df 100755 --- a/app/Views/client_branch.php +++ b/app/Views/client_branch.php @@ -163,6 +163,9 @@
+ + +
+ name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" onkeyup="validateInput(this, 'level_contacts', 'email', 'branchBtnSubmit')" required>
+ id="branchBtnSubmit">Submit
@@ -347,6 +350,9 @@ $("#branch_form").submit(function(event) { var selectedValues = $("#selected").val(); console.log(selectedValues, selectedValues); + let level_contect_data = getContactsData(); + console.log('level_contect_data', level_contect_data); + event.preventDefault(); branch_PrimaryKey = $('#client_id_branch').val(); @@ -370,11 +376,14 @@ $("#branch_form").submit(function(event) { var formData = new FormData($('#branch_form')[0]); const jsonString = JSON.stringify(selectedValues); + const level_contect_data_json_string = JSON.stringify(level_contect_data); console.log('jsonString', jsonString); + console.log('level_contect_data_json_string', level_contect_data_json_string); // Append the JSON string to the FormData object formData.append('units', jsonString); + formData.append('level_contect_data', level_contect_data_json_string); $.ajax({ data: formData, @@ -495,6 +504,8 @@ $('body').on('click', '.btnBranchEdit', function() { dataType: 'json', success: function(res) { + console.log('branch response', res); + setTimeout(function() { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); @@ -525,10 +536,25 @@ $('body').on('click', '.btnBranchEdit', function() { appendOption(res.data.units) - $('#name').val(res.contact[0].name); - $('#email').val(res.contact[0].email); - $('#mobile').val(res.contact[0].mobile); - $('#designation').val(res.contact[0].designation); + // $('#branch_table_pk').val(res.contact[0].id); + // $('#name').val(res.contact[0].name); + // $('#email').val(res.contact[0].email); + // $('#mobile').val(res.contact[0].mobile); + // $('#designation').val(res.contact[0].designation); + + if (res.contact && res.contact.length > 0 && res.contact[0]) { + $('#branch_table_pk').val(res.contact[0].id || ''); + $('#name').val(res.contact[0].name || ''); + $('#email').val(res.contact[0].email || ''); + $('#mobile').val(res.contact[0].mobile || ''); + $('#designation').val(res.contact[0].designation || ''); + } else { + $('#branch_table_pk').val(''); + $('#name').val(''); + $('#email').val(''); + $('#mobile').val(''); + $('#designation').val(''); + } res.contact.shift(); // console.log(res.contact.length) @@ -579,6 +605,7 @@ function appendContactHtml(contact = false, reset = false) {
+
@@ -591,11 +618,11 @@ function appendContactHtml(contact = false, reset = false) {
- +
- +
@@ -767,6 +794,51 @@ function checkMobileNumber(input) { }); } + +function validateInput(input, table, field, submitButId){ + + let value = $(input).val(); + let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim(); + + let message = "Value is duplicate!"; + if(label){ + message = label + " already exists!"; + } + + checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) { + if (isDuplicate) { + toastr.warning(message, 'WARNING'); + // $(input).val('') + $('#' + submitButId).prop('disabled', true); + } else{ + $('#' + submitButId).prop('disabled', false); + } + }); + +} + +function getContactsData() { + const contacts = []; + + const ids = $('input[name="branch_table_pk[]"]'); + const names = $('input[name="name[]"]'); + const mobiles = $('input[name="mobile[]"]'); + const emails = $('input[name="email[]"]'); + const designations = $('input[name="designation[]"]'); + + for (let i = 0; i < ids.length; i++) { + contacts.push({ + id: $(ids[i]).val() || null, + name: $(names[i]).val(), + mobile: $(mobiles[i]).val(), + email: $(emails[i]).val(), + designation: $(designations[i]).val() + }); + } + + return contacts; +} + - - - - - + + diff --git a/app/Views/hr_access_controll.php b/app/Views/hr_access_controll.php new file mode 100644 index 00000000..3052daca --- /dev/null +++ b/app/Views/hr_access_controll.php @@ -0,0 +1,178 @@ +
+
+
+ + +
+ + $value) { + $key = $key + 1 ?> + + +
+ + + + + + +
+ +
+ +
+
+
+
+
+
+
+
+ > + Pre enrollment +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + $policies) { + $statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active'; + $statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive'; + ?> +
+ > + +
+ +
+ +
+
+ +
+
+
+ > + Active policies +
+
+ + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + $policies) { + $statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active'; + $statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive'; + ?> +
+ > + +
+ + + +
+
+
+ +
+
+
+ > + CD statement +
+ +
+ + +
+ + +
+ + $cd) { ?> +
+ > + +
+ +
+
+
+ +
+
+
+ > + Claims +
+
+
+
+
+
+
+ + + + +
+ +
+
+ + +
There is no HR data
+ +
+
+
\ No newline at end of file From 927995b847e7431e6dcfdb0930839333c986c604 Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 11 Jul 2025 16:14:40 +0530 Subject: [PATCH 40/40] FIX_HRACCESS_CTRL_ISSUE --- app/Controllers/ClientController.php | 83 +++++++++++++++++++--------- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4b09e9ae..a1eb3002 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -6240,45 +6240,74 @@ class ClientController extends AdminController } } else { - foreach ($hrAccessTableData as $access) { - foreach ($merged as $hr) { - if ($hr['post_hr_id'] == $access['post_hr_id']) { - - $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; - if ($allowed_modules == null) { - $allowed_pre_modules = null; - $allowed_post_modules = null; - } else { + // First create a map of HR data by post_hr_id for quick lookup + $hrMap = []; + foreach ($merged as $hr) { + $hrMap[$hr['post_hr_id']] = $hr; + } + + // Process access data first + foreach ($hrAccessTableData as $access) { + $post_hr_id = $access['post_hr_id']; + + // Check if this HR exists in our merged data + if (isset($hrMap[$post_hr_id])) { + $hr = $hrMap[$post_hr_id]; + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + + // Parse allowed modules + $allowed_modules = json_decode($access['allowed_modules'], true) ?? null; $allowed_pre_modules = $allowed_modules['pre'] ?? []; $allowed_post_modules = $allowed_modules['post'] ?? []; + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => $access['id'] ?? null, + 'post_client_id' => $access['post_client_id'] ?? null, + 'pre_hr_id' => $hr['pre_hr_id'] ?? null, + 'post_hr_id' => $hr['post_hr_id'] ?? null, + 'allowed_pre_modules' => $allowed_pre_modules, + 'allowed_post_modules' => $allowed_post_modules, + 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], + 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [], + 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], + 'hr_name' => $hr['hr_name'], + 'hr_mobile' => $hr['hr_mobile'], + 'hr_mail' => $hr['hr_mail'] + ]; + + // Remove from map so we know it's been processed + unset($hrMap[$post_hr_id]); } - - $result[] = [ - 'hr_access_table_pk' => $access['id'] ?? null, - 'post_client_id' => $access['post_client_id'] ?? null, + } + + // Now process any remaining HRs that didn't have access records + foreach ($hrMap as $hr) { + $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail']; + + $result[$temp_arr_key] = [ + 'hr_access_table_pk' => null, + 'post_client_id' => $client_id ?? null, 'pre_hr_id' => $hr['pre_hr_id'] ?? null, 'post_hr_id' => $hr['post_hr_id'] ?? null, - 'allowed_pre_modules' => $allowed_pre_modules, - 'allowed_post_modules' => $allowed_post_modules, - 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [], - 'allowed_active_policies' => json_decode($access['allowed_active_policies']) ?? [], - 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [], - 'hr_name' => $hr['hr_name'], - 'hr_mobile' => $hr['hr_mobile'], - 'hr_mail' => $hr['hr_mail'] + 'allowed_pre_modules' => [], + 'allowed_post_modules' => [], + 'allowed_pre_policies' => [], + 'allowed_active_policies' => [], + 'allowed_cd' => [], + 'hr_name' => $hr['hr_name'] ?? null, + 'hr_mobile' => $hr['hr_mobile'] ?? null, + 'hr_mail' => $hr['hr_mail'] ?? null, ]; - break; } - } - } } + - $resultData['hr_access_data'] = $result; + $resultData['hr_access_data'] = array_values($result); $resultData['pre_policy_data'] = $data['pre_policy_data']; $resultData['post_policy_data'] = $data['post_policy_data']; $resultData['post_cd_data'] = $data['post_cd_data']; - - // dd($resultData); + // echo '**********************************************'; + // print_rr($resultData);die(); return $resultData; }