diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c5111235..b77e8f5e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -31,6 +31,7 @@ $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderM $routes->get("sendextraparam", "ClientController::sendextraparam"); $routes->get("updateRenewalData", "ClientController::updateRenewalData"); $routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient"); +$routes->get("updateRenewalInsurerData", "ClientController::updateRenewalInsurerData"); // $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn"); // $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail"); // $routes->post("employeeUpload", "EmployeeRestController::employeeUpload"); @@ -441,13 +442,19 @@ $routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController:: // Test initiate Claim $routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); +$routes->get('departments',"EmployeeRestController::get_ticket_type"); +$routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data"); + +//api $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("logined", "RestAuthenticationController::logined"); $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); $routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); - + $routes->get('get_ticket_type',"EmployeeRestController::get_ticket_type"); + $routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data"); }); + $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index ad575e27..15533b25 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2002,13 +2002,14 @@ class ClientController extends AdminController ->join('policy_type', 'policy_type.id = policies.policy_type_id') ->where(['policies.insurer_id' => $insurer_id, 'policies.is_active' => 1]) ->findAll(); + $client_policy_list = $this->clientPolicyModel->getPolicyTypeForPolicyBinding($client_id); $cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->findAll(); - $client_policy_data['policy_end_date'] = date('d/m/Y', strtotime($client_policy_data['policy_end_date'])); - $fromDate = $client_policy_data['policy_end_date']; - $date = \DateTime::createFromFormat('d/m/Y', $fromDate); - $date->modify('+1 year'); - $newDate = $date->format('d/m/Y'); + // $client_policy_data['policy_end_date'] = date('d/m/Y', strtotime($client_policy_data['policy_end_date'])); + $fromDate = new \DateTime($client_policy_data['policy_end_date']); + $fromDate->modify('+1 year'); + $newDate = $fromDate->format('d/m/Y'); + // print_rr($client_policy_data['policy_end_date']);die(); @@ -2020,7 +2021,8 @@ class ClientController extends AdminController "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices, 'client_policy_list' => $client_policy_list, - 'end_date' => $newDate + 'end_date' => $newDate, + 'new_start_date' => date('d/m/Y', strtotime($client_policy_data['policy_end_date'])) ], 200); } else { return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200); @@ -2216,6 +2218,7 @@ class ClientController extends AdminController public function policyGMCTerms() { try { + // echo "
";
             // print_r($this->request->getPost());die;
             $this->myLogger->logme('error', 'Terms CREATE function called');
