diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 81be817..4edaa27 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -156,6 +156,8 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) { $routes->get("test-rack-rate", "EmployeeController::testRackRate"); $routes->post("test-rack-rate", "EmployeeController::testRackRate"); $routes->get('test_members_list', 'EmployeeController::test_members_list'); + $routes->post('get_emp_history','EmployeeController::getEmpHistory'); + }); $routes->group("/master", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 8fb1ea0..eb2bef5 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1021,7 +1021,12 @@ class ClientController extends AdminController $insurerValue = (string) $this->request->getPost('insurer'); - list($insurerBranchId, $insurerId) = explode('-', $insurerValue); + if ($insurerValue === null || $insurerValue === '') { + $insurerBranchId = null; + $insurerId = null; + } else { + list($insurerBranchId, $insurerId) = explode('-', $insurerValue); + } $data['insurer_branch_id'] = $insurerBranchId; @@ -2066,9 +2071,12 @@ class ClientController extends AdminController } } + // ---------------- POLICY TREMS ------------------------------------------------------------------------------------ + public function policyGMCTerms() { try { + // echo "
";
             // print_r($this->request->getPost());die;
             $this->myLogger->logme('error', 'Terms CREATE function called');
@@ -2078,7 +2086,6 @@ class ClientController extends AdminController
 
             $data['sum_insured']   = str_replace(',', '', $this->request->getPost("sum_insured"));
             $data['family_floater']   = $this->request->getPost("family_floater") ? $this->request->getPost("family_floater") : 0;
-            // $data['corporatebuffer'] = $this->request->getPost("corporatebuffer") ? $this->request->getPost("corporatebuffer") : 0;
             $data['family_floaters'] = $this->request->getPost("family_floaters") ?? [];
 
             $data['age_ratio']['self']['min'] =  $this->request->getPost("self_min_age") ? $this->request->getPost("self_min_age") : 0;
@@ -2096,12 +2103,9 @@ class ClientController extends AdminController
             $data['is_payable_employee']['elders'] = $this->request->getPost("is_payable_employee_for_elders") ? 1 : 0;
 
 
-
-            // if (!in_array("self", $data['family_floaters'])) {
-            //     array_unshift($data['family_floaters'], "self");
-            // }
             $temp_family_floaters = $data['family_floaters'];
             $data['family_floaters'] = [];
+
             if (in_array("self", $temp_family_floaters) == 1) {
                 $data['family_floaters']['self'] = 1;
             } else {
@@ -2114,8 +2118,6 @@ class ClientController extends AdminController
                 $data['family_floaters']['spouse'] = 0;
             }
 
