App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSendToKitchenChannel', {
  connected: function() {},

  disconnected: function() {},

  received: function(data) {    
    var hostname = location.hostname.trim();
    if(data.from == "" || hostname == data.from)
    {
      var order  = data.data;
      var shop_code  = data.shop_code;
      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);
      if (typeof checkOrderSendToKitchen !== 'undefined' && $.isFunction(checkOrderSendToKitchen)) {
        checkOrderSendToKitchen(shop_code, order_lists);
      }
      // $("#notify_order_send_to_kitchen_lists").text(order_lists);
      // if($("#notify_order_send_to_kitchen").hasClass("hidden")){
        // $("#"+shop_code+"_notify_order_send_to_kitchen").removeClass("hidden");
      // }
      // $("#"+shop_code+"_notify_order_send_to_kitchen").on('shown.bs.modal', function(e){
      //   // $(document).off('focusin.modal');
      //   $("#"+shop_code+"_notify_order_send_to_kitchen").focus();
      //   $("#"+shop_code+"_doemal_new_order").addClass("hidden");
      //   $("#"+shop_code+"_notify_new_order").addClass("hidden");
      //   $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
      // }).on('hide.bs.modal', function (e) {
      //   $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
      // }).modal({show: true, keyboard: false, backdrop: false});
    }
  }
}
});

