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
@@ -129,6 +129,9 @@
<button class="btn btn-outline-danger w-100 d-none" id="btn_cancel" onclick="cancel_po()">
<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>
</div>
@@ -139,6 +142,8 @@
<?php require '../include_ending.php'; ?>
<script>
const can_delete = ['admin', 'owner'].includes(user_role);
var po_id = <?php echo $po_id; ?>;
var po_data = null;
var item_index = 0;
@@ -238,6 +243,7 @@
$('.remove_item_btn').toggleClass('d-none', !editable);
$('#btn_save').toggleClass('d-none', !editable);
$('#btn_cancel').toggleClass('d-none', !(status === -2 || status === 0));
$('#btn_delete').toggleClass('d-none', !can_delete || !po_id);
if (status === -2) {
$('#wms_status_title').text('Pending Warehouse receiving setup');
@@ -320,6 +326,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?>expense/purchase_order.php'; }
});
}
});
}
function cancel_po() {
bootbox.confirm('Cancel this purchase order?', function(ok) {
if (!ok) return;