Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_material_ui
This commit is contained in:
@@ -61,7 +61,7 @@ $(document).on('turbolinks:load', function() {
|
||||
if (data[field]["options"] == "[]" || data[field]["options"] == "") {
|
||||
var options = "";
|
||||
}else{
|
||||
var options = data.options;
|
||||
var options = data[field]["options"];
|
||||
}
|
||||
|
||||
var date = new Date(data[field]["created_at"]);
|
||||
@@ -80,7 +80,7 @@ $(document).on('turbolinks:load', function() {
|
||||
+'<span class="order-qty"> [x'+ data[field]["qty"] +'] </span>'
|
||||
+'</p>'
|
||||
|
||||
+'<p class="card-text item-options">'+ options +'</p>'
|
||||
+'<br/><p class="card-text item-options">'+ options +'</p>'
|
||||
|
||||
+'<span class="card-text">'
|
||||
+'<span class="text-muted">Order at - '
|
||||
@@ -223,8 +223,9 @@ $(document).on('turbolinks:load', function() {
|
||||
var params = { 'options':options };
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
type: 'POST',
|
||||
url: '/oqs/print/print/'+assigned_item_id,
|
||||
data: params,
|
||||
success: function(data){ }
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
|
||||
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
|
||||
var options = "";
|
||||
}else{
|
||||
var options = items.options;
|
||||
var options = items[field]["options"];
|
||||
}
|
||||
//for count
|
||||
test = document.getElementsByClassName("oqs_count");
|
||||
@@ -49,7 +49,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
|
||||
+'<span class="order-qty"> [x'+ items[field]["qty"] +'] </span>'
|
||||
+'</p>'
|
||||
|
||||
+'<p class="card-text item-options">'+ options +'</p>'
|
||||
+'<br/><p class="card-text item-options">'+ options +'</p>'
|
||||
|
||||
+'<span class="card-text">'
|
||||
+'<span class="text-muted">Order at - '
|
||||
|
||||
@@ -12,7 +12,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.pdf"
|
||||
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
# check for item not to show
|
||||
# if order_item[0].price != 0
|
||||
@@ -47,7 +47,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item.pdf"
|
||||
filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -68,7 +68,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary.pdf"
|
||||
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
@@ -96,7 +96,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item.pdf"
|
||||
filename = "tmp/order_item_#{booking_id}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -120,7 +120,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/booking_summary.pdf"
|
||||
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
|
||||
@@ -179,7 +179,7 @@ class SalePayment < ApplicationRecord
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
sale_update_payment_status(self.received_amount)
|
||||
sale_update_payment_status(self.received_amount,true)
|
||||
return payment_status
|
||||
end
|
||||
|
||||
@@ -290,7 +290,7 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount)
|
||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||
self.sale.save!
|
||||
@@ -349,10 +349,12 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
self.sale.save!
|
||||
table_update_status(sObj)
|
||||
|
||||
# if paid_amount != "0.0"
|
||||
|
||||
if check_foc
|
||||
update_shift
|
||||
# end
|
||||
elsif paid_amount != "0.0"
|
||||
update_shift
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -105,18 +105,22 @@ class OrderItemPdf < Prawn::Document
|
||||
end
|
||||
|
||||
if alt_name
|
||||
move_down 4
|
||||
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
if !(order_item.alt_name).empty?
|
||||
move_down 4
|
||||
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
move_down 5
|
||||
if !options.empty?
|
||||
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
|
||||
# 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
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
129
app/pdf/order_item_slim_pdf.rb
Normal file
129
app/pdf/order_item_slim_pdf.rb
Normal file
@@ -0,0 +1,129 @@
|
||||
class OrderItemSlimPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
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(print_settings,order_item_slim, print_status, options, alt_name)
|
||||
self.page_width = print_settings.page_width
|
||||
self.page_height = print_settings.page_height
|
||||
self.margin = 0
|
||||
self.price_width = 40 # No Need for item
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
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=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
|
||||
# db font setup
|
||||
if print_settings.font != ""
|
||||
font_families.update("#{print_settings.font}" => {
|
||||
:normal => "public/fonts/#{print_settings.font}.ttf",
|
||||
:italic => "public/fonts/#{print_settings.font}.ttf",
|
||||
:bold => "public/fonts/#{print_settings.font}.ttf",
|
||||
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
|
||||
})
|
||||
|
||||
font "#{print_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
|
||||
self.header_font_size = 11
|
||||
self.item_font_size = 9
|
||||
else
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
end
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
#font "public/fonts/Chinese.ttf"
|
||||
|
||||
text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
stroke_horizontal_rule
|
||||
move_down 1
|
||||
|
||||
#order_info
|
||||
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
|
||||
|
||||
# order items slim
|
||||
order_items_slim(order_item_slim, options, alt_name, print_settings.precision)
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
move_down 3
|
||||
end
|
||||
|
||||
# Write Order items to PDF
|
||||
def order_items_slim(order_item_slim, options, alt_name, precision)
|
||||
y_position = cursor
|
||||
|
||||
#Add Order Item
|
||||
add_order_items_slim(order_item_slim, options, alt_name, precision)
|
||||
|
||||
dash(1, :space => 1, :phase => 1)
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
move_down 1
|
||||
end
|
||||
|
||||
# Add order items slim under order info
|
||||
def add_order_items_slim(order_item_slim, options, alt_name, precision)
|
||||
y_position = cursor
|
||||
|
||||
move_down 1
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
# if alt_name
|
||||
# if !(order_item_slim.alt_name).empty?
|
||||
# move_down 1
|
||||
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||
# text "(#{order_item_slim.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
if !options.empty?
|
||||
move_down 1
|
||||
|
||||
# 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
|
||||
end
|
||||
move_down 1
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -122,19 +122,21 @@ class OrderSummaryPdf < Prawn::Document
|
||||
end
|
||||
|
||||
if alt_name
|
||||
move_down 4
|
||||
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
if !(odi.alt_name).empty?
|
||||
move_down 4
|
||||
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
move_down 5
|
||||
|
||||
# add option
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
if options != ""
|
||||
move_down 5
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
|
||||
155
app/pdf/order_summary_slim_pdf.rb
Normal file
155
app/pdf/order_summary_slim_pdf.rb
Normal file
@@ -0,0 +1,155 @@
|
||||
class OrderSummarySlimPdf < Prawn::Document
|
||||
include ActionView::Helpers::NumberHelper
|
||||
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(print_settings,order, print_status, order_items = nil,alt_name)
|
||||
self.page_width = print_settings.page_width
|
||||
self.page_height = print_settings.page_height
|
||||
self.margin = 0
|
||||
self.price_width = 40 # No Need for item
|
||||
self.qty_width = 40
|
||||
self.total_width = 40 # No Need for item
|
||||
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=90
|
||||
|
||||
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
# db font setup
|
||||
if print_settings.font != ""
|
||||
font_families.update("#{print_settings.font}" => {
|
||||
:normal => "public/fonts/#{print_settings.font}.ttf",
|
||||
:italic => "public/fonts/#{print_settings.font}.ttf",
|
||||
:bold => "public/fonts/#{print_settings.font}.ttf",
|
||||
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
|
||||
})
|
||||
|
||||
font "#{print_settings.font}"
|
||||
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
|
||||
|
||||
self.header_font_size = 11
|
||||
self.item_font_size = 9
|
||||
else
|
||||
self.header_font_size = 12
|
||||
self.item_font_size = 10
|
||||
end
|
||||
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
|
||||
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
|
||||
stroke_horizontal_rule
|
||||
move_down 1
|
||||
|
||||
#order_info
|
||||
order_info(order[0].order_id, order[0].order_by,order[0].order_at)
|
||||
|
||||
# order items
|
||||
if order_items == nil
|
||||
order_items(order, alt_name, print_settings.precision)
|
||||
else
|
||||
order_items(order_items, alt_name, print_settings.precision)
|
||||
end
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_no, order_by, order_at)
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
|
||||
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
|
||||
move_down 1
|
||||
end
|
||||
|
||||
# Write Order items to PDF
|
||||
def order_items(order_item, alt_name, precision)
|
||||
y_position = cursor
|
||||
|
||||
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 => :left
|
||||
end
|
||||
|
||||
stroke_horizontal_rule
|
||||
move_down 1
|
||||
|
||||
#Add Order Item
|
||||
add_order_items(order_item, alt_name, precision)
|
||||
|
||||
end
|
||||
|
||||
# Add order items under order info
|
||||
def add_order_items(order_item, alt_name, precision)
|
||||
y_position = cursor
|
||||
|
||||
move_down 1
|
||||
|
||||
order_item.each do|odi|
|
||||
# check for item not to show
|
||||
# if odi.price != 0
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
bounding_box([self.item_width,y_position], :width => self.qty_width) do
|
||||
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
|
||||
|
||||
end
|
||||
|
||||
if alt_name
|
||||
if !(odi.alt_name).empty?
|
||||
move_down 1
|
||||
font("public/fonts/NotoSansCJKtc-Regular.ttf") do
|
||||
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# add option
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
if options != ""
|
||||
move_down 1
|
||||
|
||||
y_position = cursor
|
||||
bounding_box([0,y_position], :width => self.item_width) do
|
||||
text "#{options}", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
move_down 1
|
||||
end
|
||||
|
||||
move_down 1
|
||||
|
||||
dash(1, :space => 1, :phase => 1)
|
||||
stroke_horizontal_line 0, (self.page_width - self.margin)
|
||||
move_down 1
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -84,8 +84,8 @@
|
||||
<%= qid.qty %>
|
||||
</span> ]
|
||||
</p>
|
||||
|
||||
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
||||
|
||||
<br/><p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
|
||||
|
||||
<span class="card-text">
|
||||
<span class="text-muted">Order at -
|
||||
|
||||
@@ -527,7 +527,7 @@
|
||||
window.location.href = '/origami/' + sale_id + '/other_charges'
|
||||
}
|
||||
else {
|
||||
alert("Please select an table!");
|
||||
swal ( "Oops" , "Please select an table!" , "warning" );
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -546,7 +546,7 @@
|
||||
window.location.href = '/origami/' + sale_id + '/discount'
|
||||
}
|
||||
else {
|
||||
alert("Please select an table!");
|
||||
swal ( "Oops" , "Please select an table!" , "warning" );
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -653,8 +653,16 @@
|
||||
url: ajax_url,
|
||||
data: 'dining_id=' + dining_id + "&sale_id=" + sale_id,
|
||||
success: function (result) {
|
||||
alert("Invoice updated")
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Invoice updated",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -498,7 +498,7 @@ $(document).ready(function(){
|
||||
window.location.href = '/origami/' + sale_id + '/discount'
|
||||
}
|
||||
else {
|
||||
alert("Please select an table!");
|
||||
swal ( "Oops" , "Please select an table!" , "warning" );
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -517,7 +517,7 @@ $(document).ready(function(){
|
||||
window.location.href = '/origami/' + sale_id + '/other_charges'
|
||||
}
|
||||
else {
|
||||
alert("Please select an table!");
|
||||
swal ( "Oops" , "Please select an table!" , "warning" );
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -600,8 +600,16 @@ $('#add_invoice').on('click',function(){
|
||||
url: ajax_url,
|
||||
data: 'dining_id='+ dining_id + "&sale_id=" + sale_id,
|
||||
success:function(result){
|
||||
alert("Invoice updated")
|
||||
window.location.reload();
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Invoice updated",
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -244,7 +244,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post "/:id", to: "edit#update"
|
||||
|
||||
# Pass assigned_order_item_id
|
||||
get 'print/print/:id', to: "print#print"
|
||||
post '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