print settings ActionCable

This commit is contained in:
Thein Lin Kyaw
2020-08-18 16:11:17 +06:30
parent 583d7ee473
commit 5dfdc7353e
25 changed files with 1050 additions and 802 deletions

View File

@@ -18,7 +18,7 @@ gem 'pg'
gem 'mysql2', '~> 0.5.2' gem 'mysql2', '~> 0.5.2'
#Use PosgreSQL #Use PosgreSQL
gem "select2-rails"
# redis server for cable # redis server for cable
gem 'redis', '~> 3.0' gem 'redis', '~> 3.0'

View File

@@ -264,6 +264,7 @@ GEM
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
schema_to_scaffold (0.8.0) schema_to_scaffold (0.8.0)
activesupport (>= 3.2.1) activesupport (>= 3.2.1)
select2-rails (4.0.13)
shoulda-matchers (3.1.3) shoulda-matchers (3.1.3)
activesupport (>= 4.0.0) activesupport (>= 4.0.0)
sidekiq (5.2.7) sidekiq (5.2.7)
@@ -367,6 +368,7 @@ DEPENDENCIES
rubyzip (= 1.0.0) rubyzip (= 1.0.0)
sass-rails (~> 5.0) sass-rails (~> 5.0)
schema_to_scaffold schema_to_scaffold
select2-rails
shoulda-matchers (~> 3.1) shoulda-matchers (~> 3.1)
sidekiq sidekiq
simple_form simple_form

View File

@@ -77,6 +77,9 @@ For Using Star Printer
**_ Need to change these print settings 1) settings/print_settings/unique_code => OrderItemStarPdf 2) settings/print_settings/unique_code => ReceiptBillStarPdf 3) settings/print_settings/unique_code => SaleItemsStarPdf **_ Need to change these print settings 1) settings/print_settings/unique_code => OrderItemStarPdf 2) settings/print_settings/unique_code => ReceiptBillStarPdf 3) settings/print_settings/unique_code => SaleItemsStarPdf
_** Other print settings aren't need to change. _** Other print settings aren't need to change.
For Cloud ActionCable Print
settings/lookups => { type: print_settings, name: ActionCable, value: 1 }
For Show Sale Items Summary at CloseCashierPrint 1) settings/print_settings For Show Sale Items Summary at CloseCashierPrint 1) settings/print_settings
a) Check => Shift Sale Items a) Check => Shift Sale Items

View File

@@ -402,17 +402,17 @@ $(document).on('turbolinks:load', function() {
url: '/oqs/print/print/'+assigned_item_id, url: '/oqs/print/print/'+assigned_item_id,
data: params, data: params,
success: function(result){ success: function(result){
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
} }
} }
location.reload(); location.reload();
} }
}); });
}); });
// Print Order Summary // Print Order Summary
@@ -428,10 +428,12 @@ $(document).on('turbolinks:load', function() {
url: '/oqs/print/print_order_summary/'+assigned_item_id, url: '/oqs/print/print_order_summary/'+assigned_item_id,
data: params, data: params,
success: function(result){ success: function(result){
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
} }
} }
location.reload(); location.reload();

View File

@@ -36,6 +36,7 @@
//= require custom.js //= require custom.js
//= require jquery-fileupload/basic //= require jquery-fileupload/basic
//= require induties/induties.js //= require induties/induties.js
//= require select2
$(document).ready(function() { $(document).ready(function() {
$('.count-to').countTo(); $('.count-to').countTo();

View File

@@ -752,6 +752,7 @@ function print_receipt(){
url: "/origami/sale/"+sale_id+"/doemal_order/payment/print", url: "/origami/sale/"+sale_id+"/doemal_order/payment/print",
data: params, data: params,
success:function(result){ success:function(result){
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
@@ -773,6 +774,7 @@ function print_receipt(){
}); });
} }
} }
}
}); });
} }
/* pdf print out */ /* pdf print out */

View File

@@ -12,6 +12,8 @@
@import "BSBMaterial/themes/all-themes"; @import "BSBMaterial/themes/all-themes";
@import "reset"; @import "reset";
@import "induties/assign_in_duties"; @import "induties/assign_in_duties";
@import "select2";
@import "select2-material";
/*@import "bootstrap-select/css/bootstrap-select.min";*/ /*@import "bootstrap-select/css/bootstrap-select.min";*/

View File

