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});
}
}