diff --git a/.gitignore b/.gitignore index eadc1489..66f5a09c 100755 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ capybara-*.html /public/image /public/system/* /public/assets/* +/public/menus/* /public/uploads/* /public/swf/* /public/receipts/ diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 07511458..1044bc6f 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -268,21 +268,24 @@ $(function() { value = item_sets[field]["instances"]; $(value).each(function(i){ if (type != -1 && modify_order != -1) { - url = '../../../../api/restaurant/menu_item_instances/'+value[i]["id"]; + + url = '../../../addorders/get_item_instance/'+value[i]["id"]; console.log("ssssssss") } if(modify_order == -1 && type != -1){ - url = '../../api/restaurant/menu_item_instances/'+value[i]["id"] ; + + url = 'addorders/get_item_instance/'+value[i]["id"] ; console.log("aaaaaa") } if (type ==-1 && modify_order == -1){ - url = '../../api/restaurant/menu_item_instances/'+value[i]["id"]; + + url = '../addorders/get_item_instance/'+value[i]["id"]; console.log("cccccccccc") } $.ajax({ type: "GET", url: url, - data: {id:value[i]}, + // data: {id:value[i]}, success:function(result){ row = '
' diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 14b1e2e1..590fdcbc 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -53,16 +53,4 @@ module LoginVerification def render_unauthorized redirect_to root_path end - - private - def check_license - License.check_license_file - end - - def check_installation - if current_company.nil? - redirect_to install_path - end - end - end diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb index f8602ded..b49ef597 100755 --- a/app/controllers/concerns/token_verification.rb +++ b/app/controllers/concerns/token_verification.rb @@ -13,8 +13,8 @@ module TokenVerification authenticate_token || render_unauthorized end - def authenticate_token - authenticate_with_http_token do |token, options| + 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") diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 8e23d2c9..0f16b981 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -58,6 +58,10 @@ class Origami::AddordersController < BaseOrigamiController end end + def get_item_instance + @id = MenuItemInstance.find(params[:id]) + end + def get_menu() if (params[:id]) #Pull this menu diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index bc92a959..f73226f4 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -99,11 +99,39 @@ class Settings::MenusController < ApplicationController sheet.add_row ["Name",menu.name], :style=>title sheet.add_row - sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Instance Code", "Instance Name", "Price"], :style=>header_text + sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Price", "Is Default"], :style=>header_text menu.menu_categories.each do |mc| mc.menu_items.each do |mi| + attributes = "" + i=0 + if mi.item_attributes.length > 0 + mi.item_attributes.each do |mia| + attribute = MenuItemAttribute.find(mia) + if i == mi.item_attributes.length - 1 + attributes = attributes + attribute.name + else + attributes = attributes + attribute.name + "," + end + i = i + 1 + end + end + + options = "" + i=0 + if mi.item_options.length > 0 + mi.item_options.each do |mia| + option = MenuItemOption.find(mia) + if i == mi.item_options.length - 1 + options = options + option.name + else + options = options + option.name + "," + end + i = i + 1 + end + end + mi.menu_item_instances.each do |mii| - sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, mii.item_instance_code, mii.item_instance_name, mii.price], :style=>wrap_text + sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, mii.price, mii.is_default], :style=>wrap_text end end end diff --git a/app/models/menu.rb b/app/models/menu.rb index 28b23c76..60200aeb 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -153,6 +153,28 @@ class Menu < ApplicationRecord # status = status + "Category Code already exists." end + # Menu Item Attributes + item_attrs = [] + attributes = row["Attributes"].split(',') + attributes.each do |attr| + attribute = MenuItemAttribute.find_by_name(attr) + if attribute.nil? + attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase }) + end + item_attrs.push(attribute.id) + end + + # Menu Item Options + item_opts = [] + options = row["Options"].split(',') + options.each do |opt| + option = MenuItemOption.find_by_name(opt) + if option.nil? + option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase }) + end + item_opts.push(option.id) + end + menu_itm = MenuItem.find_by_item_code(row["Item Code"]) if !menu_itm account = Account.find_by_title(row["Account"]) @@ -160,14 +182,14 @@ 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: "[]", 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_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by) # else # status = status + "Item Code already exists for " + row["Item Name"] + "." end menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"]) if !menu_inst - imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: "[]", price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: false) + imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"]) # else # status = status + "Instance Code already exists for " + row["Instance Name"] + "." end diff --git a/app/views/origami/addorders/get_item_instance.json.jbuilder b/app/views/origami/addorders/get_item_instance.json.jbuilder new file mode 100644 index 00000000..69302b8e --- /dev/null +++ b/app/views/origami/addorders/get_item_instance.json.jbuilder @@ -0,0 +1,39 @@ +if(@id) + menu_item = MenuItem.find(@id.menu_item_id) + # Format for option json + opt_format = [] + # Format for attributes json + menu_item.item_options.each do|opt| + menu_opt = MenuItemOption.find(opt) + if opt_format.count == 0 + opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] }) + next + end + + opt_format.each do |of| + if menu_opt.option_type.in? opt_format.map {|k| k[:type]} + if menu_opt.option_type == of[:type] + of[:values].push(menu_opt.name) + end + else + new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] } + opt_format.push(new_opt) + break + end + end + end + + json.success true + json.id @id.id + json.name @id.item_instance_name + json.code @id.item_instance_code + + json.item_id @id.menu_item_id + json.attributes @id.item_attributes + json.price @id.price + json.is_default @id.is_default + + json.options opt_format +else + json.success false +end diff --git a/app/views/origami/dinga/index.html.erb b/app/views/origami/dinga/index.html.erb index 70b572db..83aed948 100644 --- a/app/views/origami/dinga/index.html.erb +++ b/app/views/origami/dinga/index.html.erb @@ -106,6 +106,12 @@
+
+

Card Tap

+
+ +
+

Card Tap

@@ -348,7 +354,7 @@ $.ajax({ type: "POST", - url: "<%=origami_payment_paymal_path%>", + url: "<%=origami_payment_dinga_path%>", data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code}, success: function(result){ diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index d5ac5bb8..334beea9 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -432,20 +432,12 @@
- @@ -1049,7 +1041,6 @@ var customer_name = "<%= @customer.name %>"; url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print", data: params, success:function(result){ - console.log(result); // For Server Print - from jade if ($("#server_mode").val() == "cloud") { code2lab.printFile(result.filepath.substr(6), result.printer_url); diff --git a/app/views/print_settings/_form.html.erb b/app/views/print_settings/_form.html.erb index e07da111..ae1f90c1 100755 --- a/app/views/print_settings/_form.html.erb +++ b/app/views/print_settings/_form.html.erb @@ -16,7 +16,7 @@ <% if(@server_mode != 'cloud') %> <%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %> <% else %> - <%= f.input :printer_name %> + <%= f.input :printer_name, :as => :select, :collection => [] %> <% end %> <%= f.input :brand_name %> <%= f.input :printer_type %> diff --git a/app/views/settings/employees/_form.html.erb b/app/views/settings/employees/_form.html.erb index 0b973416..ad50e9b8 100755 --- a/app/views/settings/employees/_form.html.erb +++ b/app/views/settings/employees/_form.html.erb @@ -7,7 +7,11 @@
<%= f.input :name %> - <%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %> + <% if current_user.role == "administrator" %> + <%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %> + <% else %> + <%= f.input :role, :collection => Lookup.collection_of("employee_roles").select{|r| r[1] != "administrator"},:class=>'form-group' %> + <% end %> <%= f.input :emp_id, :label => "Employee Numberic ID (*Unique)" %> <%= f.input :password %> diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 2facee87..9284042f 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -50,6 +50,16 @@ class ActionController::Base end end + def check_license + License.check_license_file + end + + def check_installation + if current_company.nil? + redirect_to install_path + end + end + def website_connection(license) default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase, :username => license.dbusername, :password => license.dbpassword) diff --git a/config/routes.rb b/config/routes.rb index bd1d8921..30b78fd9 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -237,6 +237,9 @@ scope "(:locale)", locale: /en|mm/ do get '/:addorders/:id' => "addorders#detail" post '/:addorders/create' => "addorders#create",:as => "addorder_create", :defaults => { :format => 'json' } + + get '/addorders/get_item_instance/:id' => "addorders#get_item_instance",:as => "get_item_instance", :defaults => { :format => 'json' } + resources :commissions resources :commissioners diff --git a/config/secrets.yml b/config/secrets.yml index b0d7c5c8..218234f1 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -13,7 +13,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 sx_provision_url: https://connect.pos-myanmar.com/bensai/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api - server_mode: cloud + server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L diff --git a/public/menus/Main Menu.xlsx b/public/menus/Main Menu.xlsx index a35944b0..2987ce89 100644 Binary files a/public/menus/Main Menu.xlsx and b/public/menus/Main Menu.xlsx differ