Merge branch 'ui_ux_changes' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes

This commit is contained in:
phyusin
2018-06-18 17:35:55 +06:30
6 changed files with 258 additions and 1 deletions

View File

@@ -26,6 +26,31 @@ class Api::BillController < Api::ApiController
end
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
#bill channel
check_in_out_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all
unique_code="CheckInOutPdf"
if !check_in_out_pdf.empty?
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'CheckInOutPdf'
unique_code="CheckInOutPdf"
end
end
end
end
booking = Booking.find_by_booking_id(booking.booking_id)
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_check_in_out(print_settings, booking, table)
from = getCloudDomain #get sub domain in cloud mode
end
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, "cashier")
@@ -83,6 +108,15 @@ class Api::BillController < Api::ApiController
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
end
return from
end
private
def bill_params

View File

@@ -81,6 +81,30 @@ class Api::CheckInProcessController < Api::ApiController
else
render :json => { :status => true }
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
check_in_out_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all
unique_code="CheckInOutPdf"
if !check_in_out_pdf.empty?
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'CheckInOutPdf'
unique_code="CheckInOutPdf"
end
end
end
end
booking = Booking.find_by_booking_id(booking.booking_id)
table = DiningFacility.find(params[:dining_id])
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_check_in_out(print_settings, booking, table)
from = getCloudDomain #get sub domain in cloud mode
end
else
render :json => { :status => true }
end
@@ -121,6 +145,16 @@ class Api::CheckInProcessController < Api::ApiController
end
end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
end
return from
end
private
def check_in_process_params
params.permit(:dining_id,:booking_id,:time)

View File

@@ -29,6 +29,29 @@ class Origami::CheckInProcessController < BaseOrigamiController
: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 })
@booking.save!
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
check_in_out_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all
unique_code="CheckInOutPdf"
if !check_in_out_pdf.empty?
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'CheckInOutPdf'
unique_code="CheckInOutPdf"
end
end
end
end
booking = Booking.find_by_booking_id(@booking.booking_id)
table = DiningFacility.find(params[:dining_id])
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_check_in_out(print_settings, booking, table)
from = getCloudDomain #get sub domain in cloud mode
end
end
respond = {:status => 'ok'}
respond_to do |format|
@@ -36,4 +59,14 @@ class Origami::CheckInProcessController < BaseOrigamiController
end
end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
end
return from
end
end

View File

@@ -38,16 +38,43 @@ class Origami::RequestBillsController < ApplicationController
# Promotion Activation
Promotion.promo_activate(@sale)
#bill channel
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "bill_channel",table: table, from: from
if order.source == "quick_service"
result = {:status=> @status, :data => @sale.sale_id }
render :json => result.to_json
else
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
#bill channel
check_in_out_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
printer = PrintSetting.all
unique_code="CheckInOutPdf"
if !check_in_out_pdf.empty?
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'CheckInOutPdf'
unique_code="CheckInOutPdf"
end
end
end
end
booking = Booking.find_by_booking_id(bk_order.booking_id)
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_check_in_out(print_settings, booking, table)
from = getCloudDomain #get sub domain in cloud mode
end
end
else
@status = false
@@ -76,5 +103,15 @@ class Origami::RequestBillsController < ApplicationController
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
end
#get cloud domain
def getCloudDomain
from = ""
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
end
return from
end
end

View File

@@ -296,6 +296,40 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
left join menu_items as item ON item.item_code = order_items.item_code")
.where("b.booking_id = '#{ id }'")
end
end
# Check in-out time
def print_check_in_out(print_settings,booking, table)
#Use CUPS service
#Generate PDF
#Print
# Must be one print
if print_settings.print_copies == 0
print_settings.print_copies = 1
print_settings.save!
end
sale_id = booking.sale_id
filename = "tmp/check_in_out_#{sale_id}" + ".pdf"
pdf = CheckInOutPdf.new(print_settings,booking, table)
print_setting = PrintSetting.all
# if order_item[0].price != 0
if !print_setting.empty?
print_setting.each do |print_settings|
if print_settings.unique_code == 'CheckInOutPdf'
pdf = CheckInOutPdf.new(print_settings,booking, table)
end
end
end
pdf.render_file filename
print_settings.print_copies = 1
print_settings.save!
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print(filename, print_settings.printer_name)
end
end
end

View File

@@ -0,0 +1,85 @@
class CheckInOutPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:order_no_font_size, :item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,booking, table)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.header_font_size = print_settings.header_font_size.to_i
self.item_font_size = print_settings.item_font_size.to_i
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
self.order_no_font_size = 8
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
# db font setup
if print_settings.font != ""
font_families.update("#{print_settings.font}" => {
:normal => "public/fonts/#{print_settings.font}.ttf",
:italic => "public/fonts/#{print_settings.font}.ttf",
:bold => "public/fonts/#{print_settings.font}.ttf",
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
})
font "#{print_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
if table.type == "Table"
text "Table - #{table.name}", :size => self.header_font_size,:align => :center, :left_margin => -20
elsif table.type == "Room"
text "Room - #{table.name}", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 3
#check_in_out_info
check_in_out_info(booking.checkin_by)
# check_time
check_time(booking.checkin_at,booking.checkout_at)
end
# Write Check in-out Information to PDF
def check_in_out_info(checkin_by)
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "CheckBy : #{checkin_by} ", :size => self.order_no_font_size,:align => :left
end
stroke_horizontal_rule
move_down 5
end
# Write Check time to PDF
def check_time(checkin_at, checkout_at)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "Check In : #{checkin_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "Check Out : #{checkout_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
end
end