App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel', { connected: function() {}, disconnected: function() {}, received: function(data) { var hostname = location.hostname.trim(); if(data.from == "" || hostname == data.from){ var shop_code = data.shop_code; var order = data.data; var audio = data.audio; if(order.length > 0){ $('.custom-table.'+shop_code+'_order_reserve_cable tbody').html(""); $("."+shop_code+" > .nav-item.red > a > p.num").text(order.length); $.each(order, function(key,value){ var active_class = ""; if(key==0){ var order_id = value.order_reservation_id; var sr_no = rowCount; var url = "order_reservation/get_order/"+order_id; if (typeof show_order_detail !== 'undefined' && $.isFunction(show_order_detail)) { show_order_detail(url,sr_no); } active_class = "tr-active"; if (typeof audioPlayBackground !== 'undefined' && $.isFunction(audioPlayBackground)) { audioPlayBackground(shop_code,audio); } if (typeof showNewOrderAlert !== 'undefined' && $.isFunction(showNewOrderAlert)) { showNewOrderAlert(order[key],shop_code); } } var rowCount = key+1; var date = new Date(value.created_at); var time = timeFormat(date); var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate()); var delivery_type = ""; if(value.provider == "food2u" || value.provider == "yangondoor2door"){ delivery_type = "DELIVERY"; }else if(value.provider == "pick_up"){ delivery_type = "PICK-UP"; }else{ delivery_type = "DIRECT DELIVERY"; } row = '' +''+rowCount +'' +''+created_at +'' +''+time +'' +''+value.grand_total +'' +'' +''+ delivery_type +'' +'' +' '; $('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row); }); } if (typeof customTableClick !== 'undefined' && $.isFunction(customTableClick)) { customTableClick(); } } } });