Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-04-30 15:14:41 +05:30
commit 4acdc7f4e8
8 changed files with 321 additions and 25 deletions

View File

@ -537,6 +537,7 @@ $routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) {
$routes->get('bap_wise_data/(:any)','BDSReportController::Bap_Wise_Data/$1'); $routes->get('bap_wise_data/(:any)','BDSReportController::Bap_Wise_Data/$1');
$routes->match( ['get', 'post'], 'renewal_report','BDSReportController::renewalReport'); $routes->match( ['get', 'post'], 'renewal_report','BDSReportController::renewalReport');
$routes->get('getTATReport','BDSReportController::bdsTATReport'); $routes->get('getTATReport','BDSReportController::bdsTATReport');
$routes->get("getMultiReport/(:any)", "BDSReportController::getMultiReport/$1");
}); });
//New Tickets //New Tickets

View File

@ -33,6 +33,7 @@ class BDSReportController extends AdminController
protected $PTCOShareDetailsModel; protected $PTCOShareDetailsModel;
protected $coShareStmtDetailsModel; protected $coShareStmtDetailsModel;
protected $policyTypeModel; protected $policyTypeModel;
protected $policyTatReportType;
public function __construct() public function __construct()
{ {
@ -46,6 +47,13 @@ class BDSReportController extends AdminController
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel(); $this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
$this->policyTypeModel = new PolicyTypeModel(); $this->policyTypeModel = new PolicyTypeModel();
$this->policyTatReportType = [
'1' => "TAT Band Wise report",
'2' => "Account Manger Status Wise Report",
'3' => "Account Manger TAT Wise Report"
];
} }
// public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate) // public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate)
@ -209,7 +217,7 @@ class BDSReportController extends AdminController
$html = view('bds_report_bap_wise_data', $viewData); $html = view('bds_report_bap_wise_data', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} else if($report_type == 'bapInsurer'){ } else if ($report_type == 'bapInsurer') {
//Condition for BAP Insurer wise date //Condition for BAP Insurer wise date
$category = $category == 'life' ? 1 : 0; $category = $category == 'life' ? 1 : 0;
@ -217,8 +225,7 @@ class BDSReportController extends AdminController
$html = view('irda_bap_insurer_report_list', $viewData); $html = view('irda_bap_insurer_report_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} else if ($report_type == 'bapClient') {
}else if($report_type == 'bapClient'){
//Condition for BAP Client wise date //Condition for BAP Client wise date
$category = $category == 'life' ? 1 : 0; $category = $category == 'life' ? 1 : 0;
@ -226,8 +233,7 @@ class BDSReportController extends AdminController
$html = view('irda_bap_client_report_list', $viewData); $html = view('irda_bap_client_report_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} else if ($report_type == 'client') {
}else if($report_type == 'client'){
//Condition for Client wise date //Condition for Client wise date
$category = $category == 'life' ? 1 : 0; $category = $category == 'life' ? 1 : 0;
@ -910,7 +916,6 @@ class BDSReportController extends AdminController
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance']; $data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
$data['page_name'] = "Renewal Report"; $data['page_name'] = "Renewal Report";
return $this->loadLayout('renewal_search', $data); return $this->loadLayout('renewal_search', $data);
} else { } else {
$fromDate = $this->request->getPost('fromDate'); $fromDate = $this->request->getPost('fromDate');
@ -1001,6 +1006,150 @@ class BDSReportController extends AdminController
// dd(db_connect()->getLastQuery(),$result); // dd(db_connect()->getLastQuery(),$result);
$data['data'] = $result; $data['data'] = $result;
// dd($data, get_role_id(), ENROLLMENT_TEAM_ID, user_team()); // dd($data, get_role_id(), ENROLLMENT_TEAM_ID, user_team());
return $this->loadLayout('bds_tat_wise_report', $data); // return $this->loadLayout('bds_tat_wise_report', $data);
return $result;
}
public function accountMangerStatusBDSReport()
{
$data['page_name'] = "Account Manager BDS Report";
$sql = "
SELECT
COALESCE(ACM_Name, 'Total') AS ACM_Name,
COALESCE(SUM(CASE WHEN status = 'instalment_pending' THEN 1 ELSE 0 END), 0) AS `Instalment Pending`,
COALESCE(SUM(CASE WHEN status = 'under_process' THEN 1 ELSE 0 END), 0) AS `Under Process`,
COALESCE(SUM(CASE WHEN status = 'client_pending' THEN 1 ELSE 0 END), 0) AS `Client Pending`,
COALESCE(SUM(CASE WHEN status = 'co_insurer_pending' THEN 1 ELSE 0 END), 0) AS `Co Insurer Pending`,
COALESCE(SUM(CASE WHEN status = 'tpa_pending' THEN 1 ELSE 0 END), 0) AS `TPA Pending`,
COALESCE(SUM(CASE WHEN status = 'validated' THEN 1 ELSE 0 END), 0) AS `Validated`,
COALESCE(SUM(CASE WHEN status = 'cancelled' THEN 1 ELSE 0 END), 0) AS `Cancelled`,
COALESCE(SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END), 0) AS `Completed`,
COALESCE(SUM(CASE WHEN status = 'lost' THEN 1 ELSE 0 END), 0) AS `Lost`,
COALESCE(SUM(CASE WHEN status = 'insurer_pending' THEN 1 ELSE 0 END), 0) AS `Insurer Pending`
FROM (
SELECT
up.first_name AS ACM_Name,
ls.status
FROM policy_transaction pt
JOIN clients c ON pt.client_id = c.id AND c.is_active = 1
JOIN client_rm crm ON crm.client_id = c.id AND crm.is_active = 1 AND crm.level = 3
JOIN user_profiles up ON up.id = crm.user_id AND up.is_active = 1
LEFT JOIN (
SELECT
pts1.policy_tran_id,
pts1.status,
pts1.created_at
FROM policy_transaction_status pts1
INNER JOIN (
SELECT
policy_tran_id,
MAX(created_at) AS max_created_at
FROM policy_transaction_status
WHERE is_active = 1
GROUP BY policy_tran_id
) pts2
ON pts1.policy_tran_id = pts2.policy_tran_id
AND pts1.created_at = pts2.max_created_at
WHERE pts1.is_active = 1
) ls ON pt.id = ls.policy_tran_id
WHERE pt.is_active = 1
AND DATEDIFF(CURDATE(), ls.created_at) >= 4
) AS sub
GROUP BY ACM_Name;
";
$db = \Config\Database::connect();
$query = $db->query($sql);
// Get the result
$result = $query->getResultArray();
return $result;
}
public function accountManagerTatBDSReport(){
$sql = "
SELECT
COALESCE(ACM_Name, 'Total') AS ACM_Name,
COALESCE(SUM(CASE WHEN tat_bucket = '0-4 Days' THEN 1 ELSE 0 END), 0) AS `0-4 Days`,
COALESCE(SUM(CASE WHEN tat_bucket = '5-8 Days' THEN 1 ELSE 0 END), 0) AS `5-8 Days`,
COALESCE(SUM(CASE WHEN tat_bucket = '9-12 Days' THEN 1 ELSE 0 END), 0) AS `9-12 Days`,
COALESCE(SUM(CASE WHEN tat_bucket = 'Above 12 Days' THEN 1 ELSE 0 END), 0) AS `Above 12 Days`
FROM (
SELECT
up.first_name AS ACM_Name,
CASE
WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 0 AND 4 THEN '0-4 Days'
WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 5 AND 8 THEN '5-8 Days'
WHEN DATEDIFF(CURDATE(), ls.created_at) BETWEEN 9 AND 12 THEN '9-12 Days'
WHEN DATEDIFF(CURDATE(), ls.created_at) > 12 THEN 'Above 12 Days'
ELSE 'Unknown'
END AS tat_bucket
FROM policy_transaction pt
JOIN clients c ON pt.client_id = c.id AND c.is_active = 1
JOIN client_rm crm ON crm.client_id = c.id AND crm.is_active = 1 AND crm.level = 3
JOIN user_profiles up ON up.id = crm.user_id AND up.is_active = 1
LEFT JOIN (
SELECT
pts1.policy_tran_id,
pts1.status,
pts1.created_at
FROM policy_transaction_status pts1
INNER JOIN (
SELECT
policy_tran_id,
MAX(created_at) AS max_created_at
FROM policy_transaction_status
WHERE is_active = 1
GROUP BY policy_tran_id
) pts2
ON pts1.policy_tran_id = pts2.policy_tran_id
AND pts1.created_at = pts2.max_created_at
WHERE pts1.is_active = 1
) ls ON pt.id = ls.policy_tran_id
WHERE pt.is_active = 1
AND ls.created_at IS NOT NULL
) AS sub
GROUP BY ACM_Name;
";
$db = \Config\Database::connect();
$query = $db->query($sql);
// Get the result
$result = $query->getResultArray();
return $result;
}
public function getMultiReport($report_type){
$data['page_name'] = "BDS Report";
if ($report_type == 1){
$data['page_title'] = "BDS TAT Report";
$data['data'] = $this->bdsTATReport();
}else if ($report_type == 2){
$data['page_title'] = "Account Manager Status Report";
$data['data'] = $this->accountMangerStatusBDSReport();
}else{
$data['page_title'] = "Account Manager TAT Report";
$data['data'] = $this->accountManagerTatBDSReport();
}
return $this->loadLayout('bds_multi_report', $data);
} }
} }

