FEAT_BDS_TAT_REPORT : RV
This commit is contained in:
parent
bab46160f2
commit
2b142f7f1a
@ -536,7 +536,7 @@ $routes->group("/bdsReport", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get('insurer_wise_data/(:any)','BDSReportController::Insurer_wise_Data/$1');
|
$routes->get('insurer_wise_data/(:any)','BDSReportController::Insurer_wise_Data/$1');
|
||||||
$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');
|
||||||
});
|
});
|
||||||
|
|
||||||
//New Tickets
|
//New Tickets
|
||||||
|
|||||||
@ -927,4 +927,80 @@ class BDSReportController extends AdminController
|
|||||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bdsTATReport()
|
||||||
|
{
|
||||||
|
$sql = "
|
||||||
|
SELECT
|
||||||
|
tc.TAT_Category,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'under_process' THEN 1 ELSE 0 END), 0) AS `Under Process`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'client_pending' THEN 1 ELSE 0 END), 0) AS `Client Pending`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'insurer_pending' THEN 1 ELSE 0 END), 0) AS `Insurer Pending`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'instalment_pending' THEN 1 ELSE 0 END), 0) AS `Instalment Pending`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'co_insurer_pending' THEN 1 ELSE 0 END), 0) AS `Co-Insurer Pending`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'tpa_pending' THEN 1 ELSE 0 END), 0) AS `TPA Pending`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'validated' THEN 1 ELSE 0 END), 0) AS `Validated`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'cancelled' THEN 1 ELSE 0 END), 0) AS `Cancelled`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'completed' THEN 1 ELSE 0 END), 0) AS `Completed`,
|
||||||
|
COALESCE(SUM(CASE WHEN subquery.status = 'lost' THEN 1 ELSE 0 END), 0) AS `Lost` FROM
|
||||||
|
(
|
||||||
|
SELECT 'Above 12 Days' AS TAT_Category
|
||||||
|
UNION ALL
|
||||||
|
SELECT '9-12 Days'
|
||||||
|
UNION ALL
|
||||||
|
SELECT '5-8 Days'
|
||||||
|
UNION ALL
|
||||||
|
SELECT '0-4 Days'
|
||||||
|
) AS tc
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
pt.id AS policy_id,
|
||||||
|
ls.status,
|
||||||
|
CASE
|
||||||
|
WHEN DATEDIFF(CURRENT_DATE, pt.created_at) BETWEEN 0 AND 4 THEN '0-4 Days'
|
||||||
|
WHEN DATEDIFF(CURRENT_DATE, pt.created_at) BETWEEN 5 AND 8 THEN '5-8 Days'
|
||||||
|
WHEN DATEDIFF(CURRENT_DATE, pt.created_at) BETWEEN 9 AND 12 THEN '9-12 Days'
|
||||||
|
ELSE 'Above 12 Days'
|
||||||
|
END AS TAT_Category
|
||||||
|
FROM
|
||||||
|
policy_transaction pt
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
pts1.*
|
||||||
|
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
|
||||||
|
) AS subquery
|
||||||
|
ON tc.TAT_Category = subquery.TAT_Category
|
||||||
|
GROUP BY
|
||||||
|
tc.TAT_Category
|
||||||
|
ORDER BY
|
||||||
|
FIELD(tc.TAT_Category, '0-4 Days', '5-8 Days' , '9-12 Days' , 'Above 12 Days' )
|
||||||
|
";
|
||||||
|
|
||||||
|
// Run the query
|
||||||
|
$db = \Config\Database::connect();
|
||||||
|
$query = $db->query($sql);
|
||||||
|
|
||||||
|
// Get the result
|
||||||
|
$result = $query->getResultArray();
|
||||||
|
// dd(db_connect()->getLastQuery(),$result);
|
||||||
|
$data['data'] = $result;
|
||||||
|
// dd($data, get_role_id(), ENROLLMENT_TEAM_ID, user_team());
|
||||||
|
return $this->loadLayout('bds_tat_wise_report', $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
122
app/Views/bds_tat_wise_report.php
Normal file
122
app/Views/bds_tat_wise_report.php
Normal 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;">BDS TAT Band Wise Report</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") ? "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>
|
||||||
@ -758,6 +758,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url('/bdsReport/renewal_report') ?>">Renewal Reports</a>
|
<a href="<?= base_url('/bdsReport/renewal_report') ?>">Renewal Reports</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="<?= base_url('/bdsReport/getTATReport') ?>">TAT Band Reports</a>
|
||||||
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user