softDelete features
This commit is contained in:
@@ -88,6 +88,9 @@
|
||||
<button class="btn btn-outline-danger w-100 d-none" id="btn_void" onclick="void_billing()">
|
||||
<i class="ti ti-ban me-1"></i>Void Billing
|
||||
</button>
|
||||
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete" onclick="delete_billing()">
|
||||
<i class="ti ti-trash me-1"></i>Delete Billing
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -98,6 +101,9 @@
|
||||
<?php require '../include_ending.php'; ?>
|
||||
|
||||
<script>
|
||||
|
||||
const can_delete = ['admin', 'owner'].includes(user_role);
|
||||
|
||||
var billing_id = <?php echo $billing_id; ?>;
|
||||
var billing = null;
|
||||
|
||||
@@ -148,6 +154,7 @@
|
||||
$('#btn_receipt').attr('href', '<?php echo $server_url?>finance/receipt.php?billing_id=' + billing.id);
|
||||
$('#btn_receipt').toggleClass('d-none', String(billing.status) === '4' || parseFloat(billing.balance_amount || 0) <= 0.0001);
|
||||
$('#btn_void').toggleClass('d-none', String(billing.status) === '4' || parseFloat(billing.received_amount || 0) > 0.0001);
|
||||
$('#btn_delete').toggleClass('d-none', !can_delete || !billing_id);
|
||||
|
||||
var rows = '';
|
||||
$.each(billing.allocations || [], function(i, line) {
|
||||
@@ -168,6 +175,25 @@
|
||||
$('#allocation_tbody').html(rows || '<tr><td colspan="5" class="text-center py-5 text-muted">No documents found.</td></tr>');
|
||||
}
|
||||
|
||||
function delete_billing() {
|
||||
bootbox.confirm({
|
||||
message: 'Delete this billing? All linked receipts must be deleted first.',
|
||||
buttons: { confirm: { label: 'Delete', className: 'btn-danger' }, cancel: { label: 'Back', className: 'btn-secondary' } },
|
||||
callback: function(result) {
|
||||
if (!result) return;
|
||||
ajax_request({
|
||||
url: '<?php echo $server_url?>finance/api/engine/delete_receipt_billing.php',
|
||||
autoPrepare: false,
|
||||
checkRequired: 0,
|
||||
action: 'delete',
|
||||
data: { id: billing_id },
|
||||
onSuccess: function() { window.location.href = '<?php echo $server_url?>finance/receipt_billing.php'; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function void_billing() {
|
||||
bootbox.confirm('Void this receipt billing?', function(ok) {
|
||||
if (!ok) return;
|
||||
|
||||
Reference in New Issue
Block a user