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
@@ -226,6 +226,10 @@
<i class="ti ti-x me-1"></i>Cancel PO
</button>
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete" onclick="delete_po()">
<i class="ti ti-trash me-1"></i>Delete PO
</button>
</div>
</div>
@@ -240,6 +244,8 @@
<script>
// custom.js globals: remove_item(), load_location_config(), init_product_search_inputs(), init_lot_search_inputs(), escape_html(), format_number()
const can_delete = ['admin', 'owner'].includes(user_role);
var po_id = <?php echo $po_id; ?>;
var po_data = null;
var warehouses = [];
@@ -635,6 +641,7 @@
is_pending ? 'Assign a default warehouse and save first. The PO will move to Draft.' : 'PO must be in draft to confirm');
set_btn_state('#btn_cancel', can_cancel && !is_cancelled,
is_cancelled ? 'PO is already cancelled' : 'Only draft or confirmed POs can be cancelled');
$('#btn_delete').toggleClass('d-none', !can_delete || !po_id);
$('#receive_card').toggleClass('d-none', !can_receive);
$('#btn_close_po').toggleClass('d-none', !can_close);
@@ -878,6 +885,25 @@
});
}
function delete_po() {
bootbox.confirm({
message: 'Delete this PO? Unconfirmed stock-in reservations will be released.',
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?>po/api/engine/delete_po.php',
autoPrepare: false,
checkRequired: 0,
action: 'delete',
data: { id: po_id },
onSuccess: function() { window.location.href = '<?php echo $server_url?>po/po.php'; }
});
}
});
}
function cancel_po() {
bootbox.confirm({
message: 'Cancel this purchase order? Any pending (unapproved) stock-in rows will be cancelled.',