diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 58aac67c..14d79857 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -2,9 +2,9 @@ class Oqs::HomeController < BaseOqsController def index queue_stations=OrderQueueStation.all - @queue_items_details = queue_items_query(0) + @queue_items_details = queue_items_query(false) - @queue_completed_item = queue_items_query(1) + @queue_completed_item = queue_items_query(true) @queue_stations_items=Array.new diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index f086e3cd..a5267442 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -16,6 +16,7 @@ class OrderQueueStation < ApplicationRecord oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) order_items = order.order_items + #Assign OQS id to order Items oqs_stations.each do |oqs| #Get List of items - @@ -26,16 +27,13 @@ class OrderQueueStation < ApplicationRecord #Processing through the looping items order_items.each do |order_item| if (pq_item == order_item.item_code) - if oqs.id == oqpbz.order_queue_station_id - #Same Order_items can appear in two location. + # if oqs.id == oqpbz.order_queue_station_id + # #Same Order_items can appear in two location. + # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + # else AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - else - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - end - puts oqs.station_name - puts oqs.auto_print - puts oqs.cut_per_item - puts oqs.print_copy + # end + if oqs.auto_print print_slip(oqs, order, order_items) end @@ -43,29 +41,27 @@ class OrderQueueStation < ApplicationRecord end end end - - #Print OQS where printing is require end private #Print order_items in 1 slip - def print_slip(oqs, order, items) + def print_slip(oqs, order, order_items) unique_code="OrderSummaryPdf" - # 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_order_summary(oqs,order.order_id) - # update print status for completed same order items - items.each do |ai| + AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai| + # update print status for order items ai.print_status=true ai.save - end + end + end #Print order_item in 1 slip per item - def print_slip_item(oqs, item) + def print_slip_item(oqs, assigned_order_item) unique_code="OrderItemPdf" # print when complete click @@ -74,7 +70,7 @@ class OrderQueueStation < ApplicationRecord order_queue_printer.print_order_item(oqs,item.order_id, item.item_code ) # update print status for completed same order items - item.each do |ai| + assigned_order_item.each do |ai| ai.print_status=true ai.save end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index f0b3d576..52fc3244 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -23,13 +23,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # 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) - pdf.render_file "tmp/order_item.pdf" + # pdf.render_file "tmp/order_item.pdf" + pdf.render_file filename if oqs.print_copy - self.print("tmp/order_item.pdf", oqs.printer_name) - self.print("tmp/order_item.pdf", oqs.printer_name) + self.print(filename, oqs.printer_name) + self.print(filename.gsub(".","-copy."), oqs.printer_name) else - self.print("tmp/order_item.pdf", oqs.printer_name) + self.print(filename, oqs.printer_name) end end # For Print Order Summary @@ -37,7 +39,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker filename = "tmp/order_summary_#{order_id}" + ".pdf" pdf = OrderSummaryPdf.new(order) pdf.render_file filename - self.print(filename, oqs.printer_name) + if oqs.print_copy + self.print(filename, oqs.printer_name) + self.print(filename.gsub(".","-copy."), oqs.printer_name) + else + self.print(filename, oqs.printer_name) + end end end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 47c1f6a5..22f27497 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -77,6 +77,7 @@ class OrderSummaryPdf < Prawn::Document move_down 5 order_item.each do|odi| + y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "#{odi.item_name}", :size => self.item_font_size,:align => :left end @@ -84,9 +85,9 @@ class OrderSummaryPdf < Prawn::Document bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do text "#{odi.qty}", :size => self.item_font_size,:align => :left end - end - move_down 5 + move_down 5 + end end end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 18e72880..084ae8cf 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -49,7 +49,10 @@ <%= qid.qty %> ] -
Medium, Fries, Salad
+Order at @@ -97,7 +100,10 @@ <%= qid.qty %> ] -
Medium, Fries, Salad
+Order at