<SCRIPT language="JavaScript" type="text/javascript">
$(function() {
  var $menu=$("#menu");
  var menuWidth = $menu.width();
  var notesLeft = menuWidth + 170;
  //alert(notesLeft);
  var $notes=$("#notes");
  $notes.css("left", notesLeft);
});
setInterval(function() {
  var $notesItems = $("#notes .item");
  $notesItems.each(function() {
	var $notesItem = $(this);
	var personne = $notesItem.attr("data-user");
    jQuery.ajax({ 
      url: "refreshMessageAjax.php", 
      data: { Personne: personne }, 
      success: function(result) {
	    var resultObject = $.parseJSON(result);
	    $notesItem.removeClass("normal actif alert").addClass(resultObject.statut);
	    var $notesItemCounter = $notesItem.children(".counter");
	    $notesItemCounter.html(resultObject.items);
	    //alert(resultObject.statut);
	    //alert(resultObject.items);
      } 
	});
	//alert(personne);
	
  });
}, 10000);
</SCRIPT>
<?php
?> 
<style>
#notes
{
  position: fixed;
  top: 11px;
  height: 32px;
}
#notes .item, #notes .anni
{
  height: 26px;
  display: inline-block;
  padding: 3px 10px;
  font-size: 18px;
  border-radius: 16px;
}
#notes .item.normal
{
  background-color: black;
  color: grey;
}
#notes .item.actif
{
  background-color: blue;
}
#notes .item.alert, #notes .anni.alert
{
  background-color: yellow;
}
#notes .item .counter
{
  font-weight: bold;
}

</style>
<?php
require_once 'database.inc.php';
if(Test_User($lg_user,$lg_password)==True)
{
  $personnes_notes = get_config("NOTES_PERSO");
  if ($personnes_notes != "")
  {
    echo "<div id=\"notes\">\n";
	$personnes_notes_a = explode(";", $personnes_notes);
	foreach ($personnes_notes_a as $personne_notes)
	{
	  $requettenew = "SELECT * FROM message".ID_GARAGE." WHERE A = '$personne_notes' AND Etat = 0";
	  $resultatnew = Message::getByAAndEtat($personne_notes, 0);
	  $nbnew = count($resultatnew);
	  $requetteactif = "SELECT * FROM message".ID_GARAGE." WHERE A = '$personne_notes' AND Etat = 1";
	  $resultatactif = Message::getByAAndEtat($personne_notes, 1);
	  $nbactif = count($resultatactif);
	  $nbtot = $nbactif + $nbnew;
	  if (isset($Type) && isset($Sous_Type) && $Type == 7 && $Sous_Type == 1)
	  {
	    $target = "";
	  }
	  else
	  {
	    $target = " target=\"_blank\" rel='opener'";
	  }
	  echo "<a href=\"default.php?Type=7&Sous_Type=1&Personne=$personne_notes\" $target>\n";
	  if ($nbnew > 0)
	  {
        echo "<div class=\"item alert\" data-user=\"$personne_notes\"><span class=\"counter\">$nbtot</span> $personne_notes</div>\n";
	  }
	  else if ($nbactif > 0)
	  {
        echo "<div class=\"item actif\" data-user=\"$personne_notes\"><span class=\"counter\">$nbtot</span> $personne_notes</div>\n";
	  }
	  else
	  {
        echo "<div class=\"item normal\" data-user=\"$personne_notes\"><span class=\"counter\">$nbtot</span> $personne_notes</div>\n";
	  }
	  echo "</a>\n";
	}
    if (isset($Type) && isset($Sous_Type) && $Type == 8 && $Sous_Type == 1)
    {
	  $target = "";
    }
    else
    {
	  $target = " target=\"_blank\" rel='opener'";
    }
	$requetteanni = "SELECT NoClient FROM clients WHERE DateNaissance LIKE '%-".date("m-d")."'";
	$resultatanni = Client::getClientByDateNaissance();
	$nbanni = count($resultatanni);
	echo "<a href=\"default.php?Type=8&Sous_Type=1\" $target>\n";
	echo "<div class=\"anni alert\"><span class=\"counter\">$nbanni</span> Anni</div>\n";
    echo "</a>\n";
    echo "</div>\n";
  }
}
?>