326 lines
13 KiB
PHP
326 lines
13 KiB
PHP
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<div class="text-center">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6 col-xl-5">
|
|
<div class="py-1">
|
|
<i class="font-24"></i>
|
|
<h4>Deposit Summary Of <?php echo $clientData->short_name?></h4>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6 col-xl-5">
|
|
<div class="py-1">
|
|
<i class=" font-24"></i>
|
|
<h4><?php echo $insurerName->name; ?></h4>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
<div class="row mt-3 text-center">
|
|
|
|
<div class="col-3">
|
|
<p class="text-muted font-15 mb-1 text-truncate">Deposits</p>
|
|
<h4 style="font-size: 26px;"><i
|
|
class="fe-arrow-up text-success mr-1"></i>₹<?php echo $deposiamount->total_credit?>
|
|
</h4>
|
|
</div>
|
|
|
|
<div class="col-3">
|
|
<p class="text-muted font-15 mb-1 text-truncate">Consumed</p>
|
|
<h4 style="font-size: 26px;"><i
|
|
class="fe-arrow-down text-danger mr-1"></i>₹<?php echo $deposiamount->total_withdraw?>
|
|
</h4>
|
|
</div>
|
|
|
|
<div class="col-3">
|
|
<p class="text-muted font-15 mb-1 text-truncate">Refund</p>
|
|
<h4 style="font-size: 26px;"><i
|
|
class="fe-arrow-up text-success mr-1"></i>₹<?php echo $deposiamount->total_refund?>
|
|
</h4>
|
|
</div>
|
|
|
|
<div class="col-3">
|
|
<p class="text-muted font-15 mb-1 text-truncate">Current Balance</p>
|
|
<h4 style="font-size: 26px;"><i
|
|
class="fe-credit-card text-sucess mr-1"></i>₹<?php echo $deposiamount->balance?>
|
|
</h4>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- start page title -->
|
|
<!-- <div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<h4 class="page-title"></h4>
|
|
<div class="page-title-right">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> -->
|
|
<!-- end page title -->
|
|
<div class="row" id="List-page">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<div class="row">
|
|
<div class="col-12" style="text-align: right;">
|
|
<a href="<?= base_url("client/deposit/$clientData->id"); ?>"><i class="fas fa-arrow-left" style="font-size: 17px;"></i></a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row" style="margin-bottom:1rem;">
|
|
<div class="col-6" style="align-self: center;">
|
|
<h4 class="header-title" style="position: relative;">Transaction Details</h4>
|
|
</div>
|
|
|
|
<div class="col-6" style="text-align: right; position: relative;top: 53px;">
|
|
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light"
|
|
data-toggle="modal" data-target="#addTransactionModal">New</button>
|
|
</div>
|
|
</div>
|
|
|
|
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
|
|
id="tickets-table">
|
|
<thead class="bg-light">
|
|
<tr>
|
|
|
|
<th class="font-weight-medium">Date</th>
|
|
<th class="font-weight-medium">User</th>
|
|
<th class="font-weight-medium">Description</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>
|
|
|
|
</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 $row->username; ?></td>
|
|
<td><?php echo $row->description; ?></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>
|
|
</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">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="transactionMode" class="control-label">Transaction Mode</label>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="transactionMode" id="addMode"
|
|
value="add" checked>
|
|
<label class="form-check-label" for="addMode">Deposit</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="transactionMode" id="adjustmentMode"
|
|
value="adjustment">
|
|
<label class="form-check-label" for="adjustmentMode">Adjustment</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="field-1" class="control-label">Amount</label>
|
|
<input type="number" class="form-control" id="amount" placeholder="Amount">
|
|
</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</label>
|
|
<textarea class="form-control" id="description"
|
|
placeholder="Write something about the transaction"></textarea>
|
|
</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>Deposit</option>
|
|
<option value="Adjustment" hidden>Adjustment</option>
|
|
<!-- Add more options as needed -->
|
|
</select>
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
<button type="button" class="btn btn-primary" id="saveTransactionBtn">Save Transaction</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() {
|
|
|
|
$('#tickets-table').DataTable({
|
|
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>",
|
|
buttons: [{
|
|
extend: 'csv',
|
|
text: 'CSV',
|
|
title: 'TransactionDetails',
|
|
exportOptions: {
|
|
columns: ''
|
|
}
|
|
},
|
|
{
|
|
extend: 'pdf',
|
|
text: 'PDF',
|
|
title: 'TransactionDetails',
|
|
exportOptions: {
|
|
columns: ''
|
|
}
|
|
}
|
|
],
|
|
|
|
|
|
language: {
|
|
search: "_INPUT_",
|
|
searchPlaceholder: "Search..."
|
|
},
|
|
|
|
});
|
|
});
|
|
</script>
|
|
<!-- Include jQuery library (if not already included) -->
|
|
|
|
|
|
<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() {
|
|
// Collect data from modal fields
|
|
var amount = $('#amount').val();
|
|
var description = $('#description').val();
|
|
var clientId = '<?php echo $clientData->id; ?>';
|
|
var insurerId = '<?php echo $insurerName->id; ?>';
|
|
var transactionType;
|
|
if ($('#addMode').is(':checked')) {
|
|
transactionType =
|
|
'Credit'; // Assuming 'Credit' is the default when the 'Deposit' radio button is selected
|
|
} else if ($('#adjustmentMode').is(':checked') && $('#transactionTypeRow').is(':visible')) {
|
|
transactionType = $('#transactionType').val();
|
|
} else {
|
|
transactionType = ''; // You might want to handle this case based on your requirements
|
|
}
|
|
|
|
// Fetch sub_type_id based on the selected sub_type
|
|
var subTypeOptions = {
|
|
'Deposit': 1,
|
|
'Adjustment': 2,
|
|
'Deletion': 3,
|
|
// Add more options as needed
|
|
};
|
|
|
|
var subType = $('#subType').val();
|
|
var subTypeId = subTypeOptions[subType] || null;
|
|
|
|
if (subTypeId === null) {
|
|
// Handle the case where sub_type is not found in the options
|
|
alert('Invalid sub_type selected.');
|
|
return;
|
|
}
|
|
|
|
// 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: subType,
|
|
sub_type_id: subTypeId, // Include sub_type_id
|
|
client_id: clientId,
|
|
insurer_id: insurerId
|
|
},
|
|
success: function(response) {
|
|
// Handle success response
|
|
console.log("Transaction saved successfully");
|
|
// Reload the page or perform other actions as needed
|
|
location.reload();
|
|
},
|
|
error: function(error) {
|
|
// Handle error response
|
|
console.error(error);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|