FEAT_IRDA_REPORT_SRINIVAS
This commit is contained in:
parent
560d4328a8
commit
c73564ec72
@ -46,15 +46,13 @@ class BDSReportController extends AdminController
|
||||
$this->PTCOShareDetailsModel = new PTCOShareDetailsModel();
|
||||
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
|
||||
$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');
|
||||
$toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d');
|
||||
|
||||
if($insurerCategory == 0 || $insurerCategory == 1){
|
||||
try {
|
||||
$sql = "
|
||||
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,
|
||||
@ -63,28 +61,29 @@ class BDSReportController extends AdminController
|
||||
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 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
|
||||
where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null)
|
||||
group by ins.id
|
||||
";
|
||||
|
||||
$data['insurer_wise_data'] = $this->insurerModel->query($sql)->getResultArray();
|
||||
|
||||
|
||||
}else{
|
||||
$data['message'] = 'Insurer Category Not Valid';
|
||||
log_message('error',$data['message']);
|
||||
// log_message('error',$this->insurerModel->getLastQuery());
|
||||
// log_message('error',json_encode($data));
|
||||
} catch (\Exception $e) {
|
||||
$data['message'] = 'No data Found';
|
||||
$this->myLogger->logme('error', $e->getMessage());
|
||||
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');
|
||||
$toDate = \DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d');
|
||||
|
||||
if($insurerCategory == 0 || $insurerCategory == 1){
|
||||
try {
|
||||
$sql = "
|
||||
SELECT
|
||||
pot.bap AS bap,
|
||||
@ -92,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.reward + co.actual_bp_brokerage_amt + co.actual_tep_brokerage_amt + co.actual_tp_brokerage_amt), 0) AS Revenue
|
||||
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 co_share_stmt_details AS co ON ptco.id = co.co_share_id AND co.is_active = 1
|
||||
WHERE pot.is_active = 1
|
||||
@ -101,24 +100,26 @@ class BDSReportController extends AdminController
|
||||
|
||||
";
|
||||
$data['bap_wise_data'] = $this->policyTypeModel->query($sql)->getResultArray();
|
||||
}else{
|
||||
$data['message'] = 'Insurer Category Not Valid';
|
||||
log_message('error',$data['message']);
|
||||
} catch (\Exception $e) {
|
||||
$data['message'] = 'No Data Found';
|
||||
$this->myLogger->logme('error', $e->getMessage());
|
||||
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();
|
||||
$data['default_end'] = $default_start->format('d-m-Y');
|
||||
$data['default_start'] = $default_start->modify('-90 days')->format('d-m-Y');
|
||||
$data['categories'] = [
|
||||
'Life' => 'life','Non Life'=>'nonLife'
|
||||
'Life' => 'life',
|
||||
'Non Life' => 'nonLife'
|
||||
];
|
||||
$data['report_type'] = [
|
||||
'Insurer' => 'insurer',
|
||||
@ -137,7 +138,9 @@ class BDSReportController extends AdminController
|
||||
if ($report_type == 'insurer') {
|
||||
$life = $category == 'life' ? 1 : 0;
|
||||
$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
|
||||
if (!is_array($viewData)) {
|
||||
$viewData = [];
|
||||
@ -145,11 +148,12 @@ class BDSReportController extends AdminController
|
||||
|
||||
$html = view('bds_report_Insurer_wise_Data', $viewData);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
else if($report_type == 'bap'){
|
||||
} else if ($report_type == 'bap') {
|
||||
$life = $category == 'life' ? 1 : 0;
|
||||
$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
|
||||
if (!is_array($viewData)) {
|
||||
$viewData = [];
|
||||
@ -158,7 +162,6 @@ class BDSReportController extends AdminController
|
||||
$html = view('bds_report_bap_wise_data', $viewData);
|
||||
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<style>
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
@ -10,7 +9,6 @@ table.dataTable tbody td {
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
@ -22,6 +20,7 @@ table.dataTable tbody td {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@ -52,7 +51,7 @@ table.dataTable tbody td {
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Total Amount</th>
|
||||
<th>Grand Total</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
@ -63,44 +62,12 @@ table.dataTable tbody td {
|
||||
</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>
|
||||
$(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>>" + // Filter left, buttons right
|
||||
@ -110,18 +77,16 @@ if (ticketsTable.length) {
|
||||
{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'Policy-Tranction-BDS-List',
|
||||
title: 'Insurer-Wise-Report-List',
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
title: 'Policy-Tranction-BDS-List',
|
||||
title: 'Insurer-Wise-Report-List',
|
||||
exportOptions: {
|
||||
orthogonal: 'sort'
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
@ -130,9 +95,37 @@ if (ticketsTable.length) {
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
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 {
|
||||
console.error("Table atet found.");
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<style>
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
@ -10,7 +9,6 @@ table.dataTable tbody td {
|
||||
}
|
||||
|
||||
.col-12 {
|
||||
|
||||
max-width: 98% !important;
|
||||
}
|
||||
|
||||
@ -22,6 +20,7 @@ table.dataTable tbody td {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@ -31,7 +30,8 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
<th>Insurer</th>
|
||||
<th>Policies</th>
|
||||
@ -51,7 +51,7 @@ table.dataTable tbody td {
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Total Amount</th>
|
||||
<th>Grand Total</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
@ -62,44 +62,12 @@ table.dataTable tbody td {
|
||||
</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>
|
||||
$(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>>" + // Filter left, buttons right
|
||||
@ -109,18 +77,16 @@ if (ticketsTable.length) {
|
||||
{
|
||||
extend: 'csv',
|
||||
text: 'CSV',
|
||||
title: 'Policy-Tranction-BDS-List',
|
||||
title: 'Bap-Wise-Report-List',
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
text: 'Excel',
|
||||
title: 'Policy-Tranction-BDS-List',
|
||||
title: 'Bap-Wise-Report-List',
|
||||
exportOptions: {
|
||||
orthogonal: 'sort'
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
@ -129,10 +95,37 @@ if (ticketsTable.length) {
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
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 {
|
||||
console.error("Table atet found.");
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@ -59,8 +59,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="report"></div>
|
||||
<div class="card mb-1">
|
||||
|
||||
<div id="report"></div>
|
||||
</div>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
@ -69,6 +71,7 @@
|
||||
|
||||
var start = moment(start, 'DD/MM/YYYY');
|
||||
var end = moment(end, 'DD/MM/YYYY');
|
||||
|
||||
function cb(start, end) {
|
||||
$('#reportrange span').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
|
||||
$('#startDate').val(start.format('DD-MM-YYYY'));
|
||||
@ -132,6 +135,11 @@
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}else{
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
let message = response.message;
|
||||
toastr.error(message,'ERROR');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -84,8 +84,6 @@
|
||||
<!-- <script src="<?= base_url('public/unlayer/js/embed.js') . '' ?>"></script> -->
|
||||
<!-- srinivas -->
|
||||
<style>
|
||||
|
||||
|
||||
body[data-sidebar-size=condensed]:not([data-layout=compact]):not(.auth-fluid-pages) {
|
||||
min-height: 0;
|
||||
}
|
||||
@ -718,7 +716,7 @@
|
||||
<a href="<?= base_url('/policy_tranction/report/report-outstanding-list') ?>">Outstanding</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/bdsReport/irba_report') ?>">IRBA Reports</a>
|
||||
<a href="<?= base_url('/bdsReport/irba_report') ?>">IRDA Reports</a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
@ -741,7 +739,9 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/policy_tranction/report/report-business-list') ?>">Business Team</a>
|
||||
</li>
|
||||
</li></ul></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<li>
|
||||
<a href="#policyMasters" data-toggle="collapse" class="waves-effect">
|
||||
@ -756,7 +756,8 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
|
||||
</li>
|
||||
</ul></div>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user