-            // $data['family_floaters']['either-parents-pil'] =0;
-
             if (count($temp_family_floaters)) {
                 $children_value = 0;
                 $value = 0;
@@ -2174,79 +2176,55 @@ class ClientController extends AdminController
             // print_r($data);die;
 
             $data['waiverofpreexistingdiseases']   = $this->request->getPost("waiverofpreexistingdiseases");
-            if ($data['waiverofpreexistingdiseases'] == 1) {
-                $data['maternitycoverage']   = str_replace(',', '', $this->request->getPost("maternitycoverage"));
-                $data['twindelivery']   = str_replace(',', '', $this->request->getPost("twindelivery"));
-                $data['preandpostnatal']   = str_replace(',', '', $this->request->getPost("preandpostnatal"));
-                $data['babyday1cover']   = str_replace(',', '', $this->request->getPost("babyday1cover"));
-            } else {
-                $data['maternitycoverage']   = "";
-                $data['twindelivery']   = "";
-                $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");
             $data['waiverof30dayswaitingperiod'] = $this->request->getPost("waiverof30dayswaitingperiod");
+            $data['waiver_of_90_days_waiting_period'] = $this->request->getPost("waiver_of_90_days_waiting_period");
+            $data['waiver_of_other_waiting_periods'] = $this->request->getPost("waiver_of_other_waiting_periods");
+            $data['maternity_benefit'] = $this->request->getPost("maternity_benefit");
+            $data['9monthwaitingperiodwaived'] = str_replace(',', '', $this->request->getPost("9monthwaitingperiodwaived"));
+            $data['maternitycoverage']   = str_replace(',', '', $this->request->getPost("maternitycoverage"));
+            $data['twindelivery']   = str_replace(',', '', $this->request->getPost("twindelivery"));
+            $data['well_baby_well_mother_expenses']   = str_replace(',', '', $this->request->getPost("well_baby_well_mother_expenses"));
+            $data['preandpostnatal']   = str_replace(',', '', $this->request->getPost("preandpostnatal"));
+            $data['infertility_treatment_coverage']   = str_replace(',', '', $this->request->getPost("infertility_treatment_coverage"));
+            $data['babyday1cover']   = str_replace(',', '', $this->request->getPost("babyday1cover"));
+            $data['coverfromthedateofjoining'] = str_replace(',', '', $this->request->getPost("coverfromthedateofjoining"));
+            $data['mid_term_addition_of_new_born_newly_wedded_spouse'] = str_replace(',', '', $this->request->getPost("mid_term_addition_of_new_born_newly_wedded_spouse"));
             $data['prehospitalizationcover'] = str_replace(',', '', $this->request->getPost("prehospitalizationcover"));
-            // $data['posthospitalizationcover'] =$this->request->getPost("posthospitalizationcover");
+            $data['posthospitalizationcover'] =$this->request->getPost("posthospitalizationcover");
             $data['congenitaldiseasesinternal'] = str_replace(',', '', $this->request->getPost("congenitaldiseasesinternal"));
-            // $data['congenitaldiseasesexternal'] =$this->request->getPost("congenitaldiseasesexternal");
+            $data['congenitaldiseasesexternal'] = str_replace(',', '', $this->request->getPost("congenitaldiseasesexternal"));
             $data['copayzonewisecopay'] = $this->request->getPost("copayzonewisecopay");
-            $data['co_pay_details'] = str_replace(',', '', $this->request->getPost("co_pay_details"));
-
-            $data['bioabsorbablestenttoriclensmultifocallens'] = $this->request->getPost("bioabsorbablestenttoriclensmultifocallens");
             $data['roomrentlimit'] = str_replace(',', '', $this->request->getPost("roomrentlimit"));
+            $data['icu_limit'] = str_replace(',', '', $this->request->getPost("icu_limit"));
             $data['proportionatedeductionclause'] = str_replace(',', '', $this->request->getPost("proportionatedeductionclause"));
-            // $data['nursingallowance'] =str_replace(',', '',$this->request->getPost("nursingallowance"));
             $data['ailmentcapping'] = $this->request->getPost("ailmentcapping");
             $data['ailment_capping_details'] = str_replace(',', '', $this->request->getPost("ailment_capping_details"));
-
+            $data['corporatebuffer'] = str_replace(',', '', $this->request->getPost("corporatebuffer"));
+            $data['non_admissible_contingency_corporate_buffer'] = str_replace(',', '', $this->request->getPost("non_admissible_contingency_corporate_buffer"));
             $data['ambulancecharges'] = str_replace(',', '', $this->request->getPost("ambulancecharges"));
             $data['airambulance'] = str_replace(',', '', $this->request->getPost("airambulance"));
-            $data['familytransportationbenefit'] = str_replace(',', '', $this->request->getPost("familytransportationbenefit"));
             $data['reasonableandcustomarycharges'] = str_replace(',', '', $this->request->getPost("reasonableandcustomarycharges"));
             $data['daycaretreatment'] = str_replace(',', '', $this->request->getPost("daycaretreatment"));
-            $data['ayudhtreatmentcover'] = str_replace(',', '', $this->request->getPost("ayudhtreatmentcover"));
-
-            $data['congenitaldiseasesexternal'] = str_replace(',', '', $this->request->getPost("congenitaldiseasesexternal"));
-            // $data['optionalparentalcopay'] = str_replace(',', '', $this->request->getPost("optionalparentalcopay"));
-            $data['posthospitalizationcover'] = str_replace(',', '', $this->request->getPost("posthospitalizationcover"));
-            $data['corporatebuffer'] = str_replace(',', '', $this->request->getPost("corporatebuffer"));
-            $data['sublimitofcorporatebuffer'] = str_replace(',', '', $this->request->getPost("sublimitofcorporatebuffer"));
-
-            if ($data['ayudhtreatmentcover'] == 1) {
-                $data['ayushTreatmentCoverData']   = str_replace(',', '', $this->request->getPost("ayushTreatmentCoverData"));
-            } else {
-                $data['ayushTreatmentCoverData']   = "";
-            }
-
-            $data['armdcovered'] = str_replace(',', '', $this->request->getPost("armdcovered"));
-            $data['suminsuredenhancement'] = str_replace(',', '', $this->request->getPost("suminsuredenhancement"));
-            $data['automaticsuminsuredreinstatement'] = str_replace(',', '', $this->request->getPost("automaticsuminsuredreinstatement"));
-            $data['additionalsicknessbenefit'] = str_replace(',', '', $this->request->getPost("additionalsicknessbenefit"));
             $data['lasiksurgery'] = str_replace(',', '', $this->request->getPost("lasiksurgery"));
-            $data['midterminclusion'] = str_replace(',', '', $this->request->getPost("midterminclusion"));
-            $data['capd'] = str_replace(',', '', $this->request->getPost("capd"));
-            $data['organdonorexpenses'] = str_replace(',', '', $this->request->getPost("organdonorexpenses"));
+            $data['ayudhtreatmentcover'] = str_replace(',', '', $this->request->getPost("ayudhtreatmentcover"));
             $data['moderntreatmentsasperirdai'] = str_replace(',', '', $this->request->getPost("moderntreatmentsasperirdai"));
-            $data['Wellness'] = str_replace(',', '', $this->request->getPost("Wellness"));
+            $data['opd_treatment'] = str_replace(',', '', $this->request->getPost("opd_treatment"));
             $data['days_of_discharge'] = str_replace(',', '', $this->request->getPost("days_of_discharge"));
             $data['days_from_dod'] = str_replace(',', '', $this->request->getPost("days_from_dod"));
+            $data['terrorism'] = str_replace(',', '', $this->request->getPost("terrorism"));
+            $data['widower_cover'] = str_replace(',', '', $this->request->getPost("widower_cover"));
+            $data['breavement_cover'] = str_replace(',', '', $this->request->getPost("breavement_cover"));
+
+            $data['suminsuredenhancement'] = str_replace(',', '', $this->request->getPost("suminsuredenhancement"));
+
             $data['special_condition_label'] = str_replace(',', '', $this->request->getPost("special_condition_label")) ?? [];
             $data['special_condition_input'] = str_replace(',', '', $this->request->getPost("special_condition_input")) ?? [];
             $data['multiple_sum_insured'] = str_replace(',', '', $this->request->getPost("multiple_sum_insured")) ?? [];
 
-            $data['cataract'] = str_replace(',', '', $this->request->getPost("cataract"));
-
-            if ($data['cataract'] == 1) {
-                $data['cataractData']   = str_replace(',', '', $this->request->getPost("cataractData"));
-            } else {
-                $data['cataractData']   = "";
-            }
+            $data['enrollment_display_key'] = $this->enrollmentGMCDisplayValueTransform();
 
+            // print_r($data);die;
 
             $jsonData = json_encode($data);
             $dataa = array(
@@ -2255,7 +2233,6 @@ class ClientController extends AdminController
 
             $record = $this->clientPolicyModel->where('id', $client_policy_id)->first();
 
-
             // print_r($data);die;
             if ($record) {
                 $update = $this->clientPolicyModel->update($client_policy_id, $dataa);
@@ -2280,6 +2257,190 @@ class ClientController extends AdminController
         }
     }
 
+    public function enrollmentGMCDisplayValueTransform()
+    {
+        $data = [];
+
+        if ($this->request->getPost("waiverofpreexistingdiseases_display")) {
+            $data['Waiver of Pre-existing Diseases'] = $this->request->getPost("waiverofpreexistingdiseases");
+        }
+        
+        if ($this->request->getPost("waiverof1234thyearexclusions_display")) {
+            $data['Waiver of 1, 2, 3 & 4th year Exclusions'] = $this->request->getPost("waiverof1,2,3&4thyearexclusions");
+        }
+        
+        if ($this->request->getPost("waiverof30dayswaitingperiod_display")) {
+            $data['Waiver of 30 days waiting period'] = $this->request->getPost("waiverof30dayswaitingperiod");
+        }
+        
+        if ($this->request->getPost("waiver_of_90_days_waiting_period_display")) {
+            $data['Waiver of 90 Days Waiting Period'] = $this->request->getPost("waiver_of_90_days_waiting_period");
+        }
+        
+        if ($this->request->getPost("waiver_of_other_waiting_periods_display")) {
+            $data['Waiver of Other Waiting Periods'] = $this->request->getPost("waiver_of_other_waiting_periods");
+        }
+        
+        if ($this->request->getPost("maternity_benefit_display")) {
+            $data['Maternity Benefit'] = $this->request->getPost("maternity_benefit");
+        }
+        
+        if ($this->request->getPost("9monthwaitingperiodwaived_display")) {
+            $data['9-month waiting Period - waived'] = $this->request->getPost("9monthwaitingperiodwaived");
+        }
+        
+        if ($this->request->getPost("maternitycoverage_display")) {
+            $data['Maternity Coverage'] = $this->request->getPost("maternitycoverage");
+        }
+        
+        if ($this->request->getPost("twindelivery_display")) {
+            $data['Twin Delivery'] = $this->request->getPost("twindelivery");
+        }
+        
+        if ($this->request->getPost("well_baby_well_mother_expenses_display")) {
+            $data['Well baby / Well Mother Expenses'] = $this->request->getPost("well_baby_well_mother_expenses");
+        }
+        
+        if ($this->request->getPost("preandpostnatal_display")) {
+            $data['Pre and Post natal'] = $this->request->getPost("preandpostnatal");
+        }
+        
+        if ($this->request->getPost("infertility_treatment_coverage_display")) {
+            $data['Infertility Treatment Coverage'] = $this->request->getPost("infertility_treatment_coverage");
+        }
+        
+        if ($this->request->getPost("babyday1cover_display")) {
+            $data['Baby Day 1 Cover'] = $this->request->getPost("babyday1cover");
+        }
+        
+        if ($this->request->getPost("coverfromthedateofjoining_display")) {
+            $data['Cover from the date of Joining'] = $this->request->getPost("coverfromthedateofjoining");
+        }
+        
+        if ($this->request->getPost("mid_term_addition_of_new_born_newly_wedded_spouse_display")) {
+            $data['Mid Term Addition of New Born / Newly Wedded Spouse'] = $this->request->getPost("mid_term_addition_of_new_born_newly_wedded_spouse");
+        }
+        
+        if ($this->request->getPost("prehospitalizationcover_display")) {
+            $data['Pre Hospitalization Cover'] = $this->request->getPost("prehospitalizationcover");
+        }
+        
+        if ($this->request->getPost("posthospitalizationcover_display")) {
+            $data['Post Hospitalization Cover'] = $this->request->getPost("posthospitalizationcover");
+        }
+        
+        if ($this->request->getPost("congenitaldiseasesinternal_display")) {
+            $data['Congenital Diseases - Internal'] = $this->request->getPost("congenitaldiseasesinternal");
+        }
+        
+        if ($this->request->getPost("congenitaldiseasesexternal_display")) {
+            $data['Congenital Diseases - External'] = $this->request->getPost("congenitaldiseasesexternal");
+        }
+        
+        if ($this->request->getPost("copayzonewisecopay_display")) {
+            $data['Co-Pay/Zone wise Co Pay'] = $this->request->getPost("copayzonewisecopay");
+        }
+        
+        if ($this->request->getPost("roomrentlimit_display")) {
+            $data['Room Rent Limit'] = $this->request->getPost("roomrentlimit");
+        }
+        
+        if ($this->request->getPost("icu_limit_display")) {
+            $data['ICU Limit'] = $this->request->getPost("icu_limit");
+        }
+        
+        if ($this->request->getPost("proportionatedeductionclause_display")) {
+            $data['Proportionate Deduction Clause'] = $this->request->getPost("proportionatedeductionclause");
+        }
+        
+        if ($this->request->getPost("ailmentcapping_display")) {
+            $data['Ailment capping'] = $this->request->getPost("ailmentcapping");
+        }
+        
+        if ($this->request->getPost("ailment_capping_details_display")) {
+            $data['Ailment capping Details'] = $this->request->getPost("ailment_capping_details");
+        }
+        
+        if ($this->request->getPost("corporatebuffer_display")) {
+            $data['Corporate Buffer'] = $this->request->getPost("corporatebuffer");
+        }
+        
+        if ($this->request->getPost("non_admissible_contingency_corporate_buffer_display")) {
+            $data['Non-Admissible / Contingency Corporate Buffer'] = $this->request->getPost("non_admissible_contingency_corporate_buffer");
+        }
+        
+        if ($this->request->getPost("ambulancecharges_display")) {
+            $data['Ambulance Charges'] = $this->request->getPost("ambulancecharges");
+        }
+        
+        if ($this->request->getPost("airambulance_display")) {
+            $data['Air Ambulance'] = $this->request->getPost("airambulance");
+        }
+        
+        if ($this->request->getPost("reasonableandcustomarycharges_display")) {
+            $data['Reasonable and Customary Charges'] = $this->request->getPost("reasonableandcustomarycharges");
+        }
+        
+        if ($this->request->getPost("daycaretreatment_display")) {
+            $data['Day Care Treatment'] = $this->request->getPost("daycaretreatment");
+        }
+        
+        if ($this->request->getPost("lasiksurgery_display")) {
+            $data['Lasik Surgery'] = $this->request->getPost("lasiksurgery");
+        }
+        
+        if ($this->request->getPost("ayushtreatmentcover_display")) {
+            $data['AYUSH treatment cover'] = $this->request->getPost("ayudhtreatmentcover");
+        }
+        
+        if ($this->request->getPost("moderntreatmentsasperirdai_display")) {
+            $data['Modern treatments as per IRDAI'] = $this->request->getPost("moderntreatmentsasperirdai");
+        }
+        
+        if ($this->request->getPost("opd_treatment_display")) {
+            $data['OPD Treatment'] = $this->request->getPost("opd_treatment");
+        }
+        
+        if ($this->request->getPost("days_of_discharge_display")) {
+            $data['Claim Intimation Clause'] = $this->request->getPost("days_of_discharge");
+        }
+        
+        if ($this->request->getPost("days_from_dod_display")) {
+            $data['Claim Submission'] = $this->request->getPost("days_from_dod");
+        }
+        
+        if ($this->request->getPost("terrorism_display")) {
+            $data['Terrorism'] = $this->request->getPost("terrorism");
+        }
+        
+        if ($this->request->getPost("widower_cover_display")) {
+            $data['Widower Cover'] = $this->request->getPost("widower_cover");
+        }
+        
+        if ($this->request->getPost("breavement_cover_display")) {
+            $data['Breavement Cover'] = $this->request->getPost("breavement_cover");
+        }
+
+        if ($this->request->getPost("special_condition_display_value")) {
+            
+            $specialConditionKeyValue = $this->request->getPost("special_condition_display_value") ?? [];
+            $specialConditionKeyValue = json_decode($specialConditionKeyValue, true);
+
+            if (is_array($specialConditionKeyValue) && count($specialConditionKeyValue) > 0) {
+                $mergedArray = array_merge(...array_map(fn($item) => (array) $item, $specialConditionKeyValue));
+                $data = array_merge($data, $mergedArray);
+            }
+        }
+        
+        if(isset($data) && !empty($data)){
+            return $data;
+        }else{
+            $data = [];
+            return $data;
+        }
+    
+    }
+
     public function getterms()
     {
         $client_policy_id = $this->request->getVar('client_policy_id');
@@ -2332,52 +2493,32 @@ class ClientController extends AdminController
             $data['permanentTotalDisablement'] = str_replace(',', '', $this->request->getPost("permanentTotalDisablement"));
             $data['permanentPartialDisablement'] = $this->request->getPost("permanentPartialDisablement");
             $data['temporaryTotalDisablementBenefit'] = $this->request->getPost("temporaryTotalDisablementBenefit");
-            $data['accidentalHospitalizationExpenses'] = str_replace(',', '', $this->request->getPost("accidentalHospitalizationExpenses"));
-            $data['childrenEducationWelfareFund'] = str_replace(',', '', $this->request->getPost("childrenEducationWelfareFund"));
-
-            $data['compassionateVisitExpenses']   = $this->request->getPost("compassionateVisitExpenses");
-            if ($data['compassionateVisitExpenses'] == 1) {
-                $data['compassionateVisitExpensesData']   = $this->request->getPost("compassionateVisitExpensesData");
-            } else {
-                $data['compassionateVisitExpensesData']   = "";
-            }
-
-            $data['brokenBoneExpenses']   = str_replace(',', '', $this->request->getPost("brokenBoneExpenses"));
-            if ($data['brokenBoneExpenses'] == 1) {
-                $data['brokenBoneExpensesData']   = str_replace(',', '', $this->request->getPost("brokenBoneExpensesData"));
-            } else {
-                $data['brokenBoneExpensesData']   = "";
-            }
-
+            $data['medical_expenses_medical_extension'] = str_replace(',', '', $this->request->getPost("medical_expenses_medical_extension"));
+            $data['opd_treatment_cover'] = str_replace(',', '', $this->request->getPost("opd_treatment_cover"));
             $data['ambulanceCharges']   = str_replace(',', '', $this->request->getPost("ambulanceCharges"));
-            if ($data['ambulanceCharges'] == 1) {
-                $data['ambulanceChargesData']   = str_replace(',', '', $this->request->getPost("ambulanceChargesData"));
-            } else {
-                $data['ambulanceChargesData']   = "";
-            }
-
-            $data['burnExpenses']   = $this->request->getPost("burnExpenses");
-            if ($data['burnExpenses'] == 1) {
-                $data['burnExpensesData']   = $this->request->getPost("burnExpensesData");
-            } else {
-                $data['burnExpensesData']   = "";
-            }
-
-            $data['carriageOfDeadBody']   = $this->request->getPost("carriageOfDeadBody");
-            if ($data['carriageOfDeadBody'] == 1) {
-                $data['carriageOfDeadBodyData']   = $this->request->getPost("carriageOfDeadBodyData");
-            } else {
-                $data['carriageOfDeadBodyData']   = "";
-            }
-
-            $data['animalSnakeInsectBite'] = $this->request->getPost("animalSnakeInsectBite");
+            $data['repatriation_of_mortal_remains']   = str_replace(',', '', $this->request->getPost("repatriation_of_mortal_remains"));
+            $data['childrenEducationWelfareFund'] = str_replace(',', '', $this->request->getPost("childrenEducationWelfareFund"));
             $data['terrorism']             = $this->request->getPost("terrorism");
             $data['worldwideCover']        = $this->request->getPost("worldwideCover");
+            $data['family_transportation_benefits']        = $this->request->getPost("family_transportation_benefits");
+            $data['fractures_dislocation_burns']        = $this->request->getPost("fractures_dislocation_burns");
+            $data['coma']        = $this->request->getPost("coma");
+            $data['carriageOfDeadBody']   = $this->request->getPost("carriageOfDeadBody");
+            $data['compassionateVisitExpenses']   = $this->request->getPost("compassionateVisitExpenses");
+            $data['travel_expenses_for_medical_treatment']        = $this->request->getPost("travel_expenses_for_medical_treatment");
+            $data['daily_cash_allowance']        = $this->request->getPost("daily_cash_allowance");
+            $data['artifical_limb_and_prosthesis']        = $this->request->getPost("artifical_limb_and_prosthesis");
+            $data['animalSnakeInsectBite']        = $this->request->getPost("animalSnakeInsectBite");
+            $data['air_ambulance']        = $this->request->getPost("air_ambulance");
+
+
             $data['gpa_special_condition_label'] = str_replace(',', '', $this->request->getPost("gpa_special_condition_label")) ?? [];
             $data['gpa_special_condition_input'] = str_replace(',', '', $this->request->getPost("gpa_special_condition_input")) ?? [];
             $data['multiple_sum_insured'] = str_replace(',', '', $this->request->getPost("multiple_sum_insured")) ?? [];
 
+            $data['enrollment_display_key'] = $this->enrollmentGPADisplayValueTransform();
 
+            // print_r($data); die;
 
             $jsonData = json_encode($data);
             $dataa = array(
@@ -2407,6 +2548,94 @@ class ClientController extends AdminController
         }
     }
 
+    public function enrollmentGPADisplayValueTransform()
+    {   
+        $data = [];
+
+        if ($this->request->getPost("accidentalDeathBenefit_display")) {
+            $data['Accidental Death Benefit'] = $this->request->getPost("accidentalDeathBenefit");
+        }
+        if ($this->request->getPost("permanentTotalDisablement_display")) {
+            $data['Permanent Total Disablement'] = $this->request->getPost("permanentTotalDisablement");
+        }
+        if ($this->request->getPost("permanentPartialDisablement_display")) {
+            $data['Permanent Partial Disablement'] = $this->request->getPost("permanentPartialDisablement");
+        }
+        if ($this->request->getPost("temporaryTotalDisablementBenefit_display")) {
+            $data['Temporary Total Disablement Benefit'] = $this->request->getPost("temporaryTotalDisablementBenefit");
+        }
+        if ($this->request->getPost("medical_expenses_medical_extension_display")) {
+            $data['Medical Expenses / Medical Extension (IPD)'] = $this->request->getPost("medical_expenses_medical_extension");
+        }
+        if ($this->request->getPost("opd_treatment_cover_display")) {
+            $data['OPD Treatment Cover'] = $this->request->getPost("opd_treatment_cover");
+        }
+        if ($this->request->getPost("ambulanceCharges_display")) {
+            $data['Ambulance Charges'] = $this->request->getPost("ambulanceCharges");
+        }
+        if ($this->request->getPost("repatriation_of_mortal_remains_display")) {
+            $data['Repatriation of Mortal Remains'] = $this->request->getPost("repatriation_of_mortal_remains");
+        }
+        if ($this->request->getPost("childrenEducationWelfareFund_display")) {
+            $data['Children Education Welfare Fund'] = $this->request->getPost("childrenEducationWelfareFund");
+        }
+        if ($this->request->getPost("terrorism_display")) {
+            $data['Terrorism'] = $this->request->getPost("terrorism");
+        }
+        if ($this->request->getPost("worldwideCover_display")) {
+            $data['Worldwide Cover'] = $this->request->getPost("worldwideCover");
+        }
+        if ($this->request->getPost("family_transportation_benefits_display")) {
+            $data['Family Transportation Benefits'] = $this->request->getPost("family_transportation_benefits");
+        }
+        if ($this->request->getPost("fractures_dislocation_burns_display")) {
+            $data['Fractures / Dislocation / Burns'] = $this->request->getPost("fractures_dislocation_burns");
+        }
+        if ($this->request->getPost("coma_display")) {
+            $data['Coma'] = $this->request->getPost("coma");
+        }
+        if ($this->request->getPost("carriageofDeadBody_display")) {
+            $data['Carriage of Dead Body'] = $this->request->getPost("carriageOfDeadBody");
+        }
+        if ($this->request->getPost("compassionateVisitExpenses_display")) {
+            $data['Compassionate Visit Expenses'] = $this->request->getPost("compassionateVisitExpenses");
+        }
+        if ($this->request->getPost("travel_expenses_for_medical_treatment_display")) {
+            $data['Travel expenses for Medical Treatment'] = $this->request->getPost("travel_expenses_for_medical_treatment");
+        }
+        if ($this->request->getPost("daily_cash_allowance_display")) {
+            $data['Daily cash Allowance'] = $this->request->getPost("daily_cash_allowance");
+        }
+        if ($this->request->getPost("artifical_limb_and_prosthesis_display")) {
+            $data['Artifical Limb and Prosthesis'] = $this->request->getPost("artifical_limb_and_prosthesis");
+        }
+        if ($this->request->getPost("animalSnakeInsectBite_display")) {
+            $data['Animal/Snake/Insect Bite'] = $this->request->getPost("animalSnakeInsectBite");
+        }
+        if ($this->request->getPost("air_ambulance_display")) {
+            $data['Air Ambulance'] = $this->request->getPost("air_ambulance");
+        }
+
+        if ($this->request->getPost("gpa_special_condition_display_value")) {
+
+            $specialConditionKeyValue = $this->request->getPost("gpa_special_condition_display_value") ?? [];
+            $specialConditionKeyValue = json_decode($specialConditionKeyValue, true);
+
+            if (is_array($specialConditionKeyValue) && count($specialConditionKeyValue) > 0) {
+                $mergedArray = array_merge(...array_map(fn($item) => (array) $item, $specialConditionKeyValue));
+                $data = array_merge($data, $mergedArray);
+            }
+        }
+        // print_r($data); die;
+
+        if (isset($data) && !empty($data)) {
+            return $data;
+        } else {
+            $data = [];
+            return $data;
+        }
+    }
+
     public function getPolicyGPATerms()
     {
 
@@ -2421,6 +2650,8 @@ class ClientController extends AdminController
         }
     }
 
+    // ----------------------------------------------------------------------------------------------------
+
     public function updateClientPolicyStatus()
     {
 
@@ -3670,25 +3901,35 @@ class ClientController extends AdminController
     public function updatePolicyTermsKey()
     {
         $client_id = $this->request->getGet('client_id');
+        $policy_type_id = $this->request->getGet('policy_type_id');
 
         $query = $this->clientPolicyModel
             ->where("policy_terms IS NOT NULL AND policy_terms <> ''")
             ->where('is_active', 1);
+
         
         if (!empty($client_id)) {
             $query->where('client_id', $client_id);
         }
         
+        if (!empty($policy_type_id)) {
+            $query->where('policy_type_id', $policy_type_id);
+        }
+        
         $data = $query->findAll();
         
         for ($i = 0; $i < count($data); $i++) {
 
+            // dd($data[$i]);
+
             if (isset($data[$i]['policy_terms']) && !empty($data[$i]['policy_terms'])) {
                 $policyTerms = json_decode($data[$i]['policy_terms'], true);
             } else {
                 continue;
             }
 
+            // dd($policyTerms);
+
             $is_addon = $data[$i]['is_addon'];
 
             $payable_arr = [];
@@ -3711,7 +3952,7 @@ class ClientController extends AdminController
             if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
 
                 // Set default value of copayzonewisecopay to "empty"
-                $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
+                // $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
 
                 // add is_payable_employee for the GMC Policy
                 if (isset($policyTerms['age_ratio'])) {
@@ -3725,31 +3966,31 @@ class ClientController extends AdminController
                     }
                 }
 
-                // Add copayzonewisecopay and copayzonewisecopaydata if they exist_
-                if (isset($policyTerms['copayzonewisecopay'])) {
+                // // Add copayzonewisecopay and copayzonewisecopaydata if they exist_
+                // if (isset($policyTerms['copayzonewisecopay'])) {
 
-                    if(!isset($policyTerms['co_pay_details'])){
+                //     if(!isset($policyTerms['co_pay_details'])){
 
-                        $co_pay_details_value = "";
-                        if (strtolower($ans) == "nil" || $ans == 0) {
-                            $policyTerms['copayzonewisecopay'] = 0;
-                            $co_pay_details_value = "";
-                        } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) {
-                            $policyTerms['copayzonewisecopay'] = 1;
-                            $co_pay_details_value = $ans;
-                        }
+                //         $co_pay_details_value = "";
+                //         if (strtolower($ans) == "nil" || $ans == 0) {
+                //             $policyTerms['copayzonewisecopay'] = 0;
+                //             $co_pay_details_value = "";
+                //         } elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) {
+                //             $policyTerms['copayzonewisecopay'] = 1;
+                //             $co_pay_details_value = $ans;
+                //         }
 
-                        $co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms));
-                        $orderedPolicyTerms[] = [
-                            "key" => "co_pay_details",
-                            "value" =>  $co_pay_details_value,
-                            "position" => $co_pay_index + 2,
-                        ];
+                //         $co_pay_index = array_search('copayzonewisecopay', array_keys($policyTerms));
+                //         $orderedPolicyTerms[] = [
+                //             "key" => "co_pay_details",
+                //             "value" =>  $co_pay_details_value,
+                //             "position" => $co_pay_index + 2,
+                //         ];
 
-                        unset($policyTerms['optionalparentalcopay']);
+                //         unset($policyTerms['optionalparentalcopay']);
 
-                    }
-                }
+                //     }
+                // }
 
                 // Add ailmentcapping and ailmentcappingdata if they exist
                 if (isset($policyTerms['ailmentcapping'])) {
@@ -3758,7 +3999,7 @@ class ClientController extends AdminController
                         $orderedPolicyTerms[] = [
                             "key" => "ailment_capping_details",
                             "value" => "",
-                            "position" => $aliment_index + 3,
+                            "position" => $aliment_index + 2,
                         ];
                     }
                 }
