From 9de4ca04dc8d69964ef21df7609f3839e68d3ed8 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 4 Jul 2018 11:42:19 +0630 Subject: [PATCH] check query and tax for webview --- app/controllers/origami/home_controller.rb | 2 +- app/controllers/origami/rooms_controller.rb | 4 +-- app/views/origami/home/index.html.erb | 37 +++++++++++++++------ app/views/origami/home/show.html.erb | 4 ++- app/views/origami/rooms/show.html.erb | 36 ++++++++++---------- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 773892f3..2d03d298 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -7,7 +7,7 @@ class Origami::HomeController < BaseOrigamiController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @shop = Shop.first # @shift = ShiftSale.current_open_shift(current_user.id) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 6877f8aa..49b7ce14 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -3,7 +3,7 @@ class Origami::RoomsController < BaseOrigamiController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') # @shift = ShiftSale.current_open_shift(current_user.id) @webview = false if check_mobile @@ -20,7 +20,7 @@ class Origami::RoomsController < BaseOrigamiController @tables = Table.unscoped.all.active.order('status desc') @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @room = DiningFacility.find(params[:room_id]) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 3f9daa9a..3e565ffa 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -50,8 +50,8 @@
<% end %>
- Zone <%= table.zone_id %>
- Table <%= table.name %> ( <%= table.seater %> Seat ) + Table <%= table.name %> ( <%= table.seater %> Seat )
+ Zone <%= table.zone_id %>
<% else %> @@ -61,16 +61,16 @@
<% end %>
- Zone <%= table.zone_id %>
- Table <%= table.name %> ( <%= table.seater %> Seat ) + Table <%= table.name %> ( <%= table.seater %> Seat )
+ Zone <%= table.zone_id %>
<% end %> <% else %>
- Zone <%= table.zone_id %>
- Table <%= table.name %> ( <%= table.seater %> Seat ) + Table <%= table.name %> ( <%= table.seater %> Seat )
+ Zone <%= table.zone_id %>
<% end %> @@ -107,11 +107,26 @@
<% @orders.each do |order| %> -
-
- <%= order.order_id %> -
-
+
text-white" data-id="<%= order.order_id %>"> +
+ <% + order_status = "" + sale_order = order.sale_orders.first + 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 %> +
+
<% end %>
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 211cc23b..11057247 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -371,7 +371,9 @@ <% else %> No Tax <% end %>
- + <%if !@webview %> + + <% end %> <%= @obj_sale.total_tax rescue 0%> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 52c5d108..0f3064f1 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -144,25 +144,25 @@
<% @orders.each do |order| %>
text-white" data-id="<%= 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 +
+ <% + order_status = "" + sale_order = order.sale_orders.first + 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 - else - order_status = order.status - end - %> + %> <%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %> -
-
+
+
<% end %> @@ -360,7 +360,9 @@ <% else %> No Tax <% end %>
- + <%if !@webview %> + + <% end %> <%= @obj_sale.total_tax rescue 0%>