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/ClientController.php b/app/Controllers/ClientController.php index bde79526..d7581c63 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4335,44 +4335,7 @@ class ClientController extends AdminController // ----------------------------------------------------------------------------------------------------- - public function updateRenewalData() - { - $db = db_connect(); - $renewalData = $db->table('old_renewal_data_copy') - ->where('client_id IS NOT NULL') - ->where('is_inserted != 1') - ->get() - ->getResultArray(); - - $successData = []; - foreach ($renewalData as $key => $value) { - // Get branch_id properly - $branch = $this->clientBranchModel->where('client_id', $value['client_id'] ?? 0)->first(); - $value['branch_id'] = $branch['branch_id'] ?? null; - - // Fix vehicle_id key (previously "vehicel_id") - $value['vehicle_id'] = null; - if ($value['policy_type_id'] == 8 && !empty($value['policy_type_id'])) { - $value['vehicle_id'] = $this->prepareVehicleData($value); - } - - // Process client policy, policy transaction, and co-share details - $value['client_policy_id'] = $this->prepareClientPolicy($value); - $value['pt_id'] = $this->preparePolicyData($value); - $value['pt_co_id'] = $this->preparePtCoShareDetails($value); - - // Update is_inserted field in DB - $db->table('old_renewal_data_copy') - ->where('id', $value['id']) - ->set(['is_inserted' => 1]) - ->update(); - - $successData[] = ['id' => $value['id'], 'client' => $value['insured']]; - } - - kint::dump($successData); - } - + // private function preparePolicyData($renewalData) // { // $data = [ @@ -4396,11 +4359,11 @@ class ClientController extends AdminController // 'ct_type' => 1, // 'cd_ac_pk' => $renewalData['cd_ac_pk'] ?? null, // ]; - + // $policyTransactionModel = new PolicyTransactionModel(); // return $policyTransactionModel->insert($data); // } - + // private function prepareVehicleData($renewalData) // { // $vehicleData = [ @@ -4408,11 +4371,11 @@ class ClientController extends AdminController // 'owner' => $renewalData['client_id'], // 'branch_id' => ($renewalData['client_type_id'] == 1) ? $renewalData['branch_id'] : null, // ]; - + // $vehicleModel = new VehicleModel(); // return $vehicleModel->insert($vehicleData); // } - + // private function preparePtCoShareDetails($renewalData) // { // $ptCoShareDetails = [ @@ -4426,11 +4389,11 @@ class ClientController extends AdminController // 'tep_amt' => 0.00, // 'follower_policy_no' => $renewalData['policy_no'], // ]; - + // $ptCoShareDetailsModel = new PTCOShareDetailsModel(); // return $ptCoShareDetailsModel->insert($ptCoShareDetails); // } - + // private function prepareClientPolicy($renewalData) // { // $clientPolicy = [ @@ -4446,27 +4409,67 @@ class ClientController extends AdminController // 'gst' => 18.00, // 'cd_ac_pk' => $renewalData['cd_ac_pk'], // ]; - + // $clientPolicyModel = new ClientPolicyModel(); // return $clientPolicyModel->insert($clientPolicy); // } + public function updateRenewalData() + { + $db = db_connect(); + $renewalData = $db->table('old_renewal_data_copy') + ->where('client_id IS NOT NULL') + ->where('is_inserted != 1') + ->get() + ->getResultArray(); + // dd($renewalData); + + $successData = []; + foreach ($renewalData as $key => $value) { + // Get branch_id properly + $branch = $this->clientBranchModel->where('client_id', $value['client_id'] ?? 0)->first(); + // kint::dump($branch); + $value['branch_id'] = $branch['id'] ?? null; + + // Fix vehicle_id key (previously "vehicel_id") + $value['vehicle_id'] = null; + if ($value['policy_type_id'] == 8 && !empty($value['policy_type_id'])) { + $value['vehicle_id'] = $this->prepareVehicleData($value); + } + + // Process client policy, policy transaction, and co-share details + $value['client_policy_id'] = $this->prepareClientPolicy($value); + $value['pt_id'] = $this->preparePolicyData($value); + $value['pt_co_id'] = $this->preparePtCoShareDetails($value); + + // Update is_inserted field in DB + $db->table('old_renewal_data_copy') + ->where('id', $value['id']) + ->set(['is_inserted' => 1]) + ->update(); + + $successData[] = ['id' => $value['id'], 'client' => $value['insured']]; + } + + kint::dump($successData); + } + private function preparePolicyData($renewalData) - { + { $data = [ - 'issuer' => $renewalData['issuer_type_id'], - 'client_id' => $renewalData['client_id'], + 'issuer' => $renewalData['issuer_type_id'] ?? null, + 'client_id' => $renewalData['client_id'] ?? null, 'client_branch_id' => $renewalData['branch_id'] ?? 0, - 'vehicle_id' => $renewalData['vehicel_id'], - 'insurer_id' => $renewalData['insurer_id'], + 'vehicle_id' => $renewalData['vehicel_id'] ?? null, + 'insurer_id' => $renewalData['insurer_id'] ?? null, 'insurer_branch_id' => $renewalData['insurer_branch_id'], 'tpa_id' => null, 'tpa_branch_id' => null, - 'policy_type_id' => $renewalData['policy_type_id'], + 'policy_type_id' => $renewalData['policy_type_id'] ?? null, 'client_policy_id' => $renewalData['client_policy_id'] ?? null, 'issue_type' => 1, 'source_client_policy_id' => null, - 'policy_no' => $renewalData['policy_no'], + 'policy_no' => $renewalData['policy_no'] ?? null, 'cd_ac_no' => null, 'policy_issue_date' => $renewalData['date_date_of_issue'], 'policy_start_date' => $renewalData['date_policy_start_date'], @@ -4479,8 +4482,8 @@ class ClientController extends AdminController 'dependent_count' => null, 'revenue_type' => $renewalData['revenue_type'] ?? null, 'co_share' => 0, - 'pre_payable_by' => 1, - 'bro_payable_by' => 1, + 'pre_payable_by' => 1, + 'bro_payable_by' => 1, 'tsi' => '500000', 'status' => 'completed', 'ct_status' => 0, @@ -4507,22 +4510,23 @@ class ClientController extends AdminController 'month' => '2025-02-01', 'sales_generated_by' => null, 'serviced_by' => null, - 'ct_type' => 1, + 'ct_type' => 1, 'ct_tran_id' => null, 'remarks' => null, - 'cd_ac_pk' =>$renewalData['cd_ac_pk'] ?? null, + 'cd_ac_pk' => $renewalData['cd_ac_pk'] ?? null, 'install_due_date' => null, 'policy_with_corr' => 0 ]; - + // kint::dump($data); + // dd($data); $policyTransactionModel = new PolicyTransactionModel(); $id = $policyTransactionModel->insert($data); return $id; } private function prepareVehicleData($renewalData) - { + { $vehicleData = [ 'vehicle_no' => $renewalData['veh_no'], 'type' => null, @@ -4532,14 +4536,16 @@ class ClientController extends AdminController 'old_owner' => null, 'rc' => null, ]; - + + + // dd($vehicleData); $VehicleModel = new VehicleModel(); $id = $VehicleModel->insert($vehicleData); return $id; } private function preparePtCoShareDetails($renewalData) - { + { $pt_co_share_details = [ 'pt_id' => $renewalData['pt_id'], @@ -4595,7 +4601,6 @@ class ClientController extends AdminController $PTCOShareDetailsModel = new PTCOShareDetailsModel(); $id = $PTCOShareDetailsModel->insert($pt_co_share_details); return $id; - } private function prepareClientPolicy($renewalData) 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/Controllers/TicketController.php b/app/Controllers/TicketController.php index 53ae3c5b..599ad4dd 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -462,8 +462,12 @@ class TicketController extends BaseController $mail_responce = $this->sendAutoMailTrigger($ticket_id); //send mail to the head for rejected ticket approvel - if($ticket_data['claim_status_id'] == 8){ + if($ticket_data['claim_status_id'] == 8 && $ticket_data['is_head_approved'] == 0){ $this->sendMailToTheHead($ticket_data); + }else{ + $this->myLogger->logme('error', "Head Mail can't be sent"); + $this->myLogger->logme('error', "CLAIM STATUS ID : {data}", ['data' => $ticket_data['claim_status_id']]); + $this->myLogger->logme('error', "IS HEAD APPROVED : {data}", ['data' => $ticket_data['is_head_approved']]); } return $this->respond(['status' => true, 'code' => 200, 'data' => $ticket_data, "message" => "Claim updated successfully", 'mail_responce' => $mail_responce], 200); 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 @@ + + +