diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b77e8f5e..ee9ad2c0 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -51,7 +51,7 @@ $routes->get('/auth/google', 'LoginController::initiateGoogleOAuth'); $routes->get('/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus'); $routes->get('download-e-card/(:any)', 'EmployeeController::generateIDCardForEmployee/$1'); $routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocument/$1'); - +$routes->get('claim-form-download/(:any)', 'TicketController::downloadClaimForm/$1'); $routes->group("/user", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "UserController::create"); @@ -404,6 +404,7 @@ $routes->group("rfq", ["filter" => "authMVC"], function ($routes) { $routes->post("create", "LeadsController::createRFQ"); $routes->post("createQCR", "LeadsController::createQCR"); $routes->get("list/(:any)", "LeadsController::viewRFQ/$1"); + $routes->get("nonEB","LeadsController::rfqNonEB"); }); @@ -530,6 +531,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) { $routes->post('note/(:any)','TicketController::crudNote/$1'); $routes->post('reply','TicketController::saveReply'); $routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports'); + $routes->post('getPolicyStartDate','TicketController::getPolicyStartDate'); + $routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID"); // $routes->post('ticket_messages','TicketController::getTicketMessage'); }); diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php index 67634315..54abf46f 100644 --- a/app/Controllers/BDSReportController.php +++ b/app/Controllers/BDSReportController.php @@ -91,7 +91,7 @@ class BDSReportController extends AdminController 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 ptp.policy_category = $insurerCategory AND pt_co.insurer_id = ins.id THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 @@ -131,7 +131,7 @@ class BDSReportController extends AdminController SELECT pot.bap AS bap, COALESCE(COUNT(DISTINCT pt.id), 0) AS Policies, - 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((pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 @@ -267,26 +267,26 @@ 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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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, @@ -294,35 +294,35 @@ class BDSReportController extends AdminController -- 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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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, @@ -341,15 +341,15 @@ class BDSReportController extends AdminController ) AS total_policy_count, 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) + - 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), + SUM(CASE WHEN ptp.bap = 'Health' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Life' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Motor' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Fire' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Engineering' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END) + + SUM(CASE WHEN ptp.bap = 'Liability' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END)+ + SUM(CASE WHEN ptp.bap = 'Misc' THEN (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END), 0 ) AS total_premium, @@ -429,43 +429,43 @@ 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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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 (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 (pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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(pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt), 0) AS total_premium + COALESCE(SUM(pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_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' @@ -542,7 +542,7 @@ class BDSReportController extends AdminController COALESCE(( select - sum(pt_co.bp_amt + pt_co.tp_amt + pt_co.tep_amt + pt_co.non_comm_per_amt) as premium + sum(pt_co.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) as premium from co_share_stmt_details stmt 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 diff --git a/app/Controllers/Chatbot/BotService.php b/app/Controllers/Chatbot/BotService.php deleted file mode 100644 index ee3b57ad..00000000 --- a/app/Controllers/Chatbot/BotService.php +++ /dev/null @@ -1,110 +0,0 @@ -reply('Welcome! Please choose an option:', [ - 'reply_markup' => json_encode([ - 'keyboard' => [ - ['Card Download'], - ['Network Hospital'], - ['Reimbursement Claim Process'], - ['Reimbursement Claim Status'], - ['New Policy'], - ['Renew Policy'] - ], - 'resize_keyboard' => true, - 'one_time_keyboard' => true - ]) - ]); - } - - public static function handleCardDownload(BotMan $bot) - { - $bot->reply('Please choose an option:', [ - 'reply_markup' => json_encode([ - 'keyboard' => [ - ['Download Card'], - ['Go Back'] - ], - 'resize_keyboard' => true, - 'one_time_keyboard' => true - ]) - ]); - } - - public static function handleNetworkHospital(BotMan $bot) - { - $bot->reply('Please choose an option:', [ - 'reply_markup' => json_encode([ - 'keyboard' => [ - ['Find Hospital'], - ['Go Back'] - ], - 'resize_keyboard' => true, - 'one_time_keyboard' => true - ]) - ]); - } - - public static function handleReimbursementClaimProcess(BotMan $bot) - { - $bot->reply('Please choose an option:', [ - 'reply_markup' => json_encode([ - 'keyboard' => [ - ['Submit Claim'], - ['Go Back'] - ], - 'resize_keyboard' => true, - 'one_time_keyboard' => true - ]) - ]); - } - - public static function handleReimbursementClaimStatus(BotMan $bot) - { - $bot->reply('Please choose an option:', [ - 'reply_markup' => json_encode([ - 'keyboard' => [ - ['Check Status'], - ['Go Back'] - ], - 'resize_keyboard' => true, - 'one_time_keyboard' => true - ]) - ]); - } - - public static function handleNewPolicy(BotMan $bot) - { - $bot->reply('Please choose an option:', [ - 'reply_markup' => json_encode([ - 'keyboard' => [ - ['Get Quote'], - ['Go Back'] - ], - 'resize_keyboard' => true, - 'one_time_keyboard' => true - ]) - ]); - } - - public static function handleRenewPolicy(BotMan $bot) - { - $bot->reply('Please choose an option:', [ - 'reply_markup' => json_encode([ - 'keyboard' => [ - ['Renew Now'], - ['Go Back'] - ], - 'resize_keyboard' => true, - 'one_time_keyboard' => true - ]) - ]); - } -} \ No newline at end of file diff --git a/app/Controllers/Chatbot/ClaimHandler.php b/app/Controllers/Chatbot/ClaimHandler.php deleted file mode 100644 index b1839734..00000000 --- a/app/Controllers/Chatbot/ClaimHandler.php +++ /dev/null @@ -1,34 +0,0 @@ - "Reimbursement Claim Process: Here is a dummy response.", - 'reimbursement_claim_status' => "Reimbursement Claim Status: Here is a dummy response." - ]; - - if (isset($responses[$option])) { - $bot->reply($responses[$option]); - } else { - $bot->reply("Unknown claim option."); - } - - // Send Back Button - self::sendBackButton($bot); - } - - private static function sendBackButton(BotMan $bot) - { - $bot->reply(ButtonTemplate::create("Would you like to return?") - ->addButton(ElementButton::create("Go Back")->type('postback')->payload("main_menu")) - ); - } -} diff --git a/app/Controllers/Chatbot/LoginToContiueConversation.php b/app/Controllers/Chatbot/LoginToContiueConversation.php new file mode 100644 index 00000000..74a28a6c --- /dev/null +++ b/app/Controllers/Chatbot/LoginToContiueConversation.php @@ -0,0 +1,26 @@ +bot->userStorage()->delete(); + $this->bot->types(); // Typing indicator for the first message + sleep(0.5); // Delay + $this->showLoginMessage(); + } + + protected function showLoginMessage() + { + $this->say("Kindly Login to use the chatbot"); + } +} diff --git a/app/Controllers/Chatbot/PolicyHandler.php b/app/Controllers/Chatbot/PolicyHandler.php deleted file mode 100644 index 9491ef9d..00000000 --- a/app/Controllers/Chatbot/PolicyHandler.php +++ /dev/null @@ -1,36 +0,0 @@ - "Ecard Download: Here is a dummy response.", - 'network_hospital' => "Network Hospital: Here is a dummy response.", - 'new_policy' => "New Policy: Here is a dummy response.", - 'renew_policy' => "Renew Policy: Here is a dummy response." - ]; - - if (isset($responses[$option])) { - $bot->reply($responses[$option]); - } else { - $bot->reply("Unknown policy option."); - } - - // Send Back Button - self::sendBackButton($bot); - } - - private static function sendBackButton(BotMan $bot) - { - $bot->reply(ButtonTemplate::create("Would you like to return?") - ->addButton(ElementButton::create("Go Back")->type('postback')->payload("main_menu")) - ); - } -} diff --git a/app/Controllers/Chatbot/TypingMiddleware.php b/app/Controllers/Chatbot/TypingMiddleware.php deleted file mode 100644 index 047d246b..00000000 --- a/app/Controllers/Chatbot/TypingMiddleware.php +++ /dev/null @@ -1,27 +0,0 @@ -myLogger = \Config\Services::mylogger(); - $this->myLogger->logme('error', 'MIDDLEWARE'); - - // Simulate typing indicator - $bot->types(); - sleep(0.1); // Cap delay at 5 seconds (convert to microseconds) - // Proceed to the next middleware or response - return $next($bot); - } -} diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index b68a9581..610f2bda 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -2,6 +2,7 @@ namespace App\Controllers; +use App\Controllers\Chatbot\LoginToContiueConversation; use BotMan\BotMan\BotMan; use BotMan\BotMan\BotManFactory; use BotMan\BotMan\Drivers\DriverManager; @@ -19,6 +20,7 @@ class ChatbotControllerNew extends BaseController protected $myLogger; protected $session; protected $botman; + protected $isMemberLoggedIn; public function __construct() { @@ -90,6 +92,12 @@ class ChatbotControllerNew extends BaseController // $this->myLogger->logme('error', ('TEST' . $id)); $this->session->set('CHATBOT_RANDOM_USER_ID', $id); } + + $this->isMemberLoggedIn = false; + $chat_session_info = get_chatbot_session_info(); + if (!empty($chat_session_info['emp_id']) && !empty($chat_session_info['emp_code'] )){ + $this->isMemberLoggedIn = true; + } $this->botman->hears('.*', function ($bot) { @@ -98,8 +106,13 @@ class ChatbotControllerNew extends BaseController }); // Start the Main Menu when user says "hi" or "start" $this->botman->hears('start|hi|hello', function (BotMan $bot) { - $bot->reply('Hi how can i assist?'); - $bot->startConversation(new MainMenuConversation()); + if ($this->isMemberLoggedIn){ + $bot->reply('Hi how can i assist?'); + $bot->startConversation(new MainMenuConversation()); + }else { + $bot->startConversation(new LoginToContiueConversation()); + } + }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 15533b25..ca43f2d2 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -3679,7 +3679,10 @@ class ClientController extends AdminController { // ---------for client----------------------------------------------------------------------------- - $clients = $this->clientModel->where('is_active', 1)->findAll(); + $clients = $this->clientModel + ->select("*, DATE_FORMAT(dob, '%d-%m-%Y') as dob") + ->where('is_active', 1) + ->findAll(); $clientIds = array_column($clients, 'id'); @@ -3814,7 +3817,7 @@ class ClientController extends AdminController // Add additional fields if client type is 2 if ($client_type == 2) { $client_data = array_merge($client_data, [ - 'dob' => $postData['dob'], + 'dob' => change_date_format($postData['dob'],'d/m/Y','Y-m-d'), 'aadhar' => $postData['aadhar'], 'phone' => $postData['phone'], 'email' => $postData['email'], @@ -4295,7 +4298,7 @@ class ClientController extends AdminController // dd($policyTerms); // Re-encode the ordered policy terms $updatedPolicyTerms = json_encode($policyTerms); - dd($updatedPolicyTerms); + // dd($updatedPolicyTerms); // dd($orderedPolicyTerms, $updatedPolicyTerms); $this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]); @@ -4574,7 +4577,7 @@ class ClientController extends AdminController $employeeRestController = new EmployeeServiceController(); // $employeeRestController->excelFileDataValidation(['file_id' => 823]); - // $employeeRestController->employeesOnboardPreprocess(['file_id' => 644]); + // $employeeRestController->employeesOnboardPreprocess(['file_id' => 726]); // $employeeRestController->employeesOnboardProcess(['file_id' => 835]); // $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]); // $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]); @@ -4705,6 +4708,9 @@ class ClientController extends AdminController // $this->loadLayout('tat_report_band_wise_list', $reportData); // $data = $ticketModel->getTATReport(1); + // $empmodel = new EmployeeModel(); + // $data = $empmodel->getEmployeePolicy(348); + // dd($data); } // ------------------------------------------------------------------------------------------------------- @@ -4897,26 +4903,22 @@ class ClientController extends AdminController $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(); - + // $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'], $data['policy_id'], $client_id); - - $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(); + $acms_datas = $this->employeeModel->getAcmUsingClientID($data['client_id']); + // if(!empty($acms_datas)){ + // $acms = $acms_datas; + // } + }else{ + $acms_datas = ""; } @@ -4933,7 +4935,7 @@ class ClientController extends AdminController 'type' => $type, 'dataForClientAndInsurer' => $dataForClientAndInsurer, 'memberData' => $memberData, - 'acms' => $acms, + 'acms' => $acms_datas, ], 200); } else { return $this->respond([ @@ -4945,7 +4947,7 @@ class ClientController extends AdminController 'type' => $type, 'dataForClientAndInsurer' => $dataForClientAndInsurer, 'memberData' => $memberData, - 'acms' => $acms + 'acms' => $acms_datas ], 200); } } diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 8ee7765d..d1a48afb 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -100,16 +100,52 @@ class DashboardController extends AdminController $data = []; - $results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, - client_branch.id as client_branch_id, client_branch.branch_name, - client_branch.branch_code, employees.id as employee_id, - employees.name as employee_name, employees.relationship, - employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id') - ->join('client_branch', 'clients.id = client_branch.client_id', 'left') - ->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left') - ->join('employees', 'client_branch.id = employees.client_branch_id', 'left') - ->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left') - ->findAll(); + $db = db_connect(); + $sql = "SELECT + clients.id AS client_id, + clients.client_name, + clients.short_name, + client_branch.id AS client_branch_id, + client_branch.branch_name, + client_branch.branch_code, + + COUNT(employees.id) AS total_employees, + SUM(CASE WHEN employees.emp_status = 'draft' THEN 1 ELSE 0 END) AS draft_count, + SUM(CASE WHEN employees.emp_status IN ('enrolled', 'active') THEN 1 ELSE 0 END) AS enrolled_count, + + SUM(CASE WHEN auth_history.user_id IS NOT NULL THEN 1 ELSE 0 END) AS logged_in_count, + SUM(CASE WHEN auth_history.user_id IS NULL THEN 1 ELSE 0 END) AS not_logged_in_count, + + CASE + WHEN EXISTS ( + SELECT 1 FROM client_policy + WHERE client_policy.client_branch_id = client_branch.id + AND client_policy.is_active = 1 + AND client_policy.open_for_enrollment = 1 + ) THEN 1 + ELSE 0 + END AS open_or_close_enrollment + + FROM clients + LEFT JOIN client_branch ON clients.id = client_branch.client_id + LEFT JOIN employees ON client_branch.id = employees.client_branch_id + LEFT JOIN ( + SELECT user_id, user_type + FROM auth_history + WHERE user_type = 'employee' + GROUP BY user_id + ) AS auth_history ON employees.id = auth_history.user_id + + WHERE employees.relationship = 'Self' + AND employees.emp_status IN ('draft', 'enrolled', 'active') + AND employees.is_active = 1 + AND clients.is_active = 1 + AND client_branch.is_active = 1 + + GROUP BY clients.id, client_branch.id"; + + $query = $db->query($sql); + $results = $query->getResultArray(); $pendingActionsController = new PendingActionsController; $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); @@ -118,94 +154,11 @@ class DashboardController extends AdminController $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData); $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData); - $groupedData = []; - foreach ($results as $row) { - $clientId = $row['client_id']; - $clientName = $row['client_name']; - $shortName = $row['short_name']; - $branchId = $row['client_branch_id']; - $branchName = $row['branch_name']; - $branchCode = $row['branch_code']; - - $clientPolicyId = $row['client_policy_id']; - $policyTypeId = $row['policy_type_id']; - $employeeId = ''; - if ($employeeId != $row['employee_id']) { - $employeeId = $row['employee_id']; - } else { - $employeeId = null; - } - $employeeName = $row['employee_name']; - $employeeRelationship = $row['relationship']; - $employeeEmpCode = $row['emp_code']; - $employeeEmpStatus = $row['emp_status']; - $employeeUserType = $row['user_type']; - - // Initialize the client entry if it doesn't exist - if (!isset($groupedData[$clientId])) { - $groupedData[$clientId] = [ - 'client_id' => $clientId, - 'client_name' => $clientName, - 'short_name' => $shortName, - 'branches' => [] - ]; - } - - // Initialize the branch entry if it doesn't exist - if (!isset($groupedData[$clientId]['branches'][$branchId])) { - $groupedData[$clientId]['branches'][$branchId] = [ - 'client_branch_id' => $branchId, - 'branch_name' => $branchName, - 'branch_code' => $branchCode, - 'emp_login' => 0, - 'emp_enroll' => 0, - 'client_policies' => [], - 'employees' => [] - ]; - } - - // Add the client policy to the branch's policies list if it exists, not already added, and policyTypeId is not equal to 1 - if ($clientPolicyId !== null && $policyTypeId != 1 && !in_array(['client_policy_id' => $clientPolicyId, 'policy_type_id' => $policyTypeId], $groupedData[$clientId]['branches'][$branchId]['client_policies'])) { - $groupedData[$clientId]['branches'][$branchId]['client_policies'][] = [ - 'client_policy_id' => $clientPolicyId, - 'policy_type_id' => $policyTypeId - ]; - } - - // Append employee error to the branch's employees list if relationship is 'Self' and not already added - $employeeKey = $employeeId . '-' . $employeeName; // unique key to identify an employee - if ($employeeId !== null && $employeeRelationship == 'Self' && !isset($groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey])) { - $groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey] = [ - 'employee_id' => $employeeId, - 'employee_name' => $employeeName, - 'relationship' => $employeeRelationship, - 'emp_code' => $employeeEmpCode, - 'emp_status' => $employeeEmpStatus, - 'user_type' => $employeeUserType - ]; - if (!empty($employeeUserType)) { - $groupedData[$clientId]['branches'][$branchId]['emp_login']++; - } - - // Increment emp_enroll if emp_status is not 'draft' - if ($employeeEmpStatus !== 'draft') { - $groupedData[$clientId]['branches'][$branchId]['emp_enroll']++; - } - } - } - - // Re-index the arrays to match the expected structure - foreach ($groupedData as &$client) { - foreach ($client['branches'] as &$branch) { - $branch['employees'] = array_values($branch['employees']); - } - $client['branches'] = array_values($client['branches']); - } - - $data['client_branch_emp_list'] = $groupedData; + $data['client_branch_emp_list'] = $results; $session = \Config\Services::session(); - $session->set('enrollment_data', json_encode($data)); + $session->set('enrollment_data', json_encode($data)); + // echo "
";
$data['pendingActionsData'] = $pendingActionsData;
$data['businessTeamCount'] = count($businessTeamData) ?? 0;
diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php
index fd0c5455..61e0af4a 100755
--- a/app/Controllers/EmployeeServiceController.php
+++ b/app/Controllers/EmployeeServiceController.php
@@ -1640,6 +1640,7 @@ class EmployeeServiceController extends AdminController
$value['updated_by'] = $file['created_by'];
$value['id'] = $employee[0]['id'];
$value['emp_status'] = 'active';
+ $value['family_floater_key'] = generate_family_floater_key($value['relationship']);
$value['client_branch_id'] = $file['client_branch_id'];
$value['file_id'] = isset($employee[0]['file_id']) && $employee[0]['file_id'] != '' ? $employee[0]['file_id'] : $file['id'] ;
$log_message = 'Update Employee - '.$employee[0]['name'].'('.$employee[0]['emp_code'].') with PK '.$employee[0]['id'];
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index abbc6984..f0f1cc7b 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -2384,6 +2384,11 @@ class LeadsController extends BaseController
return $financialYears;
}
+
+ public function rfqNonEB(){
+
+ $this->loadLayout('view_rfq_non_eb');
+ }
diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php
index ef741d21..4e1271f8 100755
--- a/app/Controllers/MasterController.php
+++ b/app/Controllers/MasterController.php
@@ -1746,6 +1746,7 @@ class MasterController extends AdminController
'cache' => WRITEPATH . 'cache',
'sample_import_excel' => ROOTPATH . 'public/sample_import_excel',
'lead_files' => WRITEPATH . 'uploads/lead_files/',
+ 'claim_sample_forms' => ROOTPATH . 'public/claim_sample_forms/',
];
foreach ($folders as $folderName => $folderPath) {
diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php
index 348417bf..4a2a59d6 100644
--- a/app/Controllers/PolicyTransactionController.php
+++ b/app/Controllers/PolicyTransactionController.php
@@ -414,9 +414,13 @@ class PolicyTransactionController extends BaseController
// Prepare data for insertion and updating
$coShareDetails = [];
- // print_r($data);
+ // print_r($data); die;
// die;
+ if(isset($data['co_share_id']) && !empty($data['co_share_id'])){
+ $this->removePtCoShareRecords($data['co_share_id']);
+ }
+
if(isset($data['follow_insurer_id'])){
foreach ($data['follow_insurer_id'] as $index => $insurer) {
@@ -429,7 +433,7 @@ class PolicyTransactionController extends BaseController
'pt_id' => $pt_id,
'insurer_id' => $insurer_id ?? 0,
'insurer_branch_id' => $insurer_branch_id ?? 0,
- 'co_share_type' => $data['co_share_type'][$index] ?? null,
+ 'co_share_type' => $data['co_share_type'][$index] ?? 1,
'co_share_per' => $data['co_share_per'][$index] ?? 0,
'bp_amt' => $data['base_premium'][$index] ?? 0,
'bp_gst_amt' => $data['gst_amount'][$index] ?? 0,
@@ -438,6 +442,8 @@ class PolicyTransactionController extends BaseController
'bp_cgst' => $data['cgst'][$index] ?? 0,
'tp_amt' => $data['tp_premium'][$index] ?? 0,
'tep_amt' => $data['ter_premium'][$index] ?? 0,
+ 'cotp_amt' => $data['co_tp_premium'][$index] ?? 0,
+ 'cotep_amt' => $data['co_ter_premium'][$index] ?? 0,
'agreed_amt' => $data['agreed_amount'][$index] ?? 0,
'agreed_bp_per' => $data['agreed_bp'][$index] ?? 0,
'agreed_tp_per' => $data['agreed_tp'][$index] ?? 0,
@@ -499,7 +505,7 @@ class PolicyTransactionController extends BaseController
return true;
}
-
+
// print_r($data);
// die;
}
@@ -949,6 +955,23 @@ class PolicyTransactionController extends BaseController
}
}
+ //function for soft delete for pt_co_share_details records
+ public function removePtCoShareRecords($primaryKeys)
+ {
+ // print_r($primaryKeys); die;
+ if (empty($primaryKeys)) {
+ return false;
+ }
+
+ // Convert array to a comma-separated string for query binding
+ $placeholders = implode(',', array_fill(0, count($primaryKeys), '?'));
+
+ $sql = "UPDATE pt_co_share_details SET is_active = 0 WHERE id NOT IN ($placeholders)";
+
+ return db_connect()->query($sql, $primaryKeys);
+ }
+
+
//------------------------------------------------------------------------------------------------
// Policy Transaction Endorsement
@@ -1040,6 +1063,7 @@ class PolicyTransactionController extends BaseController
{
$id = $this->request->getPost('id');
$data = $this->preparePolicyTransactionData();
+ // print_r($data); die;
if (!$id) {
return $this->insertEndorsementTransaction($data);
@@ -1056,25 +1080,12 @@ class PolicyTransactionController extends BaseController
// print_r($data);
// die;
- // $data_received_date = (string)$this->request->getPost('data_received_date');
- // $closure_date = (string)$this->request->getPost('closure_date');
- // $endorse_eff_date = (string)$this->request->getPost('endorse_eff_date');
- // $month = (string)$this->request->getPost('month');
-
- // $data['data_received_date'] = empty($data['data_received_date']) ? null : date('Y-m-d', strtotime($data_received_date));
- // $data['closure_date'] = empty($data['closure_date']) ? null : date('Y-m-d', strtotime($closure_date));
- // $data['endorse_eff_date'] = empty($data['endorse_eff_date']) ? null : date('Y-m-d', strtotime($endorse_eff_date));
-
- // $month = '01-'.$data['month'];
- // $data['month'] = empty($data['month']) ? null : date('Y-m-d', strtotime($month));
-
if (!isset($data['policy_with_corr'])) {
$data['policy_with_corr'] = 0;
} elseif ($data['policy_with_corr']) {
$data['policy_with_corr'] = 1;
}
-
if(empty($data['data_received_date'])){
$data['data_received_date'] = null;
}else{
@@ -1246,7 +1257,7 @@ class PolicyTransactionController extends BaseController
public function getEndorsementDataForEdit($id)
{
$data = $this->policyTransactionModel
- ->select('
+ ->select('
policy_transaction.*,
clients.short_name as client_short_name,
clients.client_type,
@@ -1260,52 +1271,43 @@ class PolicyTransactionController extends BaseController
) as last_action_date
')
- ->join('clients', 'clients.id = policy_transaction.client_id')
- ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
- ->where('policy_transaction.id', $id)
- ->where('policy_transaction.is_active', 1)
- ->first();
-
- // $data['policy_start_date'] = empty($data['policy_start_date']) ? '' : date('d/m/Y', strtotime($data['s_date']));
- // $data['policy_end_date'] = empty($data['policy_end_date']) ? '' : date('d/m/Y', strtotime($data['e_date']));
- // $data['data_received_date'] = empty($data['data_received_date']) ? '' : date('d/m/Y', strtotime($data['data_received_date']));
- // $data['closure_date'] = empty($data['closure_date']) ? '' : date('d/m/Y', strtotime($data['closure_date']));
- // $data['endorse_eff_date'] = empty($data['endorse_eff_date']) ? '' : date('d/m/Y', strtotime($data['endorse_eff_date']));
-
- // $data['month'] = (isset($data['month']) && $data['month'] !== null && $data['month'] !== '')
- // ? date('M/Y', strtotime($data['month']))
- // : null;
+ ->join('clients', 'clients.id = policy_transaction.client_id')
+ ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
+ ->where('policy_transaction.id', $id)
+ ->where('policy_transaction.is_active', 1)
+ ->orderBy('id', 'asc')
+ ->first();
- if(!empty($data['policy_start_date'])){
+ if (!empty($data['policy_start_date'])) {
$data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
}
- if(!empty($data['policy_end_date'])){
+ if (!empty($data['policy_end_date'])) {
$data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
}
- if(!empty($data['data_received_date'])){
+ if (!empty($data['data_received_date'])) {
$data['data_received_date'] = change_date_format($data['data_received_date'], 'Y-m-d', 'd/m/Y');
}
- if(!empty($data['policy_issue_date'])){
+ if (!empty($data['policy_issue_date'])) {
$data['policy_issue_date'] = change_date_format($data['policy_issue_date'], 'Y-m-d', 'd/m/Y');
}
- if(!empty($data['endorse_eff_date'])){
+ if (!empty($data['endorse_eff_date'])) {
$data['endorse_eff_date'] = change_date_format($data['endorse_eff_date'], 'Y-m-d', 'd/m/Y');
}
- if(!empty($data['install_due_date'])){
+ if (!empty($data['install_due_date'])) {
$data['install_due_date'] = change_date_format($data['install_due_date'], 'Y-m-d', 'd/m/Y');
}
- if(!empty($data['last_action_date'])){
+ if (!empty($data['last_action_date'])) {
$data['last_action_date'] = change_date_format($data['last_action_date'], 'Y-m-d', 'd/m/Y');
}
- if(!empty($data['month'])){
+ if (!empty($data['month'])) {
$data['month'] = change_date_format($data['month'], 'Y-m-d', 'M/Y');
}
@@ -1314,7 +1316,7 @@ class PolicyTransactionController extends BaseController
//get PT Co-Share Details
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel
- ->select("
+ ->select("
pt_co_share_details.*,
(
@@ -1430,19 +1432,18 @@ class PolicyTransactionController extends BaseController
) AS actual_tep_brokerage_amount
")
- ->where('pt_id', $id)
- ->where('is_active', 1)
- ->orderBy('id', 'asc')
- ->findAll();
+ ->where('pt_id', $id)
+ ->where('is_active', 1)
+ ->orderBy('id', 'asc')
+ ->findAll();
// print_r($data['endorse_eff_date']); die;
- if($data){
+ if ($data) {
return $this->respond(['status' => true, 'data' => $data], 200);
- }else{
+ } else {
return $this->respond(['status' => false], 200);
}
-
}
//------------------------------------------------------------------------------------------------
@@ -1584,8 +1585,15 @@ class PolicyTransactionController extends BaseController
->where('policy_transaction.action_type', 'inception')
->findAll();
+ $is_copay_yes = $this->policyTransactionModel
+ ->where('client_id', $client_id)
+ ->where('client_policy_id', $client_policy_id)
+ ->where('action_type', 'inception')
+ ->where('is_active', 1)
+ ->first();
+
if ($totalCount) {
- return $this->respond(['status' => true, 'code' => 200, 'data' => $totalCount], 200);
+ return $this->respond(['status' => true, 'code' => 200, 'data' => $totalCount, 'is_copay_yes' => $is_copay_yes], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to get data'], 200);
}
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 752d116c..616a69cd 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -102,70 +102,68 @@ class RestAuthenticationController extends AdminController
{
try {
$email = $this->request->getJSON()->email;
-
- $employeeData = $this->employeeModel->select('employees.relationship,EP.employee_id')
- ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
- ->where('employees.is_active', 1)
- ->where('employees.relationship', 'self')
- ->where('employees.emp_status !=', 'truncated')
- ->where('employees.email_corporate', $email)
- ->where('EP.is_active', 1)
- ->whereIn('EP.status', ['active'])
- ->first();
-
- if (isset($employeeData['employee_id']))
- {
+
+ $employeeData = $this->employeeModel->select('
+ employees.relationship,
+ EP.employee_id,
+ employees.client_id,
+ employees.client_branch_id,
+ employees.email_corporate
+
+ ')
+ ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
+ ->where('employees.is_active', 1)
+ ->where('employees.relationship', 'Self')
+ ->where('employees.emp_status !=', 'truncated')
+ ->where('employees.email_corporate', $email)
+ ->where('EP.is_active', 1)
+ ->whereIn('EP.status', ['draft', 'enrolled'])
+ ->first();
+
+ if (isset($employeeData['employee_id'])) {
$otp = random_int(100000, 999999);
- $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self')
- ->where('is_active', 1)->set(array('otp' => $otp ))
- ->update();
- if($update)
- {
+ $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
+ ->where('is_active', 1)->set(array('otp' => $otp))
+ ->update();
+ if ($update) {
$common = [
'client_id' => $employeeData['client_id'],
'client_branch_id' => $employeeData['client_branch_id'],
'client_policy_id' => null,
'employee_policy_id' => null,
- 'employee_id' => $employeeData['id'],
+ 'employee_id' => $employeeData['employee_id'],
'mail_type' => 'otp_mail',
- ];
+ ];
$subject = 'Nhance user verification - OTP';
- $mail_content = $otp.' is your verification code for Nhance.';
- $res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject ,'common'=>$common ,'message' => $mail_content]);
+ $mail_content = $otp . ' is your verification code for Nhance.';
+ $res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject, 'common' => $common, 'message' => $mail_content]);
$this->myLogger->logme("info", $res);
- if(json_decode($res)->status == 'success')
- {
- $result = ['user_verification' => true ,'message' => "Verified Successfully"];
- return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
-
- }else{
- $result = ['user_verification' => false , 'message' => "Mail sending failed , try again"];
- return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
+ if (json_decode($res)->status == 'success') {
+ $result = ['user_verification' => true, 'message' => "Verified Successfully"];
+ return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
+ } else {
+ $result = ['user_verification' => false, 'message' => "Mail sending failed , try again"];
+ return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
}
+ } else {
- }else{
-
- $result = ['user_verification' => false , 'message' => "Verification failed , try again"];
- return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
-
+ $result = ['user_verification' => false, 'message' => "Verification failed , try again"];
+ return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
}
-
-
} else {
- $result = ['user_verification' => false , 'message' => "User not found"];
- return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
-
+ $result = ['user_verification' => false, 'message' => "User not found"];
+ return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
}
} catch (\Throwable $th) {
- return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
+ return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
}
}
-
+
public function getVerifiedUserData()
{
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index 6da26715..a7392860 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -12,13 +12,16 @@ use App\Models\TicketMailTemplateModel;
use App\Models\TicketMessageModel;
use App\Models\TicketNoteModel;
use App\Models\UserModel;
+use App\Models\ClientPolicyModel;
+use App\Models\EmployeePolicyModel;
+
use DOMDocument;
use Psr\Log\LoggerInterface;
use Kint\Kint;
use App\Models\EmployeeModel;
use App\Helpers\MailHelper;
-
+use App\Models\InsurerModel;
use CodeIgniter\API\ResponseTrait;
class TicketController extends BaseController
@@ -45,6 +48,8 @@ class TicketController extends BaseController
protected $triggerType;
protected $userModel;
protected $employeeModel;
+ protected $clientPolicyModel;
+ protected $employeePolicyModel;
public function __construct()
{
@@ -80,10 +85,10 @@ class TicketController extends BaseController
];
$this->claimType = [
1 => [
- 1 => "Main",
+ 1 => "Main Hospitalization",
+ 3 => "Pre / Post",
2 => "OPD",
- 3 => "Pre ReOpen",
- 4 => "Post ReOpen",
+ 4 => "ReOpen",
],
2 => [
1 => "TTD",
@@ -114,6 +119,7 @@ class TicketController extends BaseController
'((RELATIONSHIP))' => 'relationship',
'((POLICY_TYPE))' => 'policy_type',
'((AUTO_QUERY_CONTENT))' => 'auto_query_content',
+ '((CLAIM_FORM_LINK))' => 'claim_form_link',
];
$this->extraFields = [
1 => ['non_id_reason'],
@@ -157,6 +163,8 @@ class TicketController extends BaseController
$this->ticketMessageModel = new TicketMessageModel();
$this->userModel = new UserModel();
$this->employeeModel = new EmployeeModel();
+ $this->clientPolicyModel = new ClientPolicyModel();
+ $this->employeePolicyModel = new EmployeePolicyModel();
}
public function ticketList()
@@ -432,6 +440,11 @@ class TicketController extends BaseController
// $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');
+
+ if (in_array($ticket_data['claim_status_id'], [15, 25, 35])) {
+ $ticket_data['auto_query_content'] = $this->getCheckListAndConvertArrayToString($ticket_data);
+ }
+
// dd($ticket_data);
$template_data = $this->ticketMasterModel->getTemplateDataByTicketID($ticket_id);
if (!empty($template_data)) {
@@ -439,7 +452,6 @@ class TicketController extends BaseController
$template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data);
}
$data = $this->ticket_form_data($ticket_data['ticket_type_id'], $ticket_data['claim_status_id']);
- $data['ticket_data'] = $ticket_data;
$data['reply_data'] = $template_data;
$data['placeHolders'] = $this->placeHolders;
$data['message_data'] = $this->getTicketMessage($ticket_id);
@@ -447,6 +459,13 @@ class TicketController extends BaseController
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
$data['ticket_history'] = $this->ticketHistory($ticket_id);
$data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray();
+ if (!empty($ticket_data['client_policy_id'])){
+ $ticket_data['client_policy_id_text'] = $this->clientPolicyModel->select('concat(policy_type.policy_type,"-",client_policy.policy_no) as client_policy_name')->join('policy_type','policy_type.id = client_policy.policy_type_id and policy_type.is_active = 1')->where('client_policy.id',$ticket_data['client_policy_id'])->first()['client_policy_name'];
+ }
+ // dd($data);
+ $data['ticket_data'] = $ticket_data;
+ $data['acms'] = $this->employeeModel->getAcmUsingClientID($ticket_data['client_id']);
+
// dd($data);
return $this->loadLayout('ticket_edit_onbording', $data);
@@ -789,6 +808,13 @@ class TicketController extends BaseController
return null;
}
+ if (in_array($ticket_data['claim_status_id'], [15, 25, 35])) {
+ $ticket_data['auto_query_content'] = $this->getCheckListAndConvertArrayToString($ticket_data);
+ }
+
+ // print_r($ticket_data); die;
+
+
$this->myLogger->logme('error', "Fetched email template: " . json_encode($template_data));
// Generate Email Content
@@ -841,8 +867,10 @@ class TicketController extends BaseController
$replaceData = $ticket_data[$value] ?? '';
} else if ($value == "policy_type") {
$replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? "");
- } else {
- $replaceData = isset($ticket_data[$value]) ? strtoupper($ticket_data[$value]) : '';
+ } else if ($value == "claim_form_link"){
+ $replaceData = 'Click here to download Claim Form';
+ }else {
+ $replaceData = isset($ticket_data[$value]) ? $ticket_data[$value] : '';
}
$content = str_replace($key, $replaceData, $content);
@@ -1208,136 +1236,7 @@ class TicketController extends BaseController
}
}
- // public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){
-
- // if ($policy_type == 1) {
- // $sql = "SELECT
- // u.first_name AS acc_manager_name,
- // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) AS id_not_generated,
- // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) AS non_id,
- // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) AS cda,
- // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) AS information_required,
- // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) AS under_process,
- // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) AS approved,
- // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END) AS payment_initiated,
- // (
- // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = 1 THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = 1 THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = 1 THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = 1 THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = 1 THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = 1 THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = 1 THEN master.id END)
- // ) AS total
- // FROM
- // ticket_master master
- // JOIN
- // user_profiles u ON master.acm_id = u.id and u.is_active = 1
- // JOIN
- // ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1
- // WHERE
- // master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1
- // GROUP BY
- // u.id;
- // ";
- // $result = $this->ticketMasterModel->query($sql)->getResultArray();
- // // dd($result);
-
- // return $result;
-
-
- // }else{
- // $sql = "SELECT u.first_name AS acc_manager_name,
- // COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation,
- // COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS int_to_insurer,
- // COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS client_pending,
- // COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required,
- // COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS investigation,
- // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved,
- // COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS on_hold,
-
- // (
- // COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END)+
- // COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END)+
- // COUNT(CASE WHEN tcs.claim_status = 'CLIENT PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'INSURER PENDING' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'INVESTIGATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'ON HOLD' AND master.ticket_type_id = '$policy_type' THEN master.id END)
- // ) AS total1,
- // COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS not_covered,
- // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed,
- // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled,
- // (
- // COUNT(CASE WHEN tcs.claim_status = 'NOT COVERED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END)
- // ) AS total2
- // FROM
- // ticket_master master
- // JOIN
- // user_profiles u ON master.acm_id = u.id and u.is_active = 1
- // JOIN
- // ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1
- // WHERE
- // master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1 and master.ticket_type_id = '$policy_type'
- // GROUP BY
- // u.id;
- // ";
- // $result = $this->ticketMasterModel->query($sql)->getResultArray();
-
- // return $result;
- // }
- // }
-
- // public function tpaWiseReport($policy_type = null ,$start_date = null,$end_date = null ){
- // // $policy_type = 1;
- // $sql = "SELECT
- // tpa.name AS tpa_name,
- // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS id_not_generated,
- // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS non_id,
- // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS cda,
- // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS information_required,
- // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS under_process,
- // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS approved,
- // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS payment_initiated,
- // (
- // COUNT(CASE WHEN tcs.claim_status = 'ID NOT GENERATED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'NON ID' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'CDA' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'INFORMATION REQUIRED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status LIKE '%UNDER PROCESS%' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'APPROVED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'PAYMENT INITIATED' AND master.ticket_type_id = '$policy_type' THEN master.id END)
- // ) AS total,
- // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS closed,
- // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS settled,
- // COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS returned,
- // COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS denied,
- // (
- // COUNT(CASE WHEN tcs.claim_status = 'CLOSED' AND master.ticket_type_id = '$policy_type'THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'SETTLED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'RETURNED' AND master.ticket_type_id = '$policy_type' THEN master.id END) +
- // COUNT(CASE WHEN tcs.claim_status = 'REJECTED' AND master.ticket_type_id = '$policy_type' THEN master.id END)
- // ) AS total2
- // FROM
- // ticket_master master
- // JOIN
- // tpa ON master.tpa_id = tpa.id and tpa.is_active = 1
- // JOIN
- // ticket_claim_status tcs ON tcs.id = master.claim_status_id and tcs.is_active = 1
- // WHERE
- // master.created_at <= '$end_date' and master.created_at >= '$start_date' and master.is_active = 1
- // GROUP BY
- // tpa.id;
-
-
- // ";
- // $result = $this->ticketMasterModel->query($sql)->getResultArray();
-
- // return $result;
- // }
-
+ // -------------------------------------------------------------------------------------------------------------------------
// function for Reject ticket Head Approvel mail sent function
public function sendMailToTheHead($ticket_data)
@@ -1433,5 +1332,116 @@ class TicketController extends BaseController
return $lastMatchedStatus;
}
+
+ public function getPolicyStartDate()
+ {
+
+ $data = $this->request->getPost();
+ $client_policy_id = $data['policy_id'];
+ $policy_start_date = $this->clientPolicyModel->select('policy_start_date')->where('id', $client_policy_id)->first()['policy_start_date'];
+ // dd($data);
+ if (isset($data['employeeId']) && $data['employeeId'] != "" && $data['employeeId'] != null) {
+ // dd($data);
+ $emp_id = $data['employeeId'];
+ $empData = $this->employeeModel->select('dob,doj')->where('id',$emp_id)->findAll();
+
+ if (!empty($empData) && $empData != "" && $empData != null ) {
+ foreach ($empData as &$emp) { // Loop through the data
+ $doi = $this->employeePolicyModel->select('date_coverage,basic_cover_si')->where('client_policy_id',$client_policy_id)->first();
+ $emp['dob'] = date('d/m/Y', strtotime($emp['dob']));
+ $emp['doj'] = date('d/m/Y', strtotime($emp['doj']));
+ $emp['date_of_inception'] = date('d/m/Y', strtotime($doi['date_coverage']));
+ $emp['basic_cover_si'] = $doi['basic_cover_si'];
+ }
+ }
+
+ if ($empData){
+ return $this->respond(['status' => true, 'minDate' => $policy_start_date,'empData'=> $empData], 200);
+ }else{
+ return $this->respond(['status' => false, 'message' => "Policy Not Found"]);
+ }
+
+ } else {
+ // dd($policy_start_date);
+ if ($policy_start_date) {
+ return $this->respond(['status' => true, 'minDate' => $policy_start_date], 200);
+ } else {
+ return $this->respond(['status' => false, 'message' => "Policy Not Found"]);
+ }
+ }
+ }
+
+ public function getPoliciesbyEmpID() {
+ $received_data = $this->request->getPost();
+ $emp_id = $received_data['emp_id'];
+
+ // Get all client policy IDs for the given employee
+ $policies = $this->employeePolicyModel
+ ->select('client_policy_id')
+ ->where('employee_id', $emp_id)
+ ->findAll();
+
+ if (empty($policies)) {
+ return []; // Return empty if no policies found
+ }
+
+ // Extract client policy IDs into an array
+ $policy_ids = array_column($policies, 'client_policy_id');
+
+ // Fetch all policy names and IDs in one query
+ $policyNameandID = $this->clientPolicyModel
+ ->select('CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name, client_policy.id as client_policy_value,client_policy.policy_type_id,client_policy.policy_no')
+ ->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1')
+ ->whereIn('client_policy.id', $policy_ids)
+ ->findAll();
+
+ // dd($policyNameandID);
+ if ($policyNameandID){
+
+ return $this->respond(['status'=>true,'policy_data'=> $policyNameandID]);
+ }else{
+ return $this->respond(['status'=>false,'message'=> "Policy Not Found"]);
+ }
+ }
+
+ public function getCheckListAndConvertArrayToString($ticket_data)
+ {
+ $data = db_connect()->table('ticket_check_list')
+ ->where('is_active', 1)
+ ->where('ticket_type_id', $ticket_data['ticket_type_id'])
+ ->get()->getResultArray();
+
+ $data = !empty($data) ? implode("", array_map(fn($doc) => "{$doc['document']}
", $data)) : "";
+ // $data = !empty($data) ? implode(", ", array_column($data, 'document')) : "";
+ // print_r($data); die;
+
+ return $data;
+ }
+
+ public function downloadClaimForm($insurer_id)
+ {
+ $insurerModel = new InsurerModel();
+ $insurer_data = $insurerModel->where('MD5(id)', $insurer_id)->where('is_active', 1)->first();
+
+ if (!$insurer_data) {
+ $data['message'] = 'The Physical File Not Found';
+ echo view('errors/404', $data);
+ }
+
+ $fileName = $insurer_data['short_name'] . '.pdf';
+ $filePath = ROOTPATH . 'public/claim_sample_forms/' . $fileName;
+
+ try {
+ if (file_exists($filePath)) {
+ return $this->response->download($filePath, null);
+ } else {
+ $data['message'] = 'The Physical File Not Found';
+ echo view('errors/404', $data);
+ }
+ } catch (\Exception $e) {
+ $this->myLogger->logme('error', $e->getMessage());
+ return $this->response->setStatusCode(500)->setBody('An error occurred while downloading the file.');
+ }
+ }
}
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index a5cd1bda..c90eebb3 100755
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -682,7 +682,7 @@ if (!function_exists('generate_relationship_code'))
$slug = \Config\Services::slug();
$relationship_code = $slug->slugify($arr['relationship']);
$emp_type_code = ($relationship_code == 'self' ? 'EMP_TYP_01' : 'EMP_TYP_03');
- $relationship_code = $gender[ $arr['gender'] ] . $relationship[ $relationship_code ] ;
+ $relationship_code = $gender[ trim($arr['gender']) ] . $relationship[ trim($relationship_code) ];
return ['relationship_code' => $relationship_code,'emp_type_code' => $emp_type_code];
}
}
diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php
index 44bea402..bd66c776 100755
--- a/app/Helpers/sendMailNotification.php
+++ b/app/Helpers/sendMailNotification.php
@@ -1247,7 +1247,7 @@ class sendMailNotification
$subject = $notification['subject'];
$rand_string = 'HX3kUh';
- $link = generate_download_link($rand_string);
+ $link = generate_download_link($rand_string).'/1';
$name = 'John Doe';
$mobile = 9080706050;
diff --git a/app/Models/EmployeeModel.php b/app/Models/EmployeeModel.php
index 14ec368d..524eb18b 100755
--- a/app/Models/EmployeeModel.php
+++ b/app/Models/EmployeeModel.php
@@ -149,7 +149,21 @@ class EmployeeModel extends Model
{
return $this->db->table('employee_polices')
- ->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
+ ->select('
+ policy_type.long_name as Policy_Name ,
+ client_policy.policy_terms as Policy_Terms,
+ client_policy.client_id as ClientId,
+ client_policy.policy_id as PolicyId,
+ client_policy.id as ClientPolicyId,
+ CASE
+ WHEN client_policy.open_for_enrollment IS NULL THEN 0
+ ELSE client_policy.open_for_enrollment
+ END AS OpenForEnrollment,
+ client_policy.disclaimer,
+ client_policy.policy_type_id ,
+ employee_polices.tpa_id as tpa_id ,
+ employee_polices.rand_string as rand_string
+ ', FALSE) // Select all columns from both tables
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.policy_status', 1)
@@ -273,5 +287,21 @@ class EmployeeModel extends Model
}
+ public function getAcmUsingClientID($client_id)
+ {
+ return $this->db->table('client_rm')
+ ->select('user_profiles.id, user_profiles.first_name')
+ ->join('user_profiles', 'client_rm.user_id = user_profiles.id')
+ ->where([
+ 'client_rm.level' => 3,
+ 'user_profiles.role' => 3,
+ 'client_rm.is_active' => 1,
+ 'user_profiles.is_active' => 1,
+ 'client_rm.client_id' => $client_id
+ ])
+ ->get()
+ ->getResultArray();
+ }
+
}
diff --git a/app/Models/PTCOShareDetailsModel.php b/app/Models/PTCOShareDetailsModel.php
index dc6b2cec..1b2c84fd 100644
--- a/app/Models/PTCOShareDetailsModel.php
+++ b/app/Models/PTCOShareDetailsModel.php
@@ -66,6 +66,8 @@ class PTCOShareDetailsModel extends Model
'statement_id',
'follower_policy_no',
'non_comm_per_amt',
+ 'cotp_amt',
+ 'cotep_amt',
];
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)
diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php
index bb5f5954..136529d6 100644
--- a/app/Models/PolicyTransactionModel.php
+++ b/app/Models/PolicyTransactionModel.php
@@ -318,6 +318,280 @@ class PolicyTransactionModel extends Model
// BDS Report NEW Functin for QUERY
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer)
+
+ // public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0)
+ // {
+
+ // $date_condition = '';
+ // if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
+ // $date_condition = "
+ // AND insurer_statements.month >= '".$start_date ."'
+ // AND insurer_statements.month <= '".$end_date ."'
+ // ";
+ // }
+
+ // $builder = $this->db->table('policy_transaction')
+ // ->select("
+ // policy_transaction.*,
+ // DATE_FORMAT(policy_transaction.policy_issue_date, '%d %b %Y') AS policy_issue_date,
+ // DATE_FORMAT(
+ // IF(policy_transaction.month IS NULL,
+ // policy_transaction.policy_issue_date,
+ // policy_transaction.month),
+ // '%b %Y') AS policy_issue_month,
+ // CASE
+ // WHEN clients.client_type = 1 THEN 'Group'
+ // WHEN clients.client_type = 2 THEN 'Retail'
+ // ELSE '-'
+ // END AS client_type,
+ // CASE
+ // WHEN policy_transaction.revenue_type = 'NA' THEN 'Fresh'
+ // ELSE 'Renewal'
+ // END AS revenue_type,
+ // CASE
+ // WHEN policy_transaction.action_type = 'inception' THEN 'Policy'
+ // ELSE 'Endorsement'
+ // END AS action_type,
+ // clients.client_name AS client_name,
+ // clients.short_name AS client_short_name,
+ // client_branch.branch_name AS client_branch_name,
+ // client_branch.address1 AS client_address,
+ // policy_type.policy_type,
+ // policy_type.bap,
+ // insurers.name AS insurer_name,
+ // insurers.short_name AS insurer_short_name,
+ // insurer_branch.branch_name AS insurer_branch_name,
+ // insurer_branch.branch_code AS insurer_branch_code,
+ // user_profiles.first_name as user_name,
+ // vehicle.vehicle_no,
+ // tpa.name as tpa_name,
+ // pt_co_share_details.remark as remarks,
+ // pt_co_share_details.bp_amt,
+ // pt_co_share_details.exp_amt,
+ // pt_co_share_details.id as pt_id,
+ // sales_user.first_name as salse_person_name,
+ // service_user.first_name as service_person_name,
+
+ // ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
+
+ // ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
+
+ // ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
+
+ // ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS tp_or_ter,
+
+ // DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
+
+ // (pt_co_share_details.agreed_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per,
+
+ // pt_co_share_details.agreed_bp_per,
+ // ROUND(
+ // (
+ // SELECT
+ // (
+ // SUM(co_share_stmt_details.actual_bp_brokerage_amt) +
+ // SUM(co_share_stmt_details.actual_tp_brokerage_amt) +
+ // SUM(co_share_stmt_details.actual_tep_brokerage_amt) +
+ // SUM(co_share_stmt_details.reward)
+
+ // ) AS total_irda_amt
+ // FROM
+ // co_share_stmt_details
+ // JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
+ // WHERE
+ // co_share_stmt_details.co_share_id = pt_co_share_details.id
+ // AND co_share_stmt_details.is_active = 1
+ // AND insurer_statements.is_active = 1
+ // $date_condition
+ // ),
+ // 2
+ // ) AS total_irda_amt,
+ // ROUND(
+ // (
+ // SELECT
+ // (
+ // SUM(co_share_stmt_details.reward)
+
+ // ) AS reward
+ // FROM
+ // co_share_stmt_details
+ // JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
+ // WHERE
+ // co_share_stmt_details.co_share_id = pt_co_share_details.id
+ // AND co_share_stmt_details.is_active = 1
+ // AND insurer_statements.is_active = 1
+ // $date_condition
+ // ),
+ // 2
+ // ) AS reward,
+
+ // ROUND(
+ // (
+ // SELECT
+ // SUM(
+ // COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0) +
+ // COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0) +
+ // COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0) +
+ // COALESCE(co_share_stmt_details.reward, 0)
+ // ) AS total_irda_amt
+ // FROM
+ // co_share_stmt_details
+ // JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
+ // JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
+ // WHERE
+ // co_share_stmt_details.co_share_id = pt_co_share_details.id
+ // AND co_share_stmt_details.is_active = 1
+ // AND pt_table.is_active = 1
+ // AND insurer_statements.is_active = 1
+ // AND insurer_statements.invoice_status IS NOT NULL
+ // $date_condition
+
+ // ),
+ // 2
+ // ) AS billed_amt,
+
+ // ROUND(
+ // (
+ // (
+ // SELECT
+ // SUM(
+ // COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
+ // + COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
+ // + COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
+ // + COALESCE(co_share_stmt_details.reward, 0)
+ // )
+ // FROM
+ // co_share_stmt_details
+ // JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
+ // WHERE
+ // co_share_stmt_details.co_share_id = pt_co_share_details.id
+ // AND co_share_stmt_details.is_active = 1
+ // $date_condition
+ // )
+ // -
+ // (
+ // SELECT
+ // SUM(
+ // COALESCE(co_share_stmt_details.actual_bp_brokerage_amt, 0)
+ // + COALESCE(co_share_stmt_details.actual_tp_brokerage_amt, 0)
+ // + COALESCE(co_share_stmt_details.actual_tep_brokerage_amt, 0)
+ // + COALESCE(co_share_stmt_details.reward, 0)
+ // )
+ // FROM
+ // co_share_stmt_details
+ // JOIN pt_co_share_details AS pt_table ON co_share_stmt_details.co_share_id = pt_table.id
+ // JOIN insurer_statements ON co_share_stmt_details.statement_id = insurer_statements.id
+ // WHERE
+ // co_share_stmt_details.co_share_id = pt_co_share_details.id
+ // AND co_share_stmt_details.is_active = 1
+ // AND pt_table.is_active = 1
+ // AND insurer_statements.is_active = 1
+ // AND insurer_statements.invoice_status IS NULL
+ // $date_condition
+ // )
+ // ),
+ // 2
+ // ) AS unbilled_amt
+
+ // ")
+ // ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
+ // // ->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id', 'left')
+ // ->join('clients', 'clients.id = policy_transaction.client_id')
+ // ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
+ // ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
+ // ->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
+ // ->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
+ // ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
+ // ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
+ // ->join('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left')
+ // ->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left')
+ // ->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
+ // ->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')
+ // ->join('user_profiles AS service_user', 'policy_transaction.serviced_by = service_user.id', 'left')
+ // ->where('policy_transaction.is_active', 1)
+ // ->where('pt_co_share_details.is_active', 1);
+
+ // // Check if the start date and end date are provided
+ // if ($start_date != 0 && $end_date != 0 && $date_type != 0 && $date_type != 'statement_month') {
+
+ // $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
+ // $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
+
+ // $builder->where('policy_transaction.'.$date_type.'>=', $startDate)
+ // ->where('policy_transaction.'.$date_type.'<=', $endDate);
+
+ // }
+
+ // // if($date_type == 'statement_month' && $start_date != 0 && $end_date != 0){
+
+ // // $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
+ // // $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
+ // // $builder->where('policy_transaction.month >=', $startDate)
+ // // ->where('policy_transaction.month <=', $endDate);
+ // // }
+
+ // // Conditionally join insurer_statements if $date_type == 'statement_month'
+ // if ($date_type == 'statement_month' && $start_date != 0 && $end_date != 0) {
+ // $startDate = date('Y-m-d', strtotime($start_date));
+ // $endDate = date('Y-m-d', strtotime($end_date));
+
+ // $builder->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id', 'left')
+ // ->join('insurer_statements', 'co_share_stmt_details.statement_id = insurer_statements.id','left')
+ // ->where('insurer_statements.is_active', 1)
+ // ->where('insurer_statements.month >=', $startDate)
+ // ->where('insurer_statements.month <=', $endDate)
+ // ->groupBy('co_share_stmt_details.co_share_id');
+ // }
+
+ // if ($client_id != 0) {
+ // $builder->where('policy_transaction.client_id', $client_id);
+ // }
+
+ // if ($insurer_id != 0) {
+ // $builder->where('policy_transaction.insurer_id', $insurer_id);
+ // }
+
+ // if ($client_branch_id != 0) {
+ // $builder->where('policy_transaction.client_branch_id', $client_branch_id);
+ // }
+
+ // if ($insurer_branch_id != 0) {
+ // $builder->where('policy_transaction.insurer_branch_id', $insurer_branch_id);
+ // }
+
+ // if ($client_policy_id != 0) {
+ // $builder->where('policy_transaction.client_policy_id', $client_policy_id);
+ // }
+
+
+
+ // if ($policy_type_id != 0) {
+ // $builder->where('client_policy.policy_type_id', $policy_type_id);
+ // }
+
+ // if ($issuer != 0) {
+ // $builder->where('policy_transaction.issuer', $issuer);
+ // }
+
+ // if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
+
+ // $fromDate = date('Y-m-d', strtotime('-30 days'));
+ // $toDate = date('Y-m-d 23:59:59');
+
+ // $builder->where('policy_transaction.created_at >=', $fromDate)
+ // ->where('policy_transaction.created_at <=', $toDate);
+
+ // }
+
+ // $builder->orderBy('policy_transaction.id', 'desc');
+
+ // $result = $builder->get()->getResultArray();
+
+ // // dd($this->db->getLastQuery());
+
+ // return $result;
+ // }
+
public function getBDSReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $client_branch_id = 0, $insurer_branch_id = 0, $client_policy_id = 0)
{
@@ -365,19 +639,19 @@ class PolicyTransactionModel extends Model
vehicle.vehicle_no,
tpa.name as tpa_name,
pt_co_share_details.remark as remarks,
- pt_co_share_details.bp_amt,
+ pt_co_share_details.cop_amt as bp_amt,
pt_co_share_details.exp_amt,
pt_co_share_details.id as pt_id,
sales_user.first_name as salse_person_name,
service_user.first_name as service_person_name,
- ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS premium_wo_gst,
+ ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) AS premium_wo_gst,
- ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2) AS gst_amount,
+ ROUND((ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) * 18 / 100), 2) AS gst_amount,
- ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) + ROUND((ROUND((pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
+ ROUND((ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) + ROUND((ROUND((pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) * 18 / 100), 2)), 2) AS total_premium,
- ROUND((pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 2) AS tp_or_ter,
+ ROUND((pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 2) AS tp_or_ter,
DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
@@ -591,9 +865,89 @@ class PolicyTransactionModel extends Model
return $result;
}
+ // public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
+ // {
+ // // dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
+ // $builder = $this->db->table('policy_transaction')
+ // ->select('
+ // policy_transaction.*,
+ // clients.short_name AS client_short_name,
+ // clients.client_code,
+ // clients.client_type,
+ // clients.client_name,
+ // client_branch.branch_name AS client_branch_name,
+ // insurers.name AS insurer_name,
+ // insurers.short_name AS insurer_short_name,
+ // policy_type.policy_type,
+ // pt_co_share_details.agreed_amt AS amount,
+ // pt_co_share_details.bp_amt AS bp,
+ // pt_co_share_details.tp_amt AS tp
+ // ')
+ // ->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
+ // ->join('clients', 'clients.id = policy_transaction.client_id', 'left')
+ // ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
+ // ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
+ // ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
+ // ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
+ // ->where('policy_transaction.is_active', 1)
+ // ->where('policy_transaction.action_type', 'inception');
+
+ // if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
+
+ // $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
+ // $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
+
+ // $builder->where('policy_transaction.'.$date_type.'>=', $startDate)
+ // ->where('policy_transaction.'.$date_type.'<=', $endDate);
+ // }else{
+
+ // // $fromDate = date('Y-m-d', strtotime('-30 days'));
+ // // $toDate = date('Y-m-d 23:59:59');
+
+ // // $builder->where('policy_transaction.created_at >=', $fromDate)
+ // // ->where('policy_transaction.created_at <=', $toDate);
+ // }
+
+ // if ($client_id != 0) {
+ // $builder->where('policy_transaction.client_id', $client_id);
+ // }
+
+ // if ($insurer_id != 0) {
+ // $builder->where('policy_transaction.insurer_id', $insurer_id);
+ // }
+
+ // if ($policy_type_id != 0) {
+ // $builder->where('client_policy.policy_type_id', $policy_type_id);
+ // }
+
+ // if ($issuer != 0) {
+ // $builder->where('policy_transaction.issuer', $issuer);
+ // }
+ // if ($status != 0) {
+ // $builder->where('policy_transaction.status', $status);
+ // }
+
+ // if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
+
+ // $fromDate = date('Y-m-d', strtotime('-30 days'));
+ // $toDate = date('Y-m-d 23:59:59');
+
+ // $builder->where('policy_transaction.created_at >=', $fromDate)
+ // ->where('policy_transaction.created_at <=', $toDate);
+
+ // }
+
+ // $builder->orderBy('policy_transaction.id', 'desc')->limit(10);
+
+ // $result = $builder->get()->getResultArray();
+
+ // // dd($this->db->getLastQuery());
+
+ // return $result;
+ // }
+
public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{
- // dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
$builder = $this->db->table('policy_transaction')
->select('
policy_transaction.*,
@@ -607,7 +961,8 @@ class PolicyTransactionModel extends Model
policy_type.policy_type,
pt_co_share_details.agreed_amt AS amount,
pt_co_share_details.bp_amt AS bp,
- pt_co_share_details.tp_amt AS tp
+ pt_co_share_details.tp_amt AS tp,
+ clients.pan
')
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left')
@@ -618,59 +973,44 @@ class PolicyTransactionModel extends Model
->where('policy_transaction.is_active', 1)
->where('policy_transaction.action_type', 'inception');
- if ($start_date != 0 && $end_date != 0 && $date_type != 0) {
-
- $startDate = date('Y-m-d 00:00:00', strtotime($start_date));
- $endDate = date('Y-m-d 23:59:59', strtotime($end_date));
-
- $builder->where('policy_transaction.'.$date_type.'>=', $startDate)
- ->where('policy_transaction.'.$date_type.'<=', $endDate);
- }else{
-
- // $fromDate = date('Y-m-d', strtotime('-30 days'));
- // $toDate = date('Y-m-d 23:59:59');
-
- // $builder->where('policy_transaction.created_at >=', $fromDate)
- // ->where('policy_transaction.created_at <=', $toDate);
+ // Optimize Date Filtering
+ if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
+ $builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
+ ->where("policy_transaction.$date_type <=", date('Y-m-d 23:59:59', strtotime($end_date)));
}
- if ($client_id != 0) {
+ // Apply Filters Only When Necessary
+ if (!empty($client_id)) {
$builder->where('policy_transaction.client_id', $client_id);
}
-
- if ($insurer_id != 0) {
+ if (!empty($insurer_id)) {
$builder->where('policy_transaction.insurer_id', $insurer_id);
}
-
- if ($policy_type_id != 0) {
+ if (!empty($policy_type_id)) {
$builder->where('client_policy.policy_type_id', $policy_type_id);
}
-
- if ($issuer != 0) {
+ if (!empty($issuer)) {
$builder->where('policy_transaction.issuer', $issuer);
}
- if ($status != 0) {
+ if (!empty($status)) {
$builder->where('policy_transaction.status', $status);
}
- if($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0){
-
+ // Default to Last 30 Days if No Filters Are Applied
+ if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer)) {
$fromDate = date('Y-m-d', strtotime('-30 days'));
$toDate = date('Y-m-d 23:59:59');
-
+
$builder->where('policy_transaction.created_at >=', $fromDate)
->where('policy_transaction.created_at <=', $toDate);
-
}
-
+
+ // Optimize Query Execution
$builder->orderBy('policy_transaction.id', 'desc');
- $result = $builder->get()->getResultArray();
-
- // dd($this->db->getLastQuery());
-
- return $result;
+ return $builder->get()->getResultArray();
}
+
public function getEndorsementTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{
@@ -761,7 +1101,7 @@ class PolicyTransactionModel extends Model
pt_co_share_details.exp_amt,
pt_co_share_details.variance,
- ROUND ( (pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt),2) as original_premium,
+ ROUND ( (pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt),2) as original_premium,
ROUND(
(
SELECT
@@ -779,7 +1119,7 @@ class PolicyTransactionModel extends Model
) AS statement_premium,
COALESCE(
- (pt_co_share_details.bp_amt + pt_co_share_details.tp_amt + pt_co_share_details.tep_amt), 0
+ (pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt), 0
) -
COALESCE(
(
diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php
index 878fad2e..f75cf2a6 100644
--- a/app/Models/TicketMasterModel.php
+++ b/app/Models/TicketMasterModel.php
@@ -72,6 +72,8 @@ class TicketMasterModel extends Model
'non_id_reason',
'head_rejection_reason',
'pay_initiate_date',
+ 'emp_personal_mail',
+ 'client_policy_id'
];
diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php
index 14a5f652..94373196 100644
--- a/app/Views/chatbot.php
+++ b/app/Views/chatbot.php
@@ -63,7 +63,7 @@
if (window.botmanWidget) {
botmanChatWidget.open();
setTimeout(function(){
- botmanChatWidget.sayAsBot('Hi '+ emp_name +',This is ILA your Insurance Assistant, plz choose the following options')
+ botmanChatWidget.sayAsBot('Hi '+ (typeof emp_name !== "undefined" && emp_name !== null && emp_name !== "" ? emp_name : "Guest User") +',This is ILA your Insurance Assistant, plz choose the following options')
botmanChatWidget.whisper('Hi');
},3000);
diff --git a/app/Views/client_list.php b/app/Views/client_list.php
index ce079c60..592031dc 100755
--- a/app/Views/client_list.php
+++ b/app/Views/client_list.php
@@ -202,6 +202,7 @@ table.dataTable thead th {
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
+ e.preventDefault();
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
diff --git a/app/Views/employee_list.php b/app/Views/employee_list.php
index 976e2f69..292d5c21 100755
--- a/app/Views/employee_list.php
+++ b/app/Views/employee_list.php
@@ -232,7 +232,6 @@ table.dataTable tbody td {
document.addEventListener("DOMContentLoaded", init);
function init() {
-
const table = document.getElementById("tickets-table");
let activeDropdown = null;
@@ -264,8 +263,21 @@ function init() {
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
+
+ // Clone original dropdown items while moving onclick handlers to data attributes
+ const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.innerHTML = originalDropdown.innerHTML;
+ // Transfer onclick handlers to data attributes
+ customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
+ const originalItem = originalItems[index];
+ const originalOnclick = originalItem.getAttribute('onclick');
+ if (originalOnclick) {
+ item.setAttribute('data-onclick', originalOnclick);
+ item.removeAttribute('onclick'); // Remove original handler
+ }
+ });
+
return customDropdown;
}
@@ -287,11 +299,15 @@ function init() {
}
function handleItemClick(e, item) {
- const onclickAttr = item.getAttribute('onclick');
+ e.preventDefault();
+
+ // Execute the stored onclick handler
+ const onclickAttr = item.getAttribute('data-onclick');
if (onclickAttr) {
eval(onclickAttr);
}
+ // Handle href navigation
const href = item.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
diff --git a/app/Views/enrollment_dash.php b/app/Views/enrollment_dash.php
index 88d9fda6..e9256345 100755
--- a/app/Views/enrollment_dash.php
+++ b/app/Views/enrollment_dash.php
@@ -1,9 +1,9 @@
-
-
+
@@ -14,7 +14,8 @@
-
+
@@ -25,36 +26,46 @@
$currentItem = 0; // Counter for items
$isActive = true; // Variable to set the first item as active
foreach ($client_branch_emp_list as $clients) {
- foreach ($clients['branches'] as $branches) {
+
// Start a new carousel item if needed
if ($currentItem % $itemsPerSlide == 0) {
if (!$isActive) echo ''; // Close previous carousel item
- echo '';
- $isActive = false;
- }
- if(count($branches['client_policies']) != 0){ ?>
-
-