@@ -3792,8 +4033,6 @@ class ClientController extends AdminController
 
             }
 
-
-
             foreach ($orderedPolicyTerms as $term) {
                 $position = $term['position'];
                 $key = $term['key'];
@@ -3805,14 +4044,360 @@ class ClientController extends AdminController
                 );
             }
 
+            foreach ($policyTerms as $key => $term) {
+                if ($term == "0") {
+                    $policyTerms[$key] = "No";  // Use = for assignment
+                } elseif ($term == "1") {
+                    $policyTerms[$key] = "Yes"; // Use = for assignment
+                }
+            }
+
+            if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
+
+                if (!isset($policyTerms['waiver_of_90_days_waiting_period'])) {
+                    $policyTerms['waiver_of_90_days_waiting_period'] = "";
+                }
+                
+                if (!isset($policyTerms['waiver_of_other_waiting_periods'])) {
+                    $policyTerms['waiver_of_other_waiting_periods'] = "";
+                }
+
+                if (!isset($policyTerms['maternity_benefit'])) {
+                    $policyTerms['maternity_benefit'] = "";
+                }
+                
+                if (!isset($policyTerms['well_baby_well_mother_expenses'])) {
+                    $policyTerms['well_baby_well_mother_expenses'] = "";
+                }
+
+                if (!isset($policyTerms['icu_limit'])) {
+                    $policyTerms['icu_limit'] = "";
+                }
+
+                if (!isset($policyTerms['infertility_treatment_coverage'])) {
+                    $policyTerms['infertility_treatment_coverage'] = "";
+                }
+
+                if (!isset($policyTerms['mid_term_addition_of_new_born_newly_wedded_spouse'])) {
+                    $policyTerms['mid_term_addition_of_new_born_newly_wedded_spouse'] = "";
+                }
+
+                if (!isset($policyTerms['non_admissible_contingency_corporate_buffer'])) {
+                    $policyTerms['non_admissible_contingency_corporate_buffer'] = "";
+                }
+
+                if (!isset($policyTerms['terrorism'])) {
+                    $policyTerms['terrorism'] = "";
+                }
+
+                if (!isset($policyTerms['widower_cover'])) {
+                    $policyTerms['widower_cover'] = "";
+                }
+                
+                if (!isset($policyTerms['breavement_cover'])) {
+                    $policyTerms['breavement_cover'] = "";
+                }
+                
+                if (!isset($policyTerms['enrollment_display_key'])) {
+                    $policyTerms['enrollment_display_key'] = $this->existingGMCDisplayValueTransform($policyTerms);
+                }
+
+            } else if($data[$i]['policy_type_id'] == 1){
+
+                if (!isset($policyTerms['medical_expenses_medical_extension'])) {
+                    $policyTerms['medical_expenses_medical_extension'] = "";
+                }
+                
+                if (!isset($policyTerms['opd_treatment_cover'])) {
+                    $policyTerms['opd_treatment_cover'] = "";
+                }
+                
+                if (!isset($policyTerms['repatriation_of_mortal_remains'])) {
+                    $policyTerms['repatriation_of_mortal_remains'] = "";
+                }
+                
+                if (!isset($policyTerms['family_transportation_benefits'])) {
+                    $policyTerms['family_transportation_benefits'] = "";
+                }
+                
+                if (!isset($policyTerms['fractures_dislocation_burns'])) {
+                    $policyTerms['fractures_dislocation_burns'] = "";
+                }
+                
+                if (!isset($policyTerms['coma'])) {
+                    $policyTerms['coma'] = "";
+                }
+                
+                if (!isset($policyTerms['travel_expenses_for_medical_treatment'])) {
+                    $policyTerms['travel_expenses_for_medical_treatment'] = "";
+                }
+                
+                if (!isset($policyTerms['daily_cash_allowance'])) {
+                    $policyTerms['daily_cash_allowance'] = "";
+                }
+                
+                if (!isset($policyTerms['artifical_limb_and_prosthesis'])) {
+                    $policyTerms['artifical_limb_and_prosthesis'] = "";
+                }
+                
+                if (!isset($policyTerms['air_ambulance'])) {
+                    $policyTerms['air_ambulance'] = "";
+                }
+                                
+                if (!isset($policyTerms['enrollment_display_key'])) {
+                    $policyTerms['enrollment_display_key'] = $this->existingGPADisplayValueTransform($policyTerms);
+                }
+                
+            }
+
+            // dd($policyTerms);
             // Re-encode the ordered policy terms
             $updatedPolicyTerms = json_encode($policyTerms);
