<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Copyright (C) 2006  Sylvain FATOME

This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr
****************************************************************************************/

include ("../inc/config.inc.php");
?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_date.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php require ("../inc/fic.inc.php") ?>
<?php require ("../inc/lst.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);

	$txt_stat_tec = array(
		"--- Merci de choisir un type d'analyse statistique ---",
		"Nombre de créations de clients sur une période donnée");

 	if (strip_tags(trim(@$_POST["Submit"])) <> "Calculer") // On a peut-être choisi un type de statistique
	{
		if (strip_tags(trim(@$_POST["Submit"])) == "OK")
		{
			$typstat = strip_tags(trim($_POST['ts']));
		}
		else
			$typstat = 0;
	}
	else
		$typstat = strip_tags(trim($_POST['ts']));
	
	$stat_ok = TRUE;
	$aff_stat = FALSE;
	$pbm_stat = FALSE;

	// Vérification du mode du connecté (pour éviter les hacks)
	if (@$HTTP_SESSION_VARS["niv_log"] < 4)
		$stat_ok = FALSE;

	switch ($typstat)
	{
		case 1 :
		
			if (strip_tags(trim(@$_POST["Submit"])) == "Calculer")
			{
				$date1f = strip_tags(trim(@$_POST["date1f"]));
				if ($date1f <> "")
					$date1 = datefrang($date1f);
				else
				{
					$stat_ok = FALSE;
					$msg = "Problème sur les dates...retour au choix";
					$pbm_stat = TRUE;
				}
				
				if ($stat_ok == TRUE)
				{
					$date2f = strip_tags(trim(@$_POST["date2f"]));
					if ($date2f <> "")
						$date2 = datefrang($date2f);
					else
					{
						$stat_ok = FALSE;
						$msg = "Problème sur les dates...retour au choix";
						$pbm_stat = TRUE;
					}
				}
				
				if ($stat_ok == TRUE)
				{
					if (count($_POST["tec"]) > 0)
					{
						$tec_select = "";
						for ($i = 0; $i < count($_POST["tec"]); $i++)
						{
							$tec_select.=$_POST["tec"][$i]."-";
						}
						$tec_select_tab = explode("-",substr($tec_select,0,strlen($tec_select)-1));
						if ((in_array("tous",$tec_select_tab)) AND (count($tec_select_tab) > 1))
						{
							$stat_ok = FALSE;
							$msg = "\"TOUS\" doit être choisi seul...retour au choix";
							$pbm_stat = TRUE;
						}
					}					
					else
					{
						$stat_ok = FALSE;
						$msg = "Vous n'avez pas sélectionné de technicien...retour au choix";
						$pbm_stat = TRUE;
					}
				}
				
				if ($stat_ok == TRUE)
				{
					if (@$HTTP_SESSION_VARS["niv_log"] >= 5)
						$age = strip_tags(trim(@$_POST["age"]));
					else
						$age = @$HTTP_SESSION_VARS["code_log"];
					if ($age == "")
					{
						$stat_ok = FALSE;
						$msg = "Vous n'avez pas sélectionné d'agence...retour au choix";
						$pbm_stat = TRUE;
					}
				}

				if ($stat_ok == TRUE)
				{
					// Analyse des données et traitements statistiques
					$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
				
					/* Initialisation des totaux généraux */
				
					$nb_cli_crees_total = 0;
					$nb_cli_prospects_crees_total = 0;
					$nb_cli_ddeint_crees_total = 0;
					$nb_cli_inter_crees_total = 0;
					
					/* Calcul des totaux généraux */

					$rech = "SELECT tec_code FROM ".TBTEC;
					$rech.= " ORDER BY tec_code";
				
					$rs = mysql_query($rech) or die(mysql_error());
						
					if (mysql_num_rows($rs) >0)
					{
						while ($row = mysql_fetch_assoc($rs)) 
						{
							extract($row);

							// Détermination du nombre de clients créés par les techniciens sur la période
							$rech2 = "SELECT * FROM ".TBCLI;
							$rech2.= " WHERE cli_codecrea='".$tec_code."'";
							$rech2.= " AND cli_datecrea>='".$date1."' AND cli_datecrea<='".$date2."'";
		
							$rs2 = mysql_query($rech2) or die(mysql_error());
							$nb_cli_crees_total = $nb_cli_crees_total + mysql_num_rows($rs2);
							
							mysql_free_result($rs2);

							// Détermination du nombre de clients encore prospects et créés par les techniciens sur la période
							$rech2 = "SELECT * FROM ".TBCLI;
							$rech2.= " WHERE cli_codecrea='".$tec_code."'";
							$rech2.= " AND cli_type=0";
							$rech2.= " AND cli_datecrea>='".$date1."' AND cli_datecrea<='".$date2."'";
						
							$rs2 = mysql_query($rech2) or die(mysql_error());
							$nb_cli_prospects_crees_total = $nb_cli_prospects_crees_total + mysql_num_rows($rs2);

							mysql_free_result($rs2);
						
							// Détermination du nombre de client ayant demandé une intervention (non effectuée) et créés par les techniciens sur la période
							$rech2 = "SELECT * FROM ".TBCLI;
							$rech2.= " WHERE cli_codecrea='".$tec_code."'";
							$rech2.= " AND cli_type=1";
							$rech2.= " AND cli_datecrea>='".$date1."' AND cli_datecrea<='".$date2."'";
						
							$rs2 = mysql_query($rech2) or die(mysql_error());						
							$nb_cli_ddeint_crees_total = $nb_cli_ddeint_crees_total + mysql_num_rows($rs2);
							
							mysql_free_result($rs2);

							// Détermination du nombre total de clients ayant demandé une intervention (effectuée) et créés par les techniciens sur la période
							$nb_cli_inter_crees_total = $nb_cli_crees_total - $nb_cli_prospects_crees_total - $nb_cli_ddeint_crees_total;
						}
					}

					/* Traitement par technicien */
				
					$rech = "SELECT tec_code FROM ".TBTEC;
					
					// Traitement de multiples
					if (!in_array("tous",$tec_select_tab))
					{
						for ($i=0; $i<count($tec_select_tab); $i++)
						{
							if(!stristr($rech,"WHERE "))
								$rech.= " WHERE tec_code='".$tec_select_tab[$i]."'";
							else
								$rech.= " OR tec_code='".$tec_select_tab[$i]."'";
						}
					}
					if ($age <> "tage")
					{
						if(!stristr($rech,"WHERE "))
							$rech.= " WHERE tec_codeage='".$age."'";
						else
							$rech.= " AND tec_codeage='".$age."'";
					}
					$rech.= " ORDER BY tec_nom";
				
					$rs = mysql_query($rech) or die(mysql_error());
					$nb_tec_select = mysql_num_rows($rs);

					$i = 0;
						
					if ($nb_tec_select >0)
					{
						while ($row = mysql_fetch_assoc($rs)) 
						{
							extract($row);

							// Récupération du code technicien
							$code_tec[$i] = $tec_code;

							// Détermination du nombre de clients créés par le technicien sur la période
							$rech2 = "SELECT * FROM ".TBCLI;
							$rech2.= " WHERE cli_codecrea='".$tec_code."'";
							$rech2.= " AND cli_datecrea>='".$date1."' AND cli_datecrea<='".$date2."'";
		
							$rs2 = mysql_query($rech2) or die(mysql_error());
							$nb_cli_crees_tec[$i] = mysql_num_rows($rs2);
							mysql_free_result($rs2);

							// Détermination du nombre de clients encore prospects et créés par le technicien sur la période
							$rech2 = "SELECT * FROM ".TBCLI;
							$rech2.= " WHERE cli_codecrea='".$tec_code."'";
							$rech2.= " AND cli_type=0";
							$rech2.= " AND cli_datecrea>='".$date1."' AND cli_datecrea<='".$date2."'";
						
							$rs2 = mysql_query($rech2) or die(mysql_error());
							$nb_cli_prospects_crees_tec[$i] = mysql_num_rows($rs2);
							mysql_free_result($rs2);
						
							// Détermination du nombre de client ayant demandé une intervention (non effectuée) et créés par le techniciens sur la période
							$rech2 = "SELECT * FROM ".TBCLI;
							$rech2.= " WHERE cli_codecrea='".$tec_code."'";
							$rech2.= " AND cli_type=1";
							$rech2.= " AND cli_datecrea>='".$date1."' AND cli_datecrea<='".$date2."'";
						
							$rs2 = mysql_query($rech2) or die(mysql_error());
							$nb_cli_ddeint_crees_tec[$i] = mysql_num_rows($rs2);
							mysql_free_result($rs2);

							// Détermination du nombre total de clients ayant demandé une intervention (effectuée) et créés par le techniciens sur la période
							$nb_cli_inter_crees_tec[$i] = $nb_cli_crees_tec[$i] - $nb_cli_prospects_crees_tec[$i] - $nb_cli_ddeint_crees_tec[$i];

							$i++;
						}
					}
					mysql_close($conn);  
					
					$aff_stat = TRUE;
				}
			}
			
			break;
		
		default : 
			break;
	}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMI - ESPACE PRIVE : Statistiques Techniciens</title>

<!-- Feuille de style pour les affichages courants -->
<link href="../inc/smi.css" rel="stylesheet" type="text/css">

<!-- Feuille de style & Script pour le menu -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour affichages -->
<script language="JavaScript" src="../inc/aff.js"></script>

<!-- Définition Javascript pour calendrier popup -->

  <!-- Feuille de Style -->
  <link rel="stylesheet" type="text/css" media="all" href="../jscal/skins/aqua/theme.css" title="Aqua" />

  <!-- Script Javascript Principal -->
  <script type="text/javascript" src="../jscal/calendar.js"></script>

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscal/lang/calendar-fr.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="../jscal/calendar-setup.js"></script>

<!-- Affichage nouvelle fenêtre pour impression -->
<script type="text/javascript">
	function lanceimp(page)
	{
	  window.open(page,'impression','width='+screen.width+' height='+screen.height);
	}
</script>

<!-- Fin de la définition Javascript pour calendrier popup -->

</head>

<body>

<?php 
	include_once ("../inc/entete.php"); 
?>

<p align="center"> <span class="titrepage">STATISTIQUES TECHNICIENS </span></p>
<?PHP
$total_tec = 0;
if (@$HTTP_SESSION_VARS["niv_log"] > 4)
	$total_tec = nb_tec("");
else
{
	if (@$HTTP_SESSION_VARS["niv_log"] == 4)
		$total_tec = nb_tec(@$HTTP_SESSION_VARS["code_log"]);
}

if ($total_tec >0)
{
?>
	<form name="typstat" method="post" action="tec_stat.php">
	<br>
	<div align="center">
	<?PHP
	if ($typstat == 0)
	{
	?>
		<select name="ts" id="ts">
		<?PHP
		for ($i=0; $i<2; $i++)
		{
			if ($typstat == $i)
			{
			?>
				<option value="<?PHP echo $i; ?>" selected="selected"><?PHP echo $txt_stat_tec[$i]; ?></option>
			<?PHP
			}
			else
			{
			?>
				<option value="<?PHP echo $i; ?>"><?PHP echo $txt_stat_tec[$i]; ?></option>
			<?PHP
			}
		}
		?>					
		</select>
		<input type="submit" name="Submit" value="OK">
	<?PHP
	}
	else
	{
	?>
		<br>
		<span class="titre_gras_soul">
		<?PHP echo $txt_stat_tec[$typstat]; ?>
		</span>
		<br><br><br>
	<?PHP
		if (count($tec_select_tab) <> "")
		{
			echo "<span class=\"annot_std_it\">";
			if ((in_array("tous",$tec_select_tab)) AND (count($tec_select_tab) == 1))
			{
				echo "Tous les techniciens";
			}
			else
			{
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				if (!in_array("tous",$tec_select_tab))
					if (count($tec_select_tab) == 1) // Un seul technicien choisi
						$liste_tec = "Pour le technicien : ";
					else
						$liste_tec = "Pour les techniciens : ";
				for ($i=0; $i<count($tec_select_tab); $i++)
				{
					$rs = mysql_query("SELECT * FROM ".TBTEC." WHERE `tec_code` = '".$tec_select_tab[$i]."'");
					if (mysql_num_rows($rs) == 1) // Il ne peut y avoir qu'un seul résultat
					{
						if ($row = mysql_fetch_array($rs))
						{
							extract($row);
							$liste_tec .=$tec_nom." ".$tec_prenom.", ";
						}
					}
				}
				echo substr($liste_tec,0,strlen($liste_tec)-2);
				mysql_free_result($rs);
				mysql_close($conn);
			}
			if ($age <> "tage")
			{
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rs = mysql_query("SELECT * FROM ".TBAGE." WHERE `age_code` = '".$age."'");
				if (mysql_num_rows($rs) == 1) // Il ne peut y avoir qu'un seul résultat
				{
					if ($row = mysql_fetch_array($rs))
					{
						extract($row);
						echo "<br>Filtre sur l' agence : ".$age_nom;
					}
				}
				mysql_free_result($rs);
				mysql_close($conn);
			}
			echo "<br>";
			echo "Période du ".formatedate($date1)." au ".formatedate($date2)."<br>";
			echo "</span>";
		}
	}
	?>
	</div>
	<br>
	</form>
	<?PHP
	if (($typstat <> 0) AND ($stat_ok == TRUE))
	{
		if ($aff_stat == FALSE)
		{
	?>
			<a href="javascript:;" onclick="self.location.href=('tec_stat.php');")><img src="../img/stat.png" title="Autre statistique" width="22" height="22" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="self.location.href=('tec_stat.php');")> Autre statistique </a>
			<br>
	<?PHP
		}
		else
		{
	?>
			<a href="javascript:;" onclick="self.location.href=('tec_stat.php');")><img src="../img/stat.png" title="Nouvelle statistique" width="22" height="22" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="self.location.href=('tec_stat.php');")> Nouvelle statistique </a>
			<br>
	<?PHP
		}
	}

	if ($stat_ok == TRUE)
	{
		switch ($typstat)
		{
			case 1 :
				if ($aff_stat == FALSE) // On est en mode "paramètres"
				{
	?>
				<form name="clients" class="form_pointilles" method="post" action="tec_stat.php">
				<input name="ts" type="hidden" id="ts" value="<?PHP echo $typstat ?>">
				<table width="100%" border="0">
				<tr>
                    <td width="50%" align="center">
						<br>
						Choisissez un technicien (s&eacute;lections multiples possibles).
						<br>
						<span class="annot_petit_it">(Si 'Tous', les techniciens licenci&eacute;s seront aussi analys&eacute;s)</span>
					</td>
                    <td align="center">
					<?PHP
					if (@$HTTP_SESSION_VARS["niv_log"] >= 5)
					{
					?>
						<br>
						Choisissez une agence.
						<br>
						<br>
					<?PHP
					}
					else
					{
					?>
						&nbsp;
					<?PHP
					}
					?>
					</td>
				</tr>
				<tr>
                    <td width="50%" align="center">
						<select name="tec[]" id="tec" size="5" multiple="multiple">
						<option value="tous" selected="selected">---------- Tous ---------- </option>
		
						<?PHP
						// Création de la liste des techniciens actifs
						
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
						if (@$HTTP_SESSION_VARS["niv_log"] >= 5)
							$rs = mysql_query("SELECT * FROM ".TBTEC." WHERE `tec_out` = '0' ORDER BY tec_nom");
						else
						{
							if (@$HTTP_SESSION_VARS["niv_log"] == 4)
								$rs = mysql_query("SELECT * FROM ".TBTEC." WHERE `tec_out` = '0' AND `tec_codeage` = '".@$HTTP_SESSION_VARS["code_log"]."' ORDER BY tec_nom");
						}
						while ($resultat = mysql_fetch_array($rs)) 
						{
							extract($resultat);
							$txt_tec = $tec_nom." ".$tec_prenom." (".$tec_code.")";
							echo '<option value="'.$tec_code.'">'.$txt_tec.'</option>';
						}
						mysql_free_result($rs);
						mysql_close($conn);
						?>
						</select>
					</td>
                    <td align="center">
					<?PHP
					if (@$HTTP_SESSION_VARS["niv_log"] >= 5)
					{
					?>
						<select name="age" size="5" id="age">
						<option value="tage" selected="selected">---------- Toutes ---------- </option>
						<?PHP
						
						// Création de la liste des agences
						
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
						$rs = mysql_query("SELECT * FROM ".TBAGE." ORDER BY age_nom");
						
						while ($resultat = mysql_fetch_array($rs)) 
						{
							extract($resultat);
							echo '<option value="'.$age_code.'">'.$age_nom.'</option>';
						}
						mysql_free_result($rs);
						mysql_close($conn);
						?>
						</select>
					<?PHP
					}
					else
					{
						if (@$HTTP_SESSION_VARS["niv_log"] == 4)
						{
					?>
							<input name="age" type="hidden" id="age" value="<?PHP echo @$HTTP_SESSION_VARS["code_log"]; ?>">
					<?PHP
						}
					}
					?>
					</td>
                  </tr>
                </table>
				<br>
				<br>
				<br>
				<table width="400"  border="0" align="center">
				<tr>
					<td width="30" class="tfvNormal" id="f_date1"><div align="right">Du...</div></td>
					<td>
						<input name="date1f" type="text" id="date1f" size="10" maxlength="10" readonly="1">
						<img src="../img/calendar.png" id="f_img_date1f" title="Choisir votre date" width="16" height="16">
						<img src="../img/oblig.gif" width="10" height="11">
					</td>
					<td width="30" class="tfvNormal" id="f_date2f"><div align="right">Au...</div></td>
					<td>
						<input name="date2f" type="text" id="date2f" size="10" maxlength="10" readonly="1">
						<img src="../img/calendar.png" id="f_img_date2f" title="Choisir votre date" width="16" height="16">
						<img src="../img/oblig.gif" width="10" height="11">
					</td>
				</tr>
				</table>
				<p align="center">
				    <input type="submit" name="Submit" value="Calculer">
					<input name="init" type="reset" id="init" value="R&eacute;initialiser">
				</p>
			</form>
			
			  <script type="text/javascript">
				Calendar.setup({
					inputField     :    "date1f",     // id of the input field
					ifFormat       :    "%d-%m-%Y",      // format of the input field
					button         :    "f_img_date1f",  // trigger for the calendar (button ID)
					align          :    "Ll",           // alignment (defaults to "Bl")
					singleClick    :    true
				});
				Calendar.setup({
					inputField     :    "date2f",     // id of the input field
					ifFormat       :    "%d-%m-%Y",      // format of the input field
					button         :    "f_img_date2f",  // trigger for the calendar (button ID)
					align          :    "Ll",           // alignment (defaults to "Bl")
					singleClick    :    true
				});
			  </script>
			  
	<?PHP
			}
			else // On est en mode "affichage de stats"
			{
				// Définition et entête de la table
				echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
	
				echo "<th>";
				echo "Technicien";
				echo "</th>\n";
				echo "<th>";
				echo "Total créés";
				echo "</th>\n";
				echo "<th>";
				echo "Encore prospects";
				echo "</th>\n";
				echo "<th>";
				echo "Attente intervention";
				echo "</th>\n";
				echo "<th>";
				echo "Intervention";
				echo "</th>\n";

				$i = 0;

				/* Données pour tous les techniciens */

				// Création de l'entête de ligne (TR)
				creetrlst($i);

				echo "<td>";
				echo "<span class=\"annot_std_it\">";
				echo "Tous les techniciens";
				echo "</span>";
				echo "</td>\n";
				echo "<td align=\"center\">";
				if ($nb_cli_crees_total <> 0)
				{
					echo "<span class=\"annot_std_it\">";
					echo $nb_cli_crees_total;
					echo "</span>";
				}
				else
					echo "-";
				echo "</td>\n";
				echo "<td align=\"center\">";
				if ($nb_cli_prospects_crees_total <> 0)
				{
					echo "<span class=\"annot_std_it\">";
					echo $nb_cli_prospects_crees_total;
					echo "</span>";
					if ($nb_cli_crees_total <> 0)
					{
						echo"<span class=\"annot_petit_it\">";
						echo " (".round((($nb_cli_prospects_crees_total/$nb_cli_crees_total)*100),2)."%)";
						echo "</span>";
					}
				}
				else
					echo "-";
				echo "</td>\n";
				echo "<td align=\"center\">";
				if ($nb_cli_ddeint_crees_total <> 0)
				{
					echo "<span class=\"annot_std_it\">";
					echo $nb_cli_ddeint_crees_total;
					echo "</span>";
					if ($nb_cli_crees_total <> 0)
					{
						echo"<span class=\"annot_petit_it\">";
						echo " (".round((($nb_cli_ddeint_crees_total/$nb_cli_crees_total)*100),2)."%)";
						echo "</span>";
					}
				}
				else
					echo "-";
				echo "</td>\n";
				echo "<td align=\"center\">";
				if ($nb_cli_inter_crees_total <> 0)
				{
					echo "<span class=\"annot_std_it\">";
					echo $nb_cli_inter_crees_total;
					echo "</span>";
					if ($nb_cli_crees_total <> 0)
					{
						echo"<span class=\"annot_petit_it\">";
						echo " (".round((($nb_cli_inter_crees_total/$nb_cli_crees_total)*100),2)."%)";
						echo "</span>";
					}
				}
				else
					echo "-";
				echo "</td>\n";

				echo "</tr>\n";
				
				$i++;

				/* Saut de ligne pour lisibilité */
				
				// Création de l'entête de ligne (TR)
				creetrlst($i);

				echo "<td>";
				echo "&nbsp;";
				echo "</td>\n";
				echo "<td>";
				echo "&nbsp;";
				echo "</td>\n";
				echo "<td>";
				echo "&nbsp;";
				echo "</td>\n";
				echo "<td>";
				echo "&nbsp;";
				echo "</td>\n";
				echo "<td>";
				echo "&nbsp;";
				echo "</td>\n";

				echo "</tr>\n";
				
				$i++;

				if ($nb_tec_select > 0)
				{
					for ($j=0; $j<$nb_tec_select; $j++)
					{
						// Création de l'entête de ligne (TR)
						creetrlst($i);
		
						echo "<td>";
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
						$rs = mysql_query("SELECT * FROM ".TBTEC." WHERE `tec_code` = '".$code_tec[$j]."'");
						if ($row = mysql_fetch_array($rs))
						{
							extract($row);
							$txt_tec = $tec_nom." ".$tec_prenom;
						}
						mysql_free_result($rs);
						mysql_close($conn);
						echo "<span class=\"annot_std_gras\">";
						echo $txt_tec." (".$code_tec[$j].")";
						echo "</span>";
						if ($tec_out == 1)
						{
							echo "<span class=\"annot_petit_it\">";
							echo " Licencié";
							echo "</span>";
						}
						echo "<br>";
						if ($nb_cli_crees_tec[$j] <> 0)
						{
							echo "<span class=\"annot_petit_it\">";
							echo "<div align=\"right\">";
							echo "Par rapport technicien : ";
							echo "<br>Par rapport total : ";
							echo "</div>";
							echo "</span>";
						}
						echo "</td>\n";
						echo "<td align=\"center\">";
						if ($nb_cli_crees_tec[$j] <> 0)
						{
							echo "<span class=\"annot_std_gras\">";
							echo $nb_cli_crees_tec[$j];
							echo "</span>";
							if ($nb_cli_crees_total <> 0)
							{
								echo"<span class=\"annot_petit_it\">";
								echo "<br>-<br>(".round((($nb_cli_crees_tec[$j]/$nb_cli_crees_total)*100),2)."%)";
								echo "</span>";
							}							
						}
						else
							echo "-";
						echo "</td>\n";
						echo "<td align=\"center\">";
						if ($nb_cli_prospects_crees_tec[$j] <> 0)
						{
							echo "<span class=\"annot_std_gras\">";
							echo $nb_cli_prospects_crees_tec[$j];
							echo "</span>";
							echo "<br>";
							if ($nb_cli_crees_tec[$j] <> 0)
							{
								echo"<span class=\"annot_petit_it\">";
								echo "(".round((($nb_cli_prospects_crees_tec[$j]/$nb_cli_crees_tec[$j])*100),2)."%)";
								echo "</span>";
							}
							else
								echo "-";
							echo "<br>";
							if ($nb_cli_prospects_crees_total <> 0)
							{
								echo"<span class=\"annot_petit_it\">";
								echo "(".round((($nb_cli_prospects_crees_tec[$j]/$nb_cli_prospects_crees_total)*100),2)."%)";
								echo "</span>";
							}							
							else
								echo "-";
						}
						else
							echo "-";
						echo "</td>\n";
						echo "<td align=\"center\">";
						if ($nb_cli_ddeint_crees_tec[$j] <> 0)
						{
							echo "<span class=\"annot_std_gras\">";
							echo $nb_cli_ddeint_crees_tec[$j];
							echo "</span>";
							echo "<br>";
							if ($nb_cli_crees_tec[$j] <> 0)
							{
								echo"<span class=\"annot_petit_it\">";
								echo " (".round((($nb_cli_ddeint_crees_tec[$j]/$nb_cli_crees_tec[$j])*100),2)."%)";
								echo "</span>";
							}
							else
								echo "-";
							echo "<br>";
							if ($nb_cli_ddeint_crees_total <> 0)
							{
								echo"<span class=\"annot_petit_it\">";
								echo "(".round((($nb_cli_ddeint_crees_tec[$j]/$nb_cli_ddeint_crees_total)*100),2)."%)";
								echo "</span>";
							}							
							else
								echo "-";
						}
						else
							echo "-";
						echo "</td>\n";
						echo "<td align=\"center\">";
						if ($nb_cli_inter_crees_tec[$j] <> 0)
						{
							echo "<span class=\"annot_std_gras\">";
							echo $nb_cli_inter_crees_tec[$j];
							echo "</span>";
							echo "<br>";
							if ($nb_cli_crees_tec[$j] <> 0)
							{
								echo"<span class=\"annot_petit_it\">";
								echo " (".round((($nb_cli_inter_crees_tec[$j]/$nb_cli_crees_tec[$j])*100),2)."%)";
								echo "</span>";
							}							
							echo "<br>";
							if ($nb_cli_inter_crees_total <> 0)
							{
								echo"<span class=\"annot_petit_it\">";
								echo "(".round((($nb_cli_inter_crees_tec[$j]/$nb_cli_inter_crees_total)*100),2)."%)";
								echo "</span>";
							}							
							else
								echo "-";
						}
						else
							echo "-";
						echo "</td>\n";
		
						echo "</tr>\n";
						
						$i++;
					}
				}
				else
				{
					// Création de l'entête de ligne (TR)
					creetrlst($i);
	
					echo "<td>";
					echo"<span class=\"annot_petit_it\">";
					echo "Aucun résultat à cette demande.";
					echo "</span>";
					echo "</td>\n";
					echo "<td>";
					echo "&nbsp;";
					echo "</td>\n";
					echo "<td>";
					echo "&nbsp;";
					echo "</td>\n";
					echo "<td>";
					echo "&nbsp;";
					echo "</td>\n";
					echo "<td>";
					echo "&nbsp;";
					echo "</td>\n";
	
					echo "</tr>\n";
				}
				
				echo "</table>\n";
				// *** Fin affichage de la table
		}
		
			break;
		}
	}
	else
	{
		if ($pbm_stat == TRUE)
		{
		?>
			<p align="center" class="annot_std_it"><?PHP echo $msg; ?></p>
			<script type="text/javascript">
			window.setTimeout("location=('tec_stat.php');",5000)
			</script>
		<?PHP
		}
	}
}
else
{
?>
	<p align="center" class="annot_std_it">Vous n'avez cr&eacute;&eacute; aucun technicien...</p>
	<p align="center" class="annot_std_it">Retour à l'accueil dans 2 secondes...</p>
	<script type="text/javascript">
	window.setTimeout("location=('index.php');",2000)
	</script>
<?PHP
}
?>



<?php 
	include_once ("pied.php")
?>
