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

This commit is contained in:
Srinivas-Saravanan 2025-01-24 11:18:12 +05:30
commit c0d5d49a93
6 changed files with 336 additions and 96 deletions

View File

@ -130,6 +130,7 @@ class BDSReportController extends AdminController
];
return $this->loadLayout('irba_report', $data);
} else {
$fromDate = $this->request->getPost('fromDate');
$toDate = $this->request->getPost('toDate');
$category = $this->request->getPost('category');
@ -150,6 +151,7 @@ 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') {
$life = $category == 'life' ? 1 : 0;
$viewData = $this->Bap_wise_Data($life, $fromDate, $toDate);
if (isset($data['message'])) {
@ -163,6 +165,31 @@ class BDSReportController extends AdminController
$html = view('bds_report_bap_wise_data', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200);
} else if($report_type == 'bapInsurer'){
//Condition for BAP Insurer wise date
$category = $category == 'life' ? 1 : 0;
$viewData['data'] = $this->getBAPInsurerData($category, $fromDate, $toDate);
$html = view('irda_bap_insurer_report_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200);
}else if($report_type == 'bapClient'){
//Condition for BAP Client wise date
$category = $category == 'life' ? 1 : 0;
$viewData['data'] = $this->getBAPClientData($category, $fromDate, $toDate);
$html = view('irda_bap_client_report_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200);
}else if($report_type == 'client'){
//Condition for Client wise date
$category = $category == 'life' ? 1 : 0;
$viewData['data'] = $this->getClientData($category, $fromDate, $toDate);
$html = view('irda_client_report_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200);
}
}
@ -184,8 +211,8 @@ class BDSReportController extends AdminController
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = $start_date;
$toDate = $end_date;
$fromDate = change_date_format($start_date);
$toDate = change_date_format($end_date);
}
$this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]);
@ -242,7 +269,47 @@ class BDSReportController extends AdminController
-- Marine Hull Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium,
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END), 0) AS marine_hull_revenue,
-- Grand Totals
COALESCE(
SUM(CASE WHEN ptp.bap = 'Health' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Life' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Motor' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Fire' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Engineering' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Liability' AND pt.action_type = 'inception' THEN 1 ELSE 0 END)+
SUM(CASE WHEN ptp.bap = 'Marine Cargo' AND pt.action_type = 'inception' THEN 1 ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Misc' AND pt.action_type = 'inception' THEN 1 ELSE 0 END),
0
) AS total_policy_count,
COALESCE(
SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+
SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END)+
SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END),
0
) AS total_premium,
COALESCE(
SUM(CASE WHEN ptp.bap = 'Health' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Life' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Motor' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Fire' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Engineering' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END) +
SUM(CASE WHEN ptp.bap = 'Liability' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END)+
SUM(CASE WHEN ptp.bap = 'Marine Cargo' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END)+
SUM(CASE WHEN ptp.bap = 'Misc' THEN stmt.actual_bp_brokerage_amt + stmt.actual_tp_brokerage_amt + stmt.actual_tep_brokerage_amt + stmt.reward ELSE 0 END),
0
) AS total_revenue
from insurers ins
left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1
@ -292,8 +359,8 @@ class BDSReportController extends AdminController
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = $start_date;
$toDate = $end_date;
$fromDate = change_date_format($start_date);
$toDate = change_date_format($end_date);
}
$this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]);
@ -339,7 +406,11 @@ class BDSReportController extends AdminController
-- Marine Hull Policies
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' AND pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS marine_hull_policy_count,
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium
COALESCE(SUM(CASE WHEN ptp.bap = 'Marine Hull' THEN stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt ELSE 0 END), 0) AS marine_hull_premium,
-- Grand Totals
COALESCE(SUM(CASE WHEN pt.action_type = 'inception' THEN 1 ELSE 0 END), 0) AS total_policy_count,
COALESCE(SUM(stmt.actual_bp_amt + stmt.actual_tp_amt + stmt.actual_tep_amt), 0) AS total_premium
FROM clients c
LEFT JOIN policy_transaction pt ON pt.client_id = c.id AND pt.is_active = 1 AND pt.policy_issue_date >= '$fromDate' AND pt.policy_issue_date <= '$toDate'
@ -390,8 +461,8 @@ class BDSReportController extends AdminController
$toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) {
$fromDate = $start_date;
$toDate = $end_date;
$fromDate = change_date_format($start_date);
$toDate = change_date_format($end_date);
}
$this->myLogger->logme('error', 'From date : {fromDate} - To date {toDate} ', ['fromDate' => $fromDate, 'toDate' => $toDate]);
@ -428,12 +499,9 @@ class BDSReportController extends AdminController
), 0) as premium
from clients c
join policy_transaction on c.id = policy_transaction.client_id
join policy_type on policy_transaction.policy_type_id = policy_type.id
join policy_transaction on c.id = policy_transaction.client_id AND policy_transaction.policy_issue_date >= '$fromDate' AND policy_transaction.policy_issue_date <= '$toDate'
join policy_type on policy_transaction.policy_type_id = policy_type.id and policy_type.policy_category = $category
where c.is_active = 1
and policy_type.policy_category = $category
AND policy_transaction.policy_issue_date >= '$fromDate'
AND policy_transaction.policy_issue_date <= '$toDate'
group by client_name
order by premium desc
");

