Add Moved By in MoveTablePdf

This commit is contained in:
San Wai Lwin
2018-03-28 16:17:41 +06:30
parent ff19f20a18
commit bc922a68c8
3 changed files with 11 additions and 9 deletions

View File

@@ -71,15 +71,16 @@ class Origami::MovetableController < BaseOrigamiController
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from) @get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
# get printer info # get printer info
@from = (DiningFacility.find(change_from)).name @from = (DiningFacility.find(change_from)).name
@to = (DiningFacility.find(change_to)).name @to = (DiningFacility.find(change_to)).name
@type = (DiningFacility.find(change_to)).type @type = (DiningFacility.find(change_to)).type
@moved_by = @current_user.name
@date = DateTime.now @date = DateTime.now
@shop = Shop::ShopDetail @shop = Shop::ShopDetail
unique_code = "MoveTablePdf" unique_code = "MoveTablePdf"
print_settings = PrintSetting.find_by_unique_code(unique_code) print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type) printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by)
end end
end end

View File

@@ -239,11 +239,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end end
#Move Table Print #Move Table Print
def print_move_table(printer_settings,to,from,shop_detail,date,type) def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type) pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by)
pdf.render_file "tmp/print_move_table.pdf" pdf.render_file "tmp/print_move_table.pdf"
self.print("tmp/print_move_table.pdf") self.print("tmp/print_move_table.pdf")
end end

View File

@@ -1,6 +1,6 @@
class MoveTablePdf < Prawn::Document class MoveTablePdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(printer_settings,to,from,shop_detail,date,type) def initialize(printer_settings,to,from,shop_detail,date,type,moved_by)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.margin = 5 self.margin = 5
@@ -32,7 +32,7 @@ class MoveTablePdf < Prawn::Document
header(printer_settings.name,type) header(printer_settings.name,type)
call_move_table(to,from,date,type) call_move_table(to,from,date,type,moved_by)
move_down 5 move_down 5
stroke_horizontal_rule stroke_horizontal_rule
@@ -41,17 +41,18 @@ class MoveTablePdf < Prawn::Document
end end
def header (name,type) def header (name,type)
text "Move #{type}", :left_margin => -10, :size => self.header_font_size,:align => :center text "Move #{type}", :left_margin => -10, :size => self.header_font_size.to_i + 3,:align => :center
# move_down self.item_height # move_down self.item_height
move_down 5 move_down 5
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
end end
def call_move_table (to,from,date,type) def call_move_table (to,from,date,type,moved_by)
move_down 3 move_down 3
text "Date Time : #{date.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :left_margin => -10, :size => self.header_font_size text "Date Time : #{date.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :left_margin => -10, :size => self.header_font_size
text "Change [#{from}] To [#{to}]", :left_margin => -10, :size => self.header_font_size text "Change [#{from}] To [#{to}]", :left_margin => -10, :size => self.header_font_size
text "Moved By : #{moved_by}", :left_margin => -10, :size => self.header_font_size
end end