diff --git a/Gemfile.lock b/Gemfile.lock index 99c59b3b..a63a5ab4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,12 +96,8 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) -<<<<<<< HEAD nio4r (2.1.0) -======= mysql2 (0.4.6) - nio4r (2.0.0) ->>>>>>> f036274f5e32e3447277b99e21bc166a621a9dcf nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) 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..cbca1424 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,6 +1,15 @@ class Origami::HomeController < BaseOrigamiController def index + @order_table = Order.get_order_table() + @order_rooms = Order.get_order_rooms() + @orders = Order.get_orders() end def show + str = [] + @order_details = OrderItem.get_order_items_details(params[:order_id]) + @order_details.each do |ord_detail| + str.push(ord_detail) + end + render :json => str.to_json end end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 692c6591..9a4f7a75 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -1,6 +1,9 @@ class DiningFacility < ApplicationRecord belongs_to :zone + TABLE_TYPE = "Table" + ROOM_TYPE = "Room" + default_scope { order('order_by asc') } scope :active, -> {where(is_active: true)} diff --git a/app/models/order.rb b/app/models/order.rb index 7061fdb7..c638c3c6 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -204,9 +204,44 @@ class Order < ApplicationRecord OrderQueueProcessorJob.perform_later(self.id) end + #send order items and send to order queue def send_order_broadcast #Send to background job for processing OrderBroadcastJob.perform_later(self.id) + + #Origami: Cashier : to view order type Table + def self.get_order_table + order_table = 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("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true) + .group("orders.id") + end + #Origami: Cashier : to view order type Room + def self.get_order_rooms + order_rooms = 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 room_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("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true) + .group("orders.id") + end + #Origami: Cashier : to view orders + def self.get_orders + orders = 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_or_room_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("dining_facilities.is_active=?",true) + .group("orders.id") +>>>>>>> 47469cf466f1464fa4289e78c68b60e279174c60 end end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index afba7d7e..f839ad99 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -33,4 +33,10 @@ class OrderItem < ApplicationRecord end + #Origami : Cashier : to show order items details + def self.get_order_items_details(order_id) + 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=?",order_id) + end end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 051c9a26..e79900ab 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -18,67 +18,20 @@
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
---Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
- -
This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
---Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.
- -
This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
---Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
- -
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
-Last updated 3 mins ago
+<%=order_table.total_price%>
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
---Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
- -
This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
---Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.
- -
This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
+ <% tablename = order_room.room_name%> +<%=order_room.total_price%>
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
-This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
+<%=order.total_price%>
| - 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 - | -
| + + | ++ + | ++ + | +
| Sub-Total | -750.00 | -||
| Discounts | -(-250.00) | -||
| Service Tax | -50.00 | -||
| Commercial Tax | -39.50 | -||
| Grand Total | -589.50 | +Sub Total | +