+            // dd($updatedPolicyTerms);
 
             // dd($orderedPolicyTerms, $updatedPolicyTerms);
             $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
         }
     }
 
+    public function existingGMCDisplayValueTransform($data)
+    {
+        $transformedData = [];
+
+        if (isset($data["waiverofpreexistingdiseases"])) {
+            $transformedData['Waiver of Pre-existing Diseases'] = $data["waiverofpreexistingdiseases"];
+        }
+
+        if (isset($data["waiverof1,2,3&4thyearexclusions"])) {
+            $transformedData['Waiver of 1, 2, 3 & 4th year Exclusions'] = $data["waiverof1,2,3&4thyearexclusions"];
+        }
+
+        if (isset($data["waiverof30dayswaitingperiod"])) {
+            $transformedData['Waiver of 30 days waiting period'] = $data["waiverof30dayswaitingperiod"];
+        }
+
+        if (isset($data["waiver_of_90_days_waiting_period"])) {
+            $transformedData['Waiver of 90 Days Waiting Period'] = $data["waiver_of_90_days_waiting_period"];
+        }
+
+        if (isset($data["waiver_of_other_waiting_periods"])) {
+            $transformedData['Waiver of Other Waiting Periods'] = $data["waiver_of_other_waiting_periods"];
+        }
+
+        if (isset($data["maternity_benefit"])) {
+            $transformedData['Maternity Benefit'] = $data["maternity_benefit"];
+        }
+
+        if (isset($data["9monthwaitingperiodwaived"])) {
+            $transformedData['9-month waiting Period - waived'] = $data["9monthwaitingperiodwaived"];
+        }
+
+        if (isset($data["maternitycoverage"])) {
+            $transformedData['Maternity Coverage'] = $data["maternitycoverage"];
+        }
+
+        if (isset($data["twindelivery"])) {
+            $transformedData['Twin Delivery'] = $data["twindelivery"];
+        }
+
+        if (isset($data["well_baby_well_mother_expenses"])) {
+            $transformedData['Well baby / Well Mother Expenses'] = $data["well_baby_well_mother_expenses"];
+        }
+
+        if (isset($data["preandpostnatal"])) {
+            $transformedData['Pre and Post natal'] = $data["preandpostnatal"];
+        }
+
+        if (isset($data["infertility_treatment_coverage"])) {
+            $transformedData['Infertility Treatment Coverage'] = $data["infertility_treatment_coverage"];
+        }
+
+        if (isset($data["babyday1cover"])) {
+            $transformedData['Baby Day 1 Cover'] = $data["babyday1cover"];
+        }
+
+        if (isset($data["coverfromthedateofjoining"])) {
+            $transformedData['Cover from the date of Joining'] = $data["coverfromthedateofjoining"];
+        }
+
+        if (isset($data["mid_term_addition_of_new_born_newly_wedded_spouse"])) {
+            $transformedData['Mid Term Addition of New Born / Newly Wedded Spouse'] = $data["mid_term_addition_of_new_born_newly_wedded_spouse"];
+        }
+
+        if (isset($data["prehospitalizationcover"])) {
+            $transformedData['Pre Hospitalization Cover'] = $data["prehospitalizationcover"];
+        }
+
+        if (isset($data["posthospitalizationcover"])) {
+            $transformedData['Post Hospitalization Cover'] = $data["posthospitalizationcover"];
+        }
+
+        if (isset($data["congenitaldiseasesinternal"])) {
+            $transformedData['Congenital Diseases - Internal'] = $data["congenitaldiseasesinternal"];
+        }
+
+        if (isset($data["congenitaldiseasesexternal"])) {
+            $transformedData['Congenital Diseases - External'] = $data["congenitaldiseasesexternal"];
+        }
+
+        if (isset($data["copayzonewisecopay"])) {
+            $transformedData['Co-Pay/Zone wise Co Pay'] = $data["copayzonewisecopay"];
+        }
+
+        if (isset($data["roomrentlimit"])) {
+            $transformedData['Room Rent Limit'] = $data["roomrentlimit"];
+        }
+
+        if (isset($data["icu_limit"])) {
+            $transformedData['ICU Limit'] = $data["icu_limit"];
+        }
+
+        if (isset($data["proportionatedeductionclause"])) {
+            $transformedData['Proportionate Deduction Clause'] = $data["proportionatedeductionclause"];
+        }
+
+        if (isset($data["ailmentcapping"])) {
+            $transformedData['Ailment capping'] = $data["ailmentcapping"];
+        }
+
+        if (isset($data["ailment_capping_details"])) {
+            $transformedData['Ailment capping Details'] = $data["ailment_capping_details"];
+        }
+
+        if (isset($data["corporatebuffer"])) {
+            $transformedData['Corporate Buffer'] = $data["corporatebuffer"];
+        }
+
+        if (isset($data["non_admissible_contingency_corporate_buffer"])) {
+            $transformedData['Non-Admissible / Contingency Corporate Buffer'] = $data["non_admissible_contingency_corporate_buffer"];
+        }
+
+        if (isset($data["ambulancecharges"])) {
+            $transformedData['Ambulance Charges'] = $data["ambulancecharges"];
+        }
+
+        if (isset($data["airambulance"])) {
+            $transformedData['Air Ambulance'] = $data["airambulance"];
+        }
+
+        if (isset($data["reasonableandcustomarycharges"])) {
+            $transformedData['Reasonable and Customary Charges'] = $data["reasonableandcustomarycharges"];
+        }
+
+        if (isset($data["daycaretreatment"])) {
+            $transformedData['Day Care Treatment'] = $data["daycaretreatment"];
+        }
+
+        if (isset($data["lasiksurgery"])) {
+            $transformedData['Lasik Surgery'] = $data["lasiksurgery"];
+        }
+
+        if (isset($data["ayushtreatmentcover"])) {
+            $transformedData['AYUSH treatment cover'] = $data["ayushtreatmentcover"];
+        }
+
+        if (isset($data["moderntreatmentsasperirdai"])) {
+            $transformedData['Modern treatments as per IRDAI'] = $data["moderntreatmentsasperirdai"];
+        }
+
+        if (isset($data["opd_treatment"])) {
+            $transformedData['OPD Treatment'] = $data["opd_treatment"];
+        }
+
+        if (isset($data["days_of_discharge"])) {
+            $transformedData['Claim Intimation Clause'] = $data["days_of_discharge"];
+        }
+
+        if (isset($data["days_from_dod"])) {
+            $transformedData['Claim Submission'] = $data["days_from_dod"];
+        }
+
+        if (isset($data["terrorism"])) {
+            $transformedData['Terrorism'] = $data["terrorism"];
+        }
+
+        if (isset($data["widower_cover"])) {
+            $transformedData['Widower Cover'] = $data["widower_cover"];
+        }
+
+        if (isset($data["breavement_cover"])) {
+            $transformedData['Breavement Cover'] = $data["breavement_cover"];
+        }
+
+        return !empty($transformedData) ? $transformedData : [];
+    }
+
+    public function existingGPADisplayValueTransform($data)
+    {   
+        $transformedData = [];
+
+        if (isset($data["accidentalDeathBenefit"])) {
+            $transformedData['Accidental Death Benefit'] = $data["accidentalDeathBenefit"];
+        }
+        if (isset($data["permanentTotalDisablement"])) {
+            $transformedData['Permanent Total Disablement'] = $data["permanentTotalDisablement"];
+        }
+        if (isset($data["permanentPartialDisablement"])) {
+            $transformedData['Permanent Partial Disablement'] = $data["permanentPartialDisablement"];
+        }
+        if (isset($data["temporaryTotalDisablementBenefit"])) {
+            $transformedData['Temporary Total Disablement Benefit'] = $data["temporaryTotalDisablementBenefit"];
+        }
+        if (isset($data["medical_expenses_medical_extension"])) {
+            $transformedData['Medical Expenses / Medical Extension (IPD)'] = $data["medical_expenses_medical_extension"];
+        }
+        if (isset($data["opd_treatment_cover"])) {
+            $transformedData['OPD Treatment Cover'] = $data["opd_treatment_cover"];
+        }
+        if (isset($data["ambulanceCharges"])) {
+            $transformedData['Ambulance Charges'] = $data["ambulanceCharges"];
+        }
+        if (isset($data["repatriation_of_mortal_remains"])) {
+            $transformedData['Repatriation of Mortal Remains'] = $data["repatriation_of_mortal_remains"];
+        }
+        if (isset($data["childrenEducationWelfareFund"])) {
+            $transformedData['Children Education Welfare Fund'] = $data["childrenEducationWelfareFund"];
+        }
+        if (isset($data["terrorism"])) {
+            $transformedData['Terrorism'] = $data["terrorism"];
+        }
+        if (isset($data["worldwideCover"])) {
+            $transformedData['Worldwide Cover'] = $data["worldwideCover"];
+        }
+        if (isset($data["family_transportation_benefits"])) {
+            $transformedData['Family Transportation Benefits'] = $data["family_transportation_benefits"];
+        }
+        if (isset($data["fractures_dislocation_burns"])) {
+            $transformedData['Fractures / Dislocation / Burns'] = $data["fractures_dislocation_burns"];
+        }
+        if (isset($data["coma"])) {
+            $transformedData['Coma'] = $data["coma"]; 
+        }
+        if (isset($data["carriageofDeadBody"])) {
+            $transformedData['Carriage of Dead Body'] = $data["carriageofDeadBody"];
+        }
+        if (isset($data["compassionateVisitExpenses"])) {
+            $transformedData['Compassionate Visit Expenses'] = $data["compassionateVisitExpenses"];
+        }
+        if (isset($data["travel_expenses_for_medical_treatment"])) {
+            $transformedData['Travel expenses for Medical Treatment'] = $data["travel_expenses_for_medical_treatment"];
+        }
+        if (isset($data["daily_cash_allowance"])) {
+            $transformedData['Daily cash Allowance'] = $data["daily_cash_allowance"];
+        }
+        if (isset($data["artifical_limb_and_prosthesis"])) {
+            $transformedData['Artifical Limb and Prosthesis'] = $data["artifical_limb_and_prosthesis"];
+        }
+        if (isset($data["animalSnakeInsectBite"])) {
+            $transformedData['Animal/Snake/Insect Bite'] = $data["animalSnakeInsectBite"];
+        }
+        if (isset($data["air_ambulance"])) {
+            $transformedData['Air Ambulance'] = $data["air_ambulance"];
+        }
+
+        return !empty($transformedData) ? $transformedData : [];
+    }
+
     public function updateRemainderDate()
     {
         // Connect to the database and fetch the data
@@ -3839,23 +4424,31 @@ class ClientController extends AdminController
 
     public function sendextraparam()
     {   
-        helper('excel_util_helper');
+
+        // $employeeController = new EmployeeController();
+        // $employeeController->truncateFileData('633');
+        
+        // ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------
+
+        $employeeRestController = new EmployeeServiceController();
+        // $employeeRestController->excelFileDataValidation(['file_id' => 823]);
+        // $employeeRestController->employeesOnboardPreprocess(['file_id' => 644]);
+        // $employeeRestController->employeesOnboardProcess(['file_id' => 835]);
+        // $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]);
+        // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
+
+
+        // ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
+
         // $batch_data = [
         //     'client_id' => 17,
         //     'client_policy_id' => 30,
         //     'client_branch_id' => 18,
+        //     'event_type' => "inception",
         // ];
 
         // $batch_data['insurer_or_tpa'] = 'insurer';
         // $batch_data['insurer_or_tpa'] = 'tpa';
-        
-
-        // dd($this->request);
-        // $employeeRestController = new EmployeeServiceController();
-        // $employeeRestController->employeesOnboardPreprocess(['file_id' => 721]);
-
-        // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
-
 
         // $dashBoardController = new DashboardController();
         // $client_policy_data = $this->clientPolicyModel->getPolicyDetailsForRemainder($client_id=159, $client_branch_id=126);
@@ -3890,6 +4483,7 @@ class ClientController extends AdminController
         // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]);
         // $EmpDataServiceController->importDeletionValidation(['file_id' => 171]);
         // $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]);
+        // $EmpDataServiceController->importCorrectionUpdateEndorsementID(['file_id' => 188]);
         
         // $array = [
         //         "employeeIds" => ["12800", "12798", "12797", "12799"],
@@ -3906,20 +4500,73 @@ class ClientController extends AdminController
         
         // $EmpDataServiceController->cashDepositCalculationForDeletion($array);
 
-        // $employeeRestController = new EmployeeServiceController();
-        // $employeeRestController->employeesOnboardPreprocess(['file_id' => 756]);
+        // $result = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($batch_data);
+        // dd(db_connect()->getLastQuery());
 
-        // $employee_data = $this->employeeModel->getEmpFamilybyEmpCode(client_id: 159,client_policy_id: 336,emp_code: "6214",emp_status:[],policy_status:[]);
-        // dd(db_connect()->getLastQuery(), $employee_data);
-        // print_rr( $employee_data); die;
+        // ------------- LEADS CONTROLLER ----------------------------------------------------------
 
-        // $data = update_si_with_auto_si(159, 336, "6214");
+        // $LeadsController = new LeadsController();
+        // $RFQModel = new RFQModel();
+
+        // $data = $RFQModel->where('is_active', 1)->where('lead_id', 40)->first();
+        // // dd($data);
+        // $policy_type = 2;
+        // $proposel_name = "Proposal 2";
+        // $insurer_name = "ICICI-P-ICICI002-V1";
+        // $jsonArray = json_decode($data['json'], true);
+        // // dd($jsonArray);
+
+        // $returndata = $LeadsController->convertQCRJsonToPolicyTerms($jsonArray, $policy_type, $proposel_name, $insurer_name);
+        // dd($returndata);
+
+        // -----------BDS REPORT CONTROLLER---------------------------------------------------------------------------------
+        
+        // $BDSReportController = new BDSReportController();
+
+        // $data['data'] = $BDSReportController->getBAPInsurerData();
+        
+        // return $this->loadLayout('irda_bap_insurer_report_list', $data);
+
+        // $data['data'] = $BDSReportController->getBAPClientData();
+        // return $this->loadLayout('irda_bap_client_report_list', $data);
+
+        // $data['data'] = $BDSReportController->getClientData(1);
+        // return $this->loadLayout('irda_client_report_list', $data);
+
+        // $BDSReportController->getBAPClientData();
+
+        //--------------------------------------------------------------------------------------------------------
+
+        // $email_id = 'venkateshraman786@gmail.com';
+        // $common = ['mail_type'=>'test_mail_cli'];
+        // $bcc = "vitvelz@gmail.com";
+        
+        // $data = db_connect()
+        // ->table('jobs')
+        // ->where('id', 2264)
+        // ->get()
+        // ->getResultArray();
+
+        // $data = json_decode($data[0]['payload'], true);
+        
+        // // dd($data);
+        // // Send email and get response
+        // $result = MailHelper::send_email($data[0]);
+        // echo json_encode($result);
+        // log_message('error',json_encode($result));
+
+        //--------------------------------------------------------------------------------------------------------
+
+        // $ticketModel = new TicketMasterModel();
+        // $reportData['data'] = $ticketModel->getTATReport(1);
+        // print_rr($reportData);
+        // $this->loadLayout('tat_report_band_wise_list', $reportData);
+        // $data = $ticketModel->getTATReport(1);
+        
+
+        // $empmodel = new EmployeeModel();
+        // $data = $empmodel->getEmployeePolicy(348);
         // dd($data);
-
-        // $EmployeeRestController = new EmployeeRestController();
-        // $EmployeeRestController->calculatePremium(336, "6214", null, 126);
-
-
     }
 
     // -------------------------------------------------------------------------------------------------------
diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php
index 34fee90..3722a30 100755
--- a/app/Controllers/DashboardController.php
+++ b/app/Controllers/DashboardController.php
@@ -98,19 +98,60 @@ class DashboardController extends AdminController
     public function dashboard()
     {
 
-        $data = [];
+        $data['page_name'] = 'Dashboard';
+        
+        $db = db_connect();
+        $sql = "SELECT 
+                    clients.id AS client_id, 
+                    clients.client_name, 
+                    clients.short_name,
+                    client_branch.id AS client_branch_id, 
+                    client_branch.branch_name, 
+                    client_branch.branch_code,
+                    
+                    COUNT(employees.id) AS total_employees,  
+                    SUM(CASE WHEN employees.emp_status = 'draft' THEN 1 ELSE 0 END) AS draft_count,  
+                    SUM(CASE WHEN employees.emp_status IN ('enrolled', 'active') THEN 1 ELSE 0 END) AS enrolled_count,  
 
-        $results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name,
-                                              client_branch.id as client_branch_id, client_branch.branch_name, 
-                                              client_branch.branch_code, employees.id as employee_id, 
-                                              employees.name as employee_name, employees.relationship,
-                                              employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id')
-        ->join('client_branch', 'clients.id = client_branch.client_id', 'left')
-        ->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left')
-        ->join('employees', 'client_branch.id = employees.client_branch_id', 'left')
-        ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
-        ->findAll();
+                    SUM(CASE WHEN auth_history.user_id IS NOT NULL THEN 1 ELSE 0 END) AS logged_in_count,  
+                    SUM(CASE WHEN auth_history.user_id IS NULL THEN 1 ELSE 0 END) AS not_logged_in_count,
 
+                    CASE 
+                        WHEN EXISTS (
+                            SELECT 1 FROM client_policy 
+                            WHERE client_policy.client_branch_id = client_branch.id 
+                            AND client_policy.is_active = 1 
+                            AND client_policy.open_for_enrollment = 1
+                        ) THEN 1 
+                        ELSE 0 
+                    END AS open_or_close_enrollment  
+
+                FROM clients
+                LEFT JOIN client_branch ON clients.id = client_branch.client_id
+                LEFT JOIN employees ON client_branch.id = employees.client_branch_id
+                LEFT JOIN (
+                    SELECT user_id, user_type 
+                    FROM auth_history 
+                    WHERE user_type = 'employee' 
+                    GROUP BY user_id
+                ) AS auth_history ON employees.id = auth_history.user_id
+
+                WHERE employees.relationship = 'Self'
+                AND employees.emp_status IN ('draft', 'enrolled', 'active')
+                AND employees.is_active = 1
+                AND clients.is_active = 1
+                AND client_branch.is_active = 1
+
+                GROUP BY clients.id, client_branch.id";
+
+        $query = $db->query($sql);
+        $results = $query->getResultArray();
+
+
+        $data['client_branch_emp_list'] = $results;
+        $session = \Config\Services::session();
+        $session->set('enrollment_data', json_encode($data));  
+        
         // $pendingActionsController = new PendingActionsController;
         // $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
         // $businessTeamData = $this->policyTransactionModel->getBusinessReportList();
@@ -118,95 +159,6 @@ class DashboardController extends AdminController
         // $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
         // $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
 
-        $groupedData = [];
-
-        foreach ($results as $row) {
-            $clientId = $row['client_id'];
-            $clientName = $row['client_name'];
-            $shortName = $row['short_name'];
-            $branchId = $row['client_branch_id'];
-            $branchName = $row['branch_name'];
-            $branchCode = $row['branch_code'];
-
-            $clientPolicyId = $row['client_policy_id'];
-            $policyTypeId = $row['policy_type_id'];
-            $employeeId = '';
-            if ($employeeId != $row['employee_id']) {
-                $employeeId = $row['employee_id'];
-            } else {
-                $employeeId = null;
-            }
-            $employeeName = $row['employee_name'];
-            $employeeRelationship = $row['relationship'];
-            $employeeEmpCode =  $row['emp_code'];
-            $employeeEmpStatus = $row['emp_status'];
-            $employeeUserType = $row['user_type'];
-
-            // Initialize the client entry if it doesn't exist
-            if (!isset($groupedData[$clientId])) {
-                $groupedData[$clientId] = [
-                    'client_id' => $clientId,
-                    'client_name' => $clientName,
-                    'short_name' => $shortName,
-                    'branches' => []
-                ];
-            }
-
-            // Initialize the branch entry if it doesn't exist
-            if (!isset($groupedData[$clientId]['branches'][$branchId])) {
-                $groupedData[$clientId]['branches'][$branchId] = [
-                    'client_branch_id' => $branchId,
-                    'branch_name' => $branchName,
-                    'branch_code' => $branchCode,
-                    'emp_login' => 0,
-                    'emp_enroll' => 0,
-                    'client_policies' => [],
-                    'employees' => []
-                ];
-            }
-
-            // Add the client policy to the branch's policies list if it exists, not already added, and policyTypeId is not equal to 1
-            if ($clientPolicyId !== null && $policyTypeId != 1 && !in_array(['client_policy_id' => $clientPolicyId, 'policy_type_id' => $policyTypeId], $groupedData[$clientId]['branches'][$branchId]['client_policies'])) {
-                $groupedData[$clientId]['branches'][$branchId]['client_policies'][] = [
-                    'client_policy_id' => $clientPolicyId,
-                    'policy_type_id' => $policyTypeId
-                ];
-            }
-
-            // Append employee error to the branch's employees list if relationship is 'Self' and not already added
-            $employeeKey = $employeeId . '-' . $employeeName; // unique key to identify an employee
-            if ($employeeId !== null && $employeeRelationship == 'Self' && !isset($groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey])) {
-                $groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey] = [
-                    'employee_id' => $employeeId,
-                    'employee_name' => $employeeName,
-                    'relationship' => $employeeRelationship,
-                    'emp_code' => $employeeEmpCode,
-                    'emp_status' => $employeeEmpStatus,
-                    'user_type' => $employeeUserType
-                ];
-                if (!empty($employeeUserType)) {
-                    $groupedData[$clientId]['branches'][$branchId]['emp_login']++;
-                }
-
-                // Increment emp_enroll if emp_status is not 'draft'
-                if ($employeeEmpStatus !== 'draft') {
-                    $groupedData[$clientId]['branches'][$branchId]['emp_enroll']++;
-                }
-            }
-        }
-
-        // Re-index the arrays to match the expected structure
-        foreach ($groupedData as &$client) {
-            foreach ($client['branches'] as &$branch) {
-                $branch['employees'] = array_values($branch['employees']);
-            }
-            $client['branches'] = array_values($client['branches']);
-        }
-
-        $data['client_branch_emp_list'] = $groupedData;
-        $session = \Config\Services::session();
-        $session->set('enrollment_data', json_encode($data));   
-        // echo "
";
         // $data['pendingActionsData'] = $pendingActionsData;
         // $data['businessTeamCount'] = count($businessTeamData) ?? 0;
         // $data['financeTeamCount'] = count($financeTeamData) ?? 0;
