From 4394d293a1f5ceeea2e0957c1c44c994236429d0 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 15 Sep 2025 11:47:22 +0530 Subject: [PATCH 01/38] FIX_LIVE_ISSUE_CORRECTION_: RV --- app/Controllers/ClientController.php | 3 +- .../EmployeeMultiEventServiceController.php | 29 ++++++++++++++----- app/Controllers/EmployeeServiceController.php | 25 +++++++++++----- app/Models/EmployeePolicyModel.php | 21 ++------------ 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 2e9e11c9..8ecf4184 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5266,7 +5266,7 @@ class ClientController extends AdminController // $res = $empServiceController->employeesEnrollmentInsert(['file_id' => 836]); // $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']); // $res = $empServiceController->employeeDisembark(['file_id' => '1681']); - // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '1681']); + // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']); // dd( $res); $EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController(); @@ -5324,6 +5324,7 @@ class ClientController extends AdminController $EmpDataServiceController = new EmpDataServiceController(); // $res = $EmpDataServiceController->generateExcelForDeletion($batch_data); dd($return); die; // $res = $EmpDataServiceController->generateExcelForSIEnhancement($batch_data); die; + // $res = $EmpDataServiceController->generateExcelForCorrection($batch_data); // $res = $EmpDataServiceController->importInceptionFileValidation(['file_id' => 1932]); die; // $res = $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live // $res = $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live diff --git a/app/Controllers/EmployeeMultiEventServiceController.php b/app/Controllers/EmployeeMultiEventServiceController.php index a7519fea..e3027d01 100644 --- a/app/Controllers/EmployeeMultiEventServiceController.php +++ b/app/Controllers/EmployeeMultiEventServiceController.php @@ -1956,14 +1956,29 @@ class EmployeeMultiEventServiceController extends BaseController $field_value = ($field_name == 'dob' ? change_date_format($row[4], 'd-M-Y', 'Y-m-d') : $row[4]); + // $employee = $this->employeeModel + // ->where('emp_code', $row[1]) + // ->where('name', $row[2]) + // ->where('client_id', $file['client_id']) + // ->where('client_branch_id', $file['client_branch_id']) + // ->where('emp_status', 'active') + // ->where('is_active', 1) + // ->first(); + $employee = $this->employeeModel - ->where('emp_code', $row[1]) - ->where('name', $row[2]) - ->where('client_id', $file['client_id']) - ->where('client_branch_id', $file['client_branch_id']) - ->where('emp_status', 'active') - ->where('is_active', 1) - ->first(); + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.emp_code', $row[1]) + ->where('employees.name',$row[2]) + ->where('employees.client_id',$file['client_id']) + ->where('employees.client_branch_id',$file['client_branch_id']) + ->where('employee_polices.client_policy_id',$file['policy_id']) + ->where('employees.emp_status','active') + ->where('employees.is_active',1) + ->where('employee_polices.status','active') + ->where('employee_polices.is_active',1) + ->first(); + $existing_endorsements = $this->empEndorsementModel->where('actions', 'c') ->where('table_name', 'employees') ->where('endorsement_id is null') diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index a80ec116..07bf7ad5 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1470,10 +1470,11 @@ class EmployeeServiceController extends AdminController //get file name $file_id = $params['file_id']; $file = $this->fileModel->find($file_id); + // dd($file); $file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name']; - $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); $sheet = $spreadsheet->getActiveSheet(); $highestRowAndColumn = $sheet->getHighestRowAndColumn(); @@ -1498,13 +1499,21 @@ class EmployeeServiceController extends AdminController $employee = $this->employeeModel - ->where('emp_code', $row[1]) - ->where('name',$row[2]) - ->where('client_id',$file['client_id']) - ->where('client_branch_id',$file['client_branch_id']) - ->where('emp_status','active') - ->where('is_active',1) + ->select('employees.*') + ->join('employee_polices', 'employees.id = employee_polices.employee_id') + ->where('employees.emp_code', $row[1]) + ->where('employees.name',$row[2]) + ->where('employees.client_id',$file['client_id']) + ->where('employees.client_branch_id',$file['client_branch_id']) + ->where('employee_polices.client_policy_id',$file['policy_id']) + ->where('employees.emp_status','active') + ->where('employees.is_active',1) + ->where('employee_polices.status','active') + ->where('employee_polices.is_active',1) ->first(); + + // Kint::dump($employee); + $existing_endorsements = $this->empEndorsementModel->where('actions','c') ->where('table_name','employees') ->where('endorsement_id is null') @@ -1530,7 +1539,7 @@ class EmployeeServiceController extends AdminController $this->myLogger->logme("error",'{file_id} uploaded success',['file_id' => $file_id]); //set success msg to pull notifications $this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success')); - return true; + return true; } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 82a8cb3b..2ef130de 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -563,36 +563,19 @@ class EmployeePolicyModel extends Model employees.email_personal AS emp_email_p, employees.band AS emp_grade, employees.designation AS emp_designation, - employees.basic_pay AS emp_basic_pay, - - batch_data.emp_policy_id, - batch_data.bl AS batch_list_batch_code, - batch_data.bf AS batch_files_batch_code - + employees.basic_pay AS emp_basic_pay FROM emp_endorsement LEFT JOIN employees ON employees.id = emp_endorsement.pk LEFT JOIN employee_polices ON employees.id = employee_polices.employee_id - LEFT JOIN ( - SELECT batch_list.emp_policy_id, - batch_list.batch_code AS bl, - batch_files.batch_code AS bf - FROM - batch_files - LEFT JOIN - batch_list ON batch_files.batch_code = batch_list.batch_code - WHERE batch_files.event_type = 'correction' - AND batch_files.actions = 'export' - AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}' - ) AS batch_data ON emp_endorsement.pk = batch_data.emp_policy_id - WHERE employees.client_id = '{$client_id}' AND employee_polices.client_policy_id = '{$client_policy_id}' AND employees.client_branch_id = '{$client_branch_id}' AND emp_endorsement.actions = 'c' AND emp_endorsement.status != 'truncated' + AND emp_endorsement.is_active = 1 AND employee_polices.is_active = 1 AND employee_polices.status = 'active' AND employees.is_active = 1 From f529180f5714c0fab90b13b71f36b3c7afc19eb9 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 15 Sep 2025 12:46:46 +0530 Subject: [PATCH 02/38] FIX_GPA_ENROLLMENT_DISPLAY : RV --- app/Views/policy_gpa_terms.php | 46 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/Views/policy_gpa_terms.php b/app/Views/policy_gpa_terms.php index 480cc306..b8be22c0 100755 --- a/app/Views/policy_gpa_terms.php +++ b/app/Views/policy_gpa_terms.php @@ -169,7 +169,7 @@
- + @@ -181,7 +181,7 @@
- + @@ -197,7 +197,7 @@
- +
@@ -208,7 +208,7 @@
- +
@@ -221,7 +221,7 @@
- +
@@ -232,7 +232,7 @@
- +
@@ -245,7 +245,7 @@
- +
@@ -255,7 +255,7 @@
- +
@@ -267,7 +267,7 @@
- +
@@ -277,7 +277,7 @@
- +
@@ -289,7 +289,7 @@
- +
@@ -299,7 +299,7 @@
- +
@@ -311,7 +311,7 @@
- +
@@ -320,7 +320,7 @@
- +
@@ -332,7 +332,7 @@
- +
@@ -341,7 +341,7 @@
- +
@@ -353,7 +353,7 @@
- +
@@ -362,7 +362,7 @@
- +
@@ -374,7 +374,7 @@
- +
@@ -383,7 +383,7 @@
- +
@@ -396,7 +396,7 @@
- +
@@ -657,7 +657,7 @@ } } - if (key.includes("enrollment_display_key") && key != "") { + if (key.includes("enrollment_display_key") && key.length) { console.log('enrollment_display_key'); console.log(gpaJsonObjectForSpecialCondition[key]); @@ -698,7 +698,7 @@ .next()[0]; $(element).css("display", ""); } - disableUnwantedTermsforGPA(jsonObject); + // disableUnwantedTermsforGPA(jsonObject); Object.keys(jsonObject).forEach(function(key) { From 4536bc7f45daf84d5d003e2e47f51dd107cefd97 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 15 Sep 2025 17:30:24 +0530 Subject: [PATCH 03/38] FIX_BDS_MOTOR_CD : RV --- app/Controllers/EmpDataServiceController.php | 88 +++++++++---------- app/Controllers/EmployeeController.php | 6 +- app/Views/insurer_or_tpa_data.php | 31 +++---- .../policy_transaction_inception_form.php | 17 ++-- 4 files changed, 74 insertions(+), 68 deletions(-) diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 1aec089e..c144fb0f 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -2078,18 +2078,18 @@ class EmpDataServiceController extends BaseController 'user_id' => $user_id, ]]); - $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ - 'client_policy_id' => $client_policy_id ?? null, - 'endorsement_no' => $endorsement_id ?? null, - 'emp_count' => $emp_count ?? null, - 'action_type' => $file['event_type'] ?? null, - 'no_of_insured' => count($no_of_insured ?? []) ?? null, - 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, - 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, - 'gst' => $base_bremium_and_gst['gst'] ?? null, - 'policy_issue_date' => $policy_issue_date ?? null, - 'created_by' => $file['created_by'] ?? null, - ]]); + // $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ + // 'client_policy_id' => $client_policy_id ?? null, + // 'endorsement_no' => $endorsement_id ?? null, + // 'emp_count' => $emp_count ?? null, + // 'action_type' => $file['event_type'] ?? null, + // 'no_of_insured' => count($no_of_insured ?? []) ?? null, + // 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, + // 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, + // 'gst' => $base_bremium_and_gst['gst'] ?? null, + // 'policy_issue_date' => $policy_issue_date ?? null, + // 'created_by' => $file['created_by'] ?? null, + // ]]); // $this->cashDepositCalculationForInception($depositeData); // $this->sendMailForDownloadingECard($emp_policy_ids); @@ -2518,14 +2518,14 @@ class EmpDataServiceController extends BaseController $file_data = $this->getDataByFileId($file_id, 'success'); $this->setPullNotification($file_data); - $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ - 'client_policy_id' => $client_policy_id ?? null, - 'endorsement_no' => $endorsement_id[0] ?? null, - 'emp_count' => $emp_count ?? null, - 'action_type' => $file['event_type'] ?? null, - 'policy_issue_date' => $policy_issue_date ?? null, - 'created_by' => $file['created_by'] ?? null, - ]]); + // $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ + // 'client_policy_id' => $client_policy_id ?? null, + // 'endorsement_no' => $endorsement_id[0] ?? null, + // 'emp_count' => $emp_count ?? null, + // 'action_type' => $file['event_type'] ?? null, + // 'policy_issue_date' => $policy_issue_date ?? null, + // 'created_by' => $file['created_by'] ?? null, + // ]]); //import file to upload Google Drive @@ -3177,18 +3177,18 @@ class EmpDataServiceController extends BaseController 'user_id' => $user_id, ]]); - $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ - 'client_policy_id' => $client_policy_id ?? null, - 'endorsement_no' => $endorsement_id ?? null, - 'emp_count' => $emp_count ?? null, - 'action_type' => $file['event_type'] ?? null, - 'no_of_insured' => count($no_of_insured ?? []) ?? null, - 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, - 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, - 'gst' => $base_bremium_and_gst['gst'] ?? null, - 'policy_issue_date' => $policy_issue_date ?? null, - 'created_by' => $file['created_by'] ?? null, - ]]); + // $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ + // 'client_policy_id' => $client_policy_id ?? null, + // 'endorsement_no' => $endorsement_id ?? null, + // 'emp_count' => $emp_count ?? null, + // 'action_type' => $file['event_type'] ?? null, + // 'no_of_insured' => count($no_of_insured ?? []) ?? null, + // 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, + // 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, + // 'gst' => $base_bremium_and_gst['gst'] ?? null, + // 'policy_issue_date' => $policy_issue_date ?? null, + // 'created_by' => $file['created_by'] ?? null, + // ]]); } @@ -3688,18 +3688,18 @@ class EmpDataServiceController extends BaseController 'user_id' => $user_id, ]]); - $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ - 'client_policy_id' => $client_policy_id ?? null, - 'endorsement_no' => $endorsement_id ?? null, - 'emp_count' => $emp_count ?? null, - 'action_type' => $file['event_type'] ?? null, - 'no_of_insured' => count($no_of_insured ?? []) ?? null, - 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, - 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, - 'gst' => $base_bremium_and_gst['gst'] ?? null, - 'policy_issue_date' => $policy_issue_date ?? null, - 'created_by' => $file['created_by'] ?? null, - ]]); + // $r = Jobs::addJob(['job_name' => 'makeEntryForBDSPolicyTransaction', 'payload' => [ + // 'client_policy_id' => $client_policy_id ?? null, + // 'endorsement_no' => $endorsement_id ?? null, + // 'emp_count' => $emp_count ?? null, + // 'action_type' => $file['event_type'] ?? null, + // 'no_of_insured' => count($no_of_insured ?? []) ?? null, + // 'no_of_dependent' => count($no_of_dependent ?? []) ?? null, + // 'base_premium' => $base_bremium_and_gst['base_premium'] ?? null, + // 'gst' => $base_bremium_and_gst['gst'] ?? null, + // 'policy_issue_date' => $policy_issue_date ?? null, + // 'created_by' => $file['created_by'] ?? null, + // ]]); } $file_data = $this->getDataByFileId($file_id, 'success'); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index b97bd1b0..3751da86 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -526,7 +526,7 @@ class EmployeeController extends AdminController $client_branch_id = $this->request->getPost('client_branch_id'); $insurer_or_tpa = $this->request->getPost('insurer_or_tpa'); $actions = $this->request->getPost('action_type'); - $policy_issue_date = $this->request->getPost('policy_issue_date'); + $policy_issue_date = $this->request->getPost('policy_issue_date') ?? null; $client_data = $this->clientPolicyModel->getCliendDataForExcelFileName($client_policy_id); $file_name = generate_filename($client_data['short_name'], $event_type, $actions, $insurer_or_tpa, $client_data['policy_type'], $client_data['branch_code']); @@ -544,9 +544,7 @@ class EmployeeController extends AdminController ]; - $batch_data['policy_issue_date'] = (!empty($policy_issue_date) && strtotime($policy_issue_date) !== false) - ? change_date_format($policy_issue_date) - : null; + $batch_data['policy_issue_date'] = (!empty($policy_issue_date) && strtotime($policy_issue_date) !== false) ? change_date_format($policy_issue_date) : null; if ($actions == 'export') { diff --git a/app/Views/insurer_or_tpa_data.php b/app/Views/insurer_or_tpa_data.php index dc07ab1c..fc822a52 100755 --- a/app/Views/insurer_or_tpa_data.php +++ b/app/Views/insurer_or_tpa_data.php @@ -90,13 +90,14 @@
- @@ -1194,7 +1195,6 @@ $(document).ready(function(){ } }); - $('#upload_enrollment_model').on('hide.bs.modal', function (e) { console.log('Attempting to hide #upload_enrollment_model modal'); @@ -1263,7 +1263,6 @@ $(document).ready(function(){ }); - $('#aadhar').attr('data-parsley-required', 'false'); $('#aadhar').removeAttr('required'); @@ -1356,10 +1355,15 @@ $(document).ready(function(){ setTimeout(function(){ $('#client_branch_id').val(branch_id).change() }, 800) + + $('#table_tr_34').show(); + $('#table_tr_37').show(); }else{ $('.branchdiv').hide() $('#client_branch_id').prop('required', false); + $('#table_tr_34').hide(); + $('#table_tr_37').hide(); } if(val == 'add_vehicle'){ @@ -1541,7 +1545,6 @@ $(document).ready(function(){ $('[name="standard_tp[]"]').val(std_tp); $('[name="standard_ter[]"]').val(std_tep); - if(value == 8){ $('#vhnodiv').show(); $('#client_type_div').hide(); @@ -3843,9 +3846,13 @@ $('#Owner_type').on('change', function() { if ($(this).val() == 2) { $('.ownerbranchdiv').hide(); $('#owner_branch').prop('required', false); + $('#table_tr_34').hide(); + $('#table_tr_37').hide(); } else { $('.ownerbranchdiv').show(); $('#owner_branch').prop('required', true); + $('#table_tr_34').show(); + $('#table_tr_37').show(); } // console.log('selected Owner type', selectedClientType); From 3de88523a79a2dd7f8c84026ec0838f1632d4901 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 16 Sep 2025 15:01:22 +0530 Subject: [PATCH 04/38] FEAT_WELLNESS_HELPER&ICICI_TPA_API_CHANGE --- app/Controllers/EmployeeRestController.php | 3 + app/Controllers/ICICILombardController.php | 34 +- app/Helpers/NhanceWelnessSsoHelper.php | 380 +++++++++++++++++++++ 3 files changed, 405 insertions(+), 12 deletions(-) create mode 100644 app/Helpers/NhanceWelnessSsoHelper.php diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 1dd19735..4622c86b 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -3,6 +3,7 @@ namespace App\Controllers; use App\Helpers\MailHelper; +use App\Helpers\NhanceWelnessSsoHelper; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; @@ -3809,6 +3810,8 @@ class EmployeeRestController extends AdminController public function getWellnessUrl() { + // $url = NhanceWelnessSsoHelper::generateSSOUrl(); + // echo $url;die(); // $url = "https://aam.mohfw.gov.in/home/login"; $url = ""; diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php index 9433f7f1..2db5e29d 100644 --- a/app/Controllers/ICICILombardController.php +++ b/app/Controllers/ICICILombardController.php @@ -68,13 +68,15 @@ class ICICILombardController extends AdminController #"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f", #old policy inf end + #"EmployeeMemberId" => "EMPID3625556", + $body = [ "PolicyNumber" => "4016/A/O/53077718/00/000", "CDBGAccountNumber" => "CD-MUM-0026", "CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f", "MemberDetails" => [ [ - "EmployeeMemberId" => "EMPID3625556", + "MemberEmpId" => "EMPID3625556", "DOJ" => "21-MAR-2019", "InsuredName" => "ABC28144", "DOB" => "7-JUL-1983", @@ -86,7 +88,7 @@ class ICICILombardController extends AdminController "FlagStatus" => "A" ], [ - "EmployeeMemberId" => "EMPID3625556", + "MemberEmpId" => "EMPID3625556", "DOJ" => "21-MAR-2019", "InsuredName" => "ABC28146", "DOB" => "8-AUG-1970", @@ -98,7 +100,7 @@ class ICICILombardController extends AdminController "FlagStatus" => "A" ], [ - "EmployeeMemberId" => "EMPID0502220011", + "MemberEmpId" => "EMPID0502220011", "UHID" => "IL00688842553", "InsuredName" => "ABC28142", "DOB" => "8-SEP-1970", @@ -107,11 +109,11 @@ class ICICILombardController extends AdminController "EmailId" => "ABC@GMAIL.COM", "FlagStatus" => "M" ], - [ - "UHID" => "IL00688842552", - "DOL" => "08-JUL-2025", - "FlagStatus" => "D" - ] + // [ + // "UHID" => "IL00688842552", + // "DOL" => "08-JUL-2025", + // "FlagStatus" => "D" + // ] ] ]; // Kint::dump($body); @@ -144,13 +146,21 @@ class ICICILombardController extends AdminController 'Content-Type: application/json' ]; - $body = [ - "PolicyNumber" => "4016/A/51974976/00/000", - "BatchId" => "2345617878", + // $body = [ + // "PolicyNumber" => "4016/A/51974976/00/000", + // "BatchId" => "2345617878", + // "CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f" + // ]; + + $body = [ + "PolicyNumber" => "4016/A/O/53077718/00/000", + // "BatchId" => "3642146", + "BatchId" => "3642149", "CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f" ]; - $response = call_third_party_api($url, 'POST', $headers, json_encode($body), true); + // $response = call_third_party_api($url, 'POST', $headers, json_encode($body), true); + $response = call_third_party_api($url, 'POST', $headers, ($body), true); return $this->response->setJSON($response); } diff --git a/app/Helpers/NhanceWelnessSsoHelper.php b/app/Helpers/NhanceWelnessSsoHelper.php new file mode 100644 index 00000000..e3a4550d --- /dev/null +++ b/app/Helpers/NhanceWelnessSsoHelper.php @@ -0,0 +1,380 @@ +generateSSOUrl($userParams); + } +} + +if (!function_exists('decrypt_nhance_sso_params')) { + /** + * Decrypt Nhance SSO parameters for testing + * + * @param string|null $encryptedParams Encrypted parameters, uses sample if null + * @return array Decrypted user parameters + */ + function decrypt_nhance_sso_params($encryptedParams = null) { + $helper = new NhanceSsoHelper(); + return $helper->decryptUserParams($encryptedParams); + } +} + +if (!function_exists('test_nhance_sso_encryption')) { + /** + * Test Nhance SSO encryption/decryption functionality + * + * @return array Test results + */ + function test_nhance_sso_encryption() { + $helper = new NhanceSsoHelper(); + return $helper->runTests(); + } +} + +/** + * Nhance SSO Helper Class + */ +class NhanceWelnessSsoHelper { + + private static $baseUrl = 'https://web.samuraijack.xyz/sso'; + private static $clientId = 'nhance-gt-2tx7'; + private static $encryptionKey = '32D1D5535157AF3D4667ADAB0CC795D77D022BB281AD3272EB134C72BD0B185E'; + private static $algorithm = 'aes-256-cbc'; + + /** + * Get sample user parameters + */ + private static function getSampleUserParams() { + return [ + 'name' => 'John Doe 3', + 'email' => 'john.doe3@email.com', + 'memberId' => 'TEST-REL-01', + 'gender' => 'Male', + 'dob' => '1997-01-01', + 'policyName' => 'Nhance DEMO', + 'phone' => '6676126763', + 'employeeId' => 'EMP-NHANCE-TEST-03', + 'policyNumber' => "EMP-NHANCE-TEST-03", + 'policyStartDate' => '2025-09-08', + 'policyEndDate' => '2026-09-08', + 'moduleName' => 'home', + 'relation' => 'self', + 'planId' => 'NHANCE-PLAN-1', + + ]; + } + + /** + * Get sample encrypted parameters for testing + */ + private static function getSampleEncryptedParams() { + // Generate sample encrypted params using sample data + $sampleParams = (SELF::getSampleUserParams()); + return SELF::encryptUserParams($sampleParams); + } + + /** + * Encrypt user parameters using AES-256-CBC + */ + private static function encryptUserParams($userParams) { + try { + $jsonData = json_encode($userParams); + + // Generate a random IV + $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(SELF::$algorithm)); + // $iv = 'getvisitappdotcom'; + + // Convert hex key to binary + $key = hex2bin(SELF::$encryptionKey); + // $key = (SELF::$encryptionKey); + + // Encrypt the data + $encrypted = openssl_encrypt($jsonData, SELF::$algorithm, $key, 0, $iv); + + if ($encrypted === false) { + throw new Exception("Encryption failed"); + } + + // Combine IV and encrypted data, then encode + $encryptedData = base64_encode($iv . base64_decode($encrypted)); + + // Make URL safe + return str_replace(['+', '/', '='], ['-', '_', ''], $encryptedData); + + } catch (Exception $e) { + log_message('error', 'Nhance SSO Encryption Error: ' . $e->getMessage()); + throw new Exception("Encryption failed: " . $e->getMessage()); + } + } + + /** + * Decrypt user parameters for testing purposes + */ + public static function decryptUserParams($encryptedParams = null) { + try { + // Use sample encrypted params if none provided + if ($encryptedParams === null) { + $encryptedParams = SELF::getSampleEncryptedParams(); + log_message('info', 'Using sample encrypted parameters for decryption test'); + } + + // Handle URL format if full URL is passed + if (strpos($encryptedParams, 'userParams=') !== false) { + $encryptedParams = SELF::extractParamsFromUrl($encryptedParams); + } + + // Make URL-safe characters back to base64 + $encryptedParams = str_replace(['-', '_'], ['+', '/'], $encryptedParams); + + // Add padding if needed + $encryptedParams = $encryptedParams . str_repeat('=', (4 - strlen($encryptedParams) % 4) % 4); + + // Decode base64 + $data = base64_decode($encryptedParams); + + if ($data === false) { + throw new Exception("Failed to decode base64 data"); + } + + // Extract IV and encrypted data + $ivLength = openssl_cipher_iv_length(SELF::$algorithm); + $iv = substr($data, 0, $ivLength); + $encrypted = base64_encode(substr($data, $ivLength)); + + // Convert hex key to binary + $key = hex2bin(SELF::$encryptionKey); + + // Decrypt the data + $decrypted = openssl_decrypt($encrypted, SELF::$algorithm, $key, 0, $iv); + + if ($decrypted === false) { + throw new Exception("Decryption failed"); + } + + // Decode JSON + $userParams = json_decode($decrypted, true); + + if ($userParams === null) { + throw new Exception("Failed to decode JSON data"); + } + + return $userParams; + + } catch (Exception $e) { + log_message('error', 'Nhance SSO Decryption Error: ' . $e->getMessage()); + throw new Exception("Decryption error: " . $e->getMessage()); + } + } + + /** + * Generate SSO URL with encrypted parameters + */ + public static function generateSSOUrl($userParams = null) { + try { + // Use sample parameters if none provided + if ($userParams === null) { + $userParams = SELF::getSampleUserParams(); + log_message('info', 'Using sample user parameters for SSO URL generation'); + } + + // Validate required parameters + SELF::validateUserParams($userParams); + + // Encrypt user parameters + $encryptedParams = SELF::encryptUserParams($userParams); + + // Build the SSO URL + $ssoUrl = SELF::$baseUrl . '?userParams=' . $encryptedParams . '&clientId=' . SELF::$clientId; + + log_message('info', 'Nhance SSO URL generated successfully for user: ' . $userParams['email']); + + return $ssoUrl; + + } catch (Exception $e) { + log_message('error', 'Nhance SSO URL Generation Error: ' . $e->getMessage()); + throw new Exception("Failed to generate SSO URL: " . $e->getMessage()); + } + } + + /** + * Validate user parameters + */ + private static function validateUserParams($userParams) { + $requiredFields = [ + 'name', 'email', 'phone', 'memberId', 'gender', 'dob', + 'policyName', 'policyNumber', 'employeeId', 'moduleName', + 'relation', 'planId', 'policyStartDate', 'policyEndDate' + ]; + + foreach ($requiredFields as $field) { + if (!isset($userParams[$field]) || empty($userParams[$field])) { + throw new Exception("Required field '$field' is missing or empty"); + } + } + + // Validate date formats + if (!SELF::validateDate($userParams['dob']) || + !SELF::validateDate($userParams['policyStartDate']) || + !SELF::validateDate($userParams['policyEndDate'])) { + throw new Exception("Invalid date format. Use YYYY-MM-DD format"); + } + + // Validate gender + if (!in_array($userParams['gender'], ['Male', 'Female'])) { + throw new Exception("Gender must be 'Male' or 'Female'"); + } + + // Validate email + if (!filter_var($userParams['email'], FILTER_VALIDATE_EMAIL)) { + throw new Exception("Invalid email format"); + } + } + + /** + * Validate date format (YYYY-MM-DD) + */ + private static function validateDate($date) { + $d = \DateTime::createFromFormat('Y-m-d', $date); + return $d && $d->format('Y-m-d') === $date; + } + + /** + * Extract encrypted parameters from SSO URL + */ + private static function extractParamsFromUrl($ssoUrl) { + $parsedUrl = parse_url($ssoUrl); + if (!isset($parsedUrl['query'])) { + throw new Exception("No query parameters found in URL"); + } + + parse_str($parsedUrl['query'], $queryParams); + + if (!isset($queryParams['userParams'])) { + throw new Exception("userParams not found in URL"); + } + + return $queryParams['userParams']; + } + + /** + * Run comprehensive tests + */ + public static function runTests() { + $results = [ + 'tests_passed' => 0, + 'tests_failed' => 0, + 'test_details' => [] + ]; + + try { + // Test 1: Sample data encryption/decryption + log_message('info', 'Running Nhance SSO Test 1: Sample data round-trip'); + $sampleParams = SELF::getSampleUserParams(); + $ssoUrl = SELF::generateSSOUrl($sampleParams); + $encryptedParams = SELF::extractParamsFromUrl($ssoUrl); + $decryptedParams = SELF::decryptUserParams($encryptedParams); + + $test1Pass = json_encode($sampleParams) === json_encode($decryptedParams); + $results['test_details']['sample_round_trip'] = [ + 'status' => $test1Pass ? 'PASSED' : 'FAILED', + 'original_params' => $sampleParams, + 'decrypted_params' => $decryptedParams, + 'sso_url' => $ssoUrl + ]; + + if ($test1Pass) { + $results['tests_passed']++; + } else { + $results['tests_failed']++; + } + + // Test 2: Custom parameters + log_message('info', 'Running Nhance SSO Test 2: Custom parameters'); + $customParams = [ + 'name' => 'Jane Smith Test', + 'email' => 'jane.test@example.com', + 'phone' => '1122334455', + 'memberId' => 'TEST-CUSTOM-001', + 'gender' => 'Female', + 'dob' => '1985-03-20', + 'policyName' => 'Custom Test Policy', + 'policyNumber' => 'CUSTOM-POL-001', + 'employeeId' => 'EMP-CUSTOM-001', + 'moduleName' => 'home', + 'relation' => 'self', + 'planId' => 'NHANCE-PLAN-1', + 'policyStartDate' => date('Y-m-d'), + 'policyEndDate' => date('Y-m-d', strtotime('+2 years')) + ]; + + $customSsoUrl = SELF::generateSSOUrl($customParams); + $customEncryptedParams = SELF::extractParamsFromUrl($customSsoUrl); + $customDecryptedParams = SELF::decryptUserParams($customEncryptedParams); + + $test2Pass = json_encode($customParams) === json_encode($customDecryptedParams); + $results['test_details']['custom_round_trip'] = [ + 'status' => $test2Pass ? 'PASSED' : 'FAILED', + 'original_params' => $customParams, + 'decrypted_params' => $customDecryptedParams, + 'sso_url' => $customSsoUrl + ]; + + if ($test2Pass) { + $results['tests_passed']++; + } else { + $results['tests_failed']++; + } + + // Test 3: Null parameter handling + log_message('info', 'Running Nhance SSO Test 3: Null parameter handling'); + $nullTestUrl = SELF::generateSSOUrl(null); + $nullDecrypted = SELF::decryptUserParams(null); + + $test3Pass = !empty($nullTestUrl) && !empty($nullDecrypted); + $results['test_details']['null_parameter_handling'] = [ + 'status' => $test3Pass ? 'PASSED' : 'FAILED', + 'generated_url' => $nullTestUrl, + 'decrypted_sample' => $nullDecrypted + ]; + + if ($test3Pass) { + $results['tests_passed']++; + } else { + $results['tests_failed']++; + } + + } catch (Exception $e) { + $results['tests_failed']++; + $results['test_details']['error'] = $e->getMessage(); + log_message('error', 'Nhance SSO Test Error: ' . $e->getMessage()); + } + + $results['overall_status'] = $results['tests_failed'] === 0 ? 'ALL_PASSED' : 'SOME_FAILED'; + log_message('info', 'Nhance SSO Tests completed. Passed: ' . $results['tests_passed'] . ', Failed: ' . $results['tests_failed']); + + return $results; + } +} + +?> \ No newline at end of file From 11dd30597f32d9c80bd55fd2bf73c123619f33cf Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 18 Sep 2025 18:12:38 +0530 Subject: [PATCH 05/38] CHANGE_BDS : RV --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 286 +++++-- .../PolicyTransactionController.php | 86 ++- app/Controllers/TestingController.php | 77 ++ app/Helpers/excel_util_helper.php | 6 +- app/Models/NhanceBranchModel.php | 51 ++ app/Models/PolicyTransactionModel.php | 1 + .../policy_transaction_inception_form.php | 730 +++++++++++++----- .../policy_transaction_inception_list.php | 31 +- 9 files changed, 975 insertions(+), 294 deletions(-) create mode 100644 app/Models/NhanceBranchModel.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c217dd5b..05c618bf 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -690,6 +690,7 @@ $routes->group('test', function($routes) { $routes->get('generatePDF', 'TestingController::generatePDF'); $routes->get('viewPDF', 'TestingController::viewPDF'); $routes->get('generate-pdf-view', 'TestingController::generatePDFWithView'); + $routes->get('param/(:any)', 'TestingController::ptedfitdata/$1'); }); $routes->cli('cli/testcli', 'TestingController::testcli'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 8ecf4184..95642959 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -999,31 +999,52 @@ class ClientController extends AdminController $data['client_id'] = $this->request->getPost('client_id'); $data['updated_by'] = get_session_userid(); $inserted = false; + // print_r($this->request->getPost()); die; if ($this->request->getPost('head')) { + $data['user_id'] = $this->request->getPost('head'); - $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1); - if ($checkHead) { - $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 1)->set($data)->update(); - } else { - $data['level'] = "1"; - $data['user_id'] = $this->request->getPost('head'); - $inserted = $this->clientRMModel->insert($data); - } + $this->clientRMModel->where('client_id', $id)->where('level', 1)->delete(); + + $data['level'] = "1"; + $data['user_id'] = $this->request->getPost('head'); + $inserted = $this->clientRMModel->insert($data); } if ($this->request->getPost('manager')) { + $data['user_id'] = $this->request->getPost('manager'); - $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2); - if ($checkHead) { - $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 2)->set($data)->update(); - } else { - $data['level'] = "2"; - $data['user_id'] = $this->request->getPost('manager'); - $inserted = $this->clientRMModel->insert($data); - } + $this->clientRMModel->where('client_id', $id)->where('level', 2)->delete(); + + $data['level'] = "2"; + $data['user_id'] = $this->request->getPost('manager'); + $inserted = $this->clientRMModel->insert($data); } + // if ($this->request->getPost('head')) { + // $data['user_id'] = $this->request->getPost('head'); + // $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1); + // if ($checkHead) { + // $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 1)->set($data)->update(); + // } else { + // $data['level'] = "1"; + // $data['user_id'] = $this->request->getPost('head'); + // $inserted = $this->clientRMModel->insert($data); + // } + // } + + // if ($this->request->getPost('manager')) { + // $data['user_id'] = $this->request->getPost('manager'); + // $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2); + // if ($checkHead) { + // $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 2)->set($data)->update(); + // } else { + // $data['level'] = "2"; + // $data['user_id'] = $this->request->getPost('manager'); + // $inserted = $this->clientRMModel->insert($data); + // } + // } + if ($this->request->getPost('account_manager')) { $this->clientRMModel->where('client_id', $id)->where('level', 3)->delete(); @@ -4422,7 +4443,7 @@ class ClientController extends AdminController // } // } - public function createClientWithMinimalData() + public function createClientWithMinimalData2() { $postData = $this->request->getPost(); // print_r($postData); die; @@ -4474,7 +4495,74 @@ class ClientController extends AdminController 'name' => $postData['name'], 'mobile' => $postData['mobile'], 'email' => $postData['email'], + ]; + $this->levelContactModel->insert($contact_data); + } + } + return $this->respond([ + 'status' => true, + 'data' => $postData, + 'client_id' => $client_insert, + 'branch_id' => $branch_insert ?? null, + 'message' => 'Client created successfully' + ], 200); + } + + public function createClientWithMinimalData() + { + $postData = $this->request->getPost(); + + // print_r($postData); die; + $client_type = $postData['client_type'] ?? null; + + if($client_type == 2){ + + $client_data = [ + 'client_type' => $postData['client_type'], + 'client_name' => $postData['client_name'], + 'email' => $postData['short_name'] ?? $postData['client_name'], + 'phone' => $postData['mobile'], + 'client_code' => generate_client_code() + ]; + + $client_insert = $this->clientModel->insert($client_data); + + }else if($client_type == 1){ + + $client_data = [ + 'client_type' => $postData['client_type'], + 'client_name' => $postData['client_name'], + 'short_name' => $postData['short_name'] ?? $postData['client_name'], + 'client_code' => generate_client_code(), + 'entity_type_id' => 2 + ]; + + $client_insert = $this->clientModel->insert($client_data); + } + + if (!$client_insert) { + return $this->respond(['status' => false, 'message' => 'Failed to create client'], 200); + } + + // Additional logic for non-individual clients (client_type != 2) + if ($client_type != 2) { + $unit[] = $postData['short_name'] . '-' . 001; + $branch_data = [ + 'client_id' => $client_insert, + 'branch_name' => $postData['branch_name'], + 'branch_code' => 001, + 'gst' => $postData['gst'], + 'units' => json_encode($unit) ?? null, + ]; + + $branch_insert = $this->clientBranchModel->insert($branch_data); + if ($branch_insert) { + $contact_data = [ + 'ref_id' => $branch_insert, + 'contact_type' => 'client', + 'name' => $postData['name'], + 'email' => $postData['email'], ]; $this->levelContactModel->insert($contact_data); } @@ -4508,7 +4596,49 @@ class ClientController extends AdminController $vehicle_insert = $this->vehicleModel->insert($data); if ($vehicle_insert) { - $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); + + // $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); + $vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type') + ->join('clients', 'clients.id=vehicle.owner') + ->where('vehicle.is_active', 1) + ->findAll(); + + return $this->respond([ + 'status' => true, + 'vehicle_id' => $vehicle_insert, + 'owner_id' => $data['owner'], + 'owner_branch_id' => $data['branch_id'] ?? null, + 'owner_type' => $data['Owner_type'], + 'vehicles' => $vehicles, + 'message' => 'Vehicle created successfully + ' + ], 200); + } else { + return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200); + } + } + } + + public function createVehicleWithMinimalData2() + { + $data = $this->request->getPost(); + + if (isset($data['client_name']) && !empty($data['client_name'])) { + + $this->clientModel->insert(); + + } else { + + $vehicle_insert = $this->vehicleModel->insert($data); + + if ($vehicle_insert) { + + // $vehicles = $this->vehicleModel->where('is_active', 1)->findAll(); + $vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type') + ->join('clients', 'clients.id=vehicle.owner') + ->where('vehicle.is_active', 1) + ->findAll(); + return $this->respond([ 'status' => true, 'vehicle_id' => $vehicle_insert, @@ -4604,6 +4734,68 @@ 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'); + // $client_type = $this->request->getGet('client_type'); + + // $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) { + + // 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 { + // $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 { + // 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); + // } + // } + public function get_client_policy_data_using_policy_no() { $received_data = $this->request->getGet(); @@ -4613,54 +4805,14 @@ class ClientController extends AdminController $policy_type_id = $this->request->getGet('policy_type_id'); $client_type = $this->request->getGet('client_type'); - $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(); + $data = $this->policyTransactionModel + ->where('is_active', 1) + ->where('action_type', 'inception') + ->where('policy_no', $policy_no) + ->countAllResults(); - if ($data) { - - 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 { - $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 { - 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); - } - } - + if ($data > 0) { + return $this->respond(['status' => true, 'message' => 'This policy number is already linked to another client', 'data' => $data, 'code' => 409, 'received_data' => $received_data], 200); } else { return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200); } @@ -5259,7 +5411,7 @@ class ClientController extends AdminController // ---------- EMP SERVICE CONTROLLER -------------------------------------------------------------------------------- $empServiceController = new EmployeeServiceController(); - // $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']); + $res = $empServiceController->excelFileFormatValidation(['file_id' => '2055']); // $res = $empServiceController->excelFileDataValidation(['file_id' => '865']); // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]); // $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]); @@ -5267,7 +5419,7 @@ class ClientController extends AdminController // $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']); // $res = $empServiceController->employeeDisembark(['file_id' => '1681']); // $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']); - // dd( $res); + dd( $res); $EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController(); // $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 2b9afb78..e85a8f56 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -36,6 +36,7 @@ use App\Models\BdsPlacementModel; use Kint\Kint; use App\Helpers\MailHelper; use App\Helpers\ExcelSanitizeHelper; +use App\Models\NhanceBranchModel; use Exception; class PolicyTransactionController extends BaseController @@ -69,6 +70,7 @@ class PolicyTransactionController extends BaseController protected $filesModel; protected $coShareStmtDetailsModel; protected $BdsPlacementModel; + protected $nhanceBranchModel; public function __construct() { @@ -100,6 +102,7 @@ class PolicyTransactionController extends BaseController $this->filesModel = new FileModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->BdsPlacementModel = new BdsPlacementModel(); + $this->nhanceBranchModel = new NhanceBranchModel(); $this->invoiceStatus = [ 'pending' => 'Pending', 'generated' => 'Generated', @@ -115,6 +118,7 @@ class PolicyTransactionController extends BaseController // Static arrays for dropdowns $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll(); $data['client_type'] = [1 => 'Group', 2 => 'Individual']; $data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over']; $data['policy_status'] = [ @@ -255,6 +259,7 @@ class PolicyTransactionController extends BaseController $id = $this->request->getPost('id'); $data = $this->preparePolicyData(); $data['cd_ac_pk'] = $this->request->getPost('cd_ac_no'); + $data['issuer'] = 2; $this->myLogger->logme('error', 'Policy Trancaction modified form data ( insert data ) : '. json_encode($data)); @@ -334,11 +339,8 @@ class PolicyTransactionController extends BaseController $data['policy_with_corr'] = 1; } - if (!isset($data['is_cd_reduce_from_bds'])) { - $data['is_cd_reduce_from_bds'] = 0; - } elseif ($data['is_cd_reduce_from_bds']) { - $data['is_cd_reduce_from_bds'] = 1; - } + $data['is_cd_reduce_from_bds'] = ($data['policy_type_id'] > 7 && $data['client_type'] === 1) ? 1 : 0; + if ($data['ct_type'] == "") { $data['ct_type'] = 1; @@ -436,6 +438,11 @@ class PolicyTransactionController extends BaseController $data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll(); } + if(isset($data['cd_amt_changed']) && !empty($data['cd_amt_changed'])){ + $policy_data = $this->policyTransactionModel->where('is_active', 1)->where('id', $id)->first(); + $this->cdCorrection($policy_data, $data['cd_amt_changed']); + } + $client_data = $this->clientModel->where('id', $data['client_id'])->first(); $data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll(); @@ -621,6 +628,30 @@ class PolicyTransactionController extends BaseController DepositHelper::saveDeposit($cdTransactionData, get_session_userid()); } + private function cdCorrection($data, $amt) + { + $totalAmount = (int)($amt ?? 0); + $description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited towards the difference arising from the change in the BDS base premium.'; + + $cdTransactionData = [ + 'amount' => abs($totalAmount), + 'sub_type_id' => 4, + 'client_id' => $data['client_id'], + 'client_policy_id' => $data['client_policy_id'] ?? 0, + 'endorsement_no' => null, + 'cd_ac_no' => $data['cd_ac_no'] ?? null, + 'insurer_id' => $data['insurer_id'], + 'description' => $description, + 'transaction_type' => $totalAmount < 0 ? 'Credit' : 'Debit', + 'updated_by' => get_session_userid(), + 'event_name' => 'inception', + 'is_active' => 1, + 'cd_ac_pk' => $data['cd_ac_pk'] + ]; + + DepositHelper::saveDeposit($cdTransactionData, get_session_userid()); + } + private function processInsertIndividualMemberInEmpTable($data) { // print_r($data); @@ -753,31 +784,6 @@ class PolicyTransactionController extends BaseController ->where('policy_transaction.is_active', 1) ->first(); - // $data['policy_issue_date'] = (isset($data['policy_issue_date']) && $data['policy_issue_date'] !== null && $data['policy_issue_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_issue_date'])) - // : null; - - // $data['policy_start_date'] = (isset($data['policy_start_date']) && $data['policy_start_date'] !== null && $data['policy_start_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_start_date'])) - // : null; - - // $data['policy_end_date'] = (isset($data['policy_end_date']) && $data['policy_end_date'] !== null && $data['policy_end_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_end_date'])) - // : null; - - // $data['renewal_date'] = (isset($data['renewal_date']) && $data['renewal_date'] !== null && $data['renewal_date'] !== '') - // ? date('d/m/Y', strtotime($data['renewal_date'])) - // : null; - - // $data['rollover_date'] = (isset($data['rollover_date']) && $data['rollover_date'] !== null && $data['rollover_date'] !== '') - // ? date('d/m/Y', strtotime($data['rollover_date'])) - // : null; - - // $data['month'] = (isset($data['month']) && $data['month'] !== null && $data['month'] !== '') - // ? date('M/Y', strtotime($data['month'])) - // : null; - - $data['created_at'] = (isset($data['created_at']) && $data['created_at'] !== null && $data['created_at'] !== '') ? date('d/m/Y h:i:s A', strtotime($data['created_at'])) : null; @@ -821,8 +827,6 @@ class PolicyTransactionController extends BaseController $data['month'] = null; } - - // print_r($data); die; $data['renewal_policy'] = $this->clientPolicyModel @@ -833,7 +837,6 @@ class PolicyTransactionController extends BaseController ->where('client_policy.is_active', 1) ->findAll(); - $data['base_policy_data'] = $this->clientPolicyModel ->select('client_policy.*, policy_type.policy_type') ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') @@ -843,6 +846,16 @@ class PolicyTransactionController extends BaseController ->where('client_policy.is_active', 1) ->findAll(); + $pt_bp_amt = $this->PTCOShareDetailsModel + ->select('bp_amt') + ->where('pt_id', $id) + ->where('co_share_type', 1) + ->where('is_active', 1) + ->first(); + + // dd(db_connect()->getLastQuery() ,$pt_bp_amt); + $data['base_cd_amount'] = $pt_bp_amt['bp_amt'] ?? null; + $ptFileQuery = $this->PTFileModel ->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id') @@ -999,7 +1012,7 @@ class PolicyTransactionController extends BaseController ->findAll(); // print_r( $data['pt_co_share_details']); die; - + // return $data; if ($data) { return $this->respond(['status' => true, 'data' => $data], 200); } else { @@ -1059,8 +1072,8 @@ class PolicyTransactionController extends BaseController // !dd($this->getEndorsementDataForEdit(17)); $data['page_name'] = 'Endorsement'; - $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll(); $data['client_type'] = [1 => 'Group', 2 => 'Individual']; $data['policy_status'] = [ @@ -1242,7 +1255,8 @@ class PolicyTransactionController extends BaseController if (!$data['id']) { $data += [ - 'issuer' => $issue_type['issuer'] ?? null, + 'issuer' => 2, + 'issuer_branch' => $data['issuer_branch'] ?? 1, 'client_type' => $data['client_type'] ?? $issue_type['client_type'] ?? null, 'policy_type_id' => $issue_type['policy_type_id'] ?? null, 'issue_type' => $issue_type['issue_type'] ?? null, diff --git a/app/Controllers/TestingController.php b/app/Controllers/TestingController.php index d866cb7f..cb432d24 100644 --- a/app/Controllers/TestingController.php +++ b/app/Controllers/TestingController.php @@ -4,6 +4,7 @@ namespace App\Controllers; use App\Controllers\BaseController; use App\Models\EmployeePolicyModel; +use App\Models\InsurerBranchModel; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\API\ResponseTrait; use Dompdf\Dompdf; @@ -236,4 +237,80 @@ class TestingController extends BaseController ->findAll(); } + + public function ptedfitdata($id){ + $policy_transaction = new PolicyTransactionController(); + $data = $policy_transaction->getInceptionDataForEdit($id); + // dd($data); + $insurerBranchModel = new InsurerBranchModel(); + $insurer_branch = $insurerBranchModel->getInsurerBranchesWithInsurerNames(); + + $dataArray = $data['pt_co_share_details']; // Example + $cd_ac_pk = 'CD12345'; + $role_id = 1; + $team_id = ['6']; + $insurer_branch = $insurer_branch; + + return view('pt_calc_table', [ + 'dataArray' => $dataArray, + 'cd_ac_pk' => $cd_ac_pk, + 'role_id' => $role_id, + 'team_id' => $team_id, + 'insurer_branch' => $insurer_branch + ]); + } + + function generateInsurerTable($dataArray, $cd_ac_pk, $role_id, $team_id, $insurer_branch) + { + $html = ''; + + foreach ($dataArray as $index => $data) { + $disable_td = ($data['record_count'] > 0) ? 'readonly-select' : ''; + $insurer = $data['insurer_branch_id'] . '-' . $data['insurer_id']; + + $html .= ''; + + // Insurer selection + $html .= ''; + + // Leader toggle + $checked = ($data['co_share_type'] == 1) ? 'checked' : ''; + $html .= ''; + + // CD Account + $html .= ''; + + // CD Amount + $html .= ''; + + // Example of follower policy no + $html .= ''; + + // Add other fields (bp_amt, tp_amt, gst, etc.) + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + $html .= ''; + } + + $html .= '
'; + + return $html; + } + } diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 3b52ce83..932e53c8 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -305,10 +305,12 @@ if (!function_exists('check_si')) { if (!function_exists('check_basic_pay')) { function check_basic_pay($row, $policy_terms, $slab_details) - { + { + // dd($row, $policy_terms, $slab_details); if ($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I', 'A', 'DA', 'MI'])) // check rule only of action column data available { - $is_basic_pay_needed = $slab_details['grid_master']['basicpay']; + // $is_basic_pay_needed = $slab_details['grid_master']['basicpay']; + $is_basic_pay_needed = ($slab_details['grid_master']['basicpay'] == 1 && $slab_details['slab_rates'][0]['si_or_bp'] == 2 && $slab_details['slab_rates'][0]['basic_pay'] != null) ? 1 : 0; // $is_basic_pay_needed = true; $slug = \Config\Services::slug(); $relationship = $slug->slugify($row[5]); diff --git a/app/Models/NhanceBranchModel.php b/app/Models/NhanceBranchModel.php new file mode 100644 index 00000000..d94d5fc9 --- /dev/null +++ b/app/Models/NhanceBranchModel.php @@ -0,0 +1,51 @@ +Back
-
+ @@ -173,10 +172,13 @@ + + +
@@ -264,6 +266,19 @@
--> +
+ + +
@@ -272,6 +287,13 @@
+
+
+ + +
+
+
@@ -368,9 +390,8 @@
-
+ +
--> -
- -
+ -
+

@@ -432,16 +452,16 @@
--> -
+ -
+
@@ -573,10 +593,10 @@
-
+