CHANGE_NEW_BDS_REPORT
This commit is contained in:
parent
15d272efb1
commit
9f6dd050fd
@ -500,7 +500,7 @@
|
|||||||
$data['calc_policy_issue_date'][$index] = change_date_format($data['calc_policy_issue_date'][$index]);
|
$data['calc_policy_issue_date'][$index] = change_date_format($data['calc_policy_issue_date'][$index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$co_share_type_value = $data['co_share'] == 1 ? $data['co_share_type'][$index] ?? 1 : 1;
|
$co_share_type_value = (($data['co_share'] ?? 0) == 1) ? ($data['co_share_type'][$index] ?? 1) : 1;
|
||||||
|
|
||||||
// Prepare each co-share detail entry
|
// Prepare each co-share detail entry
|
||||||
$coShareDetails[] = [
|
$coShareDetails[] = [
|
||||||
|
|||||||
@ -593,7 +593,7 @@
|
|||||||
// return $result;
|
// 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, $user_id = 0, $where = [])
|
public function getBDSReportList1($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, $user_id = 0, $where = [])
|
||||||
{
|
{
|
||||||
|
|
||||||
$date_condition = '';
|
$date_condition = '';
|
||||||
@ -652,7 +652,7 @@
|
|||||||
|
|
||||||
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_velmurugan,
|
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_velmurugan,
|
||||||
|
|
||||||
ROUND(COALESCE(tep_gst_amt, 0) + COALESCE(bp_gst_amt, 0) + COALESCE(tp_amt, 0),2) AS gst_amount,
|
ROUND(COALESCE(tep_gst_amt, 0) + COALESCE(bp_gst_amt, 0) + COALESCE(tp_gst_amt, 0),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) +
|
ROUND(ROUND(pt_co_share_details.cop_amt + pt_co_share_details.cotp_amt + pt_co_share_details.cotep_amt, 2) +
|
||||||
ROUND(COALESCE(tep_gst_amt, 0) + COALESCE(bp_gst_amt, 0) + COALESCE(tp_amt, 0),2),
|
ROUND(COALESCE(tep_gst_amt, 0) + COALESCE(bp_gst_amt, 0) + COALESCE(tp_amt, 0),2),
|
||||||
@ -665,6 +665,7 @@
|
|||||||
(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_tp_per + pt_co_share_details.agreed_tep_per) AS agreed_tp_or_ter_per,
|
||||||
|
|
||||||
pt_co_share_details.agreed_bp_per,
|
pt_co_share_details.agreed_bp_per,
|
||||||
|
|
||||||
ROUND(
|
ROUND(
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
@ -686,6 +687,7 @@
|
|||||||
),
|
),
|
||||||
2
|
2
|
||||||
) AS total_irda_amt,
|
) AS total_irda_amt,
|
||||||
|
|
||||||
ROUND(
|
ROUND(
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
@ -725,7 +727,6 @@
|
|||||||
AND insurer_statements.is_active = 1
|
AND insurer_statements.is_active = 1
|
||||||
AND insurer_statements.invoice_status IS NOT NULL
|
AND insurer_statements.invoice_status IS NOT NULL
|
||||||
$date_condition
|
$date_condition
|
||||||
|
|
||||||
),
|
),
|
||||||
2
|
2
|
||||||
) AS billed_amt,
|
) AS billed_amt,
|
||||||
@ -772,7 +773,9 @@
|
|||||||
),
|
),
|
||||||
2
|
2
|
||||||
) AS unbilled_amt,
|
) AS unbilled_amt,
|
||||||
|
|
||||||
created_user.first_name as user_name,
|
created_user.first_name as user_name,
|
||||||
|
|
||||||
CASE
|
CASE
|
||||||
WHEN pt_co_share_details.co_share_type IN (0, 1)
|
WHEN pt_co_share_details.co_share_type IN (0, 1)
|
||||||
THEN policy_transaction.policy_no
|
THEN policy_transaction.policy_no
|
||||||
@ -1874,7 +1877,7 @@
|
|||||||
return $result[0];
|
return $result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reportBDSNew(
|
public function reportBDSNew1(
|
||||||
$start_date = 0,
|
$start_date = 0,
|
||||||
$end_date = 0,
|
$end_date = 0,
|
||||||
$client_id = 0,
|
$client_id = 0,
|
||||||
@ -1887,7 +1890,8 @@
|
|||||||
$client_policy_id = 0,
|
$client_policy_id = 0,
|
||||||
$user_id = 0,
|
$user_id = 0,
|
||||||
$where = []
|
$where = []
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
|
|
||||||
$date_condition = '';
|
$date_condition = '';
|
||||||
|
|
||||||
@ -2024,7 +2028,8 @@
|
|||||||
// ========================================================
|
// ========================================================
|
||||||
// GROUP BY Insurer Statement Months
|
// GROUP BY Insurer Statement Months
|
||||||
// =======================================================
|
// =======================================================
|
||||||
->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id ');
|
// ->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id ')
|
||||||
|
;
|
||||||
|
|
||||||
// ==============================
|
// ==============================
|
||||||
// ROLE-BASED FILTERS
|
// ROLE-BASED FILTERS
|
||||||
@ -2253,8 +2258,8 @@
|
|||||||
->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left')
|
->join('user_profiles AS created_user', 'policy_transaction.created_by = created_user.id', 'left')
|
||||||
|
|
||||||
|
|
||||||
->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id','left')
|
->join('co_share_stmt_details', 'pt_co_share_details.id = co_share_stmt_details.co_share_id', 'left')
|
||||||
->join('insurer_statements insurer_statements_oq','insurer_statements_oq.id = co_share_stmt_details.statement_id','left')
|
->join('insurer_statements insurer_statements_oq', 'insurer_statements_oq.id = co_share_stmt_details.statement_id', 'left')
|
||||||
|
|
||||||
->where('policy_transaction.is_active', 1)
|
->where('policy_transaction.is_active', 1)
|
||||||
->where('pt_co_share_details.is_active', 1)
|
->where('pt_co_share_details.is_active', 1)
|
||||||
@ -2266,7 +2271,8 @@
|
|||||||
// ========================================================
|
// ========================================================
|
||||||
// GROUP BY Insurer Statement Months
|
// GROUP BY Insurer Statement Months
|
||||||
// =======================================================
|
// =======================================================
|
||||||
->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id ,insurer_statements_oq.month');
|
// ->groupBy('policy_transaction.policy_no , pt_co_share_details.insurer_id ,insurer_statements_oq.month')
|
||||||
|
;
|
||||||
|
|
||||||
// ==============================
|
// ==============================
|
||||||
// ROLE-BASED FILTERS
|
// ROLE-BASED FILTERS
|
||||||
@ -2357,13 +2363,304 @@
|
|||||||
|
|
||||||
|
|
||||||
$result = $this->db->query($finalSql)->getResultArray();
|
$result = $this->db->query($finalSql)->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, $user_id = 0, $where = [])
|
||||||
|
{
|
||||||
|
|
||||||
|
$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 . "'
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
$default_date_filter = '';
|
||||||
|
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||||
|
|
||||||
|
$fromDate = date('Y-m-d', strtotime('-90 days'));
|
||||||
|
$toDate = date('Y-m-d 23:59:59');
|
||||||
|
|
||||||
|
if (empty($where)) {
|
||||||
|
|
||||||
|
$default_date_filter = "
|
||||||
|
AND pt.created_at >= '" . $fromDate . "'
|
||||||
|
AND pt.created_at <= '" . $toDate . "'
|
||||||
|
";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "
|
||||||
|
SELECT * FROM (
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
pt.id AS id,
|
||||||
|
pt.endorsement_no,
|
||||||
|
pt.ref,
|
||||||
|
DATE_FORMAT(pt.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||||
|
DATE_FORMAT(pcsd.pt_policy_issue_date, '%b %Y') AS policy_issue_month,
|
||||||
|
pt.month as statement_month,
|
||||||
|
|
||||||
|
'no statement uploaded' AS statement_uploaded,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN c.client_type = 1 THEN 'Group'
|
||||||
|
WHEN c.client_type = 2 THEN 'Retail'
|
||||||
|
ELSE '-'
|
||||||
|
END AS client_type,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN pt.revenue_type = 'NA' THEN 'Fresh'
|
||||||
|
ELSE 'Renewal'
|
||||||
|
END AS revenue_type,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN pt.action_type = 'inception' THEN 'Policy'
|
||||||
|
ELSE 'Endorsement'
|
||||||
|
END AS action_type,
|
||||||
|
|
||||||
|
c.client_name,
|
||||||
|
c.short_name AS client_short_name,
|
||||||
|
cb.branch_name AS client_branch_name,
|
||||||
|
cb.address1 AS client_address,
|
||||||
|
ptype.policy_type,
|
||||||
|
ptype.bap,
|
||||||
|
ins.name AS insurer_name,
|
||||||
|
ins.short_name AS insurer_short_name,
|
||||||
|
ib.branch_name AS insurer_branch_name,
|
||||||
|
ib.branch_code AS insurer_branch_code,
|
||||||
|
|
||||||
|
created_user.first_name AS user_name,
|
||||||
|
v.vehicle_no,
|
||||||
|
tpa.name AS tpa_name,
|
||||||
|
|
||||||
|
pcsd.remark AS remarks,
|
||||||
|
pcsd.cop_amt AS bp_amt,
|
||||||
|
pcsd.exp_amt,
|
||||||
|
pcsd.id AS pt_id,
|
||||||
|
|
||||||
|
su.first_name AS salse_person_name,
|
||||||
|
se.first_name AS service_person_name,
|
||||||
|
|
||||||
|
ROUND(pcsd.cop_amt + pcsd.cotp_amt + pcsd.cotep_amt, 2) AS premium_wo_gst,
|
||||||
|
ROUND((pcsd.cop_amt + pcsd.cotp_amt + pcsd.cotep_amt) * 0.18, 2) AS gst_amount,
|
||||||
|
ROUND((pcsd.cop_amt + pcsd.cotp_amt + pcsd.cotep_amt) * 1.18, 2) AS total_premium,
|
||||||
|
|
||||||
|
ROUND(pcsd.cotp_amt + pcsd.cotep_amt, 2) AS tp_or_ter,
|
||||||
|
DATEDIFF(pt.policy_end_date, CURDATE()) AS days,
|
||||||
|
(pcsd.agreed_tp_per + pcsd.agreed_tep_per) AS agreed_tp_or_ter_per,
|
||||||
|
pcsd.agreed_bp_per,
|
||||||
|
|
||||||
|
ROUND(pcsd.exp_amt, 2) AS total_irda_amt,
|
||||||
|
0.00 AS reward,
|
||||||
|
0.00 AS billed_amt,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN pcsd.co_share_type IN (0,1) THEN pt.policy_no
|
||||||
|
WHEN pcsd.co_share_type > 1 THEN
|
||||||
|
IFNULL(NULLIF(pcsd.follower_policy_no,''), pt.policy_no)
|
||||||
|
ELSE pt.policy_no
|
||||||
|
END AS policy_no
|
||||||
|
|
||||||
|
FROM policy_transaction pt
|
||||||
|
LEFT JOIN pt_co_share_details pcsd ON pt.id = pcsd.pt_id
|
||||||
|
JOIN clients c ON c.id = pt.client_id
|
||||||
|
LEFT JOIN client_branch cb ON pt.client_branch_id = cb.id
|
||||||
|
LEFT JOIN client_policy cp ON pt.client_policy_id = cp.id
|
||||||
|
LEFT JOIN user_profiles up ON pt.created_by = up.id
|
||||||
|
LEFT JOIN vehicle v ON pt.vehicle_id = v.id
|
||||||
|
LEFT JOIN policy_type ptype ON pt.policy_type_id = ptype.id
|
||||||
|
LEFT JOIN insurers ins ON pcsd.insurer_id = ins.id
|
||||||
|
LEFT JOIN insurer_branch ib ON pcsd.insurer_branch_id = ib.id
|
||||||
|
LEFT JOIN tpa ON pt.tpa_id = tpa.id
|
||||||
|
LEFT JOIN tpa_branch tb ON pt.tpa_branch_id = tb.id
|
||||||
|
LEFT JOIN user_profiles su ON pt.sales_generated_by = su.id
|
||||||
|
LEFT JOIN user_profiles se ON pt.serviced_by = se.id
|
||||||
|
LEFT JOIN user_profiles created_user ON pt.created_by = created_user.id
|
||||||
|
|
||||||
|
WHERE pt.is_active = 1
|
||||||
|
AND pcsd.is_active = 1
|
||||||
|
$default_date_filter
|
||||||
|
|
||||||
|
GROUP BY pt.policy_no, pcsd.insurer_id
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
pt.id AS id,
|
||||||
|
pt.endorsement_no,
|
||||||
|
pt.ref,
|
||||||
|
DATE_FORMAT(pt.policy_issue_date, '%d %b %Y') AS policy_issue_date,
|
||||||
|
DATE_FORMAT(IF(insq.month IS NULL, pcsd.pt_policy_issue_date, insq.month),'%b %Y') AS policy_issue_month,
|
||||||
|
insq.month as statement_month,
|
||||||
|
|
||||||
|
'statement uploaded' AS statement_uploaded,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN c.client_type = 1 THEN 'Group'
|
||||||
|
WHEN c.client_type = 2 THEN 'Retail'
|
||||||
|
ELSE '-'
|
||||||
|
END AS client_type,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN pt.revenue_type = 'NA' THEN 'Fresh'
|
||||||
|
ELSE 'Renewal'
|
||||||
|
END AS revenue_type,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN pt.action_type = 'inception' THEN 'Policy'
|
||||||
|
ELSE 'Endorsement'
|
||||||
|
END AS action_type,
|
||||||
|
|
||||||
|
c.client_name,
|
||||||
|
c.short_name AS client_short_name,
|
||||||
|
cb.branch_name AS client_branch_name,
|
||||||
|
cb.address1 AS client_address,
|
||||||
|
ptype.policy_type,
|
||||||
|
ptype.bap,
|
||||||
|
ins.name AS insurer_name,
|
||||||
|
ins.short_name AS insurer_short_name,
|
||||||
|
ib.branch_name AS insurer_branch_name,
|
||||||
|
ib.branch_code AS insurer_branch_code,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN
|
||||||
|
IFNULL(cssd.actual_tep_brokerage_amt,0) = 0 AND
|
||||||
|
IFNULL(cssd.actual_tp_brokerage_amt,0) = 0 AND
|
||||||
|
IFNULL(cssd.actual_bp_brokerage_amt,0) = 0 AND
|
||||||
|
IFNULL(cssd.reward,0) != 0
|
||||||
|
THEN 'rewards'
|
||||||
|
ELSE created_user.first_name
|
||||||
|
END AS user_name,
|
||||||
|
|
||||||
|
v.vehicle_no,
|
||||||
|
tpa.name AS tpa_name,
|
||||||
|
|
||||||
|
pcsd.remark AS remarks,
|
||||||
|
pcsd.cop_amt AS bp_amt,
|
||||||
|
pcsd.exp_amt,
|
||||||
|
pcsd.id AS pt_id,
|
||||||
|
|
||||||
|
su.first_name AS salse_person_name,
|
||||||
|
se.first_name AS service_person_name,
|
||||||
|
|
||||||
|
ROUND(pcsd.cop_amt + pcsd.cotp_amt + pcsd.cotep_amt,2) AS premium_wo_gst,
|
||||||
|
ROUND((pcsd.cop_amt + pcsd.cotp_amt + pcsd.cotep_amt) * 0.18,2) AS gst_amount,
|
||||||
|
ROUND((pcsd.cop_amt + pcsd.cotp_amt + pcsd.cotep_amt) * 1.18,2) AS total_premium,
|
||||||
|
|
||||||
|
ROUND(pcsd.cotp_amt + pcsd.cotep_amt,2) AS tp_or_ter,
|
||||||
|
DATEDIFF(pt.policy_end_date, CURDATE()) AS days,
|
||||||
|
(pcsd.agreed_tp_per + pcsd.agreed_tep_per) AS agreed_tp_or_ter_per,
|
||||||
|
pcsd.agreed_bp_per,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN insq.month = pt.month THEN pcsd.exp_amt
|
||||||
|
ELSE 0
|
||||||
|
END AS total_irda_amt_2,
|
||||||
|
|
||||||
|
COALESCE((
|
||||||
|
SELECT SUM(cs.reward)
|
||||||
|
FROM co_share_stmt_details cs
|
||||||
|
JOIN insurer_statements i ON cs.statement_id = i.id
|
||||||
|
WHERE cs.co_share_id = pcsd.id AND i.month = insq.month
|
||||||
|
AND i.is_active = 1
|
||||||
|
AND cs.is_active = 1
|
||||||
|
GROUP BY pt.policy_no, i.month, pcsd.insurer_id
|
||||||
|
),0) AS reward,
|
||||||
|
|
||||||
|
COALESCE((
|
||||||
|
SELECT SUM(
|
||||||
|
COALESCE(cs.actual_bp_brokerage_amt,0) +
|
||||||
|
COALESCE(cs.actual_tp_brokerage_amt,0) +
|
||||||
|
COALESCE(cs.actual_tep_brokerage_amt,0) +
|
||||||
|
COALESCE(cs.reward,0)
|
||||||
|
)
|
||||||
|
FROM co_share_stmt_details cs
|
||||||
|
JOIN insurer_statements i ON cs.statement_id = i.id
|
||||||
|
WHERE cs.co_share_id = pcsd.id
|
||||||
|
AND i.invoice_status IS NOT NULL
|
||||||
|
AND i.month = insq.month
|
||||||
|
AND i.is_active = 1
|
||||||
|
AND cs.is_active = 1
|
||||||
|
GROUP BY pt.policy_no, i.month, pcsd.insurer_id
|
||||||
|
),0) AS billed_amt,
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN pcsd.co_share_type IN (0,1) THEN pt.policy_no
|
||||||
|
WHEN pcsd.co_share_type > 1
|
||||||
|
THEN IFNULL(NULLIF(pcsd.follower_policy_no,''), pt.policy_no)
|
||||||
|
ELSE pt.policy_no
|
||||||
|
END AS policy_no
|
||||||
|
|
||||||
|
FROM policy_transaction pt
|
||||||
|
LEFT JOIN pt_co_share_details pcsd ON pt.id = pcsd.pt_id
|
||||||
|
LEFT JOIN co_share_stmt_details cssd ON pcsd.id = cssd.co_share_id
|
||||||
|
LEFT JOIN insurer_statements insq ON cssd.statement_id = insq.id
|
||||||
|
JOIN clients c ON c.id = pt.client_id
|
||||||
|
LEFT JOIN client_branch cb ON pt.client_branch_id = cb.id
|
||||||
|
LEFT JOIN client_policy cp ON pt.client_policy_id = cp.id
|
||||||
|
LEFT JOIN user_profiles up ON pt.created_by = up.id
|
||||||
|
LEFT JOIN vehicle v ON pt.vehicle_id = v.id
|
||||||
|
LEFT JOIN policy_type ptype ON pt.policy_type_id = ptype.id
|
||||||
|
LEFT JOIN insurers ins ON pcsd.insurer_id = ins.id
|
||||||
|
LEFT JOIN insurer_branch ib ON pcsd.insurer_branch_id = ib.id
|
||||||
|
LEFT JOIN tpa ON pt.tpa_id = tpa.id
|
||||||
|
LEFT JOIN tpa_branch tb ON pt.tpa_branch_id = tb.id
|
||||||
|
LEFT JOIN user_profiles su ON pt.sales_generated_by = su.id
|
||||||
|
LEFT JOIN user_profiles se ON pt.serviced_by = se.id
|
||||||
|
LEFT JOIN user_profiles created_user ON pt.created_by = created_user.id
|
||||||
|
|
||||||
|
WHERE pt.is_active = 1
|
||||||
|
AND pcsd.is_active = 1
|
||||||
|
AND cssd.is_active = 1
|
||||||
|
AND insq.is_active = 1
|
||||||
|
$default_date_filter
|
||||||
|
|
||||||
|
GROUP BY pt.policy_no, pcsd.insurer_id, insq.month
|
||||||
|
|
||||||
|
) AS final_result
|
||||||
|
|
||||||
|
-- GROUP BY statement_month, insurer_name, policy_no
|
||||||
|
|
||||||
|
ORDER BY
|
||||||
|
policy_no ASC,
|
||||||
|
insurer_branch_name ASC,
|
||||||
|
statement_uploaded ASC,
|
||||||
|
statement_month ASC,
|
||||||
|
STR_TO_DATE(policy_issue_month, '%b %Y') ASC
|
||||||
|
";
|
||||||
|
$query = $this->db->query($sql);
|
||||||
|
$result = $query->getResultArray();
|
||||||
|
|
||||||
|
$keys = [];
|
||||||
|
$filtered = [];
|
||||||
|
|
||||||
|
foreach ($result as $row) {
|
||||||
|
$key = $row['statement_month'].'|'.$row['insurer_name'].'|'.$row['policy_no'];
|
||||||
|
|
||||||
|
// If uploaded record exists, always keep it and override previous
|
||||||
|
if ($row['statement_uploaded'] === 'statement uploaded') {
|
||||||
|
$filtered[$key] = $row; // overwrite no-statement row if it exists
|
||||||
|
$keys[$key] = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
// Keep "no statement uploaded" only if uploaded one not added yet
|
||||||
|
elseif (!isset($keys[$key])) {
|
||||||
|
$filtered[$key] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array_values($filtered);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,7 @@ table.dataTable tbody td {
|
|||||||
<thead class="bg-light">
|
<thead class="bg-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>S. No</th>
|
<th>S. No</th>
|
||||||
<th style="display: none;">User</th>
|
<th>User</th>
|
||||||
<th>Month</th>
|
<th>Month</th>
|
||||||
<th style="display: none;">Business Type</th>
|
<th style="display: none;">Business Type</th>
|
||||||
<th style="display: none;">Client Type</th>
|
<th style="display: none;">Client Type</th>
|
||||||
@ -123,7 +123,7 @@ table.dataTable tbody td {
|
|||||||
echo base_url('policy_tranction/endorsement/list') . '?pt_id=' . $row['id'] ;
|
echo base_url('policy_tranction/endorsement/list') . '?pt_id=' . $row['id'] ;
|
||||||
}
|
}
|
||||||
?>" class="mdi mdi-pencil" ></a> </td>
|
?>" class="mdi mdi-pencil" ></a> </td>
|
||||||
<td style="display: none;"><?php echo $row['user_name'] ?: 'N/A'; ?></td>
|
<td><?php echo $row['user_name'] ?: 'N/A'; ?></td>
|
||||||
<td><?php echo $row['policy_issue_month'] ?: 'N/A'; ?></td>
|
<td><?php echo $row['policy_issue_month'] ?: 'N/A'; ?></td>
|
||||||
<td style="display: none;"><?php echo $row['revenue_type'] ?: 'N/A'; ?></td>
|
<td style="display: none;"><?php echo $row['revenue_type'] ?: 'N/A'; ?></td>
|
||||||
<td style="display: none;"><?php echo $row['client_type'] ?: 'N/A'; ?></td>
|
<td style="display: none;"><?php echo $row['client_type'] ?: 'N/A'; ?></td>
|
||||||
@ -175,6 +175,9 @@ table.dataTable tbody td {
|
|||||||
// REF : Velmurugan but he told handle in query
|
// REF : Velmurugan but he told handle in query
|
||||||
// Date : 6/11/25 12:50
|
// Date : 6/11/25 12:50
|
||||||
$unbilled_amt = $total_irda_amt - $row['billed_amt'];
|
$unbilled_amt = $total_irda_amt - $row['billed_amt'];
|
||||||
|
if($total_irda_amt == "0.00"){
|
||||||
|
$unbilled_amt = abs($unbilled_amt);
|
||||||
|
}
|
||||||
$unbilled_amt = $unbilled_amt == 0 && $row['billed_amt'] == 0 ? $total_irda_amt : $unbilled_amt ;
|
$unbilled_amt = $unbilled_amt == 0 && $row['billed_amt'] == 0 ? $total_irda_amt : $unbilled_amt ;
|
||||||
?>
|
?>
|
||||||
<td class="right-align-input"><?php echo number_format((float)$unbilled_amt,2, '.', '')?></td>
|
<td class="right-align-input"><?php echo number_format((float)$unbilled_amt,2, '.', '')?></td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user