@@ -2225,7 +2228,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;
@@ -2243,12 +2245,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 {
@@ -2261,8 +2260,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;
@@ -2321,79 +2318,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(
@@ -2402,7 +2375,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);
@@ -2427,6 +2399,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');
@@ -2479,52 +2635,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(
@@ -2554,6 +2690,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()
     {
 
@@ -3161,7 +3385,6 @@ class ClientController extends AdminController
 
     public function createPolicyTermsHtmlAsJSON()
     {
-
         echo 'hi';
     }
 
@@ -3820,19 +4043,27 @@ 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 {
@@ -3955,6 +4186,14 @@ 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'])) {
@@ -4002,7 +4241,7 @@ class ClientController extends AdminController
                 }
                 
                 if (!isset($policyTerms['enrollment_display_key'])) {
-                    $policyTerms['enrollment_display_key'] = [];
+                    $policyTerms['enrollment_display_key'] = $this->existingGMCDisplayValueTransform($policyTerms);
                 }
 
             } else if($data[$i]['policy_type_id'] == 1){
@@ -4048,30 +4287,259 @@ class ClientController extends AdminController
                 }
                                 
                 if (!isset($policyTerms['enrollment_display_key'])) {
-                    $policyTerms['enrollment_display_key'] = [];
+                    $policyTerms['enrollment_display_key'] = $this->existingGPADisplayValueTransform($policyTerms);
                 }
                 
             }
 
-            foreach ($policyTerms as $key => $term) {
-                if ($term == "0") {
-                    $policyTerms[$key] = "No";  // Use = for assignment
-                } elseif ($term == "1") {
-                    $policyTerms[$key] = "Yes"; // Use = for assignment
-                }
-            }
-            
-
             // dd($policyTerms);
             // Re-encode the ordered policy terms
             $updatedPolicyTerms = json_encode($policyTerms);
-            // dd($updatedPolicyTerms);
+            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
@@ -4366,7 +4834,7 @@ class ClientController extends AdminController
             return $this->respond([
                 'status' => false,
                 'code' => 404,
-                'message' => 'No data found',
+                'message' => 'No Employee found',
                 'param' => $param,
                 'type' => $type,
                 'dataForClientAndInsurer' => $dataForClientAndInsurer,
@@ -4375,12 +4843,12 @@ class ClientController extends AdminController
         }
     } 
     
-    public function getTheEmpDataForClaimSearchByMobile($param, $type = 'mobile')
+    public function getTheEmpDataForClaimSearchByMobile($param, $type = 'mobile', $client_policy_id = null, $client_id = null)
     {   
         $field_name = 'employees.' . $type;
 
         // Construct the base query
-        $data = $this->clientPolicyModel
+        $query = $this->clientPolicyModel
             ->select("
                 clients.id AS client_id,
                 clients.client_name,
@@ -4395,24 +4863,37 @@ class ClientController extends AdminController
                 employees.email_corporate AS emp_email,
                 employees.relationship AS emp_relationship,
                 employee_polices.uhid AS policy_no,
-                employee_polices.tpa_id AS tpa_no
+                employee_polices.tpa_id AS tpa_no,
+                employee_polices.client_policy_id AS policy_id
             ")
-            ->join('clients', 'client_policy.client_id = clients.id', 'left')
-            ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
+            ->join('clients', 'client_policy.client_id = clients.id')
+            ->join('insurers', 'client_policy.insurer_id = insurers.id')
             ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
-            ->join('employees', 'clients.id = employees.client_id', 'left')
-            ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
+            ->join('employees', 'clients.id = employees.client_id')
+            ->join('employee_polices', 'employees.id = employee_polices.employee_id')
             ->where('client_policy.is_active', 1)
             ->where('insurers.is_active', 1)
             ->where('tpa.is_active', 1)
             ->where('employees.is_active', 1)
             ->where('employees.relationship', "Self")
             ->where('employee_polices.is_active', 1)
-            ->where($field_name, $param)
-            ->groupBy('employees.id')
-            ->orderBy('employees.id', 'DESC')
-            ->first();
-        
+            ->where($field_name, $param);
+
+            if (!empty($client_id)) {
+                $query->where('employees.client_id', $client_id);
+            }
+
+            if (!empty($client_policy_id)) {
+                $query->where('employee_polices.client_policy_id', $client_policy_id);
+            }
+            
+            $query->groupBy('employees.id')
+                ->orderBy('employees.id', 'DESC');
+            
+            $data = $query->get()->getRowArray();
+
+            // print_r(db_connect()->getLastQuery()); die;
+
         $memberData = [];
         $dataForClientAndInsurer = [];
 
@@ -4425,7 +4906,7 @@ class ClientController extends AdminController
 
         if(!empty($data) && count($data) > 0){
 
-            $memberData = $this->employeeModel->getEmployeeByEmployeeCode($data['emp_code']);
+            $memberData = $this->employeeModel->getEmployeeByEmployeeCode($data['emp_code'], $data['policy_id'], $client_id);
 
             $acms = $this->clientRMModel
                 ->select('user_profiles.id, user_profiles.first_name')
@@ -4448,6 +4929,7 @@ class ClientController extends AdminController
                 'message' => 'Data found',
                 'data' => $data,
                 'param' => $param,
+                'client_policy_id' => $client_policy_id,
                 'type' => $type,
                 'dataForClientAndInsurer' => $dataForClientAndInsurer,
                 'memberData' => $memberData,
@@ -4457,8 +4939,9 @@ class ClientController extends AdminController
             return $this->respond([
                 'status' => false,
                 'code' => 404,
-                'message' => 'No data found',
+                'message' => 'No Employee found',
                 'param' => $param,
+                'client_policy_id' => $client_policy_id,
                 'type' => $type,
                 'dataForClientAndInsurer' => $dataForClientAndInsurer,
                 'memberData' => $memberData,
@@ -4471,85 +4954,6 @@ class ClientController extends AdminController
     // -----------------------------------------------------------------------------------------------------
 
 
-
-    // private function preparePolicyData($renewalData)
-    // {   
-    //     $data = [
-    //         'issuer' => $renewalData['issuer_type_id'],
-    //         'client_id' => $renewalData['client_id'],
-    //         'client_branch_id' => $renewalData['branch_id'] ?? null,
-    //         'vehicle_id' => $renewalData['vehicle_id'],
-    //         'insurer_id' => $renewalData['insurer_id'],
-    //         'insurer_branch_id' => $renewalData['insurer_branch_id'],
-    //         'policy_type_id' => $renewalData['policy_type_id'],
-    //         'client_policy_id' => $renewalData['client_policy_id'] ?? null,
-    //         'policy_no' => $renewalData['policy_no'],
-    //         'policy_issue_date' => $renewalData['date_date_of_issue'],
-    //         'policy_start_date' => $renewalData['date_policy_start_date'],
-    //         'policy_end_date' => $renewalData['date_policy_end_date'],
-    //         'policy_holder_name' => $renewalData['insured'],
-    //         'status' => 'completed',
-    //         'is_active' => 1,
-    //         'tsi' => '500000',
-    //         'month' => '2025-02-01',
-    //         'ct_type' => 1,
-    //         'cd_ac_pk' => $renewalData['cd_ac_pk'] ?? null,
-    //     ];
-
-    //     $policyTransactionModel = new PolicyTransactionModel();
-    //     return $policyTransactionModel->insert($data);
-    // }
-
-    // private function prepareVehicleData($renewalData)
-    // {   
-    //     $vehicleData = [
-    //         'vehicle_no' => $renewalData['veh_no'],
-    //         'owner' => $renewalData['client_id'],
-    //         'branch_id' => ($renewalData['client_type_id'] == 1) ? $renewalData['branch_id'] : null,
-    //     ];
-
-    //     $vehicleModel = new VehicleModel();
-    //     return $vehicleModel->insert($vehicleData);
-    // }
-
-    // private function preparePtCoShareDetails($renewalData)
-    // {   
-    //     $ptCoShareDetails = [
-    //         'pt_id' => $renewalData['pt_id'],
-    //         'insurer_id' => $renewalData['insurer_id'],
-    //         'insurer_branch_id' => $renewalData['insurer_branch_id'],
-    //         'co_share_type' => 0,
-    //         'co_share_per' => 0.00,
-    //         'bp_amt' => 0.00,
-    //         'tp_amt' => 0.00,
-    //         'tep_amt' => 0.00,
-    //         'follower_policy_no' => $renewalData['policy_no'],
-    //     ];
-
-    //     $ptCoShareDetailsModel = new PTCOShareDetailsModel();
-    //     return $ptCoShareDetailsModel->insert($ptCoShareDetails);
-    // }
-
-    // private function prepareClientPolicy($renewalData)
-    // {
-    //     $clientPolicy = [
-    //         'client_id' => $renewalData['client_id'],
-    //         'client_branch_id' => $renewalData['branch_id'],
-    //         'policy_type_id' => $renewalData['policy_type_id'],
-    //         'insurer_id' => $renewalData['insurer_id'],
-    //         'insurer_branch_id' => $renewalData['insurer_branch_id'],
-    //         'policy_no' => $renewalData['policy_no'],
-    //         'policy_start_date' => $renewalData['date_policy_start_date'],
-    //         'policy_end_date' => $renewalData['date_policy_end_date'],
-    //         'policy_status' => 1,
-    //         'gst' => 18.00,
-    //         'cd_ac_pk' => $renewalData['cd_ac_pk'],
-    //     ];
-
-    //     $clientPolicyModel = new ClientPolicyModel();
-    //     return $clientPolicyModel->insert($clientPolicy);
-    // }
-
     public function updateRenewalData()
     {
         $db = db_connect();
@@ -4557,7 +4961,7 @@ class ClientController extends AdminController
         ->where('client_id IS NOT NULL')
         ->where('is_inserted != 1')
         ->get()
-        ->getResultArray();
+            ->getResultArray();
         // dd($renewalData);
 
         $successData = [];
@@ -4588,10 +4992,55 @@ class ClientController extends AdminController
         }
 
         kint::dump($successData);
-    }   
-    
+    }
+
+    public function updateRenewalInsurerData()
+    {
+        $db = db_connect();
+        $renewalData = $db->table('old_renewal_data_copy')
+        ->where('insurer_id IS NULL')
+        ->get()
+            ->getResultArray();
+        // dd($renewalData);
+
+        $successData = [];
+        foreach ($renewalData as $key => $value) {
+
+            $insurer_data = $this->insurerModel->where('name', $value['insurer_name'])->where('is_active', 1)->first();
+
+            if (!empty($insurer_data)) {
+
+                $insurer_branch_data = $this->insurerBranchModel->where('branch_name', $value['insurer_branch'])->first();
+                if (!empty($insurer_branch_data)) {
+                    $branch = $this->insurerBranchModel->where('insurer_id', $insurer_data['id'] ?? 0)->first();
+                    $value['insurer_id'] = $insurer_data['id'] ?? null;
+                    $value['insurer_branch_id'] = $branch['id'] ?? null;
+                } else {
+                    $value['insurer_id'] = $insurer_data['id'] ?? null;
+                    $value['insurer_branch_id'] = $this->prepareInsurerBranch($value);
+                }
+            } else {
+                $value['insurer_id'] = $this->prepareinsurer($value);
+                $value['insurer_branch_id'] = $this->prepareInsurerBranch($value);
+            }
+
+            // Update is_inserted field in DB
+            $db->table('old_renewal_data_copy')
+            ->where('id', $value['id'])
+            ->set([
+                'insurer_id' => $value['insurer_id'],
+                'insurer_branch_id' => $value['insurer_branch_id'],
+            ])
+                ->update();
+
+            $successData[] = ['id' => $value['id'], 'insurer' => $value['insurer_name'], 'insurer_id' => $value['insurer_id'], 'insurer_branch_id' => $value['insurer_branch_id'],];
+        }
+
+        kint::dump($successData);
+    }
+
     public function updateRenewalDataNotExistingClient()
-    {   
+    {
         $limit = $this->request->getGet('limit') ?? 10;
         $group = $this->request->getGet('group') ?? 2;
         $db = db_connect();
@@ -4599,22 +5048,22 @@ class ClientController extends AdminController
         ->where('client_id IS NULL')
         ->where('is_inserted = 0')
         ->where('client_type_id', $group)
-        // ->limit($limit)
-        ->get()
-        ->getResultArray();
+            // ->limit($limit)
+            ->get()
+            ->getResultArray();
         // dd($renewalData);
 
         $successData = [];
         foreach ($renewalData as $key => $value) {
 
             $client_data = $this->clientModel->where('client_name', $value['insured'])->where('is_active', 1)->first();
-            if(!empty($client_data)){
+            if (!empty($client_data)) {
                 $branch = $this->clientBranchModel->where('client_id', $client_data['id'] ?? 0)->first();
                 $value['branch_id'] = $branch['id'] ?? null;
                 $value['client_id'] = $client_data['id'] ?? null;
-            }else{
+            } else {
                 $value['client_id'] = $this->prepareClient($value);
-                if($value['client_type_id'] == 1){
+                if ($value['client_type_id'] == 1) {
                     $value['branch_id'] = $this->prepareClientBranch($value);
                 }
             }
@@ -4622,7 +5071,7 @@ class ClientController extends AdminController
             // Fix vehicle_id key (previously "vehicel_id")
             if ($value['policy_type_id'] == 8 && !empty($value['policy_type_id'])) {
                 $value['vehicle_id'] = $this->prepareVehicleData($value);
-            }else{
+            } else {
                 $value['vehicle_id'] = 0;
             }
 
@@ -4715,7 +5164,7 @@ class ClientController extends AdminController
     }
 
     private function prepareVehicleData($renewalData)
-    {   
+    {
         $VehicleModel = new VehicleModel();
 
         if ($renewalData['client_type_id'] == 1) {
@@ -4723,16 +5172,16 @@ class ClientController extends AdminController
         } else {
             $veh_no = $renewalData['insured'] . "_veh_no";
         }
-        
+
         $vehicleData = $VehicleModel->where('owner', $renewalData['client_id'])
-                                          ->where('is_active', 1)
-                                          ->findAll();
-        
+        ->where('is_active', 1)
+        ->findAll();
+
         if (!empty($vehicleData)) {
             $increment = count($vehicleData);
             $veh_no = $increment . "_" . $veh_no;
         }
-        
+
 
         $vehicleData = [
             'vehicle_no' => $veh_no,
@@ -4845,7 +5294,7 @@ class ClientController extends AdminController
     }
 
     private function prepareClientBranch($renewalData)
-    {   
+    {
         $branch_code = "BRANCH001";
         $short_name = explode(" ", $renewalData['insured'])[0];
         $unit = $short_name . " - " . $branch_code;
@@ -4861,11 +5310,11 @@ class ClientController extends AdminController
             'address1' => null,
             'address2' => null,
             'gst' => null,
-            'sez' => 0, 
-            'is_active' => 1, 
+            'sez' => 0,
+            'is_active' => 1,
             'units' => $unit
         ];
-        
+
 
         $ClientBranchModel = new ClientBranchModel();
         $id = $ClientBranchModel->insert($clientBranchData);
@@ -4873,11 +5322,11 @@ class ClientController extends AdminController
     }
 
     private function prepareClient($renewalData)
-    {   
+    {
 
-        if($renewalData['client_type_id'] == 1){
+        if ($renewalData['client_type_id'] == 1) {
             $short_name = explode(" ", $renewalData['insured'])[0];
-        }else{
+        } else {
             $short_name = $renewalData['insured'];
         }
 
@@ -4913,13 +5362,58 @@ class ClientController extends AdminController
             'email' => null,
             'addon_subheading' => null
         ];
-        
-        
+
+
 
         $ClientModel = new ClientModel();
         $id = $ClientModel->insert($clientData);
         return $id;
     }
-    
 
+    private function prepareInsurerBranch($renewalData)
+    {
+
+        $insurerBranchData = [
+            'insurer_id' =>  $renewalData['insurer_id'],
+            'branch_name' =>  $renewalData['insurer_branch'],
+            'branch_code' =>  $renewalData['insurer_branch'],
+            'address1' => null,
+            'address2' => null,
+            'city' => null,
+            'district' => null,
+            'state' => null,
+            'pincode' => null,
+        ];
+
+
+
+        $InsurerBranchModel = new InsurerBranchModel();
+        $id = $InsurerBranchModel->insert($insurerBranchData);
+        return $id;
+    }
+
+    private function prepareinsurer($renewalData)
+    {
+
+        $short_name1 = explode(" ", $renewalData['insurer_name'])[0];
+        $short_name2 = explode(" ", $renewalData['insurer_name'])[1];
+        $short_name = $short_name1 . ' ' . $short_name2;
+
+        $insurerData = [
+            'type' => "pvt",
+            'category' => "general",
+            'addition_add_day' => 0,
+            'deletion_add_day' => 0,
+            'name' => $renewalData['insurer_name'],
+            'short_name' =>  $short_name,
+            'insurer_logo' => null,
+            'is_multi_event' => 0, // Default is 0
+        ];
+
+        $InsurerModel = new InsurerModel();
+        $id = $InsurerModel->insert($insurerData);
+        return $id;
+    }
+    
+    
 }
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 40e85cd0..5b24dafe 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -2539,10 +2539,19 @@ class EmployeeRestController extends AdminController
                 if($ClientPolicyValue['policy_type_id'] == 1)
                 { 
                     $data['policy_terms'] =  $this->policyTermsFiter($terms,'gpa'); 
-                    $data['department_id'] = 3;
-                }else{ 
+                    $data['ticket_type_id'] = 2;
+                }else if($ClientPolicyValue['policy_type_id'] == 6)
+                { 
+                    $data['policy_terms'] =  $this->policyTermsFiter($terms,'gpa'); 
+                    $data['ticket_type_id'] = 3;
+                }else if($ClientPolicyValue['policy_type_id'] == 7)
+                { 
+                    $data['policy_terms'] =  $this->policyTermsFiter($terms,'gpa'); 
+                    $data['ticket_type_id'] = 4;
+                }else
+                {
                     $data['policy_terms'] =  $this->policyTermsFiter($terms,'gmc'); 
-                    $data['department_id'] = 4;
+                    $data['ticket_type_id'] = 1;
                 }
             
                 $data['client_id'] = $ClientPolicyValue['client_id'];
@@ -2720,9 +2729,7 @@ class EmployeeRestController extends AdminController
         }
 
 
-       
-    
-    return $finalarray;
+        return $finalarray;
         
     }
 
@@ -3103,90 +3110,195 @@ class EmployeeRestController extends AdminController
         return false;
 
     }
+
     //Get Data from post for inserting ticket and message
     public function initiateClaim()
     {
 
         $received_data = $this->request->getPost();
+        // print_r($received_data); die;
         $employee_id = $received_data['emp_id'];
         $client_policy_id = $received_data['client_policy_id'];
         $insured_emp_id = $received_data['insured_emp_id'];
 
-        $sql = "select cp.policy_type_id as ticket_type_id,
-        cl_rm.user_id as acm_id,
-        cp.insurer_id as insurer_id,
-        cp.tpa_id as tpa_id,
-        emp.client_id ,
-        emp.id as emp_id,
-        emp_pol.uhid as policy_no,
-        emp.emp_code,
-        emp_pol.tpa_id as tpa_no,
-        emp.name as emp_name,
-        emp.email_corporate as emp_mail,
-        emp.mobile as emp_mobile,
-        empl.id as insured_emp_id,
-        empl.name as insured_name,
-        empl.relationship
+        $sql = "
+            select 
+                cp.policy_type_id,
+                cl_rm.user_id as acm_id,
+                cp.insurer_id as insurer_id,
+                cp.tpa_id as tpa_id,
+                emp.client_id ,
+                emp.id as emp_id,
+                emp_pol.uhid as policy_no,
+                emp.emp_code,
+                emp_pol.tpa_id as tpa_no,
+                emp.name as emp_name,
+                emp.email_corporate as emp_mail,
+                emp.mobile as emp_mobile,
+                empl.id as insured_emp_id,
+                empl.name as insured_name,
+                empl.relationship,
+                
+                CASE 
+                    WHEN cp.policy_type_id IN (2, 3, 4, 5) THEN 1
+                    WHEN cp.policy_type_id = 1 THEN 2
+                    WHEN cp.policy_type_id = 6 THEN 3
+                    WHEN cp.policy_type_id = 7 THEN 4
+                    ELSE NULL 
+                END AS ticket_type_id
 
+            from employees emp 
 
-
-        from employees emp 
-
-        left join employees empl on empl.id = $insured_emp_id and empl.is_active = 1 and empl.emp_status = 'active'
-        left join employee_polices emp_pol on empl.id = emp_pol.employee_id and emp_pol.client_policy_id = $client_policy_id and emp_pol.is_active = 1 
-        left join client_policy cp on cp.id = emp_pol.client_policy_id and cp.is_active = 1
-        left join client_rm cl_rm on cl_rm.client_id = empl.client_id and cl_rm.is_active = 1 and cl_rm.level = 3 
+            left join employees empl on empl.id = $insured_emp_id and empl.is_active = 1 and empl.emp_status = 'active'
+            left join employee_polices emp_pol on empl.id = emp_pol.employee_id and emp_pol.client_policy_id = $client_policy_id and emp_pol.is_active = 1 
+            left join client_policy cp on cp.id = emp_pol.client_policy_id and cp.is_active = 1
+            left join client_rm cl_rm on cl_rm.client_id = empl.client_id and cl_rm.is_active = 1 and cl_rm.level = 3 
 
         where emp.id = $employee_id and emp.is_active = 1 and emp.emp_status = 'active'
         limit 1 ";
 
-        $fetchData = $this->employeeModel->query($sql)->getResultArray()[0];
-        $fetchData['claim_status_id'] = $this->claimStatusModel->select('id')->where('ticket_type', $fetchData['ticket_type_id'])->first()['id'];
-        $fetchData['priority'] = 1;
-        $fetchData['mode_of_intimation'] = 1;
-        $fetchData['hospital_name'] = $received_data['hospital_name'];
+        $emp_ticket_data = $this->employeeModel->query($sql)->getResultArray();
+        // print_r(db_connect()->getLastQuery()); die;
 
-        $insert_status = $this->ticketMaster->insert($fetchData);
-        $ticket_id = $this->ticketMaster->insertID();
+        if(!empty($emp_ticket_data)){
 
-        if ($insert_status && !empty($ticket_id)) {
-            $mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id));
-            if (gettype($mail_sent_status) == 'array') {
-                $message = 'Claim Iniated Successfully';
-                return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
-            } else {
-                $mail_sent_status = json_decode($mail_sent_status);
-            }
-            // dd(gettype($mail_sent_status));
+            $fetchData = $emp_ticket_data[0];
+            $fetchData['claim_status_id'] =  $this->claimStatusModel
+                ->select('id')
+                ->where('ticket_type', $fetchData['ticket_type_id'])
+                ->orderBy('id', 'asc')
+                ->first()['id'];
 
-            if ($mail_sent_status->status == 'success') {
-                $sent_message_data['ticket_id'] = $ticket_id;
-                $sent_message_data['sender'] = 'staff';
-                $sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
-                $sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
-                $sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
+            $fetchData['priority'] = 1;
+            $fetchData['mode_of_intimation'] = 1;
+            $fetchData = array_merge($fetchData, $received_data);
 
-                $message_insert_status = $this->ticketMessage->insert($sent_message_data);
+            // print_r($fetchData); die;
+            $insert_status = $this->ticketMaster->insert($fetchData);
+            $ticket_id = $this->ticketMaster->insertID();
 
-                if ($message_insert_status) {
-                    $message = 'Claim Initiated Successfully';
+            if ($insert_status && !empty($ticket_id)) {
+
+                $messagesData = [
+                    'ticket_id' => $ticket_id ?? null,
+                    'sender' => 'user',
+                    'claim_status' => $fetchData['claim_status_id'] ?? null,
+                    'emp_mail' => $fetchData['emp_mail'] ?? null,
+                    'mail_subject' => $fetchData['subject'] ?? null,
+                    'mail_content' => $fetchData['message'] ?? null,
+                ];
+
+                if (!empty($messagesData['ticket_id'])) {
+                    $TicketMessageModel = new TicketMessageModel();
+                    $TicketMessageModel->insert($messagesData);
+                }
+
+                $mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id));
+                if (gettype($mail_sent_status) == 'array') {
+                    $message = 'Claim Iniated Successfully';
                     return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
                 } else {
-                    $message = 'Claim Initiated, Mail Sent Successfully';
-                    $this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, Failed to store message:$ticket_id ");
+                    $mail_sent_status = json_decode($mail_sent_status);
+                }
+                // dd(gettype($mail_sent_status));
+
+                if ($mail_sent_status->status == 'success') {
+                    $sent_message_data['ticket_id'] = $ticket_id;
+                    $sent_message_data['sender'] = 'staff';
+                    $sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
+                    $sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
+                    $sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
+
+                    $message_insert_status = $this->ticketMessage->insert($sent_message_data);
+
+                    if ($message_insert_status) {
+                        $message = 'Claim Initiated Successfully';
+                        return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
+                    } else {
+                        $message = 'Claim Initiated, Mail Sent Successfully';
+                        $this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, Failed to store message:$ticket_id ");
+                        return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
+                    }
+                } else {
+
+                    $message = 'Claim Initiated, Failed to send Mail ';
+                    $this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id ");
                     return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
                 }
             } else {
-
-                $message = 'Claim Initiated, Failed to send Mail ';
-                $this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id ");
+                $message = 'Something Went Wrong';
                 return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
             }
-        } else {
-            $message = 'Something Went Wrong';
-            return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
+
+        }else{
+            return $this->response->setJSON(['status' => false, 'code' => 200, 'message' => 'The employee is not active.'])->setStatusCode(404);
         }
     }
-    
+
+    //department
+    public function get_ticket_type()
+    {
+        $ticket_type = $this->ticketController->ticketType;
+        $ticket_type = array_map(fn($value, $key) => (object) ['id' => $key, 'name' => $value], array_values($ticket_type), array_keys($ticket_type));
+        // print_r($ticket_type); die;
+        return $this->response->setJSON(['ticket_type' => $ticket_type])->setStatusCode(200);
+    }
+
+    //ticket data
+    public function get_ticket_data()
+    {
+        $priorityType = $this->ticketController->priorityType;
+        $modeOFIntimate = $this->ticketController->modeOFIntimate;
+        $claimType = $this->ticketController->claimType;
+        $relationshipType = $this->ticketController->relationshipType;
+        $ticketTypeArray = $this->ticketController->ticketType;
+
+
+        $emp_id = $this->request->getGet('emp_id');
+        $ticket_type = $this->request->getGet('ticket_type') ?? null;
+        $ticket_id = $this->request->getGet('ticket_id') ?? null;
+        // dd($emp_id);
+
+        if (empty($emp_id)) {
+            return $this->response->setJSON(['status' => false, 'code' => 200, 'message' => 'emp_id is required.'])->setStatusCode(404);
+        }
+
+        $TicketMasterModel = new TicketMasterModel();
+        $ticket_data = $TicketMasterModel->get_ticket_data($emp_id, $ticket_type, $ticket_id);
+
+        if (!empty($ticket_data)) {
+
+            $client_claim_status = [
+                'Received' => [1, 2, 3, 4, 15, 16, 17, 18, 25, 26, 27, 28, 35, 36, 37, 38],
+                'Rejected' => [8, 49, 55, 60],
+                'Cancelled' => [13, 47, 53, 58],
+                'Returned' => [14, 48, 54, 59],
+                'Closed' => [12, 22, 32, 42],
+                'Approved' => [9, 20, 30, 40],
+                'Settled' => [11, 24, 34],
+                'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56],
+            ];
+
+            foreach ($ticket_data as $key => $value) {
+                foreach ($client_claim_status as $claim_key => $claim_value) {
+                    if (in_array($value['claim_status_id'], $claim_value)) { // Corrected argument order
+                        $ticket_data[$key]['claim_status'] = $claim_key ?? null; // Assign back to the main array
+                    }
+                }
+                $ticket_data[$key]['priority_type'] = $priorityType[$value['priority']] ?? null;
+                $ticket_data[$key]['mode_of_intimate_type'] = $modeOFIntimate[$value['mode_of_intimation']] ?? null;
+                $ticket_data[$key]['relationship_type'] = ucfirst($value['relationship']) ?? null;
+                $claimPrimaryTypey = "1";
+                if (in_array($value['claim_type'], [2, 3, 4])) {
+                    $claimPrimaryTypey = "2";
+                }
+                $ticket_data[$key]['claim_type_value'] = $claimType[$claimPrimaryTypey][$value['claim_type']] ?? null;  
+                $ticket_data[$key]['ticket_policy_type'] = $ticketTypeArray[$value['ticket_type_id']] ?? null;
+
+            }
+        }
+
+        return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200);
+    }
 
 }
\ No newline at end of file
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index 9cf89d53..ef741d21 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -287,6 +287,10 @@ class MasterController extends AdminController
             $data['deletion_add_day'] = 1;
         }
 
+        if($this->request->getPost('is_multi_event')){
+            $data['is_multi_event'] = 1;
+        }
+
         $data['created_by'] = get_session_userid();
         $data['insurer_logo'] = $file_name;
         
@@ -371,6 +375,12 @@ class MasterController extends AdminController
             $data['deletion_add_day'] = 0;
         }
 
+        if($this->request->getPost('is_multi_event')){
+            $data['is_multi_event'] = 1;
+        }else{
+            $data['is_multi_event'] = 0;
+        }
+
         $update             = $this->insurerModel->update($id,$data);
         if($update){
             echo json_encode(array("status" => true , 'data' => $data));
@@ -1723,7 +1733,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',
@@ -1732,6 +1743,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/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 69852bca..348417bf 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -274,7 +274,7 @@ class PolicyTransactionController extends BaseController
         // Separate Insurer and TPA Branch IDs and IDs
         if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
             list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
-            if (isset($data['tpa'])) {
+            if (isset($data['tpa']) && !empty($data['tpa'])) {
                 list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']);
             }
         }
@@ -1117,7 +1117,7 @@ class PolicyTransactionController extends BaseController
         // Separate Insurer and TPA Branch IDs and IDs
         if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
             list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
-            if (isset($data['tpa'])) {
+            if (isset($data['tpa']) && !empty($data['tpa'])) {
                 list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']);
             }
         }
@@ -2700,7 +2700,7 @@ class PolicyTransactionController extends BaseController
         // Build query
         $db = db_connect();
         $builder = $db->table("cash_deposit")
-            ->where('cd_ac_no', $cd_ac_no)
+            ->where('cd_ac_pk', $cd_ac_no)
             ->where('is_active', 1)
             ->orderBy('id', 'desc')
             ->limit(1);
@@ -2715,6 +2715,8 @@ class PolicyTransactionController extends BaseController
                 'status' => true,
                 'code' => 200,
                 'data' => $result,
+                'base_premium' => $base_premium,
+                'cd_ac_no' => $cd_ac_no,
                 'base_premium_greater_than_balance' => $base_premium_greater_than_balance,
             ], 200);
         }
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index e1302f55..6da26715 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -26,14 +26,15 @@ class TicketController extends BaseController
     use ResponseTrait;
 
     protected $myLogger;
