From e450927d815a05263355bf66892d777def55dcfa Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 6 Sep 2018 15:15:28 +0630 Subject: [PATCH] change UI set menu and add lateset order no in receipt bill for QuickService --- app/assets/javascripts/custom.js | 12 +- .../origami/payments_controller.rb | 22 +- app/controllers/origami/void_controller.rb | 2 +- .../origami/waste_spoile_controller.rb | 2 +- .../transactions/sales_controller.rb | 2 +- app/models/printer/receipt_printer.rb | 8 +- app/pdf/receipt_bill_a5_pdf.rb | 14 +- app/pdf/receipt_bill_pdf.rb | 14 +- app/views/origami/addorders/detail.html.erb | 824 +++++++++--------- 9 files changed, 468 insertions(+), 432 deletions(-) diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index 005d6c6a..b6189b9a 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -64,7 +64,17 @@ $(document).ready(function() { $('#modal-set-slimscroll').slimScroll({ height: height-$('#modal-set-slimscroll').attr('data-height'), - size: '5px', + size: '10px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 45 + }); + + $('#set-menu-item-slimscroll').slimScroll({ + height: height-$('#set-menu-item-slimscroll').attr('data-height'), + size: '10px', color: 'rgba(0,0,0,0.5)', alwaysVisible: false, borderRadius: '0', diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index d45e4039..304e0d90 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -91,7 +91,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - 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) + 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,nil) result = { :filepath => filename, @@ -111,6 +111,7 @@ class Origami::PaymentsController < BaseOrigamiController type = params[:type] tax_type = params[:tax_type] path = request.fullpath + latest_order_no = nil if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) @@ -204,6 +205,11 @@ class Origami::PaymentsController < BaseOrigamiController table_id = 0 end + latest_order = booking.booking_orders.order("order_id DESC").limit(1).first() + if !latest_order.nil? + latest_order_no = latest_order.order_id + end + booking.booking_orders.each do |order| # Order.pay_process_order_queue(order.order_id, table_id) oqs = OrderQueueStation.new @@ -237,7 +243,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) @@ -442,11 +448,17 @@ class Origami::PaymentsController < BaseOrigamiController def reprint sale_id = params[:sale_id] member_info = nil - + latest_order_no = nil saleObj = Sale.find(sale_id) # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") + + booking = Booking.find_by_sale_id(sale_id) + latest_order = booking.booking_orders.joins(" JOIN orders ON orders.order_id = booking_orders.order_id").where("orders.source = 'quick_service'").order("order_id DESC").limit(1).first() + if !latest_order.nil? + latest_order_no = latest_order.order_id + end # if bookings.count > 1 # # for Multiple Booking # table = DiningFacility.find(bookings[0].dining_facility_id) @@ -514,7 +526,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no) result = { :status => true, @@ -600,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil) result = { :status => true, :filepath => filename, diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index e9c17ca1..1e9acafb 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -126,7 +126,7 @@ class Origami::VoidController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 2aa1bb77..6d2bb094 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -107,7 +107,7 @@ class Origami::WasteSpoileController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 7568a39a..c1e58f6f 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -363,7 +363,7 @@ class Transactions::SalesController < ApplicationController other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index f77fc96c..607232af 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -188,19 +188,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,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) + def print_receipt_bill(printer_settings,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) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.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) + pdf = ReceiptBillPdf.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) receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf if !receipt_bill_a5_pdf.empty? receipt_bill_a5_pdf.each do |receipt_bilA5| if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' - pdf = ReceiptBillA5Pdf.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) + pdf = ReceiptBillA5Pdf.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) else - pdf = ReceiptBillPdf.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) + pdf = ReceiptBillPdf.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) end end end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 78354fd5..945ca437 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -2,7 +2,7 @@ class ReceiptBillA5Pdf < 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, :description_width, :price_num_width, :line_move - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -56,7 +56,7 @@ class ReceiptBillA5Pdf < Prawn::Document stroke_horizontal_rule - cashier_info(sale_data, customer_name) + cashier_info(sale_data, customer_name, latest_order_no) line_items(sale_items,printer_settings.precision,delimiter) all_total(sale_data,printer_settings.precision,delimiter) @@ -112,7 +112,7 @@ class ReceiptBillA5Pdf < Prawn::Document stroke_horizontal_rule end - def cashier_info(sale_data, customer_name) + def cashier_info(sale_data, customer_name, latest_order_no) move_down line_move # move_down 2 y_position = cursor @@ -160,6 +160,14 @@ class ReceiptBillA5Pdf < Prawn::Document # :size => self.item_font_size,:align => :right # end + if !latest_order_no.nil? + y_position = cursor + move_down line_move + bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do + text "OrderNo : #{ latest_order_no }",:size => self.item_font_size,:align => :left + end + end + move_down line_move stroke_horizontal_rule end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index e6e7bdaa..5902469f 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -3,7 +3,7 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -57,7 +57,7 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule - cashier_info(sale_data, customer_name) + cashier_info(sale_data, customer_name, latest_order_no) line_items(sale_items,printer_settings.precision,delimiter) all_total(sale_data,printer_settings.precision,delimiter) @@ -112,7 +112,7 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule end - def cashier_info(sale_data, customer_name) + def cashier_info(sale_data, customer_name, latest_order_no) move_down line_move # move_down 2 @@ -153,7 +153,13 @@ class ReceiptBillPdf < Prawn::Document # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , # :size => self.item_font_size,:align => :right # end - + if !latest_order_no.nil? + y_position = cursor + move_down line_move + bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do + text "OrderNo : #{ latest_order_no }",:size => self.item_font_size,:align => :left + end + end move_down line_move stroke_horizontal_rule end diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 4c6c6561..c0e298e7 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -14,141 +14,141 @@