@@ -0,0 +1,231 @@
.select2-container--material {
width: 100% !important; }
.select2-container--material .select2-selection--single {
background-color: transparent;
border: none;
border-bottom: 1px solid rgba(0,0,0,0.26);
border-radius: 0;
box-shadow: none;
box-sizing: content-box;
height: auto;
margin: 0;
outline: none;
padding: 0.46875rem 0 0.40625rem 0;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; }
.select2-container--material .select2-selection--single .select2-selection__rendered {
color: #444;
font-size: 1rem;
line-height: 18px;
padding-left: 0; }
.select2-container--material .select2-selection--single .select2-selection__clear {
cursor: pointer;
float: right;
font-weight: bold; }
.select2-container--material .select2-selection--single .select2-selection__placeholder {
color: #999; }
.select2-container--material .select2-selection--single .select2-selection__arrow {
height: 20px;
margin: 0.5rem 0 0.2rem 0;
position: absolute;
line-height: 1rem;
top: 1px;
right: 1px;
width: 20px; }
.select2-container--material .select2-selection--single .select2-selection__arrow b {
border-color: #888 transparent transparent transparent;
border-style: solid;
border-width: 5px 4px 0 4px;
height: 0;
left: 50%;
margin-left: -4px;
margin-top: -2px;
position: absolute;
top: 50%;
width: 0; }
.select2-container--material[dir="rtl"] .select2-selection--single .select2-selection__clear {
float: left; }
.select2-container--material[dir="rtl"] .select2-selection--single .select2-selection__arrow {
left: 1px;
right: auto; }
.select2-container--material.select2-container--disabled .select2-selection--single {
background-color: #eee;
cursor: default; }
.select2-container--material.select2-container--disabled .select2-selection--single .select2-selection__clear {
display: none; }
.select2-container--material.select2-container--open .select2-selection--single .select2-selection__arrow b {
border-color: transparent transparent #888 transparent;
border-width: 0 4px 5px 4px; }
.select2-container--material .select2-selection--multiple {
background-color: transparent;
border: none;
border-bottom: 1px solid #ced4da;
border-radius: 0;
box-shadow: none;
box-sizing: content-box;
cursor: text;
height: auto;
margin: 0;
outline: none;
padding: 5px 0 0 0;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; }
.select2-container--material .select2-selection--multiple .select2-selection__rendered {
box-sizing: border-box;
list-style: none;
margin: 0;
padding: 0 5px;
width: 100%; }
.select2-container--material .select2-selection--multiple .select2-selection__rendered li {
list-style: none; }
.select2-container--material .select2-selection--multiple .select2-selection__placeholder {
color: #999;
margin-top: 5px;
float: left; }
.select2-container--material .select2-selection--multiple .select2-selection__clear {
cursor: pointer;
float: right;
font-weight: bold;
margin-top: 5px;
margin-right: 10px; }
.select2-container--material .select2-selection--multiple .select2-selection__choice {
background-color: #ffca28;
border-radius: 16px;
color: rgba(0, 0, 0, 0.6);
cursor: default;
float: left;
margin-right: 5px;
margin-top: 6px;
padding: 0 12px; }
.select2-container--material .select2-selection--multiple .select2-selection__choice__remove {
cursor: pointer;
display: inline-block;
font-weight: bold;
float: right;
margin-left: 5px; }
.select2-container--material .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #333; }
.select2-container--material[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--material[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--material[dir="rtl"] .select2-selection--multiple .select2-search--inline {
float: right; }
.select2-container--material[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
margin-left: 5px;
margin-right: auto; }
.select2-container--material[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
margin-left: 2px;
margin-right: auto; }
.select2-container--material.select2-container--disabled .select2-selection--multiple {
background-color: #eee;
cursor: default; }
.select2-container--material.select2-container--disabled .select2-selection__choice__remove {
display: none; }
.select2-container--material.select2-container--open.select2-container--above .select2-selection--single, .select2-container--material.select2-container--open.select2-container--above .select2-selection--multiple {
border-top-left-radius: 0;
border-top-right-radius: 0; }
.select2-container--material.select2-container--open.select2-container--below .select2-selection--single, .select2-container--material.select2-container--open.select2-container--below .select2-selection--multiple {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; }
.select2-container--material.select2-container--focus .select2-selection--single {
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
outline: 0; }
.select2-container--material.select2-container--focus .select2-selection--multiple {
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
outline: 0; }
.select2-container--material .select2-search--dropdown .select2-search__field {
border: none;
border-bottom: 1px solid #ced4da;
border-radius: 0;
outline: none; }
.select2-container--material .select2-search--dropdown .select2-search__field:focus:not([readonly]) {
box-shadow: 0 1px 0 0 #ced4da;
border-bottom: 1px solid #ced4da; }
.select2-container--material .select2-search--inline .select2-search__field {
background: transparent;
border: none !important;
outline: 0;
box-shadow: none !important;
-webkit-appearance: textfield; }
.select2-container--material .select2-results > .select2-results__options {
overflow-y: auto; }
.select2-container--material .select2-results__option[role=group] {
padding: 0; }
.select2-container--material .select2-results__option[aria-disabled=true] {
color: #999; }
.select2-container--material .select2-results__option[aria-selected=true] {
background-color: #ddd; }
.select2-container--material .select2-results__option .select2-results__option {
padding-left: 1em; }
.select2-container--material .select2-results__option .select2-results__option .select2-results__group {
padding-left: 0; }
.select2-container--material .select2-results__option .select2-results__option .select2-results__option {
margin-left: -1em;
padding-left: 2em; }
.select2-container--material .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -2em;
padding-left: 3em; }
.select2-container--material .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -3em;
padding-left: 4em; }
.select2-container--material .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -4em;
padding-left: 5em; }
.select2-container--material .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -5em;
padding-left: 6em; }
.select2-container--material .select2-results__option--highlighted[aria-selected] {
background-color: #3f729b;
color: white; }
.select2-container--material .select2-results__group {
cursor: default;
display: block;
padding: 6px; }
.select2-dropdown {
background-color: white;
border: 1px solid #ced4da;
border-radius: 4px;
box-sizing: border-box;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
display: block;
position: absolute;
left: -100000px;
width: 100%;
z-index: 1051;
-webkit-box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); }
.select2-results {
display: block; }
.select2-results__options {
list-style: none;
margin: 0;
padding: 0; }
.select2-results__option {
padding: 6px;
user-select: none;
-webkit-user-select: none; }
.select2-results__option[aria-selected] {
cursor: pointer; }
.select2-container--open .select2-dropdown {
left: 0; }
.select2-container--open .select2-dropdown--above {
border-bottom: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; }
.select2-container--open .select2-dropdown--below {
border-top: none;
border-top-left-radius: 0;
border-top-right-radius: 0; }
.select2-search--dropdown {
display: block;
padding: 4px; }
.select2-search--dropdown .select2-search__field {
padding: 4px;
width: 100%;
box-sizing: border-box; }
.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button {
-webkit-appearance: none; }
.select2-search--dropdown.select2-search--hide {
display: none; }

View File

@@ -51,7 +51,6 @@ class Oqs::PrintController < ApplicationController
ai.save ai.save
end end
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil,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" if ENV["SERVER_MODE"] == "cloud"
result = { result = {
:filepath => filename, :filepath => filename,
@@ -119,7 +118,6 @@ class Oqs::PrintController < ApplicationController
ai.save ai.save
end end
# filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil,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" if ENV["SERVER_MODE"] == "cloud"
result = { result = {
:filepath => filename, :filepath => filename,

View File

@@ -1,2 +1,5 @@
module PrintSettingsHelper module PrintSettingsHelper
def print_settings
tag.div id: 'print_settings', class: 'hidden', data: { action_cable: Lookup.collection_of('print_settings').any? { |x| x == ["ActionCable", "1"] } }
end
end end

View File

@@ -39,16 +39,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end # end
def print_close_cashier(printer_settings, cashier_terminal, shift_sale, sale_items, total_other_charges_info, shop_details, sale_taxes, other_payment, amount, discount, member_discount, total_dinein, total_takeway, total_other_charges, total_waste, total_spoile, total_credit_payments, payment_methods, other_charges) def print_close_cashier(printer_settings, cashier_terminal, shift_sale, sale_items, total_other_charges_info, shop_details, sale_taxes, other_payment, amount, discount, member_discount, total_dinein, total_takeway, total_other_charges, total_waste, total_spoile, total_credit_payments, payment_methods, other_charges)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
if !sale_items.blank? or !sale_items.nil? if !sale_items.blank? or !sale_items.nil?
@account_cate_count = Hash.new {|hash, key| hash[key] = 0} @account_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0} @menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1} sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
@totalByAccount = Hash.new {|hash, key| hash[key] = 0} @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
end end
@@ -77,9 +75,10 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
#no print in cloud server #no print in cloud server
if ENV["SERVER_MODE"] != "cloud" if ENV["SERVER_MODE"] != "cloud"
self.print(filename, cashier_terminal.printer_name) self.print(filename, cashier_terminal.printer_name)
end
else else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: "Cashier", queue: cashier_terminal.printer_name,
unique_code: print_settings.unique_code, unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies, print_copies: print_settings.print_copies,
data: { data: {
@@ -104,6 +103,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
end end
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges) def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
filename = "tmp/reports_sale_items.pdf" filename = "tmp/reports_sale_items.pdf"
if print_settings.unique_code == "SaleItemsPdf" if print_settings.unique_code == "SaleItemsPdf"
@@ -119,9 +119,10 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
#no print in cloud server #no print in cloud server
if ENV["SERVER_MODE"] != "cloud" if ENV["SERVER_MODE"] != "cloud"
self.print(filename, print_settings.printer_name) self.print(filename, print_settings.printer_name)
end
else else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: 'Cashier', queue: print_settings.printer_name,
unique_code: print_settings.unique_code, unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies, print_copies: print_settings.print_copies,
data: { data: {

View File

@@ -1,23 +1,22 @@
class Printer::OrderQueuePrinter < Printer::PrinterWorker class Printer::OrderQueuePrinter < Printer::PrinterWorker
def print_order_item(print_settings, oqs, order_id, order_item_id, print_status, before_updated_qty="", options="") def print_order_item(print_settings, oqs, order_id, order_item_id, print_status, before_updated_qty="", options="")
booking_id = Booking.get_booking_id(order_id)
order_item = print_query('order_item', order_item_id).first #OrderItem.find_by_item_code(item_code)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
# Must be one print # Must be one print
if print_settings.print_copies == 0 if print_settings.print_copies == 0
print_settings.print_copies = 1 print_settings.print_copies = 1
print_settings.save! print_settings.save!
end end
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code) options = order_item.options
options = order_item[0].options
# check for item not to show # check for item not to show
# if order_item[0].price != 0 pdf = print_settings.unique_code.constantize.new(print_settings, order_item, print_status, options, oqs.use_alternate_name, before_updated_qty)
pdf = print_settings.unique_code.constantize.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
booking_id = Booking.get_booking_id(order_id)
# end
shop = Shop.current_shop shop = Shop.current_shop
directory_name = 'public/orders_'+shop.shop_code directory_name = "public/orders_#{shop.shop_code}"
Dir.mkdir(directory_name) unless File.exists?(directory_name) Dir.mkdir(directory_name) unless File.exists?(directory_name)
filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf" filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf"
@@ -26,28 +25,30 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
if ENV["SERVER_MODE"] != "cloud" if ENV["SERVER_MODE"] != "cloud"
self.print(filename, oqs.printer_name) self.print(filename, oqs.printer_name)
end
return filename, order_id, oqs.printer_name
else else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: oqs.station_name, queue: oqs.station_name,
unique_code: print_settings.unique_code, unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies, print_copies: print_settings.print_copies,
data: { data: {
order_item: order_item[0].as_json(methods: :type), order_item: order_item.as_json(methods: :type),
print_status: print_status.gsub(/[()]/, ""), print_status: print_status.gsub(/[()]/, ""),
booking_id: booking_id, booking_id: booking_id,
precision: print_settings.precision precision: print_settings.precision
} }
) )
end end
#For print copy
# pdf.render_file filename.gsub(".","-copy.")
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
return filename, order_id, oqs.printer_name
end end
# Query for per order # Query for per order
def print_order_summary(print_settings, oqs, order_id, order_items, print_status, before_updated_qty="", options="") def print_order_summary(print_settings, oqs, order_id, order_items, print_status, before_updated_qty="", options="")
booking_id = Booking.get_booking_id(order_id) #order[0].order_id
order = print_query('order_summary', order_id)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
@@ -61,35 +62,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
directory_name = "public/orders_#{shop.shop_code}" directory_name = "public/orders_#{shop.shop_code}"
Dir.mkdir(directory_name) unless File.exists?(directory_name) 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 = directory_name + "/order_item_#{order_id}.pdf"
# filename = "tmp/order_item_#{order_id}" + ".pdf"
# For Item Options
options = odi.options == "[]" ? "" : odi.options
# check for item not to show
#if odi.price != 0
pdf = print_settings.unique_code.constantize.new(print_settings, odi_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print(filename, oqs.printer_name)
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
end
#end
end
# For Print Order Summary
else
booking_id = Booking.get_booking_id(order_id) #order[0].order_id
order = print_query('order_summary', order_id)
filename = directory_name + "/order_summary_#{order_id}.pdf" filename = directory_name + "/order_summary_#{order_id}.pdf"
# filename = "tmp/order_summary_#{order_id}" + ".pdf" # filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, order_items, oqs.use_alternate_name, before_updated_qty) pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, order_items, oqs.use_alternate_name, before_updated_qty)
@@ -98,6 +70,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
#no print in cloud server #no print in cloud server
if ENV["SERVER_MODE"] != "cloud" if ENV["SERVER_MODE"] != "cloud"
self.print(filename, oqs.printer_name) self.print(filename, oqs.printer_name)
end
return filename, order_id, oqs.printer_name
else else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: oqs.station_name, queue: oqs.station_name,
@@ -108,15 +83,10 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order: order.as_json(methods: :type), order: order.as_json(methods: :type),
print_status: "", print_status: "",
booking_id: booking_id, booking_id: booking_id,
precision: print_settings.precision} precision: print_settings.precision
}
) )
end end
#For print copy
# pdf.render_file filename.gsub(".","-copy.")
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
end
return filename, order_id, oqs.printer_name
end end
# Print for orders in booking # Print for orders in booking

