diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index e51086b5..71e6b25a 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -426,13 +426,13 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas access_code = approved_code; } - $.ajax({ - type: "POST", - url: post_url, - data: {url: callback, ref_no: ref_no, status: status, waiting_time: waiting_time, min_type: type, reason: reject_reason}, - dataType: "json", - success: function(data) { - if(data.status){ + // $.ajax({ + // type: "POST", + // url: post_url, + // data: {url: callback, ref_no: ref_no, status: status, waiting_time: waiting_time, min_type: type, reason: reject_reason}, + // dataType: "json", + // success: function(data) { + // if(data.status){ $.ajax({ type: "POST", url: url, @@ -466,21 +466,21 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas } } }); - }else{ - swal({ - title: 'Oops', - text: data.message, - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/order_reservation'; - }); - } - } - }); + // }else{ + // swal({ + // title: 'Oops', + // text: data.message, + // type: 'error', + // html: true, + // closeOnConfirm: false, + // closeOnCancel: false, + // allowOutsideClick: false + // }, function () { + // window.location.href = '/origami/order_reservation'; + // }); + // } + // } + // }); } function showNewOrderAlert(order_reservation,shop_code){ diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 32c7f81e..c5e8c56b 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -463,4 +463,21 @@ function showHideNavbar(webview,page){ function createAccessCode(code) { localStorage.setItem("access_code",code); +} + +//get menu item cache +function getAllMenu(){ + $.ajax({ + type: "GET", + url: '/origami/get_all_menu', + data: {}, + success:function(result){ + localStorage.setItem("menus", JSON.stringify(result)); + + var menu = localStorage.getItem("menus"); + if (menu != null ) { + $( "#loading_wrapper").hide(); + } + } + }); } \ No newline at end of file diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index ea760e33..27625a84 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -31,10 +31,12 @@ class Origami::OrderReservationController < BaseOrigamiController else if @status == "rejected" OrderReservation.update_order_reservation(@id, nil, "rejected",nil,remark,access_code,current_user) - result = {:status=> true, :message => "rejected" } + response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"rejected") + result = {:status=> true, :message => "rejected" } else OrderReservation.update_order_reservation(@id, nil, "accepted", expected_waiting_time) - result = {:status=> true, :message => "accepted" } + response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"accepted") + result = {:status=> true, :message => "accepted" } end end render :json => result.to_json diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 67fef50f..a8f1f4ec 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -173,6 +173,7 @@ class OrderReservation < ApplicationRecord end def self.send_status_to_ordering(url,ref_no,status,waiting_time=nil,min_type=nil,reason=nil) + puts "send status to ordering" base_url = 'https://api.doemal.com' token = '3T-tnlYtFJ-5Z1vY6XQqxQ' order_reservation = Lookup.collection_of("order_reservation") @@ -191,19 +192,19 @@ class OrderReservation < ApplicationRecord Rails.logger.debug "Doemal URL" + base_url post_url = base_url + url - if status == 'processed' - status = 'send_to_kitchen' - elsif status == 'delivered' - status = 'ready_to_deliver' - elsif status == 'completed' - status = 'delivered' - else - status = status - end + # if status == 'processed' + # status = 'send_to_kitchen' + # elsif status == 'delivery' + # status = 'ready_to_delivery' + # elsif status == 'completed' + # status = 'delivered' + # else + # status = status + # end - if waiting_time != "" + if (!min_type.nil? && !waiting_time.nil?) && (min_type != "" && waiting_time != "") send_params = {id: ref_no,type: min_type, waiting_time: waiting_time, status: status} - elsif reason != "" + elsif !reason.nil? && reason != "" send_params = {id: ref_no, status: status, reason: reason} else send_params = {id: ref_no, status: status} @@ -226,7 +227,7 @@ class OrderReservation < ApplicationRecord rescue SocketError response = { status: false} end - Rails.logger.debug "Get Doemal Status " + Rails.logger.debug "Get Doemal Status => #{send_params}" Rails.logger.debug response.to_json return response end diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index bbd9cb79..ec8a4804 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -573,7 +573,7 @@ var menus = JSON.parse(localStorage.getItem("menus")); if (menus != null) { var id = menus[0]["categories"][0]["id"]; - console.log(id); + // console.log(id); }else{ var id = 1; } @@ -583,7 +583,6 @@ $(document).ready(function () { var menus = JSON.parse(localStorage.getItem("menus")); if (menus != null) { - console.log("menu"); menu_cache_append(menus); }else{ $("#menu_data").removeClass("hidden"); diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb index a0b0dc51..4b7c6f2c 100644 --- a/app/views/origami/dashboard/index.html.erb +++ b/app/views/origami/dashboard/index.html.erb @@ -211,23 +211,8 @@ " id="server_mode">