diff --git a/admin-dev/header.inc.php b/admin-dev/header.inc.php index 4f0b986ad..d2a5076fc 100644 --- a/admin-dev/header.inc.php +++ b/admin-dev/header.inc.php @@ -80,7 +80,102 @@ echo ' $youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), ''.Context::getContext()->shop->name.''); echo 'hints.html(hints.html()+\'
'.addslashes($youEditFieldFor).'\');'; } -echo ' + +echo ' var html = ""; + var nb_notifs = 0; + var wrapper_id = ""; + var type = new Array(); + + 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 += "
  • '.translate("A new order has been made on your shop.").'
    '.translate("Click here to see that order").'
  • "; + }); + if (html != "") + { + $("#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 += "
  • '.translate("A new customer registered on your shop.").'
    '.translate("Click here to see that customer").'
  • "; + }); + if (html != "") + { + $("#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 += "
  • '.translate("A new message posted on your shop.").'
    '.translate("Click here to see that message").'
  • "; + }); + if (html != "") + { + $("#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); + }); + } + + $(".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(); }); @@ -88,7 +183,38 @@ echo '
    - '.Configuration::get('PS_SHOP_NAME').'
    + '.CConfiguration::get('PS_SHOP_NAME').'
    '; + if(Configuration::get('PS_SHOW_NEW_ORDERS') == 1) + { + echo '
    0 +
    +

    '.translate('Last orders').'

    +
      +

      '.translate('Show all orders').'

      +
      +
      '; + } + if(Configuration::get('PS_SHOW_NEW_CUSTOMERS') == 1) + { + echo '
      0 +
      +

      '.translate('Last customers').'

      +
        +

        '.translate('Show all customers').'

        +
        +
        '; + } + if(Configuration::get('PS_SHOW_NEW_MESSAGES') == 1) + { + echo '
        0 +
        +

        '.translate('Last messages').'

        +
          +

          '.translate('Show all messages').'

          +
          +
          '; + } + echo '
          '.Tools::substr(Context::getContext()->employee->firstname, 0, 1).'. '.htmlentities(Context::getContext()->employee->lastname, ENT_COMPAT, 'UTF-8').' [ '.translate('logout').' ]'; if (Context::getContext()->shop->getBaseURL())