View File

@@ -91,6 +91,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Bill Receipt Print #Bill Receipt Print
def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
@@ -106,43 +107,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) pdf = ReceiptBillOrderPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation)
end end
if ENV["SERVER_MODE"] == "cloud"
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: "Cashier",
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
shop_details: shop_details.as_json,
body: { sale_data: sale_data,
booking: sale_data.bookings,
dining_facility: sale_data.bookings[0].dining_facility.as_json(methods: :type),
sale_taxes: sale_data.sale_taxes,
latest_order_no: latest_order_no,
sale_items: sale_items,
precision: print_settings.precision,
delimiter: print_settings.delimiter,
member_info: member_info,
customer_name: customer_name,
rebate_amount: rebate_amount,
current_balance: balance,
card_data: card_data,
card_balance_amount: card_balance_amount,
discount_price_by_accounts: discount_price_by_accounts,
item_price_by_accounts: item_price_by_accounts,
sale_payments: sale_data.sale_payments,
},
footer: { printed_status: printed_status, footer_text: "Thank You! See you Again" }
}
)
end
# print as print copies in printer setting # print as print copies in printer setting
count = printer_settings.print_copies count = printer_settings.print_copies
# override print copies for print worker loop
# print_settings.print_copies = 1
# print_settings.save!
end end
directory_name = 'public/receipts' directory_name = 'public/receipts'
Dir.mkdir(directory_name) unless File.exists?(directory_name) Dir.mkdir(directory_name) unless File.exists?(directory_name)
Rails.logger.debug "############## dir::" + directory_name Rails.logger.debug "############## dir::" + directory_name
@@ -169,8 +137,40 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end end
end end
end end
Rails.logger.debug "############## filename::" + filename Rails.logger.debug "############## filename::" + filename
return filename, sale_data.receipt_no, cashier_terminal.printer_name return filename, sale_data.receipt_no, cashier_terminal.printer_name
else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: cashier_terminal.printer_name,
unique_code: print_settings.unique_code,
print_copies: print_settings.print_copies,
data: {
shop_details: shop_details.as_json,
body: { sale_data: sale_data,
booking: sale_data.bookings,
dining_facility: sale_data.bookings[0].dining_facility.as_json(methods: :type),
sale_taxes: sale_data.sale_taxes,
latest_order_no: latest_order_no,
sale_items: sale_items,
precision: print_settings.precision,
delimiter: print_settings.delimiter,
member_info: member_info,
customer_name: customer_name,
rebate_amount: rebate_amount,
current_balance: balance,
card_data: card_data,
card_balance_amount: card_balance_amount,
discount_price_by_accounts: discount_price_by_accounts,
item_price_by_accounts: item_price_by_accounts,
sale_payments: sale_data.sale_payments
},
footer: {
printed_status: printed_status, footer_text: "Thank You! See you Again"
}
}
)
end
end end
# stock check # stock check
@@ -198,6 +198,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Move Table Print #Move Table Print
def print_move_table(printer_settings, to, from, shop_detail, date, type, moved_by, order_items, oqs) def print_move_table(printer_settings, to, from, shop_detail, date, type, moved_by, order_items, oqs)
if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] }
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
@@ -213,6 +214,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#no print in cloud server #no print in cloud server
self.print("tmp/print_move_table.pdf", oqs.printer_name) self.print("tmp/print_move_table.pdf", oqs.printer_name)
end end
end
else else
ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}", ActionCable.server.broadcast("print_channel_#{Shop.current_shop.shop_code}",
queue: oqs.station_name, queue: oqs.station_name,

