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

Version 0.9.9

Copyright (C) 2006-2009  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

Web : http://smitst.homelinux.com
****************************************************************************************/

session_start(); 
if (!isset($_SESSION["lng"])) $_SESSION["lng"]="fr";
include_once("../lng/".$_SESSION["lng"].".inc.php"); // Paramètres de language
include_once("../inc/config.inc.php");
include_once("../inc/func_log.inc.php");
if (CheckURLLog(FALSE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("10-11")==FALSE) header("Location: ../index.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_fici.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);
$pbm_conf=FALSE;
if (!exist_logo("cge")) $pbm_conf=TRUE;
if (!exist_logo(@$_SESSION["code_st"])) $pbm_conf=TRUE;
if (!existe_cdg()) $pbm_conf=TRUE;
$tx="m";
?>
<!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 - <?PHP echo $title_esp_prive; ?> : Index Sous-Traitant</title>

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

<!-- Feuille de style & Script pour le menu -->
<script language="JavaScript" src="../jscript/coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour fenêtres -->
<script language="JavaScript" src="../jscript/fen.js"></script>

<!-- Scripts Javascript divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

<!-- Scripts Javascript pour alertes -->
<script language="JavaScript" src="../jscript/alertes.js"></script>


</head>

<body onLoad="set_mnu_ageidx('m1');">

<?php
if ($pbm_conf==FALSE)
{
include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage">VOTRE TABLEAU DE BORD</span><br></p>
<br>
<div id="menu_ageidx" class="menu_ongletfull">
<a class="ongleti" id="m1" href="javascript:;" onclick="set_mnu_ageidx(this.id);" onFocus="this.blur();"><?PHP echo $mnuo_tacnt; ?></a>
<a class="ongleti" id="m2" href="javascript:;" onclick="set_mnu_ageidx(this.id);" onFocus="this.blur();">Bons de travail en cours</a>
<a class="ongleti" id="m3" href="javascript:;" onclick="set_mnu_ageidx(this.id);" onFocus="this.blur();">Bons de travail &agrave; affecter</a>
</div>
<br>

<div id="detailm1" style="display:none">
<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	$rech = cree_strrechlsttac($niv_urgence);
	switch (@$_SESSION["niv_log"])
	{
		// Filtre pour les techniciens sous-traitants
		case 11 :
			if(!stristr($rech,"WHERE "))
				$rech .= " WHERE ".TBTAC.".tac_codedest='".@$_SESSION["code_log"]."'";
			else
				$rech .= " AND ".TBTAC.".tac_codedest='".@$_SESSION["code_log"]."'";
			break;
		// Filtre pour les sous-traitants
		case 10 :
			// On construit la liste des techniciens actifs du sous-traitant
			$tab_lst_tec=array();
			$rech2 = "SELECT tec_code FROM ".TBTEC." WHERE tec_codest='".@$_SESSION["code_log"]."' AND tec_out=0";
			$rs2 = mysql_query($rech2) or die(mysql_error());
			while($row2 = mysql_fetch_array($rs2))
			{
				extract($row2);
				$tab_lst_tec[]=$tec_code;
			}
		
			if(!stristr($rech,"WHERE "))
				$rech .= " WHERE (".TBTAC.".tac_codedest='".@$_SESSION["code_log"]."'";
			else
				$rech .= " AND (".TBTAC.".tac_codedest='".@$_SESSION["code_log"]."'";
			foreach ($tab_lst_tec as $key=>$value)
			{
				$rech .= " OR ".TBTAC.".tac_codedest='".$value."'";
			}
			$rech.=")";
			break;
	}

	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE tac_datefin='0000-00-00'";
	else
		$rech .= " AND tac_datefin='0000-00-00'";
	$rech .= "ORDER BY ".TBTAC.".tac_code DESC";

	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	$nbtaches=$numrows;

	if($numrows > 0)
	{
		// *** Affichage de la table
		 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
	
		// Création entête
		titlst($tac_titre_col,FALSE);
		echo "<th>".ucfirst($txt_ent_lst_clic)."</th>\n";
			
		$i = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
		 // Affichage résumé tâche
	
			// Création de l'entête de ligne (TR)
			creetrlst($i);
	
			echo "<td>";
			echo $row["tac_code"];
			$rech2="SELECT * FROM ".TBTACC." WHERE `tacc_code`='".$row["tac_codetacc"]."'";
			$rs2 = mysql_query($rech2) or die(mysql_error());
			if ($row2 = mysql_fetch_array($rs2))
			{
				$txttacc = $alt_typtac." : ".$row2["tacc_desc"]." (".$row2["tacc_code"].")";
				echo " <img src=\"".$row2["tacc_img"]."\" title=\"".$txttacc."\" height=\"16\" witdh=\"16\" border=\"0\" align=\"absmiddle\">";
			}
									
			// Détail de la tâche
			if (trim($row["tac_afaire"])<>"")
				echo " <a href=\"#\" class=\"pop\"><img src=\"../img/help.png\" alt=\"R&eacute;sum&eacute;\" border=\"0\" align=\"absmiddle\"><span>-- ".trim($row["tac_titre"])." --<br>".formatetxtbr(trim($row["tac_afaire"]))."</span></a>";
		
			// Auteur
			echo "<div align=\"right\" class=\"annot_petit_it\">";
			echo "Auteur : ";
			if (trim($row["tac_codecrea"])<>@$_SESSION["code_log"])
				echo $row["tac_codecrea"];
			else
				echo "vous-m&ecirc;me";
			echo "</div>";
			
			// Si rattachée
			if (trim($row["tac_coderat"])<>"")
			{
				echo "<div align=\"right\" class=\"annot_petit_it\">";
				echo "Rattach&eacute;e &agrave; ";
				switch ($row["tac_typrat"])
				{
					case 1 :
						echo "int. ";
						break;
					case 2 :
						echo "cont. maint. ";
						break;
					case 3 :
						echo "cont. loc. ";
						break;
					case 4 :
						echo "dossier ";
						break;
					case 5 :
						echo "relev&eacute; ";
						break;
					case 6 :
						echo "bon trav. ";
						break;
				}
				echo $row["tac_coderat"];
				echo "</div>";
			}
			echo "</td>\n";
			 echo "<td align=\"center\">";;
			echo formatedate($row["tac_datecrea"]);
			echo "</td>\n";
			 echo "<td align=\"center\">";;
			echo formatedate($row["tac_datefinp"]);
			// Icône si date de fin dépassée
			if (formatedate($row["tac_datefin"])=="")
			{
				if (echeance_depassee_date($datea,$row["tac_datefinp"]) == TRUE)
					echo " <img src=\"../img/warn.png\" title =\"".$alt_dtedep."\" border=\"0\">";
			}
			echo "</td>\n";
	
			// Affichage détail urgence
			 echo "<td align=\"center\">";;
			echo $niv_urgence[$row["tac_urg"]];
			echo "</td>\n";
			// Fin affichage détail urgence
	
			// Affichage destinataire
			 echo "<td align=\"center\">";;
			if ($row["tac_codedest"]=="CGE")
				echo "Centre de gestion";
			else
				echo $row["tac_codedest"];
			echo "</td>\n";
			// Fin affichage destinataire
			
			 // Affichage Icône Avancement
			 echo "<td align=\"center\">";;
			 echo "<img src=\"../img/2pour".$row["tac_avance"].".png\" title=\"".$row["tac_avance"]."%\" border=\"0\" align=\"absmiddle\">";
			 echo "</td>\n";
	
			// CREATION lien dynamique sur icône (édition, suppression, etc...)
			 echo "<td align=\"center\">";;
	
			$lst_maj = TRUE;
			echo "<a href=\"tac_maj.php?td=edit&ct=".$row["tac_code"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_edit."\"></a>";
			echo " ";
	
			if  ($row["tac_codecrea"] == @$_SESSION["code_log"])
			{
				$lst_del = TRUE;
				echo "<a href=\"tac_maj.php?td=del&ct=".$row["tac_code"]."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_del."\"></a>";
				echo " ";
			}
			 echo "</td>\n";
	
			 echo "</tr>\n";
		 // Fin affichage résumé Tâche
			
			$i++;    
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
	}
	else
	{
		echo "<div class=\"annot_gras_it\">";
		echo "<br />".$alert_notacnt;
		echo "</div>";
	}	

	
	mysql_close($conn);  
	
	$taille_piedla="";
	include("../inc/piedla.inc.php"); ?>
</div>

<div id="detailm2" style="display:none">
<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);

	$rech = cree_strrechlstotst($niv_urgence);
	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE ".TBOT.".ot_codest='".@$_SESSION["code_st"]."' AND ".TBOT.".ot_codetec <> '-1' AND ".TBOT.".ot_codestatut <> 'CLOT'";
	else
		$rech .= " AND ".TBOT.".ot_codest='".@$_SESSION["code_st"]."' AND ".TBOT.".ot_codetec <> '-1' AND ".TBOT.".ot_codestatut <> 'CLOT'";
		
	$rech .= "ORDER BY ".TBOT.".ot_code DESC";
	// *** Fin de Chaîne de Recherche
		 
	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	
	if($numrows > 0)
	{
		echo "<span class=\"annot_std_it\">";
		echo "(Lieu/Statut : laisser la souris sur l'icône pour le d&eacute;tail)<br>";
		echo "</span>";
	
		// *** Affichage de la table
		 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
	
		// Création entête
		titlst($ot2_titre_col);
		echo "<th>".ucfirst($txt_ent_lst_clic)."</th>\n";
		
		$i = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
	 // Affichage résumé ordre

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

		echo "<td>";
		echo $row["ot_code"];
		$detfic=">>Mat&eacute;riel :<br />".$row["ot_mat"]."<br /><br />>>Travail &agrave; effectuer :<br />".$row["ot_pbm"];
		if ($detfic<>"")
			echo " <a href=\"#\" class=\"pop\"><img src=\"../img/help.png\" alt=\"D&eacute;tail\" border=\"0\" align=\"absmiddle\"><span>".formatetxtbr($detfic)."</span></a>";
		echo "</td>\n";

		echo "<td>";
		echo "<div align=\"center\">";
		echo formatedate($row["ot_datedde"]);
		echo "</div>";
		echo "</td>\n";
		echo "<td align=\"center\">";
		echo formatedate($row["ot_daterdv"]);
		if (formatedate($row["ot_daterdv"])<>"")
		{
			echo "<div align=\"center\" class=\"annot_petit_it\">";
			echo substr($row["ot_hrdv"],0,5);
			echo "</div>";
		}
		echo "</td>\n";

		 // Affichage Icône Lieu
		 echo "<td>";
		 $lieu = $row["ot_codelieu"];
		 $rechlieu = "SELECT * FROM ".TBLIEU." WHERE lieu_code = '$lieu'";
		 
		 $rslieu = mysql_query($rechlieu) or die(mysql_error());
		 
		if (mysql_num_rows($rslieu) <> 0)
		{
			 if ($rowlieu = mysql_fetch_array($rslieu)) 
			{
				extract ($rowlieu);
				if ($lieu_img <> "")
				{
					$lieuint = $lieu_desc." (".$lieu.")";
					echo "<div style=\"float:left;width:40px;\">";
					echo "<img src=\"".$lieu_img."\" title=\"".$lieuint."\" border=\"0\" align=\"absmiddle\">";
					echo "</div>";
				}
				else
				{
					 echo "<span class=\"annot_std_it\" style=\"float:left;\">";
					 echo $lieu;
					 echo "</span>";
				}
			}
		}
	 
		mysql_free_result($rslieu);

		// Affichage site client
		$sitecli = "";
		switch (trim($row["ot_idsite"]))
		{
			case "0" :
				$row2=lit_enr_cli($row["ot_codecli"],FALSE);
				if (is_array($row2))
				{
					extract($row2);
					$sitecli.="<strong>";
					if ($cli_ste<>"")
						$sitecli.= $cli_ste."<br />";
					else
						$sitecli.= $cli_civilite." ".$cli_prenom." ".$cli_nom."<br />";
					$sitecli.="</strong>";
					$sitecli.= $cli_adr1."<br />";
					if ($cli_adr2<>"")
						$sitecli.= $cli_adr2."<br />";
					$sitecli.= Retournecp_openId($cli_ville,FALSE)." ".Retourneville_openId($cli_ville,FALSE)."<br />";
				}
				break;
			default :
				$rech2 = "SELECT * FROM `" .TBSCLI. "` WHERE `scli_id` = '".trim($row["ot_idsite"])."'";
				$rs2 = mysql_query($rech2) or die(mysql_error());
				if ($row2 = mysql_fetch_array($rs2))
				{
					extract($row2);
					$sitecli.="<strong>";
					$sitecli.= $scli_ste."<br />";
					$sitecli.="</strong>";
					$sitecli.= $scli_adr1."<br />";
					if ($scli_adr2 <> "")
						$sitecli.= $scli_adr2."<br />";
					$sitecli.= Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE)."<br />";
				}
				mysql_free_result($rs2);
		}

		if ($sitecli<>"")
		{
			echo "<div class=\"annot_petit_it\" style=\"float:left;\">";
			echo $sitecli;
			echo "</div>";
		}

		 echo "</td>\n";

		// Affichage détail urgence
		echo "<td align=\"center\">";
		echo $niv_urgence[$row["ot_urg"]];
		echo "</td>\n";

		// Affichage technicien traitant
		echo "<td align=\"center\">";
		if (($row["ot_codetec"] <> "") AND ($row["ot_codetec"] <> "-1"))
			echo $row["ot_codetec"];
		else
			echo "&nbsp;";
		echo "</td>\n";

		 // Affichage Icône Statut
		echo "<td align=\"center\">";
		 $statut = $row["ot_codestatut"];
		 $rechico = "SELECT * FROM ".TBSTA." WHERE statut_code = '$statut'";
		 
		 $rsico = mysql_query($rechico) or die(mysql_error());
		 
		if (mysql_num_rows($rsico) <> 0)
		{
			 while ($rowico = mysql_fetch_array($rsico)) 
			{
				extract ($rowico);
				if ($rowico["statut_img"] <> "")
				{
					$statint = $rowico["statut_desc"]." (".$statut.")";
					echo "<img src=\"".$rowico["statut_img"]."\" title=\"".$statint."\" border=\"0\" align=\"absmiddle\">";
				}
				else
				{
					 echo "<span class=\"annot_std_it\">";
					 echo $statut;
					 echo "</span>";
				}
			}
		}
	 
		mysql_free_result($rsico);
		 echo "</td>\n";

		// CREATION lien dynamique sur icône (édition, suppression, etc...)
		echo "<td align=\"center\">";

		$rech2 = "SELECT int_idsite, int_codecli FROM `" .TBINT. "` WHERE `int_code` = '".$row["ot_codeint"]."'";
		$rs2 = mysql_query($rech2)or die(mysql_error());
		if ($row2 = mysql_fetch_array($rs2))
		{
			extract($row2);
		}

		if ($row["ot_codestatut"] <> "CLOT")
		{
			$lst_maj = TRUE;
			echo "<a href=\"ot_maj.php?tx=".$tx."&td=edit&ci=".$row["ot_codeint"]."&cc=".$int_codecli."&co=".$row["ot_code"]."&si=".$int_idsite."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\"></a>";
			echo " ";
		}
		else
		{
			$lst_voir = TRUE;
			echo "<a href=\"ot_maj.php?tx=".$tx."&td=view&ci=".$row["ot_codeint"]."&cc=".$int_codecli."&co=".$row["ot_code"]."&si=".$int_idsite."\"><img src=\"../img/eye.png\" border=\"0\" align=\"absmiddle\"></a>";
			echo " ";
		}

		$lst_imp = TRUE;
		$urlimp = "ot_pdf.php?co=".$row["ot_code"];
		echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/print.png\" title=\"Imprimer l'ordre\" border=\"0\" align=\"absmiddle\"></a>";
		echo " ";

		if ($row["ot_codestatut"] <> "CLOT")
		{
			$del=TRUE;

			if ((@$_SESSION["niv_log"] == 11) OR (@$_SESSION["niv_log"] == 10))
				$del=FALSE;
	
			if ($del==TRUE)
			{
				$lst_del = TRUE;
				echo "<a href=\"ot_maj.php?tx=".$tx."&td=del&ci=".$row["ot_codeint"]."&cc=".$int_codecli."&co=".$row["ot_codeco"]."&si=".$int_idsite."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\"></a>";
			}
		}
		 echo "</td>\n";

		 echo "</tr>\n";
	 // Fin affichage résumé ordre
			
			$i++;    
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
	}
	else
	{
		echo "<span class=\"annot_gras_it\">";
		echo "<br><br>Pas de bons de travail en cours";
		echo "</span>";
	}	

	mysql_close($conn);  
	
	$taille_piedla="";
	include("../inc/piedla.inc.php"); ?>
</div>

<div id="detailm3" style="display:none">
<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);

	$rech = cree_strrechlstotst($niv_urgence);
	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE ".TBOT.".ot_codest='".@$_SESSION["code_st"]."' AND ".TBOT.".ot_codetec = '-1'";
	else
		$rech .= " AND ".TBOT.".ot_codest='".@$_SESSION["code_st"]."' AND ".TBOT.".ot_codetec = '-1'";
		
	$rech .= " ORDER BY ".TBOT.".ot_code DESC";
	// *** Fin de Chaîne de Recherche
		 
	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	
	if($numrows > 0)
	{
		echo "<span class=\"annot_std_it\">";
		echo "(Lieu/Statut : laisser la souris sur l'icône pour le d&eacute;tail)<br>";
		echo "</span>";
	
		// *** Affichage de la table
		 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
	
		// Création entête
		titlst($ot2_titre_col);
		echo "<th>".ucfirst($txt_ent_lst_clic)."</th>\n";
		
		$i = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
	 // Affichage résumé ordre

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

		echo "<td>";
		echo $row["ot_code"];
		$detfic=">>Mat&eacute;riel :<br />".$row["ot_mat"]."<br /><br />>>Travail &agrave; effectuer :<br />".$row["ot_pbm"];
		if ($detfic<>"")
			echo " <a href=\"#\" class=\"pop\"><img src=\"../img/help.png\" alt=\"D&eacute;tail\" border=\"0\" align=\"absmiddle\"><span>".formatetxtbr($detfic)."</span></a>";

		echo "</td>\n";

		echo "<td align=\"center\">";
		echo formatedate($row["ot_datedde"]);
		echo "</td>\n";
		echo "<td align=\"center\">";
		echo formatedate($row["ot_daterdv"]);
		if (formatedate($row["ot_daterdv"])<>"")
		{
			echo "<div align=\"center\" class=\"annot_petit_it\">";
			echo substr($row["ot_hrdv"],0,5);
			echo "</div>";
		}
		echo "</td>\n";

		 // Affichage Icône Lieu
		 echo "<td>";
		 $lieu = $row["ot_codelieu"];
		 $rechlieu = "SELECT * FROM ".TBLIEU." WHERE lieu_code = '$lieu'";
		 
		 $rslieu = mysql_query($rechlieu) or die(mysql_error());
		 
		if (mysql_num_rows($rslieu) <> 0)
		{
			 if ($rowlieu = mysql_fetch_array($rslieu)) 
			{
				extract ($rowlieu);
				if ($lieu_img <> "")
				{
					$lieuint = $lieu_desc." (".$lieu.")";
					echo "<div style=\"float:left;width:40px;\">";
					echo "<img src=\"".$lieu_img."\" title=\"".$lieuint."\" border=\"0\" align=\"absmiddle\">";
					echo "</div>";
				}
				else
				{
					 echo "<span class=\"annot_std_it\" style=\"float:left;\">";
					 echo $lieu;
					 echo "</span>";
				}
			}
		}
	 
		mysql_free_result($rslieu);

		// Affichage site client
		$sitecli = "";
		switch (trim($row["ot_idsite"]))
		{
			case "0" :
				$row2=lit_enr_cli($row["ot_codecli"],FALSE);
				if (is_array($row2))
				{
					extract($row2);
					$sitecli.="<strong>";
					if ($cli_ste<>"")
						$sitecli.= $cli_ste."<br />";
					else
						$sitecli.= $cli_civilite." ".$cli_prenom." ".$cli_nom."<br />";
					$sitecli.="</strong>";
					$sitecli.= $cli_adr1."<br />";
					if ($cli_adr2<>"")
						$sitecli.= $cli_adr2."<br />";
					$sitecli.= Retournecp_openId($cli_ville,FALSE)." ".Retourneville_openId($cli_ville,FALSE)."<br />";
				}
				break;
			default :
				$rech2 = "SELECT * FROM `" .TBSCLI. "` WHERE `scli_id` = '".trim($row["ot_idsite"])."'";
				$rs2 = mysql_query($rech2) or die(mysql_error());
				if ($row2 = mysql_fetch_array($rs2))
				{
					extract($row2);
					$sitecli.="<strong>";
					$sitecli.= $scli_ste."<br />";
					$sitecli.="</strong>";
					$sitecli.= $scli_adr1."<br />";
					if ($scli_adr2 <> "")
						$sitecli.= $scli_adr2."<br />";
					$sitecli.= Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE)."<br />";
				}
				mysql_free_result($rs2);
		}

		if ($sitecli<>"")
		{
			echo "<div class=\"annot_petit_it\" style=\"float:left;\">";
			echo $sitecli;
			echo "</div>";
		}

		 echo "</td>\n";

		// Affichage détail urgence
		echo "<td align=\"center\">";
		echo $niv_urgence[$row["ot_urg"]];
		echo "</td>\n";

		// Affichage technicien traitant
		echo "<td align=\"center\">";
		if (($row["ot_codetec"] <> "") AND ($row["ot_codetec"] <> "-1"))
			echo $row["ot_codetec"];
		else
			echo "&nbsp;";
		echo "</td>\n";

		// Affichage Icône Statut
		echo "<td align=\"center\">";
		 
		 $statut = $row["ot_codestatut"];
		 $rechico = "SELECT * FROM ".TBSTA." WHERE statut_code = '$statut'";
		 
		 $rsico = mysql_query($rechico) or die(mysql_error());
		 
			if (mysql_num_rows($rsico) <> 0)
			{
				 while ($rowico = mysql_fetch_array($rsico)) 
				{
					extract ($rowico);
					if ($rowico["statut_img"] <> "")
					{
						$statint = $rowico["statut_desc"]." (".$statut.")";
						echo "<img src=\"".$rowico["statut_img"]."\" title=\"".$statint."\" border=\"0\" align=\"absmiddle\">";
					}
					else
					{
						 echo "<span class=\"annot_std_it\">";
						 echo $statut;
						 echo "</span>";
					}
				}
			}
		 
			mysql_free_result($rsico);

		 echo "</td>\n";

		// CREATION lien dynamique sur icône (édition, suppression, etc...)
		echo "<td align=\"center\">";

		$rech2 = "SELECT int_idsite, int_codecli FROM `" .TBINT. "` WHERE `int_code` = '".$row["ot_codeint"]."'";
		$rs2 = mysql_query($rech2)or die(mysql_error());
		if ($row2 = mysql_fetch_array($rs2))
		{
			extract($row2);
		}

		if ($row["ot_codestatut"] <> "CLOT")
		{
			$lst_maj = TRUE;
			echo "<a href=\"ot_maj.php?tx=".$tx."&td=edit&ci=".$row["ot_codeint"]."&cc=".$int_codecli."&co=".$row["ot_code"]."&si=".$int_idsite."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\"></a>";
			echo " ";
		}
		else
		{
			$lst_voir = TRUE;
			echo "<a href=\"ot_maj.php?tx=".$tx."&td=view&ci=".$row["ot_codeint"]."&cc=".$int_codecli."&co=".$row["ot_code"]."&si=".$int_idsite."\"><img src=\"../img/eye.png\" border=\"0\" align=\"absmiddle\"></a>";
			echo " ";
		}

		$lst_imp = TRUE;
		$urlimp = "ot_pdf.php?co=".$row["ot_code"];
		echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/print.png\" title=\"Imprimer l'ordre\" border=\"0\" align=\"absmiddle\"></a>";
		echo " ";

		if ($row["ot_codestatut"] <> "CLOT")
		{
			$del=TRUE;

			if ((@$_SESSION["niv_log"] == 11) OR (@$_SESSION["niv_log"] == 10))
				$del=FALSE;
	
			if ($del==TRUE)
			{
				$lst_del = TRUE;
				echo "<a href=\"ot_maj.php?tx=".$tx."&td=del&ci=".$row["ot_codeint"]."&cc=".$int_codecli."&co=".$row["ot_codeco"]."&si=".$int_idsite."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\"></a>";
			}
		}
		 echo "</td>\n";

		 echo "</tr>\n";
	 // Fin affichage résumé ordre
			
			$i++;    
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
	}
	else
	{
		echo "<span class=\"annot_gras_it\">";
		echo "<br><br>Pas de bons de travail en cours";
		echo "</span>";
	}	

	mysql_close($conn);  
	
	$taille_piedla="";
	include("../inc/piedla.inc.php"); ?>
</div>

<script type="text/javascript">
<!--
warnnbtaches(<?PHP echo $nbtaches; ?>);
//-->
</script>

<?PHP
include_once("pied.php");
}
else
{
?>
<p align="center"><span class="titrepageerr"><?PHP echo $alert_pbmconf; ?></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div align="center" class="annot_gras_it"><?PHP echo $alert_sminoconfc; ?><br /><br />
<?PHP echo $txt_div_ctactadmincge; ?></div>
<script type="text/javascript">
window.setTimeout("location=('../index.php');",2000)
//-->
</script>
<?PHP
}
?>