@@ -214,9 +166,8 @@ class DashboardController extends AdminController
         // $data['financeTeamStatusData'] = $financeTeamStatusData;
         // $data['policyStatus'] =  $this->policyStatus;
         // $data['colorShades'] =  $this->colorShades;
-        // dd($data);die;
 
-        $data['page_name'] = 'Dashboard';
+        // dd($data);
 
         echo view('layout/header',  $data);
         echo view('DashBoard', $data);
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index 5f4e9b2..bafc79c 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -25,6 +25,9 @@ use App\Models\InsurerExcelExportTemplateModel;
 use App\Models\InsurerModel;
 use App\Models\ClientDepositModel;
 use App\Models\PolicyPremium2Model;
+use App\Models\AuditHistoryModel;
+use App\Models\UserModel;
+
 
 
 use App\Controllers\Jobs;
@@ -64,6 +67,9 @@ class EmployeeController extends AdminController
     protected $insurerModel;
     protected $cashDepositModel;
     protected $PolicyPremium2Model;
+    protected $auditHistory;
+    protected $userModel;
+
 
     public function __construct()
     {
@@ -84,6 +90,8 @@ class EmployeeController extends AdminController
         $this->insurerModel = new InsurerModel();
         $this->cashDepositModel = new ClientDepositModel();
         $this->PolicyPremium2Model = new PolicyPremium2Model();
+        $this->auditHistory = new AuditHistoryModel();
+        $this->userModel = new userModel();
     }
 
     public function list()
