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

This commit is contained in:
Aung Myo
2017-12-14 17:10:40 +06:30
6 changed files with 59 additions and 44 deletions

View File

@@ -6,20 +6,22 @@ App.order = App.cable.subscriptions.create('CheckinChannel', {
disconnected: function() {}, disconnected: function() {},
received: function(data) { received: function(data) {
if((data.table != undefined) && (data.table.length > 0)){
$.each(data.table,function(key,value){ $.each(data.table,function(key,value){
// console.log(value.table_id);
if($('.table_'+value.table_id).hasClass('blue')){ if($('.table_'+value.table_id).hasClass('blue')){
$('.table_'+value.table_id).removeClass('blue'); $('.table_'+value.table_id).removeClass('blue');
$('.table_'+value.table_id).addClass('orange'); $('.table_'+value.table_id).addClass('orange');
} }
else if($('.table_'+value.table_id).hasClass('red')){ else if($('.table_'+value.table_id).hasClass('red')){
$('.table_'+value.table_id).removeClass('red'); $('.table_'+value.table_id).removeClass('red');
$('.table_'+value.table_id).addClass('orange');
}
else {
$('.table_'+value.table_id).removeClass('green');
$('.table_'+value.table_id).addClass('orange'); $('.table_'+value.table_id).addClass('orange');
} }
$('.new_text_'+value.table_id).removeClass('hide'); $('.new_text_'+value.table_id).removeClass('hide');
}); });
}
} }
}); });

View File

@@ -22,20 +22,16 @@ class Api::CheckInProcessController < Api::ApiController
if params[:dining_id] if params[:dining_id]
dining_facility = DiningFacility.find(params[:dining_id]) dining_facility = DiningFacility.find(params[:dining_id])
if dining_facility.status == "available" if dining_facility.status == "available"
dining_charge = DiningCharge.select('charge_type','charge_block') lookup_checkout_time = Lookup.collection_of("checkout_time")
.where('dining_facility_id = ?',params[:dining_id])
.first()
checkout_at = Time.now.utc checkout_at = Time.now.utc
if !dining_charge.nil? if !lookup_checkout_time.nil?
hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int if lookup_checkout_time[0][0] == 'hr'
min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
# if dining_charge.charge_type == 'hr' else
checkout_at = checkout_at + hr.hour + min.minutes checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
# else end
# end
end end
dining_facility.status = "occupied" dining_facility.status = "occupied"

View File

@@ -1,20 +1,15 @@
class Origami::CheckInProcessController < BaseOrigamiController class Origami::CheckInProcessController < BaseOrigamiController
def check_in_process def check_in_process
dining_charge = DiningCharge.select('charge_type','charge_block') lookup_checkout_time = Lookup.collection_of("checkout_time")
.where('dining_facility_id = ?',params[:dining_id])
.first()
checkout_at = Time.now.utc checkout_at = Time.now.utc
if !dining_charge.nil? if !lookup_checkout_time.nil?
hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int if lookup_checkout_time[0][0] == 'hr'
min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
# if dining_charge.charge_type == 'hr' else
checkout_at = checkout_at + hr.hour + min.minutes checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
# else end
# end
end end
@dining_facility = DiningFacility.find(params[:dining_id]) @dining_facility = DiningFacility.find(params[:dining_id])
@dining_facility.status = "occupied" @dining_facility.status = "occupied"

View File

@@ -3,8 +3,10 @@ class CheckinJob < ApplicationJob
def perform() def perform()
table = DiningFacility.get_checkin_booking table = DiningFacility.get_checkin_booking
if table.length > 0
ActionCable.server.broadcast "checkin_channel",table: table ActionCable.server.broadcast "checkin_channel",table: table
end end
end
end end

View File

@@ -78,6 +78,16 @@ class DiningFacility < ApplicationRecord
def get_checkout_booking def get_checkout_booking
booking = self.get_current_checkout_booking booking = self.get_current_checkout_booking
if booking if booking
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
free_time_min = (lookup_checkout_time[0][1]).to_i
else
free_time_min = 15
end
end
now = Time.now.utc now = Time.now.utc
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
@@ -88,7 +98,7 @@ class DiningFacility < ApplicationRecord
checkout_at_min -= min checkout_at_min -= min
if (checkout_at_hr < hr) if (checkout_at_hr < hr)
return booking return booking
elsif (checkout_at_hr == hr && checkout_at_min <= 15) elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
return booking return booking
else else
return nil return nil
@@ -103,18 +113,28 @@ class DiningFacility < ApplicationRecord
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null") bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
arr_booking = Array.new arr_booking = Array.new
if bookings if bookings
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
free_time_min = (lookup_checkout_time[0][1]).to_i
else
free_time_min = 15
end
end
bookings.each do |booking| bookings.each do |booking|
now = Time.now.utc.getlocal now = Time.now.utc
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.getlocal checkout_at = booking.checkout_at.utc
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
if (checkout_at_hr < hr) if (checkout_at_hr < hr)
arr_booking.push({'table_id' => booking.dining_facility_id}) arr_booking.push({'table_id' => booking.dining_facility_id})
elsif (checkout_at_hr == hr && checkout_at_min <= 15) elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
arr_booking.push({'table_id' => booking.dining_facility_id}) arr_booking.push({'table_id' => booking.dining_facility_id})
end end
end end

View File

@@ -1076,7 +1076,7 @@ end
end end
def self.total_other_customer(today) def self.total_other_customer(today)
query = Sale.select("count(distinct sales.customer_id) as total_cus") query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id") .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
.first() .first()