oqs updated
This commit is contained in:
@@ -122,11 +122,13 @@ $(document).ready(function(){
|
||||
|
||||
// Print Order Summary
|
||||
$('#print_order_summary').on('click',function(){
|
||||
var table_name=$('.selected-item').children().children().children('.order-zone').text().trim();
|
||||
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
|
||||
var params = { 'id':assigned_item_id };
|
||||
var params = { 'table_name':table_name };
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/oqs/print/print_order_summary/'+assigned_item_id,
|
||||
data: params,
|
||||
success: function(data){ }
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,11 +8,12 @@ class Oqs::PrintController < ApplicationController
|
||||
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||
|
||||
# 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_item(oqs,assigned_item.order_id, assigned_item.item_code )
|
||||
order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status )
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
@@ -25,16 +26,22 @@ class Oqs::PrintController < ApplicationController
|
||||
def print_order_summary
|
||||
unique_code="OrderSummaryPdf"
|
||||
assigned_item_id=params[:id]
|
||||
table_name=params[:table_name]
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||
|
||||
# get dining
|
||||
dining = DiningFacility.find_by_name(table_name);
|
||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
|
||||
# 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,assigned_item.order_id)
|
||||
order_queue_printer.print_order_summary(oqs, booking, print_status)
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
|
||||
@@ -31,6 +31,9 @@ class OrderQueueStation < ApplicationRecord
|
||||
# #Same Order_items can appear in two location.
|
||||
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
# else
|
||||
puts pq_item
|
||||
puts order_item.item_code
|
||||
puts oqs.station_name
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
# end
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
def print_order_item(oqs,order_id, item_code)
|
||||
def print_order_item(oqs,order_id, item_code, print_status)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||
pdf = OrderItemPdf.new(order_item[0])
|
||||
order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
|
||||
pdf = OrderItemPdf.new(order_item[0], print_status)
|
||||
pdf.render_file "tmp/order_item.pdf"
|
||||
if oqs.print_copy
|
||||
self.print("tmp/order_item.pdf", oqs.printer_name)
|
||||
@@ -15,16 +15,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
|
||||
def print_order_summary(oqs,order_id)
|
||||
def print_order_summary(oqs,booking, print_status)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
order=print_query('order_summary',order_id)
|
||||
order=print_query('order_summary',booking.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)
|
||||
pdf = OrderItemPdf.new(odi, print_status)
|
||||
# pdf.render_file "tmp/order_item.pdf"
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
@@ -36,8 +36,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(order)
|
||||
filename = "tmp/order_summary_#{booking.booking_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(order, print_status)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
self.print(filename, oqs.printer_name)
|
||||
@@ -59,15 +59,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||
.where("order_items.item_code='" + code + "'")
|
||||
.group("order_items.item_code")
|
||||
else
|
||||
else
|
||||
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("orders.order_id='" + code + "'")
|
||||
.group("order_items.item_code")
|
||||
.where("b.booking_id='" + code + "'")
|
||||
# .group("order_items.item_code")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
class OrderItemPdf < Prawn::Document
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(order_item)
|
||||
self.page_width = 254
|
||||
self.page_height = 1450
|
||||
self.margin = 10
|
||||
def initialize(order_item, print_status)
|
||||
self.page_width = 210
|
||||
self.page_height = 2500
|
||||
self.margin = 5
|
||||
self.price_width = 40 # No Need for item
|
||||
self.qty_width = 34
|
||||
self.qty_width = 30
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width + (self.margin*4))
|
||||
self.item_width = self.page_width - self.qty_width
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=80
|
||||
self.label_width=100
|
||||
|
||||
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
@@ -19,9 +19,9 @@ class OrderItemPdf < Prawn::Document
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
self.header_font_size = 14
|
||||
self.item_font_size = 12
|
||||
self.item_font_size = 12
|
||||
|
||||
text "#{order_item.dining}", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
text "#{ order_item.dining+print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class OrderSummaryPdf < Prawn::Document
|
||||
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
|
||||
def initialize(order)
|
||||
self.page_width = 254
|
||||
self.page_height = 1450
|
||||
self.margin = 10
|
||||
def initialize(order, print_status)
|
||||
self.page_width = 210
|
||||
self.page_height = 2500
|
||||
self.margin = 5
|
||||
self.price_width = 40 # No Need for item
|
||||
self.qty_width = 34
|
||||
self.qty_width = 30
|
||||
self.total_width = 40 # No Need for item
|
||||
self.item_width = self.page_width - (self.qty_width + (self.margin*4))
|
||||
self.item_width = self.page_width - (self.qty_width - self.margin)
|
||||
self.item_height = 15
|
||||
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||
self.label_width=100
|
||||
@@ -20,7 +20,7 @@ class OrderSummaryPdf < Prawn::Document
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
|
||||
text "#{order[0].dining}", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
text "#{ order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
|
||||
@@ -59,7 +59,7 @@ class OrderSummaryPdf < Prawn::Document
|
||||
text "Item", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
bounding_box([self.item_width-2,y_position], :width => self.qty_width, :height => self.item_height) do
|
||||
text "Qty", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
@@ -78,12 +78,17 @@ class OrderSummaryPdf < Prawn::Document
|
||||
|
||||
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
|
||||
|
||||
# pad_top(15) {
|
||||
# text_box "#{odi.item_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
|
||||
# text_box "#{odi.qty}", :at =>[self.item_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
|
||||
# }
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left, :height => self.item_height
|
||||
end
|
||||
|
||||
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
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{odi.qty}", :size => self.item_font_size,:align => :left, :height => self.item_height
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
@@ -3,7 +3,7 @@ class CreateOrderQueueStations < ActiveRecord::Migration[5.1]
|
||||
create_table :order_queue_stations do |t|
|
||||
t.string :station_name, :null => false
|
||||
t.boolean :is_active, :null => false, :default => false
|
||||
t.json :processing_items, :default => "[]"
|
||||
t.json :processing_items
|
||||
t.boolean :print_copy, :null => false, :default => false
|
||||
t.string :printer_name
|
||||
t.integer :font_size, :null => false, :default => 10
|
||||
|
||||
Reference in New Issue
Block a user