MERGE_CODE_MERGE : RV

This commit is contained in:
VENKATESHWARAN 2025-01-24 10:30:43 +05:30
commit 5e7d91aa23
5 changed files with 342 additions and 344 deletions

View File

@ -46,16 +46,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();
} }
public function Insurer_wise_Data($insurerCategory, $fromDate, $toDate)
public function Insurer_wise_Data($insurerCategory,$fromDate,$toDate){ {
$fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d');
$toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d');
try {
if($insurerCategory == 0 || $insurerCategory == 1){
$sql = " $sql = "
select ins.id,ins.name as insurers, select ins.id,ins.name as insurers,
COALESCE(SUM(CASE WHEN pt.action_type = 'inception' and pt.insurer_id = ins.id and ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies, COALESCE(SUM(CASE WHEN pt.action_type = 'inception' and pt.insurer_id = ins.id and ptp.policy_category = $insurerCategory THEN 1 ELSE 0 END), 0) AS Policies,
@ -64,28 +61,29 @@ class BDSReportController extends AdminController
from insurers ins from insurers ins
left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1 left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1
left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1 left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1
left join policy_transaction pt on pt_co.pt_id = pt.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_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate'
left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory
where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null) where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null)
group by ins.id group by ins.id
"; ";
$data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray(); $data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray();
// log_message('error',$this->insurerModel->getLastQuery());
// log_message('error',json_encode($data));
}else{ } catch (\Exception $e) {
$data['message'] = 'Insurer Category Not Valid'; $data['message'] = 'No data Found';
log_message('error',$data['message']); $this->myLogger->logme('error', $e->getMessage());
return $data; return $data;
} }
return view('bds_report_Insurer_wise_Data',$data); return ($data);
} }
public function Bap_Wise_Data($insurerCategory,$fromDate,$toDate){ public function Bap_Wise_Data($insurerCategory, $fromDate, $toDate)
{
$fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d'); $fromDate = \DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d');
$toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d');
if($insurerCategory == 0 || $insurerCategory == 1){ try {
$sql = " $sql = "
SELECT SELECT
pot.bap AS bap, pot.bap AS bap,
@ -93,7 +91,7 @@ class BDSReportController extends AdminController
COALESCE(SUM(co.actual_bp_amt + co.actual_tep_amt + co.actual_tp_amt), 0) AS Premium, COALESCE(SUM(co.actual_bp_amt + co.actual_tep_amt + co.actual_tp_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
FROM policy_type AS pot FROM policy_type AS pot
LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= $fromDate and pt.policy_issue_date <= $toDate LEFT JOIN policy_transaction AS pt ON pot.id = pt.policy_type_id AND pt.is_active = 1 AND pt.action_type = 'inception' and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate'
LEFT JOIN pt_co_share_details AS ptco ON pt.id = ptco.pt_id AND ptco.is_active = 1 LEFT JOIN pt_co_share_details AS ptco ON pt.id = ptco.pt_id AND ptco.is_active = 1
LEFT JOIN co_share_stmt_details AS co ON ptco.id = co.co_share_id AND co.is_active = 1 LEFT JOIN co_share_stmt_details AS co ON ptco.id = co.co_share_id AND co.is_active = 1
WHERE pot.is_active = 1 WHERE pot.is_active = 1
@ -102,20 +100,20 @@ class BDSReportController extends AdminController
"; ";
$data['bap_wise_data'] = $this->policyTypeModel->query($sql)->getResultArray(); $data['bap_wise_data'] = $this->policyTypeModel->query($sql)->getResultArray();
}else{ } catch (\Exception $e) {
$data['message'] = 'Insurer Category Not Valid'; $data['message'] = 'No Data Found';
log_message('error',$data['message']); $this->myLogger->logme('error', $e->getMessage());
return $data; return $data;
} }
return view('bds_report_bap_wise_data',$data); return ($data);
} }
public function irba_report() public function irba_report()
{ {
if ($this->request->getMethod() == 'get') { if ($this->request->is('get')) {
$default_start = new \DateTime(); $default_start = new \DateTime();
$data['default_end'] = $default_start->format('d-m-Y'); $data['default_end'] = $default_start->format('d-m-Y');
$data['default_start'] = $default_start->modify('-90 days')->format('d-m-Y'); $data['default_start'] = $default_start->modify('-90 days')->format('d-m-Y');
@ -141,24 +139,30 @@ class BDSReportController extends AdminController
if ($report_type == 'insurer') { if ($report_type == 'insurer') {
$life = $category == 'life' ? 1 : 0; $life = $category == 'life' ? 1 : 0;
$viewData = $this->Insurer_wise_Data($life, $fromDate, $toDate); $viewData = $this->Insurer_wise_Data($life, $fromDate, $toDate);
if (isset($data['message'])) {
return $this->respond(['status' => false, 'message' => $data['message']], 200);
}
// Ensure $viewData is an array // Ensure $viewData is an array
if (!is_array($viewData)) { if (!is_array($viewData)) {
$viewData = []; $viewData = [];
} }
$html = view('bds_report_Insurer_wise_Data', $viewData); $html = view('bds_report_Insurer_wise_Data', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} else if ($report_type == 'bap') { } else if ($report_type == 'bap') {
$life = $category == 'life' ? 1 : 0; $life = $category == 'life' ? 1 : 0;
$viewData = $this->Bap_wise_Data($life, $fromDate, $toDate); $viewData = $this->Bap_wise_Data($life, $fromDate, $toDate);
if (isset($data['message'])) {
return $this->respond(['status' => false, 'message' => $data['message']], 200);
}
// Ensure $viewData is an array // Ensure $viewData is an array
if (!is_array($viewData)) { if (!is_array($viewData)) {
$viewData = []; $viewData = [];
} }
$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'){
@ -332,7 +336,6 @@ class BDSReportController extends AdminController
$this->myLogger->logme('error', 'Query executed successfully.'); $this->myLogger->logme('error', 'Query executed successfully.');
// dd(db_connect()->getLastQuery(),$result); // dd(db_connect()->getLastQuery(),$result);
return $result; return $result;
} catch (\Exception $e) { } catch (\Exception $e) {
// Log the exception details for debugging // Log the exception details for debugging

View File

@ -1,5 +1,4 @@
<style> <style>
.table th, .table th,
.table td { .table td {
padding: 8px; padding: 8px;
@ -10,7 +9,6 @@ table.dataTable tbody td {
} }
.col-12 { .col-12 {
max-width: 98% !important; max-width: 98% !important;
} }
@ -22,6 +20,7 @@ table.dataTable tbody td {
text-align: right; text-align: right;
} }
</style> </style>
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@ -52,7 +51,7 @@ table.dataTable tbody td {
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<th>Total Amount</th> <th>Grand Total</th>
<th></th> <th></th>
<th></th> <th></th>
<th></th> <th></th>
@ -63,44 +62,12 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
</div> </div>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Select the table and footer cells
const table = document.querySelector("#tickets-table");
const tbody = table.querySelector("tbody");
const footer = table.querySelector("tfoot tr");
let totalPolicies = 0;
let totalPremium = 0;
let totalRevenue = 0;
// Loop through each row in the table body and accumulate totals
tbody.querySelectorAll("tr").forEach(row => {
const policies = parseInt(row.cells[1].textContent) || 0;
const premium = parseFloat(row.cells[2].textContent.replace(/[^0-9.-]+/g, "")) || 0;
const revenue = parseFloat(row.cells[3].textContent.replace(/[^0-9.-]+/g, "")) || 0;
totalPolicies += policies;
totalPremium += premium;
totalRevenue += revenue;
});
// Append totals to the footer
footer.innerHTML = `
<th>Grand Total</th>
<th>${totalPolicies}</th>
<th>${totalPremium.toFixed(2)}</th>
<th>${totalRevenue.toFixed(2)}</th>
`;
});
</script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable'); var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) { if (ticketsTable.length) {
ticketsTable.DataTable({ ticketsTable.DataTable({
scrollX: true, scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
@ -110,18 +77,16 @@ if (ticketsTable.length) {
{ {
extend: 'csv', extend: 'csv',
text: 'CSV', text: 'CSV',
title: 'Policy-Tranction-BDS-List', title: 'Insurer-Wise-Report-List',
}, },
{ {
extend: 'excel', extend: 'excel',
text: 'Excel', text: 'Excel',
title: 'Policy-Tranction-BDS-List', title: 'Insurer-Wise-Report-List',
exportOptions: { exportOptions: {
orthogonal: 'sort' orthogonal: 'sort'
}, },
} }
], ],
language: { language: {
search: "_INPUT_", search: "_INPUT_",
@ -130,9 +95,37 @@ if (ticketsTable.length) {
paging: true, // Enable pagination paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional) pageLength: 10, // Set default number of rows per page (optional)
ordering: false, ordering: false,
footerCallback: function(row, data, start, end, display) {
var api = this.api();
// Helper function to parse numbers
var parseNumber = function(value) {
return typeof value === 'string' ?
parseFloat(value.replace(/[\$,]/g, '')) :
typeof value === 'number' ? value : 0;
};
// Calculate total for each column
var totalPolicies = api.column(1).data().reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
var totalPremium = api.column(2).data().reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
var totalRevenue = api.column(3).data().reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
// Update the footer with totals
$(api.column(1).footer()).html(totalPolicies.toLocaleString());
$(api.column(2).footer()).html("" + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 }));
$(api.column(3).footer()).html("" + totalRevenue.toLocaleString(undefined, { minimumFractionDigits: 2 }));
}
}); });
} else { } else {
console.error("Table atet found."); console.error("Table not found.");
} }
}); });
</script> </script>

View File

@ -1,5 +1,4 @@
<style> <style>
.table th, .table th,
.table td { .table td {
padding: 8px; padding: 8px;
@ -10,7 +9,6 @@ table.dataTable tbody td {
} }
.col-12 { .col-12 {
max-width: 98% !important; max-width: 98% !important;
} }
@ -22,6 +20,7 @@ table.dataTable tbody td {
text-align: right; text-align: right;
} }
</style> </style>
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@ -31,7 +30,8 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap"> <thead class="bg-light"> <table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr> <tr>
<th>Insurer</th> <th>Insurer</th>
<th>Policies</th> <th>Policies</th>
@ -51,7 +51,7 @@ table.dataTable tbody td {
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<th>Total Amount</th> <th>Grand Total</th>
<th></th> <th></th>
<th></th> <th></th>
<th></th> <th></th>
@ -62,44 +62,12 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
</div> </div>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Select the table and footer cells
const table = document.querySelector("#tickets-table");
const tbody = table.querySelector("tbody");
const footer = table.querySelector("tfoot tr");
let totalPolicies = 0;
let totalPremium = 0;
let totalRevenue = 0;
// Loop through each row in the table body and accumulate totals
tbody.querySelectorAll("tr").forEach(row => {
const policies = parseInt(row.cells[1].textContent) || 0;
const premium = parseFloat(row.cells[2].textContent.replace(/[^0-9.-]+/g, "")) || 0;
const revenue = parseFloat(row.cells[3].textContent.replace(/[^0-9.-]+/g, "")) || 0;
totalPolicies += policies;
totalPremium += premium;
totalRevenue += revenue;
});
// Append totals to the footer
footer.innerHTML = `
<th>Grand Total</th>
<th>${totalPolicies}</th>
<th>${totalPremium.toFixed(2)}</th>
<th>${totalRevenue.toFixed(2)}</th>
`;
});
</script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable'); var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) { if (ticketsTable.length) {
ticketsTable.DataTable({ ticketsTable.DataTable({
scrollX: true, scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
@ -109,18 +77,16 @@ if (ticketsTable.length) {
{ {
extend: 'csv', extend: 'csv',
text: 'CSV', text: 'CSV',
title: 'Policy-Tranction-BDS-List', title: 'Bap-Wise-Report-List',
}, },
{ {
extend: 'excel', extend: 'excel',
text: 'Excel', text: 'Excel',
title: 'Policy-Tranction-BDS-List', title: 'Bap-Wise-Report-List',
exportOptions: { exportOptions: {
orthogonal: 'sort' orthogonal: 'sort'
}, },
} }
], ],
language: { language: {
search: "_INPUT_", search: "_INPUT_",
@ -129,10 +95,37 @@ if (ticketsTable.length) {
paging: true, // Enable pagination paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional) pageLength: 10, // Set default number of rows per page (optional)
ordering: false, ordering: false,
footerCallback: function(row, data, start, end, display) {
var api = this.api();
// Helper function to parse numbers
var parseNumber = function(value) {
return typeof value === 'string' ?
parseFloat(value.replace(/[\$,]/g, '')) :
typeof value === 'number' ? value : 0;
};
// Calculate total for each column
var totalPolicies = api.column(1).data().reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
var totalPremium = api.column(2).data().reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
var totalRevenue = api.column(3).data().reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
// Update the footer with totals
$(api.column(1).footer()).html(totalPolicies.toLocaleString());
$(api.column(2).footer()).html("" + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 }));
$(api.column(3).footer()).html("" + totalRevenue.toLocaleString(undefined, { minimumFractionDigits: 2 }));
}
}); });
} else { } else {
console.error("Table atet found."); console.error("Table not found.");
} }
}); });
</script> </script>

