update for addorder and printer
This commit is contained in:
@@ -131,6 +131,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Order.transaction do
|
||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = params[:order_source]
|
@order.source = params[:order_source]
|
||||||
@order.order_type = params[:order_type]
|
@order.order_type = params[:order_type]
|
||||||
@@ -187,6 +188,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# render json for http status code
|
# render json for http status code
|
||||||
def return_json_status_with_code(code, msg)
|
def return_json_status_with_code(code, msg)
|
||||||
@@ -234,15 +236,9 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
if ENV["SERVER_MODE"] != 'cloud'
|
||||||
cup_status = `#{"sudo service cups status"}`
|
if Printer::PrinterWorker.printers.blank?
|
||||||
if !check_cup_status(cup_status)
|
|
||||||
cup_start = `#{"sudo service cups start"}`
|
|
||||||
cup_status = `#{"sudo service cups status"}`
|
|
||||||
if !check_cup_status(cup_status)
|
|
||||||
from = ''
|
|
||||||
msg = 'Print Error ! Please contact to service'
|
msg = 'Print Error ! Please contact to service'
|
||||||
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: from
|
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,38 +10,18 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
member_info = nil
|
member_info = nil
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
booking = Booking.find_by_sale_id(sale_id)
|
booking = sale_data.booking
|
||||||
# if bookings.count > 1
|
|
||||||
# # for Multiple Booking
|
if current_user.role == 'cashier'
|
||||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
cashier_terminal = shift.cashier_terminal
|
||||||
# else
|
elsif booking.dining_facility_id
|
||||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
cashier_terminal = booking.dining_facility.cashier_terminal
|
||||||
# end
|
|
||||||
shift = ShiftSale.current_open_shift(current_user.id)
|
|
||||||
if !shift.nil?
|
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
|
||||||
else
|
else
|
||||||
if booking.dining_facility_id.to_i > 0
|
cashier_terminal = sale_data.shift_sale.cashier_terminal
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
|
||||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
|
||||||
else
|
|
||||||
shift = ShiftSale.find(sale_data.shift_sale_id)
|
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#shop detail
|
customer = sale_data.customer
|
||||||
## shop_detail = Shop.current_shop
|
|
||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
|
||||||
customer = Customer.find(sale_data.customer_id)
|
|
||||||
# rounding adjustment
|
|
||||||
if shop_detail.is_rounding_adj
|
|
||||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
|
||||||
rounding_adj = new_total - sale_data.grand_total
|
|
||||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
|
||||||
end
|
|
||||||
#end rounding adjustment
|
|
||||||
#record for sale audit
|
#record for sale audit
|
||||||
action_by = current_user.name
|
action_by = current_user.name
|
||||||
type = "FIRST_BILL"
|
type = "FIRST_BILL"
|
||||||
@@ -113,21 +93,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
if(Sale.exists?(sale_id))
|
if(Sale.exists?(sale_id))
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||||
#shop_detail = Shop.current_shop
|
|
||||||
# rounding adjustment
|
|
||||||
if !path.include? ("credit_payment")
|
|
||||||
if shop_detail.is_rounding_adj
|
|
||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
|
||||||
rounding_adj = new_total - saleObj.grand_total
|
|
||||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
#end rounding adjustment
|
|
||||||
|
|
||||||
# if pay_from = 'kbzpay'
|
|
||||||
# salePayment = SalePayment.find(sale_payment_id)
|
|
||||||
# salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid')
|
|
||||||
# else
|
|
||||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||||
if is_kbz == 'false'
|
if is_kbz == 'false'
|
||||||
Rails.logger.info '################ CASH PAYMENT #################'
|
Rails.logger.info '################ CASH PAYMENT #################'
|
||||||
@@ -141,14 +107,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
# end
|
|
||||||
|
|
||||||
if !path.include? ("credit_payment")
|
if !path.include? ("credit_payment")
|
||||||
rebate_amount = nil
|
rebate_amount = nil
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
bookings = saleObj.bookings[0]
|
bookings = saleObj.booking
|
||||||
|
|
||||||
shift = ShiftSale.current_open_shift(current_user.id)
|
shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
if !shift.nil?
|
if !shift.nil?
|
||||||
@@ -170,32 +134,13 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
# For Print
|
# For Print
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
|
||||||
print_settings = PrintSetting.all
|
|
||||||
if !print_settings.nil?
|
|
||||||
print_settings.each do |setting|
|
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
|
||||||
unique_code = "ReceiptBillPdf"
|
|
||||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
|
||||||
unique_code = "ReceiptBillStarPdf"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if !receipt_bill_a5_pdf.empty?
|
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
|
||||||
if receipt_bilA5[1] == '1'
|
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
unique_code = "ReceiptBillA5Pdf"
|
||||||
# else
|
else
|
||||||
|
unique_code = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
customer= Customer.find(saleObj.customer_id)
|
customer = saleObj.customer
|
||||||
|
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate(1)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
has_one :dining_charge
|
has_one :dining_charge
|
||||||
has_one :cashier_terminal_by_zone, foreign_key: "zone_id", primary_key: "zone_id"
|
has_one :cashier_terminal_by_zone, foreign_key: "zone_id", primary_key: "zone_id"
|
||||||
has_one :cashier_terminal, through: :cashier_terminal_by_zone
|
has_one :cashier_terminal, through: :cashier_terminal_by_zone
|
||||||
|
has_many :order_queue_process_by_zones, foreign_key: "zone_id", primary_key: "zone_id"
|
||||||
|
has_many :order_queue_stations, -> { where(is_active: true) }, through: :order_queue_process_by_zones
|
||||||
|
|
||||||
has_many :bookings
|
has_many :bookings
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ class Order < ApplicationRecord
|
|||||||
menu_items = MenuItem.search_by_item_code(item_instance_codes)
|
menu_items = MenuItem.search_by_item_code(item_instance_codes)
|
||||||
menu_items += Product.search_by_product_code(item_instance_codes) if menu_items.length < item_instance_codes.length
|
menu_items += Product.search_by_product_code(item_instance_codes) if menu_items.length < item_instance_codes.length
|
||||||
|
|
||||||
new_order_items = []
|
|
||||||
items.each do |order_item|
|
items.each do |order_item|
|
||||||
menu_item = menu_items.find { |i| i[:item_instance_code].downcase == order_item[:item_instance_code].downcase }
|
menu_item = menu_items.find { |i| i[:item_instance_code].downcase == order_item[:item_instance_code].downcase }
|
||||||
sub_order_items = []
|
sub_order_items = []
|
||||||
@@ -144,7 +143,7 @@ class Order < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
sub_order_items = sub_order_items.to_json
|
sub_order_items = sub_order_items.to_json
|
||||||
new_order_items << OrderItem.new({
|
self.order_items.build({
|
||||||
item_code: menu_item[:item_code],
|
item_code: menu_item[:item_code],
|
||||||
item_instance_code: order_item[:item_instance_code],
|
item_instance_code: order_item[:item_instance_code],
|
||||||
item_name: menu_item[:name],
|
item_name: menu_item[:name],
|
||||||
@@ -159,7 +158,6 @@ class Order < ApplicationRecord
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
self.order_items << new_order_items
|
|
||||||
self.item_count = self.order_items.count
|
self.item_count = self.order_items.count
|
||||||
self.save!
|
self.save!
|
||||||
|
|
||||||
@@ -413,56 +411,22 @@ class Order < ApplicationRecord
|
|||||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
if ENV["SERVER_MODE"] != 'cloud'
|
||||||
cup_status = `#{"sudo service cups status"}`
|
if Printer::PrinterWorker.printers.blank?
|
||||||
print_status = check_cup_status(cup_status)
|
|
||||||
end
|
|
||||||
|
|
||||||
if print_status
|
|
||||||
if !sidekiq.nil?
|
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
|
||||||
else
|
|
||||||
if order
|
|
||||||
oqs = OrderQueueStation.new
|
|
||||||
oqs.process_order(order, table_id, source)
|
|
||||||
end
|
|
||||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
|
||||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
|
||||||
cup_start = `#{"sudo service cups start"}`
|
|
||||||
cup_status = `#{"sudo service cups status"}`
|
|
||||||
print_status = check_cup_status(cup_status)
|
|
||||||
end
|
|
||||||
|
|
||||||
if print_status
|
|
||||||
if !sidekiq.nil?
|
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
|
||||||
else
|
|
||||||
if order
|
|
||||||
oqs = OrderQueueStation.new
|
|
||||||
oqs.process_order(order, table_id, source)
|
|
||||||
end
|
|
||||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
|
||||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
|
||||||
|
|
||||||
msg = 'Print Error ! Please contact to service'
|
msg = 'Print Error ! Please contact to service'
|
||||||
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
|
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !sidekiq.nil?
|
if !sidekiq.nil?
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||||
else
|
else
|
||||||
if order
|
if order
|
||||||
oqs = OrderQueueStation.new
|
oqs = OrderQueueStation.new
|
||||||
oqs.process_order(order, table_id, source)
|
oqs.process_order(order, table_id, order_source)
|
||||||
end
|
end
|
||||||
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
ActionCable.server.broadcast "order_queue_station_channel", order: assign_order, from: from
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
validates_presence_of :station_name, :printer_name
|
validates_presence_of :station_name, :printer_name
|
||||||
|
|
||||||
def process_order(order, table_id, order_source = nil, pdf_status = nil ,change_to=nil, current_user=nil)
|
def process_order(order, table_id, order_source = nil, pdf_status = nil ,change_to=nil, current_user=nil)
|
||||||
oqs_stations = OrderQueueStation.active
|
|
||||||
order_items = order.order_items
|
order_items = order.order_items
|
||||||
|
|
||||||
if table_id.to_i > 0
|
if table_id.to_i > 0
|
||||||
# get dining
|
# get dining
|
||||||
dining = DiningFacility.find(table_id)
|
dining = DiningFacility.find(table_id)
|
||||||
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}").pluck(:order_queue_station_id)
|
oqs_stations = dining.order_queue_stations
|
||||||
oqs_stations = oqs_stations.select { |s| oqs_by_zones.include? s.id }
|
else
|
||||||
|
oqs_stations = OrderQueueStation.active
|
||||||
end
|
end
|
||||||
|
|
||||||
assigned_order_items = []
|
assigned_order_items = []
|
||||||
@@ -30,12 +30,12 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
|
|
||||||
# ToDo per item per printer
|
# ToDo per item per printer
|
||||||
oqs_stations.each do |oqs|
|
oqs_stations.each do |oqs|
|
||||||
oqs_order_items = nil
|
|
||||||
oqs_order_items = order_items.select { |i| JSON.parse(oqs.processing_items).include? i.item_code }
|
oqs_order_items = order_items.select { |i| JSON.parse(oqs.processing_items).include? i.item_code }
|
||||||
assigned_order_items += oqs_order_items.map { |i| AssignedOrderItem.new({ order: order, item_code: i.item_code, instance_code: i.item_instance_code, order_queue_station: oqs, print_status: false, delivery_status: false }) }
|
|
||||||
oqs_order_items_by_zones << { oqs: oqs, oqs_order_items: oqs_order_items }
|
oqs_order_items_by_zones << { oqs: oqs, oqs_order_items: oqs_order_items }
|
||||||
|
|
||||||
|
print_status = false
|
||||||
if oqs.auto_print && order_source != "quick_service"
|
if oqs.auto_print && order_source != "quick_service"
|
||||||
|
print_status = true
|
||||||
if oqs_order_items.length > 0
|
if oqs_order_items.length > 0
|
||||||
if oqs.cut_per_item
|
if oqs.cut_per_item
|
||||||
print_slip_item(oqs, order, oqs_order_items, pdf_status, change_to, current_user, table_id)
|
print_slip_item(oqs, order, oqs_order_items, pdf_status, change_to, current_user, table_id)
|
||||||
@@ -44,9 +44,9 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
assigned_order_items.each(&:save)
|
oqs_order_items.each { |i| AssignedOrderItem.create({ order: order, item_code: i.item_code, instance_code: i.item_instance_code, order_queue_station: oqs, print_status: print_status, delivery_status: false }) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pay_process_order_queue (order_id, table_id)
|
def pay_process_order_queue (order_id, table_id)
|
||||||
@@ -155,13 +155,10 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
else
|
else
|
||||||
move_print_pdf(change_to,current_user,table_id,order_items,oqs)
|
move_print_pdf(change_to,current_user,table_id,order_items,oqs)
|
||||||
end
|
end
|
||||||
|
|
||||||
AssignedOrderItem.where("order_id = ?", order.order_id).update_all(print_status: true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#Print order_item in 1 slip per item
|
#Print order_item in 1 slip per item
|
||||||
def print_slip_item(oqs, order, assigned_items,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
def print_slip_item(oqs, order, assigned_items,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
||||||
|
|
||||||
if pdf_status.nil?
|
if pdf_status.nil?
|
||||||
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
||||||
# print when complete click
|
# print when complete click
|
||||||
@@ -176,8 +173,6 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
else
|
else
|
||||||
move_print_pdf(change_to,current_user,table_id,assigned_items,oqs)
|
move_print_pdf(change_to,current_user,table_id,assigned_items,oqs)
|
||||||
end
|
end
|
||||||
|
|
||||||
AssignedOrderItem.where("order_id = ?", order.order_id).update_all(print_status: true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_print_pdf(change_to,current_user,change_from,order_items,oqs)
|
def move_print_pdf(change_to,current_user,change_from,order_items,oqs)
|
||||||
|
|||||||
@@ -23,22 +23,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
end
|
end
|
||||||
#For print copy
|
#For print copy
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return filename, order_id, oqs.printer_name
|
return filename, order_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
@@ -55,7 +45,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
shop = Shop.current_shop
|
shop = Shop.current_shop
|
||||||
directory_name = 'public/orders_'+shop.shop_code
|
directory_name = "public/orders_#{shop.shop_code}"
|
||||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||||
|
|
||||||
# For Print Per Item
|
# For Print Per Item
|
||||||
@@ -64,7 +54,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
order_items.each do |odi|
|
order_items.each do |odi|
|
||||||
odi_item = print_query('order_item', odi.order_items_id)
|
odi_item = print_query('order_item', odi.order_items_id)
|
||||||
|
|
||||||
filename = directory_name + "/order_item_#{order_id}" + ".pdf"
|
filename = directory_name + "/order_item_#{order_id}.pdf"
|
||||||
# filename = "tmp/order_item_#{order_id}" + ".pdf"
|
# filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||||
# For Item Options
|
# For Item Options
|
||||||
options = odi.options == "[]" ? "" : odi.options
|
options = odi.options == "[]" ? "" : odi.options
|
||||||
@@ -75,32 +65,22 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
# pdf.render_file "tmp/order_item.pdf"
|
# pdf.render_file "tmp/order_item.pdf"
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
# For Print Order Summary
|
# For Print Order Summary
|
||||||
else
|
else
|
||||||
order = print_query('order_summary', order_id)
|
order = print_query('order_summary', order_id)
|
||||||
|
|
||||||
filename = directory_name + "/order_summary_#{order_id}" + ".pdf"
|
filename = directory_name + "/order_summary_#{order_id}.pdf"
|
||||||
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||||
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, order_items, oqs.use_alternate_name, before_updated_qty)
|
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, order_items, oqs.use_alternate_name, before_updated_qty)
|
||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
@@ -108,14 +88,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
#For print copy
|
#For print copy
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return filename, order_id, oqs.printer_name
|
return filename, order_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
@@ -150,7 +122,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
@@ -158,14 +129,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
#For print copy
|
#For print copy
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
# For Print Order Summary
|
# For Print Order Summary
|
||||||
@@ -175,7 +138,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, oqs.use_alternate_name, before_updated_qty)
|
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, oqs.use_alternate_name, before_updated_qty)
|
||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
@@ -183,14 +145,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
#For print copy
|
#For print copy
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return filename, booking_id, oqs.printer_name
|
return filename, booking_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
@@ -206,14 +160,14 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
.joins("left join menu_items as item ON item.item_code = order_items.item_code")
|
.joins("left join menu_items as item ON item.item_code = order_items.item_code")
|
||||||
|
|
||||||
if type == "order_item"
|
if type == "order_item"
|
||||||
query.where("order_items.order_items_id = '#{ id }'")
|
query.where("order_items.order_items_id = ?", id)
|
||||||
.group("order_items.item_code")
|
.group("order_items.item_code")
|
||||||
elsif type == "order_summary"
|
elsif type == "order_summary"
|
||||||
query.where("orders.order_id = '#{ id }'")
|
query.where("orders.order_id = ?", id)
|
||||||
.group("order_items.order_items_id")
|
.group("order_items.order_items_id")
|
||||||
else
|
else
|
||||||
# order summary for booking
|
# order summary for booking
|
||||||
query.where("b.booking_id = '#{ id }'")
|
query.where("b.booking_id = ?", id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,14 +37,15 @@ class Printer::PrinterWorker
|
|||||||
Cups.default_printer
|
Cups.default_printer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.printer_exists?(printer)
|
||||||
|
Cups.show_destinations.include? printer
|
||||||
|
end
|
||||||
|
|
||||||
def print(file_path, printer_destination = nil )
|
def print(file_path, printer_destination = nil )
|
||||||
if printer_destination.nil?
|
if printer_destination.nil?
|
||||||
printer_destination = self.printer_destination
|
printer_destination = self.printer_destination
|
||||||
end
|
end
|
||||||
|
|
||||||
puts printer_destination
|
|
||||||
puts '........Printer Destination..........'
|
|
||||||
|
|
||||||
copy = self.print_copies
|
copy = self.print_copies
|
||||||
#Print only when printer information is not null
|
#Print only when printer information is not null
|
||||||
if !self.printer_destination.nil?
|
if !self.printer_destination.nil?
|
||||||
|
|||||||
Reference in New Issue
Block a user