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
+27
View File
@@ -216,6 +216,11 @@
<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>
</div>
</div>
@@ -230,6 +235,8 @@
<script>
// custom.js globals: remove_item(), init_product_search_inputs(), format_number()
const can_delete = ['admin', 'owner'].includes(user_role);
var order_id = <?php echo $order_id; ?>;
var order_source = <?php echo json_encode($source); ?>;
var order_source_id = <?php echo (int)$source_id; ?>;
@@ -426,6 +433,7 @@
is_pending ? 'Assign warehouses and save first. The order will move to Draft.' : 'Order must be in draft to confirm');
set_btn_state('#btn_cancel', can_cancel && !is_cancelled,
is_cancelled ? 'Order is already cancelled' : 'Only draft or confirmed orders can be cancelled');
$('#btn_delete').toggleClass('d-none', !can_delete || !order_id);
set_btn_state('#btn_tracking', can_update_tracking,
is_cancelled ? 'Order is cancelled'
@@ -631,6 +639,25 @@
// ── Cancel order ──────────────────────────────────────────────────────────
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?>order/order.php'; }
});
}
});
}
function cancel_order() {
bootbox.confirm({
message: 'Cancel this order? All pending stock-out rows will be cancelled.',