-    protected $ticketType;
-    protected $priorityType;
-    protected $relationshipType;
-    protected $modeOFIntimate;
-    protected $claimType;
-    protected $claimStatus;
-    protected $placeHolders;
-    protected $extraFields;
+    public $ticketType;
+    public $priorityType;
+    public $relationshipType;
+    public $modeOFIntimate;
+    public $claimType;
+    public $claimStatus;
+    public $placeHolders;
+    public $extraFields;
+    public $nonIDReason;
 
     protected $clientModel;
     protected $ticketMasterModel;
@@ -98,7 +99,8 @@ class TicketController extends BaseController
             4 => "Trigger 4",
             5 => "Trigger 5",
             6 => "Trigger 6",
-            7 => "Trigger 7"
+            7 => "Trigger 7",
+            8 => "Trigger 8",
         ];
         $this->placeHolders = [
 
@@ -114,7 +116,8 @@ class TicketController extends BaseController
             '((AUTO_QUERY_CONTENT))' => 'auto_query_content',
         ];
         $this->extraFields = [
-
+            1 => ['non_id_reason'],
+            10 => ['pay_initiate_date'],
             3 => ['raised_date'],
             4 => ['raised_date'],
             5 => ['claim_number', 'registration_date'],
@@ -137,6 +140,13 @@ class TicketController extends BaseController
             53 => ['cancel_remark'],
             58 => ['cancel_remark'],
         ];
