diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5d329830..2df2ba04 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -340,6 +340,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1'); $routes->get('transformMailContent', 'LeadsController::transformMailContent'); $routes->get('getCDAmount', 'ClientController::getCDAmount'); + $routes->get('getTheEmpDataForClaim/(:any)', 'ClientController::getTheEmpDataForClaim/$1'); + $routes->get('getTheEmpDataForClaimSearchByMobile/(:any)', 'ClientController::getTheEmpDataForClaimSearchByMobile/$1'); }); $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { @@ -430,9 +432,14 @@ $routes->post("/employeeRest/verifyEmployeeEmailId", "RestAuthenticationControll $routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber"); $routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData"); +// Test initiate Claim +$routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); + $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->post("logined", "RestAuthenticationController::logined"); $routes->post("getId", "RestAuthenticationController::getUserIdFromToken"); + $routes->post('initiateClaim',"EmployeeRestController::initiateClaim"); + }); $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy"); @@ -475,6 +482,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); $routes->get("getFEContent", "EmployeeRestController::getFEContent"); $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); + // $routes->post('postDataForTicket',"EmployeeRestController::postDataForTicket"); }); $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy"); $routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification"); @@ -489,9 +497,10 @@ $routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrol //BDSReports $routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) { - $routes->match( ['get', 'post'], 'irba_report','BDSReportController::irba_report'); + $routes->match( ['get', 'post'], 'irba_report','BDSReportController::irba_report'); $routes->get('insurer_wise_data/(:any)','BDSReportController::Insurer_wise_Data/$1'); $routes->get('bap_wise_data/(:any)','BDSReportController::Bap_Wise_Data/$1'); + $routes->match( ['get', 'post'], 'renewal_report','BDSReportController::renewalReport'); }); @@ -500,8 +509,12 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->match( ['get', 'post'], 'list','TicketController::ticketList'); $routes->get('new/(:any)','TicketController::ticket_form/$1'); $routes->post('create','TicketController::createTicket'); - $routes->get('update','TicketController::updateTicket'); + $routes->post('update','TicketController::updateTicket'); $routes->get('view/(:any)','TicketController::view_ticket/$1'); - $routes->get('mail_template','TicketController::createMailTemplate'); + $routes->get('mail_template','TicketController::mailTemplate'); + $routes->post('crud_mail_template/(:any)','TicketController::crudTemplate/$1'); + $routes->post('note/(:any)','TicketController::crudNote/$1'); + $routes->post('reply','TicketController::saveReply'); +// $routes->post('ticket_messages','TicketController::getTicketMessage'); }); diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 59fd54e1..67634315 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -47,6 +47,39 @@ class BDSReportController extends AdminController $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->policyTypeModel = new PolicyTypeModel(); } + + // public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate) + // { + + // $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); + // $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); + // try { + // $sql = " + // select ins.id,ins.name as insurers, + // COALESCE(SUM(CASE WHEN pt.action_type = 'inception' and pt.insurer_id = ins.id and ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies, + // COALESCE(SUM(CASE WHEN ptp.policy_category = $insurerCategory and pt_co.insurer_id = ins.id THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS Premium, + // COALESCE(SUM(CASE WHEN stmt.co_share_id = pt_co.id and ptp.policy_category = $insurerCategory and pt_co.insurer_id = ins.id THEN stmt.reward + stmt.actual_bp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.actual_tp_brokerage_amt ELSE 0 END), 0) AS Revenue, + // COALESCE(SUM(CASE WHEN ptp.policy_category = $insurerCategory and pt_co.insurer_id = ins.id THEN pt_co.exp_amt ELSE 0 END), 0) AS Expected_amt + // from insurers ins + // left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 + // left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 + // left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate' + // left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory and ptp.is_active = 1 + // where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null) + // group by ins.id + // "; + + // $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); + // // log_message('error',$this->insurerModel->getLastQuery()); + // // log_message('error',json_encode($data)); + // } catch (\Exception $e) { + // $data['message'] = 'No data Found'; + // $this->myLogger->logme('error', $e->getMessage()); + // return $data; + // } + // return ($data); + // } + public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate) { @@ -54,18 +87,28 @@ class BDSReportController extends AdminController $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); try { $sql = " - select ins.id,ins.name as insurers, - COALESCE(SUM(CASE WHEN pt.action_type = 'inception' and pt.insurer_id = ins.id and ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies, - COALESCE(SUM(CASE WHEN stmt.co_share_id = pt_co.id and ptp.policy_category = $insurerCategory and pt_co.insurer_id = ins.id THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS Premium, - COALESCE(SUM(CASE WHEN stmt.co_share_id = pt_co.id and ptp.policy_category = $insurerCategory and pt_co.insurer_id = ins.id THEN stmt.reward + stmt.actual_bp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.actual_tp_brokerage_amt ELSE 0 END), 0) AS Revenue - from insurers ins - left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 - left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 - left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate' - left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory and ptp.is_active = 1 - where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null) - group by ins.id - "; + SELECT + ins.id, + ins.name AS insurers, + COALESCE(SUM(CASE WHEN pt.action_type = 'inception' AND pt.insurer_id = ins.id AND ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies, + COALESCE(SUM(CASE WHEN ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS Premium, + COALESCE(SUM(CASE WHEN stmt.co_share_id = pt_co.id AND ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN stmt.reward + stmt.actual_bp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.actual_tp_brokerage_amt ELSE 0 END), 0) AS Revenue, + COALESCE(SUM(CASE WHEN ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN pt_co.exp_amt ELSE 0 END), 0) AS Expected_amt + FROM + insurers ins + LEFT JOIN + pt_co_share_details pt_co ON ins.id = pt_co.insurer_id AND pt_co.is_active = 1 + LEFT JOIN + co_share_stmt_details stmt ON pt_co.id = stmt.co_share_id AND stmt.is_active = 1 + LEFT JOIN + policy_transaction pt ON pt_co.pt_id = pt.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + LEFT JOIN + policy_type ptp ON pt.policy_type_id = ptp.id AND ptp.policy_category = $insurerCategory AND ptp.is_active = 1 + WHERE + ins.is_active = 1 AND (ptp.policy_category = $insurerCategory OR ptp.policy_category IS NULL) + GROUP BY + ins.id; + "; $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); // log_message('error',$this->insurerModel->getLastQuery()); @@ -88,12 +131,13 @@ class BDSReportController extends AdminController SELECT pot.bap AS bap, COALESCE(COUNT(DISTINCT pt.id), 0) AS Policies, - COALESCE(SUM(co.actual_bp_amt + co.actual_tep_amt + co.actual_tp_amt), 0) AS Premium, - COALESCE(SUM(co.reward + co.actual_bp_brokerage_amt + co.actual_tep_brokerage_amt + co.actual_tp_brokerage_amt), 0) AS Revenue + COALESCE(SUM((pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt)), 0) AS Premium, + COALESCE(SUM(co.reward + co.actual_bp_brokerage_amt + co.actual_tep_brokerage_amt + co.actual_tp_brokerage_amt), 0) AS Revenue, + COALESCE(SUM(pt_co.exp_amt), 0) AS Expected_amt FROM policy_type AS pot LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate' - LEFT JOIN pt_co_share_details AS ptco ON pt.id = ptco.pt_id AND ptco.is_active = 1 - LEFT JOIN co_share_stmt_details AS co ON ptco.id = co.co_share_id AND co.is_active = 1 + LEFT JOIN pt_co_share_details AS pt_co ON pt.id = pt_co.pt_id AND pt_co.is_active = 1 + LEFT JOIN co_share_stmt_details AS co ON pt_co.id = co.co_share_id AND co.is_active = 1 WHERE pot.is_active = 1 AND pot.policy_category = $insurerCategory GROUP BY pot.bap; @@ -219,57 +263,68 @@ class BDSReportController extends AdminController $db = db_connect(); $builder = $db->query(" - select ins.id, ins.name as insurer_name, -- Health Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS health_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS health_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN pt_co.exp_amt ELSE 0 END), 0) AS health_exp_amt, -- Misc Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS misc_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS misc_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN pt_co.exp_amt ELSE 0 END), 0) AS misc_exp_amt, -- Motor Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS motor_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS motor_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN pt_co.exp_amt ELSE 0 END), 0) AS motor_exp_amt, -- Engineering Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS engineering_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS engineering_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN pt_co.exp_amt ELSE 0 END), 0) AS engineering_exp_amt, + -- Fire Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS fire_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS fire_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN pt_co.exp_amt ELSE 0 END), 0) AS fire_exp_amt, + -- Liability Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS liability_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS liability_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN pt_co.exp_amt ELSE 0 END), 0) AS liability_exp_amt, -- Life Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS life_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS life_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN pt_co.exp_amt ELSE 0 END), 0) AS life_exp_amt, -- Marine Cargo Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_cargo_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_cargoe_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN pt_co.exp_amt ELSE 0 END), 0) AS marine_cargo_exp_amt, + -- Marine Hull Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_hull_premium, COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN pt_co.exp_amt ELSE 0 END), 0) AS marine_hull_exp_amt, -- Grand Totals COALESCE( @@ -286,15 +341,15 @@ class BDSReportController extends AdminController ) AS total_policy_count, COALESCE( - SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + - SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + - SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + - SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + - SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + - SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + - SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+ - SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+ - SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), + SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0 ) AS total_premium, @@ -374,49 +429,49 @@ class BDSReportController extends AdminController -- Health Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS health_premium, -- Misc Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS misc_premium, -- Motor Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS motor_premium, -- Engineering Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS engineering_premium, -- Fire Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS fire_premium, -- Liability Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS liability_premium, -- Life Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS life_premium, -- Marine Cargo Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_cargo_premium, -- Marine Hull Policies COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, - COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0) AS marine_hull_premium, -- Grand Totals COALESCE(SUM(CASE WHEN pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS total_policy_count, - COALESCE(SUM(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt), 0) AS total_premium + COALESCE(SUM(pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt), 0) AS total_premium FROM clients c LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' LEFT JOIN policy_type ptp ON pt.policy_type_id = ptp.id - LEFT JOIN pt_co_share_details ptco ON ptco.pt_id = pt.id AND ptco.is_active = 1 - LEFT JOIN co_share_stmt_details stmt ON stmt.co_share_id = ptco.id AND stmt.is_active = 1 + LEFT JOIN pt_co_share_details pt_co ON pt_co.pt_id = pt.id AND pt_co.is_active = 1 + LEFT JOIN co_share_stmt_details stmt ON stmt.co_share_id = pt_co.id AND stmt.is_active = 1 WHERE c.is_active = 1 AND ptp.policy_category = $category GROUP BY c.id @@ -487,13 +542,13 @@ class BDSReportController extends AdminController COALESCE(( select - sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium + sum(pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) as premium from co_share_stmt_details stmt - left join pt_co_share_details ptco on stmt.co_share_id = ptco.id - left join policy_transaction pt on ptco.pt_id = pt.id + left join pt_co_share_details pt_co on stmt.co_share_id = pt_co.id + left join policy_transaction pt on pt_co.pt_id = pt.id where pt.client_id = c.id and stmt.is_active = 1 - and ptco.is_active = 1 + and pt_co.is_active = 1 and pt.is_active = 1 ), 0) as premium @@ -518,4 +573,358 @@ class BDSReportController extends AdminController return []; } } + + + // //Function for get BAP INSURE wise data for premium , policy count , revenue only + // public function getBAPInsurerData($category = 0, $start_date = null, $end_date = null) + // { + // try { + // $this->myLogger->logme('error', 'getBAPInsurerData function called'); + // $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + // $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + + // //set default last 3 months data date + // $fromDate = date('Y-m-d', strtotime('-90 days')); + // $toDate = date('Y-m-d 23:59:59'); + + // if (!empty($start_date) && !empty($end_date)) { + // $fromDate = change_date_format($start_date); + // $toDate = change_date_format($end_date); + // } + + // $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + // $db = db_connect(); + // $builder = $db->query(" + + // select ins.id, ins.name as insurer_name, + + // -- Health Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS health_revenue, + + // -- Misc Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS misc_revenue, + + + // -- Motor Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS motor_revenue, + + // -- Engineering Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS engineering_revenue, + + + // -- Fire Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS fire_revenue, + + // -- Liability Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS liability_revenue, + + + // -- Life Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS life_revenue, + + + // -- Marine Cargo Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_cargoe_revenue, + + // -- Marine Hull Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue, + + // -- Grand Totals + // COALESCE( + // SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END)+ + // SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), + // 0 + // ) AS total_policy_count, + + // COALESCE( + // SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+ + // SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+ + // SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), + // 0 + // ) AS total_premium, + + // COALESCE( + // SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) + + // SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END)+ + // SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END)+ + // SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), + // 0 + // ) AS total_revenue + + // from insurers ins + // left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 + // left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 + // left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + // left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $category + // where ins.is_active = 1 + // group by ins.id + // ORDER BY + // health_premium DESC, + // misc_premium DESC, + // motor_premium DESC, + // engineering_premium DESC, + // fire_premium DESC, + // liability_premium DESC, + // life_premium DESC, + // marine_cargo_premium DESC, + // marine_hull_premium DESC; + + // "); + + // // Get the query + // $result = $builder->getResultArray(); + // $this->myLogger->logme('error', 'Query executed successfully.'); + // // dd(db_connect()->getLastQuery(),$result); + // return $result; + // } catch (\Exception $e) { + + // // Log the exception details for debugging + // $this->myLogger->logme('error', 'Error occurred in getBAPInsurerData: {message}', ['message' => $e->getMessage()]); + // $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + // return []; + // } + // } + + // //Function for get BAP CLIENT wise data for premium , policy count , revenue only + // public function getBAPClientData($category = 0, $start_date = null, $end_date = null) + // { + + // try { + // $this->myLogger->logme('error', 'getBAPClientData function called'); + // $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + // $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + // //set default last 3 months data date + // $fromDate = date('Y-m-d', strtotime('-90 days')); + // $toDate = date('Y-m-d 23:59:59'); + + // if (!empty($start_date) && !empty($end_date)) { + // $fromDate = change_date_format($start_date); + // $toDate = change_date_format($end_date); + // } + + // $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + // $db = db_connect(); + // $builder = $db->query(" + + // SELECT + // c.id AS client_id, + // c.client_name, + + // -- Health Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS health_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS health_premium, + + // -- Misc Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS misc_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS misc_premium, + + // -- Motor Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS motor_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS motor_premium, + + // -- Engineering Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS engineering_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS engineering_premium, + + // -- Fire Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS fire_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS fire_premium, + + // -- Liability Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS liability_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS liability_premium, + + // -- Life Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS life_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS life_premium, + + // -- Marine Cargo Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_cargo_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_cargo_premium, + + // -- Marine Hull Policies + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count, + // COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium, + + // -- Grand Totals + // COALESCE(SUM(CASE WHEN pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS total_policy_count, + // COALESCE(SUM(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt), 0) AS total_premium + + // FROM clients c + // LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' + // LEFT JOIN policy_type ptp ON pt.policy_type_id = ptp.id + // LEFT JOIN pt_co_share_details ptco ON ptco.pt_id = pt.id AND ptco.is_active = 1 + // LEFT JOIN co_share_stmt_details stmt ON stmt.co_share_id = ptco.id AND stmt.is_active = 1 + // WHERE c.is_active = 1 + // AND ptp.policy_category = $category + // GROUP BY c.id + // ORDER BY + // health_premium DESC, + // misc_premium DESC, + // motor_premium DESC, + // engineering_premium DESC, + // fire_premium DESC, + // liability_premium DESC, + // life_premium DESC, + // marine_cargo_premium DESC, + // marine_hull_premium DESC + + // "); + + // // Get the query + // $result = $builder->getResultArray(); + // // dd(db_connect()->getLastQuery(),$result); + // return $result; + // } catch (\Exception $e) { + + // // Log the exception details for debugging + // $this->myLogger->logme('error', 'Error occurred in getBAPClientData: {message}', ['message' => $e->getMessage()]); + // $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + // return []; + // } + // } + + // //Function for get CLIENT wise data for premium and policy count only + // public function getClientData($category = 0, $start_date = null, $end_date = null) + // { + + // try { + + // $this->myLogger->logme('error', 'getClientData function called'); + // $this->myLogger->logme('error', 'category : {data}', ['data' => $category]); + // $this->myLogger->logme('error', 'start date : {start_date} - end date {end_date} ', ['start_date' => $start_date, 'end_date' => $end_date]); + + // //set default last 3 months data date + // $fromDate = date('Y-m-d', strtotime('-90 days')); + // $toDate = date('Y-m-d 23:59:59'); + + // if (!empty($start_date) && !empty($end_date)) { + // $fromDate = change_date_format($start_date); + // $toDate = change_date_format($end_date); + // } + + // $this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]); + + // $db = db_connect(); + // $builder = $db->query(" + + // select + // c.id as client_id, + // c.client_name, + + // ( + // select + // count(policy_transaction.id) + // from policy_transaction + // left join policy_type on policy_transaction.policy_type_id = policy_type.id + // where policy_transaction.client_id = c.id + // and policy_transaction.action_type = 'inception' + // and policy_transaction.is_active = 1 + + // ) as policy_count, + + // COALESCE(( + // select + // sum(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt) as premium + // from co_share_stmt_details stmt + // left join pt_co_share_details ptco on stmt.co_share_id = ptco.id + // left join policy_transaction pt on ptco.pt_id = pt.id + // where pt.client_id = c.id + // and stmt.is_active = 1 + // and ptco.is_active = 1 + // and pt.is_active = 1 + + // ), 0) as premium + + // from clients c + // join policy_transaction on c.id = policy_transaction.client_id AND policy_transaction.policy_issue_date >= '$fromDate' AND policy_transaction.policy_issue_date <= '$toDate' + // join policy_type on policy_transaction.policy_type_id = policy_type.id and policy_type.policy_category = $category + // where c.is_active = 1 + // group by client_name + // order by premium desc + // "); + + // // Get the query + // $result = $builder->getResultArray(); + // // dd(db_connect()->getLastQuery(),$result); + // return $result; + // } catch (\Exception $e) { + + // // Log the exception details for debugging + // $this->myLogger->logme('error', 'Error occurred in getClientData: {message}', ['message' => $e->getMessage()]); + // $this->myLogger->logme('error', 'Stack trace: {trace}', ['trace' => $e->getTraceAsString()]); + // return []; + // } + // } + + // ---------------RENEWAL REPORT----------------------------------------------------------------------------------- + + + public function renewalReport() + { + if ($this->request->is('get')) { + + $default_start = new \DateTime(); + $data['default_end'] = $default_start->format('d-m-Y'); + $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); + $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['page_name'] = "Renewal Report"; + return $this->loadLayout('renewal_search', $data); + + } else { + + $fromDate = $this->request->getPost('fromDate'); + $toDate = $this->request->getPost('toDate'); + $client_id = $this->request->getPost('client_id'); + $client_type = $this->request->getPost('client_type'); + $issuer = $this->request->getPost('issuer'); + + $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; + $data['client_type'] = [1 => 'Group', 2 => 'Individual']; + $data['renewal_data'] = $this->policyTransactionModel->getRenewalReportData($fromDate, $toDate, $client_type, $client_id, $issuer); + // print_r($data); die; + $html = view('bds_renewal_report_list', $data); + return $this->respond(['status' => true, 'html' => $html], 200); + } + } } diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 38192213..308cb9e3 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -4047,10 +4047,11 @@ class ClientController extends AdminController // -----------BDS REPORT CONTROLLER--------------------------------------------------------------------------------- - // $BDSReportController = new BDSReportController(); + $BDSReportController = new BDSReportController(); - // $data['data'] = $BDSReportController->getBAPInsurerData(); - // return $this->loadLayout('irda_bap_insurer_report_list', $data); + $data['data'] = $BDSReportController->getBAPInsurerData(); + + return $this->loadLayout('irda_bap_insurer_report_list', $data); // $data['data'] = $BDSReportController->getBAPClientData(); // return $this->loadLayout('irda_bap_client_report_list', $data); @@ -4138,6 +4139,162 @@ class ClientController extends AdminController } else { return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200); } - } + } + + // -----------Function for Claim Module-------------------------------------------------------------------------------------------- + + public function getTheEmpDataForClaim($param, $type = null) + { + // Construct the base query + $data = $this->clientPolicyModel + ->select(" + clients.id AS client_id, + clients.client_name, + insurers.id AS insurer_id, + insurers.name AS insurer_name, + tpa.id AS tpa_id, + tpa.name AS tpa_name, + employees.id AS emp_id, + employees.name AS emp_name, + employees.emp_code, + employees.mobile AS emp_mobile, + employees.email_corporate AS emp_email, + employees.relationship AS emp_relationship, + employee_polices.uhid AS policy_no + ") + ->join('clients', 'client_policy.client_id = clients.id', 'left') + ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') + ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left') + ->join('employees', 'clients.id = employees.client_id', 'left') + ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left') + ->where('client_policy.is_active', 1) + ->where('insurers.is_active', 1) + ->where('tpa.is_active', 1) + ->where('employees.is_active', 1) + ->where('employees.relationship', "Self") + ->where('employee_polices.is_active', 1) + ->where('client_policy.id', $param) + ->findAll(); + + $dataForClientAndInsurer = []; + $memberData = []; + + // Respond based on the query result + if (!empty($data) || !empty($dataForClientAndInsurer)) { + return $this->respond([ + 'status' => true, + 'code' => 200, + 'message' => 'Data found', + 'data' => $data, + 'param' => $param, + 'type' => $type, + 'dataForClientAndInsurer' => $dataForClientAndInsurer, + 'memberData' => $memberData + ], 200); + } else { + return $this->respond([ + 'status' => false, + 'code' => 404, + 'message' => 'No data found', + 'param' => $param, + 'type' => $type, + 'dataForClientAndInsurer' => $dataForClientAndInsurer, + 'memberData' => $memberData + ], 404); + } + } + + public function getTheEmpDataForClaimSearchByMobile($param, $type = 'mobile') + { + $field_name = 'employees.' . $type; + + // Construct the base query + $data = $this->clientPolicyModel + ->select(" + clients.id AS client_id, + clients.client_name, + insurers.id AS insurer_id, + insurers.name AS insurer_name, + tpa.id AS tpa_id, + tpa.name AS tpa_name, + employees.id AS emp_id, + employees.name AS emp_name, + employees.emp_code, + employees.mobile AS emp_mobile, + employees.email_corporate AS emp_email, + employees.relationship AS emp_relationship, + employee_polices.uhid AS policy_no, + employee_polices.tpa_id AS tpa_no + ") + ->join('clients', 'client_policy.client_id = clients.id', 'left') + ->join('insurers', 'client_policy.insurer_id = insurers.id', 'left') + ->join('tpa', 'client_policy.tpa_id = tpa.id', 'left') + ->join('employees', 'clients.id = employees.client_id', 'left') + ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left') + ->where('client_policy.is_active', 1) + ->where('insurers.is_active', 1) + ->where('tpa.is_active', 1) + ->where('employees.is_active', 1) + ->where('employees.relationship', "Self") + ->where('employee_polices.is_active', 1) + ->where($field_name, $param) + ->groupBy('employees.id') + ->orderBy('employees.id', 'DESC') + ->first(); + + $memberData = []; + $dataForClientAndInsurer = []; + + $acms = db_connect()->table('user_profiles') + ->select('user_profiles.id, user_profiles.first_name') + ->where('user_profiles.is_active', 1) + ->where('user_profiles.role', 3) + ->get() + ->getResultArray(); + + if(!empty($data) && count($data) > 0){ + + $memberData = $this->employeeModel->getEmployeeByEmployeeCode($data['emp_code']); + + $acms = $this->clientRMModel + ->select('user_profiles.id, user_profiles.first_name') + ->join('clients', 'client_rm.client_id = clients.id', 'left') + ->join('user_profiles', 'client_rm.user_id = user_profiles.id', 'left') + ->where('clients.is_active', 1) + ->where('client_rm.is_active', 1) + ->where('user_profiles.is_active', 1) + ->where('clients.id', $data['client_id']) + ->findAll(); + } + + + + // Respond based on the query result + if (!empty($data)) { + return $this->respond([ + 'status' => true, + 'code' => 200, + 'message' => 'Data found', + 'data' => $data, + 'param' => $param, + 'type' => $type, + 'dataForClientAndInsurer' => $dataForClientAndInsurer, + 'memberData' => $memberData, + 'acms' => $acms, + ], 200); + } else { + return $this->respond([ + 'status' => false, + 'code' => 404, + 'message' => 'No data found', + 'param' => $param, + 'type' => $type, + 'dataForClientAndInsurer' => $dataForClientAndInsurer, + 'memberData' => $memberData, + 'acms' => $acms + ], 200); + } + } + } diff --git a/app/Controllers/EmpDataServiceController.php b/app/Controllers/EmpDataServiceController.php index fa3d4378..43d26b3b 100755 --- a/app/Controllers/EmpDataServiceController.php +++ b/app/Controllers/EmpDataServiceController.php @@ -4416,7 +4416,7 @@ class EmpDataServiceController extends BaseController employees.email_corporate, employees.name, employees.mobile, - employees.basic_cover_si, + employee_polices.basic_cover_si, cp.policy_type_id, cp.is_addon, @@ -4438,7 +4438,7 @@ class EmpDataServiceController extends BaseController if ($emp_details) { $this->myLogger->logme('error', 'sendMailForDownloadingECard - Processing employee_policy_id: {id}', ['id' => $id]); - if (!empty($emp_details['email_corporate'])) { + if (!empty($emp_details['email_corporate']) && $emp_details['relationship'] === 'Self') { $params = [ 'rand_string' => $emp_details['rand_string'], diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 774d3f60..050437cd 100755 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -97,7 +97,7 @@ class EmployeeController extends AdminController // Convert the status field to an array if it exists in the request data if (isset($filterData['status']) && !empty($filterData['status'])) { - $filterData['status'] = explode(",", $filterData['status']); + // $filterData['status'] = explode(",", $filterData['status']); }else{ $filterData['status'] = []; } @@ -114,6 +114,11 @@ class EmployeeController extends AdminController // log_message('error',json_encode($data['employees'])); // Set getData in $data array with the processed $filterData $data['getData'] = $filterData; + + // return view('employee_list',$data); + $html = view('employee_data_list', $data); + return $this->respond(['status' => true, 'html' => $html], 200); + } // dd($this->employeeModel->getLastQuery()); @@ -2225,7 +2230,7 @@ class EmployeeController extends AdminController // print_rr($data);die(); // $data['dob'] = date('Y-m-d', strtotime($data['dob'])); if(isset( $data['dob'])){ - $data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d'); + $data['dob'] = change_date_format($data['dob'], null, 'Y-m-d'); } // print_rr($data); die; diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 5d24c70a..0b26b442 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -29,10 +29,15 @@ use App\Models\FEContentModel; use App\Models\AddImgModel; use App\Models\ClientBranchModel; use App\Models\AuditHistoryModel; +use App\Models\TicketClaimStatusModel; +use App\Models\TicketMasterModel; +use App\Models\TicketMessageModel; + use App\Controllers\Jobs ; use App\Controllers\JobWorker ; +use App\Controllers\TicketController; use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -73,6 +78,11 @@ class EmployeeRestController extends AdminController protected $addImgModel; protected $clientBranchModel; protected $auditHistoryModel; + protected $claimStatusModel; + protected $ticketMaster; + protected $ticketMessage; + + protected $ticketController; public function __construct() @@ -97,6 +107,11 @@ class EmployeeRestController extends AdminController $this->addImgModel = new AddImgModel(); $this->clientBranchModel = new ClientBranchModel(); $this->auditHistoryModel = new AuditHistoryModel(); + $this->claimStatusModel = new TicketClaimStatusModel(); + $this->ticketMaster = new TicketMasterModel(); + $this->ticketMessage = new TicketMessageModel(); + + $this->ticketController = new TicketController(); } @@ -722,7 +737,7 @@ class EmployeeRestController extends AdminController $jwt = $this->request->getHeaderLine('Authorization'); $jwtParts = explode(' ', $jwt); - $token = $jwtParts[2]; + $token = $jwtParts[1]; $decodedPayload = json_decode(base64_decode(explode('.', $token)[1]), true); @@ -3086,10 +3101,90 @@ class EmployeeRestController extends AdminController return false; } - + //Get Data from post for inserting ticket and message + public function initiateClaim() + { + + $received_data = $this->request->getPost(); + $employee_id = $received_data['emp_id']; + $client_policy_id = $received_data['client_policy_id']; + $insured_emp_id = $received_data['insured_emp_id']; + + $sql = "select cp.policy_type_id as ticket_type_id, + cl_rm.user_id as acm_id, + cp.insurer_id as insurer_id, + cp.tpa_id as tpa_id, + emp.client_id , + emp.id as emp_id, + emp_pol.uhid as policy_no, + emp.emp_code, + emp_pol.tpa_id as tpa_no, + emp.name as emp_name, + emp.email_corporate as emp_mail, + emp.mobile as emp_mobile, + empl.id as insured_emp_id, + empl.name as insured_name, + empl.relationship + from employees emp + + left join employees empl on empl.id = $insured_emp_id and empl.is_active = 1 and empl.emp_status = 'active' + left join employee_polices emp_pol on empl.id = emp_pol.employee_id and emp_pol.client_policy_id = $client_policy_id and emp_pol.is_active = 1 + left join client_policy cp on cp.id = emp_pol.client_policy_id and cp.is_active = 1 + left join client_rm cl_rm on cl_rm.client_id = empl.client_id and cl_rm.is_active = 1 and cl_rm.level = 3 + + where emp.id = $employee_id and emp.is_active = 1 and emp.emp_status = 'active' + limit 1 "; + + $fetchData = $this->employeeModel->query($sql)->getResultArray()[0]; + $fetchData['claim_status_id'] = $this->claimStatusModel->select('id')->where('ticket_type', $fetchData['ticket_type_id'])->first()['id']; + $fetchData['priority'] = 1; + $fetchData['mode_of_intimation'] = 1; + $fetchData['hospital_name'] = $received_data['hospital_name']; + + $insert_status = $this->ticketMaster->insert($fetchData); + $ticket_id = $this->ticketMaster->insertID(); + + if ($insert_status && !empty($ticket_id)) { + $mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id)); + if (gettype($mail_sent_status) == 'array') { + $message = 'Claim Iniated Successfully'; + return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200); + } else { + $mail_sent_status = json_decode($mail_sent_status); + } + // dd(gettype($mail_sent_status)); + + if ($mail_sent_status->status == 'success') { + $sent_message_data['ticket_id'] = $ticket_id; + $sent_message_data['sender'] = 'staff'; + $sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail; + $sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject; + $sent_message_data['mail_content'] = $mail_sent_status->data->params->message; + + $message_insert_status = $this->ticketMessage->insert($sent_message_data); + + if ($message_insert_status) { + $message = 'Claim Initiated Successfully'; + return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200); + } else { + $message = 'Claim Initiated, Mail Sent Successfully'; + $this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, Failed to store message:$ticket_id "); + return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); + } + } else { + + $message = 'Claim Initiated, Failed to send Mail '; + $this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id "); + return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); + } + } else { + $message = 'Something Went Wrong'; + return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); + } + } } \ No newline at end of file diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index ee066699..9cf89d53 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1669,11 +1669,12 @@ class MasterController extends AdminController ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] ]; - $email_id = 'hariharan@nhanceindia.in'; + $email_id = 'srinivas.saravanan@venbainfotech.com'; + $params = ['mail'=>$email_id]; $common = ['mail_type'=>'test_mail_cli']; - $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com"; + // $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com"; // Send email and get response - $result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI','bcc'=>$bcc ,'message' => $message,'attachments' => $attachments,'common'=>$common]); + $result = MailHelper::send_email(['mail' => $email_id, 'params'=>$params,'subject' => 'Mail Via CLI','message' => $message,'attachments' => $attachments,'common'=>$common]); log_message('error',json_encode($result)); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index c1cbd7d4..69852bca 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -244,34 +244,6 @@ class PolicyTransactionController extends BaseController // print_r($data); die; // var_dump($data); die; - // Format dates - // $data['policy_issue_date'] = change_date_format($this->request->getPost('policy_issue_date'), 'd/m/Y', 'Y-m-d') ?? null; - // $data['policy_start_date'] = change_date_format($this->request->getPost('policy_start_date'), 'd/m/Y', 'Y-m-d') ?? null; - // $data['policy_end_date'] = change_date_format($this->request->getPost('policy_end_date'), 'd/m/Y', 'Y-m-d') ?? null; - // $data['renewal_date'] = change_date_format($this->request->getPost('renewal_date'), 'd/m/Y', 'Y-m-d') ?? null; - // $data['rollover_date'] = change_date_format($this->request->getPost('rollover_date'), 'd/m/Y', 'Y-m-d') ?? null; - - // $data['policy_issue_date'] = (isset($data['policy_issue_date']) && $data['policy_issue_date'] !== null && $data['policy_issue_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_issue_date'])) - // : null; - - // $data['policy_start_date'] = (isset($data['policy_start_date']) && $data['policy_start_date'] !== null && $data['policy_start_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_start_date'])) - // : null; - - // $data['policy_end_date'] = (isset($data['policy_end_date']) && $data['policy_end_date'] !== null && $data['policy_end_date'] !== '') - // ? date('d/m/Y', strtotime($data['policy_end_date'])) - // : null; - - // $data['renewal_date'] = (isset($data['renewal_date']) && $data['renewal_date'] !== null && $data['renewal_date'] !== '') - // ? date('d/m/Y', strtotime($data['renewal_date'])) - // : null; - - // $data['rollover_date'] = (isset($data['rollover_date']) && $data['rollover_date'] !== null && $data['rollover_date'] !== '') - // ? date('d/m/Y', strtotime($data['rollover_date'])) - // : null; - - if(empty($data['policy_issue_date'])){ $data['policy_issue_date'] = null; } @@ -302,7 +274,7 @@ class PolicyTransactionController extends BaseController // Separate Insurer and TPA Branch IDs and IDs if(isset($data['insurer_id']) && !empty($data['insurer_id'])){ list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']); - if ($data['tpa']) { + if (isset($data['tpa'])) { list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']); } } diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php index c489e247..92c19dc7 100644 --- a/app/Controllers/TicketController.php +++ b/app/Controllers/TicketController.php @@ -11,13 +11,18 @@ use App\Models\TicketHistoryModel; use App\Models\TicketMailTemplateModel; use App\Models\TicketMessageModel; use App\Models\TicketNoteModel; +use App\Models\UserModel; +use DOMDocument; use Psr\Log\LoggerInterface; use Kint\Kint; +use App\Models\EmployeeModel; + +use App\Helpers\MailHelper; use CodeIgniter\API\ResponseTrait; class TicketController extends BaseController -{ +{ use ResponseTrait; protected $myLogger; @@ -27,13 +32,17 @@ class TicketController extends BaseController protected $modeOFIntimate; protected $claimType; protected $claimStatus; - + protected $placeHolders; + protected $clientModel; protected $ticketMasterModel; protected $ticketHistoryModel; protected $ticketMailTemplateModel; - protected $ticketMesageModel; + protected $ticketMessageModel; protected $ticketNoteModel; + protected $triggerType; + protected $userModel; + protected $employeeModel; public function __construct() { @@ -43,11 +52,11 @@ class TicketController extends BaseController $this->ticketType = [1 => "Claim-GMC", 2 => "Claim-GPA", 3 => "EDLI", 4 => "GTLI"]; $this->priorityType = [ - 1 => "Low", - 2 => "Medium", - 3 => "High", - 4 => "Urgent", - 5 => "Emergency", + 1 => "Low", + 2 => "Medium", + 3 => "High", + 4 => "Urgent", + 5 => "Emergency", 6 => "Critical" ]; $this->relationshipType = [ @@ -61,9 +70,9 @@ class TicketController extends BaseController "mother-in-law" => "Mother-in-Law" ]; $this->modeOFIntimate = [ - 1 => "In Person", - 2 => "Courier", - 3 => "Online Mode - Email", + 1 => "In Person", + 2 => "Courier", + 3 => "Online Mode - Email", 4 => "Online Mode - To TPA" ]; $this->claimType = [ @@ -80,24 +89,49 @@ class TicketController extends BaseController 4 => "Death", ] ]; + $this->triggerType = [ + 1 => "Trigger 1", + 2 => "Trigger 2", + 3 => "Trigger 3", + 4 => "Trigger 4", + 5 => "Trigger 5", + 6 => "Trigger 6", + 7 => "Trigger 7" + ]; + + $this->placeHolders = [ + + '((ACM))' => 'acm', + '((ACM_CONTACT))' => 'acm_mobile', + '((EMPLOYEE_NAME))' => 'emp_name', + '((EMPLOYEE_ID))' => 'emp_code', + '((CORPORATE_NAME))' => 'client_name', + '((INSURED_NAME))' => 'insured_name', + '((CLAIM_NO))' => 'claim_number', + '((RELATIONSHIP))' => 'relationship', + ]; + $this->ticketMasterModel = new TicketMasterModel(); $this->claimStatus = new TicketClaimStatusModel(); $this->clientModel = new ClientModel(); $this->ticketHistoryModel = new TicketHistoryModel(); - + $this->ticketMailTemplateModel = new TicketMailTemplateModel(); + $this->ticketNoteModel = new TicketNoteModel(); + $this->ticketMessageModel = new TicketMessageModel(); + $this->userModel = new UserModel(); + $this->employeeModel = new EmployeeModel(); } public function ticketList() - { + { if ($this->request->is('get')) { $data['page_name'] = "Claims"; $data['ticket_type'] = $this->ticketType; - $data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active',1)->findAll(); - $data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active',1)->findAll(); - + $data['claim_status'] = $this->claimStatus->select('id,ticket_type,claim_status')->where('is_active', 1)->findAll(); + $data['client_list'] = $this->clientModel->select('id,client_name')->where('is_active', 1)->findAll(); + $data['ticket_data'] = $this->ticketSearch(1); return $this->loadLayout('ticket_search', $data); - - } else{ + } else { $data['ticket_data'] = $this->ticketSearch(); $html = view('ticket_list', $data); @@ -105,121 +139,637 @@ class TicketController extends BaseController } } - public function ticketSearch() + public function ticketSearch($action = null) { - $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; + //action 1 get last 100 rows, action 2 filter and get all rows related to that + if ($action == 1) { + $data = $this->ticketMasterModel + ->select('ticket_master.id, ticket_claim_status.claim_status as status, + ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, + insurers.name as insurer_name, clients.client_name, + DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') + ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') + ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') + ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') + ->where('ticket_master.is_active', 1) + ->orderBy('ticket_master.id', 'DESC') + ->limit(100) + ->findAll(); + + return $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; + } } - } - // print_rr($where); - $data = $this->ticketMasterModel - ->select('ticket_master.id, ticket_claim_status.claim_status as status, + // print_rr($where); + $data = $this->ticketMasterModel + ->select('ticket_master.id, ticket_claim_status.claim_status as status, ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, insurers.name as insurer_name, clients.client_name, DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') - ->join('insurers','insurers.id = ticket_master.insurer_id and insurers.is_active = 1','left') - ->join('clients','clients.id = ticket_master.client_id and clients.is_active = 1','left') - ->join('ticket_claim_status','ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1','left') - ->where('ticket_master.is_active',1) - ->where($where) - ->findAll(); - // print_rr($data); - // log_message('error',' Claims Master Data '.json_encode($data));die(); - // print_rr($data);die(); - return $data; + ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') + ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') + ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') + ->where('ticket_master.is_active', 1) + ->where($where) + ->findAll(); + // print_rr($data); + // log_message('error',' Claims Master Data '.json_encode($data));die(); + // print_rr($data);die(); + return $data; + } } public function ticket_form($ticket_type) { - $data['ticket_form'] = 1; - $data['ticket_type'] = $this->ticketType; - $data['priorityType'] = $this->priorityType; - $data['relationshipType'] = $this->relationshipType; - $data['modeOFIntimate'] = $this->modeOFIntimate; + $data = $this->ticket_form_data($ticket_type); + // dd($data); + return $this->loadLayout('ticket_form_handler', $data); + } - $data['acms'] = db_connect()->table('user_profiles') - ->select('user_profiles.id, user_profiles.first_name') - ->where('user_profiles.is_active', 1) - ->where('user_profiles.role', 3) - ->get() - ->getResultArray(); + public function ticket_form_data($ticket_type) + { + $this->myLogger->logme('error', "Fetching ticket form data for Ticket Type: $ticket_type"); - $data['claim_status'] = db_connect()->table('ticket_claim_status') - ->select('ticket_claim_status.*') - ->where('ticket_claim_status.is_active', 1) - ->where('ticket_claim_status.ticket_type', $ticket_type) - ->get() - ->getResultArray(); + $data = [ + 'ticket_form' => 1, + 'selected_ticket_type' => $ticket_type, + 'ticket_type' => $this->ticketType, + 'priorityType' => $this->priorityType, + 'relationshipType' => $this->relationshipType, + 'modeOFIntimate' => $this->modeOFIntimate + ]; - if($ticket_type == 1){ - $data['modeOFIntimate'] = $this->claimType[1]; - return $this->loadLayout('ticket_form_handler', $data); - }else{ - - $data['modeOFIntimate'] = $this->claimType[2]; - - if($ticket_type == 2){ + switch ($ticket_type) { + case 2: $data['ticket_form'] = 'GPA'; - }else if($ticket_type = 3){ - $data['ticket_form'] == 'EDLI'; - }else if($ticket_type = 4){ + break; + case 3: + $data['ticket_form'] = 'EDLI'; + break; + case 4: $data['ticket_form'] = 'GTLI'; - } - - return $this->loadLayout('ticket_form_handler', $data); + break; } + + // Fetch ACM Users + $db = db_connect(); + $data['acms'] = $db->table('user_profiles') + ->select('id, first_name') + ->where(['is_active' => 1, 'role' => 3]) + ->get() + ->getResultArray(); + + // Fetch Claim Status + $data['claim_status'] = $this->claimStatus + ->select('*') + ->where(['is_active' => 1, 'ticket_type' => $ticket_type]) + ->get() + ->getResultArray(); + + if ($ticket_type == 1) { + $data['claim_type'] = $this->claimType[1]; + } else { + $data['claim_type'] = $this->claimType[2]; + } + + $this->myLogger->logme('error', "Ticket form data fetched successfully for Ticket Type: $ticket_type"); + + return $data; } public function view_ticket($ticket_id) { - $data = []; + // $ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first(); + $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id); + $ticket_data = $this->formatDateForClaim($ticket_data, 'd/m/Y'); + // dd($ticket_data); + $template_data = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); + if(!empty($template_data)){ + $template_data['mail_content'] = $this->replacePlaceholders($template_data['mail_content'], $ticket_data); + $template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data); + } + $data = $this->ticket_form_data($ticket_data['ticket_type_id']); + $data['ticket_data'] = $ticket_data; + $data['reply_data'] = $template_data; + $data['placeHolders'] = $this->placeHolders; + $data['message_data'] = $this->getTicketMessage($ticket_id); + $data['view_ticket_page'] = []; + $data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']); + $data['ticket_history'] = $this->ticketHistory($ticket_id); + // dd($data); + return $this->loadLayout('ticket_edit_onbording', $data); } - public function createTicket() - { - $ticket_data = $this->request->getPost(); - // print_rr($ticket_data); die; + public function formatDateForClaim($ticket_data, $out_put_format = 'Y-m-d') + { - if(empty($ticket_data['doa'])){ + if (empty($ticket_data['doa'])) { $ticket_data['doa'] = null; - }else{ - $ticket_data['doa'] = change_date_format($ticket_data['doa']); + } else { + $ticket_data['doa'] = change_date_format($ticket_data['doa'], null, $out_put_format); } - if(empty($ticket_data['dod'])){ + if (empty($ticket_data['dod'])) { $ticket_data['dod'] = null; - }else{ - $ticket_data['dod'] = change_date_format($ticket_data['dod']); + } else { + $ticket_data['dod'] = change_date_format($ticket_data['dod'], null, $out_put_format); } + if (empty($ticket_data['dob'])) { + $ticket_data['dob'] = null; + } else { + $ticket_data['dob'] = change_date_format($ticket_data['dob'], null, $out_put_format); + } + + if (empty($ticket_data['date_of_join'])) { + $ticket_data['date_of_join'] = null; + } else { + $ticket_data['date_of_join'] = change_date_format($ticket_data['date_of_join'], null, $out_put_format); + } + + if (empty($ticket_data['date_of_incep'])) { + $ticket_data['date_of_incep'] = null; + } else { + $ticket_data['date_of_incep'] = change_date_format($ticket_data['date_of_incep'], null, $out_put_format); + } + + if (empty($ticket_data['date_of_accident'])) { + $ticket_data['date_of_accident'] = null; + } else { + $ticket_data['date_of_accident'] = change_date_format($ticket_data['date_of_accident'], null, $out_put_format); + } + + if (empty($ticket_data['date_of_death'])) { + $ticket_data['date_of_death'] = null; + } else { + $ticket_data['date_of_death'] = change_date_format($ticket_data['date_of_death'], null, $out_put_format); + } + + if (empty($ticket_data['date_of_intimat'])) { + $ticket_data['date_of_intimat'] = null; + } else { + $ticket_data['date_of_intimat'] = change_date_format($ticket_data['date_of_intimat'], null, $out_put_format); + } + + return $ticket_data; + } + + public function createTicket() + { + $ticket_data = $this->request->getPost(); + $ticket_data = $this->formatDateForClaim($ticket_data); // print_rr($ticket_data); die; - if($ticket_data){ - $return_value = $this->ticketMasterModel->insert($ticket_data); - if($return_value){ - return $this->respond(['status' => true, 'code' => 200, 'data' => $ticket_data, "message" => "Claim created successfully"], 200); - } else { - return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to create claim'], 200); - } - }else{ + if ($ticket_data) { + $return_value = $this->ticketMasterModel->insert($ticket_data); + if ($return_value) { + //mail trigger part + $mail_responce = $this->sendAutoMailTrigger($return_value); + return $this->respond(['status' => true, 'code' => 200, 'data' => $ticket_data, "message" => "Claim created successfully", 'mail_responce' => $mail_responce], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to create claim'], 200); + } + } else { return $this->respond(['status' => false, 'code' => 404, 'message' => 'claim data not found'], 200); } } public function updateTicket() { + $ticket_id = $this->request->getPost('ticket_master_id'); + $ticket_data = $this->request->getPost(); + $ticket_data = $this->formatDateForClaim($ticket_data); + // print_rr($ticket_data); die; + $old_ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first(); + + if ($ticket_data) { + $return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update(); + if ($return_value) { + + //mail trigger part + $mail_responce = $this->sendAutoMailTrigger($ticket_id); + + return $this->respond(['status' => true, 'code' => 200, 'data' => $ticket_data, "message" => "Claim updated successfully", 'mail_responce' => $mail_responce], 200); + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update claim'], 200); + } + } else { + return $this->respond(['status' => false, 'code' => 404, 'message' => 'claim data not found'], 200); + } } - public function createMailTemplate() + public function mailTemplate() { $data = []; + $data['trigger_type'] = $this->triggerType; + $data['policy_type'] = $this->ticketType; + $data['placeHolders'] = $this->placeHolders; + $data['ticket_data'] = $this->ticketMailTemplateModel->where('is_active', 1)->findAll(); + $data['ticket_type'] = $this->ticketType; + $data['trigger_type'] = $this->triggerType; return $this->loadLayout('ticket_mail_template', $data); } + public function crudTemplate($action) + { + //action 1 is create. action 2 is edit and action 3 is delete + if ($action == 1) { + $received_data = $this->request->getPost(); + if (isset($received_data['id']) && $received_data['id'] != '') { + $status = $this->ticketMailTemplateModel->save($received_data); + if ($status) { + return $this->respond(['status' => true], 200); + } else { + return $this->respond(['status' => false], 200); + } + } else { + $status = $this->ticketMailTemplateModel->save($received_data); + if ($status) { + return $this->respond(['status' => true], 200); + } else { + return $this->respond(['status' => false], 200); + } + } + } elseif ($action == 2) { + $table_id = (int)$this->request->getPost('id'); + $data = $this->ticketMailTemplateModel->where('id', $table_id)->where('is_active', 1)->first(); + if ($data) { + return $this->respond(['status' => true, 'data' => $data], 200); + } else { + return $this->respond(['status' => false], 404); + } + } elseif ($action == 3) { + $table_id = (int)$this->request->getPost('id'); -} \ No newline at end of file + $sql = "update ticket_mail_template set is_active = 0 where id = $table_id "; + $status = $this->ticketMailTemplateModel->query($sql); + if ($status) { + return $this->respond(['status' => true], 200); + } else { + return $this->respond(['status' => false], 404); + } + } + } + + public function crudNote($action) + { + // action = 1 is read, action 2 is insert/update + if ($action == 1) { + $ticket_master_id = $this->request->getPost('id'); + if (isset($ticket_master_id) && $ticket_master_id != '') { + $data = $this->ticketNoteModel->where('is_active', 1)->where('ticket_id', $ticket_master_id)->first(); + if ($data) { + return $this->respond(['status' => true, 'data' => $data], 200); + } else { + return $this->respond(['status' => false], 200); + } + } + } elseif ($action == 2) { + $data = $this->request->getPost(); + // if (isset($data['id']) && $data['id'] != ''){ + $status = $this->ticketNoteModel->save($data); + // } + if ($status) { + return $this->respond(['status' => true], 200); + } else { + return $this->respond(['status' => false], 200); + } + } + } + + public function saveReply() + { + + $received_data = $this->request->getPost(); + // print_r($received_data); die; + $received_data['sender'] = 'staff'; + $status = $this->ticketMessageModel->insert($received_data); + if ($status) { + $return = $this->sendReplyMessage($received_data); + return $this->respond(['status' => true, 'code' => 200, 'return' => $return], 200); + } else { + return $this->respond(['status' => false, 'code' => 404], 404); + } + } + + public function getTicketMessage($ticket_master_id) + { + // log_message('error','Function called');die(); + // $ticket_master_id = $this->request->getPost('id'); + $user_id = get_session_userid(); + $logged_user = $this->userModel->select('first_name,last_name,profile')->where('id', $user_id)->first(); + $dataToSend = []; + $dataToSend['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name']; + $dataToSend['messages'] = $this->ticketMessageModel->where('is_active', 1) + ->where('ticket_id', $ticket_master_id)->orderBy('created_at', 'DESC') + ->findAll(); + foreach ($dataToSend['messages'] as $message) { + $mail_content_converted = $this->convertHtmlToText($message['mail_content']); + $message['mail_content'] = $mail_content_converted; + } + $dataToSend['emp_name'] = $this->ticketMasterModel->select('emp_name') + ->where('id', $ticket_master_id)->where('is_active', 1) + ->first()['emp_name']; + // dd($dataToSend); + if ($dataToSend) { + return $dataToSend; + } else { + $data = []; + return $data; + } + } + + public function convertHtmlToText($html) + { + $dom = new DOMDocument(); + @$dom->loadHTML($html); + return strip_tags($dom->saveHTML()); + } + + //---- Email Trigger Part---------------------------------------------------------------------------------------------- + + public function constructMailContent($ticket_id) + { + $this->myLogger->logme('error', "Constructing mail content for Ticket ID: $ticket_id"); + + try { + // Fetch Ticket Data + $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id); + + if (!$ticket_data) { + $this->myLogger->logme('error', "No ticket data found for Ticket ID: $ticket_id"); + return null; + } + + $this->myLogger->logme('error', "Fetched ticket data: " . json_encode($ticket_data)); + + // Fetch Email Template Data + $template_data = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); + + if (!$template_data) { + $this->myLogger->logme('error', "No email template found for Claim Status ID: " . $ticket_data['claim_status_id']); + return null; + } + + $this->myLogger->logme('error', "Fetched email template: " . json_encode($template_data)); + + // Generate Email Content + $subject = $this->replacePlaceholders($template_data['subject'], $ticket_data); + $message = $this->replacePlaceholders($template_data['mail_content'], $ticket_data); + + // Validate Essential Fields + if (empty($ticket_data['emp_mail'])) { + $this->myLogger->logme('error', "Employee email is missing for Ticket ID: $ticket_id"); + return null; + } + + if (empty($subject) || empty($message)) { + $this->myLogger->logme('error', "Generated email content is empty for Ticket ID: $ticket_id"); + return null; + } + + // Construct Mail Data + $mailData = [ + 'mail' => $ticket_data['emp_mail'], + 'subject' => $subject, + 'message' => $message, + 'cc' => $ticket_data['common_mails'] ?? '', + 'attachments' => [] + ]; + + $this->myLogger->logme('error', "Final Email Data"); + + return $mailData; + } catch (\Exception $e) { + $this->myLogger->logme('error', "Exception in constructMailContent: " . $e->getMessage()); + return null; + } + } + + public function replacePlaceholders($content, $ticket_data) + { + $this->myLogger->logme('error', "Replacing placeholders in content"); + + if (!empty($ticket_data) && !empty($content)) { + foreach ($this->placeHolders as $key => $value) { + $replaceData = strtoupper($ticket_data[$value]) ?? ''; + if ($value == "emp_code") { + $replaceData = $ticket_data[$value] ?? ''; + } + $content = str_replace($key, $replaceData, $content); + } + } + + $this->myLogger->logme('error', "Final content after placeholder replacement"); + + return $content; + } + + //mail send function + public function sendTrigger($mail_content) + { + $this->myLogger->logme('error', "Sending email with content"); + + $response = MailHelper::send_email($mail_content); + + $this->myLogger->logme('error', "Email sent response: " . json_encode($response)); + + return $response; + } + + //reply mail part + public function sendReplyMessage($mail_data) + { + $this->myLogger->logme('error', "Preparing reply email for Ticket ID: " . $mail_data['ticket_id']); + + $acm_mails = $this->ticketMasterModel->getTicketDataByTicketID($mail_data['ticket_id']); + + if (!$acm_mails) { + $this->myLogger->logme('error', "No ACM mails found for Ticket ID: " . $mail_data['ticket_id']); + $this->myLogger->logme('error', "Reply mail not send"); + return false; + } + + $ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($mail_data['ticket_id']); + + if (!$ticket_data) { + $this->myLogger->logme('error', "No ticket data found for Ticket ID : " .$mail_data['ticket_id']); + $this->myLogger->logme('error', "Reply mail not send"); + return null; + } + + if(!empty($mail_data)){ + $mail_data['mail_content'] = $this->replacePlaceholders($mail_data['mail_content'], $ticket_data); + $mail_data['mail_subject'] = $this->replacePlaceholders($mail_data['mail_subject'], $ticket_data); + } + + $this->myLogger->logme('error', "Fetched ACM emails"); + + $emailData = [ + 'mail' => $mail_data['emp_mail'], + 'subject' => $mail_data['mail_subject'], + 'message' => $mail_data['mail_content'], + 'common' => [], + 'cc' => $acm_mails['common_mails'], + 'attachments' => [] + ]; + + $this->myLogger->logme('error', "Final Reply Email Data"); + + return $this->sendTrigger($emailData); + } + + //auto mail part + public function sendAutoMailTrigger($ticket_id) + { + $auto_mail_enable = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id); + // print_rr($auto_mail_enable); + $mail_responce = []; + if (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 1) { + $mail_content = $this->constructMailContent($ticket_id); + $mail_responce = $this->sendTrigger($mail_content); + }elseif (!empty($auto_mail_enable) && $auto_mail_enable['is_auto_mail'] == 0 ){ + $this->myLogger->logme('error','Auto Mail Not Sent, Reason: Automail Not Enabled'); + }else{ + $this->myLogger->logme('error','Auto Mail Not Sent, Reason: Mail Template Not Created'); + } + + return $mail_responce; + } + + //---- End Email Trigger Part---------------------------------------------------------------------------------------------- + + + public function ticketHistory($ticket_id) + { + $sql = "SELECT + th.id, + th.field_name, + th.display_name, + th.old_value, + th.new_value, + th.created_at, + CONCAT(creator.first_name, ' ', creator.last_name) as modified_by, + -- Claim Status + old_status.claim_status as old_status_value, + new_status.claim_status as new_status_value, + + -- Account Manager + CONCAT(old_account_manager.first_name, ' ', old_account_manager.last_name) as old_account_manager, + CONCAT(new_account_manager.first_name, ' ', new_account_manager.last_name) as new_account_manager, + + -- Insured Employee ID Change + old_insured_emp.name as old_insured_id_name, + new_insured_emp.name as new_insured_id_name, + + ticket_master.ticket_type_id + + FROM + ticket_history th + + -- Join for the user who made the change + LEFT JOIN user_profiles creator + ON th.created_by = creator.id + + -- Status value lookups + LEFT JOIN ticket_claim_status old_status + ON th.field_name = 'claim_status_id' + AND th.old_value = old_status.id + AND old_status.is_active = 1 + + LEFT JOIN ticket_claim_status new_status + ON th.field_name = 'claim_status_id' + AND th.new_value = new_status.id + + LEFT JOIN user_profiles as old_account_manager + ON th.field_name = 'acm_id' + AND th.old_value = old_account_manager.id + + LEFT JOIN user_profiles as new_account_manager + ON th.field_name = 'acm_id' + AND th.new_value = new_account_manager.id + + LEFT JOIN employees as old_insured_emp + ON th.field_name = 'insured_emp_id' + AND th.old_value = old_insured_emp.id + + LEFT JOIN employees as new_insured_emp + ON th.field_name = 'insured_emp_id' + AND th.new_value = new_insured_emp.id + + LEFT JOIN ticket_master as ticket_master + on th.field_name = 'claim_type' + AND th.ticket_id = ticket_master.id + + + + WHERE + th.ticket_id = $ticket_id + AND th.is_active = 1 + ORDER BY + th.created_at DESC"; + $data = $this->ticketHistoryModel->query($sql)->getResultArray(); + $priorityType = $this->priorityType; + $relationshipType = $this->relationshipType; + $modeOFIntimate = $this->modeOFIntimate; + $claim_type = $this->claimType; + foreach ($data as &$row) { + if ($row['field_name'] == 'claim_status_id') { + $new_old_value = isset($row['old_status_value']) ? $row['old_status_value'] : '-'; + $new_new_value = $row['new_status_value']; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'acm_id') { + $new_old_value = isset($row['old_account_manager']) ? $row['old_account_manager'] : '-'; + $new_new_value = $row['new_account_manager']; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'insured_emp_id') { + $new_old_value = isset($row['old_insured_id_name']) ? $row['old_insured_id_name'] : '-'; + $new_new_value = $row['new_insured_id_name']; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'priority') { + $new_old_value = isset($priorityType[$row['old_value']]) ? $priorityType[$row['old_value']] : '-'; + $new_new_value = isset($priorityType[$row['new_value']]) ? $priorityType[$row['new_value']] : '-'; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'relationship') { + $new_old_value = isset($relationshipType[$row['old_value']]) ? $relationshipType[$row['old_value']] : '-'; + $new_new_value = isset($relationshipType[$row['new_value']]) ? $relationshipType[$row['new_value']] : '-'; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'mode_of_intimation') { + $new_old_value = isset($modeOFIntimate[$row['old_value']]) ? $modeOFIntimate[$row['old_value']] : "-"; + $new_new_value = isset($modeOFIntimate[$row['old_value']]) ? $modeOFIntimate[$row['old_value']] : "-"; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'claim_type') { + $new_old_value = isset($claim_type[$row['ticket_type_id']][$row['old_value']]) ? $claim_type[$row['ticket_type_id']][$row['old_value']] : '-'; + $new_new_value = isset($claim_type[$row['ticket_type_id']][$row['new_value']])?$claim_type[$row['ticket_type_id']][$row['new_value']]:'-'; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } elseif ($row['field_name'] == 'claim_type') { + $new_old_value = isset($claim_type[$row['old_value']]) ? $claim_type[$row['old_value']] : '-'; + $new_new_value = isset($claim_type[$row['new_value']]) ? $claim_type[$row['new_value']] : '-'; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + } else { + $new_old_value = isset($row['old_value']) ? $row['old_value'] : '-'; + $new_new_value = isset($row['new_value']) ? $row['new_value'] : '-'; + $row['old_value'] = $new_old_value; + $row['new_value'] = $new_new_value; + + } + } + + return ($data); + } +} diff --git a/app/Helpers/GmailResponseHandler.php b/app/Helpers/GmailResponseHandler.php index 4a45f65c..8ff0ed35 100644 --- a/app/Helpers/GmailResponseHandler.php +++ b/app/Helpers/GmailResponseHandler.php @@ -56,11 +56,12 @@ class GmailResponseHandler{ // 'employee_id' => isset($params['params']['common']['employee_id']) ? $params['params']['common']['employee_id'] : null, // 'mail_type' => isset($params['params']['common']['mail_type']) ? $params['params']['common']['mail_type'] : null, // 'gmail_api_status' => isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null, - // 'gmail_api_id' => isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null + // 'gmail_api_id' => isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null, + // 'received_message' => isset($params['gmail_api']['data']['labelIds'])?json_encode($params['gmail_api']['data']['labelIds']): null // ]; // Initialize data array $data = []; - // print_r($params['params']['common']);die(); + // // print_r($params['params']['common']);die(); if (isset($params['params']['common'])) { foreach ($params['params']['common'] as $key => $value) { $data[$key] = isset($value) ? $value : null; diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index a5af0834..3ecb7932 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -113,7 +113,7 @@ class sendMailNotification $subject = $cleanedText; - $link = generate_download_link($rand_string); + $link = generate_download_link($rand_string).'/1'; $app_link = $_ENV['App_Url']; $name = $get_emp_email_and_other_details['name']; diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php index 669a6dd6..6571a34e 100755 --- a/app/Models/EmployeeModel.php +++ b/app/Models/EmployeeModel.php @@ -240,4 +240,25 @@ class EmployeeModel extends Model return $results; } + public function getEmployeeByEmployeeCode($emp_code) + { + return $this->select(" + employees.id AS emp_id, + employees.name AS emp_name, + employees.emp_code, + employees.mobile AS emp_mobile, + employees.email_corporate AS emp_email, + employees.relationship AS emp_relationship, + employee_polices.uhid AS policy_no, + employee_polices.tpa_id AS tpa_no + ") + ->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left') + ->where('employees.is_active', 1) + ->where('employee_polices.is_active', 1) + ->where('employees.emp_code', $emp_code) + ->groupBy('employees.id') + ->findAll(); + } + } + diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 112bd2e5..246609cd 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -1201,5 +1201,62 @@ class PolicyTransactionModel extends Model return $builder->get()->getResultArray(); } + + + //function for fetch renewal report data + public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null) + { + $fromDate = date('Y-m-d', strtotime('-60 days')); + $toDate = date('Y-m-d 23:59:59'); + + if (!empty($start_date) && !empty($end_date)) { + $fromDate = change_date_format($start_date); + $toDate = change_date_format($end_date); + } + + $query = $this->db->table('policy_transaction pt') + ->select(' + pt.*, + c.client_name, + c.short_name AS client_short_name, + c.client_type, + policy_type.policy_type, + i.name as insurer_name, + ib.branch_name as insurer_branch_name, + vehicle.vehicle_no, + leads.status as lead_status + ') + ->join('clients c', 'pt.client_id = c.id', 'left') + ->join('pt_co_share_details pt_co', 'pt.id = pt_co.pt_id and pt_co.co_share_type = 1', 'left') + ->join('insurers i', 'pt_co.insurer_id = i.id', 'left') + ->join('insurer_branch ib', 'pt_co.insurer_branch_id = ib.id', 'left') + ->join('policy_type', 'pt.policy_type_id = policy_type.id', 'left') + ->join('vehicle', 'pt.vehicle_id = vehicle.id and vehicle.is_active = 1', 'left') + ->join('leads', 'pt.client_policy_id = leads.source_policy_id and leads.source_policy_id != 0 and leads.is_active = 1', 'left') + ->where('pt.policy_end_date >=', $fromDate) + ->where('pt.policy_end_date <=', $toDate) + ->where('pt.is_active', 1) + ->where('pt_co.is_active', 1) + ->where('pt.action_type', "inception"); + + // Apply filters if parameters are provided + if (!empty($client_type)) { + $query->where('c.client_type', $client_type); + } + if (!empty($client)) { + $query->where('pt.client_id', $client); + } + if (!empty($issuer)) { // Corrected condition to check $issuer + $query->where('pt.issuer', $issuer); + } + + $query->groupBy('pt.id'); + $query->orderBy('pt.id', 'DESC'); + // Fetch and return results + $results = $query->get()->getResultArray(); + // print($this->db->getLastQuery()); die; + return $results; + } + } diff --git a/app/Models/TicketClaimStatusModel.php b/app/Models/TicketClaimStatusModel.php index bc40b394..99078a03 100644 --- a/app/Models/TicketClaimStatusModel.php +++ b/app/Models/TicketClaimStatusModel.php @@ -46,4 +46,6 @@ class TicketClaimStatusModel extends Model return $data; } + + } diff --git a/app/Models/TicketHistoryModel.php b/app/Models/TicketHistoryModel.php index 6337be4b..6d7eb0f5 100644 --- a/app/Models/TicketHistoryModel.php +++ b/app/Models/TicketHistoryModel.php @@ -12,7 +12,8 @@ class TicketHistoryModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = []; + protected $allowedFields = ['id','field_name','display_name','old_value', + 'new_value','created_by','created_at','updated_by','updated_at','is_active']; // Callbacks protected $allowCallbacks = true; diff --git a/app/Models/TicketMailTemplateModel.php b/app/Models/TicketMailTemplateModel.php index 609338bb..e1059e8b 100644 --- a/app/Models/TicketMailTemplateModel.php +++ b/app/Models/TicketMailTemplateModel.php @@ -12,7 +12,7 @@ class TicketMailTemplateModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = []; + protected $allowedFields = ['id','template_name','subject','ticket_type','is_auto_mail','trigger_type','mail_content']; // Callbacks protected $allowCallbacks = true; diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 51896dbc..28b3215f 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -48,7 +48,9 @@ class TicketMasterModel extends Model 'date_of_intimat', 'si_amt', 'is_active', - 'claim_number' + 'claim_number', + 'emp_id', + 'insured_emp_id', ]; @@ -84,4 +86,63 @@ class TicketMasterModel extends Model return $data; } + + public function getTemplateDataByStatusID($claim_status_id) + { + + $template_data = $this->table('ticket_claim_status') + ->select('ticket_mail_template.*') + ->join('ticket_mail_template', 'ticket_mail_template.trigger_type = ticket_claim_status.trigger_type') + ->where('ticket_mail_template.is_active', 1) + ->where('ticket_claim_status.is_active', 1) + ->where('ticket_claim_status.id', $claim_status_id) + ->get() + ->getResultArray(); + + return $template_data; + } + + public function getTemplateDataByTicketID($ticket_id) + { + $template_data = $this + ->select("ticket_mail_template.*, ticket_master.emp_mail") + ->join('ticket_claim_status', 'ticket_master.claim_status_id = ticket_claim_status.id and ticket_claim_status.is_active = 1') + ->join('ticket_mail_template', ' + ticket_claim_status.trigger_type = ticket_mail_template.trigger_type + and ticket_claim_status.ticket_type = ticket_mail_template.ticket_type + and ticket_mail_template.is_active = 1') + ->where('ticket_master.id', $ticket_id) + ->where('ticket_master.is_active', 1) + ->first(); + + return $template_data; + } + + public function getTicketDataByTicketID($ticket_id) + { + $ticket_data = $this->select(" + ticket_master.*, + + user_profiles.first_name as acm, + user_profiles.mobile as acm_mobile, + user_profiles.email as acm_email, + + clients.common_mails, + clients.client_name, + + insurers.name as insurer_name, + tpa.name as tpa_name + ") + ->join('clients', 'ticket_master.client_id = clients.id', 'left') + ->join('insurers', 'ticket_master.insurer_id = insurers.id', 'left') + ->join('tpa', 'ticket_master.tpa_id = tpa.id', 'left') + ->join('user_profiles', 'ticket_master.acm_id = user_profiles.id', 'left') + ->where('ticket_master.id', $ticket_id) + ->where('ticket_master.is_active', 1) + ->first(); + + return $ticket_data; + } + + } diff --git a/app/Models/TicketMessageModel.php b/app/Models/TicketMessageModel.php index 22044b2f..37de2edb 100644 --- a/app/Models/TicketMessageModel.php +++ b/app/Models/TicketMessageModel.php @@ -12,7 +12,7 @@ class TicketMessageModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = []; + protected $allowedFields = ['id','sender','ticket_id','mail_subject','emp_mail','mail_content','created_at']; // Callbacks diff --git a/app/Models/TicketNoteModel.php b/app/Models/TicketNoteModel.php index c9c10746..7efe2281 100644 --- a/app/Models/TicketNoteModel.php +++ b/app/Models/TicketNoteModel.php @@ -12,7 +12,7 @@ class TicketNoteModel extends Model protected $returnType = 'array'; protected $useSoftDeletes = false; protected $protectFields = true; - protected $allowedFields = ['id,created_by','updated_by','is_active']; + protected $allowedFields = ['id','ticket_id','note','created_by','updated_by','is_active']; // Callbacks protected $allowCallbacks = true; diff --git a/app/Views/bds_renewal_report_list.php b/app/Views/bds_renewal_report_list.php new file mode 100644 index 00000000..524c917f --- /dev/null +++ b/app/Views/bds_renewal_report_list.php @@ -0,0 +1,145 @@ + + +
+
+
+
+
+
+

