fix timezone - time with local timezone to default timezone

This commit is contained in:
pyaephyoeaung
2022-05-19 14:20:55 +06:30
parent 7598a96e60
commit 214712fd2d
48 changed files with 294 additions and 305 deletions

View File

@@ -13,7 +13,7 @@ class Api::BillController < Api::ApiController
if params[:booking_id].present? if params[:booking_id].present?
booking = Booking.find(params[:booking_id]) booking = Booking.find(params[:booking_id])
if booking.booking_orders.count > 0 if booking.booking_orders.count > 0
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil? if booking.checkin_at > Time.current && booking.checkout_at.nil?
@status = false @status = false
@error_message = "Operation failed, Could not request bill!" @error_message = "Operation failed, Could not request bill!"
else else

View File

@@ -40,11 +40,11 @@ class Api::CheckInProcessController < Api::ApiController
lookup_checkout_time = Lookup.collection_of("checkout_alert_time") lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
now = Time.now.utc now = Time.current
lookup_checkout_time.each do |checkout_time| lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-") arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p") start_time = Time.zone.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p") end_time = Time.zone.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time if start_time <= now && now <= end_time
alert_time_min = checkout_time[1].to_i alert_time_min = checkout_time[1].to_i
end end
@@ -68,18 +68,18 @@ class Api::CheckInProcessController < Api::ApiController
if dining_facility.is_active && dining_facility.status == "available" if dining_facility.is_active && dining_facility.status == "available"
if dining_facility.current_checkin_booking.nil? if dining_facility.current_checkin_booking.nil?
if params[:checkin_time].present? if params[:checkin_time].present?
checkin_at = Time.parse(params[:checkin_time]) checkin_at = Time.zone.parse(params[:checkin_time])
else else
checkin_at = Time.now checkin_at = Time.current
end end
checkout_at = nil checkout_at = nil
lookup_checkout_time = Lookup.collection_of("checkout_time") lookup_checkout_time = Lookup.collection_of("checkout_time")
today = Time.now today = Time.current
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
lookup_checkout_time.each do |checkout_time| lookup_checkout_time.each do |checkout_time|
start_time, end_time = checkout_time[0].split("-").map{ |t| Time.parse(t.strip).strftime("%H:%M%p") } start_time, end_time = checkout_time[0].split("-").map{ |t| Time.zone.parse(t.strip).strftime("%H:%M%p") }
if start_time <= today.strftime("%H:%M%p") && today.strftime("%H:%M%p") <= end_time if start_time <= today.strftime("%H:%M%p") && today.strftime("%H:%M%p") <= end_time
checkout_at = checkin_at + (checkout_time[1]).to_i.minutes checkout_at = checkin_at + (checkout_time[1]).to_i.minutes
end end
@@ -134,7 +134,7 @@ class Api::CheckInProcessController < Api::ApiController
def request_time def request_time
if !params[:booking_id].nil? && !params[:time].nil? if !params[:booking_id].nil? && !params[:time].nil?
time = Time.parse(params[:time]) time = Time.zone.parse(params[:time])
booking = Booking.find(params[:booking_id]) booking = Booking.find(params[:booking_id])
checkout_at = booking.checkout_at.utc checkout_at = booking.checkout_at.utc
@@ -163,9 +163,9 @@ class Api::CheckInProcessController < Api::ApiController
if !params[:booking_id].nil? && !params[:checkout_time].nil? if !params[:booking_id].nil? && !params[:checkout_time].nil?
booking = Booking.find(params[:booking_id]) booking = Booking.find(params[:booking_id])
dining_facility = DiningFacility.find(booking.dining_facility_id) dining_facility = DiningFacility.find(booking.dining_facility_id)
checkout_at = Time.parse(params[:checkout_time]).utc checkout_at = Time.zone.parse(params[:checkout_time]).utc
if dining_facility.check_time(checkout_at, booking, "checkout") if dining_facility.check_time(checkout_at, booking, "checkout")
checkout_time = checkout_at.getlocal checkout_time = checkout_at
booking.checkout_at = checkout_time booking.checkout_at = checkout_time
booking.reserved_at = checkout_time booking.reserved_at = checkout_time
booking.reserved_by = current_login_employee.name booking.reserved_by = current_login_employee.name

View File

@@ -198,7 +198,7 @@ class Api::OrdersController < Api::ApiController
if booking_id.present? if booking_id.present?
if booking = Booking.find(booking_id) if booking = Booking.find(booking_id)
if booking.checkout_at.present? if booking.checkout_at.present?
if booking.checkout_at.utc <= Time.now.utc if booking.checkout_at <= Time.current
status = false status = false
end end
end end

View File

@@ -31,38 +31,38 @@ class BaseReportController < ActionController::Base
period = params[:period] period = params[:period]
if params[:from].present? && params[:to].present? if params[:from].present? && params[:to].present?
from = Time.parse(params[:from]) from = Time.zone.parse(params[:from])
to = Time.parse(params[:to]) to = Time.zone.parse(params[:to])
else else
case period.to_i case period.to_i
when PERIOD["today"] when PERIOD["today"]
from = Time.now from = Time.current
to = Time.now to = Time.current
when PERIOD["yesterday"] when PERIOD["yesterday"]
from = 1.day.ago from = 1.day.ago
to = 1.day.ago to = 1.day.ago
when PERIOD["this_week"] when PERIOD["this_week"]
from = Time.now.beginning_of_week from = Time.current.beginning_of_week
to = Time.now to = Time.current
when PERIOD["last_week"] when PERIOD["last_week"]
from = 1.week.ago.beginning_of_week from = 1.week.ago.beginning_of_week
to = 1.week.ago.end_of_week to = 1.week.ago.end_of_week
when PERIOD["last_7"] when PERIOD["last_7"]
from = 7.day.ago from = 7.day.ago
to = Time.now to = Time.current
when PERIOD["this_month"] when PERIOD["this_month"]
from = Time.now.beginning_of_month from = Time.current.beginning_of_month
to = Time.now to = Time.current
when PERIOD["last_month"] when PERIOD["last_month"]
from = 1.month.ago.beginning_of_month from = 1.month.ago.beginning_of_month
to = 1.month.ago.end_of_month to = 1.month.ago.end_of_month
when PERIOD["last_30"] when PERIOD["last_30"]
from = 30.day.ago from = 30.day.ago
to = Time.now to = Time.current
when PERIOD["this_year"] when PERIOD["this_year"]
from = Time.now.beginning_of_year from = Time.current.beginning_of_year
to = Time.now to = Time.current
when PERIOD["last_year"] when PERIOD["last_year"]
from = 1.year.ago.beginning_of_year from = 1.year.ago.beginning_of_year
to = 1.year.ago.end_of_year to = 1.year.ago.end_of_year

View File

@@ -105,7 +105,7 @@ class Crm::DiningQueuesController < BaseCrmController
booking = Booking.create({:dining_facility_id => params[:table_id], booking = Booking.create({:dining_facility_id => params[:table_id],
:type => type, :type => type,
:checkin_at => Time.now.utc, :checkin_at => Time.current,
:customer_id => queue.customer_id, :customer_id => queue.customer_id,
:booking_status => "assign"}) :booking_status => "assign"})
booking.save! booking.save!

