diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js
index 1df7a16e..401d894a 100755
--- a/app/assets/javascripts/addorder.js
+++ b/app/assets/javascripts/addorder.js
@@ -180,7 +180,7 @@ $(function() {
image_path = "image/logo.png";
}
}
-
+ console.log(menu_items[field].options)
row = '
'
+'
'
@@ -202,7 +202,7 @@ $(function() {
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
- + options +"' data-image='"+image_path+"' data-toggle='"
+ + JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='"
+data_modal+"' data-target='."+data_target+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
+JSON.stringify(menu_items[field].instances)+"'>"
@@ -237,10 +237,10 @@ $(function() {
//instances = $(this).data('instance');
item_sets = $(this).data('item-sets');
instances = $(this).data('instances');
- // item_sets = $(data).attr('data-item-sets');
+ item_options = $(this).data('options');
for(var field in item_sets) {
-
+
$('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
value = item_sets[field]["instances"];
@@ -283,10 +283,20 @@ $(function() {
});
}
+ for(var j in item_options) {
+ value = item_options[j]["values"];
+ type = item_options[j]["type"];
+ row = "
"+type+"
"
+ $(value).each(function(i){
+ row +="";
+ });
+ $(".options-list").append(row);
+ }
$('.set-item').attr('data-code',instances[0]['code']);
$('.set-item').attr('data-name',instances[0]['name']);
$('.set-item').attr('data-price',instances[0]['price']);
- $('.set-item').attr('data-options','[]');
+ // $('.set-item').attr('data-options','[]');
$('.set-item').attr('data-parent',true);
$('#set_change_qty').val(1);
@@ -371,32 +381,28 @@ $(function() {
customer_display_view(item,"set_add");
attribute_arr = []
- option_arr = []
var rowCount = $('.summary-items tbody tr').length+1;
- option_arr = []
code = $('.set-item').attr('data-code');
name = $('.set-item').attr('data-name');
price = $('.set-item').attr('data-price');
option = $('.set-item').attr('data-options');
parent = $('.set-item').attr('data-parent');
total = qty * price ;
- option_arr.push(option);
row =""
+ +option+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>"
+'| '+rowCount+' | '
- +'' + item_name+ ' ' + name +' | '
+ +'' + item_name+ ' ' + name +'-' + option +' | '
+'' + qty + ' | '
+''
+ parseFloat(total).toFixed(2)
+' | '
+'
';
$(".summary-items tbody").append(row);
-
var rowCount = $('.summary-items tbody tr').length+1;
$(items).each(function(i){
code = $(items[i]).attr('data-code');
@@ -406,15 +412,14 @@ $(function() {
sub_item = $(items[i]).attr('data-sub-item');
option = $(items[i]).attr('data-options');
total = qty * price ;
- option_arr.push(option);
row =""
+ +option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
+'| '+rowCount+' | '
- +'' + item_name+ ' ' + name +' | '
+ +'' + item_name+ ' ' + name +'-' + option +' | '
+'' + qty + ' | '
+''
+ parseFloat(total).toFixed(2)
@@ -626,8 +631,6 @@ $(function() {
if(group == "set_menu"){
- code = $(this).data('code');
- value = $(this).data('value');
instance = $(".selected-instance");
$(instance).each(function(i){
@@ -638,6 +641,12 @@ $(function() {
}
});
}
+
+ if(group == "set_menu_default"){
+ option_arr = get_selected_attributes('selected-option');
+ $('.set-item').attr('data-options',JSON.stringify(option_arr));
+ $('.set_default_option').text(option_arr);
+ }
}); //End selecct attribute buttom
diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb
index 240343b1..4d7d6026 100755
--- a/app/controllers/settings/menus_controller.rb
+++ b/app/controllers/settings/menus_controller.rb
@@ -6,6 +6,10 @@ class Settings::MenusController < ApplicationController
# GET /settings/menus.json
def index
@settings_menus = Menu.all.page(params[:page]).per(10)
+ respond_to do |format|
+ format.html
+ format.csv { send_data Menu.to_csv }
+ end
end
# GET /settings/menus/1
diff --git a/app/models/menu.rb b/app/models/menu.rb
index b96fe03a..052a7042 100755
--- a/app/models/menu.rb
+++ b/app/models/menu.rb
@@ -31,4 +31,29 @@ class Menu < ApplicationRecord
menu.destroy
return false
end
-end
+
+ def self.to_csv
+ m_attributes = %w{id name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
+ CSV.generate(headers: true) do |csv|
+ csv << m_attributes
+ menu = Menu.all
+ menu.each do |user|
+ puts user
+ csv << m_attributes.map{ |attr| user.send(attr)}
+ end
+ end
+
+ # mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
+ # CSV.generate(headers: true) do |csv|
+ # csv << m_attributes
+
+ # csv << mc_attributes
+ # MenuCategory.all.each do |user|
+ # puts user
+ # csv << mc_attributes.map{ |attr| user.send(attr)}
+ # end
+ # end
+
+ end
+
+end
\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
index 6a3bc551..f4cbac01 100755
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,5 +1,6 @@
require_relative 'boot'
+require 'csv'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
diff --git a/lib/tasks/receipt.rake b/lib/tasks/receipt.rake
index ee884fb2..fa24f481 100644
--- a/lib/tasks/receipt.rake
+++ b/lib/tasks/receipt.rake
@@ -1,44 +1,4 @@
namespace :consolidate do
-
-
- desc 'export sers who have logged in since 2017-06-30'
- task :export => :environment do
- puts "Export users who have logged in since 2017-06-30"
-
- # get a file ready, the 'data' directory has already been added in Rails.root
- filepath = File.join(Rails.root, 'data', 'recent_users.json')
- puts "- exporting users into #{filepath}"
-
- # the key here is to use 'as_json', otherwise you get an ActiveRecord_Relation object, which extends
- # array, and works like in an array, but not for exporting
- users = Employee.all.as_json
-puts users
- # The pretty is nice so I can diff exports easily, if that's not important, JSON(users) will do
- File.open(filepath, 'w') do |f|
- f.write(JSON.pretty_generate(users))
- end
-
- puts "- dumped #{users.size} users"
- end
-
- desc 'import users from recent users dump'
- task :import => :environment do
- puts "Importing current users"
-
- filepath = File.join(Rails.root, 'data', 'recent_users.json')
- abort "Input file not found: #{filepath}" unless File.exist?(filepath)
-
- current_users = JSON.parse(File.read(filepath))
-
- current_users.each do |cu|
- puts cu.to_json
- Employee.create(cu)
- end
-
- puts "- imported #{current_users.size} users"
- end
-
-
desc "Receipt"
task :receipt => :environment do
Receipt.delete_all
|