Renewal Policy List

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + $row) { ?> + + + + + + + + + + + + + + + + + + +
+
S.No.
+
+
Renewal Month
+
+
Issuer
+
+
Policy No
+
+
Policy
+
+
Insurer Name
+
+
Insurer Branch
+
+
Insured
+
+
Client Type
+
+
Business Type
+
+
Date of Issue
+
+
Policy Start Date
+
+
Policy Expiry Date
+
+
Vehicle No
+
+
Lead Status
+
+ + + +
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/app/Views/bds_report_Insurer_wise_Data.php b/app/Views/bds_report_Insurer_wise_Data.php index 602e04e5..d97e6f18 100644 --- a/app/Views/bds_report_Insurer_wise_Data.php +++ b/app/Views/bds_report_Insurer_wise_Data.php @@ -45,7 +45,7 @@ table.dataTable tbody td { - + diff --git a/app/Views/bds_report_bap_wise_data.php b/app/Views/bds_report_bap_wise_data.php index 45585259..391e6526 100644 --- a/app/Views/bds_report_bap_wise_data.php +++ b/app/Views/bds_report_bap_wise_data.php @@ -45,7 +45,7 @@ table.dataTable tbody td { - + diff --git a/app/Views/employee_data_list.php b/app/Views/employee_data_list.php index d985fea1..9543fa85 100755 --- a/app/Views/employee_data_list.php +++ b/app/Views/employee_data_list.php @@ -160,7 +160,7 @@ View E-Card - + Send E-Card Mail diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php index 255d8278..7c35a42d 100755 --- a/app/Views/employee_list.php +++ b/app/Views/employee_list.php @@ -135,8 +135,9 @@ table.dataTable tbody td { - + +
@@ -502,24 +503,29 @@ function fetchEmpolyeeList(event) { const queryString = objectToQueryString(queryParams); const apiURL = $('#get-emp-list').attr('href') + "?" + queryString; // console.log(apiURL); - window.location.href = apiURL; + // window.location.href = apiURL; // var apiURL2 = $('#get-emp-list').attr('href'); // Get href attribute value - // console.log(apiURL); - // $.ajax({ - // url: apiURL, - // method: 'GET', - // data: queryParams, - // success: function(response) { - // // Assuming response is a JSON array - // // displayDataTables(response); - // console.log(response); - // }, - // error: function(xhr, status, error) { - // console.error('Error:', error); - // } - // }); + console.log(apiURL); + $.ajax({ + url: apiURL, + method: 'GET', + data: queryParams, + success: function(response) { + if(response.status == true){ + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + $('#employee_table_list').html(response.html); + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + } + }, + error: function(xhr, status, error) { + console.error('Error:', error); + toastr.error('Failed to fetch Data','Error'); + } + }); } diff --git a/app/Views/irba_report.php b/app/Views/irba_report.php index 497798a7..d86d4452 100644 --- a/app/Views/irba_report.php +++ b/app/Views/irba_report.php @@ -87,7 +87,8 @@ 'Last 7 Days': [moment().subtract(6, 'days'), moment()], 'Last 30 Days': [moment().subtract(29, 'days'), moment()], 'This Month': [moment().startOf('month'), moment().endOf('month')], - 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] + 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')], + 'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')] } }, cb); diff --git a/app/Views/irda_bap_client_report_list.php b/app/Views/irda_bap_client_report_list.php index 3f31a226..69414819 100644 --- a/app/Views/irda_bap_client_report_list.php +++ b/app/Views/irda_bap_client_report_list.php @@ -20,6 +20,17 @@ table.dataTable tbody td { .right-align-input { text-align: right; } + +.right-align-input:nth-child(4n+1), +.right-align-input:nth-child(4n+2) { + background-color: #f9f9f9; /* Light gray shade */ +} + +.right-align-input:nth-child(4n+3), +.right-align-input:nth-child(4n+4) { + background-color: #ffffff; /* White shade */ +} +
@@ -46,8 +57,8 @@ table.dataTable tbody td { Life Marine Cargo Misc - Motor Marine Hull + Motor Grand Total @@ -118,7 +129,6 @@ table.dataTable tbody td { - diff --git a/app/Views/irda_bap_insurer_report_list.php b/app/Views/irda_bap_insurer_report_list.php index 8ab3b8fc..116e201d 100644 --- a/app/Views/irda_bap_insurer_report_list.php +++ b/app/Views/irda_bap_insurer_report_list.php @@ -44,8 +44,8 @@ table.dataTable tbody td { Life Marine Cargo Misc - Motor Marine Hull + Motor Grand Total @@ -107,44 +107,59 @@ table.dataTable tbody td { - + - + - + - + - + - + - - + - + - + - + + + + diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index e7f6a91a..fa265d9c 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -739,6 +739,9 @@
  • IRDA Reports
  • +
  • + Renewal Reports +
  • diff --git a/app/Views/notification old.php b/app/Views/notification old.php new file mode 100644 index 00000000..ed5f8ee5 --- /dev/null +++ b/app/Views/notification old.php @@ -0,0 +1,2009 @@ + +
    + +
    +
    + +
    + + + +
    +

    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    + +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    +
    +
    + Submit +
    +
    +
    + + +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/notification.php b/app/Views/notification.php index cb738661..051d2f98 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -14,15 +14,14 @@ min-height: 600px; } -#account_maneger_summary_mail_modal .modal-dialog, -#member_review_and_summary_mail_modal .modal-dialog { +.modal-dialog { max-width: 90% !important; width: 90% !important; } /* Also ensure the modal body has proper height */ -#account_maneger_summary_mail_modal .modal-body, -#member_review_and_summary_mail_modal .modal-body { + +.modal-body { min-height: 600px; padding: 20px; } @@ -34,178 +33,178 @@
    - +
    -
    - +
    +
    -

    + ?>

    -
    +
    -
    -
    - - -
    -
    - - -
    +
    +
    + +
    - -
    -
    - - -
    -
    - - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    - -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    - - -     - Edit -
    -
    - -
    -
    - -
    -
    -
    -
    - Submit -
    +
    + +
    +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    + +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    + + +     + Edit +
    +
    + +
    +
    + +
    +
    +
    +
    + Submit +
    +
    +
    +
    @@ -217,7 +216,7 @@
    -
    +
    - - - - - + \ No newline at end of file diff --git a/app/Views/renewal_search.php b/app/Views/renewal_search.php new file mode 100644 index 00000000..341020f9 --- /dev/null +++ b/app/Views/renewal_search.php @@ -0,0 +1,236 @@ +
    +
    +
    +
    +
    + + + +
    +
    +
    + +
    +
    + +
    +   + +
    + > + > +
    + +
    + + +
    + + +
    + + +
    + +
    + + +
    + +
    +
    + +
    + Submit +
    +
    + +
    +
    +
    +
    +
    +
    + +
    + + \ No newline at end of file diff --git a/app/Views/ticket_conversation.php b/app/Views/ticket_conversation.php index 0b34ae71..e0e67c6a 100644 --- a/app/Views/ticket_conversation.php +++ b/app/Views/ticket_conversation.php @@ -1,28 +1,37 @@ +
    + +
    -
    - +
    +
    + +
    +
    + User +
    -
    RUPESH
    - User
    -
    16 December 2024 04:15 pm
    +
    format('j F Y h:i a');?>
    - Body
    -
    +

    +
    +
    @@ -30,38 +39,41 @@
    - +
    -
    - -
    -
    -
    Venkatesh HelpDesk Admin
    - Staff +
    +
    + +
    +
    + Staff +
    -
    24 January 2025 03:41 pm
    +
    format('j F Y h:i a');?>
    -

    hi how are you i am fine

    +

    -
    + +
    -
    \ No newline at end of file +
    + +
    diff --git a/app/Views/ticket_edit_onbording.php b/app/Views/ticket_edit_onbording.php index 22b50aba..02da248b 100644 --- a/app/Views/ticket_edit_onbording.php +++ b/app/Views/ticket_edit_onbording.php @@ -22,25 +22,29 @@
    + + + + \ No newline at end of file diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php index 9026b5a7..d24e22c7 100644 --- a/app/Views/ticket_form_gmc.php +++ b/app/Views/ticket_form_gmc.php @@ -1,8 +1,8 @@
    -
    " style="margin-right: 23px;"> +
    " style="margin-right: 23px;">
    - +
    @@ -15,9 +15,10 @@
    - + +
    @@ -25,11 +26,12 @@
    - + $value) { - echo ""; + $selected = (isset($ticket_data) && $ticket_data['priority'] == $key) ? 'selected' : ''; + echo ""; } } ?> @@ -53,11 +56,12 @@
    + value="" + name="policy_no" placeholder="Policy Number" >
    - - + +
    - - + +
    - - + +
    @@ -94,29 +98,29 @@ aria-hidden="true" onclick="openFetchEmpDataodal(this)">
    - +
    - - + +
    @@ -126,7 +130,8 @@ $value) { - echo ""; + $selected = (isset($ticket_data) && $ticket_data['relationship'] == $key) ? 'selected' : ''; + echo ""; } } ?> @@ -134,16 +139,16 @@
    - +
    @@ -151,11 +156,12 @@ - + $value) { - echo ""; + if (isset($claim_type) && count($claim_type)) { + foreach ($claim_type as $key => $value) { + $selected = (isset($ticket_data) && $ticket_data['claim_type'] == $key) ? 'selected' : ''; + echo ""; } } ?> @@ -180,42 +187,42 @@
    + value="" name="dod">
    - Submit +
    diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php index 87bf7052..59e3f849 100644 --- a/app/Views/ticket_form_gpa.php +++ b/app/Views/ticket_form_gpa.php @@ -8,9 +8,9 @@
    -
    " style="margin-right: 23px;"> +
    " style="margin-right: 23px;">
    - +
    @@ -23,19 +23,22 @@
    -
    -
    + + +
    - + $value) { - echo ""; + $selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : ''; + echo ""; } } ?> @@ -45,11 +48,12 @@
    - - $value) { - echo ""; - } - } - ?> - + +
    - - + + +
    + value="" + name="policy_no" readonly>
    @@ -98,7 +86,8 @@ if (isset($ticket_type) && count($ticket_type)) { foreach ($ticket_type as $key => $value) { if($key != 1){ - echo ""; + $selected = (isset($ticket_data) && $ticket_data['ticket_type_id'] == $key) ? 'selected' : ((isset($selected_ticket_type) && $selected_ticket_type == $key) ? 'selected' : ''); + echo ""; } } } @@ -107,13 +96,14 @@
    - - + $value) { - echo ""; + if (isset($claim_type) && count($claim_type)) { + foreach ($claim_type as $key => $value) { + $selected = (isset($ticket_data) && $ticket_data['claim_type'] == $key) ? 'selected' : ''; + echo ""; } } ?> @@ -121,17 +111,19 @@
    - +
    +
    @@ -140,7 +132,7 @@
    @@ -148,21 +140,21 @@
    + value="" name="dob">
    @@ -170,7 +162,7 @@
    @@ -178,14 +170,14 @@
    @@ -199,4 +191,39 @@
    -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/app/Views/ticket_form_handler.php b/app/Views/ticket_form_handler.php index 091be7c4..6e5532a3 100644 --- a/app/Views/ticket_form_handler.php +++ b/app/Views/ticket_form_handler.php @@ -43,11 +43,12 @@ @@ -58,7 +59,8 @@ if ($ticket_form == 1) {