From b3b2e9bd8d6e4df5680f6cc5d39abd330ae6762c Mon Sep 17 00:00:00 2001 From: Cherry Date: Wed, 31 May 2017 16:24:34 +0630 Subject: [PATCH] order controller updated --- app/controllers/api/orders_controller.rb | 1 + app/controllers/origami/home_controller.rb | 19 +++ app/views/origami/home/index.html.erb | 187 +++++++-------------- 3 files changed, 80 insertions(+), 127 deletions(-) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index d0fe2a77..57f2e48c 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -37,6 +37,7 @@ class Api::OrdersController < Api::ApiController #Create Table Booking or Room Booking if !params["booking_id"].nil? && params[:booking_id].to_i > 0 @order.new_booking = false + # @order.new_booking = true @order.booking_id = params[:booking_id] end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 8cbc8e55..fa4cec7c 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,6 +1,25 @@ class Origami::HomeController < BaseOrigamiController def index + @order = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, + order_items.id as order_items_id,dining_facilities.name as table_name") + .joins("left join booking_orders on booking_orders.order_id = orders.id + left join bookings on bookings.id = booking_orders.id + left join dining_facilities on dining_facilities.id = bookings.dining_facility_id + left join order_items on order_items.order_id = orders.id") + .where("orders.order_type=? and dining_facilities.is_active=?","dine_in",true) + .group("orders.id") + end def show + @order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") + .joins("left join orders on orders.id = order_items.order_id") + .where("order_items.order_id=?",params[:order_id]) + respond_to do |format| + format.html + format.json{ + render :json => @order_details.to_json + } + end + end end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 051c9a26..156ee076 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -18,16 +18,23 @@
+
-
+ <% @order.each do |order| %> +
+
-

Card title that wraps to a new line

-

This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.

+ + +

<%=order.table_name%>

+ +

<%=order.total_price%>

-
+ <%end %> +
@@ -137,27 +144,27 @@
-
+ + -
+
@@ -172,7 +179,7 @@
-
ORDER DETAILS - Table 4
+
ORDER DETAILS <% if @order_details%>- Table 4<%end%>
@@ -186,120 +193,26 @@
-
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + <% sub_total = 0%> + <% if @order_details%> + <% @order_details.each do |order_detail| %> + + + + + + <% end %> + <% end %>
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
- Menu Items Name @ 50.00 - - 5 - - 250.00 -
+ <%=order_detail.item_name%> @ <%=order_detail.price%> + + <%=order_detail.qty%> + + <%=order_detail.total_price%> + <%sub_total+=order_detail.total_price%> +
@@ -307,8 +220,13 @@ - - + + + +
Sub-Total750.00Total Amount<%=sub_total%>
@@ -349,3 +267,18 @@
+ \ No newline at end of file