View File

@@ -3,8 +3,8 @@ class Crm::HomeController < BaseCrmController
@booking = Booking.all @booking = Booking.all
@customer = Customer.all @customer = Customer.all
from = Time.now.beginning_of_day.utc from = Time.current.beginning_of_day
to = Time.now.end_of_day.utc to = Time.current.end_of_day
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC') @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
redirect_to crm_customers_path redirect_to crm_customers_path
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)

View File

@@ -78,15 +78,15 @@ private
def get_date_range_from_params def get_date_range_from_params
if params[:from].present? && params[:to].present? if params[:from].present? && params[:to].present?
if params[:from_time].present? && params[:to_time].present? if params[:from_time].present? && params[:to_time].present?
from = Time.parse("#{params[:from]} #{params[:from_time]}") from = Time.zone.parse("#{params[:from]} #{params[:from_time]}")
to = Time.parse("#{params[:to]} #{params[:to_time]}") to = Time.zone.parse("#{params[:to]} #{params[:to_time]}")
else else
from = Time.parse(params[:from]) from = Time.zone.parse(params[:from])
to = Time.parse(params[:to]).end_of_day to = Time.zone.parse(params[:to]).end_of_day
end end
else else
from = Time.now.beginning_of_day from = Time.current.beginning_of_day
to = Time.now.end_of_day to = Time.current.end_of_day
end end
return from, to return from, to
end end

View File

@@ -32,7 +32,7 @@ class Induties::AssignInDutiesController < ApplicationController
induty.booking_id = booking_id induty.booking_id = booking_id
induty.commissioner_ids = commissioner_ids induty.commissioner_ids = commissioner_ids
induty.by_name = params[:by_name] induty.by_name = params[:by_name]
induty.in_time = Time.now.utc induty.in_time = Time.current
if induty.save if induty.save
dinning = DiningFacility.find(induty.dinning_id) dinning = DiningFacility.find(induty.dinning_id)
@induty= {"id"=>induty.id, @induty= {"id"=>induty.id,
@@ -48,7 +48,7 @@ class Induties::AssignInDutiesController < ApplicationController
def induties_checkout def induties_checkout
induty_id = params[:induty_id] induty_id = params[:induty_id]
induty = InDuty.find(induty_id) induty = InDuty.find(induty_id)
induty.out_time = Time.now.utc induty.out_time = Time.current
induty.save induty.save
@induty =induty @induty =induty
respond_to do |format| respond_to do |format|

View File

@@ -90,7 +90,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'") .where("assigned_order_items.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.current.beginning_of_day.utc}'")
.group("assigned_order_items.assigned_order_item_id") .group("assigned_order_items.assigned_order_item_id")
.order("assigned_order_items.created_at") .order("assigned_order_items.created_at")
end end
@@ -106,7 +106,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") .where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.current.beginning_of_day.utc}' and '#{Time.current.end_of_day.utc}'")
.group("assigned_order_items.order_id") .group("assigned_order_items.order_id")
.limit(20) .limit(20)
.order("assigned_order_items.created_at") .order("assigned_order_items.created_at")

View File

@@ -192,7 +192,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table} #{queue_status}") .where("assigned_order_items.created_at >= '#{Time.current.beginning_of_day.utc}' #{oqs} #{table} #{queue_status}")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.order("assigned_order_items.assigned_order_item_id desc") .order("assigned_order_items.assigned_order_item_id desc")
.group("odt.order_items_id") .group("odt.order_items_id")
@@ -210,7 +210,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") .where("assigned_order_items.delivery_status = true AND assigned_order_items.created_at between '#{Time.current.beginning_of_day.utc}' and '#{Time.current.end_of_day.utc}'")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.order_id") .group("assigned_order_items.order_id")
.limit(50) .limit(50)
@@ -231,7 +231,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") .where("assigned_order_items.created_at between '#{Time.current.beginning_of_day.utc}' and '#{Time.current.end_of_day.utc}'")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("odt.order_items_id") .group("odt.order_items_id")
.order("assigned_order_items.created_at desc") .order("assigned_order_items.created_at desc")
@@ -266,7 +266,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = aoi.order_id left join booking_orders as bo on bo.order_id = aoi.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("aoi.delivery_status = #{status} AND aoi.created_at >= '#{Time.now.beginning_of_day.utc}' ") .where("aoi.delivery_status = #{status} AND aoi.created_at >= '#{Time.current.beginning_of_day.utc}' ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("order_queue_stations.id") .group("order_queue_stations.id")
end end

View File

@@ -3,8 +3,8 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon
def settle_trans def settle_trans
if(params[:type] == 'request') if(params[:type] == 'request')
card_settle_trans = CardSettleTran.new() card_settle_trans = CardSettleTran.new()
card_settle_trans.req_date = Time.now.strftime("%Y-%m-%d") card_settle_trans.req_date = Time.current.strftime("%Y-%m-%d")
card_settle_trans.req_time = Time.now.utc card_settle_trans.req_time = Time.current
card_settle_trans.req_cmd = params[:data][:cmd_type] card_settle_trans.req_cmd = params[:data][:cmd_type]
card_settle_trans.req_type = params[:data][:payment_type] card_settle_trans.req_type = params[:data][:payment_type]
card_settle_trans.save() card_settle_trans.save()
@@ -13,8 +13,8 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon
response = {status: 'success', card_settle_trans_id: card_settle_trans_id} response = {status: 'success', card_settle_trans_id: card_settle_trans_id}
else else
card_settle_trans = CardSettleTran.find(params[:card_settle_trans_id]) card_settle_trans = CardSettleTran.find(params[:card_settle_trans_id])
card_settle_trans.res_date = Time.now.strftime("%Y-%m-%d") card_settle_trans.res_date = Time.current.strftime("%Y-%m-%d")
card_settle_trans.res_time = Time.now.utc card_settle_trans.res_time = Time.current
card_settle_trans.res_cmd = params[:data][:CMD] card_settle_trans.res_cmd = params[:data][:CMD]
card_settle_trans.res_type = params[:data][:TYPE] card_settle_trans.res_type = params[:data][:TYPE]
card_settle_trans.status = params[:data][:STATUS] card_settle_trans.status = params[:data][:STATUS]
@@ -42,8 +42,8 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon
if(params[:type] == 'request') if(params[:type] == 'request')
card_sale_trans = CardSaleTran.new() card_sale_trans = CardSaleTran.new()
card_sale_trans.sale_id = params[:data][:sale_id] card_sale_trans.sale_id = params[:data][:sale_id]
card_sale_trans.req_date = Time.now.strftime("%Y-%m-%d") card_sale_trans.req_date = Time.current.strftime("%Y-%m-%d")
card_sale_trans.req_time = Time.now.utc card_sale_trans.req_time = Time.current
card_sale_trans.req_amt = params[:data][:amt] card_sale_trans.req_amt = params[:data][:amt]
card_sale_trans.req_inv_no = params[:data][:inv_no] card_sale_trans.req_inv_no = params[:data][:inv_no]
card_sale_trans.req_cmd = params[:data][:cmd_type] card_sale_trans.req_cmd = params[:data][:cmd_type]

View File

@@ -2,14 +2,14 @@ class Origami::CheckInProcessController < BaseOrigamiController
def check_in_process def check_in_process
lookup_checkout_time = Lookup.collection_of("checkout_time") lookup_checkout_time = Lookup.collection_of("checkout_time")
today = Time.now today = Time.current
checkout_at = Time.now checkout_at = Time.current
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
lookup_checkout_time.each do |checkout_time| lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-") arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).strftime("%H:%M%p") start_time = Time.zone.parse(arr_time[0].strip).strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).strftime("%H:%M%p") end_time = Time.zone.parse(arr_time[1].strip).strftime("%H:%M%p")
if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end end
@@ -25,7 +25,7 @@ class Origami::CheckInProcessController < BaseOrigamiController
# end # end
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking", @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => "TableBooking",
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) :checkin_by=>current_login_employee.name,:checkin_at => Time.current,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
cashier_terminal = CashierTerminal.find_by_id(@dining_facility.zone_id) cashier_terminal = CashierTerminal.find_by_id(@dining_facility.zone_id)

