From 205598304cc14bc3ed5305ca1bcd336469eb2ca1 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 17 Dec 2024 10:20:10 +0530 Subject: [PATCH] CHANGE_MAIL_POLICY_TERMS_STATEMENT_UPLOAD_DELETION_QUERY_USER_HELPDESK_AND_OTHER_AND_LIVE_ISSUE_CHANGES : RV --- app/Controllers/ClientController.php | 46 +++- app/Controllers/EmpDataServiceController.php | 82 ++----- app/Controllers/EmployeeController.php | 53 ++++- .../PolicyTransactionController.php | 200 +++++++++--------- app/Controllers/UserController.php | 132 +++++++----- app/Helpers/sendMailNotification.php | 96 +++++++-- app/Models/ClientPolicyModel.php | 33 +++ app/Models/EmployeePolicyModel.php | 12 +- app/Views/client_policy.php | 1 - app/Views/employee_data_list.php | 4 +- app/Views/insurer_statement_list.php | 19 +- app/Views/policy_gmc_terms.php | 149 ++++++++++++- .../policy_transaction_inception_list.php | 34 ++- 13 files changed, 593 insertions(+), 268 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 40f52992..fcdd14e4 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -118,6 +118,8 @@ class ClientController extends AdminController $this->leadsModel = new LeadsModel(); } + //-------------------------------------------------------------------------------------------------------- + public function checkDuplicateTableFieldValue() { $table = $this->request->getPost('table'); @@ -2176,6 +2178,7 @@ class ClientController extends AdminController $data['preandpostnatal'] = ""; $data['babyday1cover'] = ""; } + $data['9monthwaitingperiodwaived'] = str_replace(',', '', $this->request->getPost("9monthwaitingperiodwaived")); $data['coverfromthedateofjoining'] = str_replace(',', '', $this->request->getPost("coverfromthedateofjoining")); $data['waiverof1,2,3&4thyearexclusions'] = $this->request->getPost("waiverof1,2,3&4thyearexclusions"); @@ -3791,7 +3794,16 @@ class ClientController extends AdminController } public function sendextraparam() - { + { + // $batch_data = [ + // 'client_id' => 17, + // 'client_policy_id' => 30, + // 'client_branch_id' => 18, + // ]; + + // $batch_data['insurer_or_tpa'] = 'insurer'; + // $batch_data['insurer_or_tpa'] = 'tpa'; + // dd($this->request); // $employeeRestController = new EmployeeServiceController(); @@ -3808,9 +3820,18 @@ class ClientController extends AdminController // $emp_data = $this->employeePolicyModel->getEmployeePolicyForEcard(12); // $ids = array_column($emp_data, 'id'); // $EmpDataServiceController->sendMailForDownloadingECard($ids); + + // $EmpDataServiceController = new EmpDataServiceController(); + // $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live + + // $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data); + // print_rr($result); die; // $empServiceController = new EmployeeServiceController(); // $res = $empServiceController->employeesOnboardPreprocess(['file_id' => '741']); + + // $PolicyTransactionController = new PolicyTransactionController(); + // $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']); } // ------------------------------------------------------------------------------------------------------- @@ -3832,4 +3853,27 @@ class ClientController extends AdminController return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data to update'], 200); } } + + + // ------------------------------------------------------------------------------------------------------- + + public function enrollmentAddonSIAmountDropdown($client_policy_id) + { + if(!empty($client_policy_id)){ + $client_policy_details = $this->clientPolicyModel->where('id', $client_policy_id)->where('policy_status', 1)->where('is_active', 1)->first(); + + if(!empty($client_policy_details) && $client_policy_details['policy_type_id'] == 3 && $client_policy_details['is_addon'] == 3){ + + $base_policy_id = $client_policy_details['base_policy'] ?? 0; + + if(!empty($base_policy_id)){ + + + + } + + } + } + } + } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 617eeda9..1e4366ca 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -751,11 +751,15 @@ class EmpDataServiceController extends BaseController public function generateExcelForDeletion($export_data) - { + { + // dd($export_data); + $ids = []; $objects = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($export_data); + // dd($objects); + $totals = 0; foreach ($objects as $obj) { $ids[] = $obj->endorsement_primarykey; @@ -2932,6 +2936,14 @@ class EmpDataServiceController extends BaseController $batch_code = $file['batch_code']; $user_id = $file['created_by']; + $ref_data = [ + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'client_branch_id' => $client_branch_id, + 'insurer_or_tpa' => $file['insurer_or_tpa'], + 'event_type' => $file['event_type'], + ]; + $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name']; @@ -2963,72 +2975,8 @@ class EmpDataServiceController extends BaseController } } - $db = \Config\Database::connect(); - - $sql = " - SELECT DISTINCT - a.id as endorsement_primarykey, - a.group_key, - employee_polices.id as primaryKey, - employees.name AS emp_name, - employees.emp_code AS emp_code, - employees.dob AS emp_dob, - employees.gender AS emp_gender, - employees.relationship AS emp_relationship, - 'Has Define' as emp_type, - - employee_polices.basic_cover_si, - employee_polices.uhid as risk_id, - employee_polices.policy_end_date, - employee_polices.rata_premimum as premium, - - - deletiondata.empstatus, - deletiondata.changeevent, - deletiondata.dateofexit, - deletiondata.reasonforexit, - deletiondata.status, - - DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) AS no_of_days, - ROUND((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365, 2) AS pro_rata_premium, - ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18, 2) AS gst, - ROUND(((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) + (((employee_polices.rata_premimum * DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit)) / 365) * 0.18), 2) AS total - FROM - emp_endorsement a - LEFT JOIN - employees ON a.emp_code = employees.emp_code and a.pk = employees.id - LEFT JOIN - employee_polices ON employees.id = employee_polices.employee_id - - LEFT JOIN( - - select aa.emp_code, aa.new_value as 'empstatus', bb.new_value as 'changeevent', cc.new_value as 'dateofexit', dd.new_value as 'reasonforexit', ee.new_value as 'status' from - - ( SELECT a1.emp_code, a1.field_name, a1.new_value from emp_endorsement as a1 where a1.field_name = 'emp_status') aa - left join - ( SELECT b1.emp_code, b1.field_name, b1.new_value from emp_endorsement as b1 where b1.field_name = 'change_event') bb on aa.emp_code = bb.emp_code - left join - ( SELECT c1.emp_code, c1.field_name, c1.new_value from emp_endorsement as c1 where c1.field_name = 'date_of_exit') cc on aa.emp_code = cc.emp_code - left join - ( SELECT d1.emp_code, d1.field_name, d1.new_value from emp_endorsement as d1 where d1.field_name = 'reason_for_exit') dd on aa.emp_code = dd.emp_code - left JOIN - ( SELECT e1.emp_code, e1.field_name, e1.new_value from emp_endorsement as e1 where e1.field_name = 'status') ee on aa.emp_code = ee.emp_code - - ) as deletiondata on a.emp_code = deletiondata.emp_code - - WHERE employee_polices.client_policy_id = '$client_policy_id' - AND employees.client_branch_id = '$client_branch_id' - AND a.actions = 'd' - AND employee_polices.is_active = 1 - AND employee_polices.status = 'active' - AND employees.is_active = 1 - AND employees.emp_status = 'active' - AND (a.endorsement_id IS NULL OR a.endorsement_id = '') - group by group_key - "; - - $query = $db->query($sql); - $endorsement_data = $query->getResultArray(); + $objects = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($ref_data, 1); + $endorsement_data = $objects; // dd($endorsement_data); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 5092c22e..7721b203 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1762,9 +1762,11 @@ class EmployeeController extends AdminController public function update_emp_data() { $data = $this->request->getPost(); - - $data['dob'] = date('Y-m-d', strtotime($data['dob'])); - + // print_rr($data); + // $data['dob'] = date('Y-m-d', strtotime($data['dob'])); + $data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d'); + // print_rr($data); die; + // Fetch current employee data $employee_data = $this->employeeModel->where('id', $data['employee_primary_id'])->first(); @@ -1973,5 +1975,50 @@ class EmployeeController extends AdminController return redirect()->back()->with('error', 'Log file not found.'); } + public function exportToExceltpadata() + { + // Create a new Spreadsheet + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + + // Header row + $headers = [ + 'TPA_NAME', 'SHORT_NAME', 'TPA_BRANCH_NAME', 'TPA_BRANCH_CODE', + 'TPA_CONTACT_PERSON_NAME', 'TPA_CONTACT_PERSON_EMAIL', 'TPA_CONTACT_PERSON_MOBILE', + 'TPA_CONTACT_PERSON_DESIGNATION', 'IS_DELETED' + ]; + $sheet->fromArray($headers, NULL, 'A1'); + + // Data rows + $data = [ + ["ICICI Lombard Health Care", "IL Health care", "Chennai", "997133", "Heena", "dharanisri@jubiliant.in", "9043955294", "General Manager", "YES"], + ["ICICI Lombard Health Care", "IL Health care", "Chennai", "997133", "Mahammad shireen", "mahammad.shireen@icicilombard.com", "8655420732", "Claims head", "NO"], + ["Medi Assist Insurance TPA Private Limited", "Medi Assist", "Chennai", "YA0000000348", "Ragavi", "dharanisri@jubiliant.in", "9043955294", "Senior Manager", "YES"], + ["Medi Assist Insurance TPA Private Limited", "Medi Assist", "Chennai", "YA0000000348", "Vijayalakshmi", "vijayalakshmi.c@mediassist.in", "7795542162", "Senior Executive | Account Management", "NO"], + ["Vidal Health Insurance TPA", "Vidal", "Chennai", "YA0000000349", "vijalakshmi", "vijayalakshmi.c@mediassist.in", "7795542162", "Senior Executive", "NO"], + ["Vidal Health Insurance TPA", "Vidal", "Chennai", "YA0000000349", "M.Pushparaj", "pushparaj.moorthy@vidalhealth.com", "8939634456", "Executive", "NO"], + ["Digit in-House", "Digit in-House", "Go Digit General Insurance Ltd", "1", "sathish", "sathish.n@vidalhealth.com", "7823913800", "Senior Executive", "NO"], + ["Digit in-House", "Digit in-House", "Go Digit General Insurance Ltd", "1", "Mr. Pavan", "TK.Pavankumar@godigit.com", "8754490492", "Strategic Partnerships", "NO"], + ["Aditya Birla Health Insurance Co. Limited", "ABHI", "Chennai", "O1", "sathish", "sathish.n@vidalhealth.com", "7823913800", "Senior Executive", "NO"], + ["Aditya Birla Health Insurance Co. Limited", "ABHI", "Chennai", "O1", "Jhonson Kj", "jhonson.kj@adityabirlacapital.com", "9900729513", "Executive", "NO"], + ["Aditya Birla Health Insurance Co. Limited", "ABHI", "Chennai", "01", "Jhonson Kj", "jhonson.kj@adityabirlacapital.com", "9900729513", "Executive", "NO"], + ["R Care Health", "R Care", "Chennai", "01", "Jeevanadam", "Jeevanandam.Kumaran@relianceada.com", "8825982053", "Executive", "NO"], + ["IFFCO-TOKIO GENERAL INSURANCE CO. LTD", "ITGI", "Chennai", "01", "Anjali", "Anjali.K@ext.iffcotokio.co.in", "6374270165", "Senior Executive", "NO"], + ["Star Health and Allied Insurance", "STAR", "Chennai", "110000", "Mr. Vijay Baskar", "vijayabhaskar.m@starhealth.in", "9840905286", "Area Manager", "NO"], + ]; + $sheet->fromArray($data, NULL, 'A2'); + + // Save the file + $filename = 'TPA_Data.xlsx'; + $writer = new Xlsx($spreadsheet); + + // Set headers for download + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); + header('Cache-Control: max-age=0'); + + $writer->save('php://output'); + exit; + } } diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index e2e70696..5e94b340 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -1744,6 +1744,7 @@ class PolicyTransactionController extends BaseController $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(month:$month,year:$year,insurer_id:$file['insurer_id'],insurer_branch_id:$file['branch_id']); // var_dump($source_data);die(); // Kint::dump($source_data);//die(); + // check policy no,insurer and etc in DB for this month // if all good return true, otherwise return false with messssage @@ -1752,34 +1753,37 @@ class PolicyTransactionController extends BaseController $is_row_empty = check_row_is_empty_or_null($excel_row); if(!$is_row_empty) { - break; - } - - $is_source_found = 0; - $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 - $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 - - foreach ($source_data as $source_key => $source_row) - { - if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['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 = 0; + $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 + $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 + + foreach ($source_data as $source_key => $source_row) { - $is_source_found = 1; - unset($source_data[$source_key]); - continue 2; + $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['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']) + { + $is_source_found = 1; + unset($source_data[$source_key]); + continue 2; + } + } + + if($is_source_found == 0) + { + // echo $excel_key.'-'.$excel_row[1] . '- not found
'; + $error_data['error_code'] = 1;//match not found + // $error_data['error_data'] = ($error_data['error_data'] ?? []); + $error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found } - } - if($is_source_found == 0) - { - // echo $excel_key.'-'.$excel_row[1] . '- not found
'; - $error_data['error_code'] = 1;//match not found - // $error_data['error_data'] = ($error_data['error_data'] ?? []); - $error_data['error_data'] = array_merge($error_data['error_data'],[$excel_row[0]]);//match not found } } + + // dd($error_data); + if($error_data['error_code']) { $status = 'failed'; @@ -1850,94 +1854,96 @@ class PolicyTransactionController extends BaseController $is_row_empty = check_row_is_empty_or_null($excel_row); if(!$is_row_empty) { - break; - } - - $is_source_found = 0; - $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 - $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 - - foreach ($source_data as $source_key => $source_row) - { - // Kint::dump(change_date_format($excel_row[3],'d/m/Y','Y-m-d')); - if( ($policy_no == $source_row['policy_no']) && $endorsement_no == $source_row['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 = 0; + $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 + $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 + + foreach ($source_data as $source_key => $source_row) { - $is_source_found = 1; - - //calculate percentage first - $total_amt = 0; - - $actual_bp_per = trim($excel_row[9]); - $actual_bp_brokerage = trim($excel_row[12]); - $actual_bp_amt = trim($excel_row[6]); - - if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) + // Kint::dump(change_date_format($excel_row[3],'d-m-Y','Y-m-d')); + $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['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']) { - $total_amt += $actual_bp_brokerage; - //percentage reverse calculation - if($actual_bp_per == 0 || $actual_bp_per == "") + $is_source_found = 1; + + //calculate percentage first + $total_amt = 0; + + $actual_bp_per = trim($excel_row[9]); + $actual_bp_brokerage = trim($excel_row[12]); + $actual_bp_amt = trim($excel_row[6]); + + if(($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) { - $actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100,2); + $total_amt += $actual_bp_brokerage; + //percentage reverse calculation + if($actual_bp_per == 0 || $actual_bp_per == "") + { + $actual_bp_per = round(($actual_bp_brokerage / $actual_bp_amt) * 100,2); + } + } - - } - else - { - $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100); - $total_amt += $actual_bp_brokerage; - } - - $actual_tp_per = trim($excel_row[10]); - $actual_tp_brokerage = trim($excel_row[13]); - $actual_tp_amt = trim($excel_row[7]); - - if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") - { - $total_amt += $actual_tp_brokerage; - //percentage reverse calculation - if($actual_tp_per == 0 || $actual_tp_per == "") + else { - $actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100; + $actual_bp_brokerage = $actual_bp_amt * ($actual_bp_per / 100); + $total_amt += $actual_bp_brokerage; } - } - else - { - $actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100); - $total_amt += $actual_tp_brokerage; - } - $actual_tep_per = trim($excel_row[11]); - $actual_tep_brokerage = trim($excel_row[14]); - $actual_tep_amt = trim($excel_row[8]); + $actual_tp_per = trim($excel_row[10]); + $actual_tp_brokerage = trim($excel_row[13]); + $actual_tp_amt = trim($excel_row[7]); - if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") - { - $total_amt += $actual_tep_brokerage; - //percentage reverse calculation - if($actual_tep_per == 0 || $actual_tep_per == "") + if($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") { - $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100; + $total_amt += $actual_tp_brokerage; + //percentage reverse calculation + if($actual_tp_per == 0 || $actual_tp_per == "") + { + $actual_tp_per = ($actual_tp_brokerage / $actual_tp_amt) * 100; + } } + else + { + $actual_tp_brokerage = $actual_tp_amt * ($actual_tp_per / 100); + $total_amt += $actual_tp_brokerage; + } + + $actual_tep_per = trim($excel_row[11]); + $actual_tep_brokerage = trim($excel_row[14]); + $actual_tep_amt = trim($excel_row[8]); + + if($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") + { + $total_amt += $actual_tep_brokerage; + //percentage reverse calculation + if($actual_tep_per == 0 || $actual_tep_per == "") + { + $actual_tep_per = ($actual_tep_brokerage / $actual_tep_amt) * 100; + } + } + else + { + $actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100); + $total_amt += $actual_tep_brokerage; + } + + //find variance + $variance_amt = $source_row['exp_amt'] - $total_amt; + + $data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id]; + + unset($source_data[$source_key]); + continue 2; } - else - { - $actual_tep_brokerage = $actual_tep_amt * ($actual_tep_per / 100); - $total_amt += $actual_tep_brokerage; - } - - //find variance - $variance_amt = $source_row['exp_amt'] - $total_amt; - - $data_to_update[] = ['id' => $source_row['id'],'actual_bp_amt' => $actual_bp_amt,'actual_tp_amt' => $actual_tp_amt,'actual_tep_amt' => $actual_tep_amt,'actual_bp_per' => $actual_bp_per,'actual_tp_per' => $actual_tp_per,'actual_tep_per' => $actual_tep_per,'variance' => $variance_amt,'actual_tep_brokerage_amt' => $actual_tep_brokerage,'actual_tp_brokerage_amt' => $actual_tp_brokerage,'actual_bp_brokerage_amt' => $actual_bp_brokerage,'reward' => trim($excel_row[15]),'statement_id' => $file_id]; - - unset($source_data[$source_key]); - continue 2; } + } } + // dd($data_to_update); $this->PTCOShareDetailsModel->updateBatch($data_to_update, 'id'); // dd($data_to_update); // if($error_data['error_code']) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 8d68fc1a..ce177302 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -71,39 +71,43 @@ class UserController extends AdminController $this->userTeamsModel->insert($teamData); } + $db = \Config\Database::connect(); + $tableName = 'hdz_staff'; + + // Set default values + $admin = 0; + $acm = 0; + $acm_id = null; + if ($userData['role'] == 3) { - - $db = \Config\Database::connect(); - $tableName = 'hdz_staff'; $admin = 0; $acm = 1; $acm_id = $insert; - - $password = '12345678'; //Default password - $hashedPassword = password_hash($password, PASSWORD_DEFAULT); - - foreach ($temp_team as $key => $value) { - - $team = $this->teamModel->where('id', $value)->first(); - - if ($team['name'] == 'Claims') { - $hdz_staff = [ - 'emp_code' => $userData['emp_code'], - 'fullname' => $userData['first_name'], - 'username' => strtolower($userData['first_name']), - 'email' => $userData['email'], - 'admin' => $admin, - 'acm' => $acm, - 'acm_id' => $acm_id, - 'registration' => time(), - 'password' => $hashedPassword, - 'active' => 1, - ]; - - $db->table($tableName)->insert($hdz_staff); - } - } + } else if (in_array($userData['role'], [1, 5])) { + $admin = 1; + $acm = 0; + $acm_id = null; } + + $password = '12345678'; // Default password + $hashedPassword = password_hash($password, PASSWORD_DEFAULT); + + $hdz_staff = [ + 'emp_code' => $userData['emp_code'], + 'fullname' => $userData['first_name'], + 'username' => strtolower($userData['first_name']), + 'email' => $userData['email'], + 'admin' => $admin, + 'acm' => $acm, + 'acm_id' => $acm_id, + 'registration' => time(), + 'password' => $hashedPassword, + 'active' => 1, + 'department' => 'a:7:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"5";i:3;s:1:"3";i:4;s:1:"9";i:5;s:1:"4";i:6;s:2:"10";}', + ]; + + $db->table($tableName)->insert($hdz_staff); + } } $this->myLogger->logme('error', 'User create Successfully created by id {data}', ['data' => get_session_userid()]); @@ -149,33 +153,55 @@ class UserController extends AdminController } } + $db = \Config\Database::connect(); + $tableName = 'hdz_staff'; + + $hdz_staff = [ + 'emp_code' => $userData['emp_code'], + 'fullname' => $userData['first_name'], + 'username' => strtolower($userData['first_name']), + 'email' => $userData['email'], + 'registration' => time(), + 'active' => 1, + 'department' => 'a:7:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"5";i:3;s:1:"3";i:4;s:1:"9";i:5;s:1:"4";i:6;s:2:"10";}', + ]; + if ($userData['role'] == 3) { - - $db = \Config\Database::connect(); - $tableName = 'hdz_staff'; - $admin = 1; - - foreach ($userData['team'] as $key => $value) { - if ($value == 2) { - - $hdz_staff = [ - 'emp_code' => $userData['emp_code'], - 'fullname' => $userData['first_name'], - 'username' => strtolower($userData['first_name']), - 'email' => $userData['email'], - 'admin' => $admin, - 'registration' => time(), - 'active' => 1, - ]; - - $db->table($tableName)->where('emp_code', $userData['emp_code']) - ->where('email', $userData['email']) - ->set($hdz_staff) - ->update(); - } - } - + $hdz_staff['admin'] = 0; + $hdz_staff['acm'] = 1; + $hdz_staff['acm_id'] = $id; + } elseif (in_array($userData['role'], [1, 5])) { + $hdz_staff['admin'] = 1; + $hdz_staff['acm'] = 0; + $hdz_staff['acm_id'] = null; + } else { + + return redirect()->to(base_url('/user/list')); } + + // Check if staff data exists + $staffData = $db->table($tableName) + // ->where('emp_code', $userData['emp_code']) + ->where('email', $userData['email']) + ->get()->getResult(); + + if (!empty($staffData)) { + + // Update existing record + $db->table($tableName) + // ->where('emp_code', $userData['emp_code']) + ->where('email', $userData['email']) + ->set($hdz_staff)->update(); + + } else { + + $password = '12345678'; // Default password + $hdz_staff['password'] = password_hash($password, PASSWORD_DEFAULT); + + // Insert new record + $db->table($tableName)->insert($hdz_staff); + } + } return redirect()->to(base_url('/user/list')); diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index cb87e28f..3ac48a4d 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -203,6 +203,7 @@ class sendMailNotification $temp_data = ''; $policy_name = ''; $is_addon = ''; + $rowspan = count($item) ?? 2; foreach ($item as $inner_item) { @@ -215,8 +216,10 @@ class sendMailNotification } //end of getting policy premium data + // dd($policy_premium_data); + if($inner_item['payable_employee'] == 1 && $client_policy_data['policy_type_id'] == 2){ - $payable_employee_array[] = $inner_item; + $payable_employee_array['emp_data'][] = $inner_item; } // dd($policy_premium_data); @@ -235,7 +238,18 @@ class sendMailNotification $gst_forself = ''; // if(checkFamilyFloaters($policy_premium_data, $client_policy_data, $inner_item)){ - $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + + if($policy_premium_data['premium_type'] == 2){ + $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + }else{ + if ($inner_item['relationship'] == 'Self') { + $payable_employee_array['si_amount'] = $inner_item['basic_cover_si']; + $payable_employee_array['self_premium'] = $inner_item['rata_premimum']; + $payable_employee_array['self_gst'] = $inner_item['gst']; + } + empty($inner_item['basic_cover_si']) ? $si = 0 : $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + } + $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); // } @@ -244,8 +258,13 @@ class sendMailNotification $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; - $temp_data .= '' . $si . ''; - + + if($policy_premium_data['premium_type'] == 2){ + $temp_data .= '' . $si . ''; + }else{ + $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '') ); + } + // Only Display SI Topup and Dependent Addon if ($inner_item['is_addon'] == 2 || $inner_item['is_addon'] == 3) { $temp_data .= '' . $premium . ''; @@ -305,14 +324,24 @@ class sendMailNotification $gst = 0; } - if(count($payable_employee_array) > 0){ + // dd($payable_employee_array); + // dd(count($payable_employee_array['emp_data'])); + + if(count($payable_employee_array['emp_data']) > 0){ $table_content .= '

Policy Type :'; $temp_data = ''; $is_addon = ''; - - foreach ($payable_employee_array as $inner_item) { + $rowspan = count($payable_employee_array['emp_data']) ?? 2; + $self_si_amount = $payable_employee_array['si_amount'] ?? 0; + $self_premium = $payable_employee_array['self_premium'] ?? 0; + $self_gst = $payable_employee_array['self_gst'] ?? 0; + + + // dd($payable_employee_array['si_amount'], $self_si_amount); + + foreach ($payable_employee_array['emp_data'] as $inner_item) { //getting policy premium data $client_policy_data = $clientPolicyModel->where('id', $inner_item['client_policy_id'])->first(); @@ -323,22 +352,63 @@ class sendMailNotification } //end of getting policy premium data + // dd($policy_premium_data); $si = ''; $premium = ''; $gst_forself = ''; - $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); - $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); - $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); + if($policy_premium_data['premium_type'] == 2){ + $si = '₹ ' .format_indian_number($inner_item['basic_cover_si']); + }else{ + empty($self_si_amount) ? $si = 0 : $si = '₹ ' .format_indian_number($self_si_amount); + } + + if($policy_premium_data['premium_type'] == 1){ + + empty($self_premium) ? $premium = 0 : $premium = '₹ ' .format_indian_number($self_premium); + empty($self_gst) ? $gst_forself = 0 : $gst_forself = '₹ ' .format_indian_number($self_gst); + + }else{ + + $premium = '₹ ' .format_indian_number(round($inner_item['rata_premimum'])); + $gst_forself = '₹ ' .format_indian_number(round($inner_item['gst'])); + + } $temp_data .= ''; $temp_data .= '' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . ''; $temp_data .= '' . $inner_item['relationship'] . ''; $temp_data .= '' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . ''; - $temp_data .= '' . $si . ''; - $temp_data .= '' . $premium . ''; - $temp_data .= '' . $gst_forself . ''; + + // dd($si); + + if($policy_premium_data['premium_type'] == 2){ + + $temp_data .= '' . $si . ''; + $temp_data .= '' . $premium . ''; + $temp_data .= '' . $gst_forself . ''; + + }else{ + + if($policy_premium_data['premium_type'] == 1){ + + $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '') ); + $temp_data .= (($premium != 0 && count($item) != 1) ? ('' . $premium . '') : ($premium == 0 ? "" : '' . $premium . '') ); + $temp_data .= (($gst_forself != 0 && count($item) != 1) ? ('' . $gst_forself . '') : ($gst_forself == 0 ? "" : '' . $gst_forself . '') ); + + }else{ + + $temp_data .= (($si != 0 && count($item) != 1) ? ('' . $si . '') : ($si == 0 ? "" : '' . $si . '') ); + $temp_data .= '' . $premium . ''; + $temp_data .= '' . $gst_forself . ''; + } + + $self_si_amount = 0; + $self_premium = 0; + $self_gst = 0; + } + $temp_data .= ''; diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 7ed17d10..cd68444d 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -54,6 +54,39 @@ class ClientPolicyModel extends Model "is_member_modify_allowed", ]; + // Callbacks + protected $allowCallbacks = true; + protected $beforeInsert = ["checkAndADDCreatedByValue"]; + protected $afterInsert = []; + protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"]; + protected $afterUpdate = []; + protected $beforeFind = []; + protected $afterFind = []; + protected $beforeDelete = []; + protected $afterDelete = []; + + protected function checkAndADDCreatedByValue(array $data) + { + // Check if 'updated_by' value is null or empty + if (empty($data['data']['created_by'])) { + // Set 'updated_by' value to the current session user ID + $data['data']['created_by'] = get_session_userid(); + } + + return $data; + } + + protected function checkAndUpdateUpdatedByValue(array $data) + { + // Check if 'updated_by' value is null or empty + if (empty($data['data']['updated_by'])) { + // Set 'updated_by' value to the current session user ID + $data['data']['updated_by'] = get_session_userid(); + } + + return $data; + } + public function getClientPolicyById($id){ return $this->db->table('client_policy') diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 2eda9d79..9d281507 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -557,7 +557,7 @@ class EmployeePolicyModel extends Model } - public function getDeletionEmployeeDataForExportExcel($ref_data) + public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0) { $client_id = $ref_data['client_id']; @@ -618,8 +618,7 @@ class EmployeePolicyModel extends Model employee_polices.basic_cover_si, employee_polices.uhid as uhid, employee_polices.policy_end_date, - employee_polices.premium, - employee_polices.rata_premimum as pro_rata_premium, + employee_polices.rata_premimum as premium, employee_polices.claim_status, batch_data.emp_policy_id AS emp_policy_id, @@ -714,9 +713,14 @@ class EmployeePolicyModel extends Model group by group_key "); - $result = $query->getResult(); + if($return_type == 1){ + $result = $query->getResultArray(); + }else{ + $result = $query->getResult(); + } // dd($this->db->getLastQuery(), $result); + return $result; } diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php index 7a3b3911..9d5fd143 100755 --- a/app/Views/client_policy.php +++ b/app/Views/client_policy.php @@ -257,7 +257,6 @@ } }) - var policy_PrimaryKey = $('#client_id_policy').val(); var policy_client = $('#policy_PrimaryKey').val(); diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index e023579b..97943e91 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -217,7 +217,7 @@
- +

@@ -264,7 +264,7 @@ $(document).ready(function(){ var dob = flatpickr("#dob", { - dateFormat: "d/m/Y", + dateFormat: "d/M/Y", allowInput: false }); }) diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index 4407c302..1c41c568 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -332,7 +332,7 @@ table.dataTable tbody td { - + @@ -515,13 +515,13 @@ table.dataTable tbody td { - + `; tableBody.appendChild(newRow); $('.payment_date').datepicker({ - format: 'dd-mm-yyyy', + format: 'dd/mm/yyyy', autoclose: true }); }); @@ -579,15 +579,16 @@ function formatDate(date) { var day = ("0" + date.getDate()).slice(-2); var month = ("0" + (date.getMonth() + 1)).slice(-2); var year = date.getFullYear(); - return day + "-" + month + "-" + year; + return day + "/" + month + "/" + year; } function formatDateToDMY(dateStr) { // Split the date string by the hyphen var parts = dateStr.split('-'); - return parts[2] + '-' + parts[1] + '-' + parts[0]; // Rearrange to DD-MM-YYYY + return parts[2] + '/' + parts[1] + '/' + parts[0]; // Rearrange to DD-MM-YYYY } function showInvoiceStatusModal(event) { + console.log('############ showInvoiceStatusModal function called ##################'); var modal_received_amt_div = document.getElementById('modal_received_amt_div'); modal_received_amt_div.style.display = 'none'; // alert(); @@ -635,7 +636,7 @@ function showInvoiceStatusModal(event) // Clear existing rows in the payment table var paymentTableBody = document.querySelector('#payment_table_modal tbody'); - + console.log('response.data.payments.length', response.data.payments.length) // Populate payment table rows if(response.data.payments.length) { @@ -652,7 +653,7 @@ function showInvoiceStatusModal(event) `; }); } - $('.payment_date').datepicker({ format: 'dd-mm-yyyy',autoclose: true}); + $('.payment_date').datepicker({ format: 'dd/mm/yyyy',autoclose: true}); // Show the modal var myModal = new bootstrap.Modal(document.getElementById('invoice_modal')); myModal.show(); @@ -690,7 +691,7 @@ $(document).ready(function(){ $('.payment_date').datepicker({ - format: 'dd-mm-yyyy', + format: 'dd/mm/yyyy', autoclose: true }); @@ -705,7 +706,7 @@ minDate.setDate(today.getDate() - 180); var maxDate = new Date(); maxDate.setDate(today.getDate() + 180); $('#invoice_date_modal').datepicker({ - format: 'dd-mm-yyyy', + format: 'dd/mm/yyyy', autoclose: true, startDate: minDate, endDate: maxDate diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index ff2b1925..bd141858 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -39,6 +39,7 @@ .form-group-client-policy-masters { display: -webkit-box; max-width: 100% !important; + margin-left: -23px; } .flex-container { @@ -85,9 +86,9 @@ } .s { - /* margin-left: 30px; - width: 689px; */ - margin-left: 141px; + margin-left: 50px; + /* width: 689px; */ + /* margin-left: 141px; */ width: 576px; } @@ -221,6 +222,9 @@
+
+ +
@@ -231,6 +235,9 @@
-
+
+ +
@@ -278,6 +296,9 @@
+
+ +
@@ -287,6 +308,9 @@
+
+ +
@@ -298,6 +322,9 @@
+
+ +
@@ -308,6 +335,9 @@
+
+ +
@@ -317,6 +347,9 @@
+
+ +
@@ -326,6 +359,9 @@
+
+ +
@@ -336,6 +372,9 @@
+
+ +
@@ -345,6 +384,9 @@
+
+ +
@@ -354,7 +396,10 @@
- - - -