Use ActsAsTenant as Multi-tenancy for shops See below files: - app/controllers/concern/multi_tenancy.rb - app/models/application_record.rb - app/models/shop.rb An initializer can be created to control option in ActsAsTenant. config/initializers/acts_as_tenant.rb require 'acts_as_tenant/sidekiq' ActsAsTenant.configure do |config| config.require_tenant = false # true end more details: https://github.com/ErwinM/acts_as_tenant
35 lines
1.2 KiB
Ruby
35 lines
1.2 KiB
Ruby
class Api::CallWaitersController < ActionController::API
|
|
|
|
#List all active customers by name
|
|
def index
|
|
@table_id = params[:dining_id]
|
|
@time = params[:time]
|
|
@table = DiningFacility.find(@table_id)
|
|
shift_ids = []
|
|
#for multiple zone with terminal
|
|
multiple_zone = CashierTerminalByZone.where("zone_id = #{@table.zone_id}")
|
|
multiple_zone.each do |zone|
|
|
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first
|
|
if !shift.nil?
|
|
shift_ids.push(shift.id)
|
|
end
|
|
end
|
|
|
|
# CallWaiterJob.perform_later(@table,@time)
|
|
if ENV["SERVER_MODE"] == 'cloud'
|
|
from = request.subdomain + "." + request.domain
|
|
else
|
|
from = ""
|
|
end
|
|
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from, shift_ids: shift_ids
|
|
# get printer info
|
|
@shop = Shop.current_shop
|
|
unique_code = "CallWaiterPdf"
|
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
|
printer.print_call_waiter(print_settings,@table,@time,@shop)
|
|
end
|
|
|
|
|
|
end
|