diff --git a/app/controllers/api/restaurant/menu_categories_controller.rb b/app/controllers/api/restaurant/menu_categories_controller.rb
index 5ab10ff5..f1f3e6d0 100644
--- a/app/controllers/api/restaurant/menu_categories_controller.rb
+++ b/app/controllers/api/restaurant/menu_categories_controller.rb
@@ -13,9 +13,7 @@ class Api::Restaurant::MenuCategoriesController < Api::ApiController
# This API show current order details
# Input Params - menu_id
def show
- puts "SSSSSSSSSSSSS"
@menu = menu_detail(params[:id])
- puts @menu.to_json
end
diff --git a/app/views/api/restaurant/menu/_menu_item.json.jbuilder b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
index c93c3b12..d86624b5 100644
--- a/app/views/api/restaurant/menu/_menu_item.json.jbuilder
+++ b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
@@ -32,8 +32,8 @@ elsif item.menu_item_instances.count > 1 then
end
#Child Menu items
-if (item.children) then
- json.set_items item.children.each do |item|
+if (item.menu_item_sets) then
+ json.set_items item.menu_item_sets.each do |item|
json.partial! 'api/restaurant/menu/menu_item', item: item
end
diff --git a/app/views/api/restaurant/menu_categories/show.json.jbuilder b/app/views/api/restaurant/menu_categories/show.json.jbuilder
index d7a6d581..f48f6c77 100644
--- a/app/views/api/restaurant/menu_categories/show.json.jbuilder
+++ b/app/views/api/restaurant/menu_categories/show.json.jbuilder
@@ -6,8 +6,8 @@ if @menu.menu_items
json.alt_name item.alt_name
json.type item.type
json.min_qty item.min_qty
- json.min_selectable_item item.min_selectable_item
- json.max_selectable_item item.max_selectable_item
+ # json.min_selectable_item item.min_selectable_item
+ # json.max_selectable_item item.max_selectable_item
#Item instance
if item.menu_item_instances.count == 1 then
@@ -33,11 +33,11 @@ if @menu.menu_items
end
#Child Menu items
- if (item.children) then
- json.set_items item.children.each do |item|
+ if (item.menu_item_sets) then
+ json.set_items item.menu_item_sets.each do |item|
json.partial! 'api/restaurant/menu/menu_item', item: item
end
- end
+ end
end
end
diff --git a/app/views/origami/addorders/show.html.erb b/app/views/origami/addorders/show.html.erb
index c7aa4455..638da002 100644
--- a/app/views/origami/addorders/show.html.erb
+++ b/app/views/origami/addorders/show.html.erb
@@ -23,7 +23,7 @@
-
+
@@ -42,7 +42,7 @@
| Sub Total: |
- 22222 |
+ 0.00 |
@@ -53,14 +53,16 @@
$(function(){
+ //click menu sidebar menu category
$(".menu_category").on("click", function(){
var menu_id = $(this).find(".menu-id").text();
var url = $(this).attr('data-ref');
show_menu_item_list(url);
- }); //End menu category Click
-
+ });
+ //End menu category Click
+
+ //show menu item list when click menu category
function show_menu_item_list(url_item){
-
var menu_list = $('.menu_items_list');
menu_list.empty();
@@ -74,7 +76,7 @@ $(function(){
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
-
+ console.log(data);
for(var field in menu_items) {
if (menu_items[field].item_instances){
var price = parseFloat(menu_items[field].item_instances[1].price).toFixed(2);
@@ -130,47 +132,75 @@ $(function(){
}
//end show detail function
+ // click plus icon for add
$(document).on('click', '.add_icon', function(event){
var item_data = $(this);
- show_item_detail(item_data);
+ show_item_detail(item_data);
+ calculate_sub_total();
}); //End Add Icon Click
function show_item_detail(data){
+ qty = 1;
+ append = 0;
+ price = data.attr('data-price');
+ instance_code = data.attr('data-instance');
- price = data.attr('data-price');
-
- if (data.attr('data-qty') === undefined){
- qty = 1;
- }else{
- qty = data.attr('data-qty');
- }
-
- if (data.attr('data-instance') == "undefined"){
+ if (instance_code == "undefined"){
instance = '';
}else{
- instance = data.attr('data-instance');
+ instance = "("+data.attr('data-instance')+")";
}
+ var rowCount = $('.summary-items tbody tr').length+1;
+ var item_row = $('.summary-items tbody tr');
+
+ $(item_row).each(function(i){
+ if ($(item_row[i]).attr('data-code') == data.attr('data-item-code')) {
+ qty = parseInt($(item_row[i]).children('#item_qty').text()) +1;
+ $(item_row[i]).children('#item_qty').text(qty);
+ $(item_row[i]).children('#item_price').text(price*qty);
+ append = 1;
+ }else{
+ qty = 1;
+ }
+ });
-
- var rowCount = $('.summary-items tbody');
- console.log(rowCount);
- for(var field in rowCount) {
- // console.log(rowCount[field].attr('data-code'));
- }
-
- row ='
'
+ if (append===0) {
+ row ="
"
+'| '+rowCount+' | '
- +'' + data.attr('data-name')+ ' ' + instance + ' | '
+ +'' + data.attr('data-name')+ ' ' + instance + ' | '
+'' + qty + ' | '
+''
+ parseFloat(price).toFixed(2)
+' | '
+'
';
- $(".summary-items tbody").append(row);
+ $(".summary-items tbody").append(row);
+ }
}
+ function calculate_sub_total(){
+ var total_price = 0;
+ var taxable_amount = 0;
+ var item_row = $('.summary-items tbody tr');
+
+ $(item_row).each(function(i){
+ // var taxable = $(item_row[i]).attr('data-taxable');
+ var unit_price = parseFloat($(item_row[i]).attr('data-price'));
+ var qty = parseFloat($(item_row[i]).children('#item_qty').text());
+ // if(taxable == 'true'){
+ // taxable_amount += qty*unit_price;
+ // }
+ total_price += qty*unit_price;
+ });
+ var fixed_total_price = parseFloat(total_price).toFixed(2);
+ var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
+ $('#sub_total').empty();
+ $('#sub_total').append(fixed_total_price);
+ // $('#sub_total').attr('taxable_amount',fixed_taxable_amount);
+ // $('#show_sub').text(fixed_total_price);
+}
+
});