nhance/app/Views/client_deposit_list.php

216 lines
10 KiB
PHP
Executable File

<?php
helper('datatable_view');
$cd_header_labels = ['Insurer Name', 'Insurer Branch Name', 'CD Account Number', 'Current Balance', 'Action'];
$cd_col_count = count($cd_header_labels);
$cd_col_max_len = array_fill(0, $cd_col_count, 0);
for ($i = 0; $i < $cd_col_count; $i++) {
$cd_col_max_len[$i] = mb_strlen($cd_header_labels[$i]);
}
$balances = $balances ?? [];
$clientData = $clientData ?? [];
foreach ($clientData as $value) {
$cd_col_max_len[0] = max($cd_col_max_len[0], mb_strlen((string) ($value->insurer_name ?? '')));
$cd_col_max_len[1] = max($cd_col_max_len[1], mb_strlen((string) ($value->insurer_branch_name ?? '')));
$cd_col_max_len[2] = max($cd_col_max_len[2], mb_strlen((string) ($value->cd_master_account_no ?? '')));
$insurerId = $value->insurer_id;
$cd_ac_pk = $value->cd_ac_pk;
$balStr = 'N/A';
if (isset($balances[$insurerId . '-' . $cd_ac_pk])) {
$balStr = (string) ($balances[$insurerId . '-' . $cd_ac_pk]->balance ?? '');
}
$balDisplay = '₹ ' . $balStr;
$cd_col_max_len[3] = max($cd_col_max_len[3], mb_strlen($balDisplay));
$cd_col_max_len[4] = max($cd_col_max_len[4], mb_strlen('View Deposit'));
}
$cd_col_min_px = [100, 120, 120, 100, 120];
$cd_col_max_px = [240, 280, 280, 200, 160];
$cd_col_width_px = nhance_dt_column_widths_px($cd_header_labels, $cd_col_max_len, $cd_col_min_px, $cd_col_max_px);
?>
<style>
<?php for ($i = 0; $i < $cd_col_count; $i++) : ?>
#client-deposit-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
#client-deposit-list-table thead th:nth-child(<?= $i + 1 ?>) {
min-width: <?= (int) $cd_col_width_px[$i] ?>px;
width: <?= (int) $cd_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
overflow: visible !important;
}
#client-deposit-list-table tbody td:nth-child(<?= $i + 1 ?>) {
width: <?= (int) $cd_col_width_px[$i] ?>px;
max-width: <?= (int) $cd_col_width_px[$i] ?>px;
min-width: <?= (int) $cd_col_width_px[$i] ?>px;
box-sizing: border-box;
vertical-align: middle;
}
<?php endfor; ?>
#client-deposit-list-table tbody td:nth-child(1),
#client-deposit-list-table tbody td:nth-child(2),
#client-deposit-list-table tbody td:nth-child(3),
#client-deposit-list-table tbody td:nth-child(4) {
overflow: hidden;
text-overflow: ellipsis;
}
#client-deposit-list-table tbody td:nth-child(5) {
overflow: visible;
text-overflow: clip;
white-space: nowrap;
text-align: center;
}
#client-deposit-list-table .view-deposit-link {
display: inline-flex;
align-items: center;
gap: 0.35rem;
padding: 0.25rem 0.5rem;
border-radius: 0.25rem;
text-decoration: none;
}
#client-deposit-list-table .view-deposit-link:hover {
background-color: #f5f7fa;
}
#client-deposit-list-table tbody td {
padding: 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
#client-deposit-list-table_wrapper .dataTables_scrollHead table thead th,
#client-deposit-list-table thead th {
padding: 5px 2.35rem 5px 11px !important;
font-size: 13px;
line-height: 1.25;
}
</style>
<script>
var pageHideMainNavTitle = true;
var pageTitle = 'Client Deposit - <?= $clientName[0]["client_name"]; ?>';
var pageBackButton = '<a href="<?= base_url("client/list"); ?>" class="topbar-icon-btn" data-toggle="tooltip" data-placement="top" title="Back to Client List" aria-label="Back to Client List"><i class="ri-arrow-left-s-line"></i></a>';
</script>
<div class="row" id="client_list">
<div class="col-12">
<div class="card">
<div class="card-body">
<!-- <div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Client Deposit -
<?php echo $clientName[0]['client_name'];?></h4>
</div>
<div class="col-6" style="text-align: right;">
<a href="<?= base_url("client/list"); ?>"><i class="mdi mdi-arrow-left" style="font-size: 17px;"></i></a>
</div>
<!- <div class="col-6" style="text-align: right; position: relative;top: 53px;">
<a href="<?= base_url("client/client_deposit"); ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">ADD</a>
</div> ->
</div> -->
<div class="table-responsive">
<table data-custom-table-css="table" class="table mb-0 nowrap w-100 table-centered" cellspacing="0" id="client-deposit-list-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Insurer Name&nbsp;</th>
<th class="font-weight-medium">Insurer Branch Name&nbsp;</th>
<th class="font-weight-medium">CD Account Number&nbsp;</th>
<th class="font-weight-medium">Current Balance&nbsp;</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($clientData as $value): ?>
<tr>
<td><?php echo $value->insurer_name;?></td>
<td><?php echo $value->insurer_branch_name;?></td>
<td><?php echo $value->cd_master_account_no;?></td>
<td>₹
<?php
$insurerId = $value->insurer_id;
$cd_ac_pk = $value->cd_ac_pk;
// Check if the balance information exists for the insurer
if (isset($balances[$insurerId . '-'. $cd_ac_pk])) {
$balance = $balances[$insurerId . '-'. $cd_ac_pk]->balance;
echo $balance;
} else {
echo "N/A"; // Display "Not Available" if balance information is not present
}
?>
</td>
<td>
<a class="view-deposit-link"
href="<?= base_url("client/view_deposit/{$value->insurer_id}?client_id={$value->client_id}&cd_ac_pk={$value->cd_ac_pk}"); ?>">
<i class="mdi mdi-eye text-muted font-18 vertical-middle"></i><span>View Details</span>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<script>
$(document).ready(function() {
nhanceListDataTableBeforeInit();
var nhDepositTable = $('#client-deposit-list-table').DataTable(nhanceMergeListDataTableOptions({
// dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>",
dom: "<'row'<'col-12 d-flex justify-content-between align-items-center'<'datatable-search dataTables_filter'f><'datatable-buttons dt-buttons'B>>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'Client Deposit Details - ' + ' <?php echo $clientName[0]['client_name'];?>',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
},
{
extend: 'pdf',
text: '<i class="mdi mdi-file-pdf " ></i><span class=" btn-custom"> PDF </span>',
title: 'Client Deposit Details - ' + ' <?php echo $clientName[0]['client_name'];?>',
exportOptions: {
columns: ':not(:last-child)'
},
className: 'app-btn-primary ',
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"
style="position:absolute; right:11px; top:50%; transform:translateY(-53%); color:#666;"></i>
<i class="mdi mdi-close-circle datatable-clear-icon"
style="position:absolute; right:11px; top:50%; transform:translateY(-53%); color:#666; display:none;"></i>
</div>`,
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
columnDefs: [
<?php for ($i = 0; $i < $cd_col_count; $i++) : ?>
{ targets: <?= $i ?>, width: '<?= (int) $cd_col_width_px[$i] ?>px' },
<?php endfor; ?>
],
}));
nhanceListDataTableAfterInit();
nhanceListDataTableBindAdjust(nhDepositTable);
$('.dataTables_length label').css('height', '21px');
})
</script>