nhance/app/Views/payout_list.php
2025-11-15 10:49:27 +05:30

318 lines
13 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
.badge-container {
background: #F0F0F0;
padding: 6px 12px;
border-radius: 6px;
font-size: 14px;
display: inline-block;
}
.summary-box {
background: #e3f2fd;
padding: 15px;
border-radius: 6px;
margin-bottom: 20px;
border-left: 4px solid #2196F3;
}
.summary-row {
display: flex;
justify-content: space-between;
margin-bottom: 8px;
font-size: 14px;
}
.summary-row:last-child {
margin-bottom: 0;
font-size: 16px;
font-weight: bold;
padding-top: 8px;
border-top: 1px solid #2196F3;
}
</style>
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Payout List <span id="payout_title"></span></h4>
</div>
</div>
<div class="table-responsive">
<table data-custom-table-css="table" id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Inovice No</th>
<th class="font-weight-medium">Invoice Date</th>
<th class="font-weight-medium">Invoice Amount</th>
<th class="font-weight-medium">UTR Total Amount</th>
<th class="font-weight-medium">Balance</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Agent</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if (isset($payout_list_data) && !empty($payout_list_data)) { ?>
<?php foreach($payout_list_data as $index => $row){ ?>
<tr>
<td> <?= $index + 1 ?> </td>
<td> <?= $row['invoice_no'] ?> </td>
<td> <?= change_date_format($row['invoice_no'], null, 'd-M-Y') ?? "" ?> </td>
<td> <?= format_indian_number($row['invoice_amount']) ?> </td>
<td> <?= format_indian_number($row['total_utr_amount']) ?> </td>
<td> <?= format_indian_number($row['balance_amount']) ?> </td>
<td> <?= $row['status_text'] ?> </td>
<td> <?= $row['agent_name'] ?? " - " ?> </td>
<td>
<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" onclick="showUtrModal(this)"><i class="mdi mdi-bank-transfer mr-2 text-muted font-18 vertical-middle"></i>UTR</a>
<a href="<?= base_url('payout/invoices/save?type="edit"') ?>" class="dropdown-item"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="<?= base_url('payout/invoices/save?type="adjustment"') ?>" class="dropdown-item"><i class="mdi mdi-tune mr-2 text-muted font-18 vertical-middle"></i>Adjustment</a>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
</div><!-- end col -->
</div>
</div>
<div class="modal fade" id="payout_modal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-lg" style="max-width: 1100px;">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">UTR Management<span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body" id="modal_body">
<div class="summary-box">
<div class="summary-row">
<span>Invoice Amount:</span>
<span id="utrInvoiceAmount" style="font-weight: bold;">₹0.00</span>
</div>
<div class="summary-row">
<span>Total UTR Paid:</span>
<span id="utrTotalPaid" style="font-weight: bold;">₹0.00</span>
</div>
<div class="summary-row">
<span>Remaining Balance:</span>
<span id="utrRemaining" style="font-weight: bold;">₹0.00</span>
</div>
</div>
<div id="utrContent">
<div style="margin-top: 20px; padding-top: 20px; border-top: 2px solid #eee;">
<h3 style="margin-bottom: 15px;">Add New UTR</h3>
<form id="utrForm" method="POST" action="">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>UTR Number *</label>
<input type="text" name="utrNumber" id="utrNumber" class="form-control" placeholder="Enter UTR number" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Amount (₹) *</label>
<input type="number" name="utrAmount" id="utrAmount" class="form-control" step="0.01" placeholder="Enter amount" required>
<small style="color: #666; display: block; margin-top: 5px;">
Maximum: <span id="maxUtrAmount">₹0.00</span>
</small>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Date *</label>
<input type="text" name="utrDate" id="utrDate" class="form-control" placeholder="DD/MM/YYYY" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="margin-top: 27px;">
<button type="submit" class="btn btn-primary" style="width: 100%;">Add UTR</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="utr-list" id="utrList"></div>
</div>
</div>
</div>
</div>
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
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',
title: 'List',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
},
{
extend: 'excel',
title: 'List',
sheetName: 'Policy-Tranction-payout-List',
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
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>'
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
ordering: false
});
} else {
console.error("Table atet found.");
}
});
function fetchUtrDetails(invoice_id)
{
let invoice_id = $('#agent_id').val();
if (!invoice_id) {
toastr.warning("Invoice Id not found!", "WARNING");
return false;
}
let url = '<?= base_url('payout/fetchUtrDetails') ?>';
// Data to send in the AJAX request
let requestData = {
invoice_id: invoice_id,
};
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
$('#modal_body').empty();
$('#modal_body').append(response.data);
if (response.status == false) {
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
});
}
function saveUtrDetails(invoice_id)
{
let invoice_id = $('#agent_id').val();
if (!invoice_id) {
toastr.warning("Invoice Id not found!", "WARNING");
return false;
}
let url = '<?= base_url('payout/fetchUtrDetails') ?>';
// Data to send in the AJAX request
let requestData = {
invoice_id: invoice_id,
};
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
$('#payout_list').empty();
$('#payout_list').append(response.data);
if (response.status == false) {
toastr.warning(response.message || 'Unable to fetch data', 'WARNING');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
});
}
</script>