From b726b9530dcce44b46f1ea0e324c09a1ad3b23e8 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Mon, 21 Oct 2024 09:08:10 +0530 Subject: [PATCH 01/17] CHANGE_VIEW_MEMBERS_LIST_PAGE : RV --- app/Views/employee_data_list.php | 68 ++++++++++++++++---------------- app/Views/employee_list.php | 7 ---- app/Views/leads_form.php | 25 ++++++++++-- 3 files changed, 55 insertions(+), 45 deletions(-) diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index e3791918..7a6ae90e 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -34,6 +34,10 @@ position: absolute; } +.right-align-input { + text-align: right; +} + @@ -47,24 +51,23 @@

Employees

- +
- - + - - - - - + - - + - + + + + @@ -86,19 +89,18 @@ - - + - - - - - + - - + - + + + + @@ -132,24 +134,22 @@ - + - - + - - - - - + - - + + + + @@ -174,6 +174,7 @@ if (ticketsTable.length) { ticketsTable.DataTable({ + scrollX: true, dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector @@ -181,9 +182,6 @@ extend: 'csv', text: 'CSV', title: 'Member-List', - exportOptions: { - columns: ':not(:last-child)' - }, }], language: { search: "_INPUT_", diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 0d1b3dca..d615e7db 100755 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -115,7 +115,6 @@ var client_id = ''; var client_branch_id = ''; - $(document).ready(function() { console.log("document loaded"); //fetchClientPolicies(); @@ -127,7 +126,6 @@ $(window).on("load", function() { fetchClientPolicies(); }); - function fetchClientPolicies() { $('#loader').show(); var apiURL = '' + 'util/clients-with-policies'; @@ -204,7 +202,6 @@ function fetchClientPolicies() { $('#loader').hide(); } - function appendClients(data) { var clientID = ; $.each(data, function(index, item) { @@ -219,7 +216,6 @@ function appendClients(data) { }); } - function appendBranch(data) { $('#branch_id').empty(); @@ -239,7 +235,6 @@ function appendBranch(data) { }); } - function appendPolicies(data) { $('#policies').empty(); @@ -286,7 +281,6 @@ $(document).ready(function() { }); }); - $(document).ready(function() { $('#branch_id').on('change', function() { @@ -321,7 +315,6 @@ function objectToQueryString(obj) { return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&'); } - function fetchEmpolyeeList(event) { event.preventDefault(); // Prevent default action diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 15c97dbe..f00ea8b6 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -537,6 +537,7 @@ function getPolicyData(input) { } } +// Salse team user list data function selecSalsePerson(salse_person_ids) { salse_person_ids = JSON.parse(salse_person_ids); @@ -588,7 +589,7 @@ function addHTMLInput() {
- @@ -602,7 +603,7 @@ function addHTMLInput() {
- @@ -715,7 +716,6 @@ function addHTMLInput() { increment++; // Increment after adding the input } - function removeHTMLInput(element) { const container = document.getElementById('dynamic-form-container'); @@ -849,6 +849,24 @@ $('#lead_type').change(function() { }) +function insurerChange(input, unique_id) { + var lead_type = $('#lead_type').val() + + if(lead_type == 2){ + var val = $(input).val(); + $('#proposed_insurer_'+unique_id).val(val).select2(); + } +} + +function tpaChange(input, unique_id) { + var lead_type = $('#lead_type').val() + + if(lead_type == 2){ + var val = $(input).val(); + $('#proposed_tpa_'+unique_id).val(val).select2(); + } +} + //----------------------------------------------------------------------------------------------------------- function getURLParamsForReport() { @@ -866,4 +884,5 @@ function getURLParamsForReport() { console.log('pt_id', pt_id); // Retain the log if necessary } + \ No newline at end of file From 3ebc9d171a975bb0a102cc9507a57bd5070914b4 Mon Sep 17 00:00:00 2001 From: Smart Date: Wed, 23 Oct 2024 10:29:21 +0530 Subject: [PATCH 02/17] CHANGE_in routes : GWM --- app/Config/Routes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f8d085da..ccfd0a66 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -390,6 +390,8 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { + $routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData"); + $routes->post("storeFireBase", "EmployeeRestController::storeFireBase"); $routes->post("saveMpin", "RestAuthenticationController::saveMpin"); $routes->post("updateMpin", "RestAuthenticationController::updateMpin"); From 5637583448623127388d0e3efe8aa4baba25b0e4 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 23 Oct 2024 12:06:22 +0530 Subject: [PATCH 03/17] FIX_LIVE_ISSUES --- app/Controllers/ClientController.php | 1 + app/Controllers/EmpDataServiceController.php | 134 ++++++++++--------- app/Controllers/EmployeeController.php | 2 + app/Controllers/MasterController.php | 1 + app/Models/EmployeePolicyModel.php | 10 +- app/Views/DashBoard.php | 2 +- app/Views/employee_data_list.php | 4 + app/Views/leads_list.php | 3 + 8 files changed, 90 insertions(+), 67 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 020ff116..c6b3f152 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2105,6 +2105,7 @@ class ClientController extends AdminController $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")); diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 20353e2f..5cefd249 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -312,22 +312,6 @@ class EmpDataServiceController extends BaseController 'db_column_name' => 'total' ] ]; - - // get excel export format structure array - $template_json = $this->clientPolicyModel - ->select('insurer_excel_export_template.jsoncolumns') - ->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id') - ->where('client_policy.id', $export_data['client_policy_id']) - ->where('insurer_excel_export_template.event_name', $export_data['event_type']) - ->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024 - ->where('insurer_excel_export_template.type_name', $export_data['actions']) - ->first(); - - if(!empty($template_json) && $template_json != null){ - $excel_header_columns = json_decode($template_json['jsoncolumns'], true); - }else{ - return 6; - } if( $export_data['insurer_or_tpa'] == 'tpa'){ @@ -380,7 +364,7 @@ class EmpDataServiceController extends BaseController [ 'column_index' => 9, 'column_name' => 'DATE OF COVERAGE', - 'db_column_name' => 'date_of_coverage' + 'db_column_name' => 'date_coverage' ], [ 'column_index' => 10, @@ -438,6 +422,22 @@ class EmpDataServiceController extends BaseController 'db_column_name' => 'total' ] ]; + }else{ + // get excel export format structure array + $template_json = $this->clientPolicyModel + ->select('insurer_excel_export_template.jsoncolumns') + ->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id') + ->where('client_policy.id', $export_data['client_policy_id']) + ->where('insurer_excel_export_template.event_name', $export_data['event_type']) + ->where('insurer_excel_export_template.is_active', 1) //Live issue changes 17-10-2024 + ->where('insurer_excel_export_template.type_name', $export_data['actions']) + ->first(); + + if(!empty($template_json) && $template_json != null){ + $excel_header_columns = json_decode($template_json['jsoncolumns'], true); + }else{ + return 6; + } } $excel_data_info = generate_insurer_based_excel($excel_header_columns, $objects); @@ -1253,20 +1253,26 @@ class EmpDataServiceController extends BaseController $insurer_or_tpa = $file['insurer_or_tpa']; if ($insurer_or_tpa == 'tpa') { - $id = 'tpa_id'; } else if ($insurer_or_tpa == 'insurer') { - $id = 'uhid'; } + $ref_data = [ + 'client_id' => $client_id, + 'client_policy_id' => $client_policy_id, + 'client_branch_id' => $client_branch_id, + 'insurer_or_tpa' => $insurer_or_tpa, + 'event_type' => $file['event_type'], + ]; + $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name']; $excel_data = $this->readExcelFileToArray($file_name_with_path); $excel_header = $excel_data[0]; unset($excel_data[0]); - array_pop($excel_data); + // array_pop($excel_data); - $inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATIONSHIP CODE','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PR0 RATA PREMIUM','GST','TOTAL']; + $inceptionHeader = ['S.No', 'NAME OF EMP/DEP','EMP ID','EMP/DEP TYPE','RELATIONSHIP CODE','DOB','GENDER','PRE EXISTING AILMENTS','BASIC COVER SI','DATE OF COVERAGE','AGE','RELATIONSHIP','REMARKS','POLICY END DATE','NO OF DAYS','TPA ID','UHID','PREMIUM','PR0 RATA PREMIUM','GST','TOTAL AMOUNT']; foreach ($inceptionHeader as $key => $value) { if($excel_header[$key] != $value){ @@ -1280,49 +1286,50 @@ class EmpDataServiceController extends BaseController $this->setPullNotification($file_data); $this->myLogger->logme('error', 'Inception File Validation -- Upload the worng excel file'); - return ['status' => 'error', 'message' => 'Upload the worng excel file']; + return ['status' => 'error', 'message' => 'Upload the worng excel file', 'excel_header' => $excel_header, 'inception_header' => $inceptionHeader]; } } $emp_count = count($excel_data); - $employee_data = $this->employeePolicyModel - ->select(' - - employee_polices.id as emp_policy_id, - employees.name AS emp_name, - employees.emp_code AS emp_code, - "Has Define" as emp_type, - employees.relationship_code AS emp_relationship_code, - employees.dob AS emp_dob, - employees.gender AS emp_gender, - employee_polices.pre_existing_alignments, - employee_polices.basic_cover_si, - employee_polices.date_coverage, - TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age, - employees.relationship AS emp_relationship, - employees.change_event AS change_event, - employee_polices.policy_end_date, - employee_polices.days, - employee_polices.tpa_id, - employee_polices.uhid, - employee_polices.premium, - employee_polices.rata_premimum, - employee_polices.gst, - (employee_polices.rata_premimum + employee_polices.gst) AS total - ') + $employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1); - ->join('employees', 'employees.id = employee_polices.employee_id') - ->where('employee_polices.client_policy_id', $client_policy_id) - ->where('employees.client_id', $client_id) - ->where('employees.client_branch_id', $client_branch_id) - ->where("employee_polices.{$id} IS NULL OR employee_polices.{$id} = ''") - ->where('employee_polices.is_active', 1) - ->where('employee_polices.status', 'active') - ->where('employees.is_active', 1) - ->where('employees.emp_status', 'active') - ->findAll(); + // ->select(' + + // employee_polices.id as emp_policy_id, + // employees.name AS emp_name, + // employees.emp_code AS emp_code, + // "Has Define" as emp_type, + // employees.relationship_code AS emp_relationship_code, + // employees.dob AS emp_dob, + // employees.gender AS emp_gender, + // employee_polices.pre_existing_alignments, + // employee_polices.basic_cover_si, + // employee_polices.date_coverage, + // TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age, + // employees.relationship AS emp_relationship, + // employees.change_event AS change_event, + // employee_polices.policy_end_date, + // employee_polices.days, + // employee_polices.tpa_id, + // employee_polices.uhid, + // employee_polices.premium, + // employee_polices.rata_premimum, + // employee_polices.gst, + // (employee_polices.rata_premimum + employee_polices.gst) AS total + // ') + + // ->join('employees', 'employees.id = employee_polices.employee_id') + // ->where('employee_polices.client_policy_id', $client_policy_id) + // ->where('employees.client_id', $client_id) + // ->where('employees.client_branch_id', $client_branch_id) + // ->where("employee_polices.{$id} IS NULL OR employee_polices.{$id} = ''") + // ->where('employee_polices.is_active', 1) + // ->where('employee_polices.status', 'active') + // ->where('employees.is_active', 1) + // ->where('employees.emp_status', 'active') + // ->findAll(); @@ -1372,15 +1379,14 @@ class EmpDataServiceController extends BaseController $difference = $emp_data_count - $excel_data_count; $status = 'in-progress'; - if ($excel_data_count < $emp_data_count) { + if ($excel_data_count < $emp_data_count) { $status = 'in-progress-partially'; $partially_updated_data = 'Expected : ' . $emp_data_count . ', ' . 'Updated : ' . $excel_data_count . ', ' . 'difference : ' . $difference; $this->myLogger->logme('error', 'Inception File Validation -- excel file count partially : {data}', ['data' => $partially_updated_data]); } - if ($emp_data_count < $excel_data_count) { $data = [ @@ -1498,11 +1504,11 @@ class EmpDataServiceController extends BaseController ]; } - if ($emp_value['days'] != $excel_data[$key][14]) { + if ($emp_value['no_of_days'] != $excel_data[$key][14]) { $errors[$key][] = [ 'row' => $key, 'column' => 14, - 'db_data' => $emp_value['days'], + 'db_data' => $emp_value['no_of_days'], 'excel_data' => $excel_data[$key][14] ]; } @@ -1516,11 +1522,11 @@ class EmpDataServiceController extends BaseController ]; } - if ($emp_value['rata_premimum'] != $excel_data[$key][18]) { + if ($emp_value['pro_rata_premium'] != $excel_data[$key][18]) { $errors[$key][] = [ 'row' => $key, 'column' => 18, - 'db_data' => $emp_value['rata_premimum'], + 'db_data' => $emp_value['pro_rata_premium'], 'excel_data' => $excel_data[$key][18] ]; } @@ -1557,7 +1563,7 @@ class EmpDataServiceController extends BaseController } } - $batch_list_id[] = $emp_value['emp_policy_id']; + $batch_list_id[] = $emp_value['primaryKey']; } diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 1df4dc16..6ddc5808 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1399,6 +1399,8 @@ class EmployeeController extends AdminController $error_data = json_decode($file['error_data']); + // dd($error_data); + $file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name']; if (!file_exists($file_name_with_path)) { diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index a37da6bd..691234eb 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -175,6 +175,7 @@ class MasterController extends AdminController $editData['action'] = ['import' => 'Import', 'export' => 'Export']; $editData['db_column_name'] = [ + 'S.No.' => 'index', 'Employee Name' => 'emp_name', 'Employee ID' => 'emp_code', 'Date of Birth' => 'emp_dob', diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index f9e11a2b..a0172b1d 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -168,7 +168,7 @@ class EmployeePolicyModel extends Model //------------------------------------------------------------------------------------------------------- - public function getInceptionEmployeeDataForExportExcel($ref_data) + public function getInceptionEmployeeDataForExportExcel($ref_data, $return_type = 0) { $client_policy_id = $ref_data['client_policy_id']; $client_branch_id = $ref_data['client_branch_id']; @@ -269,7 +269,12 @@ class EmployeePolicyModel extends Model // Get the result set $query = $this->db->query($sql); - $results = $query->getResult(); + + if($return_type == 1){ + $results = $query->getResultArray(); + }else{ + $results = $query->getResult(); + } return $results; } @@ -1019,6 +1024,7 @@ class EmployeePolicyModel extends Model try { // Execute the query $this->db->query($sql); + // Commit the transaction if ($this->db->transStatus() === FALSE) { diff --git a/app/Views/DashBoard.php b/app/Views/DashBoard.php index 16f0ec66..4da6b9c0 100755 --- a/app/Views/DashBoard.php +++ b/app/Views/DashBoard.php @@ -202,7 +202,7 @@ body { - +
From ca0abe663fbee9ffa13dde526c75c874ed1b61ec Mon Sep 17 00:00:00 2001 From: Smart Date: Wed, 23 Oct 2024 14:06:24 +0530 Subject: [PATCH 04/17] CHANGE_ in iAgreeForAddOn : GWM --- app/Controllers/EmployeeRestController.php | 30 ++++++++++++------- .../RestAuthenticationController.php | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index c13eb6ba..0ac4e935 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1856,6 +1856,7 @@ class EmployeeRestController extends AdminController public function iAgreeForAddOn() { + $postData = json_decode($this->request->getBody(), true); $client_policy_id = $postData['client_policy_id']; sort($client_policy_id); @@ -1876,21 +1877,30 @@ class EmployeeRestController extends AdminController $array_list = []; foreach ($client_policy_id as $key => $value) { - foreach ($empData as $empDataKey => $empDataValue) + $policy = $this->clientPolicyModel->where('id',$value)->where('open_for_enrollment',1)->find(); + if($policy) { - $this->employeePolicyModel->where('client_policy_id', $value ) - ->where('is_active', 1 ) - ->where('employee_id', $empDataValue['id'] ) - ->set(array('status'=>'enrolled')) - ->update(); + foreach ($empData as $empDataKey => $empDataValue) + { + $this->employeePolicyModel->where('client_policy_id', $value ) + ->where('is_active', 1 ) + ->where('employee_id', $empDataValue['id'] ) + ->set(array('status'=>'enrolled')) + ->update(); + } + + $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']); + if(count($find) > 0){ + $array_list[] = $find; + } + } - $find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']); - if(count($find) > 0){ - $array_list[] = $find; - } } + print_r($array_list); + die; + $notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first(); diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index d4256270..a33cff95 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -94,7 +94,7 @@ class RestAuthenticationController extends AdminController { try { $mobile_number = $this->request->getJSON()->mobile_number; - $otp_verification = $this->request->getJSON()->otp_verification; + $otp_verification = $this->request->getJSON()->otp; $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); From f68612d90ceaf065d95ba0356c34fdb1d9ada043 Mon Sep 17 00:00:00 2001 From: Smart Date: Wed, 23 Oct 2024 14:10:10 +0530 Subject: [PATCH 05/17] CHANGE_ in iAgreeForAddOn : GWM --- app/Controllers/EmployeeRestController.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0ac4e935..b4359c53 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1898,9 +1898,6 @@ class EmployeeRestController extends AdminController } - print_r($array_list); - die; - $notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first(); From 4392468481de0318f7c961473b36939cdf77b325 Mon Sep 17 00:00:00 2001 From: Smart Date: Fri, 25 Oct 2024 11:54:55 +0530 Subject: [PATCH 06/17] CHANGE_ getVerifiedUserData API : GWM --- app/Controllers/RestAuthenticationController.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index a33cff95..bed2e473 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -94,9 +94,16 @@ class RestAuthenticationController extends AdminController { try { $mobile_number = $this->request->getJSON()->mobile_number; - $otp_verification = $this->request->getJSON()->otp; + $otp_verification = $this->request->getJSON()->otp_verification; - $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + if (isset($this->request->getJSON()->login_by_hr)) + { + $employeeData = $this->employeeModel->where('id', $this->request->getJSON()->employee_id)->where('relationship', 'self')->first(); + }else{ + $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); + } + + if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr)) { $auth = HttpRequestHelper::getRequestInfo(); From 411249fd632432dadc2a7e9ce4bdf4f2f8ab0068 Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 25 Oct 2024 13:50:16 +0530 Subject: [PATCH 07/17] FIX_LIVE_UNHANDLED_ISSUES --- app/Controllers/EmployeeController.php | 10 +++++---- app/Controllers/EmployeeRestController.php | 4 ++++ app/Controllers/EmployeeServiceController.php | 17 +++++++++++--- app/Helpers/excel_util_helper.php | 22 ++++++++++++++++++- app/Views/batch_list.php | 2 +- app/Views/file_list.php | 2 +- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 1df4dc16..673f2933 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -279,7 +279,7 @@ class EmployeeController extends AdminController $data['fileList'] = $this->fileModel ->select([ - 'files.*', + 'files.id','files.file_name','files.created_by','files.created_at','files.is_active','files.status','files.client_id','files.policy_id','files.client_branch_id','files.action','files.uploaded_by', 'up.emp_code', 'up.first_name', 'c.short_name', @@ -301,9 +301,10 @@ class EmployeeController extends AdminController ->join('client_branch cb', 'files.client_branch_id = cb.id', 'left') ->join('policy_type', 'policy_type.id = cp.policy_type_id') ->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left') - ->where('files.created_by', get_session_userid()) + // ->where('files.created_by', get_session_userid()) ->orderBy('files.created_at', 'desc') - ->findAll(); + ->limit(100) + ->find(); // dd($data['fileList']); $data['batch_list'] = $this->batchFileModel->select( @@ -318,7 +319,8 @@ class EmployeeController extends AdminController ->join('policy_type', 'policy_type.id = client_policy.policy_type_id') ->join('clients', 'clients.id = client_policy.client_id') ->orderBy('batch_files.id', 'desc') - ->findAll(); + ->limit(100) + ->find(); // dd($data['fileList']);die(); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index c13eb6ba..b0d07d2e 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -804,6 +804,7 @@ class EmployeeRestController extends AdminController 'basic_pay'=> $extra['11'][$index], 'unit'=> isset($extra['12'][$index]) ? $extra['12'][$index] : null, 'client_branch_id' => $client_branch_id + 'date_coverage' => $extra['13'][$index] ]; $basic_cover_si_value = null; @@ -840,6 +841,8 @@ class EmployeeRestController extends AdminController $count = 0; for ($a=0; $a employeeModel->checkExistingEmployee($dataToInsert[$a],$client_branch_id); $emp_id =0; @@ -891,6 +894,7 @@ class EmployeeRestController extends AdminController 'employee_id'=>$emp_id, 'client_policy_id'=>$policy_id, 'status'=> 'draft', + 'date_coverage' => $date_coverage 'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null ]; diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index ef99ee20..b6236313 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -594,6 +594,15 @@ class EmployeeServiceController extends AdminController 'data_type' => 'str', 'format' => null, 'allowed_values' => null + ], + 'doc' => [ + 'col_idx' => 13, + 'col_cell_name' => 'N', + 'col_name' => 'DOC', + 'is_mandatory' => false, + 'data_type' => 'str', + 'format' => 'd-M-Y', + 'allowed_values' => null ] ]; @@ -605,7 +614,7 @@ class EmployeeServiceController extends AdminController 4 => 4, // inception: gender (Gender) -> enrollment: gender (Gender) 5 => 5, // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation) 6 => 9, // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI) - 7 => null, // inception: doc (Date of Coverage) -> No match in enrollment + 7 => 13, // inception: doc (Date of Coverage) 8 => 3, // inception: doj (DOJ) -> enrollment: doj (DOJ) 9 => 11, // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay) 10 => 10, // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade) @@ -1249,7 +1258,7 @@ class EmployeeServiceController extends AdminController //get policy slab rates $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$client_id); - $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled','draft'],policy_status:['enrolled','draft']); + $existing_famility_details = $this->employeeModel->getEmpFamilybyEmpCode(client_id: $client_id,client_policy_id: $client_policy_id,emp_status: ['enrolled'],policy_status:['enrolled']); // $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception']; $file = ['id' => null,'client_id' => $client_id,'policy_id' => $client_policy_id,'action' => 'inception','created_by' => get_session_userid(),'client_branch_id' => $params['client_branch_id']]; @@ -1613,6 +1622,7 @@ class EmployeeServiceController extends AdminController $value['emp_status'] = 'active'; $value['created_by'] = $file['created_by']; $value['client_branch_id'] = $file['client_branch_id']; + $value['family_floater_key'] = generate_family_floater_key($value['relationship']); $log_message = 'Insert Employee- '.$value['name'] .'('.$value['emp_code'] .') with PK '; // $this->myLogger->logme('error',('Insert - ' . $value['emp_code'] .' - '. $value['name'])); // echo 'update emp'; @@ -1983,7 +1993,7 @@ public function employeesEnrollmentInsert($params) $value['file_id'] = $file_id; $value['temp']['emp_id'] = null; // dummy value for using exisitng funciton in model - if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'Father') { + if (strtolower(trim($value['relationship'])) === 'mother' || strtolower(trim($value['relationship'])) === 'father') { $relation = 'parent'; } else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){ $relation = 'child'; @@ -1997,6 +2007,7 @@ public function employeesEnrollmentInsert($params) $value['family_floater_key'] = $relation; $policy_data['basic_cover_si'] = $row[9]; + $policy_data['date_coverage'] = $row[13]; $policy_data['client_policy_id'] = $file['policy_id']; $employee = $this->employeeModel->checkExistingEmployee($value,$file['client_branch_id']); diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index 6de54c74..bf911f77 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -1800,7 +1800,7 @@ if(!function_exists('transform_enrollment_row_to_inception_row')) $res[4] = $row[4]; // inception: gender (Gender) -> enrollment: gender (Gender) $res[5] = $row[5]; // inception: relationship (RELATIONSHIP) -> enrollment: relationship (Relation) $res[6] = $row[9]; // inception: basic_cover_si (BASIC COVER SI) -> enrollment: basic_cover_si (SI) - $res[7] = null; // inception: doc (Date of Coverage) -> No match in enrollment + $res[7] = $row[13]; // inception: doc (Date of Coverage) -> No match in enrollment $res[8] = $row[3]; // inception: doj (DOJ) -> enrollment: doj (DOJ) $res[9] = $row[11]; // inception: basic_pay (Basic Pay) -> enrollment: basic_pay (Basic Pay) $res[10] = $row[10]; // inception: band_grade (Band/Grade) -> enrollment: band_grade (Grade) @@ -2119,4 +2119,24 @@ if(!function_exists('group_slab_rates_basedon_name')) return $temp_slab_rates; } +} + + +//this key generating mandantory for display employee info in enrolment app w/o error +if(!function_exists('generate_family_floater_key')) +{ + function generate_family_floater_key($relationship) + { + if (strtolower(trim($relationship)) === 'mother' || strtolower(trim($relationship)) === 'father') { + $relation = 'parent'; + } else if(strtolower(trim($relationship)) === 'son' || strtolower(trim($relationship)) === 'daughter'){ + $relation = 'child'; + }else if(strtolower(trim($relationship)) === 'father in Law' || strtolower(trim($relationship)) === 'mother in Law'){ + $relation = 'parent_in_law'; + }else if(strtolower(trim($relationship)) === 'spouse'){ + $relation = 'spouse'; + }else{ + $relation = 'self'; + } + } } \ No newline at end of file diff --git a/app/Views/batch_list.php b/app/Views/batch_list.php index 00e5b465..a2c371b2 100755 --- a/app/Views/batch_list.php +++ b/app/Views/batch_list.php @@ -67,7 +67,7 @@ - + @@ -100,6 +101,7 @@ + diff --git a/public/sample_excel/enrollment.xlsx b/public/sample_excel/enrollment.xlsx index dec7c20ffda4228bd47b41a2be60ea38311f37f9..568e3b5e8e6c534f0f3fbb277383bb8cf3bfb1d6 100755 GIT binary patch delta 4147 zcmZ8k2{aU57awCU*|)J~r;Ig>B_V^c%WhD%zkL{6QcM{862>ydlq?}xMi>#Y?~*05 zCA*S+i6Wo=edm1jy>s3<_uO-T@4dUcyL?n0QK2=~BPC-7P*G6R%7e<8^Us0Mch7BAzFWKANq_eB!{)X6#iGZa#h6zL3Zwh#6b_zO1hsnN zX5Tb3%CJ*aIElD_eR2X6|1oQ)sv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xb$zrkApigZ1P>?pH|B3SY5#)(BV0Lo$bYTp7e$C9PA0-(CPXPG*B=5foNNUAh%cOc Wf4Y=hY=l2q5ZAZ_N$Y<9>;C|`FJAQk From afdc8bde2c2dc7b58c6cc11b3f14db800e261669 Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 26 Oct 2024 18:02:15 +0530 Subject: [PATCH 11/17] CHNAGE_MAIL_PARAMS_CLI --- app/Controllers/MasterController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 0a5bb5d1..42f3d660 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1607,11 +1607,21 @@ class MasterController extends AdminController { // print_r($email_id);die(); // $gmailapi = \Config\Services::gmailapi(); + $email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id; $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']); print_r($res); } - + public function testCheckBounceMails() + { + $gmailapi = \Config\Services::gmailapi(); + $from_date = CLI::getOption('from') ? CLI::getOption('from') : null; + $to_date = CLI::getOption('to') ? CLI::getOption('to') : null; + $count = CLI::getOption('count') ? CLI::getOption('count') : null; + $page = CLI::getOption('page') ? CLI::getOption('page') : null; + $res = $gmailapi->checkBounceStatus(from_date:$from_date,to_date:$to_date,count:$count,page:$page); + print_r($res); + } public function appCheckList() { From 13a8f999e5a325a0fd4eff08e6e71a8209d57937 Mon Sep 17 00:00:00 2001 From: velz Date: Mon, 28 Oct 2024 17:29:40 +0530 Subject: [PATCH 12/17] FIX_RELATED_ENROLMENTFILE_DOC_CAPTURE --- app/Controllers/EmployeeController.php | 2 +- app/Controllers/EmployeeRestController.php | 7 ++++--- app/Controllers/EmployeeServiceController.php | 2 +- app/Helpers/excel_util_helper.php | 2 +- app/Models/EmployeePolicyModel.php | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 4b5f3f64..569f1c65 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -827,7 +827,7 @@ class EmployeeController extends AdminController $res = $empServiceController->employeesOnboardPreprocess(['client_policy_id' => $client_policy_id,'client_branch_id' => $client_data['client_branch_id']]); // dd($res); - $count = count($res); + $count = ($res); $message = $count . ' Employees are Initiate Onboard Process againts Client ' . $client_data['client_name'] . ' and the Policy is ' . $client_data['policy_name']; session()->setFlashdata('success1', $message); return redirect()->to(base_url('/employee/upload')); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index a8a6e3d8..0c43d7cd 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -703,7 +703,7 @@ class EmployeeRestController extends AdminController $file_name_with_path = WRITEPATH."/uploads/excel/".$filename; //make an entry in DB - $file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $employee_id, 'status' => 'draft', 'action' => 'enrollment', 'client_branch_id' => $client_branch_id]); //here field policy_id have client_policy_id and not policy id from policy master + $file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $employee_id, 'status' => 'inprogress', 'action' => 'enrollment', 'client_branch_id' => $client_branch_id]); //here field policy_id have client_policy_id and not policy id from policy master $this->myLogger->logme("error", '{file_id} - client uploaded success', ['file_id' => $file_id]); $empServiceController = new EmployeeServiceController(); @@ -834,7 +834,7 @@ class EmployeeRestController extends AdminController 'band'=> $extra['10'][$index], 'basic_pay'=> $extra['11'][$index], 'unit'=> isset($extra['12'][$index]) ? $extra['12'][$index] : null, - 'client_branch_id' => $client_branch_id + 'client_branch_id' => $client_branch_id, 'date_coverage' => $extra['13'][$index] ]; @@ -925,7 +925,7 @@ class EmployeeRestController extends AdminController 'employee_id'=>$emp_id, 'client_policy_id'=>$policy_id, 'status'=> 'draft', - 'date_coverage' => $date_coverage + 'date_coverage' => $date_coverage, 'basic_cover_si'=>isset($basic_cover_si[$a]) ? $basic_cover_si[$a] : null ]; @@ -967,6 +967,7 @@ class EmployeeRestController extends AdminController } } + $this->fileModel->where('id', $file_id)->set(['status' => 'success','reason' => '','error_data' => ''])->update(); return $this->respond(['status' => 'success', 'code' => 200, 'message' => "Success" ], 200); }else{ return $this->respond(['status' => 'failed', 'code' => 404, 'message' => "Client id and Client Policy id is Not Match!" ], 404); diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index b6236313..f697a04a 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -1097,7 +1097,7 @@ class EmployeeServiceController extends AdminController }// end of foreach }// end of if current action I,DA,A - // s($result); + // return $result; // die(); if(isset($result['error_summary']) && count($result['error_summary'])) { diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php index bf911f77..ab6299ac 100755 --- a/app/Helpers/excel_util_helper.php +++ b/app/Helpers/excel_util_helper.php @@ -1646,7 +1646,7 @@ if(!function_exists('get_premium_for_si')) // dd($slab_details); foreach ($slab_details as $skey => $slab_value) { - if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band && $slab_value['unit'] == $unit && $slab_value['max_si'] == 0) + if($slab_value['si'] == $si_amount && $slab_value['grade'] == $band && $slab_value['unit'] == $unit) { return $slab_value['premium']; } diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 180f810c..18dff3a9 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -806,8 +806,8 @@ class EmployeePolicyModel extends Model ->where('emp.client_id',$client_id) ->where('employee_polices.client_policy_id',$policy_id); - $result->whereIn('employee_polices.status', ['draft', 'enrolled']); - $result->whereIn('emp.emp_status', ['draft', 'enrolled']); + $result->whereIn('employee_polices.status', ['enrolled']); + $result->whereIn('emp.emp_status', ['enrolled']); $result = $result->findAll(); return ($result); } From 9699c6de7286ab409ecd86ee5f3f06b38dbe5378 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 29 Oct 2024 15:16:31 +0530 Subject: [PATCH 13/17] FEAT_RFQ_AND_QCR_MODULE : RV --- app/Config/Routes.php | 8 + app/Controllers/LeadsController.php | 270 ++ app/Models/LeadsModel.php | 19 +- app/Models/PolicyTypeModel.php | 1 + app/Models/RFQModel.php | 60 + app/Views/leads_list.php | 7 +- .../policy_transaction_inception_form.php | 29 +- app/Views/tpa_basic_info.php | 22 +- app/Views/view_rfq.php | 2825 +++++++++++++++++ 9 files changed, 3212 insertions(+), 29 deletions(-) create mode 100644 app/Models/RFQModel.php create mode 100644 app/Views/view_rfq.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ca0cbe4f..3d943692 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -18,6 +18,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"); @@ -343,6 +344,13 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) { $routes->get("list", "LeadsController::viewLeadsList"); $routes->post("create", "LeadsController::createLead"); $routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1"); + $routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); +}); + +$routes->group("rfq", ["filter" => "authMVC"], function ($routes) { + $routes->post("create", "LeadsController::createRFQ"); + $routes->post("createQCR", "LeadsController::createQCR"); + $routes->get("list/(:any)", "LeadsController::viewRFQ/$1"); }); $routes->get("driveListFiles", "GoogleDriveController::listFiles"); diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 9c9d153f..737a686f 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -4,6 +4,9 @@ namespace App\Controllers; use CodeIgniter\API\ResponseTrait; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; + use App\Models\UserModel; use App\Models\ClientModel; use App\Models\ClientBranchModel; @@ -15,6 +18,8 @@ use App\Models\KYCEntityTypeModel; use App\Models\PolicyTransactionStatusModel; use App\Models\InsurerBranchModel; use App\Models\TPABranchModel; +use App\Models\RFQModel; +use App\Models\InsurerModel; class LeadsController extends BaseController { @@ -35,6 +40,8 @@ class LeadsController extends BaseController protected $policyTransactionStatusModel; protected $insurerBranchModel; protected $tpaBranchModel; + protected $RFQModel; + protected $insurerModel; //variables for storing array protected $issuer; @@ -58,6 +65,8 @@ class LeadsController extends BaseController $this->policyTransactionStatusModel = new PolicyTransactionStatusModel(); $this->insurerBranchModel = new InsurerBranchModel(); $this->tpaBranchModel = new TPABranchModel(); + $this->RFQModel = new RFQModel(); + $this->insurerModel = new InsurerModel(); $this->issuer = [1 => 'JIBS', 2 => 'Nhance']; $this->clientType = [1 => 'Group', 2 => 'Individual']; @@ -296,4 +305,265 @@ class LeadsController extends BaseController } + //--------RFQ----------------------------------------------------------------------------------------------- + + + public function viewRFQ($id, $type = 1){ + + $data['rfq_data'] = $this->RFQModel + ->where('lead_id', $id) + ->where('type', $type) + ->where('is_active', 1) + ->first(); + + $data['rfq_count'] = $this->RFQModel + ->where('lead_id', $id) + ->where('type', 1) + ->where('is_active', 1) + ->countAllResults(); + + $data['qcr_count'] = $this->RFQModel + ->where('lead_id', $id) + ->where('type', 2) + ->where('is_active', 1) + ->countAllResults(); + + // dd(count($data['rfq_data'])); + + $data['lead_id'] = $id; + $lead_data = $this->leadsModel + ->select('policy_type.question_json') + ->join('policy_type', 'leads.policy_type_id = policy_type.id') + ->where('leads.id', $id) + ->first(); + + $data['question_json'] = $lead_data['question_json']; + $data['page_name'] = isset($data['rfq_data']['type']) && $data['rfq_data']['type'] == 2 ? 'QCR' : 'RFQ'; + $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); + + + // dd($data); + $this->loadLayout('view_rfq.php', $data); + } + + public function createRFQ(){ + + $data = $this->request->getPost(); + $lead_id = $data['lead_id']; + $data['type'] = 1; + $this->RFQModel + ->where('lead_id', $lead_id) + ->where('type', 1) + ->where('is_active', 1) + ->set('is_active', 0) + ->update(); + + $result = $this->RFQModel->insert($data); + + if ($result) { + return $this->respond(['status' => true, 'id' => $result, 'message' => 'New RFQ created successfully', 'data' =>$data], 200); + } + + return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' =>$data], 200); + + } + + public function createQCR(){ + + $data = $this->request->getPost(); + $lead_id = $data['lead_id']; + $data['type'] = 2; + + $this->RFQModel + ->where('lead_id', $lead_id) + ->where('type', 2) + ->where('is_active', 1) + ->set('is_active', 0) + ->update(); + + $result = $this->RFQModel->insert($data); + + if ($result) { + return $this->respond(['status' => true, 'id' => $result, 'message' => 'New QCR created successfully', 'data' =>$data], 200); + } + + return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' =>$data], 200); + } + + //-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------ + + //export main route function + public function exportQCRandRFQ($lead_id, $type, $export_type){ + + if($export_type == 'mail'){ + $this-> exportMailForQCRandRFQ($lead_id, $type); + }else{ + $this-> exportExcelForQCRandRFQ($lead_id, $type); + } + } + + //FOR EXCEL + public function exportExcelForQCRandRFQ($lead_id, $type) + { + $filepath = $this->constructExcelToSaveTemp($lead_id, $type); + $filepath = $filepath['filePath']; + + if (file_exists($filepath)) { + // Set headers to force download + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment; filename="' . basename($filepath) . '"'); + header('Content-Length: ' . filesize($filepath)); + header('Pragma: public'); + + // Output the file content + readfile($filepath); + + // Delete the file after download + unlink($filepath); + + exit; + } else { + echo "File does not exist."; + } + } + + //FOR MAIL + public function exportMailForQCRandRFQ($lead_id, $type){ + + $filepath = $this->constructExcelToSaveTemp($lead_id, $type); + + if ($filepath) { + return $this->respond(['status' => true, 'file_path' => $filepath, 'message' => 'Mail send successfully'], 200); + } + + return $this->respond(['status' => false, 'file_path' => $filepath, 'message' => "Mail send failed"], 200); + } + + //Construct excel file and save the file to the folder and return file path + public function constructExcelToSaveTemp($lead_id, $type) + { + $rfq_data = $this->RFQModel + ->select(' + leads.client_name, + leads.client_short_name, + insurers.name as insurer_name, + insurer_branch.branch_name as insurer_branch_name, + tpa.name as tpa_name, + tpa_branch.branch_name as tpa_branch_name, + policy_type.policy_type, + rfq.json + ') + ->join('leads', 'rfq.lead_id = leads.id') + ->join('policy_type', 'leads.policy_type_id = policy_type.id') + ->join('insurers', 'leads.insurer_id = insurers.id') + ->join('insurer_branch', 'leads.insurer_branch_id = insurer_branch.id') + ->join('tpa', 'leads.tpa_id = tpa.id') + ->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id') + ->where('rfq.lead_id', $lead_id) + ->where('rfq.type', $type) + ->where('rfq.is_active', 1) + ->first(); + + $lead_data = [ + 'Insured' => $rfq_data['client_name'], + 'Insurer' => $rfq_data['insurer_name'] . ' - ' . $rfq_data['insurer_branch_name'], + 'TPA' => $rfq_data['tpa_name'] . ' - ' . $rfq_data['tpa_branch_name'], + ]; + + $jsonData = $rfq_data['json']; + $data = json_decode($jsonData, true); + + // Initialize PhpSpreadsheet + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + + // Start with lead_data at the top + $rowNumber = 1; + foreach ($lead_data as $key => $value) { + $sheet->setCellValue("A{$rowNumber}", $key); + $sheet->setCellValue("B{$rowNumber}", $value); + + // Apply bold style to the key + $sheet->getStyle("A{$rowNumber}")->applyFromArray([ + 'font' => [ + 'bold' => true, + ], + ]); + + $rowNumber++; + } + + // Leave two blank rows + $rowNumber += 2; + + // Set headers and subheaders starting from current row + $headers = $data['table_data']['headers']; + $subHeaderRow = $rowNumber + 1; + $columnLetter = 'A'; + + // Add headers in the first row and subheaders in the second row + foreach ($headers as $header) { + if ($header['parentHeader'] === 'Item Key' || $header['parentHeader'] == 'Action') { + continue; // Skip "Item Key" and "Action" columns + } + + if($header['parentHeader'] === 'Sno'){ + $header['parentHeader'] = 'S.No.'; + } + + $sheet->setCellValue("{$columnLetter}{$rowNumber}", $header['parentHeader']); + + // Apply bold style to the header + $sheet->getStyle("{$columnLetter}{$rowNumber}")->applyFromArray([ + 'font' => [ + 'bold' => true, + ], + ]); + + foreach ($header['subHeaders'] as $subHeader) { + $sheet->setCellValue("{$columnLetter}{$subHeaderRow}", $subHeader); + + // Apply bold style to the subheader + $sheet->getStyle("{$columnLetter}{$subHeaderRow}")->applyFromArray([ + 'font' => [ + 'bold' => true, + ], + ]); + + $columnLetter++; + } + } + + // Move to next row for data entries + $rowNumber = $subHeaderRow + 1; + + // Add data rows + foreach ($data['table_data']['data'] as $dataRow) { + $columnLetter = 'A'; + foreach ($dataRow['data'] as $cellData) { + if ($cellData['parentth'] === 'Item Key' || $cellData['parentth'] == 'Action') { + continue; // Skip "Item Key" data + } + $sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['value']); + $columnLetter++; + } + $rowNumber++; + } + + // Set filename based on type + $string = ($type == 2) ? 'QCR' : 'RFQ'; + $filename = $string . '_' . $rfq_data['client_short_name'] . '_' . $rfq_data['policy_type'] . '_' . date('Ymdhis') . '.xlsx'; + + // Save to temporary location + $uploadFilePath = WRITEPATH . 'tmp/' . $filename; + $writer = new Xlsx($spreadsheet); + $writer->save($uploadFilePath); + + return [ + 'filePath' => $uploadFilePath, + 'fileName' => $filename, + ]; // Return file path and file name + } + } diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index 239ce3c5..9de34d05 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -91,14 +91,27 @@ class LeadsModel extends Model leads.*, kyc_entity_type.name as entity_type, policy_type.policy_type, - user_profiles.first_name as salse_person_name + user_profiles.first_name as salse_person_name, + + ( + SELECT COUNT(*) AS qcr_count + FROM rfq + WHERE type = 2 + AND is_active = 1 and lead_id = leads.id + ) AS qcr_count, + + ( + SELECT COUNT(*) AS rfq_count + FROM rfq + WHERE type = 1 + AND is_active = 1 and lead_id = leads.id + + ) AS rfq_count ') ->join('kyc_entity_type', 'leads.entity_type_id = kyc_entity_type.id', 'left') ->join('user_profiles', 'leads.salse_person_id = user_profiles.id', 'left') ->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left') ->where('leads.is_active', 1) - ->where('leads.is_active', 1) - ->where('leads.is_active', 1) ->orderBy('id', 'desc') ->findAll(); diff --git a/app/Models/PolicyTypeModel.php b/app/Models/PolicyTypeModel.php index 82c06d70..3edd01f1 100755 --- a/app/Models/PolicyTypeModel.php +++ b/app/Models/PolicyTypeModel.php @@ -22,5 +22,6 @@ class PolicyTypeModel extends Model "etp", "iep", "itp", + "question_json", ]; } diff --git a/app/Models/RFQModel.php b/app/Models/RFQModel.php new file mode 100644 index 00000000..f74a1313 --- /dev/null +++ b/app/Models/RFQModel.php @@ -0,0 +1,60 @@ +" onclick="getLeadsDataForEdit('')"> Edit - + RFQ + 0) { ?> + + QCR + + diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index c6d0e22a..c6e29bfe 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -799,7 +799,7 @@
- +
@@ -858,7 +858,7 @@ - +
SNO Client/Branch BranchName/codeNameEMP CodeRelationshipDate of Birth Policy name Insurer name TPA ID
-
- by + by diff --git a/app/Views/file_list.php b/app/Views/file_list.php index 2cd80976..a504ad5f 100755 --- a/app/Views/file_list.php +++ b/app/Views/file_list.php @@ -53,7 +53,7 @@ - ' . $file['first_name'] . '' ?> + ' . $file['first_name'] . '' ?> Date: Sat, 26 Oct 2024 08:50:13 +0530 Subject: [PATCH 08/17] CHANGE_TPA_TEMPLATE_ADD_BASIC_COVER_SI : RV --- app/Controllers/EmployeeController.php | 9 +++++---- app/Models/EmployeePolicyModel.php | 8 ++------ app/Views/layout/header.php | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 6ddc5808..7c5d3f01 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -1123,6 +1123,7 @@ class EmployeeController extends AdminController '{FRONT_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['front_card'], '{BACK_CARD}' => base_url() . 'public/uploads/template_bg/' . $value['back_card'], '{EMP_ID}' => $value['emp_code'], + '{SI_AMT}' => $value['basic_cover_si'], '{CORPORATE_NAME}' => $value['client_name'], '{AGE}' => $value['emp_age'], '{TPA_NAME}' => $value['tpa_name'], @@ -1304,10 +1305,9 @@ class EmployeeController extends AdminController } } + // Preview E-Card Template function public function previewTemplate($id = null) { - - $value = [ 'tpa_id' => 'TPA12345', 'name' => 'John Doe', @@ -1324,10 +1324,10 @@ class EmployeeController extends AdminController 'emp_age' => 39, 'tpa_name' => 'Example TPA', 'insurer_branch_city' => 'New York', - 'relationship' => 'Self' + 'relationship' => 'Self', + 'basic_cover_si' => '5,00,000', ]; - $tpa_id = $this->TPAModel->where('id', $id)->first(); $template_data_path = WRITEPATH . 'e_card_template/'; @@ -1354,6 +1354,7 @@ class EmployeeController extends AdminController '{POLICY_NO}' => $value['policy_no'], '{INSURER_NAME}' => strtoupper($value['insurer_name']), '{EMP_ID}' => $value['emp_code'], + '{SI_AMT}' => $value['basic_cover_si'], '{CORPORATE_NAME}' => $value['client_name'], '{AGE}' => $value['emp_age'], '{TPA_NAME}' => $value['tpa_name'], diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index a0172b1d..180f810c 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -851,6 +851,7 @@ class EmployeePolicyModel extends Model ep.tpa_id, ep.uhid, ep.policy_end_date, + ep.basic_cover_si, clients.client_name, clients.short_name AS client_short_name, @@ -858,8 +859,6 @@ class EmployeePolicyModel extends Model cp.policy_start_date, cp.policy_no, - policies.name AS policy_name, - insurers.name AS insurer_name, insurers.short_name AS insurer_short_name, insurers.insurer_logo, @@ -878,7 +877,6 @@ class EmployeePolicyModel extends Model ->join('employee_polices ep', 'ep.employee_id = e.id') ->join('client_policy cp', 'cp.id = ep.client_policy_id') ->join('clients', 'clients.id = cp.client_id') - ->join('policies', 'policies.id = cp.policy_id') ->join('insurers', 'insurers.id = cp.insurer_id') ->join('insurer_branch', 'insurer_branch.id = cp.insurer_branch_id') ->join('tpa', 'tpa.id = cp.tpa_id') @@ -918,6 +916,7 @@ class EmployeePolicyModel extends Model ep.tpa_id, ep.uhid, ep.policy_end_date, + ep.basic_cover_si, clients.client_name, clients.short_name AS client_short_name, @@ -925,8 +924,6 @@ class EmployeePolicyModel extends Model cp.policy_start_date, cp.policy_no, - policies.name AS policy_name, - insurers.name AS insurer_name, insurers.short_name AS insurer_short_name, insurers.insurer_logo, @@ -945,7 +942,6 @@ class EmployeePolicyModel extends Model ->join('employee_polices ep', 'ep.employee_id = e.id') ->join('client_policy cp', 'cp.id = ep.client_policy_id') ->join('clients', 'clients.id = cp.client_id') - ->join('policies', 'policies.id = cp.policy_id') ->join('insurers', 'insurers.id = cp.insurer_id') ->join('insurer_branch', 'insurer_branch.id = cp.insurer_branch_id') ->join('tpa', 'tpa.id = cp.tpa_id') diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index fbb9588f..9ad74bc1 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -663,7 +663,7 @@ --> - +
  • From 32b64d236d1a6812acc423e6cc86b228a7661b1b Mon Sep 17 00:00:00 2001 From: Smart Date: Sat, 26 Oct 2024 17:01:29 +0530 Subject: [PATCH 09/17] CHANGE_create date_coverage filed value while dependent creation : GWM --- app/Controllers/EmployeeRestController.php | 51 +++++++++++++++++----- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index b4359c53..dd807973 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -309,6 +309,7 @@ class EmployeeRestController extends AdminController $data['client_policy_id']= $client_policy_id; $data['basic_cover_si']= $basic_cover_si; $data['status']= 'draft'; + $data['date_coverage'] = $this->getEmployeeCoverageDate($emp_code, $client_policy_id); $this->employeePolicyModel->insert($data); @@ -320,10 +321,7 @@ class EmployeeRestController extends AdminController public function updatePremiumAmount($client_policy_id , $emp_code , $client_branch_id) { $response = $this->calculatePremium($client_policy_id , $emp_code , null , $client_branch_id); - // echo '
    ';
    -        // print_r($response);
    -        // echo '
    '; - // die(); + if(count($response[$emp_code])) { @@ -354,6 +352,45 @@ class EmployeeRestController extends AdminController } } + public function getEmployeeCoverageDate($emp_code, $client_policy_id) + { + $empData = $this->employeeModel->where('emp_code',$emp_code)->where('relationship', 'self')->where('is_active',1)->first();; + if($empData) + { + $empPolicyData = $this->employeePolicyModel->select('employee_polices.employee_id,employee_polices.client_policy_id,employee_polices.date_coverage,client_policy.policy_type_id,client_policy.base_policy') + ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id', 'left') + ->where('employee_polices.employee_id' , $empData['id'] ) + ->where('employee_polices.is_active' , 1 ) + ->findAll(); + if(count($empPolicyData)) + { + // find same policy 'self' date of coverage + $filterSelfPolicy = array_filter($empPolicyData, function($row) use ($client_policy_id) { + return $row['client_policy_id'] == $client_policy_id; + }); + $filterSelfPolicy = array_values($filterSelfPolicy); // Reset the index of the filtered result + + if(count($filterSelfPolicy)){ + return $filterSelfPolicy[0]['date_coverage']; + }else{ + // find base policy 'self' date of coverage + $basePolicy = $this->clientPolicyModel->where('id',$client_policy_id)->get()->getRow()->base_policy; + + $filterSelfBasePolicy = array_filter($empPolicyData, function($row) use ($basePolicy) { + return $row['client_policy_id'] == $basePolicy; + }); + $filterSelfBasePolicy = array_values($filterSelfBasePolicy); // Reset the index of the filtered result + + if(count($filterSelfBasePolicy)){ + return $filterSelfBasePolicy[0]['date_coverage']; + }else{ return null; } + } + + }else{ return null; } + + }else{ return null; } + } + public function RelationshipMap($value){ @@ -432,7 +469,6 @@ class EmployeeRestController extends AdminController } - // Get the RelationShip list public function createOrUpdateEmployeePolicySiAmount() { @@ -632,11 +668,6 @@ class EmployeeRestController extends AdminController } - - - - - // Upload the Employee Detail in DB by Sheet Data public function employeeUpload() { From 25bbfa1125d3aba4793103f2984344015fca7190 Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 26 Oct 2024 17:51:09 +0530 Subject: [PATCH 10/17] FEAT_EXPLORED_GMAILAPI_ATTACHEMENT&MAIL_DELIVERY_STATUS --- app/Config/Routes.php | 3 +- app/Controllers/MasterController.php | 4 +- app/Helpers/MailHelper.php | 5 +- app/Libraries/GmailAPI.php | 158 +++++++++++++++++++++------ app/Views/employee_data_list.php | 2 + public/sample_excel/enrollment.xlsx | Bin 7646 -> 7762 bytes 6 files changed, 132 insertions(+), 40 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index ca0cbe4f..8c1521be 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -355,7 +355,8 @@ $routes->cli('cli/processjobs', 'JobWorker::processJobs'); $routes->get("processjob", "JobWorker::processJob"); $routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken'); -$routes->cli('cli/send_mail_cli(/:any)?', 'MasterController::testGmailAPIViaCLI$1'); +$routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI'); +$routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMails'); $routes->cli('cli/app_check_list', 'MasterController::appCheckList'); $routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken'); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 691234eb..0a5bb5d1 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -34,6 +34,8 @@ use App\Models\InsurerExcelExportTemplateModel; use App\Models\SettingsModel; use App\Models\VehicleModel; +use CodeIgniter\CLI\CLI; + class MasterController extends AdminController { use ResponseTrait; @@ -1672,7 +1674,7 @@ class MasterController extends AdminController echo "Check the following..!\n"; echo "1. Update Gmail Oauth credentials in 'gmail_api_oauth_credentials' field in 'settings' table in JSON format.\n"; echo "2. Call this cli route to generate new access token: 'php public/index.php cli/new_gmail_token' from root of the project.\n"; - echo "3. Call this cli route : 'php public/index.php cli/send_mail_cli someone@gmail.com' to send test mail to testGmailAPIViaCLI ( replace someone@gmail.com with real time mail).\n"; + echo "3. Call this cli route : 'php public/index.php cli/send_mail_cli --to someone@gmail.com' to send test mail to testGmailAPIViaCLI ( replace someone@gmail.com with real time mail).\n"; } else { diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index f94d6419..a65a5b31 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -93,7 +93,8 @@ class MailHelper $emaill = $params['mail']; $subject = $params['subject']; $message = $params['message']; - + $attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : []; + //check BCC mail if (isset($params['bcc'])) { $bcc = $params['bcc']; @@ -118,7 +119,7 @@ class MailHelper try { - $res = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc); + $res = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments); if($res['status']) { diff --git a/app/Libraries/GmailAPI.php b/app/Libraries/GmailAPI.php index f08a832e..e74101d4 100755 --- a/app/Libraries/GmailAPI.php +++ b/app/Libraries/GmailAPI.php @@ -26,18 +26,20 @@ class GmailAPI 'https://www.googleapis.com/auth/gmail.addons.current.message.readonly', 'https://www.googleapis.com/auth/gmail.readonly', 'https://www.googleapis.com/auth/gmail.labels', - 'https://www.googleapis.com/auth/gmail.send' + 'https://www.googleapis.com/auth/gmail.send', + 'https://mail.google.com/' ]); $this->setAuthConfig(); //die(); $this->client->setAccessType('offline'); $this->client->setPrompt('select_account consent'); - - if (php_sapi_name() !== 'cli' || (uri_string() == 'cli/send_mail_cli' || uri_string() == 'cli/processjob') ) + // echo uri_string();//die(); + if (php_sapi_name() !== 'cli' || (uri_string() == 'cli/send_mail_cli' || uri_string() == 'cli/processjob' || uri_string() == 'cli/check_bounce_mail_cli') ) { + // echo 'getting token';die(); $this->setTokenFromDB(); // Call only if not in CLI } - + // die(); $this->service = new Gmail($this->client); } @@ -99,44 +101,73 @@ class GmailAPI $settingsModel->where('id', 1)->set([$this->tokenField => $token])->update(); } - public function createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = []) - { - $boundary = uniqid(rand(), true); + public function createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = [], $attachments = []) +{ + // print_r($to);die(); + $boundary = uniqid(rand(), true); // Unique boundary for separating parts - $rawMessageString = "From: $from\r\n"; - $rawMessageString .= "To: $to\r\n"; - $rawMessageString .= "Reply-To: $replyTo\r\n"; + // Initialize raw message headers + $rawMessageString = "From: $from\r\n"; + $rawMessageString .= "To: $to\r\n"; + $rawMessageString .= "Reply-To: $replyTo\r\n"; - if (!empty($cc)) { - $rawMessageString .= "Cc: " . implode(',', $cc) . "\r\n"; - } - - if (!empty($bcc)) { - $rawMessageString .= "Bcc: " . implode(',', $bcc) . "\r\n"; - } - - $rawMessageString .= "Subject: $subject\r\n"; - $rawMessageString .= "MIME-Version: 1.0\r\n"; - $rawMessageString .= "Content-Type: multipart/alternative; boundary=\"$boundary\"\r\n\r\n"; - $rawMessageString .= "--$boundary\r\n"; - $rawMessageString .= "Content-Type: text/html; charset=UTF-8\r\n"; - $rawMessageString .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; - $rawMessageString .= $htmlContent . "\r\n"; - $rawMessageString .= "--$boundary--"; - - $rawMessage = base64_encode($rawMessageString); - $rawMessage = str_replace(['+', '/', '='], ['-', '_', ''], $rawMessage); - - $message = new Message(); - $message->setRaw($rawMessage); - - return $message; + if (!empty($cc)) { + $rawMessageString .= "Cc: " . implode(',', $cc) . "\r\n"; } - public function sendMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = []) + if (!empty($bcc)) { + $rawMessageString .= "Bcc: " . implode(',', $bcc) . "\r\n"; + } + + $rawMessageString .= "Subject: $subject\r\n"; + $rawMessageString .= "MIME-Version: 1.0\r\n"; + $rawMessageString .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\r\n"; + + // Add HTML content as an alternative part + $rawMessageString .= "--$boundary\r\n"; + $rawMessageString .= "Content-Type: text/html; charset=UTF-8\r\n"; + $rawMessageString .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; + $rawMessageString .= $htmlContent . "\r\n\r\n"; + + // Process each attachment + foreach ($attachments as $attachment) { + $filePath = $attachment['filePath']; + $fileName = $attachment['fileName']; + $fileData = file_get_contents($filePath); + + if ($fileData === false) { + continue; // Skip this attachment if file cannot be read + } + + $base64File = base64_encode($fileData); + + // Add each attachment with appropriate headers + $rawMessageString .= "--$boundary\r\n"; + $rawMessageString .= "Content-Type: application/octet-stream; name=\"$fileName\"\r\n"; + $rawMessageString .= "Content-Disposition: attachment; filename=\"$fileName\"\r\n"; + $rawMessageString .= "Content-Transfer-Encoding: base64\r\n\r\n"; + $rawMessageString .= chunk_split($base64File) . "\r\n\r\n"; + } + + // End boundary to signify the end of the message + $rawMessageString .= "--$boundary--"; + + // Encode the final raw message in base64 for Gmail API + $rawMessage = base64_encode($rawMessageString); + $rawMessage = str_replace(['+', '/', '='], ['-', '_', ''], $rawMessage); + + // Create Gmail message object + $message = new Message(); + $message->setRaw($rawMessage); + + return $message; +} + + + public function sendMessage($to, $subject, $htmlContent, $from, $replyTo, $cc = [], $bcc = [],$attachments = []) { try { - $message = $this->createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc, $bcc); + $message = $this->createMessage($to, $subject, $htmlContent, $from, $replyTo, $cc, $bcc,$attachments); $res = $this->service->users_messages->send('me', $message); return array('status' => true, 'data' => $res); } catch (\Exception $e) { @@ -177,4 +208,59 @@ class GmailAPI $this->myLogger->logme('error', 'New token generated and stored in the database.'); print 'New token generated and stored in the database.'; } + + + + public function checkBounceStatus( string $userId = 'me',string $from_date = null,string $to_date = null,int $count = null,string $page = null) + { + $query = 'from:mailer-daemon OR "delivery failed" OR "failure notice"'; + if($from_date != '' && $to_date != '') + { + $query .= 'after:' . $from_date . ' before:' . $to_date; + } + $maxResults = $count ? $count : 20; + $pageToken = $page ? $page : null; + + $params = ['q' => $query,'maxResults' => $maxResults]; + if(isset($pageToken)){ $params['pageToken'] = $pageToken; } + $messages = $this->service->users_messages->listUsersMessages($userId, $params); + + $bounceDetails = []; + $pageToken = $messages->getNextPageToken(); + $bounceDetails['pageToken'] = $pageToken; + if (count($messages->getMessages()) > 0) { + foreach ($messages->getMessages() as $message) { + // Get full message details + $msg = $this->service->users_messages->get($userId, $message->getId(), ['format' => 'full']); + + // Extract important headers and content + $headers = $msg->getPayload()->getHeaders(); + $subject = null; + $date = null; + $to = null; + + foreach ($headers as $header) { + if ($header->getName() === 'Subject') { + $subject = $header->getValue(); + } + if ($header->getName() === 'Date') { + $date = $header->getValue(); + } + if ($header->getName() === 'To') { + $to = $header->getValue(); + } + } + + $bounceDetails['data'][] = [ + 'subject' => $subject, + 'date' => $date, + 'to' => $to, + 'snippet' => $msg->getSnippet(), + ]; + } + } + + return $bounceDetails; + } + } diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index 69ca1f74..2a70d76a 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -67,6 +67,7 @@
  • Name EMP Code RelationshipGender Date of Birth Policy name Insurer name -
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    SnoParticularsProposal 1 + + + + + Action
    - - Quote Asked -
    1 + QCR + Client + + +
    + + + + + + + + + +
    + + +
    +
    + +
    + + + +
    + + +
    +
    Family Members
    +
    +
    +
    + +
    + +
    + + + + +
    + +
    + + + + + + + + \ No newline at end of file From a6422ba6b6f005aed8ce591ba86bf507dbaf3613 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 29 Oct 2024 15:24:07 +0530 Subject: [PATCH 14/17] FEAT_SEND_MAIL_ATTACHMENT_RFQ --- app/Config/Routes.php | 1 + app/Controllers/LeadsController.php | 77 ++++++++++++++++++++++++++++ app/Controllers/MasterController.php | 13 ++++- 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 8c1521be..6885275a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -343,6 +343,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) { $routes->get("list", "LeadsController::viewLeadsList"); $routes->post("create", "LeadsController::createLead"); $routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1"); + $routes->get("sendMail", "LeadsController::sendMailWithAttachement"); }); $routes->get("driveListFiles", "GoogleDriveController::listFiles"); diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 9c9d153f..f3a85d33 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -16,6 +16,9 @@ use App\Models\PolicyTransactionStatusModel; use App\Models\InsurerBranchModel; use App\Models\TPABranchModel; +use App\Helpers\MailHelper; + + class LeadsController extends BaseController { use ResponseTrait; @@ -296,4 +299,78 @@ class LeadsController extends BaseController } + //this funciton for send mail to insurer and client with either RFQ/QCR + public function sendMailWithAttachement() + { + helper('excel_util_helper'); + helper('MailHelper'); + + $params = $this->request->getGet(); + // dd($params); + $lead_id = $params['lead_id']; + $file_type = $params['file_type']; //rfq or qcr + $recipient_type = $params['recipient_type'];//insurer or client + $recipient_mail = $params['recipient_mail'];// - only primary key of contacts + $recipient_mail = json_decode($params['recipient_mail'], true);;// - only primary key of contacts + $cc = 'velz1990@gmail.com,vitvelz@gmail.com'; + $reply_to = 'velmurugan.s@venbainfotech.com'; + $result_data = []; + // dd($recipient_mail); + if(!is_array($recipient_mail) || count($recipient_mail) == 0) + { + 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') + ->join('policy_type','leads.policy_type_id = policy_type.id') + ->where('leads.id', $lead_id) + ->first(); + // dd($lead_data); + // dd(calculate_days_bw_dates($lead_data['policy_end_date'],$lead_data['policy_start_date'])); + //get file path to attach + $file_path = WRITEPATH."uploads/excel/sample/correction.xls"; + $file_name = $file_type.'.xlsx'; + + $attachments = [['fileName' => $file_name,'filePath' => $file_path]]; + + //get recipient address + $recipient_data = $this->levelContactModel + ->where(['contact_type' => $recipient_type, 'is_active' => 1]) + ->whereIn('id', $recipient_mail) + ->findAll(); + // !dd($recipient_data); + + $subject = $file_type == 'rfq' ? 'Request for Quotation from '. $lead_data['client_name'] . ' for '.$lead_data['policy_type'] : 'Quotation Comparison Report for ' .$lead_data['policy_type']; + $message = ''; + + + foreach($recipient_data as $recipient) + { + + $message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'], $message); + $message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message); + $message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message); + $message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'],'Y-m-d','d-m-Y'), $message); + $message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'],$lead_data['policy_start_date'])->days, $message); + + // !dd($message); + $res = MailHelper::send_email(['mail' => $recipient['email'], 'subject' => $subject, 'message' => $message,'attachments' => $attachments,'reply_to' => $reply_to]); + // !dd($res); + // if($res['status'] == 'success' && $res['code'] == '200') + // { + $result_data[] = ['mail' => $recipient['email'],'status' => $res]; + // } + // else + // { + // $result_data[] = ['mail' => $recipient['email'],'status' => 'falied']; + // } + } + //delete attachment file + // unlink($file_path); + return $this->respond(['status' => 'success','code' => 200,'data' => $result_data ], 200); + + } + + } diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 42f3d660..a4927e3d 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1605,10 +1605,21 @@ class MasterController extends AdminController //testing a sample mail from cli public function testGmailAPIViaCLI(string $email_id = 'velmurugan.s@venbainfotech.com') { + + $email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id; // print_r($email_id);die(); // $gmailapi = \Config\Services::gmailapi(); + $message = ''; + + $attachments = [ + ["filePath" => WRITEPATH."uploads/excel/sample/correction.xls","fileName" => "correction.xls"], + ["filePath" => WRITEPATH."uploads/excel/sample/deletion.xls","fileName" => "deletion.xls"], + ["filePath" => "C:\\Users\\Venba\\Desktop\\IQ.pdf","fileName" => "Questions.pdf"], + ["filePath" => "C:\\Users\\Venba\\Desktop\\config_age.png","fileName" => "config_age.png"] + ]; + $email_id = CLI::getOption('to') ? CLI::getOption('to') : $email_id; - $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => 'This is sample mail sent via CLI mode']); + $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments]); print_r($res); } From 4272bd817cef16039f3574496e9e9f9ac4855031 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 29 Oct 2024 17:53:08 +0530 Subject: [PATCH 15/17] CHNAGE_RFQ_MAIL_TEMPLATE --- app/Controllers/LeadsController.php | 54 ++++++++++++++++++----------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 8b68ef55..b9f4029f 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -22,6 +22,7 @@ use App\Models\RFQModel; use App\Models\InsurerModel; use App\Helpers\MailHelper; +use Kint; class LeadsController extends BaseController @@ -583,61 +584,72 @@ class LeadsController extends BaseController $recipient_mail = $params['recipient_mail'];// - only primary key of contacts $recipient_mail = json_decode($params['recipient_mail'], true);;// - only primary key of contacts $cc = 'velz1990@gmail.com,vitvelz@gmail.com'; - $reply_to = 'velmurugan.s@venbainfotech.com'; + $result_data = []; // dd($recipient_mail); - if(!is_array($recipient_mail) || count($recipient_mail) == 0) + if($recipient_type == 'insurer' && (!is_array($recipient_mail) || count($recipient_mail) == 0)) { return $this->respond(['status' => 'failed','code' => 400,'data' => '','messgae' => 'Recipient mail not found ! ' ], 200); } + // dd(); //gather lead info $lead_data = $this->leadsModel - ->select('leads.*,policy_type.long_name,policy_type.policy_type') + ->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') + ->join('user_profiles','leads.created_by = user_profiles.id') ->where('leads.id', $lead_id) ->first(); + if( $recipient_type == 'client' && ($lead_data['contact_person_email'] == '' || $lead_data['contact_person_email'] == null)) + { + return $this->respond(['status' => 'failed','code' => 400,'data' => '','messgae' => 'Recipient mail not found ! ' ], 200); + } // dd($lead_data); - // dd(calculate_days_bw_dates($lead_data['policy_end_date'],$lead_data['policy_start_date'])); + $reply_to = $lead_data['created_person_email']; //get file path to attach - $file_path = WRITEPATH."uploads/excel/sample/correction.xls"; - $file_name = $file_type.'.xlsx'; - + $file_info = $this->constructExcelToSaveTemp($lead_id, ( $file_type == 'rfq' ? 1 : 2) ); + // $file_path = WRITEPATH."uploads/excel/sample/correction.xls"; + // $file_name = $file_type.'.xlsx'; + // !dd($file_info); + $file_path = $file_info['filePath']; + $file_name = $file_info['fileName']; $attachments = [['fileName' => $file_name,'filePath' => $file_path]]; //get recipient address - $recipient_data = $this->levelContactModel + if($recipient_type == 'insurer') + { + $recipient_data = $this->levelContactModel ->where(['contact_type' => $recipient_type, 'is_active' => 1]) ->whereIn('id', $recipient_mail) ->findAll(); + } + else + { + $recipient_data = [['name' => $lead_data['contact_person_name'],'email' => $lead_data['contact_person_email']] ]; + } // !dd($recipient_data); $subject = $file_type == 'rfq' ? 'Request for Quotation from '. $lead_data['client_name'] . ' for '.$lead_data['policy_type'] : 'Quotation Comparison Report for ' .$lead_data['policy_type']; - $message = ''; + $original_message = '

    Request for Quotation (RFQ)

    Dear {{RECIPIENT_NAME}},

    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.

    RFQ Details

    Client name{{CLIENT_NAME}}
    Coverage Type{{POLICY_LONG_NAME}}
    Policy Start Date{{POLICY_START_DATE}}
    Policy Duration{{DURATION}}
    Please note: Additional terms and details are included in the attachment for your reference.

    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.

    '; foreach($recipient_data as $recipient) { - + $message = $original_message; $message = str_replace("{{RECIPIENT_NAME}}", $recipient['name'], $message); $message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message); $message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message); $message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'],'Y-m-d','d-m-Y'), $message); $message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'],$lead_data['policy_start_date'])->days, $message); - // !dd($message); - $res = MailHelper::send_email(['mail' => $recipient['email'], 'subject' => $subject, 'message' => $message,'attachments' => $attachments,'reply_to' => $reply_to]); + // print_rr($message); + + $res = MailHelper::send_email(['mail' => $recipient['email'], 'subject' => $subject, 'message' => $message,'attachments' => $attachments,'reply_to' => $reply_to]); // !dd($res); - // if($res['status'] == 'success' && $res['code'] == '200') - // { - $result_data[] = ['mail' => $recipient['email'],'status' => $res]; - // } - // else - // { - // $result_data[] = ['mail' => $recipient['email'],'status' => 'falied']; - // } + + $result_data[] = ['mail' => $recipient['email'],'status' => $res]; } //delete attachment file - // unlink($file_path); + unlink($file_path); return $this->respond(['status' => 'success','code' => 200,'data' => $result_data ], 200); } From de8049eaed3f6e46bcb0d5c32e298a51d4f29787 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 29 Oct 2024 21:30:07 +0530 Subject: [PATCH 16/17] FEAT_RFQ_MAIL_GET_FROM_MODAL_DATA : RV --- app/Config/Routes.php | 8 ++ app/Controllers/LeadsController.php | 14 ++- app/Models/LevelContactModel.php | 24 ++++ app/Views/leads_form.php | 13 ++- app/Views/view_rfq.php | 175 +++++++++++++++++++++++++++- 5 files changed, 227 insertions(+), 7 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0771e41a..ede8146b 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -300,6 +300,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("send_manual_reminder/(:any)", "DashboardController::sendManualReminder/$1"); $routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1"); $routes->get("get_client_branch_data/(:any)", "ClientController::get_client_branch_data/$1"); + $routes->get("getLevelContects", "LeadsController::getLevelContects"); }); @@ -348,6 +349,13 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) { $routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); }); +$routes->group("rfq", ["filter" => "authMVC"], function ($routes) { + $routes->post("create", "LeadsController::createRFQ"); + $routes->post("createQCR", "LeadsController::createQCR"); + $routes->get("list/(:any)", "LeadsController::viewRFQ/$1"); +}); + + $routes->get("driveListFiles", "GoogleDriveController::listFiles"); $routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']); $routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']); diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 8b68ef55..b542b7a1 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -344,7 +344,7 @@ class LeadsController extends BaseController $data['page_name'] = isset($data['rfq_data']['type']) && $data['rfq_data']['type'] == 2 ? 'QCR' : 'RFQ'; $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); - + $data['lead_data'] = $this->leadsModel->where('leads.id', $id)->where('leads.is_active', 1)->first(); // dd($data); $this->loadLayout('view_rfq.php', $data); } @@ -642,5 +642,17 @@ class LeadsController extends BaseController } + public function getLevelContects(){ + + $data = $this->levelContactModel->getContectForRFQ(); + + if($data){ + return $this->respond(['status' => true, 'data' => $data], 200); + }else{ + return $this->respond(['status' => false], 200); + } + + } + } diff --git a/app/Models/LevelContactModel.php b/app/Models/LevelContactModel.php index 88f52ab2..234db3aa 100755 --- a/app/Models/LevelContactModel.php +++ b/app/Models/LevelContactModel.php @@ -25,4 +25,28 @@ class LevelContactModel extends Model "token_time_out" ]; + + public function getContectForRFQ(){ + + $result = $this + + ->select(' + level_contacts.id, + insurers.short_name as insurer_name, + insurer_branch.branch_code, + level_contacts.name as contect_person_name, + level_contacts.email as contect_person_email, + ') + ->join('insurer_branch', 'level_contacts.ref_id = insurer_branch.id') + ->join('insurers', 'insurer_branch.insurer_id = insurers.id') + ->where('level_contacts.contact_type', 'insurer') + ->where('level_contacts.is_active', 1) + ->where('insurer_branch.is_active', 1) + ->where('insurers.is_active', 1) + ->findAll(); + + return $result; + + } + } diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index f00ea8b6..9cb36865 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -278,6 +278,8 @@ //SELECT2 document ready function $(document).ready(function() { + + getURLParamsForReport() addHTMLInput() setTimeout(function() { $("textarea.select2-search__field").attr('rows', '1'); @@ -870,19 +872,20 @@ function tpaChange(input, unique_id) { //----------------------------------------------------------------------------------------------------------- function getURLParamsForReport() { - const params = new URLSearchParams(window.location.search); - const pt_id = params.get('pt_id') ?? 0; - if (pt_id != 0) { + const params = new URLSearchParams(window.location.search); + const lead_id = params.get('lead_id') ?? 0; + + if (lead_id != 0) { hide_list_show_add(); setTimeout(() => - getPolicyTransactionDataForEdit(pt_id), + getLeadsDataForEdit(lead_id), 1500); // Reduced timeout } else { show_list_hide_add(); } - console.log('pt_id', pt_id); // Retain the log if necessary + console.log('lead_id', lead_id); // Retain the log if necessary } \ No newline at end of file diff --git a/app/Views/view_rfq.php b/app/Views/view_rfq.php index ba2f222b..0874cb18 100644 --- a/app/Views/view_rfq.php +++ b/app/Views/view_rfq.php @@ -202,7 +202,7 @@ body {       Export Excel - + @@ -316,6 +316,29 @@ body { + + + +