From 65d6d5a8cd4a14bed81441d9a18a38ffaa4490c0 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 12 Feb 2025 14:10:23 +0530 Subject: [PATCH] FEAT_LEAD_FILTER_AND_OTHER_CHANGES : RV --- app/Config/Routes.php | 5 +- app/Controllers/EmpDataServiceController.php | 35 +- app/Controllers/LeadsController.php | 27 +- app/Models/LeadsModel.php | 19 +- app/Views/lead_filter.php | 367 +++++++++++++++++++ app/Views/leads_list.php | 3 + app/Views/view_rfq.php | 25 +- 7 files changed, 451 insertions(+), 30 deletions(-) create mode 100644 app/Views/lead_filter.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 77b01b3d..b3c5c7a4 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -387,15 +387,14 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->group("leads", ["filter" => "authMVC"], function ($routes) { - $routes->get("list", "LeadsController::viewLeadsList"); + $routes->match(['get', 'post'],"list", "LeadsController::viewLeadsList"); $routes->post("create", "LeadsController::createLead"); $routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1"); $routes->get("sendMail", "LeadsController::sendMailWithAttachement"); $routes->post("sendMail", "LeadsController::sendMailWithAttachement"); $routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1"); $routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1"); - $routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1"); - + $routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1"); }); $routes->group("rfq", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index 856ef118..83cdbaf0 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -1011,14 +1011,33 @@ class EmpDataServiceController extends BaseController // dd($inceptionData, $additionData, $dependentAdditionData, $correctionData, $enhancementData, $deletionData, $mergedData); - $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', 'all') - ->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(); + // $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', 'all') + // ->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(); + + $sql = " + SELECT `insurer_excel_export_template`.`jsoncolumns` + FROM `client_policy` + JOIN `insurer_excel_export_template` + ON `insurer_excel_export_template`.`insurer_id` = `client_policy`.`insurer_id` + AND `insurer_excel_export_template`.`policy_type_id` = + CASE + WHEN `client_policy`.`policy_type_id` IN (2, 3, 4, 5) THEN 2 + ELSE `client_policy`.`policy_type_id` + END + WHERE `client_policy`.`id` = '".$export_data['client_policy_id']."' + AND `insurer_excel_export_template`.`event_name` = 'all' + AND `insurer_excel_export_template`.`is_active` = 1 + AND `insurer_excel_export_template`.`type_name` = '".$export_data['actions']."' + LIMIT 1"; + + $query = db_connect()->query($sql); + $template_json = $query->getRowArray(); if(!empty($template_json) && $template_json != null){ diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 0a9c444c..d274600b 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -107,6 +107,7 @@ class LeadsController extends BaseController // $d = $this->calculateMembersDemography(['lead_id' => 24]); //$this->mergeQuoteExcelFileWithMembersListExcelFile(24, 1, $propsal_and_insurer = null); // dd($d); + $data['page_name'] = 'Leads'; // Set basic data @@ -134,11 +135,27 @@ class LeadsController extends BaseController // dd($data); - // Fetch leads data - $data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising(); - - // Load layout and pass data - $this->loadLayout('leads_list', $data); + if ($this->request->is('get')) { + // Fetch leads data + $data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising(); + // Load layout and pass data + $this->loadLayout('lead_filter', $data); + }else{ + + $search_data = $this->request->getPost(); + // print_r($search_data); + + $where = []; + foreach ($search_data as $search_objects => $key) { + if ($key != null && $key != '' && $key != 0) { + $where[$search_objects] = $key; + } + } + + $data['lead_data_list'] = $this->leadsModel->getLeadDataForLising($where); + $html = view('leads_list', $data); + return $this->respond(['status' => true, 'html' => $html], 200); + } } public function createLead() diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php index 5867a5d0..bc47a3ff 100644 --- a/app/Models/LeadsModel.php +++ b/app/Models/LeadsModel.php @@ -120,10 +120,10 @@ class LeadsModel extends Model return $data; } - public function getLeadDataForLising() + public function getLeadDataForLising($where = null) { - return $this->select(' + $data = $this->select(' leads.*, kyc_entity_type.name as entity_type, policy_type.policy_type, @@ -144,13 +144,16 @@ class LeadsModel extends Model ) 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) - ->orderBy('id', 'desc') - ->findAll(); + ->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); + if (!empty($where)) { + $data->where($where); + } + + return $data->orderBy('leads.id', 'desc')->findAll(); } public function getLeadForInsertClientList($type = null, $client_id = null) diff --git a/app/Views/lead_filter.php b/app/Views/lead_filter.php new file mode 100644 index 00000000..d0a00908 --- /dev/null +++ b/app/Views/lead_filter.php @@ -0,0 +1,367 @@ + + +
+
+
+
+
+
+
+

Lead Filter

+
+
+ + + +
+
+
+
+
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+ +
+
+
+
+ +
+
+
+ + +
+ +
+ + + \ No newline at end of file diff --git a/app/Views/leads_list.php b/app/Views/leads_list.php index ddf4d238..cbe4d478 100644 --- a/app/Views/leads_list.php +++ b/app/Views/leads_list.php @@ -161,6 +161,7 @@ table.dataTable tbody td {