Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into doemal_ordering

This commit is contained in:
EikhantMon
2018-07-04 14:28:44 +06:30
6 changed files with 31 additions and 32 deletions

View File

@@ -96,8 +96,8 @@ class Origami::AddordersController < BaseOrigamiController
end end
def create def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s # Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s # Rails.logger.debug "Table ID - " + params[:table_id].to_s
is_extra_time = false is_extra_time = false
extra_time = '' extra_time = ''

View File

@@ -44,8 +44,9 @@ class Order < ApplicationRecord
if self.table_id.to_i > 0 if self.table_id.to_i > 0
table = DiningFacility.find(self.table_id) table = DiningFacility.find(self.table_id)
table.status = "occupied" table.update_attributes(status:"occupied")
table.save # table.status = "occupied"
# table.save
end end
else else
@@ -144,7 +145,7 @@ class Order < ApplicationRecord
end end
#if (!menu_item.nil?) #if (!menu_item.nil?)
Rails.logger.debug menu_item # Rails.logger.debug menu_item
set_order_items = Array.new set_order_items = Array.new
##If menu Item set item - must add child items to order as well, where price is only take from menu_item ##If menu Item set item - must add child items to order as well, where price is only take from menu_item
if (menu_item[:type] == "SetMenuItem") if (menu_item[:type] == "SetMenuItem")

View File

@@ -232,12 +232,15 @@ class OrderQueueStation < ApplicationRecord
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="") order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai| assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
# update print status for order items AssignedOrderItem.where({ order_id: '#{assigned}'}).update_all(print_status: true)
ai.print_status=true # assigned_items =AssignedOrderItem.where("order_id = '#{ order.order_id }'")
ai.save
end
# assigned_items.each do |ai|
# # update print status for order items
# ai.print_status=true
# ai.save
# end
end end
#Print order_item in 1 slip per item #Print order_item in 1 slip per item
@@ -273,9 +276,12 @@ class OrderQueueStation < ApplicationRecord
end end
end end
# update print status for completed same order items # update print status for completed same order items
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai| # AssignedOrderItem.where("order_id = '#{ order.order_id }'").update_all(print_status: true)
ai.print_status=true # AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
ai.save # ai.print_status=true
end # ai.save
# end
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where({ order_id: '#{assigned}'}).update_all(print_status: true)
end end
end end

View File

@@ -8,10 +8,10 @@ class SaleOrder < ApplicationRecord
belongs_to :order belongs_to :order
def create_sale_order(sale, order) def create_sale_order(sale, order)
self.sale_id = sale sale_order = SaleOrder.new
self.order_id = order sale_order.sale_id = sale
self.save sale_order.order_id = order
sale_order.save!
end end
private private

View File

@@ -17,8 +17,8 @@ class ShiftSale < ApplicationRecord
belongs_to :employee, :foreign_key => 'employee_id' belongs_to :employee, :foreign_key => 'employee_id'
def self.current_shift def self.current_shift
today_date = DateTime.now.strftime("%Y-%m-%d") # today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null").take shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null").first
return shift return shift
end end

View File

@@ -6,25 +6,21 @@ if @zones
#List all tables #List all tables
json.tables zone.tables do |table| json.tables zone.tables do |table|
if table.is_active if table.is_active
booking = table.get_current_booking
json.id table.id json.id table.id
json.name table.name json.name table.name
json.status table.status json.status table.status
json.zone_id table.zone_id #Add this zone_id to keep data structure consistance json.zone_id table.zone_id #Add this zone_id to keep data structure consistance
json.current_booking booking.booking_id rescue "" json.current_booking table.get_current_booking.booking_id rescue ""
json.sale_id booking.sale_id rescue ""
end end
end end
json.rooms zone.rooms do |room| json.rooms zone.rooms do |room|
if room.is_active if room.is_active
booking = room.get_current_booking
json.id room.id json.id room.id
json.name room.name json.name room.name
json.status room.status json.status room.status
json.zone_id room.zone_id #Add this zone_id to keep data structure consistance json.zone_id room.zone_id #Add this zone_id to keep data structure consistance
json.current_booking booking.booking_id rescue "" json.current_booking room.get_current_booking.booking_id rescue ""
json.sale_id booking.sale_id rescue ""
end end
end end
end end
@@ -32,25 +28,21 @@ if @zones
else #list all tables and rooms with out zones else #list all tables and rooms with out zones
json.tables @all_tables do |table| json.tables @all_tables do |table|
if table.is_active if table.is_active
booking = table.get_current_booking
json.id table.id json.id table.id
json.name table.name json.name table.name
json.status table.status json.status table.status
json.zone_id table.zone_id #Add this zone_id to keep data structure consistance json.zone_id table.zone_id #Add this zone_id to keep data structure consistance
json.current_booking booking.booking_id rescue "" json.current_booking table.get_current_booking.booking_id rescue ""
json.sale_id booking.sale_id rescue ""
end end
end end
json.rooms @all_rooms do |room| json.rooms @all_rooms do |room|
if room.is_active if room.is_active
booking = room.get_current_booking
json.id room.id json.id room.id
json.name room.name json.name room.name
json.status room.status json.status room.status
json.zone_id room.zone_id #Add this zone_id to keep data structure consistance json.zone_id room.zone_id #Add this zone_id to keep data structure consistance
json.current_booking booking.booking_id rescue "" json.current_booking room.get_current_booking.booking_id rescue ""
json.sale_id booking.sale_id rescue ""
end end
end end
end end