View File

@@ -195,6 +195,8 @@
</div> </div>
<input type="hidden" id="server_mode" value="<%=ENV["SERVER_MODE"]%>"> <input type="hidden" id="server_mode" value="<%=ENV["SERVER_MODE"]%>">
<%= print_settings %>
<script type="text/javascript"> <script type="text/javascript">
$(document).on('turbolinks:load', function() { $(document).on('turbolinks:load', function() {
$('#back').on('click', function () { $('#back').on('click', function () {
@@ -202,8 +204,6 @@
}); });
}); });
document.getElementById("defaultOpen").click(); document.getElementById("defaultOpen").click();
</script> </script>
<style type="text/css"> <style type="text/css">

View File

@@ -597,6 +597,8 @@
</div> </div>
</div> </div>
<%= print_settings %>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog"> <div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@@ -973,12 +975,14 @@
if((receipt_no!=undefined) && (receipt_no!="")) if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,""); createReceiptNoInFirstBillData(receipt_no,"");
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -1029,12 +1033,15 @@
receipt_no = ($("#receipt_no").html()).trim(); receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!="")) if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type); createReceiptNoInFirstBillData(receipt_no,type);
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -1055,7 +1062,6 @@
success:function(result){ success:function(result){
} }
}); });
} }
$('#pay').on('click', function () { $('#pay').on('click', function () {
@@ -1267,12 +1273,14 @@
url: ajax_url, url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
window.location.href = '/origami/'; window.location.href = '/origami/';
} }
}); });
@@ -1376,12 +1384,14 @@
data: "remark="+ remark + "&sale_id=" + sale_id, data: "remark="+ remark + "&sale_id=" + sale_id,
success: function (result) { success: function (result) {
console.log(result) console.log(result)
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
window.location.href = '/origami/'; window.location.href = '/origami/';
} }
}); });

