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
@@ -123,6 +123,9 @@
<button class="btn btn-outline-danger w-100 d-none" id="btn_void" onclick="void_receipt()">
<i class="ti ti-ban me-1"></i>Void Receipt
</button>
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete" onclick="delete_receipt()">
<i class="ti ti-trash me-1"></i>Delete Receipt
</button>
</div>
</div>
</div>
@@ -133,6 +136,9 @@
<?php require '../include_ending.php'; ?>
<script>
const can_delete = ['admin', 'owner'].includes(user_role);
var receipt_id = <?php echo $receipt_id; ?>;
var receipt = null;
@@ -184,6 +190,7 @@
$('#display_method').html(display_text(method_label(receipt.payment_method)));
$('#display_notes').html(receipt.notes ? escape_html(receipt.notes).replace(/\n/g, '<br>') : '<span class="text-muted">—</span>');
$('#btn_void').toggleClass('d-none', String(receipt.status) === '4');
$('#btn_delete').toggleClass('d-none', !can_delete || !receipt_id);
var selected_formula = receipt.formula_id || '';
ajax_request({
@@ -245,6 +252,25 @@
});
}
function delete_receipt() {
bootbox.confirm({
message: 'Delete this receipt? The GL entry and invoice allocations will be reversed.',
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.php',
autoPrepare: false,
checkRequired: 0,
action: 'delete',
data: { id: receipt_id },
onSuccess: function() { window.location.href = '<?php echo $server_url?>finance/receipt.php'; }
});
}
});
}
function void_receipt() {
bootbox.confirm('Void this receipt? Allocated invoices and credit notes will be reopened if not fully settled by other receipts.', function(ok) {
if (!ok) return;