View File

@ -238,6 +238,7 @@ class DashboardController extends AdminController
// echo "<pre>"; // echo "<pre>";
$data['pendingActionsData'] = $pendingActionsData; $data['pendingActionsData'] = $pendingActionsData;
$data['businessTeamCount'] = count($businessTeamData) ?? 0; $data['businessTeamCount'] = count($businessTeamData) ?? 0;
// dd($businessTeamData);
$data['financeTeamCount'] = count($financeTeamData) ?? 0; $data['financeTeamCount'] = count($financeTeamData) ?? 0;
$data['businessTeamStatusData'] = $businessTeamStatusData; $data['businessTeamStatusData'] = $businessTeamStatusData;
$data['financeTeamStatusData'] = $financeTeamStatusData; $data['financeTeamStatusData'] = $financeTeamStatusData;
@ -257,6 +258,7 @@ class DashboardController extends AdminController
} }
// dd(get_role_id(),user_team()); // dd(get_role_id(),user_team());
// dd($data);
$data['page_name'] = 'Dashboard'; $data['page_name'] = 'Dashboard';
@ -725,7 +727,6 @@ class DashboardController extends AdminController
'validated' => [], 'validated' => [],
'cancelled' => [], 'cancelled' => [],
'instalment_pending' => [], 'instalment_pending' => [],
'completed' => [],
]; ];
// Loop through results and group them by their status // Loop through results and group them by their status