+        $this->nonIDReason = [
+            "Newborn Baby" => "Newborn Baby",
+            "Newly Wedded Spouse" => "Newly Wedded Spouse",
+            "Policy Pending" => "Policy Pending",
+            "New Joinee" => "New Joinee",
+            "Exceptional Case" => "Exceptional Case"
+        ];
 
         $this->ticketMasterModel = new TicketMasterModel();
         $this->claimStatus = new TicketClaimStatusModel();
@@ -296,7 +306,8 @@ class TicketController extends BaseController
             'ticket_type' => $this->ticketType,
             'priorityType' => $this->priorityType,
             'relationshipType' => $this->relationshipType,
-            'modeOFIntimate' => $this->modeOFIntimate
+            'modeOFIntimate' => $this->modeOFIntimate,
+            'nonIDReason' => $this->nonIDReason
         ];
 
         switch ($ticket_type) {
@@ -528,6 +539,12 @@ class TicketController extends BaseController
             $ticket_data['settled_date'] = change_date_format($ticket_data['settled_date'], null, $out_put_format);
         }
 
+        if (empty($ticket_data['pay_initiate_date'])) {
+            $ticket_data['pay_initiate_date'] = null;
+        } else {
+            $ticket_data['pay_initiate_date'] = change_date_format($ticket_data['pay_initiate_date'], null, $out_put_format);
+        }
+
         return $ticket_data;
     }
 
