oqs updated
This commit is contained in:
@@ -8,6 +8,8 @@ class Oqs::PrintController < ApplicationController
|
|||||||
|
|
||||||
# order queue stations
|
# order queue stations
|
||||||
oqs = assigned_item.order_queue_station
|
oqs = assigned_item.order_queue_station
|
||||||
|
|
||||||
|
# Check Printed
|
||||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||||
|
|
||||||
# print when complete click
|
# print when complete click
|
||||||
@@ -22,7 +24,7 @@ class Oqs::PrintController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Print Order Details
|
# Print Order Details with booking id
|
||||||
def print_order_summary
|
def print_order_summary
|
||||||
unique_code="OrderSummaryPdf"
|
unique_code="OrderSummaryPdf"
|
||||||
assigned_item_id=params[:id]
|
assigned_item_id=params[:id]
|
||||||
@@ -32,6 +34,8 @@ class Oqs::PrintController < ApplicationController
|
|||||||
|
|
||||||
# order queue stations
|
# order queue stations
|
||||||
oqs = assigned_item.order_queue_station
|
oqs = assigned_item.order_queue_station
|
||||||
|
|
||||||
|
# Check Printed
|
||||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||||
|
|
||||||
# get dining
|
# get dining
|
||||||
@@ -41,7 +45,7 @@ class Oqs::PrintController < ApplicationController
|
|||||||
# print when complete click
|
# print when complete click
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_summary(oqs, booking, print_status)
|
order_queue_printer.print_booking_summary(oqs, booking.booking_id, print_status)
|
||||||
|
|
||||||
# update print status for completed same order items
|
# update print status for completed same order items
|
||||||
assigned_items.each do |ai|
|
assigned_items.each do |ai|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
|
|
||||||
order_items = order.order_items
|
order_items = order.order_items
|
||||||
|
|
||||||
|
# get dining
|
||||||
|
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||||
|
|
||||||
#Assign OQS id to order Items
|
#Assign OQS id to order Items
|
||||||
oqs_stations.each do |oqs|
|
oqs_stations.each do |oqs|
|
||||||
#Get List of items -
|
#Get List of items -
|
||||||
@@ -31,9 +34,7 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
# #Same Order_items can appear in two location.
|
# #Same Order_items can appear in two location.
|
||||||
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
# else
|
# else
|
||||||
puts pq_item
|
|
||||||
puts order_item.item_code
|
|
||||||
puts oqs.station_name
|
|
||||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
|
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_summary(oqs,order.order_id)
|
order_queue_printer.print_order_summary(oqs,order.order_id, print_status="")
|
||||||
|
|
||||||
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
|
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
|
||||||
# update print status for order items
|
# update print status for order items
|
||||||
@@ -70,7 +71,7 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
# print when complete click
|
# print when complete click
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_item(oqs,item.order_id, item.item_code )
|
order_queue_printer.print_order_item(oqs,item.order_id, item.item_code, print_status="" )
|
||||||
|
|
||||||
# update print status for completed same order items
|
# update print status for completed same order items
|
||||||
assigned_order_item.each do |ai|
|
assigned_order_item.each do |ai|
|
||||||
|
|||||||
@@ -5,21 +5,28 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||||
|
|
||||||
|
filename = "tmp/order_item_#{order_item[0].item_name}" + ".pdf"
|
||||||
pdf = OrderItemPdf.new(order_item[0], print_status)
|
pdf = OrderItemPdf.new(order_item[0], print_status)
|
||||||
pdf.render_file "tmp/order_item.pdf"
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
self.print("tmp/order_item.pdf", oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
self.print("tmp/order_item.pdf", oqs.printer_name)
|
|
||||||
|
#For print copy
|
||||||
|
pdf.render_file filename.gsub(".","-copy.")
|
||||||
|
self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
else
|
||||||
self.print("tmp/order_item.pdf", oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_order_summary(oqs,booking, print_status)
|
# Query for per order
|
||||||
|
def print_order_summary(oqs, order_id, print_status)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
order=print_query('order_summary',booking.booking_id)
|
order=print_query('order_summary', order_id)
|
||||||
# For Print Per Item
|
# For Print Per Item
|
||||||
if oqs.cut_per_item
|
if oqs.cut_per_item
|
||||||
order.each do|odi|
|
order.each do|odi|
|
||||||
@@ -36,11 +43,51 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
# For Print Order Summary
|
# For Print Order Summary
|
||||||
else
|
else
|
||||||
filename = "tmp/order_summary_#{booking.booking_id}" + ".pdf"
|
filename = "tmp/order_summary_#{ order_id }" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new(order, print_status)
|
pdf = OrderSummaryPdf.new(order, print_status)
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
|
|
||||||
|
#For print copy
|
||||||
|
pdf.render_file filename.gsub(".","-copy.")
|
||||||
|
self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
|
else
|
||||||
|
self.print(filename, oqs.printer_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Print for orders in booking
|
||||||
|
def print_booking_summary(oqs, booking_id, print_status)
|
||||||
|
order=print_query('booking_summary', booking_id)
|
||||||
|
# For Print Per Item
|
||||||
|
if oqs.cut_per_item
|
||||||
|
order.each do|odi|
|
||||||
|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
||||||
|
pdf = OrderItemPdf.new(odi, print_status)
|
||||||
|
pdf.render_file filename
|
||||||
|
|
||||||
|
if oqs.print_copy
|
||||||
|
self.print(filename, oqs.printer_name)
|
||||||
|
|
||||||
|
#For print copy
|
||||||
|
pdf.render_file filename.gsub(".","-copy.")
|
||||||
|
self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
|
else
|
||||||
|
self.print(filename, oqs.printer_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# For Print Order Summary
|
||||||
|
else
|
||||||
|
filename = "tmp/booking_summary_#{ booking_id }" + ".pdf"
|
||||||
|
pdf = OrderSummaryPdf.new(order, print_status)
|
||||||
|
pdf.render_file filename
|
||||||
|
if oqs.print_copy
|
||||||
|
self.print(filename, oqs.printer_name)
|
||||||
|
|
||||||
|
#For print copy
|
||||||
|
pdf.render_file filename.gsub(".","-copy.")
|
||||||
self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
else
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
@@ -49,25 +96,33 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Query for OQS with status
|
# Query for OQS with status
|
||||||
def print_query(type, code)
|
def print_query(type, id)
|
||||||
if type == 'order_item'
|
if type == "order_item"
|
||||||
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
|
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, 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.order_id = order_items.order_id
|
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||||
left join booking_orders AS bo ON bo.order_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.booking_id = bo.booking_id
|
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||||
left join customers as cus ON cus.customer_id = orders.customer_id")
|
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||||
.where("order_items.item_code='" + code + "'")
|
.where("order_items.item_code = '#{ id }'")
|
||||||
.group("order_items.item_code")
|
.group("order_items.item_code")
|
||||||
else
|
elsif type == "order_summary"
|
||||||
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
|
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, 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.order_id = order_items.order_id
|
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||||
left join booking_orders AS bo ON bo.order_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.booking_id = bo.booking_id
|
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||||
left join customers as cus ON cus.customer_id = orders.customer_id")
|
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||||
.where("b.booking_id='" + code + "'")
|
.where("orders.order_id = '#{ id }'")
|
||||||
# .group("order_items.item_code")
|
else
|
||||||
|
# order summary for booking
|
||||||
|
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, 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.order_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.booking_id = bo.booking_id
|
||||||
|
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
||||||
|
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||||
|
.where("b.booking_id = '#{ id }'")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user