softDelete features

This commit is contained in:
Thanakorn S
2026-05-22 14:07:22 +07:00
parent 738f600fe8
commit 648efee991
59 changed files with 1783 additions and 16 deletions
+26
View File
@@ -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_payment').attr('href', '<?php echo $server_url?>finance/payment.php?billing_id=' + billing.id);
$('#btn_payment').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.paid_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 payments 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_payment_billing.php',
autoPrepare: false,
checkRequired: 0,
action: 'delete',
data: { id: billing_id },
onSuccess: function() { window.location.href = '<?php echo $server_url?>finance/payment_billing.php'; }
});
}
});
}
function void_billing() {
bootbox.confirm('Void this payment billing?', function(ok) {
if (!ok) return;