diff --git a/Gemfile b/Gemfile index 41682d12..6005cae2 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ gem 'rubyzip', '= 1.0.0' gem 'axlsx', '= 2.0.1' gem 'axlsx_rails' gem 'roo' +gem 'pdfjs_viewer-rails' #Reporting gem #gem 'compendium' #gem "cancan" diff --git a/Gemfile.lock b/Gemfile.lock index eee001d1..b7f4b2ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -125,6 +125,7 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) + json (2.1.0) kaminari (1.0.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.0.1) @@ -168,6 +169,10 @@ GEM nokogiri (1.8.1) mini_portile2 (~> 2.3.0) pdf-core (0.7.0) + pdfjs_viewer-rails (0.2.0) + json (> 1.8.4) + rails (> 4.2.0) + sass-rails (~> 5.0) pg (0.21.0) prawn (2.2.2) pdf-core (~> 0.7.0) @@ -333,6 +338,7 @@ DEPENDENCIES momentjs-rails mysql2 (>= 0.3.18, < 0.5) nested_form + pdfjs_viewer-rails pg prawn prawn-table diff --git a/Main Menu.xlsx b/Main Menu.xlsx deleted file mode 100644 index 94c70338..00000000 Binary files a/Main Menu.xlsx and /dev/null differ diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 973fc159..2340abd4 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,7 +1,7 @@ class Api::ApiController < ActionController::API include TokenVerification - before_action :lookup_domain + # before_action :lookup_domain helper_method :current_token, :current_login_employee, :get_cashier private diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb index 2c17e258..f8602ded 100755 --- a/app/controllers/concerns/token_verification.rb +++ b/app/controllers/concerns/token_verification.rb @@ -13,12 +13,12 @@ module TokenVerification authenticate_token || render_unauthorized end - def authenticate_token + def authenticate_token authenticate_with_http_token do |token, options| # Rails.logger.debug "token - " + token.to_s if(options.length !=0 && options["from"] == "DOEMAL") if(ENV["SERVER_MODE"] === "cloud") - from = request.subdomain.downcase + "." + request.domain.downcase + from = "local" #request.subdomain.downcase + "." + request.domain.downcase aes = MyAesCrypt.new return aes.checkKeyForAuth(from, token) end diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 0264084c..bc92a959 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -167,8 +167,9 @@ class Settings::MenusController < ApplicationController # end end - p.serialize("tmp/menus/" + menu.name + ".xlsx") - render :json => {status: true} + file_path = "public/menus/" + menu.name + ".xlsx" + p.serialize(file_path) + render :json => { status: true, path: file_path } end def import diff --git a/app/models/menu.rb b/app/models/menu.rb index 8bf616c9..28b23c76 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -160,7 +160,7 @@ class Menu < ApplicationRecord account = Account.create({title: row["Account"], account_type: "0"}) end - menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: "[]", item_options: "[]", account_id: account_id, is_sub_item: 0, is_available: 1, created_by: created_by) + menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: "[]", item_options: "[]", is_sub_item: 0, is_available: 1, created_by: created_by) # else # status = status + "Item Code already exists for " + row["Item Name"] + "." end diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index cb8db5f0..d5ac5bb8 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -632,6 +632,8 @@ var customer_name = "<%= @customer.name %>"; if (credit <= 0) { calculate_member_discount(sale_id); } + + $("#pdfModal").modal({show : true, backdrop : false, keyboard : false}); $.ajax({type: "POST", url: "<%= origami_payment_cash_path %>", @@ -652,13 +654,14 @@ var customer_name = "<%= @customer.name %>"; var msg = ''; } - $("#loading_wrapper" ).hide(); + $("#loading_wrapper" ).hide(); //PDF lightbox data + var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6); $("#sale_receipt_no").val(result.receipt_no); $("#filename").val(result.filename); $("#printer_name").val(result.printer_name); - $("#receipt_pdf").attr("src", result.filename.substring(6)); + $("#receipt_pdf").attr("src", pdfPath); $("#pdfModal").modal({show : true, backdrop : false, keyboard : false}); $("#pdfModalLabel").text("Sale Completed"); $("#changed_amount").text(""); diff --git a/app/views/settings/menus/index.html.erb b/app/views/settings/menus/index.html.erb index d8e37899..8eeb5269 100755 --- a/app/views/settings/menus/index.html.erb +++ b/app/views/settings/menus/index.html.erb @@ -115,7 +115,8 @@ url: "/settings/menus/" + menu_id + "/export", success: function(result){ if(result.status){ - swal("Success", "Export Success...", "success"); + location.href = result.path.substring(6); + // swal("Success", "Export Success...", "success"); } } }); diff --git a/config/routes.rb b/config/routes.rb index 9489009f..bd1d8921 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,8 @@ scope "(:locale)", locale: /en|mm/ do root 'home#index' mount Sidekiq::Web => '/kiq' + mount PdfjsViewer::Rails::Engine => "/pdfjs", as: 'pdfjs' + # Action Cable Creation # if ENV["SERVER_MODE"] != "cloud" mount ActionCable.server => "/cable" diff --git a/config/shops.json b/config/shops.json index b3369529..65755243 100644 --- a/config/shops.json +++ b/config/shops.json @@ -3,8 +3,15 @@ { "lookup": "local", "value": { - "key": "999d675168d813d5e1c7", - "iv": "999d675168d813d5e1c7" + "key": "999d675168d813d5e1c7", + "iv": "999d675168d813d5e1c7" + } + }, + { + "lookup": "demo10.pos-myanmar.com", + "value": { + "key": "634W2ioj6QA88vafKamHBRu5aKX/BLIPdTWuuXGFBsA=\n", + "iv": "QqpO/h7o60dYTbNETRbZ4g==\n" } } ] diff --git a/public/menus/Main Menu.xlsx b/public/menus/Main Menu.xlsx new file mode 100644 index 00000000..a35944b0 Binary files /dev/null and b/public/menus/Main Menu.xlsx differ diff --git a/public/menus/Shwe Myittar.xlsx b/public/menus/Shwe Myittar.xlsx new file mode 100644 index 00000000..5cd9d6b9 Binary files /dev/null and b/public/menus/Shwe Myittar.xlsx differ