View File

@@ -28,7 +28,7 @@
end end
%> %>
<!-- end count function --> <!-- end count function -->
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<% if request.user_agent.include? "Mobile" %> <% if request.user_agent.include? "Mobile" %>
<div class="row m-t-10" style="margin-left: 0.2rem"> <div class="row m-t-10" style="margin-left: 0.2rem">
<% else %> <% else %>
@@ -565,6 +565,10 @@
<p id="order_id" class="hidden"></p> <p id="order_id" class="hidden"></p>
<p id="status" class="hidden"></p> <p id="status" class="hidden"></p>
<%= print_settings %>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<div class="modal fade" id="waiting_timeModal" tabindex="-1" role="dialog"> <div class="modal fade" id="waiting_timeModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document"> <div class="modal-dialog modal-md" role="document">
<div class="modal-content"> <div class="modal-content">

View File

@@ -315,6 +315,9 @@
</div> </div>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>"> <input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
</div> </div>
<%= print_settings %>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog"> <div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@@ -1018,12 +1021,14 @@ $(document).ready(function(){
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print", url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
data: params, data: params,
success:function(result){ success:function(result){
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
if (pdf_view ==1) { if (pdf_view ==1) {
var flag = localStorage.getItem("trans_flag"); var flag = localStorage.getItem("trans_flag");
@@ -1323,12 +1328,14 @@ $(document).ready(function(){
title: "Information!", title: "Information!",
text: 'Thank You !', text: 'Thank You !',
}, function () { }, function () {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
var flag = localStorage.getItem("trans_flag"); var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){ if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id; window.location.href = '/transactions/sales/'+sale_id;
@@ -1369,12 +1376,14 @@ $(document).ready(function(){
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) {result success: function (result) {result
customer_display_view(null,"reload"); customer_display_view(null,"reload");
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
var flag = localStorage.getItem("trans_flag"); var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){ if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id; window.location.href = '/transactions/sales/'+sale_id;
@@ -1412,12 +1421,14 @@ $(document).ready(function(){
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) { success: function (result) {
// console.log(result) // console.log(result)
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
var flag = localStorage.getItem("trans_flag"); var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){ if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id; window.location.href = '/transactions/sales/'+sale_id;

View File

@@ -234,6 +234,8 @@
</div> </div>
</div> </div>
<%= print_settings %>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog"> <div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@@ -326,11 +328,13 @@ $(document).ready(function(){
type: "GET", type: "GET",
url: ajax_url, url: ajax_url,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -396,10 +400,12 @@ $(document).ready(function(){
url: ajax_url, url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
}
window.location.href = '/origami/'+cashier_type; window.location.href = '/origami/'+cashier_type;
} }
}); });
@@ -437,11 +443,13 @@ function check_emp_access_code(access_code,type) {
type: "GET", type: "GET",
url: ajax_url, url: ajax_url,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });

View File

@@ -624,6 +624,8 @@
</div> </div>
</div> </div>
<%= print_settings %>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog"> <div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@@ -1067,12 +1069,14 @@ $("#first_bill").on('click', function(){
receipt_no = ($("#receipt_no").html()).trim(); receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!="")) if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,""); createReceiptNoInFirstBillData(receipt_no,"");
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -1107,13 +1111,14 @@ $(".choose_payment").on('click', function () {
if((receipt_no!=undefined) && (receipt_no!="")) if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type); createReceiptNoInFirstBillData(receipt_no,type);
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -1350,12 +1355,14 @@ $('#add_invoice').on('click',function(){
url: ajax_url, url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
window.location.href = '/origami/'; window.location.href = '/origami/';
} }
}); });
@@ -1442,12 +1449,14 @@ $('#add_invoice').on('click',function(){
data: "remark="+ remark + "&sale_id=" + sale_id, data: "remark="+ remark + "&sale_id=" + sale_id,
success: function (result) { success: function (result) {
console.log(result) console.log(result)
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
window.location.href = '/origami/'; window.location.href = '/origami/';
} }
}); });

