nhance/app/Views/view_deposit.php
2025-12-16 12:00:25 +05:30

473 lines
23 KiB
PHP
Executable File

<style>
.metrics{
border:1px solid lightgrey;border-radius:10px;box-shadow: 0px 4px 4px 0px #00000040;
min-width: none;
max-width: 350px;
}
.dataTables_length label {height: 21px !important;}
</style>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div style="display: flex; align-items: center;">
<a href="<?= base_url("client/deposit/$clientData->id"); ?>" style="color:black; font-size: 40px; margin-right: 10px;">
<i class="mdi mdi-chevron-left"></i>
</a>
<h3 style="margin: 0;">Transaction Details - <?php echo $insurerName->name; ?></h3>
</div>
<br>
<div class="d-flex justify-content-between">
<div><h4>CD Account No : <?php echo isset($insurerName->cd_master_account_no) && !empty($insurerName->cd_master_account_no) ? $insurerName->cd_master_account_no : 'N/A' ?></h4></div>
<div> <h4>Deposit Summary Of <?php echo $clientData->short_name?></h4></div>
</div>
<div>
<div class="row text-center">
<div class="col-3 d-flex justify-content-between align-items-center metrics mr-2 mt-2">
<span class="text-muted font-15 mb-1 text-truncate">Deposits</span>
<h4 style="font-size: 18px;display:inline;"><i
class="fe-arrow-up text-success mr-1" ></i>₹<?php echo $deposiamount->total_credit?>
</h4>
</div>
<div class="col-3 d-flex justify-content-between align-items-center metrics mr-2 mt-2">
<span class="text-muted font-15 mb-1 text-truncate">Consumed</span>
<h4 style="font-size: 20px;display:inline;"><i
class="fe-arrow-down text-danger mr-1"></i>₹<?php echo $deposiamount->total_withdraw?>
</h4>
</div>
<div class="col-3 d-flex justify-content-between align-items-center metrics mr-2 mt-2">
<span class="text-muted font-15 mb-1 text-truncate">Refund</span>
<h4 style="font-size: 20px;display:inline;"><i
class="fe-arrow-up text-success mr-1"></i>₹<?php echo $deposiamount->total_refund?>
</h4>
</div>
<div class="col-3 d-flex justify-content-between align-items-center metrics mr-2 mt-2">
<span class="text-muted font-15 mb-1 text-truncate">Current Balance</span>
<h4 style="font-size: 20px;display:inline;"><i
class="fe-credit-card text-sucess mr-1"></i>₹<?php echo $deposiamount->balance?>
</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body">
<!-- <div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="text-align: right; position: relative;top: 56px; z-index:999">
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target="#addTransactionModal"> + Add</button>
</div>
</div> -->
<table data-custom-table-css="table" class="table table-sm table-hover m-0 table-centered dt-responsive w-100" cellspacing="0"
id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Date</th>
<th class="font-weight-medium">Record Date</th>
<th class="font-weight-medium">Unit</th>
<th class="font-weight-medium">Policy</th>
<th class="font-weight-medium">Endorsement No</th>
<th class="font-weight-medium">Sub Type</th>
<th class="font-weight-medium">Credit</th>
<th class="font-weight-medium">Debit</th>
<th class="font-weight-medium">Balance</th>
<th class="font-weight-medium">Description</th>
<th class="font-weight-medium">User</th>
</tr>
</thead>
<tbody>
<?php foreach($depositdata as $row) { ?>
<tr id="<?php echo $row->id;?>">
<td><?php echo date('d-M-Y h:i A', strtotime($row->created_at)); ?></td>
<td><?php echo isset($row->record_date)? date('d-M-Y', strtotime($row->record_date)):'-' ?></td>
<td><?php echo $row->unit ?? ' - '; ?></td>
<!-- <td><?php echo $row->policy_name ?? '<center> - </center>'; ?></td> -->
<td>
<?php
$policyType = $row->policy_type ?? '';
$policyNo = $row->policy_no ?? '';
if ($policyType || $policyNo) {
echo trim($policyType . ' - ' . $policyNo, ' -');
} else {
echo '<center> - </center>';
}
?>
</td>
<td><?php echo $row->endorsement_no ?? '<center> - </center>'; ?></td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?>
</td>
<td><?php echo ($row->transaction_type == 'Credit') ? $row->amount : '-'; ?></td>
<td><?php echo ($row->transaction_type == 'Debit') ? $row->amount : '-'; ?></td>
<td><?php echo $row->balance; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo $row->username; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- end col -->
</div>
</div>
<!-- Add this modal markup at the end of your HTML body -->
<!-- Button to trigger modal -->
<!-- Add this modal markup at the end of your HTML body -->
<div class="modal fade" id="addTransactionModal" tabindex="-1" role="dialog" aria-labelledby="addTransactionModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addTransactionModalLabel">Add Transaction</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<h3>Transaction Mode</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<div class="form-check mt-2">
<input class="form-check-input" type="radio" name="transactionMode" id="addMode"value="1" checked>
<label class="form-check-label" for="addMode">Replenishment by Client</label>
</div>
<div class="form-check mt-2">
<input class="form-check-input" type="radio" name="transactionMode" id="refund_by_insurer"value="6">
<label class="form-check-label" for="addMode">Refund by Insurer</label>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="form-check mt-2">
<input class="form-check-input" type="radio" name="transactionMode" id="assetpolicyadd"value="4">
<label class="form-check-label" for="adjustmentMode">Non EB Credit</label>
</div>
<div class="form-check mt-2">
<input class="form-check-input" type="radio" name="transactionMode" id="assetpolicyreduce"value="5">
<label class="form-check-label" for="adjustmentMode">No EB Debit</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Amount<span class="text-danger">*</span></label>
<input type="number" class="form-control" id="amount" placeholder="Amount" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="record_date">Record Date <span class="text-danger"></span></label>
<input type="text" class="form-control policy_start_date" id="record_date" name="record_date" placeholder="Record Date">
</div>
</div>
</div>
<!-- <div class="row" id="transactionTypeRow" style="display:none;">
<div class="col-md-6">
<div class="form-group">
<label for="transactionType" class="control-label">Transaction Type</label>
<select class="form-control" id="transactionType">
<option value="Credit">Add</option>
<option value="Debit">Reduce</option>
</select>
</div>
</div>
</div> -->
<div class="row">
<div class="col-md-12">
<div class="form-group no-margin">
<label for="description" class="control-label">Description<span class="text-danger">*</span></label>
<textarea class="form-control" id="description"
placeholder="Write something about the transaction" required></textarea>
<input type="hidden" id="cd_ac_pk" value="<?php echo $depositdata[0]->cd_ac_pk?>">
<input type="hidden" id="cd_ac_no" value="<?php echo $depositdata[0]->cd_ac_no?>">
</div>
</div>
</div>
<!-- <div class="form-group">
<label for="subType" class="control-label" style="display: none;">Transaction Sub Type</label>
<select class="form-control" id="subType" name="sub_type" style="display: none;">
<option value="Deposit" hidden>Replenishment</option>
<option value="Adjustment" hidden>Adjustment</option>
</select>
</div> -->
<div class="modal-footer">
<button type="button" class="btn cancel-btn" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary submit-btn" id="saveTransactionBtn">Submit</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('input[name="transactionMode"]').change(function() {
if ($(this).val() === 'adjustment') {
$('#transactionTypeRow').show();
} else {
$('#transactionTypeRow').hide();
}
});
});
</script>
<script>
$(document).ready(function() {
var record_date = flatpickr("#record_date", {
dateFormat: "d/m/Y",
allowInput: false,
});
$('#tickets-table').DataTable({
// dom: "<'row'<'col-sm-2'f><'col-sm-10 text-right'B>>" +
// "<'row'<'col-sm-12'tr>>" +
// "<'row'<'col-sm-5'i><'col-sm-7'p>>",
// buttons: [
// {
// text: '+ add',
// className: 'btn btn-primary buttons-html5',
// action: function () {
// var myModal = new bootstrap.Modal(document.getElementById('addTransactionModal'));
// myModal.show();
// }
// }
// ,
// {
// extend: 'csv',
// text: 'CSV',
// title: 'CD TransactionDetails',
// exportOptions: {
// columns: ''
// }
// },
// {
// extend: 'pdf',
// text: 'PDF',
// title: 'TransactionDetails',
// exportOptions: {
// columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
// format: {
// body: function (data, row, column, node) {
// return data.replace(/<.*?>/g, '');
// }
// }
// },
// customize: function (doc) {
// doc.pageOrientation = 'landscape';
// doc.styles.tableHeader.alignment = 'left';
// doc.defaultStyle.alignment = 'left';
// doc.content[1].table.widths = [
// '9%', '9%', '8%', '9%', '10%',
// '9%', '9%', '9%', '9%', '11%', '8%'
// ];
// }
// }
// ],
dom: "<'row'<'col-12 d-flex justify-content-between'<'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: [
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
className: 'btn app-btn-primary mr-2',
action: function () {
var myModal = new bootstrap.Modal(document.getElementById('addTransactionModal'));
myModal.show();
}
},
{
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: 'CD TransactionDetails',
exportOptions: { columns: '' },
className: 'app-btn-primary ',
},
{
extend: 'pdf',
text: 'PDF',
text: '<i class="mdi mdi-file-pdf" ></i><span class=" btn-custom"> EXCEL </span>',
title: 'TransactionDetails',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
format: {
body: function (data, row, column, node) {
return data.replace(/<.*?>/g, '');
}
}
},
customize: function (doc) {
doc.pageOrientation = 'landscape';
doc.styles.tableHeader.alignment = 'left';
doc.defaultStyle.alignment = 'left';
doc.content[1].table.widths = [
'9%', '9%', '8%', '9%', '10%',
'9%', '9%', '9%', '9%', '11%', '8%'
];
}
}
]
}
],
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>'
},
ordering: false,
paging: true
});
});
</script>
<script>
$(document).ready(function() {
// // Event listener for radio buttons
// $('input[name="transactionMode"]').change(function() {
// if ($(this).val() === 'add') {
// // Set the hidden input value to 'Deposit' when 'Deposit' radio button is selected
// $('#subType').val('Deposit');
// } else if ($(this).val() === 'adjustment') {
// // Set the hidden input value to 'Adjustment' when 'Adjustment' radio button is selected
// $('#subType').val('Adjustment');
// }
// });
$('#saveTransactionBtn').on('click', function() {
var amount = $('#amount').val();
var description = $('#description').val();
var clientId = '<?php echo $clientData->id; ?>';
var insurerId = '<?php echo $insurerName->id; ?>';
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
var subType = "";
var record_date = $('#record_date').val();
var cd_ac_no = $('#cd_ac_no').val();
var cd_ac_pk = $('#cd_ac_pk').val();
if (amount == "") {
toastr.warning('Amount field is required')
return;
}
if (description == "") {
toastr.warning('Description field is required')
return;
}
//tranction type
if (transactionTypeValue == 1) {
transactionType = 'Credit';
subType = '1'; // Replenishment or Deposite
} else if (transactionTypeValue == 2) {
transactionType = 'Credit'
subType = '2'; // Adjustment add
} else if (transactionTypeValue == 3) {
transactionType = 'Debit'
subType = '2'; // Adjustment reduce
} else if (transactionTypeValue == 4) {
transactionType = 'Credit'
subType = '5'; // Asset Policy add
} else if (transactionTypeValue == 5) {
transactionType = 'Debit'
subType = '5'; // Asset Policy reduce
} else if (transactionTypeValue == 6) {
transactionType = 'Debit'
subType = '6'; // Refund by indurer
}
console.log('transactionTypeValue', transactionTypeValue)
console.log('transactionType', transactionType)
console.log('description ', description)
console.log('amount ', amount)
console.log('clientId ', clientId)
console.log('insurerId ', insurerId)
console.log('subType ', subType)
console.log('cd_ac_pk ', cd_ac_pk)
console.log('cd_ac_no ', cd_ac_no)
// Send data to the server using Ajax
$.ajax({
type: 'POST',
url: '<?= base_url() . "client/save_deposit" ?>',
data: {
amount: amount,
description: description,
transaction_type: transactionType,
sub_type_id: subType, // Include sub_type_id
client_id: clientId,
insurer_id: insurerId,
record_date: record_date,
cd_ac_pk: cd_ac_pk,
cd_ac_no: cd_ac_no
},
success: function(response) {
// Handle success response
toastr.success("Transaction saved successfully", "Success");
// Reload the page or perform other actions as needed
location.reload();
},
error: function(xhr, status, error) {
toastr.error("Transaction save failed", "Error");
console.error(xhr.responseText);
console.error(status, error);
location.reload(); // Uncomment if you need to reload the page on error
}
});
});
});
</script>