add void and cancel on pending bill

This commit is contained in:
nyanlinhtut
2023-04-21 15:13:33 +06:30
parent 6e4017ea4a
commit 7578286ee4
3 changed files with 67 additions and 1 deletions

View File

@@ -411,13 +411,15 @@
<% if current_user.role != "waiter" && @status != "order"%>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn btn-block bg-red waves-effect" >VOID</button>
<%end%>
<% if @status != "sale"%>
<!-- <button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button> -->
<% order_id = @pending.try(:orders).try(:first).try(:order_id) if @status == 'order' %>
<button type="button" class="btn btn-block bg-blue waves-effect req_bill" >Req.Bill</button>
<input type="hidden" id="save_order_id" value="<%=order_id%>">
<button type="button" id="order_cancel" class="btn btn-block bg-red waves-effect" >CANCEL</button>
<input type="hidden" id="save_order_id" value="<%=order_id%>">
<%end%>
<% elsif @pending && params[:active] == 'completed' %>
@@ -718,4 +720,37 @@ $('#reprint').on('click', function () {
});
}
$('#order_cancel').on('click', function () {
var order_id = $('#save_order_id').val();
swal({
title: "Alert",
text: "Are you sure want to cancel this order?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, cancel it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$('.confirm').prop("disabled",true);
$.ajax({
type: "GET",
url: "/foodcourt/food_court/"+order_id+"/cancel_order" ,
data: {},
dataType: "json",
success: function(data) {
if(data.status == true)
{
window.location.href = '/foodcourt/app_orders';
}else{
alert("error")
swal("Alert!", "Error!", data.error_message);
location.reload();
}
}
});
}
});
});
</script>