diff --git a/Gemfile b/Gemfile index decd0ac6..44ecff75 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,12 @@ gem 'simple_form' gem 'bootstrap', '~> 4.0.0.alpha3' gem "font-awesome-rails" +#Report and Printing gems +gem 'cups', '~> 0.0.7' +gem 'prawn' +gem 'prawn-table' +gem 'spreadsheet' +gem 'to_xls-rails' # Use jquery as the JavaScript library gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 75591f98..231d65f7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,7 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.0.5) + cups (0.0.7) database_cleaner (1.5.3) debug_inspector (0.0.2) diff-lcs (1.3) @@ -98,6 +99,12 @@ GEM nio4r (2.0.0) nokogiri (1.7.1) mini_portile2 (~> 2.1.0) + pdf-core (0.7.0) + prawn (2.2.2) + pdf-core (~> 0.7.0) + ttfunk (~> 1.5) + prawn-table (0.2.2) + prawn (>= 1.3.0, < 3.0.0) puma (3.8.2) rack (2.0.1) rack-test (0.6.3) @@ -146,6 +153,7 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) + ruby-ole (1.2.12.1) sass (3.4.23) sass-rails (5.0.6) railties (>= 4.0.0, < 6) @@ -160,6 +168,8 @@ GEM simple_form (3.4.0) actionpack (> 4, < 5.1) activemodel (> 4, < 5.1) + spreadsheet (1.1.4) + ruby-ole (>= 1.0) spring (2.0.1) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -175,6 +185,9 @@ GEM thor (0.19.4) thread_safe (0.3.6) tilt (2.0.7) + to_xls-rails (1.3.1) + spreadsheet (>= 0.8.5) + ttfunk (1.5.0) turbolinks (5.0.1) turbolinks-source (~> 5) turbolinks-source (5.0.0) @@ -199,6 +212,7 @@ DEPENDENCIES bootstrap (~> 4.0.0.alpha3) byebug coffee-rails (~> 4.2) + cups (~> 0.0.7) database_cleaner factory_girl_rails (~> 4.0) faker @@ -207,6 +221,8 @@ DEPENDENCIES jquery-rails listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) + prawn + prawn-table puma (~> 3.0) rails (~> 5.0.2) rspec-rails (~> 3.5) @@ -214,12 +230,14 @@ DEPENDENCIES schema_to_scaffold shoulda-matchers (~> 3.1) simple_form + spreadsheet spring spring-watcher-listen (~> 2.0.0) + to_xls-rails turbolinks (~> 5) tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) BUNDLED WITH - 1.13.7 + 1.14.6 diff --git a/app/models/print_worker.rb b/app/models/print_worker.rb new file mode 100644 index 00000000..05084068 --- /dev/null +++ b/app/models/print_worker.rb @@ -0,0 +1,20 @@ +require 'cups' + +class PrintWorker + def self.printers() + Cups.show_destinations + end + + def self.default_printer() + Cups.default_printer + end + + def self.print_receipt_cashgo(sale,receipt_setting, printer_destination,order_id) + + pdf = CashPdf.new(sale,receipt_setting,order_id) + pdf.render_file "tmp/receipt_#{sale.receipt_no}" + ".pdf" + + page = Cups::PrintJob.new("tmp/receipt_#{sale.receipt_no}.pdf", printer_destination) + page.print + end +end