@@ -593,6 +610,17 @@ class TicketController extends BaseController
         $data['policy_type']  = $this->ticketType;
         $data['placeHolders'] = $this->placeHolders;
         $data['ticket_data']  = $this->ticketMailTemplateModel->where('is_active', 1)->findAll();
+
+        foreach ($data['ticket_data'] as $key => $ticket_data) {
+
+            $tooltip_array = $this->claimStatus->select('claim_status')->where('ticket_type',$data['ticket_data'][$key]['ticket_type'])->where('trigger_type',$data['ticket_data'][$key]['trigger_type'])->where('is_active',1)->first();
+            if (isset($tooltip_array) && $tooltip_array != null){
+                $data['ticket_data'][$key]['tool_tip'] = $tooltip_array['claim_status'];
+            }else{
+                $data['ticket_data'][$key]['tool_tip'] =$data['ticket_data'][$key]['template_name'];
+            }
+        }
+        // dd($data['ticket_data']);
         $data['ticket_type']  = $this->ticketType;
         $data['trigger_type'] = $this->triggerType;
         return $this->loadLayout('ticket_mail_template', $data);
@@ -621,6 +649,21 @@ class TicketController extends BaseController
         } elseif ($action == 2) {
             $table_id = (int)$this->request->getPost('id');
             $data = $this->ticketMailTemplateModel->where('id', $table_id)->where('is_active', 1)->first();
+            if ($data && isset($data['ticket_type']) && isset($data['trigger_type'])) {
+                $tooltip_array = $this->claimStatus->select('claim_status')
+                    ->where('ticket_type', $data['ticket_type'])
+                    ->where('trigger_type', $data['trigger_type'])
+                    ->where('is_active', 1)
+                    ->first();
+                
+                $data['tool_tip'] = (isset($tooltip_array['claim_status'])) 
+                    ? $tooltip_array['claim_status'] 
+                    : $data['template_name'];
+            } else {
+                // Handle case where $data is null or missing required fields
+                $data = $data ?: []; // Ensure $data is an array if null
+                $data['tool_tip'] = $data['template_name'];
+            }
             if ($data) {
                 return $this->respond(['status' => true, 'data' => $data], 200);
             } else {
@@ -1381,6 +1424,12 @@ class TicketController extends BaseController
                 $lastMatchedStatus = $status;
             }
         }