View File

@ -434,7 +434,7 @@ class EmployeeController extends AdminController
$filePath = ROOTPATH . 'public/sample_excel/sample_correction .xls'; $filePath = ROOTPATH . 'public/sample_excel/sample_correction .xls';
} else if ($actionType == 'si_enhancement') { } else if ($actionType == 'si_enhancement') {
$filePath = ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls'; $filePath = ROOTPATH . 'public/sample_excel/sample_si_enhancement.xls';
} else if ($actionType == 'dependent_addtion') { } else if ($actionType == 'dependent_addition') {
$filePath = ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls'; $filePath = ROOTPATH . 'public/sample_excel/sample_dependent_addition.xls';
} else if ($actionType == 'addition') { } else if ($actionType == 'addition') {
$filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls'; $filePath = ROOTPATH . 'public/sample_excel/sample_addition.xls';

View File

@ -1335,6 +1335,8 @@ class PolicyTransactionModel extends Model
) )
->where("th.last_policy_status_change <= '{$dateThreshold}'", null, false) ->where("th.last_policy_status_change <= '{$dateThreshold}'", null, false)
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
->where("policy_transaction.status is not null", null, false)
->whereNotIn("policy_transaction.status", ['completed'])
// ->where('policy_transaction.status', 'completed') // ->where('policy_transaction.status', 'completed')
->where('(pt_co_share_details.bp_amt IS NULL OR pt_co_share_details.bp_amt = 0)', null, false); ->where('(pt_co_share_details.bp_amt IS NULL OR pt_co_share_details.bp_amt = 0)', null, false);
@ -1426,8 +1428,9 @@ class PolicyTransactionModel extends Model
// ->where('policy_transaction.status', 'completed') // ->where('policy_transaction.status', 'completed')
->where('COALESCE(pt_co_share_details.agreed_bp_per, 0) + COALESCE(pt_co_share_details.agreed_tp_per, 0) + COALESCE(pt_co_share_details.agreed_tep_per, 0) = 0') ->where('COALESCE(pt_co_share_details.agreed_bp_per, 0) + COALESCE(pt_co_share_details.agreed_tp_per, 0) + COALESCE(pt_co_share_details.agreed_tep_per, 0) = 0')
->where('COALESCE(pt_co_share_details.actual_bp_amt, 0) + COALESCE(pt_co_share_details.actual_tp_amt, 0) + COALESCE(pt_co_share_details.actual_tep_amt, 0) = 0') ->where('COALESCE(pt_co_share_details.actual_bp_amt, 0) + COALESCE(pt_co_share_details.actual_tp_amt, 0) + COALESCE(pt_co_share_details.actual_tep_amt, 0) = 0')
->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0'); ->where('COALESCE(pt_co_share_details.actual_bp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tp_brokerage_amt, 0) + COALESCE(pt_co_share_details.actual_tep_brokerage_amt, 0) = 0')
->where("policy_transaction.status is not null", null, false)
->whereNotIn("policy_transaction.status", ['completed']);
if ($start_date != 0 && $end_date != 0 && $date_type != 0) { if ($start_date != 0 && $end_date != 0 && $date_type != 0) {

View File

@ -259,10 +259,10 @@
<?php include('endorsement_dash.php'); ?> <?php include('endorsement_dash.php'); ?>
<?php include('enrollment_dash.php'); ?> <?php include('enrollment_dash.php'); ?>
<?php } ?> <?php } ?>
<!--
<?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?> <?php // if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
<?php include('bds_dash.php'); ?> <?php // include('bds_dash.php'); ?>
<?php } ?> <?php // } ?> -->
</div> </div>

