diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index b7a4d343..3ba36f45 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2148,6 +2148,29 @@ class ClientController extends AdminController } } + public function generateKycPrimaryTable($client_id){ + + $db = db_connect(); + $builder = $db->table('kyc_docs kd'); + $builder->select('kd.*, ck.file_name AS upload_doc_name'); + $builder->join('clients c', 'kd.kyc_type_id = c.entity_type_id'); + $builder->join( + 'client_kyc_documents ck', + 'kd.id = ck.kyc_doc_type_id AND ck.client_id = c.id AND ck.is_active = 1', + 'left' + ); + $builder->where('c.id', $client_id); + $builder->groupBy(['kd.id', 'ck.file_name']); + + $query = $builder->get(); + $result['data'] = $query->getResult(); + + $table = view('client_kyc_primary_table', $result); + + print_r($table); + + } + public function getPolicesByInsurerId($id = null) { $this->myLogger->logme('error', 'getPolicesByInsurerId function called'); @@ -2659,194 +2682,269 @@ 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("suminsuredenhancement_display")) { + // $data['Sum Insured Enhancement'] = $this->request->getPost("suminsuredenhancement"); + // } + + // 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 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"); - } + // Mapping of POST keys to display labels + $fields = [ + 'waiverofpreexistingdiseases' => 'Waiver of Pre-existing Diseases', + 'waiverof1,2,3&4thyearexclusions' => 'Waiver of 1, 2, 3 & 4th year Exclusions', + 'waiverof30dayswaitingperiod' => 'Waiver of 30 days waiting period', + 'suminsuredenhancement' => 'Sum Insured Enhancement', + 'waiver_of_90_days_waiting_period' => 'Waiver of 90 Days Waiting Period', + 'waiver_of_other_waiting_periods' => 'Waiver of Other Waiting Periods', + 'maternity_benefit' => 'Maternity Benefit', + '9monthwaitingperiodwaived' => '9-month waiting Period - waived', + 'maternitycoverage' => 'Maternity Coverage', + 'twindelivery' => 'Twin Delivery', + 'well_baby_well_mother_expenses' => 'Well baby / Well Mother Expenses', + 'preandpostnatal' => 'Pre and Post natal', + 'infertility_treatment_coverage' => 'Infertility Treatment Coverage', + 'babyday1cover' => 'Baby Day 1 Cover', + 'coverfromthedateofjoining' => 'Cover from the date of Joining', + 'mid_term_addition_of_new_born_newly_wedded_spouse' => 'Mid Term Addition of New Born / Newly Wedded Spouse', + 'prehospitalizationcover' => 'Pre Hospitalization Cover', + 'posthospitalizationcover' => 'Post Hospitalization Cover', + 'congenitaldiseasesinternal' => 'Congenital Diseases - Internal', + 'congenitaldiseasesexternal' => 'Congenital Diseases - External', + 'copayzonewisecopay' => 'Co-Pay/Zone wise Co Pay', + 'roomrentlimit' => 'Room Rent Limit', + 'icu_limit' => 'ICU Limit', + 'proportionatedeductionclause' => 'Proportionate Deduction Clause', + 'ailmentcapping' => 'Ailment capping', + 'ailment_capping_details' => 'Ailment capping Details', + 'corporatebuffer' => 'Corporate Buffer', + 'non_admissible_contingency_corporate_buffer' => 'Non-Admissible / Contingency Corporate Buffer', + 'ambulancecharges' => 'Ambulance Charges', + 'airambulance' => 'Air Ambulance', + 'reasonableandcustomarycharges' => 'Reasonable and Customary Charges', + 'daycaretreatment' => 'Day Care Treatment', + 'lasiksurgery' => 'Lasik Surgery', + 'ayudhtreatmentcover' => 'AYUSH treatment cover', + 'moderntreatmentsasperirdai' => 'Modern treatments as per IRDAI', + 'opd_treatment' => 'OPD Treatment', + 'days_of_discharge' => 'Claim Intimation Clause', + 'days_from_dod' => 'Claim Submission', + 'terrorism' => 'Terrorism', + 'widower_cover' => 'Widower Cover', + 'breavement_cover' => 'Breavement Cover' + ]; - if ($this->request->getPost("suminsuredenhancement_display")) { - $data['Sum Insured Enhancement'] = $this->request->getPost("suminsuredenhancement"); - } - - 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); + foreach ($fields as $postKey => $label) { + $displayKey = $postKey . '_display'; + $value = $this->request->getPost($postKey); + if ($this->request->getPost($displayKey) && $value !== null && $value !== '') { + $data[$label] = $value; } } - - if(isset($data) && !empty($data)){ - return $data; - }else{ - $data = []; - return $data; + + // Handle special conditions + if ($this->request->getPost("special_condition_display_value")) { + $specialConditionKeyValue = json_decode($this->request->getPost("special_condition_display_value"), true); + if (is_array($specialConditionKeyValue) && count($specialConditionKeyValue) > 0) { + $mergedArray = array_merge(...array_map(fn($item) => (array) $item, $specialConditionKeyValue)); + // Only add non-empty values + foreach ($mergedArray as $k => $v) { + if ($v !== null && $v !== '') { + $data[$k] = $v; + } + } + } } - + + return $data; } + public function getterms() { $client_policy_id = $this->request->getVar('client_policy_id'); @@ -3006,92 +3104,145 @@ 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 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"); - } + // Map POST keys to display labels + $fields = [ + 'accidentalDeathBenefit' => 'Accidental Death Benefit', + 'permanentTotalDisablement' => 'Permanent Total Disablement', + 'permanentPartialDisablement' => 'Permanent Partial Disablement', + 'temporaryTotalDisablementBenefit' => 'Temporary Total Disablement Benefit', + 'medical_expenses_medical_extension' => 'Medical Expenses / Medical Extension (IPD)', + 'opd_treatment_cover' => 'OPD Treatment Cover', + 'ambulanceCharges' => 'Ambulance Charges', + 'repatriation_of_mortal_remains' => 'Repatriation of Mortal Remains', + 'childrenEducationWelfareFund' => 'Children Education Welfare Fund', + 'terrorism' => 'Terrorism', + 'worldwideCover' => 'Worldwide Cover', + 'family_transportation_benefits' => 'Family Transportation Benefits', + 'fractures_dislocation_burns' => 'Fractures / Dislocation / Burns', + 'coma' => 'Coma', + 'carriageOfDeadBody' => 'Carriage of Dead Body', + 'compassionateVisitExpenses' => 'Compassionate Visit Expenses', + 'travel_expenses_for_medical_treatment' => 'Travel expenses for Medical Treatment', + 'daily_cash_allowance' => 'Daily cash Allowance', + 'artifical_limb_and_prosthesis' => 'Artifical Limb and Prosthesis', + 'animalSnakeInsectBite' => 'Animal/Snake/Insect Bite', + 'air_ambulance' => '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); + foreach ($fields as $postKey => $label) { + $displayKey = $postKey . '_display'; + $value = $this->request->getPost($postKey); + if ($this->request->getPost($displayKey) && $value !== null && $value !== '') { + $data[$label] = $value; } } - // print_r($data); die; - if (isset($data) && !empty($data)) { - return $data; - } else { - $data = []; - return $data; + // Handle GPA special conditions + if ($this->request->getPost("gpa_special_condition_display_value")) { + $specialConditionKeyValue = json_decode($this->request->getPost("gpa_special_condition_display_value"), true); + if (is_array($specialConditionKeyValue) && count($specialConditionKeyValue) > 0) { + $mergedArray = array_merge(...array_map(fn($item) => (array) $item, $specialConditionKeyValue)); + foreach ($mergedArray as $k => $v) { + if ($v !== null && $v !== '') { + $data[$k] = $v; + } + } + } } + + return $data; } public function getPolicyGPATerms() diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index ae86e534..cb01779e 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -51,7 +51,7 @@ use CodeIgniter\API\ResponseTrait; use Illuminate\Http\Request; use App\Controllers\EmployeeServiceController; - +use App\Models\ClaimFilesModel; use Kreait\Firebase\Factory; use Kreait\Firebase\Messaging\CloudMessage; use Kreait\Firebase\Messaging\Notification; @@ -3417,11 +3417,19 @@ class EmployeeRestController extends AdminController { $received_data = $this->request->getPost(); - // print_r($received_data); die; + $get_file_data = $this->request->getFiles('claim_doc'); + // print_r($get_file_data); die; $employee_id = $received_data['emp_id']; $client_policy_id = $received_data['client_policy_id']; $insured_emp_id = $received_data['insured_emp_id']; + $file_data = ""; + if(isset($get_file_data) && !empty($get_file_data)){ + $file_path = WRITEPATH . 'uploads/claim_files/'; + $file_data = multi_file_Upload($get_file_data, $file_path); + } + + if (empty($received_data['doa'])) { $received_data['doa'] = null; } else{ @@ -3502,6 +3510,8 @@ class EmployeeRestController extends AdminController if ($insert_status && !empty($ticket_id)) { + $this->handleCliamFiles($file_data, $ticket_id); + //insert first history $this->ticketController->putHistoryAfterInsert($fetchData, $ticket_id); @@ -3555,6 +3565,30 @@ class EmployeeRestController extends AdminController } } + public function handleCliamFiles($data, $ticket_id) + { + if(!empty($data) && !empty($ticket_id)) + { + $insert_ids = []; + $claim_file = new ClaimFilesModel(); + foreach ($data as $key => $value) { + + $data = [ + 'ticket_id' => $ticket_id, + 'doc_name' => $value['file_name'], + 'url' => $value['file_path'], + 'file_type' => 2, + ]; + + $insert_ids[] = $claim_file->insert($data); + } + + return $insert_ids; + } + + return []; + } + //department // public function get_ticket_type() // { @@ -3572,12 +3606,17 @@ class EmployeeRestController extends AdminController $emp_code = $this->request->getGet('emp_code'); if (empty($client_id) || empty($emp_code)) { + $this->myLogger->logme('error', "Missing required parameters: client_id={$client_id}, emp_code={$emp_code}"); - return $this->response->setJSON([ - 'status' => false, - 'code' => 400, - 'message' => 'client_id and emp_code are required' - ])->setStatusCode(400); + // return $this->response->setJSON([ + // 'status' => false, + // 'code' => 400, + // 'message' => 'client_id and emp_code are required' + // ])->setStatusCode(400); + + $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)); + return $this->response->setJSON(['ticket_type' => $ticket_type])->setStatusCode(200); } // Get policy type ids diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 9838492c..60d3b955 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1894,6 +1894,8 @@ class MasterController extends AdminController 'cache' => WRITEPATH . 'cache', 'sample_import_excel' => ROOTPATH . 'public/sample_import_excel', 'lead_files' => WRITEPATH . 'uploads/lead_files/', + 'claim_files' => WRITEPATH . 'uploads/claim_files/', + 'claim_dump_excel' => WRITEPATH . 'uploads/claim_dump_excel/', 'claim_sample_forms' => ROOTPATH . 'public/claim_sample_forms/', ]; diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index baece64e..828fc262 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -2287,7 +2287,8 @@ class TicketController extends BaseController 'url' => $data['url'][$key]??'', 'ticket_id'=> $data['ticket_id_url']??'', 'created_by' => get_session_userid(), - 'is_active' => 1 + 'is_active' => 1, + 'file_type' => 1 ]; $insertArr[] = $insertData; @@ -2324,6 +2325,7 @@ class TicketController extends BaseController $urlData = $this->claimFilesModel ->where('ticket_id', $ticket_id) ->where('is_active',1) + ->where('file_type',1) ->findAll(); return $this->response->setJSON([ diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index eae819ea..d65d7e6b 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -64,6 +64,42 @@ if (!function_exists('file_Upload')) { } } +if (!function_exists('multi_file_Upload')) { + function multi_file_Upload($fileToUpload, $filepath) + { + $uploadedFiles = []; + + // Handle multiple files + if (is_array($fileToUpload)) { + foreach ($fileToUpload as $file) { + if ($file !== null && $file->isValid() && !$file->hasMoved()) { + $file->move($filepath); + $fileName = $file->getName(); // safer unique name + $uploadedFiles[] = [ + 'file_name' => $fileName, + 'file_path' => $filepath . $fileName + ]; + } + } + } + // Handle single file + else { + if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) { + $fileToUpload->move($filepath); + $fileName = $fileToUpload->getName(); + $uploadedFiles[] = [ + 'file_name' => $fileName, + 'file_path' => $filepath . $fileName + ]; + } + } + + return $uploadedFiles; // always return array of files + } +} + + + if (!function_exists('file_unlink')) { function file_unlink($filepath) { diff --git a/app/Models/ClaimFilesModel.php b/app/Models/ClaimFilesModel.php index 2a5ec138..31c950a5 100644 --- a/app/Models/ClaimFilesModel.php +++ b/app/Models/ClaimFilesModel.php @@ -11,6 +11,7 @@ class ClaimFilesModel extends Model protected $allowedFields = [ 'id', 'ticket_id', + 'file_type', 'doc_name', 'url', 'created_by', diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index fa46e077..285cb00b 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -1253,11 +1253,16 @@ $(document).ready(function(){ e.preventDefault(); } + if(shouldClose){ + console.log("alert closed") + localStorage.removeItem('vehicleFormData'); + $("#vehicle_form").find("input, select, textarea").val(""); + } + } }); - - + $('#aadhar').attr('data-parsley-required', 'false'); $('#aadhar').removeAttr('required');