View File

@@ -314,6 +314,8 @@
</div> </div>
</div> </div>
<%= print_settings %>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog"> <div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
@@ -440,11 +442,13 @@ $('#reprint').on('click', function () {
type: "GET", type: "GET",
url: ajax_url, url: ajax_url,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -542,12 +546,14 @@ $(document).on('click', '.access_modal', function(event){
type: "GET", type: "GET",
url: ajax_url, url: ajax_url,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });

View File

@@ -164,6 +164,8 @@
</div> </div>
</div> </div>
<%= print_settings %>
<!-- membership paymentmodal --> <!-- membership paymentmodal -->
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>"> <input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<span class="hidden" id="member_discount"><%= @membership.discount%></span> <span class="hidden" id="member_discount"><%= @membership.discount%></span>
@@ -243,7 +245,6 @@
</div> </div>
</div> </div>
</div> </div>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<div class="modal fade" id="AccessCodeModal" tabindex="-1" role="dialog"> <div class="modal fade" id="AccessCodeModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-sm" role="document"> <div class="modal-dialog modal-sm" role="document">
@@ -303,31 +304,6 @@ $(document).ready(function(){
}) })
}); });
// $('#pay').on('click',function() {
// window.location.href = '/origami/sale/<%= @sale.id %>/payment';
// });
// Print for first bill
// $("#first_bill").on('click', function () {
// var sale_id = '<%= @sale.id %>';
// var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
// $.ajax({
// type: "GET",
// url: ajax_url,
// success: function (result) {
// receipt_no = ($("#receipt_no").html()).trim();
// if((receipt_no!=undefined) && (receipt_no!=""))
// createReceiptNoInFirstBillData(receipt_no,"");
// // For Server Print - from jade
// if ($("#server_mode").val() == "cloud") {
// code2lab.printFile(result.filepath.substr(6), result.printer_url);
// }
// location.reload();
// }
// });
// });
// Print for first bill // Print for first bill
$("#first_bill").on('click', function () { $("#first_bill").on('click', function () {
swal({ swal({
@@ -353,13 +329,14 @@ $(document).ready(function(){
receipt_no = ($("#receipt_no").html()).trim(); receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!="")) if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,""); createReceiptNoInFirstBillData(receipt_no,"");
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -389,12 +366,15 @@ $(document).ready(function(){
receipt_no = ($("#receipt_no").html()).trim(); receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!="")) if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type); createReceiptNoInFirstBillData(receipt_no,type);
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
location.reload(); location.reload();
} }
}); });
@@ -463,12 +443,14 @@ $('#void').on('click',function () {
url: ajax_url, url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id + "&access_code=" + access_code , data: "remark="+ remark + "&sale_id=" + sale_id + "&access_code=" + access_code ,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
window.location.href = '/origami'; window.location.href = '/origami';
} }
}); });
@@ -502,12 +484,14 @@ $('#foc').click(function() {
title: "Information!", title: "Information!",
text: 'Thank You !', text: 'Thank You !',
}, function () { }, function () {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
window.location.href = '/origami'; window.location.href = '/origami';
}); });
} }
@@ -531,7 +515,6 @@ $(document).on('click', '.access_modal', function(event){
url: url, url: url,
data: {}, data: {},
success: function (result) { success: function (result) {
console.log(result)
if (result.status == true) { if (result.status == true) {
createAccessCode(code); createAccessCode(code);
if (type == "edit") { if (type == "edit") {

View File

@@ -5,7 +5,7 @@
<%= simple_form_for(@print_setting) do |f| %> <%= simple_form_for(@print_setting) do |f| %>
<%= f.error_notification %> <%= f.error_notification %>
<div class="form-inputs"> <div class="form-inputs p-l-10">
<%= f.input :name %> <%= f.input :name %>
<%= f.input :unique_code %> <%= f.input :unique_code %>
<%= f.input :template %> <%= f.input :template %>
@@ -13,11 +13,8 @@
<%= f.input :header_font_size %> <%= f.input :header_font_size %>
<%= f.input :item_font_size %> <%= f.input :item_font_size %>
<% if(@server_mode != 'cloud') %> <%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: "Please Select", class: "mdb-select md-form" %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: "Please Select" %>
<% else %>
<%= f.input :printer_name, :as => :select, :collection => [], include_blank: "Please Select" %>
<% end %>
<%= f.input :brand_name %> <%= f.input :brand_name %>
<%= f.input :printer_type %> <%= f.input :printer_type %>
<%= f.input :api_settings %> <%= f.input :api_settings %>
@@ -45,7 +42,7 @@
</div> </div>
<div class="form-actions"> <div class="form-actions p-l-10">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div> </div>
<% end %> <% end %>
@@ -87,7 +84,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
var serverMode = "<%= @server_mode %>"; var serverMode = "<%= @server_mode %>";
if(serverMode == 'cloud'){ if(serverMode == 'cloud' && typeof code2lab != 'undefined'){
var printers = code2lab.getPrinters(); var printers = code2lab.getPrinters();
var printerInfo = JSON.parse([printers]); var printerInfo = JSON.parse([printers]);
var select = $("#print_setting_printer_name"); var select = $("#print_setting_printer_name");
@@ -100,6 +97,8 @@
}); });
} }
$('#print_setting_printer_name option:first').attr('disabled', true);
if ($('#sale_items').val() == '1') { if ($('#sale_items').val() == '1') {
$('#sale_items').prop('checked', true); $('#sale_items').prop('checked', true);
} }
@@ -121,6 +120,11 @@
$("#print_setting_api_settings").val($(this).val()); $("#print_setting_api_settings").val($(this).val());
} }
}); });
$("#print_setting_printer_name").select2({
theme: 'material',
tags: true
})
}); });
function isNumberKey(evt) { function isNumberKey(evt) {

View File

@@ -12,11 +12,9 @@
<%= f.input :auto_print_receipt %> <%= f.input :auto_print_receipt %>
<%= f.label "Select Zones", :class => 'control-label' %> <%= f.label "Select Zones", :class => 'control-label' %>
<%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'checkbox form-group'%> <%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'checkbox form-group'%>
<% if(@server_mode != 'cloud') %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %> <%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: "Please Select", class: "mdb-select md-form" %>
<% else %>
<%= f.input :printer_name, :as => :select, :collection => [], include_blank: false %>
<% end %>
<%= f.input :font %> <%= f.input :font %>
<%= f.input :font_size %> <%= f.input :font_size %>
<%= f.input :show_tax %> <%= f.input :show_tax %>
@@ -24,7 +22,7 @@
<%= f.input :show_guest_info %> <%= f.input :show_guest_info %>
</div> </div>
<div class="form-actions"> <div class="form-actions p-l-10">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div> </div>
<% end %> <% end %>
@@ -65,7 +63,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
var serverMode = "<%= @server_mode %>"; var serverMode = "<%= @server_mode %>";
if(serverMode == 'cloud'){ if(serverMode == 'cloud' && typeof code2lab != 'undefined'){
var printers = code2lab.getPrinters(); var printers = code2lab.getPrinters();
var printerInfo = JSON.parse([printers]); var printerInfo = JSON.parse([printers]);
var select = $("#cashier_terminal_printer_name"); var select = $("#cashier_terminal_printer_name");
@@ -77,5 +75,12 @@
.text(value.deviceName)); .text(value.deviceName));
}); });
} }
$('#cashier_terminal_printer_name option:first').attr('disabled', true);
$("#cashier_terminal_printer_name").select2({
theme: 'material',
tags: true
})
}); });
</script> </script>

