function getPush() { $.post("ajax.php",{"getNotifications" : "1"}, function(data) { if (data) { json = jQuery.parseJSON(data); // Add orders notifications to the list html = ""; nb_notifs = 0; $.each(json.order, function(property, value) { html += "
  • " + new_order_msg + "
    " + order_number_msg + "#" + parseInt(value.id_order) + "
    " + total_msg + "" + value.total_paid_real + "
    " + from_msg + "" + value.customer_name + "
    " + see_order_msg + "
  • "; }); if (html != "") { $("#list_orders_notif").prev("p").hide(); $("#list_orders_notif").empty().append(html); nb_notifs = $("#list_orders_notif li").length; $("#orders_notif_value").text(nb_notifs); $("#orders_notif_number_wrapper").show(); } else { $("#orders_notif_number_wrapper").hide(); } // Add customers notifications to the list html = ""; nb_notifs = 0; $.each(json.customer, function(property, value) { html += "
  • " + new_customer_msg + "
    " + customer_name_msg + "" + value.customer_name + "
    " + see_customer_msg + "
  • "; }); if (html != "") { $("#list_customers_notif").prev("p").hide(); $("#list_customers_notif").empty().append(html); nb_notifs = $("#list_customers_notif li").length; $("#customers_notif_value").text(nb_notifs); $("#customers_notif_number_wrapper").show(); } else { $("#customers_notif_number_wrapper").hide(); } // Add messages notifications to the list html = ""; nb_notifs = 0; $.each(json.message, function(property, value) { html += "
  • " + new_msg + "
    " + from_msg + "" + value.customer_name + "
    " + excerpt_msg + "" + value.message_customer + "
    " + see_msg + "
  • "; }); if (html != "") { $("#list_messages_notif").prev("p").hide(); $("#list_messages_notif").empty().append(html); nb_notifs = $("#list_messages_notif li").length; $("#messages_notif_value").text(nb_notifs); $("#messages_notif_number_wrapper").show(); } else { $("#messages_notif_number_wrapper").hide(); } } setTimeout("getPush()",60000); }); } $().ready(function() { var hints = $('.translatable span.hint'); if (youEditFieldFor) { hints.html(hints.html() + '
    ' + youEditFieldFor + ''); } var html = ""; var nb_notifs = 0; var wrapper_id = ""; var type = new Array(); $(".notifs").live("click", function(){ wrapper_id = $(this).attr("id"); type = wrapper_id.split("s_notif") $.post("ajax.php",{"updateElementEmployee" : "1", "updateElementEmployeeType" : type[0]}, function(data) { if(data) { if(!$("#" + wrapper_id + "_wrapper").is(":visible")) { $(".notifs_wrapper").hide(); $("#" + wrapper_id + "_number_wrapper").hide(); $("#" + wrapper_id + "_wrapper").show(); }else { $("#" + wrapper_id + "_wrapper").hide(); } } }); }); $("#main").click(function(){ $(".notifs_wrapper").hide(); }); getPush(); });