update pull split bill
This commit is contained in:
@@ -137,7 +137,22 @@
|
||||
<% @orders.each do |order| %>
|
||||
<div class="card orders red text-white" data-id = "<%= order.order_id %>">
|
||||
<div class="card-block">
|
||||
<%= order.order_id %>
|
||||
<%
|
||||
order_status = ""
|
||||
sale_order = SaleOrder.find_by_order_id(order)
|
||||
if sale_order
|
||||
unless sale_order.sale_id.nil?
|
||||
sale = Sale.find(sale_order.sale_id)
|
||||
order_status = sale.sale_status
|
||||
if order_status == 'new'
|
||||
order_status = order.status
|
||||
end
|
||||
end
|
||||
else
|
||||
order_status = order.status
|
||||
end
|
||||
%>
|
||||
<%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -349,7 +364,10 @@
|
||||
end
|
||||
%>
|
||||
</table>
|
||||
<button class='btn bg-blue' id='add_invoice'> Add to existing invoice </button>
|
||||
<button class='btn bg-primary' id='add_invoice'> Add to existing invoice </button>
|
||||
<% if !@spit_bill.nil? && @spit_bill == '1' %>
|
||||
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @sale_array.size > 1 %>
|
||||
<br><br>
|
||||
@@ -696,34 +714,46 @@ $('#pay').on('click',function() {
|
||||
});
|
||||
// Bill Request
|
||||
$('#request_bills').click(function() {
|
||||
var order_id = $('#save_order_id').attr('data-order');
|
||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||
$.ajax({
|
||||
var lookup_split_bill = '<%= @spit_bill %>';
|
||||
if(lookup_split_bill == '1'){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Do you want to Split bill?",
|
||||
type: "success",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#009900",
|
||||
confirmButtonText: "Yes, split it!",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
var dining_id = "<%= @room.id %>";
|
||||
window.location.href = '/origami/room/' + dining_id + "/split_bills";
|
||||
}else{
|
||||
requestBillProcess();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
requestBillProcess();
|
||||
}
|
||||
});
|
||||
|
||||
function requestBillProcess(){
|
||||
var order_id = $('#save_order_id').attr('data-order');
|
||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
// data: 'order_id='+ order_id,
|
||||
success:function(result){
|
||||
if(!result.status){
|
||||
$.confirm({
|
||||
title: 'Information!',
|
||||
content: result.error_message,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Ok',
|
||||
btnClass: 'btn-green',
|
||||
action: function(){
|
||||
window.location.href = '/origami';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
url: ajax_url,
|
||||
// data: 'order_id='+ order_id,
|
||||
success: function (result) {
|
||||
if (!result.status) {
|
||||
swal("Information!", result.error_message);
|
||||
}
|
||||
else {
|
||||
else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#move').on('click',function(){
|
||||
var dining_id = "<%= @room.id %>"
|
||||
@@ -736,7 +766,7 @@ $('#back').on('click',function(){
|
||||
|
||||
$('#add_invoice').on('click',function(){
|
||||
var dining_id = "<%= @room.id %>"
|
||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||
var sale_id = $("#sale_id").val(); //<%= @obj_sale.sale_id rescue "" %>
|
||||
var ajax_url = "/origami/sale/append_order";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
@@ -864,4 +894,22 @@ $('#add_invoice').on('click',function(){
|
||||
var dining_id = "<%= @room.id %>"
|
||||
window.location.href = '/origami/addorders/' + dining_id;
|
||||
});
|
||||
|
||||
/* split bill in add to existing invoice*/
|
||||
$('#split_bill').on('click', function(){
|
||||
swal({
|
||||
title: "Alert",
|
||||
text: "Are you sure, you want to split bill?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Yes, split it!",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if(isConfirm){
|
||||
var dining_id = "<%= @room.id %>";
|
||||
window.location.href = '/origami/table/' + dining_id + "/split_bills";
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user