@@ -114,6 +122,10 @@ class EmployeeController extends AdminController
         // log_message('error',json_encode($data['employees']));
             // Set getData in $data array with the processed $filterData
             $data['getData'] = $filterData;
+
+            $html = view('employee_data_list', $data);
+            return $this->respond(['status' => true, 'html' => $html], 200);
+
         }
         
         // dd($this->employeeModel->getLastQuery());
@@ -2187,33 +2199,41 @@ class EmployeeController extends AdminController
         }
     }
 
+    //UPDATE EMPLOYEE
     public function update_emp_data()
-    {
+    {   
+        helper('utility_helper');
+        
         $data = $this->request->getPost();
         // print_rr($data);die();
         // $data['dob'] = date('Y-m-d', strtotime($data['dob']));
-        $data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d');
+        if (isset($data['dob'])) {
+            $data['dob'] = change_date_format($data['dob'], null, 'Y-m-d');
+        }
         // print_rr($data); die;
 
         // Fetch current employee data
         $employee_data = $this->employeeModel->where('id', $data['employee_primary_id'])->first();
-    
+
         if ($employee_data['relationship'] == 'Self') {
 
-            if ($employee_data['gender'] != $data['gender']) {
+            if (isset($data['gender'])) {
 
-                $spouse_gender = ($data['gender'] == 'M') ? 'F' : 'M';
-                $this->employeeModel
-                    ->where('emp_code', $employee_data['emp_code'])
-                    ->where('relationship', 'Spouse')
-                    ->set(['gender' => $spouse_gender])
-                    ->update();
+                if ($employee_data['gender'] != $data['gender']) {
+
+                    $spouse_gender = ($data['gender'] == 'M') ? 'F' : 'M';
+                    $this->employeeModel
+                        ->where('emp_code', $employee_data['emp_code'])
+                        ->where('relationship', 'Spouse')
+                        ->set(['gender' => $spouse_gender])
+                        ->update();
+                }
             }
         }
-    
+
         // Update the employee data
         $result = $this->employeeModel->where('id', $data['employee_primary_id'])->set($data)->update();
-    
+
         if ($result) {
             return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'message' => 'Employee updated successfully'], 200);
         } else {
@@ -2650,4 +2670,55 @@ class EmployeeController extends AdminController
         return $html;
     }
 
+
+
+    public function getEmpHistory(){
+
+        $emp_id = $this->request->getPost('emp_id');
+
+        $data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->orderBy('created_at', 'DESC')->findAll();
+
+        foreach ($data['emp_history'] as &$emp_history) { 
+            $emp_history['field_name'] = $this->formatFieldName($emp_history['field_name']);
+            $user = $emp_history['created_by'];
+
+            if ($user != null && $user != '') {
+                $userData = $this->userModel->select('first_name, last_name')->where('id', $user)->where('is_active', 1)->first();
+                if ($userData) {
+                    $emp_history['created_by'] = ucwords($userData['first_name'] . ' ' . $userData['last_name']);
+                } else {
+                    $emp_history['created_by'] = '-';
+                }
+            } else {
+                $emp_history['created_by'] = '-';
+            }
+            
+
+            $emp_history['created_at'] =  date("d-m-Y H:i:s", strtotime($emp_history['created_at']));
+        }
+
+        unset($emp_history); 
+        
+        $emp_pol_pk = $this->employeePolicyModel->select('id')->where('employee_id',$emp_id)->first()['id'];
+        $data['emp_pol_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_pol_pk)->where('table_name','employee_polices')->findAll();
+
+        return $this->respond(['status' => true, 'data' => $data],200);
+
+        
+    }   
+
+    public function formatFieldName($unformattedString){
+
+        if (str_contains($unformattedString, '_')) {
+            $data = str_replace('_', ' ', $unformattedString);
+        }else{
+            $data = $unformattedString;
+        }
+        
+        $format = ucwords($data);
+
+        return $format;
+
+    }
+
 }
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 4b5c903..f8614ce 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -1720,7 +1720,8 @@ class MasterController extends AdminController
             'excel' => WRITEPATH . 'uploads/excel/',
             'statements' => WRITEPATH . 'uploads/statements/',
             'import_excel' => WRITEPATH . 'uploads/import_excel/',
-            'logs' => WRITEPATH . 'uploads/logs/',
+            'logs' => WRITEPATH . 'logs',
+            'session' => WRITEPATH . 'session',
             'client_kyc_documents' => WRITEPATH . 'uploads/client_kyc_documents/',
             'tmp' => WRITEPATH . 'tmp/',
             'e_card_imgs' => ROOTPATH . 'public/e_card_imgs',
@@ -1729,6 +1730,7 @@ class MasterController extends AdminController
             'logo' => ROOTPATH . 'public/uploads/logo/',
             'template_bg' => ROOTPATH . 'public/uploads/template_bg/',
             'attachments' => WRITEPATH . 'uploads/attachments/',
+            'cache' => WRITEPATH . 'cache',
             'sample_import_excel' => ROOTPATH . 'public/sample_import_excel',
             'lead_files' => WRITEPATH . 'uploads/lead_files/',
         ];
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 7d32c05..216e461 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -112,22 +112,29 @@ class RestAuthenticationController extends AdminController
     public function verifyEmployeeWithEmailId()
     {
         try {
+
             $data = $this->request->getJSON();
 
             $email = $data->email;
 
-            $employeeData = $this->employeeModel->select('employees.relationship,EP.employee_id')
-                                                ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner') 
-                                                ->where('employees.is_active', 1)
-                                                ->where('employees.relationship', 'self')
-                                                ->where('employees.emp_status !=', 'truncated')
-                                                ->where('employees.email_corporate', $email)
-                                                ->where('EP.is_active', 1)
-                                                ->whereIn('EP.status', ['draft', 'enrolled'])
-                                                ->first();
-            
-            if (isset($employeeData['employee_id'])) 
-             {
+            $employeeData = $this->employeeModel->select('
+                employees.relationship,
+                EP.employee_id,
+                employees.client_id,
+                employees.client_branch_id,
+                employees.email_corporate
+
+            ')
+                ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
+                ->where('employees.is_active', 1)
+                ->where('employees.relationship', 'Self')
+                ->where('employees.emp_status !=', 'truncated')
+                ->where('employees.email_corporate', $email)
+                ->where('EP.is_active', 1)
+                ->whereIn('EP.status', ['draft', 'enrolled'])
+                ->first();
+
+            if (isset($employeeData['employee_id'])) {
 
                 $otp = random_int(100000, 999999);
 
@@ -140,43 +147,38 @@ class RestAuthenticationController extends AdminController
                     $data->otp = $otp; 
                     $this->callThirdPartyAPI($data, 'updateEmpOTP');
 
+
                     $common = [
                         'client_id' => $employeeData['client_id'],
                         'client_branch_id' => $employeeData['client_branch_id'],
                         'client_policy_id' => null,
                         'employee_policy_id' =>  null,
-                        'employee_id' => $employeeData['id'],
+                        'employee_id' => $employeeData['employee_id'],
                         'mail_type' => 'otp_mail',
-                      ];
+                    ];
                     $subject = 'Nhance user verification - OTP';
-                    $mail_content = $otp.' is your verification code for Nhance.';
-                    $res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject ,'common'=>$common ,'message' => $mail_content]);
+                    $mail_content = $otp . ' is your verification code for Nhance.';
+                    $res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject, 'common' => $common, 'message' => $mail_content]);
                     $this->myLogger->logme("info", $res);
 
