Files
sx-fc/app/assets/javascripts/channels/check_new_order.js
2018-05-09 11:28:01 +06:30

42 lines
1.2 KiB
JavaScript

App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', {
connected: function() {},
disconnected: function() {},
received: function(data) {
var order = data.data;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
if(key==0){
order_lists = value.order_reservation_id;
}else if(key == (order.length - 1)){
order_lists += ' and ' + value.order_reservation_id;
}else{
order_lists += ', ' + value.order_reservation_id;
}
});
// alert(order_lists);
swal({
title: 'Information',
target: document.getElementById("notify_new_order"),
text: "You have new orders <br/>"+
"Are you accept or reject for these orders <b>"+order_lists+"</b>?",
type: 'success',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
if(isConfirm){
swal.close();
}
});
// $("#notify_new_order_lists").text(order_lists);
// $("#notify_new_order").modal({show: true, keyboard: false, backdrop: false});
}
}
});