365 lines
16 KiB
PHP
Executable File
365 lines
16 KiB
PHP
Executable File
<?php
|
|
helper('datatable_view');
|
|
$cdm_header_labels = [
|
|
'S.No', 'Client Name', 'Insurer Name', 'Insurer Branch Name', 'Opening Date', 'CD Account No', 'Opening Amount', 'Date/User', 'Action',
|
|
];
|
|
$cdm_col_count = count($cdm_header_labels);
|
|
$cdm_col_max_len = array_fill(0, $cdm_col_count, 0);
|
|
for ($i = 0; $i < $cdm_col_count; $i++) {
|
|
$cdm_col_max_len[$i] = mb_strlen($cdm_header_labels[$i]);
|
|
}
|
|
$CD_Master_Data = $CD_Master_Data ?? [];
|
|
foreach ($CD_Master_Data as $index => $row) {
|
|
$cdm_col_max_len[0] = max($cdm_col_max_len[0], mb_strlen((string) ($index + 1)));
|
|
$clientCell = ($row['client_name'] ?? '') . '( ' . ($row['short_name'] ?? '') . ' )';
|
|
$cdm_col_max_len[1] = max($cdm_col_max_len[1], mb_strlen($clientCell));
|
|
$cdm_col_max_len[2] = max($cdm_col_max_len[2], mb_strlen((string) ($row['insurer_name'] ?? '')));
|
|
$cdm_col_max_len[3] = max($cdm_col_max_len[3], mb_strlen((string) ($row['insurer_branch_name'] ?? '')));
|
|
$od = ! empty($row['opening_date']) ? date('d/m/Y', strtotime((string) $row['opening_date'])) : '';
|
|
$cdm_col_max_len[4] = max($cdm_col_max_len[4], mb_strlen($od));
|
|
$cdm_col_max_len[5] = max($cdm_col_max_len[5], mb_strlen((string) ($row['cd_ac_no'] ?? '')));
|
|
$cdm_col_max_len[6] = max($cdm_col_max_len[6], mb_strlen((string) ($row['opening_bal'] ?? '')));
|
|
$du = ! empty($row['created_at'])
|
|
? (date('d/m/Y h:i A', strtotime((string) $row['created_at'])) . ' by ' . ($row['user_name'] ?? ''))
|
|
: '';
|
|
$cdm_col_max_len[7] = max($cdm_col_max_len[7], mb_strlen($du));
|
|
$cdm_col_max_len[8] = max($cdm_col_max_len[8], 4);
|
|
}
|
|
$cdm_col_min_px = [48, 140, 120, 140, 100, 120, 100, 200, 72];
|
|
$cdm_col_max_px = [64, 400, 320, 360, 120, 200, 160, 480, 88];
|
|
$cdm_col_width_px = nhance_dt_column_widths_px($cdm_header_labels, $cdm_col_max_len, $cdm_col_min_px, $cdm_col_max_px);
|
|
?>
|
|
<style>
|
|
.col-12 {
|
|
|
|
max-width: 98% !important;
|
|
}
|
|
|
|
.column-header {margin-right: 10px;}
|
|
|
|
|
|
|
|
.dataTables_length label {height: 21px !important;}
|
|
|
|
|
|
</style>
|
|
|
|
<style>
|
|
<?php for ($i = 0; $i < $cdm_col_count; $i++) : ?>
|
|
#cd-master-list-table_wrapper .dataTables_scrollHead table thead th:nth-child(<?= $i + 1 ?>),
|
|
#cd-master-list-table thead th:nth-child(<?= $i + 1 ?>) {
|
|
min-width: <?= (int) $cdm_col_width_px[$i] ?>px;
|
|
width: <?= (int) $cdm_col_width_px[$i] ?>px;
|
|
box-sizing: border-box;
|
|
vertical-align: middle;
|
|
overflow: visible !important;
|
|
}
|
|
#cd-master-list-table tbody td:nth-child(<?= $i + 1 ?>) {
|
|
width: <?= (int) $cdm_col_width_px[$i] ?>px;
|
|
max-width: <?= (int) $cdm_col_width_px[$i] ?>px;
|
|
min-width: <?= (int) $cdm_col_width_px[$i] ?>px;
|
|
box-sizing: border-box;
|
|
vertical-align: middle;
|
|
}
|
|
<?php endfor; ?>
|
|
#cd-master-list-table tbody td:not(:last-child) {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
#cd-master-list-table tbody td:last-child {
|
|
overflow: visible;
|
|
text-overflow: clip;
|
|
}
|
|
#cd-master-list-table tbody td {
|
|
padding: 5px 11px !important;
|
|
font-size: 13px;
|
|
line-height: 1.25;
|
|
}
|
|
#cd-master-list-table thead th {
|
|
padding: 5px 2.35rem 5px 11px !important;
|
|
font-size: 13px;
|
|
line-height: 1.25;
|
|
}
|
|
</style>
|
|
|
|
<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;">CD Master</h4>
|
|
</div>
|
|
<div class="col-6" style="text-align: right; position: relative;top: 56px;">
|
|
<!- <button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light"
|
|
data-toggle="modal" data-target="#con-close-modal" data-placement="top" title="Add"
|
|
data-trigger="hover">ADD</button> ->
|
|
</div>
|
|
</div> -->
|
|
|
|
<table data-custom-table-css="table" data-nhance-list-dt="1" id="cd-master-list-table" class="table mb-0 nowrap" cellspacing="0">
|
|
<thead class="bg-light">
|
|
<tr>
|
|
<th class="font-weight-medium">S.No </th>
|
|
<th class="font-weight-medium">Client Name </th>
|
|
<th class="font-weight-medium">Insurer Name </th>
|
|
<th class="font-weight-medium">Insurer Branch Name </th>
|
|
<th class="font-weight-medium">Opening Date </th>
|
|
<th class="font-weight-medium">CD Account No </th>
|
|
<th class="font-weight-medium">Opening Amount </th>
|
|
<th class="font-weight-medium">Date/User </th>
|
|
<th class="font-weight-medium text-center">Action </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach($CD_Master_Data as $index => $row){ ?>
|
|
<tr>
|
|
<td><?= $index + 1; ?></td>
|
|
<td><?php echo $row['client_name']; ?>( <?= $row['short_name'] ?> )</td>
|
|
<td><?php echo $row['insurer_name']; ?></td>
|
|
<td><?php echo $row['insurer_branch_name']; ?></td>
|
|
<td><?php echo date('d/m/Y', strtotime($row['opening_date'])); ?></td>
|
|
<td><?php echo $row['cd_ac_no']; ?></td>
|
|
<td><?php echo $row['opening_bal']; ?></td>
|
|
<td><?php echo date('d/m/Y h:i A', strtotime($row['created_at'])) ?> <br>by <?php echo $row['user_name']; ?></td>
|
|
<td class="text-center table-action-cell">
|
|
<div class="btn-group dropdown">
|
|
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
|
<div class="dropdown-menu dropdown-menu-right">
|
|
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
|
<?php if($row['cd_ac_no_count'] == 0) { ?>
|
|
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div><!-- end col -->
|
|
</div>
|
|
<!-- end row -->
|
|
|
|
<?php include("cd_master_add_modal.php"); ?>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
nhanceListDataTableBeforeInit();
|
|
var table = $('#cd-master-list-table').DataTable(nhanceMergeListDataTableOptions({
|
|
// 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>>",
|
|
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'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: [
|
|
{
|
|
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
|
|
className: 'btn app-btn-primary mr-2',
|
|
action: function (e, dt, node, config) {
|
|
showCdMasterAddModal();
|
|
}
|
|
},
|
|
{
|
|
extend: 'collection',
|
|
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
|
className: 'btn app-btn-secondary ',
|
|
buttons: [
|
|
{
|
|
extend: 'csv',
|
|
title: 'CD-Master-List',
|
|
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
|
className: 'app-btn-primary my_class',
|
|
exportOptions: {
|
|
columns: ':not(:last-child)'
|
|
},
|
|
},
|
|
{
|
|
extend: 'excel',
|
|
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
|
|
sheetName: 'CD-Master-List',
|
|
exportOptions: {
|
|
orthogonal: 'sort'
|
|
},
|
|
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:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
|
<i class="mdi mdi-close-circle datatable-clear-icon"
|
|
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
|
</div>`,
|
|
searchPlaceholder: "Search",
|
|
emptyTable: '<div class="text-center text-muted">No Data found</div>',
|
|
paginate: {
|
|
previous: '◄',
|
|
next: '►'
|
|
}
|
|
},
|
|
paging: true,
|
|
pageLength: 10,
|
|
order: [[0, 'desc']],
|
|
columnDefs: [
|
|
<?php for ($i = 0; $i < $cdm_col_count; $i++) : ?>
|
|
{ targets: <?= $i ?>, width: '<?= (int) $cdm_col_width_px[$i] ?>px' },
|
|
<?php endfor; ?>
|
|
],
|
|
// 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: 'CD-Master-List',
|
|
// className: 'my_class',
|
|
// exportOptions: {
|
|
// columns: ':not(:last-child)'
|
|
// },
|
|
// },
|
|
// {
|
|
// text: 'Add',
|
|
// className: 'buttons-html5 ',
|
|
// action: function (e, dt, node, config) {
|
|
// showCdMasterAddModal();
|
|
// }
|
|
// }
|
|
// ],
|
|
// language: {
|
|
// search: "_INPUT_",
|
|
// searchPlaceholder: "Search..."
|
|
// },
|
|
// paging: true,
|
|
}));
|
|
nhanceListDataTableAfterInit();
|
|
nhanceListDataTableBindAdjust(table);
|
|
|
|
function applyBottomRowDropup() {
|
|
if (!table) return;
|
|
const currentRows = table.rows({ page: 'current' }).nodes().toArray();
|
|
$('#cd-master-list-table tbody tr').removeClass('nh-force-dropup');
|
|
$('#cd-master-list-table tbody tr td.table-action-cell .btn-group.dropdown').removeClass('dropup');
|
|
|
|
const targetCount = Math.min(2, currentRows.length);
|
|
for (let i = 0; i < targetCount; i++) {
|
|
const row = currentRows[currentRows.length - 1 - i];
|
|
if (!row) continue;
|
|
$(row).addClass('nh-force-dropup');
|
|
$(row).find('td.table-action-cell .btn-group.dropdown').addClass('dropup');
|
|
}
|
|
}
|
|
applyBottomRowDropup();
|
|
$('#cd-master-list-table').on('draw.dt', applyBottomRowDropup);
|
|
})
|
|
|
|
$(document).ready(function(){
|
|
|
|
<?php if (session()->has('error')) : ?>
|
|
toastr.error('<?= session()->getFlashdata('error') ?>', 'Failed');
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->has('success')) : ?>
|
|
toastr.success('<?= session()->getFlashdata('success') ?>', 'Success');
|
|
<?php endif; ?>
|
|
})
|
|
|
|
$('body').on('click', '.btnEdit', function () {
|
|
|
|
var cd_id = $(this).attr('data-id');
|
|
$('#title').html('Update Opening Amount');
|
|
|
|
$.ajax({
|
|
url: '<?php echo base_url('master/cash_deposite/list/');?>'+cd_id,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function (res) {
|
|
|
|
console.log(res)
|
|
|
|
$('#updateModal').modal('show');
|
|
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/edit');?>');
|
|
$('#CD_Master_ID').val(res.data.id);
|
|
$('#cd_client_id').val(res.data.client_id).change();
|
|
$('#cd_client_id').prop("disabled", true);
|
|
$('#insurer_id_for_cd').val(res.data.insurer_id).change();
|
|
$('#insurer_id_for_cd').prop("disabled", true);
|
|
$('#insurer_branch_id').val(res.data.insurer_branch_id).select2();
|
|
$('#insurer_branch_id').prop("disabled", true);
|
|
$('#opening_date').val(res.data.opening_date);
|
|
$('#cd_ac_no_for_cd_master').val(res.data.cd_ac_no);
|
|
//$('#cd_ac_no_for_cd_master').prop("disabled", true);
|
|
$('#opening_bal').val(res.data.opening_bal);
|
|
if(res.cd_transaction_count <= 1){
|
|
$('#opening_bal').prop("disabled", false)
|
|
}else{
|
|
$('#opening_bal').prop("disabled", true)
|
|
}
|
|
$('#cd_master_btn_Submit').html('Update');
|
|
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
});
|
|
|
|
function removeCDMaster(element) {
|
|
|
|
Swal.fire({
|
|
title: "Are you sure?",
|
|
text: "You need to remove this CD.",
|
|
icon: "info",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
confirmButtonText: "Yes",
|
|
}).then((result) => {
|
|
|
|
if (result.isConfirmed) {
|
|
var id = element.getAttribute('data-id');
|
|
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
|
|
$.ajax({
|
|
url: form_action,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(res) {
|
|
// console.log(res.status == true);
|
|
if(res){
|
|
if (res.status == true) {
|
|
toastr.success('CD removed successfully.', 'Success');
|
|
location.reload();
|
|
} else {
|
|
toastr.warning('Failed to remove CD.', 'Warning');
|
|
}
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
console.log('Something Wrong!', 'warning');
|
|
}
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|