print developing
This commit is contained in:
@@ -1,25 +1,16 @@
|
||||
class Oqs::PrintController < ApplicationController
|
||||
def print
|
||||
unique_code=="OrderItemPdf"
|
||||
unique_code="OrderItemPdf"
|
||||
assigned_item_id=params[:id]
|
||||
assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id)
|
||||
|
||||
print_settings=PrintingSetting.find_by_unique_cod(unique_code)
|
||||
# order_queue_printer= OrderQueuePrinter.new(print_settings)
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
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 )
|
||||
|
||||
unique_code =params[:unique_code]
|
||||
assigned_item_id=params[:id]
|
||||
# if unique_code=="OrderItemPdf"
|
||||
# print_settings=PrintingSetting.find_by_unique_cod(unique_code)
|
||||
# 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 )
|
||||
# update print status when complete click
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_item.print_status=true
|
||||
assigned_item.save
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,20 +4,43 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order_item=OrderItem.find_by_item_code(item_code)
|
||||
pdf = OrderItemPdf.new(printer_settings,order_item)
|
||||
pdf.render_file "tmp/order_item_queue_#{order_id}_#{item_code}" + ".pdf"
|
||||
order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||
pdf = OrderItemPdf.new(order_item[0],printer_settings)
|
||||
pdf.render_file "tmp/receipt.pdf"
|
||||
self.print("tmp/receipt.pdf")
|
||||
end
|
||||
|
||||
def print_order_summary(booking_id)
|
||||
def print_order_summary(printer_settings,booking_id)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order=print_query('booking',booking_id)
|
||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new
|
||||
pdf = OrderSummaryPdf.new(order,printer_settings)
|
||||
pdf.render_file filename
|
||||
|
||||
self.print(filename)
|
||||
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
|
||||
|
||||
@@ -5,14 +5,27 @@ class OrderItemPdf < Prawn::Document
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
|
||||
# font "public/fonts/padauk.ttf"
|
||||
font_size 9
|
||||
text "#{"table_name"}", :size => 15
|
||||
text "#{order_item.dining}", :size => 15
|
||||
stroke_horizontal_rule
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user