update oqs print in cloud
This commit is contained in:
@@ -354,12 +354,16 @@ $(document).on('turbolinks:load', function() {
|
||||
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
|
||||
var options = $('.selected-item').children('.card-block').find('.item-options').text();
|
||||
var params = { 'options':options };
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
type: 'GET',
|
||||
url: '/oqs/print/print/'+assigned_item_id,
|
||||
data: params,
|
||||
success: function(data){ }
|
||||
success: function(result){
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -374,7 +378,12 @@ $(document).on('turbolinks:load', function() {
|
||||
type: 'GET',
|
||||
url: '/oqs/print/print_order_summary/'+assigned_item_id,
|
||||
data: params,
|
||||
success: function(data){ }
|
||||
success: function(result){
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ class Oqs::PrintController < ApplicationController
|
||||
authorize_resource :class => false
|
||||
# Print Order Item
|
||||
def print
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
printer = PrintSetting.all
|
||||
unique_code="OrderItemPdf"
|
||||
@@ -41,19 +41,30 @@ class Oqs::PrintController < ApplicationController
|
||||
# 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(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
|
||||
filename, receipt_no, cashier_printer = order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status=true
|
||||
ai.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
# Print Order Details with booking id
|
||||
def print_order_summary
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
printer = PrintSetting.all
|
||||
unique_code="OrderSummaryPdf"
|
||||
@@ -98,14 +109,25 @@ class Oqs::PrintController < ApplicationController
|
||||
# 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_booking_summary(print_settings,oqs, booking_id, print_status)
|
||||
filename, receipt_no, cashier_printer = order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status)
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status = true
|
||||
ai.save
|
||||
end
|
||||
end
|
||||
|
||||
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount)
|
||||
if ENV["SERVER_MODE"] == "cloud"
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,9 +1,6 @@
|
||||
class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, before_updated_qty="", options="")
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
# Must be one print
|
||||
if print_settings.print_copies == 0
|
||||
print_settings.print_copies = 1
|
||||
@@ -12,7 +9,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
|
||||
|
||||
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
# filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||
print_setting = PrintSetting.all
|
||||
@@ -39,6 +36,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# end
|
||||
|
||||
shop = Shop.first
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
pdf.render_file filename
|
||||
|
||||
if oqs.print_copy
|
||||
@@ -56,7 +59,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, oqs.printer_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return filename, order_id, oqs.printer_name
|
||||
end
|
||||
|
||||
# Query for per order
|
||||
@@ -72,12 +77,19 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
print_setting = PrintSetting.all.order("id ASC")
|
||||
order=print_query('order_summary', order_id)
|
||||
|
||||
shop = Shop.first
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
|
||||
order_items.each do|odi|
|
||||
odi_item=print_query('order_item', odi.order_items_id)
|
||||
filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||
odi_item=print_query('order_item', odi.order_items_id)
|
||||
|
||||
filename = directory_name + "/order_item_#{order_id}" + ".pdf"
|
||||
# filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -122,7 +134,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
filename = directory_name + "/order_summary_#{order_id}" + ".pdf"
|
||||
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
||||
if !print_setting.empty?
|
||||
print_setting.each do |print_settings|
|
||||
@@ -160,6 +173,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
end
|
||||
return filename, order_id, oqs.printer_name
|
||||
end
|
||||
|
||||
# Print for orders in booking
|
||||
@@ -173,10 +187,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
print_setting = PrintSetting.all.order("id ASC")
|
||||
|
||||
order=print_query('booking_summary', booking_id)
|
||||
|
||||
shop = Shop.first
|
||||
directory_name = 'public/orders_'+shop.shop_code
|
||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item_#{booking_id}" + ".pdf"
|
||||
# filename = "tmp/order_item_#{booking_id}" + ".pdf"
|
||||
filename = directory_name + "/order_item_#{booking_id}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -222,7 +242,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||
# filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||
filename = directory_name + "/booking_summary_#{booking_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
||||
|
||||
if !print_setting.empty?
|
||||
@@ -261,6 +282,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
end
|
||||
return filename, booking_id, oqs.printer_name
|
||||
end
|
||||
|
||||
# Query for OQS with status
|
||||
|
||||
@@ -176,12 +176,15 @@
|
||||
<!-- OQS Buttons -->
|
||||
<br>
|
||||
<a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a>
|
||||
<% if ENV["SERVER_MODE"] != "cloud" %>
|
||||
|
||||
<button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a>
|
||||
|
||||
<button type="button" class="btn bg-blue btn-block btn-lg waves-effect" id="print_order_summary">Print <br/>Order<br/>Summary</button>
|
||||
<% if ENV["SERVER_MODE"] != "cloud" %>
|
||||
<%end%>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="server_mode" value="<%=ENV["SERVER_MODE"]%>">
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).on('turbolinks:load', function() {
|
||||
|
||||
@@ -357,7 +357,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post "/:id", to: "edit#update"
|
||||
|
||||
# Pass assigned_order_item_id
|
||||
post 'print/print/:id', to: "print#print"
|
||||
get 'print/print/:id', to: "print#print"
|
||||
get 'print/print_order_summary/:id', to: "print#print_order_summary"
|
||||
|
||||
get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs"
|
||||
|
||||
Reference in New Issue
Block a user