softDelete features

This commit is contained in:
Thanakorn S
2026-05-22 14:07:22 +07:00
parent f04554793e
commit 2410f7bade
59 changed files with 1783 additions and 16 deletions
+26
View File
@@ -146,6 +146,10 @@
<i class="ti ti-ban me-1"></i>Void Invoice
</button>
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete"
onclick="delete_invoice()">
<i class="ti ti-trash me-1"></i>Delete
</button>
</div>
</div>
@@ -160,6 +164,8 @@
<script>
// custom.js globals: format_number()
const can_delete = ['admin', 'owner'].includes(user_role);
var invoice_id = <?php echo $invoice_id; ?>;
var invoice_data = null;
@@ -223,6 +229,7 @@
!is_invoice ? 'Only original invoices can be voided'
: status === 0 ? 'Invoice has not been issued yet'
: status === 4 ? 'Invoice is already void' : '');
$('#btn_delete').toggleClass('d-none', !can_delete || !invoice_id);
}
@@ -344,6 +351,25 @@
function delete_invoice() {
bootbox.confirm({
message: 'Delete this document? Any GL entry will be removed.',
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?>order/api/engine/delete_invoice.php',
autoPrepare: false,
checkRequired: 0,
action: 'delete',
data: { id: invoice_id },
onSuccess: function() { window.location.href = '<?php echo $server_url?>order/invoice.php'; }
});
}
});
}
function void_invoice() {
bootbox.confirm({
message: '<strong>Void this invoice?</strong><br>This action cannot be undone.',