softDelete features
This commit is contained in:
@@ -187,6 +187,11 @@
|
||||
<i class="ti ti-ban me-1"></i>Cancel Quotation
|
||||
</button>
|
||||
|
||||
<button class="btn btn-outline-danger w-100 d-none" id="btn_delete"
|
||||
onclick="delete_quotation()">
|
||||
<i class="ti ti-trash me-1"></i>Delete Quotation
|
||||
</button>
|
||||
|
||||
<hr class="d-none" id="hr_convert">
|
||||
<a href="javascript:void(0);" class="btn btn-success w-100 d-none" id="btn_convert"
|
||||
onclick="convert_to_order()">
|
||||
@@ -207,6 +212,8 @@
|
||||
<script>
|
||||
// custom.js globals: remove_item(), init_product_search_inputs(), escape_html(), format_number()
|
||||
|
||||
const can_delete = ['admin', 'owner'].includes(user_role);
|
||||
|
||||
var quotation_id = <?php echo $quotation_id; ?>;
|
||||
var quotation_data = null;
|
||||
var item_index = 0;
|
||||
@@ -342,6 +349,7 @@
|
||||
$('#btn_reject').toggleClass('d-none', !is_sent);
|
||||
$('#btn_reopen').toggleClass('d-none', is_draft || is_closed);
|
||||
$('#btn_cancel').toggleClass('d-none', is_closed || (is_draft && !quotation_id));
|
||||
$('#btn_delete').toggleClass('d-none', !can_delete || !quotation_id);
|
||||
|
||||
// Convert to Order — only on Accepted, not yet converted
|
||||
var show_convert = is_accepted && !is_converted;
|
||||
@@ -481,6 +489,25 @@
|
||||
}
|
||||
|
||||
|
||||
function delete_quotation() {
|
||||
bootbox.confirm({
|
||||
message: 'Delete this quotation? 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?>revenue/api/engine/delete_quotation.php',
|
||||
autoPrepare: false,
|
||||
checkRequired: 0,
|
||||
action: 'delete',
|
||||
data: { id: quotation_id },
|
||||
onSuccess: function() { window.location.href = '<?php echo $server_url?>revenue/quotation.php'; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).on('contact:selected', '#contact', function(e, contact) {
|
||||
$('#contact_id').val(contact.id);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user