View File

@@ -9,7 +9,7 @@ class Origami::FoodCourtController < ApplicationController
def index def index
today = DateTime.now today = DateTime.now
day = Date.today.wday day = Date.current.wday
# if params[:menu] == "true" # if params[:menu] == "true"
@menus = [] @menus = []
@menu = [] @menu = []
@@ -48,7 +48,7 @@ class Origami::FoodCourtController < ApplicationController
def modify_order def modify_order
@cashier_type = "food_court" @cashier_type = "food_court"
today = DateTime.now today = DateTime.now
day = Date.today.wday day = Date.current.wday
# if params[:menu] == "true" # if params[:menu] == "true"
@menus = [] @menus = []
@menu = [] @menu = []

View File

@@ -14,7 +14,7 @@ class Origami::MoveroomController < BaseOrigamiController
@status_sale = "" @status_sale = ""
@sale_array = Array.new @sale_array = Array.new
@dining = DiningFacility.find(params[:dining_id]) @dining = DiningFacility.find(params[:dining_id])
@dining_room = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") @dining_room = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}' ")
@dining_room.each do |booking| @dining_room.each do |booking|
if booking.sale_id.nil? if booking.sale_id.nil?
@order_items = Array.new @order_items = Array.new

View File

@@ -15,7 +15,7 @@ class Origami::MovetableController < BaseOrigamiController
@status_sale = "" @status_sale = ""
@sale_array = Array.new @sale_array = Array.new
@dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}' ")
@dining_booking.each do |booking| @dining_booking.each do |booking|
if booking.sale_id.nil? if booking.sale_id.nil?
@@ -73,7 +73,7 @@ class Origami::MovetableController < BaseOrigamiController
# bookings = Booking.where('dining_facility_id=?',change_from) # bookings = Booking.where('dining_facility_id=?',change_from)
bookings = Booking.where("((DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}')) AND dining_facility_id='#{change_from}'") bookings = Booking.where("((DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}')) AND dining_facility_id='#{change_from}'")
booking_array = Array.new booking_array = Array.new
order_items = Array.new order_items = Array.new

View File

@@ -9,7 +9,7 @@ class Origami::QuickServiceController < ApplicationController
def index def index
today = DateTime.now today = DateTime.now
day = Date.today.wday day = Date.current.wday
@menus = [] @menus = []
@menu = [] @menu = []
@@ -47,7 +47,7 @@ class Origami::QuickServiceController < ApplicationController
def modify_order def modify_order
@cashier_type = "quick_service" @cashier_type = "quick_service"
today = DateTime.now today = DateTime.now
day = Date.today.wday day = Date.current.wday
# if params[:menu] == "true" # if params[:menu] == "true"
@menus = [] @menus = []
@menu = [] @menu = []

View File

@@ -12,7 +12,7 @@ class Origami::RequestBillsController < ApplicationController
order_id = params[:id] # order_id order_id = params[:id] # order_id
order = Order.find(order_id) order = Order.find(order_id)
booking = order.booking booking = order.booking
if booking.checkin_at.utc > Time.now.utc && booking.checkout_at.nil? if booking.checkin_at > Time.current && booking.checkout_at.nil?
@status = false @status = false
@error_message = "Operation failed, Could not request bill!" @error_message = "Operation failed, Could not request bill!"
else else
@@ -26,7 +26,7 @@ class Origami::RequestBillsController < ApplicationController
in_duties.each do |in_duty| in_duties.each do |in_duty|
induty = InDuty.find(in_duty.id) induty = InDuty.find(in_duty.id)
induty.sale_id = sale_data.sale_id induty.sale_id = sale_data.sale_id
induty.out_time = Time.now.utc induty.out_time = Time.current
induty.save induty.save
end end
end end

View File

@@ -34,7 +34,7 @@ class Origami::RoomsController < BaseOrigamiController
@membership = MembershipSetting::MembershipSetting @membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.all @payment_methods = PaymentMethodSetting.all
@dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") @dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.current.prev_day}' ")
@order_items = Array.new @order_items = Array.new
@dining_room.each do |booking| @dining_room.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved' if booking.sale_id.nil? && booking.booking_status != 'moved'

View File

@@ -62,7 +62,7 @@ class Origami::SplitBillController < BaseOrigamiController
split_orders = [] split_orders = []
new_order = nil new_order = nil
booking = Booking.create({:dining_facility_id => table.id, :type => type, :checkin_at => Time.now.utc, :checkin_by => current_user.name, :booking_status => "assign" }) booking = Booking.create({:dining_facility_id => table.id, :type => type, :checkin_at => Time.current, :checkin_by => current_user.name, :booking_status => "assign" })
if orders.present? if orders.present?
split_orders += orders.map { |x| x["id"] } split_orders += orders.map { |x| x["id"] }

View File

