From 0a07b3479d76bfed3c4e55ebf9ead2e7639b5b0e Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 11 May 2018 17:03:53 +0630 Subject: [PATCH] check shop code for new order --- .../javascripts/channels/order_reservation.js | 7 ++--- app/assets/javascripts/order_reservation.js | 24 ++++++++++-------- .../order_reservation_controller.rb | 8 +++++- .../origami/order_reservation_controller.rb | 1 + .../origami/order_reservation/index.html.erb | 24 +++++++++++++++++- public/beep.mp3 | Bin 0 -> 63528 bytes public/beep.wav | Bin 9702 -> 0 bytes 7 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 public/beep.mp3 delete mode 100644 public/beep.wav diff --git a/app/assets/javascripts/channels/order_reservation.js b/app/assets/javascripts/channels/order_reservation.js index 52b4cef5..b0e0c272 100644 --- a/app/assets/javascripts/channels/order_reservation.js +++ b/app/assets/javascripts/channels/order_reservation.js @@ -3,10 +3,11 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel' disconnected: function() {}, - received: function(data) { + received: function(data) { + var shop_code = data.shop_code; var order = data.data; if(order.length > 0){ - $('.order_reserve_cable tbody').html(""); + $('.custom-table.'+shop_code+'_order_reserve_cable tbody').html(""); $(".nav-item.red > a > p.num").text(order.length); $.each(order, function(key,value){ var active_class = ""; @@ -42,7 +43,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel' +'' +' '; - $('.custom-table.order_reserve_cable tbody').append(row); + $('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row); }); } diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index 8f631284..9b7c8a06 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -405,27 +405,29 @@ function timeFormat(date){ } function showNewOrder(order_reservation){ - // console.log(order_reservation); if((order_reservation!=undefined) && (order_reservation!=null) && (order_reservation!="")){ var date = new Date(order_reservation.requested_time); var time = timeFormat(date); var requested_date = date.getFullYear() + '-' + (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >= 10? date.getDate() : '0' + date.getDate()) +' '+time; //audio play - var audio = new Audio('/beep.wav'); // define your audio + var audio = new Audio('/beep.mp3'); // define your audio // setTimeout(function(){ // audio.loop = true; audio.play(); // },10000); - swal({ - html: true, - title: 'Information', - text: "You have new order " + order_reservation.order_reservation_id + " at "+requested_date+"", - type: 'success', - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }); + $("#new_order").text(order_reservation.order_reservation_id); + $("#new_order_date").text(requested_date); + $("#doemal_new_order").on('show.bs.modal', function(e){ + $("#notify_new_order").modal('hide'); + $("#notify_order_send_to_kitchen").modal('hide'); + $("#notify_order_ready_to_delivery").modal('hide'); + }).on('shown.bs.modal', function(e){ + $("#doemal_new_order").focus(); + }).on('hide.bs.modal', function (e) { + audio.pause(); + $("#doemal_new_order").modal("hide"); + }).modal({show: true, keyboard: false, backdrop: false}); } } diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index 866d3da3..d85a85b2 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -64,8 +64,14 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation) if flag #&& ENV["SERVER_MODE"] != 'cloud' + shop = Shop.find_by_id(1) + if !shop.shop_code.nil? + shop_code = shop.shop_code + else + shop_code = '' + end order_reservation = OrderReservation.get_pending_orders #find(order_reservation_id) - ActionCable.server.broadcast "order_reservation_channel",data: order_reservation + ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code end if flag diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 827cfcda..a3421fbd 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -4,6 +4,7 @@ class Origami::OrderReservationController < BaseOrigamiController @order = OrderReservation.latest_order #.active @count_on_order = OrderReservation.get_count_on_order @count_on_completed = OrderReservation.get_count_on_completed + @shop = Shop.find_by_id(1) end def update diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb index 9a958dde..aa85fe71 100644 --- a/app/views/origami/order_reservation/index.html.erb +++ b/app/views/origami/order_reservation/index.html.erb @@ -67,7 +67,7 @@