+
+        if($lastMatchedStatus == 1){
+            if(!empty($incoming_form_values['tpa_no'])){
+                $lastMatchedStatus = 2;
+            }
+        }
     
         return $lastMatchedStatus;
     }
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 3f0d7a43..c8fcb855 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -259,6 +259,7 @@ class ClientPolicyModel extends Model
         ->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
         ->where('client_id', $clientId)
         ->where('insurer_id', $insurerId)
+        ->where('cash_deposit.is_active', 1)
         ->get()
         ->getRow();
 }
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index d8fd4894..14ec368d 100755
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -240,9 +240,9 @@ class EmployeeModel extends Model
         return $results;
     }
 
-    public function getEmployeeByEmployeeCode($emp_code)
+    public function getEmployeeByEmployeeCode($emp_code, $client_policy_id = null, $client_id = null)
     {
-        return $this->select("
+        $query =  $this->select("
             employees.id AS emp_id,
             employees.name AS emp_name,
             employees.emp_code,
@@ -255,9 +255,22 @@ class EmployeeModel extends Model
         ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
         ->where('employees.is_active', 1)
         ->where('employee_polices.is_active', 1)
-        ->where('employees.emp_code', $emp_code)    
-        ->groupBy('employees.id')
-        ->findAll();
+        ->where('employees.emp_code', $emp_code);
+
+        if(!empty($client_id)){
+            $query->where('employees.client_id', $client_id);    
+        }
+
+        if(!empty($client_policy_id)){
+            $query->where('employee_polices.client_policy_id', $client_policy_id);    
+        }
+
+        $query->groupBy('employees.id');
+        $data = $query->findAll();
+
+        return $data;
+
+
     }
 
 }
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index 246609cd..bb5f5954 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -501,8 +501,8 @@ class PolicyTransactionModel extends Model
             ->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
             ->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
             ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
-            ->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left')
-            ->join('insurer_branch', 'policy_transaction.insurer_branch_id = insurer_branch.id', 'left')
+            ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
+            ->join('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left')
             ->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left')
             ->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
             ->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php
index 4cb59773..878fad2e 100644
--- a/app/Models/TicketMasterModel.php
+++ b/app/Models/TicketMasterModel.php
@@ -68,6 +68,10 @@ class TicketMasterModel extends Model
         'return_remark',
         'cancel_remark',
         'awb_no_courier_name',
+
+        'non_id_reason',
+        'head_rejection_reason',
+        'pay_initiate_date',
         
     ]; 
       