@@ -30,9 +30,9 @@ class Settings::DiningChargesController < ApplicationController
def create def create
@dining_charge = DiningCharge.new(dining_charge_params) @dining_charge = DiningCharge.new(dining_charge_params)
@dining_charge.dining_facility_id = @settings_dining_facility.id @dining_charge.dining_facility_id = @settings_dining_facility.id
@dining_charge.minimum_free_time = DateTime.parse(dining_charge_params["minimum_free_time"]) @dining_charge.minimum_free_time = Time.zone.parse(dining_charge_params["minimum_free_time"])
@dining_charge.charge_block = DateTime.parse(dining_charge_params["charge_block"]) @dining_charge.charge_block = Time.zone.parse(dining_charge_params["charge_block"])
@dining_charge.time_rounding_block = DateTime.parse(dining_charge_params["time_rounding_block"]) @dining_charge.time_rounding_block = Time.zone.parse(dining_charge_params["time_rounding_block"])
respond_to do |format| respond_to do |format|
if @dining_charge.save if @dining_charge.save
@@ -54,14 +54,14 @@ class Settings::DiningChargesController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
@dining_charge.dining_facility_id = @settings_dining_facility.id @dining_charge.dining_facility_id = @settings_dining_facility.id
@dining_charge.minimum_free_time = DateTime.parse(dining_charge_params["minimum_free_time"]) @dining_charge.minimum_free_time = Time.zone.parse(dining_charge_params["minimum_free_time"])
@dining_charge.charge_block = DateTime.parse(dining_charge_params["charge_block"]) @dining_charge.charge_block = Time.zone.parse(dining_charge_params["charge_block"])
@dining_charge.time_rounding_block = DateTime.parse(dining_charge_params["time_rounding_block"]) @dining_charge.time_rounding_block = Time.zone.parse(dining_charge_params["time_rounding_block"])
if @dining_charge.update(dining_charge_params) if @dining_charge.update(dining_charge_params)
@dining_charge.minimum_free_time = DateTime.parse(dining_charge_params["minimum_free_time"]) @dining_charge.minimum_free_time = Time.zone.parse(dining_charge_params["minimum_free_time"])
@dining_charge.charge_block = DateTime.parse(dining_charge_params["charge_block"]) @dining_charge.charge_block = Time.zone.parse(dining_charge_params["charge_block"])
@dining_charge.time_rounding_block = DateTime.parse(dining_charge_params["time_rounding_block"]) @dining_charge.time_rounding_block = Time.zone.parse(dining_charge_params["time_rounding_block"])
# @dining_charge.minimum_free_time = @dining_charge.minimum_free_time.to_datetime.advance(hours: +6, minutes: +30) # @dining_charge.minimum_free_time = @dining_charge.minimum_free_time.to_datetime.advance(hours: +6, minutes: +30)
# @dining_charge.charge_block = @dining_charge.charge_block.to_datetime.advance(hours: +6, minutes: +30) # @dining_charge.charge_block = @dining_charge.charge_block.to_datetime.advance(hours: +6, minutes: +30)
# @dining_charge.time_rounding_block = @dining_charge.time_rounding_block.to_datetime.advance(hours: +6, minutes: +30) # @dining_charge.time_rounding_block = @dining_charge.time_rounding_block.to_datetime.advance(hours: +6, minutes: +30)

View File

@@ -12,6 +12,8 @@ class Transactions::BookingsController < ApplicationController
@bookings = Booking.order("sale_id desc") @bookings = Booking.order("sale_id desc")
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20) @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
else else
from = Time.zone.parse(params[:from]).beginning_of_day
to = Time.zone.parse(params[:to]).end_of_day
booking = Booking.search(filter,from,to) booking = Booking.search(filter,from,to)
if booking.count > 0 if booking.count > 0
@bookings = booking @bookings = booking

View File

@@ -50,54 +50,49 @@ class Transactions::CardSaleTransController < ApplicationController
def get_date_range_from_params def get_date_range_from_params
period_type = params[:period_type] period_type = params[:period_type]
period = params[:period] period = params[:period]
from = params[:from]
to = params[:to] if params[:from].present? && params[:to].present?
day_ref = Time.now from = Time.zone.parse(params[:from])
if from.present? && to.present? to = Time.zone.parse(params[:to])
f_date = DateTime.parse(from) else
t_date = DateTime.parse(to)
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day
to = t_time.end_of_day
else
case period.to_i case period.to_i
when PERIOD["today"] when PERIOD["today"]
from = day_ref.beginning_of_day.utc from = Time.current
to = day_ref.end_of_day.utc to = Time.current
when PERIOD["yesterday"] when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc from = 1.day.ago
to = (day_ref - 1.day).end_of_day.utc to = 1.day.ago
when PERIOD["this_week"] when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc from = Time.current.beginning_of_week
to = Time.now.utc to = Time.current
when PERIOD["last_week"] when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc from = 1.week.ago.beginning_of_week
to = (day_ref - 7.day).end_of_week.utc to = 1.week.ago.end_of_week
when PERIOD["last_7"] when PERIOD["last_7"]
from = (day_ref - 7.day).utc from = 7.day.ago
to = Time.now.utc to = Time.current
when PERIOD["this_month"] when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc from = Time.current.beginning_of_month
to = Time.now.utc to = Time.current
when PERIOD["last_month"] when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc from = 1.month.ago.beginning_of_month
to = (day_ref - 1.month).end_of_month.utc to = 1.month.ago.end_of_month
when PERIOD["last_30"] when PERIOD["last_30"]
from = (day_ref - 30.day).utc from = 30.day.ago
to = Time.now.utc to = Time.current
when PERIOD["this_year"] when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc from = Time.current.beginning_of_year
to = Time.now.utc to = Time.current
when PERIOD["last_year"] when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc from = 1.year.ago.beginning_of_year
to = (day_ref - 1.year).end_of_year.utc to = 1.year.ago.end_of_year
end end
end end
return from, to from = from.beginning_of_day
to = to.end_of_day
return from, to
end end
end end

View File

@@ -51,54 +51,49 @@ class Transactions::CardSettleTransController < ApplicationController
def get_date_range_from_params def get_date_range_from_params
period_type = params[:period_type] period_type = params[:period_type]
period = params[:period] period = params[:period]
from = params[:from]
to = params[:to] if params[:from].present? && params[:to].present?
day_ref = Time.now from = Time.zone.parse(params[:from])
if from.present? && to.present? to = Time.zone.parse(params[:to])
f_date = DateTime.parse(from) else
t_date = DateTime.parse(to)
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day
to = t_time.end_of_day
else
case period.to_i case period.to_i
when PERIOD["today"] when PERIOD["today"]
from = day_ref.beginning_of_day.utc from = Time.current
to = day_ref.end_of_day.utc to = Time.current
when PERIOD["yesterday"] when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc from = 1.day.ago
to = (day_ref - 1.day).end_of_day.utc to = 1.day.ago
when PERIOD["this_week"] when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc from = Time.current.beginning_of_week
to = Time.now.utc to = Time.current
when PERIOD["last_week"] when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc from = 1.week.ago.beginning_of_week
to = (day_ref - 7.day).end_of_week.utc to = 1.week.ago.end_of_week
when PERIOD["last_7"] when PERIOD["last_7"]
from = (day_ref - 7.day).utc from = 7.day.ago
to = Time.now.utc to = Time.current
when PERIOD["this_month"] when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc from = Time.current.beginning_of_month
to = Time.now.utc to = Time.current
when PERIOD["last_month"] when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc from = 1.month.ago.beginning_of_month
to = (day_ref - 1.month).end_of_month.utc to = 1.month.ago.end_of_month
when PERIOD["last_30"] when PERIOD["last_30"]
from = (day_ref - 30.day).utc from = 30.day.ago
to = Time.now.utc to = Time.current
when PERIOD["this_year"] when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc from = Time.current.beginning_of_year
to = Time.now.utc to = Time.current
when PERIOD["last_year"] when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc from = 1.year.ago.beginning_of_year
to = (day_ref - 1.year).end_of_year.utc to = 1.year.ago.end_of_year
end end
end end
return from, to from = from.beginning_of_day
to = to.end_of_day
return from, to
end end
end end

View File

