move table
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0'
|
|||||||
gem 'mysql2', '>= 0.3.18', '< 0.5'
|
gem 'mysql2', '>= 0.3.18', '< 0.5'
|
||||||
|
|
||||||
#Use PosgreSQL
|
#Use PosgreSQL
|
||||||
# gem 'pg'
|
gem 'pg'
|
||||||
|
|
||||||
# redis server for cable
|
# redis server for cable
|
||||||
# gem 'redis', '~> 3.0'
|
# gem 'redis', '~> 3.0'
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ GEM
|
|||||||
nokogiri (1.8.0)
|
nokogiri (1.8.0)
|
||||||
mini_portile2 (~> 2.2.0)
|
mini_portile2 (~> 2.2.0)
|
||||||
pdf-core (0.7.0)
|
pdf-core (0.7.0)
|
||||||
|
pg (0.21.0)
|
||||||
prawn (2.2.2)
|
prawn (2.2.2)
|
||||||
pdf-core (~> 0.7.0)
|
pdf-core (~> 0.7.0)
|
||||||
ttfunk (~> 1.5)
|
ttfunk (~> 1.5)
|
||||||
@@ -260,6 +261,7 @@ DEPENDENCIES
|
|||||||
kaminari (~> 1.0.1)
|
kaminari (~> 1.0.1)
|
||||||
listen (~> 3.0.5)
|
listen (~> 3.0.5)
|
||||||
mysql2 (>= 0.3.18, < 0.5)
|
mysql2 (>= 0.3.18, < 0.5)
|
||||||
|
pg
|
||||||
prawn
|
prawn
|
||||||
prawn-table
|
prawn-table
|
||||||
puma (~> 3.0)
|
puma (~> 3.0)
|
||||||
|
|||||||
@@ -17,22 +17,25 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@status_order = ""
|
@status_order = ""
|
||||||
@status_sale = ""
|
@status_sale = ""
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
|
|
||||||
@dining.bookings.active.each do |booking|
|
@dining.bookings.active.each do |booking|
|
||||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||||
@order_items = Array.new
|
@order_items = Array.new
|
||||||
booking.booking_orders.each do |booking_order|
|
booking.booking_orders.each do |booking_order|
|
||||||
|
|
||||||
order = Order.find(booking_order.order_id)
|
order = Order.find(booking_order.order_id)
|
||||||
@obj_order = order
|
if (order.status == "new")
|
||||||
@date = order.created_at
|
@obj_order = order
|
||||||
order.order_items.each do |item|
|
@date = order.created_at
|
||||||
@order_items.push(item)
|
order.order_items.each do |item|
|
||||||
|
@order_items.push(item)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@status_order = 'order'
|
@status_order = 'order'
|
||||||
else
|
else
|
||||||
sale = Sale.find(booking.sale_id)
|
sale = Sale.find(booking.sale_id)
|
||||||
if sale.sale_status != "completed"
|
if sale.sale_status != "completed"
|
||||||
|
puts "enter"
|
||||||
@sale_array.push(sale)
|
@sale_array.push(sale)
|
||||||
if @status_order == 'order'
|
if @status_order == 'order'
|
||||||
@status_order = 'sale'
|
@status_order = 'sale'
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class Origami::MovetableController < BaseOrigamiController
|
|||||||
bookings = Booking.where('dining_facility_id=?',change_from)
|
bookings = Booking.where('dining_facility_id=?',change_from)
|
||||||
booking_array = Array.new
|
booking_array = Array.new
|
||||||
bookings.each do | booking |
|
bookings.each do | booking |
|
||||||
if booking.sale_id.nil? || booking.sale.sale_status != 'completed'
|
if booking.sale_id.nil? || booking.sale.sale_status != 'completed' || booking.booking_status != 'moved'
|
||||||
booking_array.push(booking)
|
booking_array.push(booking)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,10 +12,27 @@ class Booking < ApplicationRecord
|
|||||||
scope :active, -> {where("booking_status != 'moved'")}
|
scope :active, -> {where("booking_status != 'moved'")}
|
||||||
|
|
||||||
def self.update_dining_facility(booking_arr, newd, old)
|
def self.update_dining_facility(booking_arr, newd, old)
|
||||||
booking_arr.each do |booking|
|
table = DiningFacility.find(newd)
|
||||||
booking.dining_facility_id = newd
|
exist = table.get_booking
|
||||||
booking.save
|
if exist
|
||||||
end
|
# order exists
|
||||||
|
booking_arr.each do |booking|
|
||||||
|
booking.dining_facility_id = newd
|
||||||
|
booking.booking_status = 'moved'
|
||||||
|
booking.save
|
||||||
|
booking.booking_orders.each do |bo|
|
||||||
|
bo.booking_id = exist.booking_id
|
||||||
|
bo.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
# new table
|
||||||
|
booking_arr.each do |booking|
|
||||||
|
booking.dining_facility_id = newd
|
||||||
|
booking.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
new_dining = DiningFacility.find(newd)
|
new_dining = DiningFacility.find(newd)
|
||||||
new_dining.make_occupied
|
new_dining.make_occupied
|
||||||
old_dining = DiningFacility.find(old)
|
old_dining = DiningFacility.find(old)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Customer < ApplicationRecord
|
|||||||
has_many :orders
|
has_many :orders
|
||||||
has_many :sales
|
has_many :sales
|
||||||
|
|
||||||
validates_presence_of :name, :contact_no, :email,:company,:card_no
|
validates_presence_of :name, :contact_no, :email,:card_no
|
||||||
validates :contact_no, uniqueness: true
|
validates :contact_no, uniqueness: true
|
||||||
validates :email, uniqueness: true
|
validates :email, uniqueness: true
|
||||||
validates :card_no, uniqueness: true
|
validates :card_no, uniqueness: true
|
||||||
@@ -34,7 +34,7 @@ class Customer < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_membership_transactions(customer)
|
def self.get_membership_transactions(customer)
|
||||||
@@ -58,13 +58,13 @@ class Customer < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search(search)
|
def self.search(search)
|
||||||
if search
|
if search
|
||||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||||
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",)
|
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",)
|
||||||
else
|
else
|
||||||
find(:all)
|
find(:all)
|
||||||
end
|
end
|
||||||
@@ -80,8 +80,8 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
WALKIN = "CUS-000000000001"
|
WALKIN = "CUS-000000000001"
|
||||||
TAKEAWAY = "CUS-000000000002"
|
TAKEAWAY = "CUS-000000000002"
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
|
|
||||||
def get_booking
|
def get_booking
|
||||||
booking = self.get_current_booking
|
booking = self.get_current_booking
|
||||||
|
puts "is bookig?"
|
||||||
|
puts booking
|
||||||
if booking
|
if booking
|
||||||
if booking.dining_facility_id.to_i == self.id
|
if booking.dining_facility_id.to_i == self.id
|
||||||
if booking.booking_status == 'assign'
|
if booking.booking_status == 'assign'
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ if (@booking)
|
|||||||
order_items = []
|
order_items = []
|
||||||
@booking.booking_orders.each do |bo|
|
@booking.booking_orders.each do |bo|
|
||||||
order = Order.find(bo.order_id)
|
order = Order.find(bo.order_id)
|
||||||
#if (order.status == "new")
|
if (order.status == "new")
|
||||||
order_items = order_items + order.order_items
|
order_items = order_items + order.order_items
|
||||||
#end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
json.order_items order_items do |item|
|
json.order_items order_items do |item|
|
||||||
|
|||||||
Reference in New Issue
Block a user