diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 0c4363db..af36a6e3 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -96,162 +96,298 @@ $(function() { } //end show list function //click menu sidebar menu category - $(document).on('click', '.menu_category', function(event){ - event.preventDefault(); + $('.menu_category').on("click", function(){ + // event.preventDefault(); + $('.sub_category_list').addClass("hidden"); var menu_id = $(this).attr("data-id"); - var url = "get_menu_category/"+menu_id; - show_menu_item_list(url); - + var url = "get_menu_category/"+menu_id; + show_menu_item_list(url,menu_id); var sub_id = $(this).attr("data-sub-id"); if (sub_id == "true") { var sub_url = "get_menu_sub_category/"+menu_id; sub_category = $(this).find('.sub_category_list'); - show_sub_category_list(sub_url,sub_category); + show_sub_category_list(sub_url,sub_category,menu_id); } - }); + }); + //End menu category Click + + //click menu sidebar menu category + $(document).on('click', '.menu_sub_category', function(event){ + event.preventDefault(); + $('.sub_category_list').addClass("hidden"); + var menu_id = $(this).attr("data-id"); + var url = "get_menu_category/"+menu_id; + show_menu_item_list(url,menu_id); + }); //End menu category Click //show menu item list when click menu category - function show_menu_item_list(url_item){ + function show_menu_item_list(url_item,menu_id){ var menu_list = $('.menu_items_list'); menu_list.empty(); - type = window.location.href.indexOf("quick_service"); - modify_order = window.location.href.indexOf("modify_order"); - if (type != -1 && modify_order != -1) { - url_item = '../../../addorders/'+url_item; - }if(modify_order == -1 && type != -1){ - url_item = 'addorders/'+url_item; - } - if (type ==-1 && modify_order == -1){ - url_item = url_item - } + menus = JSON.parse(localStorage.getItem("menus")); + if (menus != null) { + for(var i in menus) { + var categories = menus[i]["categories"]; + for(var ii in categories) { + if (categories[ii]["id"] == menu_id) { + var menu_items = categories[ii]["items"]; + // for(var field in menu_items) { + // if (menu_items[field].is_sub_item == false) { + // instances = menu_items[field].instances ; - //Start Ajax - $.ajax({ - type: "GET", - url: url_item, - data: {}, - dataType: "json", - success: function(data) { - var menu_items_list = $('.menu_items_list'); - menu_items_list.empty(); - menu_items = data.menu_items; + // if (!instances.length > 0) { + // swal("Hello Please Check!","Does not have instance item in this menu items ("+ menu_items[field].name+")","warning"); + // } + // if (instances.length > 0) { + // qty = 1; + // options = []; + // price = 0; - for(var field in menu_items) { - if (menu_items[field].is_sub_item == false) { - instances = menu_items[field].instances ; + // if (JSON.stringify(menu_items[field].item_sets)!='[]') { + // fa_plus = ''; + // add = ''; + // menu_item_box = 'add_icon'; + // data_target = 'sx_item_set_detailModal'; + // data_modal = 'modal' + // add_icon = "set_item_box" + // code = menu_items[field].code; + // name = menu_items[field].name; + // instances = menu_items[field].instances; + // $(instances).each(function(i){ + // if (instances[i].is_default == true) { + // price = parseFloat(instances[i].price).toFixed(2); + // }else{ + // price = 0; + // } + // }); + // is_available = menu_items[field].is_available ; + // is_on_promotion = 0; + // item_attributes = menu_items[field].attributes; + // promotion_price = menu_items[field].promotion_price; + // }else{ + // fa_plus = 'material-icons'; + // add = 'view_list' + // menu_item_box = 'menu_item_box'; + // data_target = 'sx_item_detailModal'; + // data_modal = '' + // add_icon = "add_icon" - if (!instances.length > 0) { - swal("Hello Please Check!","Does not have instance item in this menu items ("+ menu_items[field].name+")","warning"); - } - if (instances.length > 0) { - qty = 1; - options = []; - price = 0; + // $(instances).each(function(i){ + // if (instances[i].is_default === true) { + // code = instances[i].code; + // name = instances[i].name; + // price = parseFloat(instances[i].price).toFixed(2); + // is_available = instances[i].is_available ; + // is_on_promotion = instances[i].is_on_promotion; + // item_attributes = instances[i].values; + // promotion_price = instances[i].promotion_price; + // code = instances[i].code; + // } + // }); + // } - if (JSON.stringify(menu_items[field].item_sets)!='[]') { - fa_plus = ''; - add = ''; - menu_item_box = 'add_icon'; - data_target = 'sx_item_set_detailModal'; - data_modal = 'modal' - add_icon = "set_item_box" - code = menu_items[field].code; - name = menu_items[field].name; - instances = menu_items[field].instances; - $(instances).each(function(i){ - if (instances[i].is_default == true) { - price = parseFloat(instances[i].price).toFixed(2); - }else{ - price = 0; - } - }); - is_available = menu_items[field].is_available ; - is_on_promotion = 0; - item_attributes = menu_items[field].attributes; - promotion_price = menu_items[field].promotion_price; - }else{ - fa_plus = 'material-icons'; - add = 'view_list' - menu_item_box = 'menu_item_box'; - data_target = 'sx_item_detailModal'; - data_modal = '' - add_icon = "add_icon" + // if (menu_items[field].image) { + // if (modify_order) { + // image_path = "../../"+menu_items[field].image; + // }else{ + // image_path = menu_items[field].image; + // } + + // }else{ + // if (modify_order) { + // image_path = "../../image/logo.png"; + // }else{ + // image_path = "image/logo.png"; + // } + // } - $(instances).each(function(i){ - if (instances[i].is_default === true) { - code = instances[i].code; - name = instances[i].name; - price = parseFloat(instances[i].price).toFixed(2); - is_available = instances[i].is_available ; - is_on_promotion = instances[i].is_on_promotion; - item_attributes = instances[i].values; - promotion_price = instances[i].promotion_price; - code = instances[i].code; - } - }); - } + // row = '
' + // +'
' + // +'
'+ menu_items[field].name +'
' + // +"
" + // +"" + // +add+ '' + // +'
' + // +'
' + // +"
" - if (menu_items[field].image) { - if (modify_order) { - image_path = "../../"+menu_items[field].image; - }else{ - image_path = menu_items[field].image; - } - - }else{ - if (modify_order) { - image_path = "../../image/logo.png"; - }else{ - image_path = "image/logo.png"; - } - } + // // +"
" + // // +"" + // // +"
" - row = '
' - +'
' - +'
'+ menu_items[field].name +'
' - +"
" - +"" - +add+ '' - +'
' - +'
' - +"
" - - // +"
" - // +"" - // +"
" - - +'' - +'
'; - $('.menu_items_list').append(row); - } - //end instances in menu-items alest 1 instance + // +'' + // +'
'; + // $('.menu_items_list').append(row); + // } + // //end instances in menu-items alest 1 instance + // } + // //end is_sub_item false + // } + show_menu_list(menu_items); } - //end is_sub_item false } } - }); - //end Ajax + }else{ + + type = window.location.href.indexOf("quick_service"); + modify_order = window.location.href.indexOf("modify_order"); + + if (type != -1 && modify_order != -1) { + url_item = '../../../addorders/'+url_item; + }if(modify_order == -1 && type != -1){ + url_item = 'addorders/'+url_item; + } + if (type ==-1 && modify_order == -1){ + url_item = url_item + } + + //Start Ajax + $.ajax({ + type: "GET", + url: url_item, + data: {}, + dataType: "json", + success: function(data) { + var menu_items_list = $('.menu_items_list'); + menu_items_list.empty(); + menu_items = data.menu_items; +show_menu_list(menu_items); + // for(var field in menu_items) { + // if (menu_items[field].is_sub_item == false) { + // instances = menu_items[field].instances ; + + // if (!instances.length > 0) { + // swal("Hello Please Check!","Does not have instance item in this menu items ("+ menu_items[field].name+")","warning"); + // } + // if (instances.length > 0) { + // qty = 1; + // options = []; + // price = 0; + + // if (JSON.stringify(menu_items[field].item_sets)!='[]') { + // fa_plus = ''; + // add = ''; + // menu_item_box = 'add_icon'; + // data_target = 'sx_item_set_detailModal'; + // data_modal = 'modal' + // add_icon = "set_item_box" + // code = menu_items[field].code; + // name = menu_items[field].name; + // instances = menu_items[field].instances; + // $(instances).each(function(i){ + // if (instances[i].is_default == true) { + // price = parseFloat(instances[i].price).toFixed(2); + // }else{ + // price = 0; + // } + // }); + // is_available = menu_items[field].is_available ; + // is_on_promotion = 0; + // item_attributes = menu_items[field].attributes; + // promotion_price = menu_items[field].promotion_price; + // }else{ + // fa_plus = 'material-icons'; + // add = 'view_list' + // menu_item_box = 'menu_item_box'; + // data_target = 'sx_item_detailModal'; + // data_modal = '' + // add_icon = "add_icon" + + // $(instances).each(function(i){ + // if (instances[i].is_default === true) { + // code = instances[i].code; + // name = instances[i].name; + // price = parseFloat(instances[i].price).toFixed(2); + // is_available = instances[i].is_available ; + // is_on_promotion = instances[i].is_on_promotion; + // item_attributes = instances[i].values; + // promotion_price = instances[i].promotion_price; + // code = instances[i].code; + // } + // }); + // } + + // if (menu_items[field].image) { + // if (modify_order) { + // image_path = "../../"+menu_items[field].image; + // }else{ + // image_path = menu_items[field].image; + // } + + // }else{ + // if (modify_order) { + // image_path = "../../image/logo.png"; + // }else{ + // image_path = "image/logo.png"; + // } + // } + + // row = '
' + // +'
' + // +'
'+ menu_items[field].name +'
' + // +"
" + // +"" + // +add+ '' + // +'
' + // +'
' + // +"
" + + // // +"
" + // // +"" + // // +"
" + + // +'' + // +'
'; + // $('.menu_items_list').append(row); + // } + // //end instances in menu-items alest 1 instance + // } + // //end is_sub_item false + // } + } + }); + //end Ajax + } } //end show list function //click item row for item set @@ -274,55 +410,95 @@ $(function() { value = item_sets[field]["instances"]; $(value).each(function(i){ - if (type != -1 && modify_order != -1) { - url = '../../../addorders/get_item_instance/'+value[i]["id"]; - console.log("ssssssss") - } - if(modify_order == -1 && type != -1){ - - url = 'addorders/get_item_instance/'+value[i]["id"] ; - console.log("aaaaaa") - } - if (type ==-1 && modify_order == -1){ - - url = '../addorders/get_item_instance/'+value[i]["id"]; - console.log("cccccccccc") - } - $.ajax({ - type: "GET", - url: url, - // data: {id:value[i]}, - success:function(result){ - - row = '
' - +"
" - +'
' - +''+result["name"]+'' + menus = JSON.parse(localStorage.getItem("menus")); + if (menus != null) { + for(var i in menus) { + var categories = menus[i]["categories"]; + for(var ii in categories) { + var items = categories[ii]["items"]; + for(var iii in items) { + var result = items[iii]["instances"]; + for(var iv in result) { + if (value[i]["id"] == result[iv]["id"]) { + row = '
' + +"
" + +'
' + +''+result[iv]["name"]+'' + +'
' + +'
' + +'' + +' ' + +'
' + +'' +'
' - +'
' - +'' - +' ' - +'
' - +'' - +'
' - +'
' - - $(".instance-list").append(row); + +'
' + $(".instance-list").append(row); + } + } + } } - }); + } + }else{ + if (type != -1 && modify_order != -1) { + url = '../../../addorders/get_item_instance/'+value[i]["id"]; + console.log("ssssssss") + } + if(modify_order == -1 && type != -1){ + url = 'addorders/get_item_instance/'+value[i]["id"] ; + console.log("aaaaaa") + } + if (type ==-1 && modify_order == -1){ + url = '../addorders/get_item_instance/'+value[i]["id"]; + console.log("cccccccccc") + } + $.ajax({ + type: "GET", + url: url, + // data: {id:value[i]}, + success:function(result){ + + row = '
' + +"
" + +'
' + +''+result["name"]+'' + +'
' + +'
' + +'' + +' ' + +'
' + +'' + +'
' + +'
' + + $(".instance-list").append(row); + } + }); + } }); } @@ -442,10 +618,8 @@ $(function() { $(document).on('click', '#remove_set', function(event){ code = $(this).parent().parent('.selected-set').attr('data-code'); instance = $(".selected-instance"); - console.log(code) $(instance).each(function(i){ if ($(instance[i]).attr('data-code')==code){ - console.log($(instance[i])) $(instance[i]).removeClass("selected-instance") } }); @@ -496,7 +670,6 @@ $(function() { var rowCount = $('.summary-items tbody tr').length+1; var set_option = [] $(items).each(function(i){ - console.log($(items[0]).attr('data-name')) code = $(items[i]).attr('data-code'); name = $(items[i]).attr('data-name'); price = $(items[i]).attr('data-price'); @@ -754,7 +927,6 @@ $(function() { attribute_arr = get_selected_attributes('selected-attribute'); option_arr = get_selected_attributes('selected-option'); - console.log(option_arr) if (item_row.length>0) { var instances = jQuery.parseJSON(item_row.attr('data-instances')); @@ -990,7 +1162,6 @@ $(function() { dataType: "json", success:function(result){ if (result.status) { - console.log(result) if (result.data == null){ swal({ title: "Please Open Shift !", @@ -1243,54 +1414,76 @@ $(function() { var menu_id = $(this).attr("data-id"); var url = "get_menu_sub_category/"+menu_id; sub_category = $(this).find('.sub_category_list'); - show_sub_category_list(url,sub_category); + show_sub_category_list(url,sub_category,menu_id); }); //End menu category Click //show menu item list when click menu category - function show_sub_category_list(url,sub_category){ - - if (type != -1 && modify_order != -1) { - var url = "../../../addorders/"+url; - }if(modify_order== -1 && type != -1){ - var url = 'addorders/'+url; - } - if (type ==-1 && modify_order == -1){ - var url = url; - } + function show_sub_category_list(url,sub_category,menu_id){ var menu_list = $('.sub_category_list'); menu_list.empty(); - //Start Ajax - $.ajax({ - type: "GET", - url: url, - data: {}, - dataType: "json", - success: function(data) { - var sub_category_list = $('.sub_category_list'); - sub_category_list.empty(); - data = data.sub_category; - if (data.length>0) { - // if ((sub_category.hasClass('hidden'))) { + menus = JSON.parse(localStorage.getItem("menus")); + if (menus != null) { + for(var j in menus) { + var categories = menus[j]["categories"]; + console.log("categories"); + console.log(categories); + for(var ii in categories) { + console.log(menu_id); + console.log(categories[ii]["parent_id"]); + if (menu_id == categories[ii]["parent_id"]) { + console.log("parrrrrrrrrrrrrrrrr"); + console.log(categories[ii]["parent_id"]); + var sub_category_list = $('.sub_category_list'); + sub_category_list.empty(); $(sub_category).removeClass('hidden'); - // }else{ - // $(sub_category).addClass('hidden'); - // } - - for(var i in data) { - - row = '' ; - $(sub_category).append(row); - //end is_sub_item false - } + row = '' ; + $(sub_category).append(row); + } } } - }); - //end Ajax + }else{ + if (type != -1 && modify_order != -1) { + var url = "../../../addorders/"+url; + }if(modify_order== -1 && type != -1){ + var url = 'addorders/'+url; + } + if (type ==-1 && modify_order == -1){ + var url = url; + } + //Start Ajax + $.ajax({ + type: "GET", + url: url, + data: {}, + dataType: "json", + success: function(data) { + var sub_category_list = $('.sub_category_list'); + sub_category_list.empty(); + data = data.sub_category; + if (data.length > 0) { + // if ((sub_category.hasClass('hidden'))) { + $(sub_category).removeClass('hidden'); + // }else{ + // $(sub_category).addClass('hidden'); + // } + for(var i in data) { + + row = '' ; + $(sub_category).append(row); + //end is_sub_item false + } + } + } + }); + //end Ajax + } } /* Get Item rows */ @@ -1378,5 +1571,119 @@ $(function() { // price = $("#unit_price").text(); // $("#total_price").text(qty*price); // }); + function show_menu_list(menu_items) { + var menu_list = $('.menu_items_list'); + menu_list.empty(); + for(var field in menu_items) { + if (menu_items[field].is_sub_item == false) { + instances = menu_items[field].instances ; + if (!instances.length > 0) { + swal("Hello Please Check!","Does not have instance item in this menu items ("+ menu_items[field].name+")","warning"); + } + if (instances.length > 0) { + qty = 1; + options = []; + price = 0; + + if (JSON.stringify(menu_items[field].item_sets)!='[]') { + fa_plus = ''; + add = ''; + menu_item_box = 'add_icon'; + data_target = 'sx_item_set_detailModal'; + data_modal = 'modal' + add_icon = "set_item_box" + code = menu_items[field].code; + name = menu_items[field].name; + instances = menu_items[field].instances; + $(instances).each(function(i){ + if (instances[i].is_default == true) { + price = parseFloat(instances[i].price).toFixed(2); + }else{ + price = 0; + } + }); + is_available = menu_items[field].is_available ; + is_on_promotion = 0; + item_attributes = menu_items[field].attributes; + promotion_price = menu_items[field].promotion_price; + }else{ + fa_plus = 'material-icons'; + add = 'view_list' + menu_item_box = 'menu_item_box'; + data_target = 'sx_item_detailModal'; + data_modal = '' + add_icon = "add_icon" + + $(instances).each(function(i){ + if (instances[i].is_default === true) { + code = instances[i].code; + name = instances[i].name; + price = parseFloat(instances[i].price).toFixed(2); + is_available = instances[i].is_available ; + is_on_promotion = instances[i].is_on_promotion; + item_attributes = instances[i].values; + promotion_price = instances[i].promotion_price; + code = instances[i].code; + } + }); + } + + if (menu_items[field].image) { + if (modify_order) { + image_path = "../../"+menu_items[field].image; + }else{ + image_path = menu_items[field].image; + } + + }else{ + if (modify_order) { + image_path = "../../image/logo.png"; + }else{ + image_path = "image/logo.png"; + } + } + + row = '
' + +'
' + +'
'+ menu_items[field].name +'
' + +"
" + +"" + +add+ '' + +'
' + +'
' + +"
" + + // +"
" + // +"" + // +"
" + + +'' + +'
'; + $('.menu_items_list').append(row); + } + //end instances in menu-items alest 1 instance + } + //end is_sub_item false + } + } }); \ No newline at end of file diff --git a/app/controllers/api/restaurant/menu_controller.rb b/app/controllers/api/restaurant/menu_controller.rb index 96ba3cc0..011e4602 100755 --- a/app/controllers/api/restaurant/menu_controller.rb +++ b/app/controllers/api/restaurant/menu_controller.rb @@ -11,7 +11,10 @@ class Api::Restaurant::MenuController < Api::ApiController # to hash menu_array = [] all_menu.each do |m| - menu_array.push(m.to_json(:include => {:menu_categories => { :include => { :menu_items => { :include => [:menu_item_sets, :menu_item_instances => {:include => :menu_instance_item_sets}]} } }})) + menu_array.push(m.to_json(:include => {:menu_categories => + { :include => { :menu_items => + { :include => [:menu_item_sets, :menu_item_instances => + { :include => :menu_instance_item_sets}]} } }})) end #export Checksum file generate by md5 diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 15d896e6..fd298fb3 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -18,9 +18,15 @@ class Origami::AddordersController < BaseOrigamiController if check_mobile @webview = true end - @menus = Menu.all - @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') - + + # if params[:menus].present? + # @menus = JSON.parse(params[:menus], object_class: OpenStruct) + # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') + # else + @menus = Menu.all + @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') + # end + @table_id = params[:id] @table = DiningFacility.find(@table_id) @booking = @table.get_booking @@ -57,7 +63,7 @@ class Origami::AddordersController < BaseOrigamiController end def get_item_instance - @id = MenuItemInstance.find(params[:id]) + @instance = MenuItemInstance.find(params[:id]) end def get_menu() @@ -113,8 +119,6 @@ class Origami::AddordersController < BaseOrigamiController end items_arr.push(items) } -puts items_arr.to_json - puts "sssssssssssssssssssssss" # begin # if params[:order_source] == "quick_service" # customer_id = "CUS-000000000002" # for no customer id from mobile diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 027b89a5..9977850f 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -3,6 +3,8 @@ class Origami::DashboardController < BaseOrigamiController def index @shop = Shop.first + + today = DateTime.now.strftime('%Y-%m-%d') # @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count() # @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count() @@ -81,4 +83,8 @@ class Origami::DashboardController < BaseOrigamiController end end +def get_all_menu + @menus = Menu.all +end + end diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 948ffe69..218bacb8 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -81,7 +81,7 @@ class MenuCategory < ApplicationRecord def get_sub_category menu_category = MenuCategory.find_by_menu_category_id(self.id) - if menu_category + if !menu_category.nil? return true end return false diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 241fe79c..43ab6db0 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -48,9 +48,9 @@ <% if type %> <% if !menu.code.include? "SPL" %> - <% end%> <% else %> -
- - -
diff --git a/app/views/origami/addorders/get_item_instance.json.jbuilder b/app/views/origami/addorders/get_item_instance.json.jbuilder index 69302b8e..c95f782d 100644 --- a/app/views/origami/addorders/get_item_instance.json.jbuilder +++ b/app/views/origami/addorders/get_item_instance.json.jbuilder @@ -1,5 +1,5 @@ -if(@id) - menu_item = MenuItem.find(@id.menu_item_id) +if(@instance) + menu_item = MenuItem.find(@instance.menu_item_id) # Format for option json opt_format = [] # Format for attributes json @@ -24,14 +24,14 @@ if(@id) end json.success true - json.id @id.id - json.name @id.item_instance_name - json.code @id.item_instance_code + json.id @instance.id + json.name @instance.item_instance_name + json.code @instance.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.item_id @instance.menu_item_id + json.attributes @instance.item_attributes + json.price @instance.price + json.is_default @instance.is_default json.options opt_format else diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder new file mode 100644 index 00000000..946ebe49 --- /dev/null +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -0,0 +1,24 @@ +json.id menu.id +json.name menu.name +json.is_active menu.is_active +json.valid_time_from menu.valid_time_from.strftime("%H:%M") +json.valid_time_to menu.valid_time_to.strftime("%H:%M") + +if (menu.menu_categories) + json.categories menu.menu_categories do |category| + json.id category.id + json.code category.code + json.order_by category.order_by + json.name category.name + json.alt_name category.alt_name + json.order_by category.order_by + json.parent_id category.menu_category_id + json.is_available category.is_available + + if category.menu_items + json.items category.menu_items do |item| + json.partial! 'origami/addorders/menu_item', item: item + end + end + end +end diff --git a/app/views/origami/dashboard/get_all_menu.json.jbuilder b/app/views/origami/dashboard/get_all_menu.json.jbuilder new file mode 100644 index 00000000..9ecfa65b --- /dev/null +++ b/app/views/origami/dashboard/get_all_menu.json.jbuilder @@ -0,0 +1,15 @@ +menu_json = json.array! @menus do |menu| + json.id menu.id + json.name menu.name + json.valid_days menu.valid_days + json.valid_time_from menu.valid_time_from.strftime("%H:%M") + json.valid_time_to menu.valid_time_to.strftime("%H:%M") + + json.partial! 'origami/dashboard/menu', menu: menu + # if (@current_menu) + # json.current_menu do + # json.partial! 'api/restaurant/menu/menu', menu: @current_menu + # end + # end +end + diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb index bbb19c78..baf543e6 100644 --- a/app/views/origami/dashboard/index.html.erb +++ b/app/views/origami/dashboard/index.html.erb @@ -207,6 +207,16 @@ " id="server_mode"> \ No newline at end of file diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 8fa42403..242b5fdd 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -1010,7 +1010,27 @@ $('#add_order').on('click', function () { var dining_id = "<%= @dining.id %>"; - window.location.href = '/origami/addorders/' + dining_id; + // var menus = JSON.parse(localStorage.getItem("menus")); + // var menu_arr = []; + // if (menus != null) { + // for(var i in menus) { + // var arr = {}; + // arr.id = menus[i]["id"]; + // arr.name = menus[i]["name"]; + // menu_arr.push(arr); + // } + // } + // menu_arr = JSON.stringify(menu_arr); + // console.log(menu_arr) + // $.ajax({ + // type: 'POST', + // data: {menus: menu_arr}, + // url: '/origami/addorders/' + dining_id, + // success: function(data) { + + // } + // }); + window.location.href = '/origami/addorders/' + dining_id; }); /* check in process */ diff --git a/config/routes.rb b/config/routes.rb index ce5d44a5..8ccdcb5c 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,6 +97,7 @@ scope "(:locale)", locale: /en|mm/ do post '/check_emp_access_code/:code' => 'home#check_emp_access_code', :defaults => { :format => 'json' } get "dashboard" => "dashboard#index" + get "get_all_menu" => "dashboard#get_all_menu" get "quick_service" => "quick_service#index"