update checking booking

This commit is contained in:
Aung Myo
2017-12-14 17:10:05 +06:30
parent fc45198542
commit 035d0851ee
6 changed files with 49 additions and 0 deletions

View 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')
}
});

View 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

View File

@@ -5,8 +5,12 @@ class Api::CheckInProcessController < Api::ApiController
dining_facility = DiningFacility.find(params[:dining_id])
booking = dining_facility.get_current_checkout_booking
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_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 }
else
render :json => { :status => false, :error_message => "No current booking!" }

View 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

View File

@@ -122,4 +122,11 @@ class DiningFacility < ApplicationRecord
end
return arr_booking
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

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CheckInBookingJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end