print developing
This commit is contained in:
@@ -1,25 +1,16 @@
|
|||||||
class Oqs::PrintController < ApplicationController
|
class Oqs::PrintController < ApplicationController
|
||||||
def print
|
def print
|
||||||
unique_code=="OrderItemPdf"
|
unique_code="OrderItemPdf"
|
||||||
assigned_item_id=params[:id]
|
assigned_item_id=params[:id]
|
||||||
assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id)
|
assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id)
|
||||||
|
|
||||||
print_settings=PrintingSetting.find_by_unique_cod(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
# order_queue_printer= OrderQueuePrinter.new(print_settings)
|
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_item(print_settings,assigned_order_item[0].order_id, assigned_order_item[0].item_code )
|
order_queue_printer.print_order_item(print_settings,assigned_order_item[0].order_id, assigned_order_item[0].item_code )
|
||||||
|
|
||||||
unique_code =params[:unique_code]
|
# update print status when complete click
|
||||||
assigned_item_id=params[:id]
|
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||||
# if unique_code=="OrderItemPdf"
|
assigned_item.print_status=true
|
||||||
# print_settings=PrintingSetting.find_by_unique_cod(unique_code)
|
assigned_item.save
|
||||||
# obj= OrderQueuePrinter.new(print_settings)
|
|
||||||
# obj.print_order_item(print_settings,assigned_item_id)
|
|
||||||
|
|
||||||
|
|
||||||
# end
|
|
||||||
|
|
||||||
# assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id)
|
|
||||||
|
|
||||||
# order_queue_printer.print_order_item(assigned_order_item[0].order_id, assigned_order_item[0].item_code )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,20 +4,43 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
order_item=OrderItem.find_by_item_code(item_code)
|
order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||||
pdf = OrderItemPdf.new(printer_settings,order_item)
|
pdf = OrderItemPdf.new(order_item[0],printer_settings)
|
||||||
pdf.render_file "tmp/order_item_queue_#{order_id}_#{item_code}" + ".pdf"
|
pdf.render_file "tmp/receipt.pdf"
|
||||||
self.print("tmp/receipt.pdf")
|
self.print("tmp/receipt.pdf")
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_order_summary(booking_id)
|
def print_order_summary(printer_settings,booking_id)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
|
order=print_query('booking',booking_id)
|
||||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new
|
pdf = OrderSummaryPdf.new(order,printer_settings)
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
self.print(filename)
|
self.print(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Query for OQS with status
|
||||||
|
def print_query(type, code)
|
||||||
|
if type == 'order_item'
|
||||||
|
OrderItem.select("order_items.item_code, order_items.item_name,order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
|
||||||
|
.joins("left join orders ON orders.id = order_items.order_id
|
||||||
|
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||||
|
left join bookings AS b ON b.id = bo.booking_id
|
||||||
|
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||||
|
left join customers as cus ON cus.id = orders.customer_id")
|
||||||
|
.where("order_items.item_code=" + code)
|
||||||
|
.group("order_items.item_code")
|
||||||
|
else
|
||||||
|
OrderItem.select("order_items.item_code, order_items.item_name, df.name as dining")
|
||||||
|
.joins("left join orders ON orders.id = order_items.order_id
|
||||||
|
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||||
|
left join bookings AS b ON b.id = bo.booking_id
|
||||||
|
left join dining_facilities AS df ON df.id = b.dining_facility_id")
|
||||||
|
.where("booking.id=" + code)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,13 +6,26 @@ class OrderItemPdf < Prawn::Document
|
|||||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||||
# font "public/fonts/Zawgyi-One.ttf"
|
# font "public/fonts/Zawgyi-One.ttf"
|
||||||
# font "public/fonts/padauk.ttf"
|
# font "public/fonts/padauk.ttf"
|
||||||
|
|
||||||
|
|
||||||
font_size 9
|
font_size 9
|
||||||
text "#{"table_name"}", :size => 15
|
text "#{order_item.dining}", :size => 15
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
|
cashier_info(order_item.order_by,order_item.order_at, order_item.customer)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def cashier_info(order_by, order_at, customer)
|
||||||
|
move_down 5
|
||||||
|
y_position = cursor
|
||||||
|
|
||||||
|
bounding_box([0,y_position], :width =>200, :height => 20) do
|
||||||
|
text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y %m %d")}", :size => 7,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
stroke_horizontal_rule
|
||||||
|
|
||||||
|
move_down 5
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user