-                    if(json_decode($res)->status == 'success')
-                    {
-                        $result = ['user_verification' => true ,'message' => "Verified Successfully"];
-                        return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
-
-                    }else{
-                        $result = ['user_verification' => false , 'message' => "Mail sending failed , try again"];
-                        return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+                    if (json_decode($res)->status == 'success') {
+                        $result = ['user_verification' => true, 'message' => "Verified Successfully"];
+                        return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
+                    } else {
+                        $result = ['user_verification' => false, 'message' => "Mail sending failed , try again"];
+                        return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
                     }
+                } else {
 
-                }else{
-
-                    $result = ['user_verification' => false , 'message' => "Verification failed , try again"];
-                    return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
-
+                    $result = ['user_verification' => false, 'message' => "Verification failed , try again"];
+                    return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
                 }
-
-               
             } else {
                 // Call the third-party API function
-                return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeEmailId');
+                return $this->callThirdPartyAPI($this->request->getJSON(), 'verifyEmployeeEmailId');
             }
         } catch (\Throwable $th) {
-            return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
+            return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
         }
     }
 
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index c8ef144..108174f 100755
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -1123,20 +1123,27 @@ if (!function_exists('premium_calculation_manager'))
                 return false;
             }
         $temp_slab_rates =  $slab_details[ $slab_index ]['slab_rates'];