View File

@ -59,8 +59,10 @@
</div> </div>
</div> </div>
</div> </div>
<div id="report"></div> <div class="card mb-1">
<div id="report"></div>
</div>
<script> <script>
$(function() { $(function() {
@ -69,6 +71,7 @@
var start = moment(start, 'DD/MM/YYYY'); var start = moment(start, 'DD/MM/YYYY');
var end = moment(end, 'DD/MM/YYYY'); var end = moment(end, 'DD/MM/YYYY');
function cb(start, end) { function cb(start, end) {
$('#reportrange span').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY')); $('#reportrange span').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
$('#startDate').val(start.format('DD-MM-YYYY')); $('#startDate').val(start.format('DD-MM-YYYY'));
@ -134,6 +137,11 @@
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}else{
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
let message = response.message;
toastr.error(message,'ERROR');
} }

View File

@ -84,8 +84,6 @@
<!-- <script src="<?= base_url('public/unlayer/js/embed.js') . '' ?>"></script> --> <!-- <script src="<?= base_url('public/unlayer/js/embed.js') . '' ?>"></script> -->
<!-- srinivas --> <!-- srinivas -->
<style> <style>
body[data-sidebar-size=condensed]:not([data-layout=compact]):not(.auth-fluid-pages) { body[data-sidebar-size=condensed]:not([data-layout=compact]):not(.auth-fluid-pages) {
min-height: 0; min-height: 0;
} }
@ -718,7 +716,7 @@
<a href="<?= base_url('/policy_tranction/report/report-outstanding-list') ?>">Outstanding</a> <a href="<?= base_url('/policy_tranction/report/report-outstanding-list') ?>">Outstanding</a>
</li> </li>
<li> <li>
<a href="<?= base_url('/bdsReport/irba_report') ?>">IRBA Reports</a> <a href="<?= base_url('/bdsReport/irba_report') ?>">IRDA Reports</a>
</li> </li>
<?php } ?> <?php } ?>
@ -741,7 +739,9 @@
<li> <li>
<a href="<?= base_url('/policy_tranction/report/report-business-list') ?>">Business Team</a> <a href="<?= base_url('/policy_tranction/report/report-business-list') ?>">Business Team</a>
</li> </li>
</li></ul></div> </li>
</ul>
</div>
<li> <li>
<a href="#policyMasters" data-toggle="collapse" class="waves-effect"> <a href="#policyMasters" data-toggle="collapse" class="waves-effect">
@ -756,7 +756,8 @@
<li> <li>
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a> <a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
</li> </li>
</ul></div> </ul>
</div>
</li> </li>
<li> <li>