softDelete features
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
<button class="btn btn-outline-danger w-100 d-none" id="btn_reject" onclick="change_status('reject')"><i class="ti ti-x me-1"></i>Reject</button>
|
||||
<button class="btn btn-outline-secondary w-100 d-none" id="btn_reopen" onclick="change_status('reopen')"><i class="ti ti-refresh me-1"></i>Reopen as Draft</button>
|
||||
<button class="btn btn-outline-danger w-100 d-none" id="btn_cancel" onclick="change_status('cancel')"><i class="ti ti-ban me-1"></i>Cancel</button>
|
||||
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete" onclick="delete_request()"><i class="ti ti-trash me-1"></i>Delete Request</button>
|
||||
<hr class="d-none" id="hr_convert">
|
||||
<button class="btn btn-success w-100 d-none" id="btn_convert" onclick="convert_to_po()"><i class="ti ti-transfer me-1"></i>Convert to PO</button>
|
||||
<a href="#" class="btn btn-outline-primary w-100 d-none" id="btn_view_po"><i class="ti ti-clipboard-list me-1"></i>View PO</a>
|
||||
@@ -131,6 +132,8 @@
|
||||
<?php require '../include_ending.php'; ?>
|
||||
|
||||
<script>
|
||||
const can_delete = ['admin', 'owner'].includes(user_role);
|
||||
|
||||
var request_id = <?php echo $request_id; ?>;
|
||||
var request_data = null;
|
||||
var item_index = 0;
|
||||
@@ -225,6 +228,7 @@
|
||||
$('#btn_approve, #btn_reject').toggleClass('d-none', !is_submitted);
|
||||
$('#btn_reopen').toggleClass('d-none', is_draft || is_closed);
|
||||
$('#btn_cancel').toggleClass('d-none', !(is_draft || is_submitted) || !request_id);
|
||||
$('#btn_delete').toggleClass('d-none', !can_delete || !request_id);
|
||||
$('#hr_convert, #btn_convert').toggleClass('d-none', !is_approved);
|
||||
$('#btn_view_po').toggleClass('d-none', !(request_data && parseInt(request_data.po_id) > 0))
|
||||
.attr('href', request_data && request_data.po_id ? '<?php echo $server_url?>expense/manage_purchase_order.php?id=' + request_data.po_id : '#');
|
||||
@@ -295,6 +299,25 @@
|
||||
});
|
||||
}
|
||||
|
||||
function delete_request() {
|
||||
bootbox.confirm({
|
||||
message: 'Delete this purchase request? This cannot be undone.',
|
||||
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_purchase_request.php',
|
||||
autoPrepare: false,
|
||||
checkRequired: 0,
|
||||
action: 'delete',
|
||||
data: { id: request_id },
|
||||
onSuccess: function() { window.location.href = '<?php echo $server_url?>expense/purchase_request.php'; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function change_status(action_type) {
|
||||
var labels = {
|
||||
submit: 'Submit this purchase request?',
|
||||
|
||||
@@ -145,6 +145,9 @@
|
||||
<?php require '../include_ending.php'; ?>
|
||||
|
||||
<script>
|
||||
|
||||
const can_delete = ['admin', 'owner'].includes(user_role);
|
||||
|
||||
function po_status_badge(status) {
|
||||
const map = {
|
||||
'-2': '<span class="badge bg-danger">Pending Warehouse</span>',
|
||||
@@ -229,12 +232,31 @@
|
||||
<a href="<?php echo $server_url?>expense/manage_purchase_order.php?id=${po.id}" title="View">
|
||||
<i class="ti ti-eye fs-5"></i>
|
||||
</a>
|
||||
${can_delete ? `<a href="javascript:void(0);" class="link-danger ms-2" title="Delete" onclick="delete_po(${po.id})"><i class="ti ti-trash fs-5"></i></a>` : ''}
|
||||
</td>
|
||||
</tr>`;
|
||||
});
|
||||
$('table#po_list tbody').html(body);
|
||||
}
|
||||
|
||||
function delete_po(id) {
|
||||
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: id },
|
||||
onSuccess: function() { retrieve_pos(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(async function() {
|
||||
await load_dept_cache();
|
||||
populate_dept_filter('filter_dept');
|
||||
|
||||
@@ -128,6 +128,9 @@
|
||||
<?php require '../include_ending.php'; ?>
|
||||
|
||||
<script>
|
||||
|
||||
const can_delete = ['admin', 'owner'].includes(user_role);
|
||||
|
||||
var status_badge = {
|
||||
'-1': '<span class="badge bg-secondary">Cancelled</span>',
|
||||
'0': '<span class="badge bg-warning text-dark">Draft</span>',
|
||||
@@ -195,12 +198,31 @@
|
||||
<a href="<?php echo $server_url?>expense/manage_purchase_request.php?id=${r.id}" title="View">
|
||||
<i class="ti ti-eye fs-5"></i>
|
||||
</a>
|
||||
${can_delete ? `<a href="javascript:void(0);" class="link-danger ms-2" title="Delete" onclick="delete_request(${r.id})"><i class="ti ti-trash fs-5"></i></a>` : ''}
|
||||
</td>
|
||||
</tr>`;
|
||||
});
|
||||
$('table#request_list tbody').html(body);
|
||||
}
|
||||
|
||||
function delete_request(id) {
|
||||
bootbox.confirm({
|
||||
message: 'Delete this purchase request? This cannot be undone.',
|
||||
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_purchase_request.php',
|
||||
autoPrepare: false,
|
||||
checkRequired: 0,
|
||||
action: 'delete',
|
||||
data: { id: id },
|
||||
onSuccess: function() { retrieve_requests(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(async function() {
|
||||
await load_dept_cache();
|
||||
populate_dept_filter('filter_dept');
|
||||
|
||||
Reference in New Issue
Block a user