@@ -12,10 +12,13 @@ class Transactions::CreditNotesController < ApplicationController
filter = params[:filter] filter = params[:filter]
customer = params[:customer] customer = params[:customer]
from = params[:from]
to = params[:to]
order_source = params[:order_source] order_source = params[:order_source]
if params[:from].present? && params[:to].present?
from = Time.zone.parse(params[:from]).beginning_of_day
to = Time.zone.parse(params[:to]).end_of_day
end
if filter.nil? && from.nil? && to.nil? && customer.nil? && order_source.nil? if filter.nil? && from.nil? && to.nil? && customer.nil? && order_source.nil?
order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=sales.sale_id GROUP BY so.sale_id)" order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=sales.sale_id GROUP BY so.sale_id)"

View File

@@ -73,54 +73,48 @@ class Transactions::OrderReservationsController < ApplicationController
def get_date_range_from_params def get_date_range_from_params
period_type = params[:period_type] period_type = params[:period_type]
period = params[:period] period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if from.present? && to.present? if params[:from].present? && params[:to].present?
f_date = DateTime.parse(from) from = Time.zone.parse(params[:from])
t_date = DateTime.parse(to) to = Time.zone.parse(params[:to])
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day
to = t_time.end_of_day
else else
case period.to_i case period.to_i
when PERIOD["today"] when PERIOD["today"]
from = day_ref.beginning_of_day.utc from = Time.current
to = day_ref.end_of_day.utc to = Time.current
when PERIOD["yesterday"] when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc from = 1.day.ago
to = (day_ref - 1.day).end_of_day.utc to = 1.day.ago
when PERIOD["this_week"] when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc from = Time.current.beginning_of_week
to = Time.now.utc to = Time.current
when PERIOD["last_week"] when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc from = 1.week.ago.beginning_of_week
to = (day_ref - 7.day).end_of_week.utc to = 1.week.ago.end_of_week
when PERIOD["last_7"] when PERIOD["last_7"]
from = (day_ref - 7.day).utc from = 7.day.ago
to = Time.now.utc to = Time.current
when PERIOD["this_month"] when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc from = Time.current.beginning_of_month
to = Time.now.utc to = Time.current
when PERIOD["last_month"] when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc from = 1.month.ago.beginning_of_month
to = (day_ref - 1.month).end_of_month.utc to = 1.month.ago.end_of_month
when PERIOD["last_30"] when PERIOD["last_30"]
from = (day_ref - 30.day).utc from = 30.day.ago
to = Time.now.utc to = Time.current
when PERIOD["this_year"] when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc from = Time.current.beginning_of_year
to = Time.now.utc to = Time.current
when PERIOD["last_year"] when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc from = 1.year.ago.beginning_of_year
to = (day_ref - 1.year).end_of_year.utc to = 1.year.ago.end_of_year
end end
end end
from = from.beginning_of_day
to = to.end_of_day
return from, to return from, to
end end

View File

@@ -11,6 +11,8 @@ class Transactions::OrdersController < ApplicationController
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
orders = Order.order("order_id desc") orders = Order.order("order_id desc")
else else
from = Time.zone.parse(params[:from]).beginning_of_day
to = Time.zone.parse(params[:to]).end_of_day
orders = Order.search(filter,from,to) orders = Order.search(filter,from,to)
end end

View File

@@ -181,53 +181,47 @@ class Transactions::SalesController < ApplicationController
def get_date_range_from_params def get_date_range_from_params
period_type = params[:period_type] period_type = params[:period_type]
period = params[:period] period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if from.present? && to.present? if params[:from].present? && params[:to].present?
f_date = DateTime.parse(from) from = Time.zone.parse(params[:from])
t_date = DateTime.parse(to) to = Time.zone.parse(params[:to])
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec) else
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec) case period.to_i
from = f_time.beginning_of_day when PERIOD["today"]
to = t_time.end_of_day from = Time.current
else to = Time.current
case period.to_i when PERIOD["yesterday"]
when PERIOD["today"] from = 1.day.ago
from = day_ref.beginning_of_day.utc to = 1.day.ago
to = day_ref.end_of_day.utc when PERIOD["this_week"]
from = Time.current.beginning_of_week
to = Time.current
when PERIOD["last_week"]
from = 1.week.ago.beginning_of_week
to = 1.week.ago.end_of_week
when PERIOD["last_7"]
from = 7.day.ago
to = Time.current
when PERIOD["this_month"]
from = Time.current.beginning_of_month
to = Time.current
when PERIOD["last_month"]
from = 1.month.ago.beginning_of_month
to = 1.month.ago.end_of_month
when PERIOD["last_30"]
from = 30.day.ago
to = Time.current
when PERIOD["this_year"]
from = Time.current.beginning_of_year
to = Time.current
when PERIOD["last_year"]
from = 1.year.ago.beginning_of_year
to = 1.year.ago.end_of_year
end
end
when PERIOD["yesterday"] from = from.beginning_of_day
from = (day_ref - 1.day).beginning_of_day.utc to = to.end_of_day
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to return from, to
end end

View File

@@ -13,6 +13,8 @@ class Transactions::ShiftSalesController < ApplicationController
@shift_sales = ShiftSale.all.order("id desc") @shift_sales = ShiftSale.all.order("id desc")
@shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20)
else else
from = Time.zone.parse(from).beginning_of_day
to = Time.zone.parse(to).end_of_day
shift_sale = ShiftSale.search(filter,from,to) shift_sale = ShiftSale.search(filter,from,to)
if shift_sale.count > 0 if shift_sale.count > 0
@shift_sales = shift_sale @shift_sales = shift_sale

View File

@@ -8,6 +8,8 @@ class Transactions::SurveysController < ApplicationController
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
@surveys = Survey.all @surveys = Survey.all
else else
from = Time.zone.parse(params[:from]).beginning_of_day
to = Time.zone.parse(params[:to]).end_of_day
@surveys = Survey.search(filter,from,to) @surveys = Survey.search(filter,from,to)
end end

View File

@@ -56,7 +56,7 @@ class AssignedOrderItem < ApplicationRecord
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id") left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.order_id = '#{order_id}' AND assigned_order_items.delivery_status = false AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ") .where("assigned_order_items.order_id = '#{order_id}' AND assigned_order_items.delivery_status = false AND assigned_order_items.created_at >= '#{Time.current.beginning_of_day.utc}' ")
.order("assigned_order_items.assigned_order_item_id desc") .order("assigned_order_items.assigned_order_item_id desc")
.group("assigned_order_items.assigned_order_item_id") .group("assigned_order_items.assigned_order_item_id")
return order_item return order_item

View File

@@ -60,7 +60,7 @@ class Booking < ApplicationRecord
end end
scope :active, -> { where('booking_status != ?', 'moved') } scope :active, -> { where('booking_status != ?', 'moved') }
scope :today, -> { where('created_at >= ?', Time.now) } scope :today, -> { where('created_at >= ?', Time.current) }
scope :assign, -> { where(booking_status: 'assign') } scope :assign, -> { where(booking_status: 'assign') }
def self.sync_booking_records(bookings) def self.sync_booking_records(bookings)
@@ -128,9 +128,9 @@ class Booking < ApplicationRecord
end end
if from.present? && to.present? if from.present? && to.present?
booking = Booking.joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") booking = Booking.joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id")
.where("DATE_FORMAT(bookings.created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(bookings.created_at,'%d-%m-%Y') <= ? and NOT bookings.booking_status = 'void' ", from,to) .where("bookings.created_at BETWEEN ? AND ? and NOT bookings.booking_status = 'void' ", from,to)
query = booking.where(keyword) query = booking.where(keyword)
else else
joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id")
.where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") .where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")