View File

@ -4049,13 +4049,13 @@ class ClientController extends AdminController
$BDSReportController = new BDSReportController();
$data['data'] = $BDSReportController->getBAPInsurerData();
return $this->loadLayout('irda_bap_insurer_report_list', $data);
// $data['data'] = $BDSReportController->getBAPInsurerData();
// return $this->loadLayout('irda_bap_insurer_report_list', $data);
// $data['data'] = $BDSReportController->getBAPClientData();
// return $this->loadLayout('irda_bap_client_report_list', $data);
$data['data'] = $BDSReportController->getBAPClientData();
return $this->loadLayout('irda_bap_client_report_list', $data);
// $data['data'] = $BDSReportController->getClientData();
// $data['data'] = $BDSReportController->getClientData(1);
// return $this->loadLayout('irda_client_report_list', $data);
// $BDSReportController->getBAPClientData();

View File

@ -546,6 +546,7 @@ if (!function_exists('change_date_format')) {
'Y,m,d', // 2024,12,01
'd/m/Y', // 01/01/2025
'd-m-Y', // 01-01-2025
];

View File

@ -95,14 +95,16 @@
});
</script>
<script>
$('#category').on('click', function() {
$('#category').on('click', function(){
var choosed_option = $('#category').val();
if (choosed_option == 'life') {
$("#report_type option[value='insurer']").show();
$("#report_type option[value='bap']").hide();
$("#report_type option[value='bapClient']").hide();
$("#report_type option[value='bapInsurer']").hide();
$("#report_type option[value='client']").show();
$("#report_type").val('0');
if (choosed_option == 'life' ){
$("#report_type option[value='insurer']").show();
$("#report_type option[value='bap']").hide();
$("#report_type option[value='bapClient']").hide();
$("#report_type option[value='bapInsurer']").hide();
$("#report_type option[value='client']").show();
} else if (choosed_option == 'nonLife') {
$("#report_type option[value='insurer']").show();

View File

@ -33,6 +33,7 @@ table.dataTable tbody td {
</div>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
@ -47,6 +48,7 @@ table.dataTable tbody td {
<th colspan="2" style="text-align: center;">Misc</th>
<th colspan="2" style="text-align: center;">Motor</th>
<th colspan="2" style="text-align: center;">Marine Hull</th>
<th colspan="2" style="text-align: center;">Grand Total</th>
</tr>
<tr>
@ -56,42 +58,37 @@ table.dataTable tbody td {
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
<th>Policies</th>
<th>Premium</th>
</tr>
</thead>
<tbody>
<?php if (isset($data) && !empty($data)) { ?>
@ -128,11 +125,53 @@ table.dataTable tbody td {
<td class="right-align-input"><?php echo $row['motor_policy_count'] ?></td>
<td class="right-align-input"><?php echo $row['motor_premium']; ?></td>
<td class="right-align-input"><?php echo $row['total_policy_count'] ?></td>
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th></th>
<th>Grand Total</th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
</tr>
</tfoot>
</table>
<div>
@ -165,47 +204,9 @@ $(document).ready(function() {
extend: 'excel',
text: 'Excel',
title: 'IRDA-BAP-CLIENT-List',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var total = 0;
// Find cells in column AB (28th column in Excel)
$('row c[r^="AB"]', sheet).each(function() {
var value = parseFloat($('v', this)
.text()); // Get the value inside the cell
if (!isNaN(value)) {
total += value;
}
});
// Get the last row index and append the total row
var lastRow = $('row:last', sheet);
var rowIndex = parseInt(lastRow.attr('r')) +
2; // Find the next row index
var totalRow = '<row r="' + rowIndex + '">' +
'<c t="inlineStr" r="AA' + rowIndex +
'"><is><t>Total</t></is></c>' + // Insert "Total" in AA
'<c t="n" r="AB' + rowIndex + '"><v>' + total.toFixed(2) +
'</v></c>' + // Insert sum in AB
'</row>';
// Append the new total row to the sheet
$(sheet).find('sheetData').append(totalRow);
},
exportOptions: {
orthogonal: 'sort'
},
customizeData: function(data) {
for (var i = 0; i < data.body.length; i++) {
for (var j = 0; j < data.body[i].length; j++) {
// Check if the column is the 9th index (10th column)
if (j === 9) {
data.body[i][j] = '\u200C' + data.body[i][j];
}
}
}
}
}
],
@ -214,8 +215,57 @@ $(document).ready(function() {
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
pageLength: 20, // 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;
};
// Define column groups for total calculations
var columnGroups = [
{ policy: 2, premium: 3 },
{ policy: 4, premium: 5},
{ policy: 6, premium: 7 },
{ policy: 8, premium: 9 },
{ policy: 10, premium: 11 },
{ policy: 12, premium: 13 },
{ policy: 14, premium: 15 },
{ policy: 16, premium: 17 },
{ policy: 18, premium: 19 },
{ policy: 20, premium: 21 }
];
// Loop through each column group to calculate totals and update the footer
columnGroups.forEach(function(group) {
var totalPolicies = api
.column(group.policy)
.data()
.reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
var totalPremium = api
.column(group.premium)
.data()
.reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
// Update the footer
$(api.column(group.policy).footer()).html(totalPolicies.toLocaleString());
$(api.column(group.premium).footer()).html(
"" + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 })
);
});
}
});
} else {
console.error("Table atet found.");

View File

@ -46,6 +46,7 @@ table.dataTable tbody td {
<th colspan="3" style="text-align: center;">Misc</th>
<th colspan="3" style="text-align: center;">Motor</th>
<th colspan="3" style="text-align: center;">Marine Hull</th>
<th colspan="3" style="text-align: center;">Grand Total</th>
</tr>
<tr>
@ -87,10 +88,15 @@ table.dataTable tbody td {
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
<th>Policies</th>
<th>Premium</th>
<th>Revenue</th>
</tr>
</thead>
<tbody>
<?php if (isset($data) && !empty($data)) { ?>
@ -136,11 +142,64 @@ table.dataTable tbody td {
<td class="right-align-input"><?php echo $row['motor_premium']; ?></td>
<td class="right-align-input"><?php echo $row['motor_revenue']; ?></td>
<td class="right-align-input"><?php echo $row['total_policy_count'] ?></td>
<td class="right-align-input"><?php echo $row['total_premium']; ?></td>
<td class="right-align-input"><?php echo $row['total_revenue']; ?></td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th></th>
<th>Grand Total</th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
<th class="right-align-input"></th>
</tr>
</tfoot>
</table>
<div>
@ -222,8 +281,68 @@ $(document).ready(function() {
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
pageLength: 20, // 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;
};
// Define column groups for total calculations
var columnGroups = [
{ policy: 2, premium: 3, revenue: 4 },
{ policy: 5, premium: 6, revenue: 7 },
{ policy: 8, premium: 9, revenue: 10 },
{ policy: 11, premium: 12, revenue: 13 },
{ policy: 14, premium: 15, revenue: 16 },
{ policy: 17, premium: 18, revenue: 19 },
{ policy: 20, premium: 21, revenue: 22 },
{ policy: 23, premium: 24, revenue: 25 },
{ policy: 26, premium: 27, revenue: 28 },
{ policy: 29, premium: 30, revenue: 31 }
];
// Loop through each column group to calculate totals and update the footer
columnGroups.forEach(function(group) {
var totalPolicies = api
.column(group.policy)
.data()
.reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
var totalPremium = api
.column(group.premium)
.data()
.reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
var totalRevenue = api
.column(group.revenue)
.data()
.reduce(function(a, b) {
return parseNumber(a) + parseNumber(b);
}, 0);
// Update the footer
$(api.column(group.policy).footer()).html(totalPolicies.toLocaleString());
$(api.column(group.premium).footer()).html(
"" + totalPremium.toLocaleString(undefined, { minimumFractionDigits: 2 })
);
$(api.column(group.revenue).footer()).html(
"" + totalRevenue.toLocaleString(undefined, { minimumFractionDigits: 2 })
);
});
}
});
} else {
console.error("Table atet found.");