From d1fd92bfd326b9d36e7521ad0bfed00225475f0e Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 2 Feb 2018 13:41:38 +0630 Subject: [PATCH] split bill ui --- .../origami/split_bill_controller.rb | 16 +- app/views/origami/home/show.html.erb | 4 +- app/views/origami/split_bill/index.html.erb | 582 +++++------------- config/routes.rb | 2 +- 4 files changed, 183 insertions(+), 421 deletions(-) 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 @@
- +
@@ -13,84 +13,58 @@
- - + + +

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 '-'%>

-
- - - - - +
+
ItemsQTY
+ + + + - - - - <% sub_total = 0 %> - <% @sale_data.sale_items.each do |sale_item| %> - <% - sub_total += sale_item.qty*sale_item.unit_price - if sale_item.price != 0 && sale_item.remark != "void" && sale_item.remark != "foc" - %> - > - - - - - <% - end - end + + + + <% sub_total = 0 %> + <% @order_items.each do |order_item| %> + <% + sub_total += order_item.qty*order_item.price %> - -
ItemsQTY Price
- - <%=sale_item.product_name%>@<%=sale_item.unit_price%> - - <%=sale_item.qty%> - - <%=(sale_item.qty*sale_item.unit_price)%> -
-
-
- -
+ > + + + <%=order_item.item_name%>@<%=order_item.price%> + + + <%=order_item.qty%> + + + <%=(order_item.qty*order_item.price)%> + + + <% + end + %> + + +
+
+ +
@@ -100,173 +74,116 @@
-
Discount Control
+
Split Bill Control
-
- +
+
-
-
- <% - @accounts.each do |acc| - %> - - <% end %> -
-
-
+
+
-
-
-
-
+
+ +
+
+
-
-
5%
-
-
-
-
1
-
2
-
3
-
-
-
- -
-
-
10%
-
-
-
-
4
-
5
-
6
-
-
+
1
+
2
+
3
-
-
15%
-
-
-
-
7
-
8
-
9
-
-
+
4
+
5
+
6
-
-
20%
-
-
-
-
0
-
.
-
00
-
-
+
7
+
8
+
9
-
-
30%
-
-
-
-
-
DEL
-
CLR
-
-
+
0
+
DEL
+
CLR
- - - + + +
-
-
+
+ - -
- -
- - - - - <% if @member_discount%> - - <%end %> -
+ +
+ +
+ + + +
+ diff --git a/config/routes.rb b/config/routes.rb index 58fd5ffd..12c263d5 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,7 +221,7 @@ scope "(:locale)", locale: /en|mm/ do post "bank_integration/sale_trans", to: "bank_integration#sale_trans", as:"sale_trans" #split bill - get 'table/:dining_id/split_bill' => 'split_bill#index', as:'split_bill_index' + get '/table/:dining_id/split_bills' => 'split_bill#index', as:'split_bill_index' end #--------- Waiter/Ordering Station ------------#