add options in oqs
This commit is contained in:
@@ -111,8 +111,9 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
// Print Order Item
|
// Print Order Item
|
||||||
$('#print_order_item').on('click',function(){
|
$('#print_order_item').on('click',function(){
|
||||||
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
|
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
|
||||||
var params = { 'id':assigned_item_id };
|
var options = $('.selected-item').children('.card-block').find('.item-options').text();
|
||||||
|
var params = { 'options':options };
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: '/oqs/print/print/'+assigned_item_id,
|
url: '/oqs/print/print/'+assigned_item_id,
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
:headers => {
|
:headers => {
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
}
|
},
|
||||||
|
:timeout => 10
|
||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
@@ -163,7 +164,8 @@ end
|
|||||||
:headers => {
|
:headers => {
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
}
|
},
|
||||||
|
:timeout => 10
|
||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ class Oqs::PrintController < ApplicationController
|
|||||||
# Print Order Item
|
# Print Order Item
|
||||||
def print
|
def print
|
||||||
unique_code="OrderItemPdf"
|
unique_code="OrderItemPdf"
|
||||||
assigned_item_id=params[:id]
|
assigned_item_id = params[:id]
|
||||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
options = params[:options]
|
||||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
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
|
# order queue stations
|
||||||
oqs = assigned_item.order_queue_station
|
oqs = assigned_item.order_queue_station
|
||||||
@@ -13,9 +14,9 @@ class Oqs::PrintController < ApplicationController
|
|||||||
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
|
||||||
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, assigned_item.order_id, assigned_item.item_code, print_status )
|
order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status, options )
|
||||||
|
|
||||||
# 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|
|
||||||
@@ -27,10 +28,10 @@ class Oqs::PrintController < ApplicationController
|
|||||||
# Print Order Details with booking id
|
# 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]
|
||||||
table_name=params[:table_name]
|
table_name = params[:table_name]
|
||||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||||
|
|
||||||
# order queue stations
|
# order queue stations
|
||||||
oqs = assigned_item.order_queue_station
|
oqs = assigned_item.order_queue_station
|
||||||
@@ -43,13 +44,13 @@ class Oqs::PrintController < ApplicationController
|
|||||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||||
|
|
||||||
# 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_booking_summary(oqs, booking.booking_id, 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|
|
||||||
ai.print_status=true
|
ai.print_status = true
|
||||||
ai.save
|
ai.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillPdf"
|
||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
# customer= Customer.where('customer_id=' +.customer_id)
|
||||||
|
|
||||||
customer= Customer.find( @sale_data.customer_id)
|
customer= Customer.find(@sale_data.customer_id)
|
||||||
# get member information
|
# get member information
|
||||||
member_info = Customer.get_member_account(customer)
|
member_info = Customer.get_member_account(customer)
|
||||||
# get printer info
|
# get printer info
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||||
|
|
||||||
def print_order_item(oqs,order_id, item_code, print_status)
|
def print_order_item(oqs,order_id, item_code, print_status, options="")
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#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"
|
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, options)
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
@@ -31,7 +31,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
if oqs.cut_per_item
|
if oqs.cut_per_item
|
||||||
order.each do|odi|
|
order.each do|odi|
|
||||||
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
||||||
pdf = OrderItemPdf.new(odi, print_status)
|
# For Item Options
|
||||||
|
options = odi.options == "[]"? "" : odi.options
|
||||||
|
pdf = OrderItemPdf.new(odi, print_status, options)
|
||||||
# pdf.render_file "tmp/order_item.pdf"
|
# pdf.render_file "tmp/order_item.pdf"
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
@@ -65,7 +67,10 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
if oqs.cut_per_item
|
if oqs.cut_per_item
|
||||||
order.each do|odi|
|
order.each do|odi|
|
||||||
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
|
||||||
pdf = OrderItemPdf.new(odi, print_status)
|
# For Item Options
|
||||||
|
options = odi.options == "[]"? "" : odi.options
|
||||||
|
pdf = OrderItemPdf.new(odi, print_status, options)
|
||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
if oqs.print_copy
|
||||||
@@ -98,7 +103,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
# Query for OQS with status
|
# Query for OQS with status
|
||||||
def print_query(type, id)
|
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.options, 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
|
||||||
@@ -107,16 +112,17 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
.where("order_items.item_code = '#{ id }'")
|
.where("order_items.item_code = '#{ id }'")
|
||||||
.group("order_items.item_code")
|
.group("order_items.item_code")
|
||||||
elsif type == "order_summary"
|
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.options, 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("orders.order_id = '#{ id }'")
|
.where("orders.order_id = '#{ id }'")
|
||||||
|
.group("order_items.order_items_id")
|
||||||
else
|
else
|
||||||
# order summary for booking
|
# 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")
|
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, 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
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class OrderItemPdf < Prawn::Document
|
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
|
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, print_status)
|
def initialize(order_item, print_status, options)
|
||||||
self.page_width = 210
|
self.page_width = 210
|
||||||
self.page_height = 2500
|
self.page_height = 2500
|
||||||
self.margin = 5
|
self.margin = 5
|
||||||
@@ -29,7 +29,7 @@ class OrderItemPdf < Prawn::Document
|
|||||||
order_info(order_item.order_by,order_item.order_at)
|
order_info(order_item.order_by,order_item.order_at)
|
||||||
|
|
||||||
# order items
|
# order items
|
||||||
order_items(order_item)
|
order_items(order_item, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write Order Information to PDF
|
# Write Order Information to PDF
|
||||||
@@ -52,23 +52,11 @@ class OrderItemPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Write Order items to PDF
|
# Write Order items to PDF
|
||||||
def order_items(order_item)
|
def order_items(order_item, options)
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
# No Need for Order Item
|
|
||||||
# bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
|
||||||
# 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
|
|
||||||
# text "Qty", :size => self.item_font_size,:align => :right
|
|
||||||
# end
|
|
||||||
|
|
||||||
# stroke_horizontal_rule
|
|
||||||
# move_down 5
|
|
||||||
|
|
||||||
#Add Order Item
|
#Add Order Item
|
||||||
add_order_items(order_item)
|
add_order_items(order_item, options)
|
||||||
|
|
||||||
dash(1, :space => 1, :phase => 1)
|
dash(1, :space => 1, :phase => 1)
|
||||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||||
@@ -76,7 +64,7 @@ class OrderItemPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Add order items under order info
|
# Add order items under order info
|
||||||
def add_order_items(order_item)
|
def add_order_items(order_item, options)
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
@@ -91,6 +79,14 @@ class OrderItemPdf < Prawn::Document
|
|||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
|
# add option
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "#{options}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -92,6 +92,18 @@ class OrderSummaryPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
move_down 5
|
move_down 5
|
||||||
|
|
||||||
|
# add option
|
||||||
|
options = odi.options == "[]"? "" : odi.options
|
||||||
|
|
||||||
|
if options != ""
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||||
|
text "#{options}", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
|
||||||
|
move_down 5
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
</span> ]
|
</span> ]
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<p class="card-text"><%= qid.options %></p>
|
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
||||||
|
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<small class="text-muted">Order at
|
<small class="text-muted">Order at
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
</span> ]
|
</span> ]
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<p class="card-text"><%= qid.options %></p>
|
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
||||||
|
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<small class="text-muted">Order at
|
<small class="text-muted">Order at
|
||||||
|
|||||||
Reference in New Issue
Block a user