View File

@@ -54,22 +54,22 @@ class DiningFacility < ApplicationRecord
lookup_checkout_time = Lookup.collection_of("checkout_alert_time") lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0 free_time_min = 0
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
now = Time.now.utc now = Time.current
lookup_checkout_time.each do |checkout_time| lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-") arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p") start_time = Time.zone.parse(arr_time[0].strip).strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p") end_time = Time.zone.parse(arr_time[1].strip).strftime("%H:%M%p")
if start_time <= now && now <= end_time if start_time <= now && now <= end_time
free_time_min = checkout_time[1].to_i free_time_min = checkout_time[1].to_i
end end
end end
end end
now = Time.now.utc now = Time.current
hr = (now.strftime("%H").to_i).to_int hr = (now.strftime("%H").to_i).to_int
min = (now.strftime("%M").to_i).to_int min = (now.strftime("%M").to_i).to_int
if !booking.checkout_at.nil? if !booking.checkout_at.nil?
checkout_at = booking.checkout_at.utc checkout_at = booking.checkout_at
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
checkout_at_min -= min checkout_at_min -= min
@@ -93,11 +93,11 @@ class DiningFacility < ApplicationRecord
lookup_checkout_time = Lookup.collection_of("checkout_alert_time") lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0 free_time_min = 0
if !lookup_checkout_time.empty? if !lookup_checkout_time.empty?
now = Time.now.utc now = Time.current
lookup_checkout_time.each do |checkout_time| lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-") arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p") start_time = Time.zone.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p") end_time = Time.zone.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time if start_time <= now && now <= end_time
free_time_min = checkout_time[1].to_i free_time_min = checkout_time[1].to_i
end end
@@ -105,11 +105,11 @@ class DiningFacility < ApplicationRecord
end end
bookings.each do |booking| bookings.each do |booking|
now = Time.now.utc now = Time.current
hr = (now.strftime("%H").to_i).to_int hr = (now.strftime("%H").to_i).to_int
min = (now.strftime("%M").to_i).to_int min = (now.strftime("%M").to_i).to_int
if !booking.checkout_at.nil? if !booking.checkout_at.nil?
checkout_at = booking.checkout_at.utc checkout_at = booking.checkout_at
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
checkout_at_min -= min checkout_at_min -= min
@@ -155,8 +155,8 @@ class DiningFacility < ApplicationRecord
def check_time(time, booking = nil, type) def check_time(time, booking = nil, type)
status = true status = true
today = Time.now.utc.strftime("%Y-%m-%d %H:%M") today = Time.current.utc.strftime("%Y-%m-%d %H:%M")
check_time = time.strftime("%Y-%m-%d %H:%M") check_time = time.utc.strftime("%Y-%m-%d %H:%M")
if type.downcase == "checkin" if type.downcase == "checkin"
if check_time < today if check_time < today
status = false status = false

View File

@@ -182,33 +182,33 @@ class License
def expired? def expired?
if renewal_date_str = read_license("renewable_date") if renewal_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str) renewal_date = Time.zone.parse(renewal_date_str)
renewal_date < Date.today renewal_date < Date.current
end end
end end
def expire_in?(days) def expire_in?(days)
if renewal_date_str = read_license("renewable_date") if renewal_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str) renewal_date = Time.zone.parse(renewal_date_str)
renewal_date < days.days.from_now renewal_date < days.days.from_now
end end
end end
def days_to_expire def days_to_expire
if renewal_date_str = read_license("renewable_date") if renewal_date_str = read_license("renewable_date")
Date.today - DateTime.parse(renewal_date_str).to_date Date.current - Time.zone.parse(renewal_date_str).to_date
end end
end end
# Check License expired date from PROVISION SERVER # Check License expired date from PROVISION SERVER
def check_expired(renewal_date_str) def check_expired(renewal_date_str)
expired_date_str = read_license("renewable_date") expired_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str) renewal_date = Time.zone.parse(renewal_date_str)
if(renewal_date_str != expired_date_str) if(renewal_date_str != expired_date_str)
update_license("renewable_date", renewal_date_str) update_license("renewable_date", renewal_date_str)
end end
if (renewal_date < Date.today) if (renewal_date < Date.current)
return true return true
else else
return false return false

View File

@@ -40,9 +40,9 @@ class MenuCategory < ApplicationRecord
def valid_time def valid_time
menu = self.menu menu = self.menu
from_t = Time.parse(menu.valid_time_from.strftime("%H:%M:%S")) from_t = Time.zone.parse(menu.valid_time_from.strftime("%H:%M:%S"))
to_t = Time.parse(menu.valid_time_to.strftime("%H:%M:%S")) to_t = Time.zone.parse(menu.valid_time_to.strftime("%H:%M:%S"))
current_t = Time.parse(Time.now.strftime("%H:%M:%S")) current_t = Time.zone.parse(Time.current.strftime("%H:%M:%S"))
from = from_t.hour * 3600 + from_t.min*60 + from_t.sec from = from_t.hour * 3600 + from_t.min*60 + from_t.sec
to = to_t.hour * 3600 + to_t.min* 60 + to_t.sec to = to_t.hour * 3600 + to_t.min* 60 + to_t.sec
@@ -73,7 +73,7 @@ class MenuCategory < ApplicationRecord
end end
end end
day = Date.today.wday day = Date.current.wday
dayresult = menu.valid_days.include?(day.to_s) dayresult = menu.valid_days.include?(day.to_s)

View File

@@ -29,12 +29,12 @@ class Order < ApplicationRecord
#add extra time #add extra time
if self.is_extra_time && self.extra_time if self.is_extra_time && self.extra_time
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking", booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkout_at => Time.now.utc + self.extra_time.to_i, :checkin_at => Time.current, :checkout_at => Time.current + self.extra_time.to_i,
:checkin_by => self.employee_name, :checkin_by => self.employee_name,
:booking_status => "assign" }) :booking_status => "assign" })
else else
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking", booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name, :checkin_at => Time.current, :checkin_by => self.employee_name,
:booking_status => "assign" }) :booking_status => "assign" })
end end
#end extra time #end extra time
@@ -84,7 +84,7 @@ class Order < ApplicationRecord
if self.new_booking if self.new_booking
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name, :checkin_at => Time.current, :checkin_by => self.employee_name,
:booking_status => "assign" }) :booking_status => "assign" })
table = DiningFacility.find(self.table_id) table = DiningFacility.find(self.table_id)
table.status = "occupied" table.status = "occupied"
@@ -316,8 +316,8 @@ class Order < ApplicationRecord
#Origami: Cashier : to view orders #Origami: Cashier : to view orders
def self.get_orders def self.get_orders
from = Time.now.beginning_of_day.utc from = Time.current.beginning_of_day.utc
to = Time.now.end_of_day.utc to = Time.current.end_of_day.utc
orders=Booking.select("sales.receipt_no, sales.sale_status as sale_status, orders.status as order_status, orders=Booking.select("sales.receipt_no, sales.sale_status as sale_status, orders.status as order_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id, orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,orders.customer_id as customer_id, bookings.booking_id,orders.customer_id as customer_id,
@@ -353,7 +353,7 @@ class Order < ApplicationRecord
end end
if from.present? && to.present? if from.present? && to.present?
order = Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to) order = Order.where("date BETWEEN ? AND ?", from, to)
query = order.where(keyword) query = order.where(keyword)
else else
where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%") where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%")
@@ -449,7 +449,7 @@ class Order < ApplicationRecord
end end
def set_order_date def set_order_date
self.date = Time.now.utc self.date = Time.current
end end
def self.sync_order_records(orders) def self.sync_order_records(orders)

