MERGE_TEST_BDS_CO_SHARE_SPLIT

This commit is contained in:
Venba 2025-03-06 12:34:41 +00:00
commit 2382487b9e
18 changed files with 1566 additions and 1062 deletions

View File

@ -91,7 +91,7 @@ class BDSReportController extends AdminController
ins.id, ins.id,
ins.name AS insurers, 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 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 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 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 FROM
@ -131,7 +131,7 @@ class BDSReportController extends AdminController
SELECT SELECT
pot.bap AS bap, pot.bap AS bap,
COALESCE(COUNT(DISTINCT pt.id), 0) AS Policies, 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(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 COALESCE(SUM(pt_co.exp_amt), 0) AS Expected_amt
FROM policy_type AS pot FROM policy_type AS pot
@ -267,26 +267,26 @@ class BDSReportController extends AdminController
-- Health Policies -- 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' 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 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, COALESCE(SUM(CASE WHEN ptp.bap = 'Health' THEN pt_co.exp_amt ELSE 0 END), 0) AS health_exp_amt,
-- Misc Policies -- 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' 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 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, COALESCE(SUM(CASE WHEN ptp.bap = 'Misc' THEN pt_co.exp_amt ELSE 0 END), 0) AS misc_exp_amt,
-- Motor Policies -- 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' 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 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, COALESCE(SUM(CASE WHEN ptp.bap = 'Motor' THEN pt_co.exp_amt ELSE 0 END), 0) AS motor_exp_amt,
-- Engineering Policies -- 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' 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 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, 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 -- 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' 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 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, COALESCE(SUM(CASE WHEN ptp.bap = 'Fire' THEN pt_co.exp_amt ELSE 0 END), 0) AS fire_exp_amt,
-- Liability Policies -- 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' 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 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, COALESCE(SUM(CASE WHEN ptp.bap = 'Liability' THEN pt_co.exp_amt ELSE 0 END), 0) AS liability_exp_amt,
-- Life Policies -- 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' 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 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, COALESCE(SUM(CASE WHEN ptp.bap = 'Life' THEN pt_co.exp_amt ELSE 0 END), 0) AS life_exp_amt,
-- Marine Cargo Policies -- 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' 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 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, 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 -- 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' 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 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, 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, ) AS total_policy_count,
COALESCE( 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 = '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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.cop_amt + pt_co.cotp_amt + pt_co.cotep_amt + pt_co.non_comm_per_amt) ELSE 0 END),
0 0
) AS total_premium, ) AS total_premium,
@ -429,43 +429,43 @@ class BDSReportController extends AdminController
-- Health Policies -- 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' 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 -- 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' 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 -- 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' 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 -- 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' 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 -- 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' 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 -- 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' 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 -- 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' 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 -- 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' 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 -- 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' 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 -- Grand Totals
COALESCE(SUM(CASE WHEN pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS total_policy_count, 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 FROM clients c
LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate' LEFT JOIN policy_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(( COALESCE((
select 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 from co_share_stmt_details stmt
left join pt_co_share_details pt_co on stmt.co_share_id = pt_co.id left join pt_co_share_details pt_co on stmt.co_share_id = pt_co.id
left join policy_transaction pt on pt_co.pt_id = pt.id left join policy_transaction pt on pt_co.pt_id = pt.id

View File

@ -100,16 +100,52 @@ class DashboardController extends AdminController
$data = []; $data = [];
$results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name, $db = db_connect();
client_branch.id as client_branch_id, client_branch.branch_name, $sql = "SELECT
client_branch.branch_code, employees.id as employee_id, clients.id AS client_id,
employees.name as employee_name, employees.relationship, clients.client_name,
employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id') clients.short_name,
->join('client_branch', 'clients.id = client_branch.client_id', 'left') client_branch.id AS client_branch_id,
->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left') client_branch.branch_name,
->join('employees', 'client_branch.id = employees.client_branch_id', 'left') client_branch.branch_code,
->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
->findAll(); 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; $pendingActionsController = new PendingActionsController;
$pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
@ -118,94 +154,11 @@ class DashboardController extends AdminController
$businessTeamStatusData = $this->data_construct_for_bds($businessTeamData); $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
$financeTeamStatusData = $this->data_construct_for_bds($financeTeamData); $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
$groupedData = [];
foreach ($results as $row) { $data['client_branch_emp_list'] = $results;
$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;
$session = \Config\Services::session(); $session = \Config\Services::session();
$session->set('enrollment_data', json_encode($data)); $session->set('enrollment_data', json_encode($data));
// echo "<pre>"; // echo "<pre>";
$data['pendingActionsData'] = $pendingActionsData; $data['pendingActionsData'] = $pendingActionsData;
$data['businessTeamCount'] = count($businessTeamData) ?? 0; $data['businessTeamCount'] = count($businessTeamData) ?? 0;

View File

@ -438,6 +438,8 @@ class PolicyTransactionController extends BaseController
'bp_cgst' => $data['cgst'][$index] ?? 0, 'bp_cgst' => $data['cgst'][$index] ?? 0,
'tp_amt' => $data['tp_premium'][$index] ?? 0, 'tp_amt' => $data['tp_premium'][$index] ?? 0,
'tep_amt' => $data['ter_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_amt' => $data['agreed_amount'][$index] ?? 0,
'agreed_bp_per' => $data['agreed_bp'][$index] ?? 0, 'agreed_bp_per' => $data['agreed_bp'][$index] ?? 0,
'agreed_tp_per' => $data['agreed_tp'][$index] ?? 0, 'agreed_tp_per' => $data['agreed_tp'][$index] ?? 0,

View File

@ -66,6 +66,8 @@ class PTCOShareDetailsModel extends Model
'statement_id', 'statement_id',
'follower_policy_no', 'follower_policy_no',
'non_comm_per_amt', 'non_comm_per_amt',
'cotp_amt',
'cotep_amt',
]; ];
public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id) public function getNonReconcileredPolicyTransactions(string $insurer_id,string $insurer_branch_id)

View File

@ -318,6 +318,280 @@ class PolicyTransactionModel extends Model
// BDS Report NEW Functin for QUERY // BDS Report NEW Functin for QUERY
// public function getBDSReportList($client_id, $policy_id, $branch_id, $issuer) // 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) 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, vehicle.vehicle_no,
tpa.name as tpa_name, tpa.name as tpa_name,
pt_co_share_details.remark as remarks, 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.exp_amt,
pt_co_share_details.id as pt_id, pt_co_share_details.id as pt_id,
sales_user.first_name as salse_person_name, sales_user.first_name as salse_person_name,
service_user.first_name as service_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, DATEDIFF(policy_transaction.policy_end_date, CURDATE()) AS days,
@ -591,9 +865,89 @@ class PolicyTransactionModel extends Model
return $result; 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) 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') $builder = $this->db->table('policy_transaction')
->select(' ->select('
policy_transaction.*, policy_transaction.*,
@ -619,60 +973,45 @@ class PolicyTransactionModel extends Model
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
->where('policy_transaction.action_type', 'inception'); ->where('policy_transaction.action_type', 'inception');
if ($start_date != 0 && $end_date != 0 && $date_type != 0) { // Optimize Date Filtering
if (!empty($start_date) && !empty($end_date) && !empty($date_type)) {
$startDate = date('Y-m-d 00:00:00', strtotime($start_date)); $builder->where("policy_transaction.$date_type >=", date('Y-m-d 00:00:00', strtotime($start_date)))
$endDate = date('Y-m-d 23:59:59', strtotime($end_date)); ->where("policy_transaction.$date_type <=", 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) { // Apply Filters Only When Necessary
if (!empty($client_id)) {
$builder->where('policy_transaction.client_id', $client_id); $builder->where('policy_transaction.client_id', $client_id);
} }
if (!empty($insurer_id)) {
if ($insurer_id != 0) {
$builder->where('policy_transaction.insurer_id', $insurer_id); $builder->where('policy_transaction.insurer_id', $insurer_id);
} }
if (!empty($policy_type_id)) {
if ($policy_type_id != 0) {
$builder->where('client_policy.policy_type_id', $policy_type_id); $builder->where('client_policy.policy_type_id', $policy_type_id);
} }
if (!empty($issuer)) {
if ($issuer != 0) {
$builder->where('policy_transaction.issuer', $issuer); $builder->where('policy_transaction.issuer', $issuer);
} }
if ($status != 0) { if (!empty($status)) {
$builder->where('policy_transaction.status', $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')); $fromDate = date('Y-m-d', strtotime('-30 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
->where('policy_transaction.created_at <=', $toDate); ->where('policy_transaction.created_at <=', $toDate);
} }
// Optimize Query Execution
$builder->orderBy('policy_transaction.id', 'desc'); $builder->orderBy('policy_transaction.id', 'desc');
$result = $builder->get()->getResultArray(); return $builder->get()->getResultArray();
// dd($this->db->getLastQuery());
return $result;
} }
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) 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)
{ {
// dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status); // dd($start_date, $end_date, $client_id, $insurer_id, $policy_type_id, $date_type, $issuer, $status);
@ -762,7 +1101,7 @@ class PolicyTransactionModel extends Model
pt_co_share_details.exp_amt, pt_co_share_details.exp_amt,
pt_co_share_details.variance, 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( ROUND(
( (
SELECT SELECT
@ -780,7 +1119,7 @@ class PolicyTransactionModel extends Model
) AS statement_premium, ) AS statement_premium,
COALESCE( 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( COALESCE(
( (

View File

@ -202,6 +202,7 @@ table.dataTable thead th {
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -232,7 +232,6 @@ table.dataTable tbody td {
document.addEventListener("DOMContentLoaded", init); document.addEventListener("DOMContentLoaded", init);
function init() { function init() {
const table = document.getElementById("tickets-table"); const table = document.getElementById("tickets-table");
let activeDropdown = null; let activeDropdown = null;
@ -264,8 +263,21 @@ function init() {
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; 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; 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; return customDropdown;
} }
@ -287,11 +299,15 @@ function init() {
} }
function handleItemClick(e, item) { function handleItemClick(e, item) {
const onclickAttr = item.getAttribute('onclick'); e.preventDefault();
// Execute the stored onclick handler
const onclickAttr = item.getAttribute('data-onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);
} }
// Handle href navigation
const href = item.getAttribute('href'); const href = item.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') {
window.location.href = href; window.location.href = href;

View File

@ -1,9 +1,9 @@
<div class="tab-pane fade" id="enrollment-dash-tab"> <div class="tab-pane fade" id="enrollment-dash-tab">
<div class="row visa_status_count_view"> <div class="row visa_status_count_view">
<div class="col-12"> <div class="col-12">
<div class="card" style="border: 0px;height: 470px;"> <div class="card" style="border: 0px;height: 470px;">
<div class="card-body status-option" id="statusContent" style="padding: 0.5rem !important;background-color: white;"> <div class="card-body status-option" id="statusContent"
style="padding: 0.5rem !important;background-color: white;">
<!-- Search Input Field --> <!-- Search Input Field -->
<div class="row"> <div class="row">
<div class="col-3"> <div class="col-3">
@ -14,7 +14,8 @@
</div> </div>
<div class="col-5"></div> <div class="col-5"></div>
<div class="col-4"> <div class="col-4">
<input type="text" id="searchInput" class="search-input" placeholder="Search by client or branch"> <input type="text" id="searchInput" class="search-input"
placeholder="Search by client or branch">
</div> </div>
</div> </div>
<!-- Carousel Structure --> <!-- Carousel Structure -->
@ -25,32 +26,42 @@
$currentItem = 0; // Counter for items $currentItem = 0; // Counter for items
$isActive = true; // Variable to set the first item as active $isActive = true; // Variable to set the first item as active
foreach ($client_branch_emp_list as $clients) { foreach ($client_branch_emp_list as $clients) {
foreach ($clients['branches'] as $branches) {
// Start a new carousel item if needed // Start a new carousel item if needed
if ($currentItem % $itemsPerSlide == 0) { if ($currentItem % $itemsPerSlide == 0) {
if (!$isActive) echo '</div>'; // Close previous carousel item if (!$isActive) echo '</div>'; // Close previous carousel item
echo '<div class="carousel-item' . ($isActive ? ' active' : '') . '">'; echo '<div class="carousel-item' . ($isActive ? ' active' : '') . '">';
$isActive = false; $isActive = false;
} }
if(count($branches['client_policies']) != 0){ ?> ?>
<!-- New Card Layout for each item --> <!-- New Card Layout for each item -->
<div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="<?php echo $clients['short_name']; ?>" data-branch="<?php echo $branches['branch_name']; ?>"> <div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item"
data-client="<?php echo $clients['short_name']; ?>"
data-branch="<?php echo $clients['branch_name']; ?>">
<div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);"> <div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<div class="card-header add_card_background_random" > <div class="card-header add_card_background_random">
<div class="row"> <div class="row">
<div class="col-8 emp-count-view-click" > <div class="col-8 emp-count-view-click">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="w-100 " > <div class="w-100 ">
<h3 class="my-2 py-1" ><span data-plugin="counterup" style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;" onclick="enrollment_list(this, 'emp_count_view_click')"><?php echo isset($branches['employees']) ? count($branches['employees']) : '0'; ?></span></h3> <h3 class="my-2 py-1"><span data-plugin="counterup"
style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;"
onclick="enrollment_list(this, 'emp_count_view_click')"><?php echo isset($clients['total_employees']) ? $clients['total_employees'] : '0'; ?></span>
</h3>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-12 emp-count-view-click" > <div class="col-12 emp-count-view-click">
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="w-100" > <div class="w-100">
<h5 class="mt-0 text-truncate" title="Branch Info" style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;"><?php echo isset($clients['short_name']) ? $clients['short_name'] : 'N/A'; ?> - <?php echo isset($branches['branch_name']) ? $branches['branch_name'] : 'N/A'; ?></h5> <h5 class="mt-0 text-truncate" title="Branch Info"
style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;">
<?php echo isset($clients['short_name']) ? $clients['short_name'] : 'N/A'; ?>
-
<?php echo isset($clients['branch_name']) ? $clients['branch_name'] : 'N/A'; ?>
</h5>
</div> </div>
</div> </div>
</div> </div>
@ -66,27 +77,42 @@
</div> --> </div> -->
</div> </div>
</div> </div>
<div class="card-body" > <div class="card-body">
<input type="text" class="client_id" value="<?php echo $clients['client_id']; ?>" hidden> <input type="text" class="client_id"
<input type="text" class="client_branch_id" value="<?php echo $branches['client_branch_id'] ?>" hidden> value="<?php echo $clients['client_id']; ?>" hidden>
<input type="text" class="client_branch_id"
value="<?php echo $clients['client_branch_id'] ?>" hidden>
<div class="row emp-status" style="margin-top: -9px;"> <div class="row emp-status" style="margin-top: -9px;">
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click">
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_logged_in_view_click')"><?php echo isset($branches['emp_login']) ? $branches['emp_login'] : '0'; ?></span><br> <span style="font-size: large;color: black !important;"
<span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span> class="number_css"
onclick="enrollment_list(this, 'emp_logged_in_view_click')"><?php echo isset($clients['logged_in_count']) ? $clients['logged_in_count'] : '0'; ?></span><br>
<span class="text-nowrap "
style="color: currentColor;font-size: 15px;">Logged-In</span>
</div> </div>
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click">
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"><?php echo isset($branches['emp_login']) ? count($branches['employees']) - $branches['emp_login'] : '0'; ?></span><br> <span style="font-size: large;color: black !important;"
<span class="text-nowrap" style="color: currentColor;font-size: 15px;margin-left: -13px;">Not Logged-In</span> class="number_css"
onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"><?php echo isset($clients['not_logged_in_count']) ? $clients['not_logged_in_count'] : '0'; ?></span><br>
<span class="text-nowrap"
style="color: currentColor;font-size: 15px;margin-left: -13px;">Not
Logged-In</span>
</div> </div>
</div> </div>
<div class="row emp-status" style="margin-top: 5px;"> <div class="row emp-status" style="margin-top: 5px;">
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click">
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_enrolled_view_click')"><?php echo isset($branches['emp_enroll']) ? count($branches['employees']) - $branches['emp_enroll'] : '0'; ?></span><br> <span style="font-size: large;color: black !important;"
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span> class="number_css"
onclick="enrollment_list(this, 'emp_not_enrolled_view_click')"><?php echo isset($clients['draft_count']) ? $clients['draft_count'] : '0'; ?></span><br>
<span class="text-nowrap"
style="color: currentColor;font-size: 15px;">Draft</span>
</div> </div>
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click">
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_enrolled_view_click')"><?php echo isset($branches['emp_enroll']) ? $branches['emp_enroll'] : '0'; ?></span><br> <span style="font-size: large;color: black !important;"
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span> class="number_css"
onclick="enrollment_list(this, 'emp_enrolled_view_click')"><?php echo isset($clients['enrolled_count']) ? $clients['enrolled_count'] : '0'; ?></span><br>
<span class="text-nowrap"
style="color: currentColor;font-size: 15px;">Enrolled</span>
</div> </div>
</div> </div>
</div> </div>
@ -94,20 +120,31 @@
</div> </div>
<?php <?php
$currentItem++; $currentItem++;
}
}
} }
if ($currentItem % $itemsPerSlide != 0) echo '</div>'; // Close the last carousel item if ($currentItem % $itemsPerSlide != 0) echo '</div>'; // Close the last carousel item
?> ?>
</div> </div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev"> <a class="carousel-control-prev" href="#carouselExampleControls" role="button"
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" style="width: 28px;"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/></svg> <!-- <img src="<?php echo base_url()?>public/assets/images/left_arrow.png" alt="<"> --> data-slide="prev">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" style="width: 28px;">
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path
d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z" />
</svg>
<!-- <img src="<?php echo base_url() ?>public/assets/images/left_arrow.png" alt="<"> -->
<!-- <span class="carousel-control-prev-icon" aria-hidden="true"></span> --> <!-- <span class="carousel-control-prev-icon" aria-hidden="true"></span> -->
<span class="sr-only">Previous</span> <span class="sr-only">Previous</span>
</a> </a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next"> <a class="carousel-control-next" href="#carouselExampleControls" role="button"
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" style="width: 28px;"><!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z"/></svg> data-slide="next">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" style="width: 28px;">
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path
d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z" />
</svg>
<!-- <span class="carousel-control-next-icon" aria-hidden="true"></span> --> <!-- <span class="carousel-control-next-icon" aria-hidden="true"></span> -->
<span class="sr-only">Next</span> <span class="sr-only">Next</span>
</a> </a>
@ -119,7 +156,8 @@
</div> </div>
<script> <script>
$(document).ready(function() {
$(document).ready(function() {
var lastDirection = ''; // Variable to keep track of the last direction var lastDirection = ''; // Variable to keep track of the last direction
// Scroll functionality // Scroll functionality
@ -224,10 +262,73 @@ $(document).ready(function() {
// Initial check for empty carousel items // Initial check for empty carousel items
checkEmptyCarouselItem(); checkEmptyCarouselItem();
}); });
document.addEventListener('DOMContentLoaded', function() {
random_color_set();
});
function enrollment_list(current_element, type) { $('#enrollment_status_open_close').change(function() {
if ($(this).val() === 'open') {
var enrollment_data = '<?php echo addslashes(json_encode($client_branch_emp_list, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT)); ?>';
console.log('Raw enrollment_data:', enrollment_data);
try {
// Ensure enrollment_data is not empty or invalid
if (!enrollment_data || enrollment_data === 'null' || enrollment_data === '""') {
throw new Error('Invalid JSON data received.');
}
// Parse JSON data
var data = JSON.parse(enrollment_data);
console.log('Parsed data:', data);
// Ensure parsed data is always treated as an array
if (!Array.isArray(data)) {
data = data && typeof data === 'object' ? [data] : [];
}
console.log('Final client_branch_emp_list:', data);
updateCarouselWithData(data, 1);
} catch (error) {
console.error('Error parsing JSON:', error.message, error);
}
} else {
// Fetch the session data from PHP
var enrollment_data = '<?php echo addslashes(json_encode($client_branch_emp_list, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT)); ?>';
console.log('Raw enrollment_data:', enrollment_data);
try {
// Ensure enrollment_data is valid before parsing
if (!enrollment_data || enrollment_data === 'null' || enrollment_data === '""') {
throw new Error('Invalid JSON data received.');
}
// Parse JSON data
var data = JSON.parse(enrollment_data);
console.log('Parsed data:', data);
// Ensure `data` is always an array
data = Array.isArray(data) ? data : (data && typeof data === 'object' ? [data] : []);
console.log('Final client_branch_emp_list:', data);
updateCarouselWithData(data, 2);
} catch (error) {
console.error('Error parsing JSON:', error.message, error);
}
}
});
function enrollment_list(current_element, type) {
var clientId = $(current_element).closest('.carousel-slide-item').find('.client_id').val(); var clientId = $(current_element).closest('.carousel-slide-item').find('.client_id').val();
var branchId = $(current_element).closest('.carousel-slide-item').find('.client_branch_id').val(); var branchId = $(current_element).closest('.carousel-slide-item').find('.client_branch_id').val();
@ -242,82 +343,9 @@ function enrollment_list(current_element, type) {
// Redirect to the constructed URL with parameters // Redirect to the constructed URL with parameters
window.location.href = `${url}?${params.toString()}`; window.location.href = `${url}?${params.toString()}`;
}
$('#enrollment_status_open_close').change(function () {
if ($(this).val() === 'open') {
var enrollment_data = '<?php echo addslashes($_SESSION['enrollment_data']); ?>';
try {
// Parse JSON data
var data = JSON.parse(enrollment_data);
console.log('Parsed data:', data);
// Ensure data is an object and client_branch_emp_list is treated as an array
if (data && typeof data === 'object') {
if (Array.isArray(data.client_branch_emp_list)) {
console.log('client_branch_emp_list:', data.client_branch_emp_list);
updateCarouselWithData(data, 1);
} else {
// Convert client_branch_emp_list to an array if it's not already
if (data.client_branch_emp_list && typeof data.client_branch_emp_list === 'object') {
// If it's an object but not an array, wrap it in an array
data.client_branch_emp_list = [data.client_branch_emp_list];
} else {
// Handle the case where it's neither an array nor an object
console.error('client_branch_emp_list is not an array or object:', data.client_branch_emp_list);
data.client_branch_emp_list = []; // Ensure it is at least an empty array
} }
console.log('Converted client_branch_emp_list:', data.client_branch_emp_list); function updateCarouselWithData(data, open_close) {
updateCarouselWithData(data, 1);
}
} else {
console.error('Parsed data is not an object:', data);
}
} catch (e) {
console.error('Error parsing JSON:', e);
}
} else {
// Fetch the session data from PHP
var enrollment_data = '<?php echo addslashes($_SESSION['enrollment_data']); ?>';
try {
// Parse JSON data
var data = JSON.parse(enrollment_data);
console.log('Parsed data:', data);
// Ensure data is an object and client_branch_emp_list is treated as an array
if (data && typeof data === 'object') {
if (Array.isArray(data.client_branch_emp_list)) {
console.log('client_branch_emp_list:', data.client_branch_emp_list);
updateCarouselWithData(data, 2);
} else {
// Convert client_branch_emp_list to an array if it's not already
if (data.client_branch_emp_list && typeof data.client_branch_emp_list === 'object') {
// If it's an object but not an array, wrap it in an array
data.client_branch_emp_list = [data.client_branch_emp_list];
} else {
// Handle the case where it's neither an array nor an object
console.error('client_branch_emp_list is not an array or object:', data.client_branch_emp_list);
data.client_branch_emp_list = []; // Ensure it is at least an empty array
}
console.log('Converted client_branch_emp_list:', data.client_branch_emp_list);
updateCarouselWithData(data, 2);
}
} else {
console.error('Parsed data is not an object:', data);
}
} catch (e) {
console.error('Error parsing JSON:', e);
}
}
});
function updateCarouselWithData(data, open_close) {
var itemsPerSlide = 3; // Number of items per slide var itemsPerSlide = 3; // Number of items per slide
var currentItem = 0; // Counter for items var currentItem = 0; // Counter for items
var isActive = true; // Variable to set the first item as active var isActive = true; // Variable to set the first item as active
@ -327,10 +355,11 @@ function updateCarouselWithData(data, open_close) {
carouselInner.empty(); carouselInner.empty();
// Check if data.client_branch_emp_list is valid // Check if data.client_branch_emp_list is valid
if (Array.isArray(data.client_branch_emp_list) && data.client_branch_emp_list.length > 0) { if (Array.isArray(data) && data.length > 0) {
console.log("Processing array...");
console.log("Processing array........................................");
// Handle the case where data.client_branch_emp_list is an array // Handle the case where data.client_branch_emp_list is an array
var items = data.client_branch_emp_list[0]; var items = data[0];
console.log("Items data:", items); console.log("Items data:", items);
// Convert items object to an array // Convert items object to an array
@ -338,17 +367,15 @@ function updateCarouselWithData(data, open_close) {
// Validate if client_list is an array // Validate if client_list is an array
if (Array.isArray(client_list)) { if (Array.isArray(client_list)) {
console.log(client_list); console.log(client_list);
for (var i = 0; i < client_list.length; i++) {
var client = client_list[i];
// console.log(item.branches);
var branch_list = client.branches;
for (var j = 0; j < branch_list.length; j++) {
var branch = branch_list[j];
console.log(branch);
if(open_close == 1){ for (var i = 0; i < data.length; i++) {
if(branch.client_policies.length > 0){
let client = data[i];
if (open_close == 1 && client.open_or_close_enrollment == 1) {
if (currentItem % itemsPerSlide === 0) { if (currentItem % itemsPerSlide === 0) {
if (!isActive) carouselInner.append('</div>'); // Close previous carousel item if (!isActive) carouselInner.append('</div>'); // Close previous carousel item
carouselInner.append('<div class="carousel-item' + (isActive ? ' active' : '') + '">'); carouselInner.append('<div class="carousel-item' + (isActive ? ' active' : '') + '">');
@ -356,14 +383,14 @@ function updateCarouselWithData(data, open_close) {
} }
// Generate HTML for each item // Generate HTML for each item
var itemHtml = ` var itemHtml = `
<div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="${client.short_name}" data-branch="${branch.branch_name }"> <div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="${client.short_name}" data-branch="${client.branch_name }">
<div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);"> <div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<div class="card-header add_card_background_random" > <div class="card-header add_card_background_random" >
<div class="row"> <div class="row">
<div class="col-8 emp-count-view-click" > <div class="col-8 emp-count-view-click" >
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="w-100 " > <div class="w-100 " >
<h3 class="my-2 py-1" ><span data-plugin="counterup" style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;" onclick="enrollment_list(this, 'emp_count_view_click')">${branch.employees.length}</span></h3> <h3 class="my-2 py-1" ><span data-plugin="counterup" style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;" onclick="enrollment_list(this, 'emp_count_view_click')">${client.total_employees}</span></h3>
</div> </div>
</div> </div>
</div> </div>
@ -372,7 +399,7 @@ function updateCarouselWithData(data, open_close) {
<div class="col-12 emp-count-view-click" > <div class="col-12 emp-count-view-click" >
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="w-100" > <div class="w-100" >
<h5 class="mt-0 text-truncate" title="Branch Info" style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;">${client.short_name} - ${branch.branch_name} </h5> <h5 class="mt-0 text-truncate" title="Branch Info" style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;">${client.short_name} - ${client.branch_name} </h5>
</div> </div>
</div> </div>
</div> </div>
@ -390,24 +417,24 @@ function updateCarouselWithData(data, open_close) {
</div> </div>
<div class="card-body" > <div class="card-body" >
<input type="text" class="client_id" value="${client.client_id}" hidden> <input type="text" class="client_id" value="${client.client_id}" hidden>
<input type="text" class="client_branch_id" value="${branch.client_branch_id}" hidden> <input type="text" class="client_branch_id" value="${client.client_branch_id}" hidden>
<div class="row emp-status" style="margin-top: -9px;"> <div class="row emp-status" style="margin-top: -9px;">
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_logged_in_view_click')">${branch.emp_login}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_logged_in_view_click')">${client.logged_in_count ?? 0}</span><br>
<span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span> <span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span>
</div> </div>
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"> ${branch.employees.length - (branch.emp_login || 0)}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"> ${client.not_logged_in_count ?? 0}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;margin-left: -13px;">Not Logged-In</span> <span class="text-nowrap" style="color: currentColor;font-size: 15px;margin-left: -13px;">Not Logged-In</span>
</div> </div>
</div> </div>
<div class="row emp-status" style="margin-top: 5px;"> <div class="row emp-status" style="margin-top: 5px;">
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_enrolled_view_click')">${branch.employees.length - (branch.emp_enroll || 0)}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_enrolled_view_click')">${client.draft_count ?? 0}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span> <span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span>
</div> </div>
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_enrolled_view_click')">${(branch.emp_enroll || 0)}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_enrolled_view_click')">${(client.enrolled_count ?? 0)}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span> <span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div> </div>
</div> </div>
@ -418,9 +445,9 @@ function updateCarouselWithData(data, open_close) {
carouselInner.find('.carousel-item').last().append(itemHtml); carouselInner.find('.carousel-item').last().append(itemHtml);
currentItem++; currentItem++;
}
}else{ } else {
if(branch.client_policies.length == 0){
if (currentItem % itemsPerSlide === 0) { if (currentItem % itemsPerSlide === 0) {
if (!isActive) carouselInner.append('</div>'); // Close previous carousel item if (!isActive) carouselInner.append('</div>'); // Close previous carousel item
carouselInner.append('<div class="carousel-item' + (isActive ? ' active' : '') + '">'); carouselInner.append('<div class="carousel-item' + (isActive ? ' active' : '') + '">');
@ -428,14 +455,14 @@ function updateCarouselWithData(data, open_close) {
} }
// Generate HTML for each item // Generate HTML for each item
var itemHtml = ` var itemHtml = `
<div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="${client.short_name}" data-branch="${branch.branch_name }"> <div class="col-xl-3 col-md-6 d-inline-block scroll-item carousel-slide-item" data-client="${client.short_name}" data-branch="${client.branch_name }">
<div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);"> <div class="card" style="box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);">
<div class="card-header add_card_background_random" > <div class="card-header add_card_background_random" >
<div class="row"> <div class="row">
<div class="col-8 emp-count-view-click" > <div class="col-8 emp-count-view-click" >
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="w-100 " > <div class="w-100 " >
<h3 class="my-2 py-1" ><span data-plugin="counterup" style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;" onclick="enrollment_list(this, 'emp_count_view_click')">${branch.employees.length}</span></h3> <h3 class="my-2 py-1" ><span data-plugin="counterup" style="font-size: 2.0rem;background-color: white;border-radius: 6px;height: 30;padding: 4px 11px 4px 11px;" onclick="enrollment_list(this, 'emp_count_view_click')">${client.total_employees}</span></h3>
</div> </div>
</div> </div>
</div> </div>
@ -444,7 +471,7 @@ function updateCarouselWithData(data, open_close) {
<div class="col-12 emp-count-view-click" > <div class="col-12 emp-count-view-click" >
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<div class="w-100" > <div class="w-100" >
<h5 class="mt-0 text-truncate" title="Branch Info" style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;">${client.short_name} - ${branch.branch_name} </h5> <h5 class="mt-0 text-truncate" title="Branch Info" style="font-weight: 400 !important;font-size: 20px !important;line-height: 36px;color: black !important;">${client.short_name} - ${client.branch_name} </h5>
</div> </div>
</div> </div>
</div> </div>
@ -462,24 +489,24 @@ function updateCarouselWithData(data, open_close) {
</div> </div>
<div class="card-body" > <div class="card-body" >
<input type="text" class="client_id" value="${client.client_id}" hidden> <input type="text" class="client_id" value="${client.client_id}" hidden>
<input type="text" class="client_branch_id" value="${branch.client_branch_id}" hidden> <input type="text" class="client_branch_id" value="${client.client_branch_id}" hidden>
<div class="row emp-status" style="margin-top: -9px;"> <div class="row emp-status" style="margin-top: -9px;">
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_logged_in_view_click')">${branch.emp_login}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_logged_in_view_click')">${client.logged_in_count}</span><br>
<span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span> <span class="text-nowrap " style="color: currentColor;font-size: 15px;">Logged-In</span>
</div> </div>
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"> ${branch.employees.length - (branch.emp_login || 0)}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_logged_in_view_click')"> ${client.not_logged_in_count ?? 0}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;margin-left: -13px;">Not Logged-In</span> <span class="text-nowrap" style="color: currentColor;font-size: 15px;margin-left: -13px;">Not Logged-In</span>
</div> </div>
</div> </div>
<div class="row emp-status" style="margin-top: 5px;"> <div class="row emp-status" style="margin-top: 5px;">
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_enrolled_view_click')">${branch.employees.length - (branch.emp_enroll || 0)}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_not_enrolled_view_click')">${client.draft_count ?? 0}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span> <span class="text-nowrap" style="color: currentColor;font-size: 15px;">Draft</span>
</div> </div>
<div class="col-6 emp-count-view-click" > <div class="col-6 emp-count-view-click" >
<span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_enrolled_view_click')">${(branch.emp_enroll || 0)}</span><br> <span style="font-size: large;color: black !important;" class="number_css" onclick="enrollment_list(this, 'emp_enrolled_view_click')">${(client.enrolled_count ?? 0)}</span><br>
<span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span> <span class="text-nowrap" style="color: currentColor;font-size: 15px;">Enrolled</span>
</div> </div>
</div> </div>
@ -490,39 +517,32 @@ function updateCarouselWithData(data, open_close) {
carouselInner.find('.carousel-item').last().append(itemHtml); carouselInner.find('.carousel-item').last().append(itemHtml);
currentItem++; currentItem++;
} }
}
}
// Create a new carousel item every `itemsPerSlide` items
} }
// Close the last carousel item if it was opened // Close the last carousel item if it was opened
if (currentItem % itemsPerSlide !== 0) carouselInner.append('</div>'); if (currentItem % itemsPerSlide !== 0) carouselInner.append('</div>');
} else { } else {
console.error('Expected an array for items, but got:', client_list); console.error('Expected an array for items, but got:', client_list);
} }
} else if (typeof data.client_branch_emp_list === 'object') {
console.error('client_branch_emp_list is an object, not an array:', data.client_branch_emp_list); } else if (typeof data === 'object') {
console.error('client_branch_emp_list is an object, not an array:', data);
} else { } else {
console.error('client_branch_emp_list is missing or not in the expected format:', data.client_branch_emp_list); console.error('client_branch_emp_list is missing or not in the expected format:', data);
} }
random_color_set(); random_color_set();
// Initialize or refresh carousel if needed // Initialize or refresh carousel if needed
$('#carouselExampleControls').carousel('dispose').carousel(); $('#carouselExampleControls').carousel('dispose'); // Properly dispose of the instance
} $('#carouselExampleControls').carousel(); // Reinitialize it
}
document.addEventListener('DOMContentLoaded', function() { function random_color_set() {
random_color_set();
});
function remove_empty_carousel() {
}
function random_color_set() {
// Array of predefined colors // Array of predefined colors
var colors = ['#EBE8FF', '#FFECE5', '#FFE8F5']; var colors = ['#EBE8FF', '#FFECE5', '#FFE8F5'];
// '#6ADBE3' // '#6ADBE3'
@ -548,6 +568,6 @@ function random_color_set() {
header.style.backgroundPosition = 'center'; // Center the image within the div header.style.backgroundPosition = 'center'; // Center the image within the div
index++; index++;
}); });
} }
</script> </script>

View File

@ -133,6 +133,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Preserve click handlers and add auto-close // Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
event.preventDefault(e);
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -470,17 +470,21 @@ document.addEventListener("DOMContentLoaded", function () {
// Create custom dropdown // Create custom dropdown
function createCustomDropdown(row) { function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu'); const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null; if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML; customDropdown.innerHTML = originalDropdown.innerHTML;
// Remove inline onclick handlers and store them in data attributes
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
const originalOnclick = originalItems[index].getAttribute('onclick');
item.removeAttribute('onclick'); // Remove the inline handler
item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
});
return customDropdown; return customDropdown;
} }
@ -494,45 +498,33 @@ document.addEventListener("DOMContentLoaded", function () {
document.body.appendChild(customDropdown); document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) { row.addEventListener("click", function(event) {
// Ignore clicks on the action column // Ignore clicks on the first column
if (event.target.closest('td:last-child')) { if (event.target.closest('td:first-child')) return;
return;
}
// Hide any active dropdown if (activeDropdown) activeDropdown.style.display = 'none';
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block'; customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed'; customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`; customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown; activeDropdown = customDropdown;
event.stopPropagation(); event.stopPropagation();
}); });
// Handle custom dropdown clicks
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick'); e.preventDefault();
if (onclickAttr) {
eval(onclickAttr);
}
// Execute the original onclick from data attribute
const onclickAttr = this.getAttribute('data-onclick');
if (onclickAttr) eval(onclickAttr);
// Handle href navigation
const href = this.getAttribute('href'); const href = this.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') window.location.href = href;
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
activeDropdown = null; activeDropdown = null;
@ -543,7 +535,7 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
}); });
// Close dropdown when clicking outside // Close dropdown on outside click
document.addEventListener("click", function() { document.addEventListener("click", function() {
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';

View File

@ -129,6 +129,7 @@
// Preserve click handlers and add auto-close // Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -362,23 +362,26 @@ custom-dropdown-menu {
<?php include('policy_transaction_endorsement_form.php'); ?> <?php include('policy_transaction_endorsement_form.php'); ?>
<script> <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table"); const table = document.getElementById("tickets-table");
// Create custom dropdown // Create custom dropdown
function createCustomDropdown(row) { function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu'); const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null; if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML; customDropdown.innerHTML = originalDropdown.innerHTML;
// Remove inline onclick handlers and store them in data attributes
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
const originalOnclick = originalItems[index].getAttribute('onclick');
item.removeAttribute('onclick'); // Remove the inline handler
item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
});
return customDropdown; return customDropdown;
} }
@ -392,45 +395,34 @@ document.addEventListener("DOMContentLoaded", function () {
document.body.appendChild(customDropdown); document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) { row.addEventListener("click", function(event) {
// Ignore clicks on the action column // Ignore clicks on the first column
if (event.target.closest('td:last-child')) { if (event.target.closest('td:first-child')) return;
return;
}
// Hide any active dropdown if (activeDropdown) activeDropdown.style.display = 'none';
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block'; customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed'; customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`; customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown; activeDropdown = customDropdown;
event.stopPropagation(); event.stopPropagation();
}); });
// Preserve click handlers and add auto-close // Handle custom dropdown clicks
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick'); e.preventDefault();
if (onclickAttr) {
eval(onclickAttr);
}
// Execute the original onclick from data attribute
const onclickAttr = this.getAttribute('data-onclick');
if (onclickAttr) eval(onclickAttr);
// Handle href navigation
const href = this.getAttribute('href'); const href = this.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') window.location.href = href;
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
activeDropdown = null; activeDropdown = null;
@ -441,7 +433,7 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
}); });
// Close dropdown when clicking outside // Close dropdown on outside click
document.addEventListener("click", function() { document.addEventListener("click", function() {
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';

File diff suppressed because it is too large Load Diff

View File

@ -1254,7 +1254,7 @@ $('#issue_type').change(function(){
let value = $(this).val() let value = $(this).val()
if(value == 1){ if(value == 1){
$('#revenue_type').val('NA'); $('#revenue_type').val('');
$('#revenue_type option[value="NA"]').show(); $('#revenue_type option[value="NA"]').show();
$('#revenue_type option[value="EANR"]').show(); $('#revenue_type option[value="EANR"]').show();
$('#revenue_type option[value="EA"]').hide(); $('#revenue_type option[value="EA"]').hide();

View File

@ -177,6 +177,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Preserve click handlers // Preserve click handlers
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

View File

@ -420,17 +420,21 @@ document.addEventListener("DOMContentLoaded", function () {
// Create custom dropdown // Create custom dropdown
function createCustomDropdown(row) { function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu'); const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null; if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div'); const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu'; customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML; customDropdown.innerHTML = originalDropdown.innerHTML;
// Remove inline onclick handlers and store them in data attributes
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
const originalOnclick = originalItems[index].getAttribute('onclick');
item.removeAttribute('onclick'); // Remove the inline handler
item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
});
return customDropdown; return customDropdown;
} }
@ -444,45 +448,34 @@ document.addEventListener("DOMContentLoaded", function () {
document.body.appendChild(customDropdown); document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) { row.addEventListener("click", function(event) {
// Ignore clicks on the first column (td:first-child) // Ignore clicks on the first column
if (event.target.closest('td:first-child')) { if (event.target.closest('td:first-child')) return;
return;
}
// Hide any active dropdown if (activeDropdown) activeDropdown.style.display = 'none';
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block'; customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed'; customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`; customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown; activeDropdown = customDropdown;
event.stopPropagation(); event.stopPropagation();
}); });
// Preserve click handlers and add auto-close // Handle custom dropdown clicks
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick'); e.preventDefault();
if (onclickAttr) {
eval(onclickAttr);
}
// Execute the original onclick from data attribute
const onclickAttr = this.getAttribute('data-onclick');
if (onclickAttr) eval(onclickAttr);
// Handle href navigation
const href = this.getAttribute('href'); const href = this.getAttribute('href');
if (href && href !== '#') { if (href && href !== '#') window.location.href = href;
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';
activeDropdown = null; activeDropdown = null;
@ -493,7 +486,7 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
}); });
// Close dropdown when clicking outside // Close dropdown on outside click
document.addEventListener("click", function() { document.addEventListener("click", function() {
if (activeDropdown) { if (activeDropdown) {
activeDropdown.style.display = 'none'; activeDropdown.style.display = 'none';

View File

@ -128,6 +128,7 @@ document.addEventListener("DOMContentLoaded", function () {
// Preserve click handlers and add auto-close // Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => { customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) { item.addEventListener('click', function(e) {
e.preventDefault();
const onclickAttr = this.getAttribute('onclick'); const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) { if (onclickAttr) {
eval(onclickAttr); eval(onclickAttr);

11
writable/cache/.gitkeep vendored Executable file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>