View File

@@ -1,10 +1,3 @@
<style type="text/css">
div.form-inputs span{
padding: 1%;
}
</style>
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8"> <div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<div class="card"> <div class="card">
@@ -12,22 +5,11 @@ div.form-inputs span{
<%= simple_form_for([:settings,@settings_order_queue_station]) do |f| %> <%= simple_form_for([:settings,@settings_order_queue_station]) do |f| %>
<%= f.error_notification %> <%= f.error_notification %>
<div class="form-inputs p-l-15"> <div class="form-inputs p-l-10">
<%= f.input :station_name %> <%= f.input :station_name %>
<%= f.input :is_active %> <%= f.input :is_active %>
<% if(@server_mode != 'cloud') %> <%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: "Please Select", class: "mdb-select md-form" %>
<div class="form-group select required order_queue_station_printer_name bmd-form-group is-filled focused">
<label class="control-label select required bmd-label-static" for="order_queue_station_printer_name"><abbr title="required">*</abbr> Printer name</label>
<select class="form-control select required" name="order_queue_station[printer_name]" id="order_queue_station_printer_name">
<% Printer::PrinterWorker.printers.each do |printer| %>
<option value="<%= printer.force_encoding("UTF-8") %>"><%= printer.force_encoding("UTF-8") %></option>
<% end %>
</select>
</div>
<% else %>
<%= f.input :printer_name, :as => :select, :collection => [], include_blank: false %>
<% end %>
<!-- <%= f.input :font_size %> -->
<%= f.input :print_copy %> <%= f.input :print_copy %>
<%= f.hidden_field :processing_items %> <%= f.hidden_field :processing_items %>
<%= f.label "Select Zones", :class => 'control-label' %> <%= f.label "Select Zones", :class => 'control-label' %>
@@ -38,7 +20,7 @@ div.form-inputs span{
<%= f.input :auto_print %> <%= f.input :auto_print %>
</div> </div>
<div class="form-actions p-l-15"> <div class="form-actions p-l-10">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div> </div>
<% end %> <% end %>
@@ -76,7 +58,7 @@ div.form-inputs span{
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
var serverMode = "<%= @server_mode %>"; var serverMode = "<%= @server_mode %>";
if(serverMode == 'cloud'){ if(serverMode == 'cloud' && typeof code2lab != 'undefined'){
var printers = code2lab.getPrinters(); var printers = code2lab.getPrinters();
var printerInfo = JSON.parse([printers]); var printerInfo = JSON.parse([printers]);
var select = $("#order_queue_station_printer_name"); var select = $("#order_queue_station_printer_name");
@@ -89,4 +71,11 @@ div.form-inputs span{
}); });
} }
}); });
$('#order_queue_station_printer_name option:first').attr('disabled', true);
$("#order_queue_station_printer_name").select2({
theme: 'material',
tags: true
})
</script> </script>

View File

@@ -280,7 +280,7 @@
</div> </div>
</div> </div>
</div> </div>
<%= print_settings %>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>"> <input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<span class="hidden" id="member_discount"><%= @membership.discount%></span> <span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @sale.customer.membership_id rescue 0%></span> <span class="hidden" id="membership_id"><%= @sale.customer.membership_id rescue 0%></span>
@@ -405,12 +405,14 @@
url: ajax_url, url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) { success: function (result) {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade // For Server Print - from jade
if ($("#server_mode").val() == "cloud") { if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){ if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url); code2lab.printFile(result.filepath.substr(6), result.printer_url);
} }
} }
}
window.location.href = '/transactions/sales/'; window.location.href = '/transactions/sales/';
} }
}); });