diff --git a/.gitignore b/.gitignore index 42a48b40..98acc705 100644 --- a/.gitignore +++ b/.gitignore @@ -47,9 +47,9 @@ config/deploy/config/* #Gemfile.lock # For Redis Server log file -dump.rdb +/dump.rdb -# Fonts +# Fonts public/fonts/* # Ruby-Mine IDE folder diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5c3fb862..ab924a87 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,14 +3,9 @@ + - - - - - - - + @@ -25,7 +20,7 @@ - + @@ -52,76 +47,71 @@ - - + + - - + + - - + + - - - - - - - - - - - - + + - + - - + + - - + + - - + + - - + + - - - - - - - - + + + - + - - + + + + + + + + + + + + @@ -161,8 +151,6 @@ - - @@ -212,6 +200,8 @@ + + @@ -291,53 +281,26 @@ - + - - + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -744,12 +707,12 @@ - + - + @@ -765,17 +728,17 @@ + - + - @@ -786,6 +749,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -796,65 +795,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -863,14 +803,6 @@ - - - - - - - - @@ -1119,7 +1051,7 @@ - + @@ -1153,23 +1085,7 @@ - - - - - - - - - - - - - - - - - + @@ -1206,7 +1122,95 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index f161bc25..9ff9fce7 100644 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -22,7 +22,23 @@ class Inventory::StockChecksController < BaseInventoryController StockJournal.from_stock_check(item) end end - + + def print_stock_check + stock_id = params[:stock_check_id] # sale_id + stockcheck = StockCheck.find(stock_id) + stockcheck_items = stockcheck.stock_check_items + member_info = nil + unique_code = "StockPrint" + + shop_details = Shop.find(1) + checker = Employee.find(stockcheck.check_by) + print_settings=PrintSetting.find_by_unique_code(unique_code) + printer = Printer::ReceiptPrinter.new(print_settings) + + printer.print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker.name, shop_details) + + end + # before_action :set_stock_check, only: [:show, :edit, :update, :destroy] # GET /stock_checks diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 4bd25201..18af1dd1 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -74,7 +74,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker # print as print copies in printer setting count = printer_settings.print_copies - begin + begin if count == 1 pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf" self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf") @@ -84,9 +84,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end count -= 1 - end until count == 0 + end until count == 0 end + # stock check + def print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker_name, shop_details) + pdf = StockResultPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details) + pdf.render_file "tmp/print_stock_check_result.pdf" + self.print("tmp/print_stock_check_result.pdf") + end + #Queue No Print def print_queue_no(printer_settings,queue) #Use CUPS service diff --git a/app/pdf/stock_result_pdf.rb b/app/pdf/stock_result_pdf.rb new file mode 100644 index 00000000..489fb0ae --- /dev/null +++ b/app/pdf/stock_result_pdf.rb @@ -0,0 +1,92 @@ +class StockResultPdf < 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,:text_width + + def initialize(printer_settings,stockcheck, stockcheck_items,checker_name, shop_details) + self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width + self.page_height = printer_settings.page_height + self.margin = 5 + self.price_width = 40 + self.qty_width = 20 + self.total_width = 40 + self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) + self.item_height = 15 + self.item_description_width = (self.page_width-20) / 2 + self.label_width = 100 + + self.text_width = (self.page_width - 80) - self.price_width / 3 + # @item_width = self.page_width.to_i / 2 + # @qty_width = @item_width.to_i / 3 + # @double = @qty_width * 1.3 + # @half_qty = @qty_width / 2 + #setting page margin and width + super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + # font "public/fonts/#{font_name}".to_s + ".ttf".to_s + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + self.header_font_size = 10 + self.item_font_size = 8 + + header( shop_details) + + stroke_horizontal_rule + + detail(stockcheck,stockcheck_items, checker_name) + end + + def header (shop_details) + move_down 7 + text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center + move_down 5 + text "#{shop_details.address}", :size => self.item_font_size,:align => :center + # move_down self.item_height + move_down 5 + text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center + move_down 5 + + stroke_horizontal_rule + end + + def detail(stockcheck, stockcheck_items, checker_name) + move_down 7 + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + text "Checker : ", :size => self.item_font_size,:align => :left + end + bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do + text "#{checker_name}" , :size => self.item_font_size,:align => :left + end + + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + text "Check Start Time : ", :size => self.item_font_size,:align => :left + end + bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do + text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left + end + + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + text "Check End Time ", :size => self.item_font_size,:align => :left + end + bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do + text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left + end + + if stockcheck_items.length > 0 + stockcheck_items.each do |st| + move_down 5 + y_position = cursor + + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ st.item_code }", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{st.stock_count.to_i}" , :size => self.item_font_size,:align => :right + end + end + end + move_down 5 + stroke_horizontal_rule + end +end diff --git a/app/views/inventory/stock_checks/show.html.erb b/app/views/inventory/stock_checks/show.html.erb index 09ff16b5..4d0e83d0 100644 --- a/app/views/inventory/stock_checks/show.html.erb +++ b/app/views/inventory/stock_checks/show.html.erb @@ -71,4 +71,13 @@ $('#save_to_journal').on('click', function(){ } }) }) + +$('#print').on('click',function(){ + check_id = $('#stock_check_id').val(); + $.ajax({ + type: 'post', + url: '<%= inventory_print_stock_check_path %>', + data: 'stock_check_id='+ check_id + }) +}) diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb index 7ac413d0..bea1f981 100644 --- a/app/views/settings/promotions/_form.html.erb +++ b/app/views/settings/promotions/_form.html.erb @@ -39,9 +39,18 @@ <% end %> - - <%= f.input :promo_day %> + + + <%= f.hidden_field :promo_day, :value => "", :class => "form-control col-md-1" %> + Sun + Mon + Tue + Wed + Thu + Fri + Sat + <%= f.input :promo_type,input_html: { class: "" }, @@ -133,6 +142,8 @@ <% end %>