diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ee9ad2c0..37966b25 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -22,7 +22,7 @@ $routes->get("update-policy-terms-for-corrections", "ClientController::updatePol $routes->get("update_rack_rate_json", "ClientController::updateRackRateJson"); $routes->get("updatajson", "EmpDataServiceController::updatajson"); $routes->get("view", "EmployeeController::viewECard/$1"); -// $routes->get("exportQCRandRFQ", "LeadsController::exportQCRandRFQ"); +$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); $routes->get("smapletest", "ClientController::smapletest"); $routes->get("testMailAttachments", "ClientController::testMailAttachments"); $routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey"); @@ -346,6 +346,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('getCDAmount', 'ClientController::getCDAmount'); $routes->get('getTheEmpDataForClaim/(:any)', 'ClientController::getTheEmpDataForClaim/$1'); $routes->get('getTheEmpDataForClaimSearchByMobile/(:any)', 'ClientController::getTheEmpDataForClaimSearchByMobile/$1'); + $routes->get('getLeadNonEB/(:any)', 'LeadsController::getLeadNonEB/$1'); + $routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields'); }); $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 94a28fb6..f46fc522 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2586,7 +2586,8 @@ class EmployeeRestController extends AdminController { $data['floter_text_heading'] = 'Sum Insured'; }else{ - if($terms->family_floater == 1){ $data['floter_text_heading'] = 'Floter Sum Insured'; }else{ $data['floter_text_heading'] = 'Sum Insured'; } + + if(isset($terms['family_floater']) && strpos(strtolower($terms['family_floater']), "no") !== false ){ $data['floter_text_heading'] = 'Sum Insured'; }else{ $data['floter_text_heading'] = 'Floter Sum Insured'; } } $employee_policy = $this->employeePolicyModel->select('employees.*,employee_polices.employee_id , employee_polices.basic_cover_si , employee_polices.premium , employee_polices.gst , employee_polices.tpa_id , employee_polices.rand_string , employee_polices.uhid as uhid') diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index ed6c0743..6a958c71 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -118,14 +118,6 @@ class LeadsController extends BaseController public function viewLeadsList() { - - // $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null); - // $job_details = new Jobs(); - // $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => ['lead_id' => 24]]); - // $d = $this->calculateMembersDemography(['lead_id' => 24]); - //$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null); - // dd($d); - $data['page_name'] = 'Leads'; // Set basic data @@ -138,23 +130,6 @@ class LeadsController extends BaseController $data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll(); $data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll(); - // Fetch insurer and TPA branch data - $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); - $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); - // print_r($data['tpa']);die(); - // Fetch sales team members who are active in team 5 - $data['salse_team'] = $this->userModel - ->select('user_profiles.*') - ->join('user_teams', 'user_profiles.id = user_teams.user_id') - ->where('user_teams.team_id', 5) - ->where('user_teams.is_active', 1) - ->where('user_profiles.is_active', 1) - ->findAll(); - - // dd($data); - $data['lastFiveYears'] = $this->getLastFiveFinancialYears(); - $data['gpaClaimType'] = $this->claim_type_for_gpa; - $data['causeOfDeath'] = $this->cause_of_death; // dd($lastFiveYears); if ($this->request->is('get')) { // Fetch leads data @@ -184,7 +159,7 @@ class LeadsController extends BaseController // print_r($this->request->getPost()); die; $id = $this->request->getPost('id'); $data = $this->prepareLeadData(); - // print_r($this->request->getPost()); die; + // print_r($data); die; if (!$id) { @@ -215,11 +190,69 @@ class LeadsController extends BaseController $data['client_code'] = generate_client_code('IC'); } - $data = $this->prepareMultipleLeadData($data); + if(isset($data['lead_form_type'])){ + $data = $this->prepareSingleLeadData($data); + }else{ + $data = $this->prepareMultipleLeadData($data); + } // print_r($data); die; return $data; } + private function prepareSingleLeadData($data) + { + // print_r($data); die; + $uploadFilePath = WRITEPATH . 'uploads/lead_files/'; + + // Get all uploaded files for 'file_name[]' + $files = $this->request->getFileMultiple('file_name'); + + // print_r($files); die; + + + // Separate the insurer and insurer branch, handle missing or invalid data + if (isset($data['insurer']) && strpos($data['insurer'], '-') !== false) { + list($insurer_branch_id, $insurer_id) = explode('-', $data['insurer']); + + }else{ + $insurer_branch_id = 0; + $insurer_id = 0; + } + + $data['insurer_id'] = $insurer_id; + $data['insurer_branch_id'] = $insurer_branch_id; + + // Separate the insurer and insurer branch, handle missing or invalid data + if (isset($data['tpa']) && strpos($data['tpa'], '-') !== false) { + list($tpa_branch_id, $tpa_id) = explode('-', $data['tpa']); + } else { + $tpa_branch_id = 0; + $tpa_id = 0; + } + + $data['tpa_id'] = $tpa_id; + $data['tpa_branch_id'] = $tpa_branch_id; + + + if (!empty($data['policy_start_date'])) { + $data['policy_start_date'] = change_date_format($data['policy_start_date']); + } else { + $data['policy_start_date'] = null; + } + + if (!empty($data['policy_end_date'])) { + $data['policy_end_date'] = change_date_format($data['policy_end_date']); + } else { + $data['policy_end_date'] = null; + } + + $data['file_name'] = file_Upload($files, $uploadFilePath); + $processcedData[] = $data; + + // print_r($data);die(); + return $processcedData; + } + private function prepareMultipleLeadData($data) { // print_r($data); die; @@ -291,22 +324,8 @@ class LeadsController extends BaseController $file_name = file_Upload($files[$index], $uploadFilePath); - $last_3_years_claims = null; - if($value != 2){ - $last_3_years_claims = []; - $finyear = json_decode($data['finyear']); + $last_3_years_claims = $data['finyear']; - foreach ($finyear as $year){ - $received_policy_type = ($year->finyear[0]->policy_type); - if ($value == $received_policy_type){ - array_push($last_3_years_claims,$year); - }else{ - continue; - } - } - $last_3_years_claims = json_encode($last_3_years_claims); - } - $processedData[] = [ 'lead_type' => $data['lead_type'], 'issuer' => $data['issuer'], @@ -328,18 +347,18 @@ class LeadsController extends BaseController 'policy_type_id' => $value, 'salse_person_id' => $data['salse_person_id'] ?? 0, - 'insurer_id' => $insurer_id ?? 0, - 'insurer_branch_id' => $insurer_branch_id ?? 0, - 'tpa_id' => $tpa_id ?? 0, - 'tpa_branch_id' => $tpa_branch_id ?? 0, - 'policy_start_date' => $policy_start_date, - 'policy_end_date' => $policy_end_date, - 'no_of_lives' => $data['no_of_lives'][$index] ?? null, - 'incurred_claims' => $data['incurred_claims'][$index] ?? 0, - 'location' => $data['location'][$index] ?? null, - 'proposed_insurer_id' => $proposed_insurer_id ?? 0, - 'proposed_insurer_branch_id' => $proposed_insurer_branch_id ?? 0, - 'proposed_tpa_id' => $proposed_tpa_id ?? 0, + 'insurer_id' => $insurer_id ?? 0, + 'insurer_branch_id' => $insurer_branch_id ?? 0, + 'tpa_id' => $tpa_id ?? 0, + 'tpa_branch_id' => $tpa_branch_id ?? 0, + 'policy_start_date' => $policy_start_date, + 'policy_end_date' => $policy_end_date, + 'no_of_lives' => $data['no_of_lives'][$index] ?? null, + 'incurred_claims' => $data['incurred_claims'][$index] ?? 0, + 'location' => $data['location'][$index] ?? null, + 'proposed_insurer_id' => $proposed_insurer_id ?? 0, + 'proposed_insurer_branch_id' => $proposed_insurer_branch_id ?? 0, + 'proposed_tpa_id' => $proposed_tpa_id ?? 0, 'proposed_tpa_branch_id' => $proposed_tpa_branch_id ?? 0, 'renewal_emp_count' => $data['renewal_emp_count'][$index] ?? 0, @@ -370,6 +389,9 @@ class LeadsController extends BaseController 'status' => $data['status'] ?? null, 'notes' => $data['notes'] ?? null, + + 'lead_form_type' => $data['lead_form_type'] ?? 1, + 'custom_fields' => $data['custom_fields'] ?? null, ]; } // print_r($processedData);die(); @@ -384,11 +406,13 @@ class LeadsController extends BaseController $insertCount[] = $insert; $this->insertLeadStatus($insert, $value['status'], 3); - //for this push the job to the calculateMembersDemography() function - $job_details = new Jobs(); - $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [ - 'lead_id' => $insert, - ]]); + if($value['lead_form_type'] == 1){ + //for this push the job to the calculateMembersDemography() function + $job_details = new Jobs(); + $r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [ + 'lead_id' => $insert, + ]]); + } } if (count($insertCount) > 0) { @@ -416,6 +440,12 @@ class LeadsController extends BaseController ->where('leads.is_active', 1) ->first(); + $data['lead_edit_data'] = $this->leadsModel + ->where('leads.id', $id) + ->where('leads.is_active', 1) + ->first(); + + if (!empty($data['policy_start_date'])) { $data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y'); } else { @@ -440,6 +470,19 @@ class LeadsController extends BaseController $data['premium_date'] = null; } + $data['lastFiveYears'] = $this->getLastFiveFinancialYears(); + $data['gpaClaimType'] = $this->claim_type_for_gpa; + $data['causeOfDeath'] = $this->cause_of_death; + + if (!empty($data['fin_years_claims'])) { + $decoded = json_decode($data['fin_years_claims'], true); + $data['lead_edit_data']['fin_years_claims_array'] = isset($decoded['finyear']) ? $decoded['finyear'] : []; + } else { + $data['lead_edit_data']['fin_years_claims_array'] = []; + } + + $data['html'] = $this->generateViewPageHtml($data['policy_type_id'], $data) ?? ""; + if ($data) { return $this->respond(['status' => true, 'data' => $data], 200); } else { @@ -628,15 +671,20 @@ class LeadsController extends BaseController //export main route function - public function exportQCRandRFQ($lead_id, $type, $export_type) + public function exportQCRandRFQ($lead_id, $type, $lead_form_type) { - $this->exportExcelForQCRandRFQ($lead_id, $type); + $this->exportExcelForQCRandRFQ($lead_id, $type, $lead_form_type); } //FOR EXCEL - public function exportExcelForQCRandRFQ($lead_id, $type) - { - $filepath = $this->constructExcelToSaveTemp($lead_id, $type); + public function exportExcelForQCRandRFQ($lead_id, $type, $lead_form_type = 1) + { + if($lead_form_type == 2){ + $filepath = $this->constructNonEbExcelToSaveTemp($lead_id, $type); + }else{ + $filepath = $this->constructExcelToSaveTemp($lead_id, $type); + } + $lead_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); // dd($filepath); @@ -2317,69 +2365,6 @@ class LeadsController extends BaseController //------------------------------------------------------------------------------------------------ - // public function transformMailContent($lead_id, $page_name) - // { - // helper('excel_util_helper'); - // // $params = $this->request->getGet(); - - // // print_r($params); die; - // // $lead_id = $params['lead_id']; - // // $file_type = $params['file_type']; //rfq or qcr - // // $recipient_type = $params['recipient_type']; //insurer or client or internal or placement - // // $recipient_mail = $params['recipient_mail']; // - only primary key of contacts - // // $propsal_and_insurer = isset($params['proposal_insurer']) ? $params['proposal_insurer'] : null; - - // // if ($recipient_type == 'insurer' && empty($recipient_mail)) { - // // return $this->respond(['status' => 'failed', 'code' => 400, 'data' => '', 'messgae' => 'Recipient mail not found ! '], 200); - // // } - - // //gather lead info - // $lead_data = $this->leadsModel - // ->select('leads.*,policy_type.long_name,policy_type.policy_type,user_profiles.email as created_person_email') - // ->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left') - // ->join('user_profiles', 'leads.created_by = user_profiles.id', 'left') - // ->where('leads.id', $lead_id) - // ->first(); - - // // dd($lead_data); - - // if($lead_data){ - - // $recipient_data = ['name' => "Team"]; - // // $original_message = '
We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.
| Client name | {{CLIENT_NAME}} |
|---|---|
| Coverage Type | {{POLICY_LONG_NAME}} |
| Policy Start Date | {{POLICY_START_DATE}} |
| Policy Duration | {{DURATION}} |
Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.
Best regards,
Nhance India Pvt Ltd
© Nhance India Pvt Ltd. All rights reserved.