update checking booking
This commit is contained in:
14
app/assets/javascripts/channels/check_in_booking.js
Normal file
14
app/assets/javascripts/channels/check_in_booking.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', {
|
||||||
|
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||||
|
|
||||||
|
connected: function() {},
|
||||||
|
|
||||||
|
disconnected: function() {},
|
||||||
|
|
||||||
|
received: function(data) {
|
||||||
|
$('.table_'+data.table.id).removeClass('green');
|
||||||
|
$('.table_'+data.table.id).addClass('orange');
|
||||||
|
$('.new_text_'+data.table.id).removeClass('hide')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
10
app/channels/check_in_booking_channel.rb
Normal file
10
app/channels/check_in_booking_channel.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class CheckInBookingChannel < ApplicationCable::Channel
|
||||||
|
def subscribed
|
||||||
|
stream_from "check_in_booking_channel"
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribed
|
||||||
|
stop_all_streams
|
||||||
|
# Any cleanup needed when channel is unsubscribed
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -5,8 +5,12 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
dining_facility = DiningFacility.find(params[:dining_id])
|
dining_facility = DiningFacility.find(params[:dining_id])
|
||||||
booking = dining_facility.get_current_checkout_booking
|
booking = dining_facility.get_current_checkout_booking
|
||||||
if !booking.nil?
|
if !booking.nil?
|
||||||
|
|
||||||
|
DiningFacility.check_in_booking(params[:dining_id])
|
||||||
|
|
||||||
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||||
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||||
|
|
||||||
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time }
|
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time }
|
||||||
else
|
else
|
||||||
render :json => { :status => false, :error_message => "No current booking!" }
|
render :json => { :status => false, :error_message => "No current booking!" }
|
||||||
|
|||||||
9
app/jobs/check_in_booking_job.rb
Normal file
9
app/jobs/check_in_booking_job.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class CheckInBookingJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(table)
|
||||||
|
ActionCable.server.broadcast "check_in_booking_channel",table: table
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -122,4 +122,11 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
return arr_booking
|
return arr_booking
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#send order items and send to order queue
|
||||||
|
def self.check_in_booking(table_id)
|
||||||
|
table = DiningFacility.find(table_id)
|
||||||
|
#Send to background job for processing
|
||||||
|
CheckInBookingJob.perform_later(table)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
5
spec/jobs/check_in_booking_job_spec.rb
Normal file
5
spec/jobs/check_in_booking_job_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe CheckInBookingJob, type: :job do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user