From 085d4576f583a3a015687b7dfe50965d13193ed9 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 19 Dec 2024 14:31:31 +0530 Subject: [PATCH] CHANGE_MEMBERS_DEMOGRAPHY_STARTED --- app/Controllers/LeadsController.php | 86 +++++++++++++++++++++++++++- app/Helpers/sendMailNotification.php | 2 +- app/Models/RFQModel.php | 3 +- 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 7c5eef43..856fb649 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -90,6 +90,11 @@ class LeadsController extends BaseController public function viewLeadsList() { + + // $d = $this->constructExcelToSaveTemp(24, 1, $propsal_and_insurer = null); + // $d = $this->calculateMembersDemography(['lead_id' => 34]); + //$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null); + // dd($d); $data['page_name'] = 'Leads'; // Set basic data @@ -431,7 +436,7 @@ class LeadsController extends BaseController //FOR EXCEL public function exportExcelForQCRandRFQ($lead_id, $type) { - $filepath = $this->constructExcelToSaveTemp($lead_id, $type); + //$filepath = $this->constructExcelToSaveTemp($lead_id, $type); $filepath = $filepath['filePath']; if (file_exists($filepath)) { @@ -662,6 +667,85 @@ class LeadsController extends BaseController 'fileName' => $filename, ]; } + + //Merge RFQ/QCR file with lead members file + public function mergeQuoteExcelFileWithMembersListExcelFile($lead_id, $type, $source_file_path) + { + $rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); + + if($source_file_path && $rfq_data['file_name']) + { + + } + + return true; + } + + public function calculateMembersDemography($params) + { + $lead_id = $params['lead_id']; + $lead_data = $this->leadsModel->find($lead_id); + // print_rr($lead_data); + if($lead_data['file_name']) + { + $file_name_with_path = WRITEPATH."/uploads/lead_files/".$lead_data['file_name']; + + //check physical file + if(!file_exists($file_name_with_path)) + { + //file not found update status and reason + $message = "Lead Physcial file not found"; + // echo $message; + $this->myLogger->logme('error',($message . ' for file ' . $file_name_with_path)); + return ['status' => 'failed','message' => 'no physcial file']; + } + + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + + //get members data + $members_sheet = $spreadsheet->getSheet(0); + $highestRowAndColumn = $members_sheet->getHighestRowAndColumn(); + // dd($highestRowAndColumn); + $members = $members_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + // dd($members); + + //get age band data + $age_band_sheet = $spreadsheet->getSheet(1); + $highestRowAndColumn = $age_band_sheet->getHighestRowAndColumn(); + $age_band_data = $age_band_sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']); + print_r($age_band_data); + + //check age or dob column + $members_heading = $members[0]; + Kint::dump($members_heading); + $available_col = null; + $col_index = null; + + if (in_array('age', array_map('strtolower',$members_heading))) { + $available_col = 'age'; + $col_index = array_search('age',array_map('strtolower',$members_heading)); + } elseif (in_array('dob', array_map('strtolower', $members_heading))) { + $available_col = 'dob'; + $col_index = array_search('dob', array_map('strtolower', $members_heading)); + } + + if ($available_col == null) { + $message = 'No DOB or Age column '; + $this->myLogger->logme('error',($message . $file_name_with_path)); + return ['status' => 'failed','message' => $message]; + } + + //convert age slab data into array + + } + else + { + $this->myLogger->logme('error',(' no file found ' . $file_name_with_path)); + return ['status' => 'failed','message' => 'no file found']; + } + + } + //this funciton for send mail to insurer and client with either RFQ/QCR public function sendMailWithAttachement() diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 3ac48a4d..2615b1fc 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -327,7 +327,7 @@ class sendMailNotification // dd($payable_employee_array); // dd(count($payable_employee_array['emp_data'])); - if(count($payable_employee_array['emp_data']) > 0){ + if(isset($payable_employee_array['emp_data']) && count($payable_employee_array['emp_data']) > 0){ $table_content .= '

Policy Type :'; $temp_data = ''; diff --git a/app/Models/RFQModel.php b/app/Models/RFQModel.php index d616e517..006ac637 100644 --- a/app/Models/RFQModel.php +++ b/app/Models/RFQModel.php @@ -67,7 +67,8 @@ class RFQModel extends Model tpa.name as tpa_name, tpa_branch.branch_name as tpa_branch_name, policy_type.policy_type, - rfq.json + rfq.json, + file_name ') ->join('leads', 'rfq.lead_id = leads.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id')