From 941204afc1a64871d852c8882e4ce6b9163849a8 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 16 Feb 2018 14:30:53 +0630 Subject: [PATCH] update add order --- app/assets/javascripts/addorder.js | 76 ++++++----- .../origami/quick_service_controller.rb | 2 +- app/views/origami/addorders/detail.html.erb | 123 ++++++------------ 3 files changed, 89 insertions(+), 112 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index bc0b2721..91c02552 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -123,8 +123,10 @@ $(function() { if (JSON.stringify(menu_items[field].item_sets)!='[]') { fa_plus = ''; add = ''; - menu_item_box = 'set_item_box'; + 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; @@ -144,6 +146,8 @@ $(function() { add = 'add' 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) { @@ -164,11 +168,11 @@ $(function() { }else{ image_path = "/image/logo.png"; } - if (menu_item_box == "set_item_box") { - add_icon = "set_item_box" - }else{ - add_icon = "add_icon" - } + // if (menu_item_box == "set_item_box") { + + // }else{ + + // } row = '
' +'
' @@ -190,7 +194,10 @@ $(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+"' >" + + 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)+"'>" +"
" +"" @@ -218,10 +225,12 @@ $(function() { $('.set_change_qty').val(1); change_qty_plus_minus("set_count","set_plus","set_minus"); data = $(this).parent().children().children('.add_icon'); - - instances = $(this).data('instance'); + // data = $(this).parent().siblings('.add_icon'); + //instances = $(this).data('instance'); item_sets = $(this).data('item-sets'); - + instances = $(this).data('instances'); + // item_sets = $(data).attr('data-item-sets'); +console.log(instances) for(var field in item_sets) { $('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]); @@ -274,11 +283,11 @@ $(function() { $('#set_change_qty').val(1); $('#set_item_instances').text(instances); - $('#set_name').text(data.attr('data-name')); - $('#set_item_code').text(data.attr('data-item-code')); - $('#set_total_price').text(data.attr('data-price')); + $('#set_name').text($(this).attr('data-name')); + $('#set_item_code').text($(this).attr('data-item-code')); + $('#set_total_price').text($(this).attr('data-price')); // $('#set_total_price').text(0); - $('#set_unit_price').text(data.attr('data-price')); + $('#set_unit_price').text($(this).attr('data-price')); // $('#set_unit_price').text(0); }); // click instance for add item set @@ -735,7 +744,7 @@ $(function() { if (type == 'true') { type = 'cashier' - var table_type = $('#table_id').find("option:selected").data('type'); + var table_type = $('#table_type').text(); var table_id = $('#table_id').val(); var customer_id = $('#customer_id').val(); var booking_id = $('#booking_id').text(); @@ -762,21 +771,28 @@ $(function() { 'customer_id': customer_id, 'guest_info': "", 'table_id': table_id, 'order_items': order_items }; - $.ajax({ - type: "POST", - url: ajax_url, - data: params, - dataType: "json", - success:function(result){ - - if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id - } - else { - window.location.href = "/origami/room/" + table_id - } - } - }); + if (table_id.length>0) { + $.ajax({ + type: "POST", + url: ajax_url, + data: params, + dataType: "json", + success:function(result){ + + if(table_type == "Table"){ + window.location.href = "/origami/table/" + table_id + } + else { + window.location.href = "/origami/room/" + table_id + } + } + }); + }else{ + $(this).removeAttr('disabled', ''); + $("#oqs_loading_wrapper").hide(); + + swal("Opps","Please Select Table or Room","warning"); + } }); diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index 8dfc901c..c6ad1383 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -3,7 +3,7 @@ class Origami::QuickServiceController < ApplicationController def index @menu = MenuCategory.all.active - @dining = DiningFacility.all.active + @zone = Zone.all @customer = Customer.all @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 36f45b74..2ec7ad24 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -78,10 +78,11 @@ Back - Select + <%else%>
<% else %> @@ -361,92 +362,46 @@
<% end %>