View File

@@ -32,7 +32,7 @@ class OrderReservation < ApplicationRecord
customer.contact_no = params[:contact_no] ? params[:contact_no] : '' customer.contact_no = params[:contact_no] ? params[:contact_no] : ''
customer.gender = gender customer.gender = gender
customer.address = params[:address] ? params[:address] : '' customer.address = params[:address] ? params[:address] : ''
customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : '' customer.date_of_birth = params[:date_of_birth] ? Time.zone.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : ''
customer.membership_id = params[:membership_id] customer.membership_id = params[:membership_id]
customer.customer_type = "Doemal" customer.customer_type = "Doemal"
customer.tax_profiles = ["2"] customer.tax_profiles = ["2"]
@@ -426,7 +426,7 @@ class OrderReservation < ApplicationRecord
else else
shop_code = '' shop_code = ''
end end
order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.now.utc}'") order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.current.utc}'")
if order_reservation.length > 0 if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud' if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain from = request.subdomain + "." + request.domain
@@ -444,7 +444,7 @@ class OrderReservation < ApplicationRecord
else else
shop_code = '' shop_code = ''
end end
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.now.utc}'") order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.current.utc}'")
if order_reservation.length > 0 if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud' if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain from = request.subdomain + "." + request.domain

View File

@@ -12,13 +12,13 @@ class Promotion < ApplicationRecord
PROMO_TYPE4 = "Percentage" PROMO_TYPE4 = "Percentage"
def is_promo_day def is_promo_day
promo_day.include? Date.today.wday.to_s promo_day.include? Date.current.wday.to_s
end end
def self.promo_activate(saleObj) def self.promo_activate(saleObj)
current_day = Time.now.strftime("%Y-%m-%d") current_day = Time.current.strftime("%Y-%m-%d")
current_time = Time.now.strftime('%H:%M:%S') current_time = Time.current.strftime('%H:%M:%S')
day = Date.today.wday day = Date.current.wday
promoList = is_between_promo_datetime(current_day,current_time) promoList = is_between_promo_datetime(current_day,current_time)
promoList.each do |promo| promoList.each do |promo|

View File

@@ -36,7 +36,7 @@ class Sale < ApplicationRecord
scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) } scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) }
scope :sale_payments_with_audit_except_void_between, -> (from, to) do scope :sale_payments_with_audit_except_void_between, -> (from, to) do
joins(sanitize_sql_array(["LEFT JOIN sale_payments ON sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to])) joins(sanitize_sql_array(["LEFT JOIN sale_payments ON sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from.utc, to.utc]))
.joins("LEFT JOIN sale_audits ON sale_audits.sale_id = sale_payments.sale_id AND SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id") .joins("LEFT JOIN sale_audits ON sale_audits.sale_id = sale_payments.sale_id AND SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id")
end end
@@ -91,7 +91,7 @@ class Sale < ApplicationRecord
def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, in_duties_count = 0) def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, in_duties_count = 0)
Sale.transaction do Sale.transaction do
if booking if booking
current = Time.now current = Time.current
#get all order attached to this booking and combine into 1 invoice #get all order attached to this booking and combine into 1 invoice
sale = booking.sale || booking.build_sale( sale = booking.sale || booking.build_sale(
{ {
@@ -735,9 +735,9 @@ class Sale < ApplicationRecord
if from.present? && to.present? if from.present? && to.present?
if shift.blank? if shift.blank?
sale = Sale.where("DATE_FORMAT(receipt_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(receipt_date,'%Y-%m-%d') <= ? and NOT sale_status = 'new' ", from,to) sale = Sale.where("receipt_date BETWEEN ? AND ? and NOT sale_status = 'new'", from,to)
else else
sale = Sale.where("(DATE_FORMAT(receipt_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(receipt_date,'%Y-%m-%d') <= ? and NOT sale_status = 'new') and shift_sale_id = '#{shift.id}'", from,to) sale = Sale.where("receipt_date BETWEEN ? AND ? and NOT sale_status = 'new' and shift_sale_id = '#{shift.id}'", from,to)
end end
query = sale.where(keyword) query = sale.where(keyword)
else else
@@ -1588,7 +1588,7 @@ end
if !from.nil? && !to.nil? if !from.nil? && !to.nil?
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1615,7 +1615,7 @@ end
if !from.nil? && !to.nil? if !from.nil? && !to.nil?
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1652,7 +1652,7 @@ end
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1673,7 +1673,7 @@ end
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1698,7 +1698,7 @@ end
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
query = query.merge(Sale.receipt_date_between(from, to)) query = query.merge(Sale.receipt_date_between(from, to))
else else
query = query.merge(Sale.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)) query = query.merge(Sale.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day))
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1719,7 +1719,7 @@ end
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1741,7 +1741,7 @@ end
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1772,7 +1772,7 @@ end
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1826,7 +1826,7 @@ end
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1848,7 +1848,7 @@ end
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1916,7 +1916,7 @@ end
if (!from.nil? && !to.nil?) if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1938,7 +1938,7 @@ end
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1960,7 +1960,7 @@ end
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -1983,7 +1983,7 @@ end
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
@@ -2060,7 +2060,7 @@ end
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
.joins("join orders as orders on orders.order_id = sale_orders.order_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id")
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}") query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}")
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
.group("sales.sale_id") .group("sales.sale_id")
end end
@@ -2138,7 +2138,7 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil)
if !from.nil? && !to.nil? if !from.nil? && !to.nil?
query = query.receipt_date_between(from, to) query = query.receipt_date_between(from, to)
else else
query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) query = query.receipt_date_between(Time.current.beginning_of_day, Time.current.end_of_day)
end end
if !shift.nil? if !shift.nil?
@@ -2162,8 +2162,8 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
receipt_date = "sales.receipt_date between '#{from}' and '#{to}'" receipt_date = "sales.receipt_date between '#{from}' and '#{to}'"
query = self.get_hourly_item_query(type,filter,true) query = self.get_hourly_item_query(type,filter,true)
else else
start_time = Time.parse(start_time).utc start_time = Time.zone.parse(start_time).utc
end_time = Time.parse(end_time).utc end_time = Time.zone.parse(end_time).utc
receipt_date = "sales.receipt_date between '#{start_time}' and '#{end_time}'" receipt_date = "sales.receipt_date between '#{start_time}' and '#{end_time}'"
query = self.get_hourly_item_query(type,filter,false) query = self.get_hourly_item_query(type,filter,false)
end end

