softDelete features
This commit is contained in:
@@ -140,6 +140,10 @@
|
||||
<i class="ti ti-ban me-1"></i>Void
|
||||
</button>
|
||||
|
||||
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete" onclick="delete_invoice()">
|
||||
<i class="ti ti-trash me-1"></i>Delete
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -151,6 +155,9 @@
|
||||
<?php require '../include_ending.php'; ?>
|
||||
|
||||
<script>
|
||||
|
||||
const can_delete = ['admin', 'owner'].includes(user_role);
|
||||
|
||||
var invoice_id = <?php echo $invoice_id; ?>;
|
||||
var invoice_data = null;
|
||||
|
||||
@@ -199,6 +206,7 @@
|
||||
!is_pi ? 'Only purchase invoices can be voided'
|
||||
: status === 0 ? 'Issue the document before voiding'
|
||||
: status === 4 ? 'Already void' : '');
|
||||
$('#btn_delete').toggleClass('d-none', !can_delete || !invoice_id);
|
||||
}
|
||||
|
||||
function retrieve_invoice() {
|
||||
@@ -362,6 +370,25 @@
|
||||
});
|
||||
}
|
||||
|
||||
function delete_invoice() {
|
||||
bootbox.confirm({
|
||||
message: 'Delete this document? Any GL entry will 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_invoice.php',
|
||||
autoPrepare: false,
|
||||
checkRequired: 0,
|
||||
action: 'delete',
|
||||
data: { id: invoice_id },
|
||||
onSuccess: function() { window.location.href = '<?php echo $server_url?>po/invoice.php'; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function void_invoice() {
|
||||
bootbox.confirm({
|
||||
message: '<strong>Void this purchase invoice?</strong><br>This action cannot be undone.',
|
||||
|
||||
Reference in New Issue
Block a user