check shop code for new order

This commit is contained in:
phyusin
2018-05-11 17:03:53 +06:30
parent a896617a4d
commit 0a07b3479d
7 changed files with 48 additions and 16 deletions

View File

@@ -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'
+'</td>'
+' </tr>';
$('.custom-table.order_reserve_cable tbody').append(row);
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row);
});
}

View File

@@ -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 <b>" + order_reservation.order_reservation_id + "</b> at <b>"+requested_date+"</b>",
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});
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -67,7 +67,7 @@
<div class="tab-pane active" id="pending" role="tabpanel">
<div class="card-block font-13">
<div id="menu-slimscroll" data-height="50">
<table class="table table-stripe custom-table order_reserve_cable">
<table class="table table-stripe custom-table <%= @shop.shop_code %>_order_reserve_cable">
<tbody>
<% i=1
@order.each do |order| %>
@@ -571,6 +571,28 @@
</div>
</div>
<div class="modal fade text-center" id="doemal_new_order" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title text-center" id="doemal_new_orderLabel">New Order</h4><hr>
</div>
<div class="modal-body doemal_new_orderBody">
<div class="form-group text-center">
You have new order <b><span id="new_order"></span></b> at <b><span id="new_order_date"></span></b>
</div>
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade text-center" id="notify_new_order" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">

BIN
public/beep.mp3 Normal file

Binary file not shown.

Binary file not shown.