diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 24ded975..87b8644d 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -2,6 +2,20 @@ class Origami::SplitBillController < BaseOrigamiController def index dining_id = params[:dining_id] - @table = DiningFacility.find_by_id(dining_id) + @table = DiningFacility.find(dining_id) + @booking = @table.get_booking + @order_items = Array.new + if @booking + @booking.booking_orders.each do |booking_order| + @order = Order.find(booking_order.order_id) + if (@order.status == "new") + @order.order_items.each do |item| + @order_items.push(item) + end + end + end + else + @booking = nil + end end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index bc068a1d..f9599783 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -674,7 +674,7 @@ $('#request_bills').click(function () { swal({ title: "Alert", - text: "Are you sure want to Split?", + text: "Do you want to Split bill?", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", @@ -683,7 +683,7 @@ }, function (isConfirm) { if (isConfirm) { var dining_id = "<%= @dining.id %>"; - window.location.href = '/origami/table/' + dining_id + "/split_bill"; + window.location.href = '/origami/table/' + dining_id + "/split_bills"; }else{ var order_id = $('#save_order_id').attr('data-order'); var ajax_url = "/origami/" + order_id + "/request_bills"; diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb index 0691ca2c..9aa09d37 100755 --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -1,7 +1,7 @@
Order No: <%=@order.order_id rescue ' '%>
Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+Date: <%=@order.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
| Items | -QTY | +
|---|
| Items | +QTY | Price | -
|---|---|---|
| - <%=sale_item.account_id%> - <%=sale_item.product_name%>@<%=sale_item.unit_price%> - | -- <%=sale_item.qty%> - | -- <%=(sale_item.qty*sale_item.unit_price)%> - | -