App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChannel', { // App.messages = App.cable.subscriptions.create('MessagesChannel', { connected: function() {}, disconnected: function() {}, received: function(data) { var oqs_id = $('.oqs_active').attr('data-id'); items = data.order; for(var field in items) { var price = parseFloat(items[field].price).toFixed(2); if (items[field]["options"] == "[]" || items[field]["options"] == "") { var options = ""; }else{ var options = items[field]["options"]; } //for count test = document.getElementsByClassName("oqs_count"); for (var i = 0; i < test.length; i++) { oqs_count_id = $(".oqs_count"+i).attr("data-id"); oqs_count = $(".oqs_count"+i).text(); if ( oqs_count_id == items[field]["order_queue_station_id"]) { oqs_count_total = +oqs_count +1 ; $(".oqs_count"+i).text(oqs_count_total) } } //end count var date = new Date(items[field]["created_at"]); var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); if (oqs_id == items[field]["order_queue_station_id"]) { row ='
' +'' +'
' +'
' +''+items[field]["table_type"]+'-'+ items[field]["zone"] +'' +'' +''+items[field]["order_id"]+'' +'
' +'

' +''+ items[field]["item_name"] +'- ' +' [x'+ items[field]["qty"] +'] ' +'

' +'

'+ options +'

' +'' +'Order at - ' +''+ show_date +'
' +'Order By - '+ items[field]["item_order_by"] +' ' +'
' +'
' +' ' +' ' +'
' +'' +'
'; $('.oqs_append').append(row); } }//end looping var $divs = $("div.queue_station"); var SortListDivs = $divs.sort(function (a, b) { first = $(a).attr('data-order-no'); next = $(b).attr('data-order-no'); return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16)); }); $("#oqs_container").html(SortListDivs); }, });