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
+25
View File
@@ -157,6 +157,9 @@
<button class="btn btn-outline-danger w-100 d-none" id="btn_cancel" onclick="cancel_order()">
<i class="ti ti-x me-1"></i>Cancel Order
</button>
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete" onclick="delete_order()">
<i class="ti ti-trash me-1"></i>Delete Order
</button>
<a href="<?php echo $server_url?>revenue/order.php" class="btn btn-light w-100">
Back
</a>
@@ -172,6 +175,8 @@
<script>
// custom.js globals: remove_item(), init_product_search_inputs(), escape_html(), format_number()
const can_delete = ['admin', 'owner'].includes(user_role);
var order_id = <?php echo $order_id; ?>;
var order_data = null;
var item_index = 0;
@@ -306,6 +311,7 @@
}
$('#btn_cancel').toggleClass('d-none', status !== -2);
$('#btn_delete').toggleClass('d-none', !can_delete || !order_id);
var is_existing = order_id > 0;
var can_invoice = is_existing && status >= 1 && status !== -1 && !has_active_invoice;
@@ -426,6 +432,25 @@
});
}
function delete_order() {
bootbox.confirm({
message: 'Delete this order? Unconfirmed stock-out rows will also 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_order.php',
autoPrepare: false,
checkRequired: 0,
action: 'delete',
data: { id: order_id },
onSuccess: function() { window.location.href = '<?php echo $server_url?>revenue/order.php'; }
});
}
});
}
function cancel_order() {
bootbox.confirm({
message: 'Cancel this pending sales order? It will be removed from WMS queue.',