From 2f024e86915b6f8324c4c6e1b7b7ac47bcf4c03d Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 1 Feb 2018 10:29:24 +0630 Subject: [PATCH] update qurick raw --- app/assets/javascripts/addorder.js | 124 +++++++-- app/assets/stylesheets/addorder.scss | 9 +- app/controllers/api/bill_controller.rb | 3 +- .../api/call_waiters_controller.rb | 3 +- app/controllers/base_origami_controller.rb | 3 +- app/controllers/home_controller.rb | 3 +- .../origami/addorders_controller.rb | 9 + .../origami/dashboard_controller.rb | 59 +++++ .../origami/quick_service_controller.rb | 42 +++ app/models/order.rb | 2 - app/models/sale.rb | 35 +++ app/models/sale_payment.rb | 2 +- app/views/origami/addorders/detail.html.erb | 92 +++++-- app/views/origami/dashboard/index.html.erb | 245 ++++++++++++++++++ app/views/origami/home/index.html.erb | 6 +- .../origami/quick_service/index.html.erb | 0 app/views/origami/shifts/new.html.erb | 2 +- config/routes.rb | 6 +- 18 files changed, 585 insertions(+), 60 deletions(-) create mode 100644 app/controllers/origami/dashboard_controller.rb create mode 100644 app/controllers/origami/quick_service_controller.rb create mode 100644 app/views/origami/dashboard/index.html.erb create mode 100644 app/views/origami/quick_service/index.html.erb diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 4b158946..60bcbcc3 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -83,9 +83,12 @@ $(function() { //show menu item list when click menu category function show_menu_item_list(url_item){ - var menu_list = $('.menu_items_list'); menu_list.empty(); + if ($('#type').val() == 'true') { + url_item = 'addorders/'+url_item + } + //Start Ajax $.ajax({ type: "GET", @@ -702,26 +705,41 @@ $(function() { } } - // Pay Discount for Payment + // Create Order $("#create_order").on('click', function(e){ + $(this).attr('disabled', 'disabled'); e.preventDefault(); $("#oqs_loading_wrapper").show(); - var table_id = $('#table_id').text(); - var customer_id = $('#customer_id').text(); - var booking_id = $('#booking_id').text(); + + type = $('#type').val(); + if (type == 'true') { + type = 'cashier' + + var table_type = $('#table_id').find("option:selected").data('type'); + var table_id = $('#table_id').val(); + var customer_id = $('#customer_id').val(); + var booking_id = $('#booking_id').text(); + var ajax_url = 'addorders/create'; + }else{ + type = 'cashier' + var table_type = $('#table_type').text(); + var table_id = $('#table_id').text(); + var customer_id = $('#customer_id').text(); + var booking_id = $('#booking_id').text(); + var ajax_url = '../addorders/create'; + } if (!booking_id.length > 0) { - var params = {'order_source': "cashier", 'order_type': "dine_in", + var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id, 'table_id': table_id, 'order_items': order_items }; } - var table_type = $('#table_type').text(); + var order_items = JSON.stringify(get_order_item_rows()); - var ajax_url = '../addorders/create'; - var params = {'order_source': "cashier", 'order_type': "dine_in", + var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "", 'table_id': table_id, 'order_items': order_items }; @@ -731,27 +749,61 @@ $(function() { data: params, dataType: "json", success:function(result){ - // $("#oqs_loading_wrapper").hide(); - // swal({ - // title: "Information !", - // text: 'Order has been successfully created', - // confirmButtonColor: "green", - // confirmButtonText: "Yes!", - // closeOnConfirm: false, - // }, function (isConfirm) { - // if (isConfirm) { + if(table_type == "Table"){ window.location.href = "/origami/table/" + table_id } else { window.location.href = "/origami/room/" + table_id - } - // } - // }); + } } }); }); + + // Pay Discount for Payment + $("#create_pay_order").on('click', function(e){ + + $(this).attr('disabled', 'disabled'); + e.preventDefault(); + $("#oqs_loading_wrapper").show(); + + type = $('#type').val(); + type = 'quick_service' + var table_type = $('#table_id').find("option:selected").data('type'); + var table_id = $('#table_id').val(); + var customer_id = $('#customer_id').val(); + var booking_id = $('#booking_id').text(); + var ajax_url = 'addorders/create'; + + if (!booking_id.length > 0) { + + var params = {'order_source': type, 'order_type': "dine_in", + 'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id, + 'table_id': table_id, + 'order_items': order_items }; + } + var order_items = JSON.stringify(get_order_item_rows()); + + var params = {'order_source': type, 'order_type': "dine_in", + '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){ + console.log(result) + if (result.status) { + window.location.href = "/origami/sale/"+result.data["sale_id"]+"/payment" + } + // window.location.href = "/origami/quick_service" + } + }); + }); + //click item row for update qty $('.summary-items').on('click', '.item_box', function(){ $(this).attr('data-active',true); @@ -863,11 +915,21 @@ $(function() { $("#back").on("click", function(){ var table_id = $('#table_id').text(); var table_type = $('#table_type').text(); - if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id - }else { - window.location.href = "/origami/room/" + table_id - } + type = $('#type').val(); + if (type == 'true') { + var table_type = $('#table_id').find("option:selected").data('type'); + var table_id = $('#table_id').val(); + window.location.href = "/origami/dashboard" + }else{ + var table_type = $('#table_type').text(); + var table_id = $('#table_id').text(); + + if(table_type == "Table"){ + window.location.href = "/origami/table/" + table_id + }else { + window.location.href = "/origami/room/" + table_id + } + } }); // Get Selected Class @@ -970,6 +1032,9 @@ $(function() { $(".sub_click").on("click", function(){ var menu_id = $(this).attr("data-id"); var url = "get_menu_sub_category/"+menu_id; + if ($('#type').val() == 'true') { + url = 'addorders/'+url + } sub_category = $(this).find('.sub_category_list'); show_sub_category_list(url,sub_category); }); @@ -992,7 +1057,12 @@ $(function() { data = data.sub_category; if (data.length>0) { - $(sub_category).removeClass('hidden'); + if ((sub_category.hasClass('hidden'))) { + $(sub_category).removeClass('hidden'); + }else{ + $(sub_category).addClass('hidden'); + } + for(var i in data) { row = '