@@ -676,5 +680,27 @@ class TicketMasterModel extends Model
             return $result;
         }
     }
+
+    //api
+    public function get_ticket_data($emp_id, $ticket_type = null, $ticket_id = null)
+    {
+        $query = $this->select('ticket_master.*, tms.mail_subject as subject')
+            ->join('ticket_messages tms', 'ticket_master.id = tms.ticket_id', 'left')
+            ->where('ticket_master.is_active', 1)
+            ->where('ticket_master.emp_id', $emp_id);
+
+        if (!empty($ticket_id)) {
+            $query->where('ticket_master.id', $ticket_id);
+        }
+
+        if (!empty($ticket_type)) {
+            $query->where('ticket_master.ticket_type_id', $ticket_type);
+        }
+
+        $data = $query->findAll();
+        //  dd($data, db_connect()->getLastQuery());
+        return $data;
+    }
+    
     
 }
diff --git a/app/Views/insurer_basic_info.php b/app/Views/insurer_basic_info.php
index 80cf1599..524f2604 100755
--- a/app/Views/insurer_basic_info.php
+++ b/app/Views/insurer_basic_info.php
@@ -103,7 +103,8 @@ input:checked + .slider:before {
                         
 
                         
-
+ +

> @@ -112,6 +113,15 @@ input:checked + .slider:before {
+ +
+ + +
+
@@ -133,7 +143,7 @@ input:checked + .slider:before {
-
+
" width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar" />
diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 0587df3e..4321896f 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -804,7 +804,7 @@ $(`#tpa_${i}`).val(tpa).trigger('change'); $(`#proposed_insurer_${i}`).val(insurer).trigger('change'); $(`#proposed_tpa_${i}`).val(tpa).trigger('change'); - $('#policy_start_date').val(res.data.policy_end_date); + $('#policy_start_date').val(res.new_start_date); $('#policy_end_date').val(res.end_date); console.log($(`#policy_type_id_${i}_${random_id}`)); console.log($(`#insurer_${i}`)); diff --git a/app/Views/policy_gmc_terms.php b/app/Views/policy_gmc_terms.php index 93f24a59..68ae324d 100755 --- a/app/Views/policy_gmc_terms.php +++ b/app/Views/policy_gmc_terms.php @@ -1012,11 +1012,29 @@ $("#policyJsonForm").submit(function(event) { return; } + + var specialConditions = []; + + $(".removeDom").each(function () { + var isChecked = $(this).find("input[name='special_condition_display[]']").is(":checked"); + + if (isChecked) { + var label = $(this).find("input[name='special_condition_label[]']").val(); + var input = $(this).find("input[name='special_condition_input[]']").val(); + + specialConditions.push({ [label]: input }); + } + }); + + console.log("specialConditions", specialConditions); + + $('.loader').fadeIn(); $('.loader-mask').fadeIn(); var formData = new FormData($('#policyJsonForm')[0]); var policy_form_action = ''; + formData.append("special_condition_display_value", JSON.stringify(specialConditions)); $.ajax({ data: formData, @@ -1140,6 +1158,25 @@ $('body').on('click', '.btnPolicyMaster', function() { element.value = " "; } else { element.value = jsonObject[key][index]; + + if (key.includes("special_condition_label")) { + let checkbox = $(element).closest('.form-group').find('input[name="special_condition_display[]"]'); + console.log("First element:", element); + + if (checkbox.length) { + console.log("Checkbox found:", checkbox); + + // Correct way to set the 'id' attribute + let formattedValue = jsonObject[key][index].replace(/[\s\-\/,&]+/g, '').toLowerCase(); + console.log('formattedValue', formattedValue); + checkbox.attr('id', formattedValue + '_display'); + + console.log("Updated Checkbox:", checkbox); + } else { + console.log("Checkbox not found for:", element); + } + } + } }); } @@ -1534,7 +1571,7 @@ function specialCondition(count = 0) { var index = $('.modifyclassinput').length; var appendElement = `
- +
-
-
- -
+
- - -
-
-
-
- - -
-
-
-
- - -
-
-
- -
-
-
- - -
+
-
-
- - +
+
+
+
+ + +
+

+ Search by Client, Branch, and Policy + +

+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+
- +
+
+ + \ No newline at end of file diff --git a/app/Views/ticket_type_modal.php b/app/Views/ticket_type_modal.php index 262698f5..d16b53a9 100644 --- a/app/Views/ticket_type_modal.php +++ b/app/Views/ticket_type_modal.php @@ -19,7 +19,7 @@