View File

@@ -223,7 +223,7 @@ class ShiftSale < ApplicationRecord
end end
if from.present? && to.present? if from.present? && to.present?
booking = ShiftSale.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to) booking = ShiftSale.where("created_at BETWEEN ? AND ? and NOT booking_status = 'void' ", from, to)
query = booking.where(keyword) query = booking.where(keyword)
else else
where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")

View File

@@ -4,8 +4,8 @@ class StockCheck < ApplicationRecord
def create(user, reason, item_list) def create(user, reason, item_list)
self.reason = reason self.reason = reason
self.check_by = user.id self.check_by = user.id
self.check_start = Time.now self.check_start = Time.current
self.check_end = Time.now self.check_end = Time.current
save save
item_list.each do |item| item_list.each do |item|
stockItem = StockCheckItem.new stockItem = StockCheckItem.new

View File

@@ -8,7 +8,7 @@ class Survey < ApplicationRecord
end end
if from.present? && to.present? if from.present? && to.present?
survey = Survey.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ?", from,to) survey = Survey.where("created_at BETWEEN ? AND ?", from, to)
query = survey.where(keyword) query = survey.where(keyword)
else else
where("dining_name LIKE ?", "%#{filter}%") where("dining_name LIKE ?", "%#{filter}%")

View File

@@ -13,8 +13,8 @@ if @zones
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
if !current_booking.nil? if !current_booking.nil?
json.current_booking current_booking.booking_id json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") json.checkin_at current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") : "" json.checkout_at current_booking.checkout_at ? current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S") : ""
else else
json.current_booking "" json.current_booking ""
json.checkin_at "" json.checkin_at ""
@@ -32,8 +32,8 @@ if @zones
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
if !current_booking.nil? if !current_booking.nil?
json.current_booking current_booking.booking_id json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") json.checkin_at current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") : "" json.checkout_at current_booking.checkout_at ? current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S") : ""
else else
json.current_booking "" json.current_booking ""
json.checkin_at "" json.checkin_at ""
@@ -53,8 +53,8 @@ else #list all tables and rooms with out zones
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
if !current_booking.nil? if !current_booking.nil?
json.current_booking current_booking.booking_id json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") json.checkin_at current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") : "" json.checkout_at current_booking.checkout_at ? current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S") : ""
else else
json.current_booking "" json.current_booking ""
json.checkin_at "" json.checkin_at ""
@@ -72,8 +72,8 @@ else #list all tables and rooms with out zones
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
if !current_booking.nil? if !current_booking.nil?
json.current_booking current_booking.booking_id json.current_booking current_booking.booking_id
json.checkin_at Time.parse(current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") json.checkin_at current_booking.checkin_at.strftime("%Y-%m-%d %H:%M:%S")
json.checkout_at current_booking.checkout_at ? Time.parse(current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S")).strftime("%Y-%m-%d %H:%M:%S") : "" json.checkout_at current_booking.checkout_at ? current_booking.checkout_at.strftime("%Y-%m-%d %H:%M:%S") : ""
else else
json.current_booking "" json.current_booking ""
json.checkin_at "" json.checkin_at ""

View File

@@ -70,13 +70,13 @@
from_date = @from.strftime("%d-%m-%Y") from_date = @from.strftime("%d-%m-%Y")
from_time = @from.strftime("%H:%M") if @from.strftime("%H:%M") != "00:00" from_time = @from.strftime("%H:%M") if @from.strftime("%H:%M") != "00:00"
else else
from_date = Time.now.strftime('%d-%m-%Y') from_date = Time.current.strftime('%d-%m-%Y')
end end
if !@to.nil? && @to != "" if !@to.nil? && @to != ""
to_date = @to.strftime("%d-%m-%Y") to_date = @to.strftime("%d-%m-%Y")
to_time = @to.strftime("%H:%M") if @to.strftime("%H:%M") != "23:59" to_time = @to.strftime("%H:%M") if @to.strftime("%H:%M") != "23:59"
else else
to_date = Time.now.strftime('%d-%m-%Y') to_date = Time.current.strftime('%d-%m-%Y')
end end
%> %>
<div class="col-lg-3 col-md-3 col-sm-3 col-mbl-view mbl-style"> <div class="col-lg-3 col-md-3 col-sm-3 col-mbl-view mbl-style">

View File

@@ -477,7 +477,7 @@
<!-- Footer --> <!-- Footer -->
<div class="legal"> <div class="legal">
<div class="copyright"> <div class="copyright">
&copy; <%= Time.now.strftime("%Y") %> <a href="javascript:void(0);">Code2Lab</a>. &copy; <%= Time.current.strftime("%Y") %> <a href="javascript:void(0);">Code2Lab</a>.
</div> </div>
<div class="version"> <div class="version">
<b>Version: </b> 1.0.1 <b>Version: </b> 1.0.1

View File

@@ -38,7 +38,7 @@
<%= qsi.station_name %> <%= qsi.station_name %>
<% if @filter.nil? %> <% if @filter.nil? %>
<span class="badge bg-blue-grey oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>" id="completed_count"> <span class="badge bg-blue-grey oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>" id="completed_count">
<!-- <span class="badge badge-pill badge-default oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>"> --> <%= qsi.assigned_order_items.where("delivery_status=0 AND created_at >= '#{Time.now.beginning_of_day.utc}'").count %> <!-- <span class="badge badge-pill badge-default oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>"> --> <%= qsi.assigned_order_items.where("delivery_status=0 AND created_at >= '#{Time.current.beginning_of_day.utc}'").count %>
</span> </span>
<%else%> <%else%>
<span class="label-count badge bg-blue-grey" data-id="<%= qsi.id %>"> <span class="label-count badge bg-blue-grey" data-id="<%= qsi.id %>">

View File

@@ -1,5 +1,5 @@
<% renewable_date = current_license.read_license("renewable_date") %> <% renewable_date = current_license.read_license("renewable_date") %>
<% date_count = (renewable_date.to_date - Date.today).to_i %> <% date_count = (renewable_date.to_date - Date.current).to_i %>
<% day = pluralize( date_count, 'day' )%> <% day = pluralize( date_count, 'day' )%>
<% if @license_status == 0 %> <% if @license_status == 0 %>

View File

@@ -2,7 +2,7 @@
<% license_status = current_license.detail_with_local_file %> <% license_status = current_license.detail_with_local_file %>
<% renewable_date = current_license.read_license("renewable_date") %> <% renewable_date = current_license.read_license("renewable_date") %>
<% date_count = (renewable_date.to_date - Date.today).to_i %> <% date_count = (renewable_date.to_date - Date.current).to_i %>
<% day = pluralize( date_count, 'day' )%> <% day = pluralize( date_count, 'day' )%>
<% if license_status == 0 <% if license_status == 0

View File

@@ -35,7 +35,7 @@ Rails.application.configure do
config.active_support.deprecation = :log config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations. # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load config.active_record.migration_error = true
# Debug mode disables concatenation and preprocessing of assets. # Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large # This option may cause significant delays in view rendering with a large