View File

@ -0,0 +1,122 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
</style>
<div class="row">
<div class="col-12" id="second_page">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;"><?= $page_title ?></h4>
</div>
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead>
<tr>
<?php
// Get headers dynamically
$headers = array_keys($data[0]);
foreach ($headers as $header): ?>
<th><?= esc($header) ?></th>
<?php endforeach; ?>
<th>TOTAL</th>
</tr>
</thead>
<tbody>
<?php
// Initialize column-wise totals
$columnTotals = array_fill_keys($headers, 0);
foreach ($data as $row):
$rowTotal = 0; // Initialize row total
?>
<tr>
<?php foreach ($row as $key => $value):
$numValue = is_numeric($value) ? (int) $value : 0;
if ($key != 'TAT_Category') {
$columnTotals[$key] += $numValue;
$rowTotal += $numValue;
}
?>
<td><?= esc($value) ?></td>
<?php endforeach; ?>
<td><strong><?= esc($rowTotal) ?></strong></td> <!-- Row Total -->
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<?php foreach ($columnTotals as $key => $total): ?>
<th><?= ($key == "TAT_Category" || $key == 'ACM_Name') ? "TOTAL" : esc($total) ?></th>
<?php endforeach; ?>
<th><strong><?= array_sum(array_filter($columnTotals, 'is_numeric')) ?></strong></th> <!-- Grand Total -->
</tr>
</tfoot>
</table>
</div>
</div> <!-- end card-body -->
</div> <!-- end card -->
</div> <!-- end col-12 -->
</div> <!-- end row -->
<script>
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [
{
extend: 'csv',
text: 'CSV',
title: 'BDS TAT BAND WISE DATA',
},
{
extend: 'excel',
text: 'Excel',
title: 'BDS TAT BAND WISE DATA',
},
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
pageLength: 10,
ordering: false
});
} else {
console.error("Table not found.");
}
});
</script>

View File

@ -766,6 +766,26 @@
</div> </div>
</li> </li>
<?php } ?> <?php } ?>
<li>
<a href="#policy_tat_report_type" data-toggle="collapse" class="waves-effect">
<i class="ri-file-chart-fill"></i>
<span> Policy TAT Reports </span>
</a>
<div class="collapse" id="policy_tat_report_type">
<ul class="nav-third-level">
<li>
<a href="<?= base_url('/bdsReport/getMultiReport/1') ?>">TAT Band Wise</a>
</li>
<li>
<a href="<?= base_url('/bdsReport/getMultiReport/2') ?>">ACM Status Wise</a>
</li>
<li>
<a href="<?= base_url('/bdsReport/getMultiReport/3') ?>">ACM TAT Wise</a>
</li>
</ul>
</div>
</li>
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) )) { ?> <?php if ((get_role_id() == 1 || get_role_id() == 5) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) )) { ?>
<li> <li>