-        
-        //if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage
-        if($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A')
-        {
-            $insurer = new InsurerModel();
-            $insurer = ($insurer->find($policy_terms['insurer_id']));
-            if($insurer['addition_add_day'] == true)
-            {
-                // $emp_data['policy_details']['date_coverage'] = (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d');
 
-                 $emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) && $emp_data['policy_details']['date_coverage'] != '' && $emp_data['policy_details']['date_coverage'] != null ? 
-                    (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d') : null ;
-            }
-        }
+
+        // ------------"THIS PART HAS NO INSURER IN THE PRE-ENROLL, SO COMMENT OUT THIS PART (04-03-2025)."-------------------------------------------------------------------------------------------------------------------
+        
+        // //if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage
+        // if($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A')
+        // {
+        //     $insurer = new InsurerModel();
+        //     $insurer = ($insurer->find($policy_terms['insurer_id']));
+        //     if($insurer['addition_add_day'] == true)
+        //     {
+        //         // $emp_data['policy_details']['date_coverage'] = (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d');
+
+        //          $emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) && $emp_data['policy_details']['date_coverage'] != '' && $emp_data['policy_details']['date_coverage'] != null ? 
+        //             (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d') : null ;
+        //     }
+        // }
+
+        // -------------------------------------------------------------------------------------------------------------------------------
+
+
         // dd($emp_data);
         $is_match_found = false;
         $gst = isset($policy_terms['gst']) && $policy_terms['gst'] != 0 ? $policy_terms['gst'] : 18;
diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php
index 79523f6..ca22481 100755
--- a/app/Helpers/utility_helper.php
+++ b/app/Helpers/utility_helper.php
@@ -544,6 +544,10 @@ if (!function_exists('change_date_format')) {
             'Y/m/d',     // 2024/12/01
             'Y.m.d',     // 2024.12.01
             'Y,m,d',     // 2024,12,01
+
+            'd/m/Y',     // 01/01/2025
+            'd-m-Y',     // 01-01-2025
+
         ];
 
         try {
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index b52af3b..552b3f9 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -121,8 +121,8 @@ class ClientPolicyModel extends Model
         ->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
         ->select('policy_type.policy_type as policy_type_name')
         ->select('client_branch.branch_name as branch_name')
-        ->join('insurers', 'insurers.id = client_policy.insurer_id')
-        ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
+        ->join('insurers', 'insurers.id = client_policy.insurer_id', 'left')
+        ->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id', 'left')
         ->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
         ->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')        
         ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index 73caca1..0826428 100755
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -149,7 +149,21 @@ class EmployeeModel extends Model
     {
 
         return $this->db->table('employee_polices')
-                        ->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
+                        ->select(' 
+                            policy_type.long_name as Policy_Name , 
+                            client_policy.policy_terms as Policy_Terms, 
+                            client_policy.client_id as ClientId, 
+                            client_policy.policy_id as PolicyId,
+                            client_policy.id as ClientPolicyId, 
+                            CASE 
+                                WHEN client_policy.open_for_enrollment IS NULL THEN 0 
+                                ELSE client_policy.open_for_enrollment 
+                            END AS OpenForEnrollment,
+                            client_policy.disclaimer,
+                            client_policy.policy_type_id , 
+                            employee_polices.tpa_id as tpa_id , 
+                            employee_polices.rand_string as rand_string
+                        ', FALSE) // Select all columns from both tables
                         ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
                         ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
                         ->where('client_policy.policy_status', 1)
diff --git a/app/Views/client_list.php b/app/Views/client_list.php
index b54817b..f7f8296 100755
--- a/app/Views/client_list.php
+++ b/app/Views/client_list.php
@@ -202,6 +202,7 @@ table.dataTable thead th {
 
         customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
             item.addEventListener('click', function(e) {
+                e.preventDefault();
                 const onclickAttr = this.getAttribute('onclick');
                 if (onclickAttr) {
                     eval(onclickAttr);
diff --git a/app/Views/client_policy.php b/app/Views/client_policy.php
index 10ff476..c3bc46d 100755
--- a/app/Views/client_policy.php
+++ b/app/Views/client_policy.php
@@ -10,10 +10,10 @@
         
-                    
+                    
-                    
+                    
@@ -76,10 +76,10 @@
                                     
-                            
+
@@ -274,9 +274,11 @@ + + // **Show the modal** + showModal(); + } else { + let message = response.message; + toastr.error(message, 'ERROR'); + } + }, function(xhr, status, error) { + console.error('Error fetching data:', error); + console.error(xhr.responseText); + toastr.error('An error occurred while fetching the report page.', 'ERROR'); + + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }); +} + +// function closeModal(){ +// var myModalEl = document.getElementById('emp_history_modal'); +// var modalInstance = bootstrap.Modal.getInstance(myModalEl); +// if (modalInstance) { +// modalInstance.hide(); +// } +// } + \ No newline at end of file diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 255d827..3a779fb 100755 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -135,31 +135,105 @@ table.dataTable tbody td { - + +
+ function enrollment_list(current_element, type) { + var clientId = $(current_element).closest('.carousel-slide-item').find('.client_id').val(); + var branchId = $(current_element).closest('.carousel-slide-item').find('.client_branch_id').val(); + + var baseUrl = ''; // Adjust this to your actual base URL if needed + var url = baseUrl + 'employee/enrollment-list'; // Change this to the actual URL of your enroller_list page + + var params = new URLSearchParams({ + client_id: clientId, + branch_id: branchId, + type: type + }); + + // Redirect to the constructed URL with parameters + window.location.href = `${url}?${params.toString()}`; + } + + function updateCarouselWithData(data, open_close) { + var itemsPerSlide = 3; // Number of items per slide + var currentItem = 0; // Counter for items + var isActive = true; // Variable to set the first item as active + var carouselInner = $('.carousel-inner'); + + // Clear existing carousel items + carouselInner.empty(); + + // Check if data.client_branch_emp_list is valid + if (Array.isArray(data) && data.length > 0) { + + console.log("Processing array........................................"); + // Handle the case where data.client_branch_emp_list is an array + var items = data[0]; + console.log("Items data:", items); + + // Convert items object to an array + var client_list = Object.values(items); + + // Validate if client_list is an array + if (Array.isArray(client_list)) { + + console.log(client_list); + + for (var i = 0; i < data.length; i++) { + + let client = data[i]; + + if (open_close == 1 && client.open_or_close_enrollment == 1) { + + if (currentItem % itemsPerSlide === 0) { + if (!isActive) carouselInner.append(''); // Close previous carousel item + carouselInner.append(''); // Close previous carousel item + carouselInner.append(''); + + } else { + console.error('Expected an array for items, but got:', client_list); + } + + } else if (typeof data === 'object') { + console.error('client_branch_emp_list is an object, not an array:', data); + } else { + console.error('client_branch_emp_list is missing or not in the expected format:', data); + } + random_color_set(); + + // Initialize or refresh carousel if needed + $('#carouselExampleControls').carousel('dispose'); // Properly dispose of the instance + $('#carouselExampleControls').carousel(); // Reinitialize it + + } + + function random_color_set() { + // Array of predefined colors + var colors = ['#EBE8FF', '#FFECE5', '#FFE8F5']; + // '#6ADBE3' + // Array of predefined background images + var images = [ + '/public/assets/images/mask_group.png', + '/public/assets/images/mask_group_orange.png', + '/public/assets/images/mask_group_pink.png', + ]; + // '/public/assets/images/mask_group_blue.png' + + // Counter to keep track of the current index + var index = 0; + + // Base URL for the images + var baseUrl = ''; + + // Apply a color and image from the arrays to each card-header in sequence + document.querySelectorAll('.add_card_background_random').forEach(function(header) { + header.style.backgroundColor = colors[index % colors.length]; + header.style.backgroundImage = `url(${baseUrl + images[index % images.length]})`; + header.style.backgroundSize = 'cover'; // Ensure the image covers the entire div + header.style.backgroundPosition = 'center'; // Center the image within the div + index++; + }); + } + + \ No newline at end of file diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index be4b592..eb9311d 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -604,17 +604,17 @@ - + --> diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index dd3138d..68ae324 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1,71 +1,75 @@
Insurer Policy Client BranchTPA Date Enrolment Status Status
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Self: +
Min Age:
+
+
Max Age:
+
Is Payable by employee:
Spouse: +
Min Age:
+
+
Max Age:
+
Is Payable by employee:
Children: + +
Min Age:
+
+
Max Age:
+
Is Payable by employee:
+ +
+
+ +
+ Select Other Members: +
-
- Yes - No -
-
-
-
+ +
- - - - - - - - - - - - - - - - - - - - - - - + + + + +
Self:
Min Age:
Max Age:
Is Payable by employee:
Spouse:
Min Age:
Max Age:
Is Payable by employee:
Children: + +
Elders + Count:
Min Age:
Max Age:
Is Payable by employee:
+
Min Age:
+
+
Max Age:
+
Is Payable by employee: +
-
- -
-
- - -
-
- Select Other Members: - -
-
- - - - - - - - - - -
Elders Count:
Min Age:
Max Age:
Is Payable by employee:
-
-
+
+ -
- - + +
- +
- Yes, waived off - No +
-