App.checkin = App.cable.subscriptions.create('SecondDisplayChannel', {
//  App.messages = App.cable.subscriptions.create('MessagesChannel', {

  connected: function() {},

  disconnected: function() {},

  received: function(data) {
  var hostname = location.hostname.trim();
    if(data.from == "" || hostname == data.from){
      var data_obj  = data.data;
      var status    = data.status;
      var count     = 0
      var sub_total = 0
      if (data.status == "order") {
        for(var i in data_obj) {

          sub_total = sub_total + (data_obj[i].price * data_obj[i].qty)
          count += 1
          row ='<tr>'
                  +'<td>'+count+'</td>'
                  +'<td class="item-name">'+data_obj[i].item_name+'</td>'
                  +'<td class="item-attr">'+data_obj[i].qty +'</td>'
                  + '<td class="item-attr">'+data_obj[i].qty*data_obj[i].price +'</td>'
                +'</tr>'
            $(".second_display_items").append(row);
        }//end looping
      }else{
         $('#s_sub_total').empty();
         $('#s_sub_total').append(data_obj.total_amount);
         $('#s_total_discount').empty();
         $('#s_total_discount').append(data_obj.total_discount);
         $('#s_tatal_tax').empty();
         $('#s_tatal_tax').append(data_obj.total_tax);
         $('#s_grand_total').empty();
         $('#s_grand_total').append(data_obj.grand_total);
      }
    }
  }
});
