<?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
****************************************************************************************/


// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_cocl.inc.php");
include_once("../inc/fic_int.inc.php");
include_once("../inc/fic_ot.inc.php");
include_once("../inc/fic_tac.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);

$pbm_ot = FALSE;
$pbm_cli = FALSE;

$msg1_err_type="Aucun sous-traitant pour cette sp&eacute;cialit&eacute; dans le d&eacute;partement du client";

$url_query=$_SERVER['QUERY_STRING'];
$tx = strip_tags(trim($_GET['tx'])); // Source de l'appel m:depuis le menu, i:depuis l'intervention
$td = strip_tags(trim($_GET['td'])); // Récupération type demande
$ca = strip_tags(trim($_GET['ca'])); // Récupération code Agence gestionnaire du compte client
$cc = strip_tags(trim($_GET['cc'])); // Récupération code Client
$ci = strip_tags(trim($_GET['ci'])); // Récupération code Intervention
$si = strip_tags(trim($_GET['si'])); // Récupération id du site
$tr = strip_tags(trim($_GET['tr'])); // Récupération code technicien responsable
$co = strip_tags(trim($_GET['co'])); // Récupération code contrat
$tl=1;
if (isset($_GET["tl"]))
	$tl = intval(strip_tags(trim($_GET['tl']))); // Récupération type liste
if (($tl<>1) AND ($tl<>2))
	$tl=1;
if ((@$_SESSION["niv_log"] == 10) OR (@$_SESSION["niv_log"] == 11))
	$tl=1;

if (($tx<>"m") AND ($tx<>"i"))
	$pbm_ot=TRUE;
	
if ((@$_SESSION["niv_log"] <> 3) AND (@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["niv_log"] <> 5) AND (@$_SESSION["niv_log"] <> 9) AND (@$_SESSION["niv_log"] <> 10) AND (@$_SESSION["niv_log"] <> 11))
	$pbm_ot=TRUE;

if ($pbm_ot==FALSE)
{
	if ($ci<> "")
	{
		// Récupération des informations Intervention
		$row = lit_enr_int($ci);
		if (is_array($row))
		{
			extract ($row);
	
			if ($int_codecli==$cc)
			{
				$row2 = lit_enr_cli($int_codecli,TRUE);
				if (is_array($row2))
				{
					extract ($row2);
					if ($si>0)
					{
						$row3=lit_enr_scli_id($si,TRUE);
						if (is_array($row3))
						{
							extract ($row3);
							if ($scli_codecli<>$cc)
								$pbm_cli=TRUE;
						}
						else
							$pbm_cli = TRUE;
					}
					else
					{
						$scli_codepays=$cli_codepays;
						$scli_dep=$cli_dep;
					}
				}
				else
					$pbm_cli = TRUE;
			}
			else
				$pbm_cli = TRUE;
		}
		else
			$pbm_ot=TRUE;
	}
	else
	{
		if ($tx=="i")
			$pbm_ot=TRUE;
	}
}

if (($pbm_ot==FALSE) AND ($pbm_cli==FALSE))
{
	if ($tr<>"")
	{
		$row=lit_enr_tec($tr,TRUE);
		if (is_array($row))
		{
			extract($row);
			switch (@$_SESSION["niv_log"])
			{
				case 3 :
				case 11 :
					if (@$_SESSION["code_log"]<>$tec_code)
						$pbm_ot=TRUE;
					break;
				case 4 :
					if (@$_SESSION["code_age"]<>$tec_codeage) $pbm_ot=TRUE;
					break;
				case 10 :
					if (@$_SESSION["code_st"]<>$tec_codest) $pbm_ot=TRUE;
					break;
				default :
					break;
			}
		}
		else
			$pbm_ot=TRUE;
	}
	else
	{
		if ($tx=="i")
			$pbm_ot = TRUE;
	}
}

if (($pbm_ot==FALSE) AND ($pbm_cli==FALSE))
{
	if ($ca<>"")
	{
		$row=lit_enr_age($ca,TRUE);
		if (is_array($row))
			extract($row);
		else
			$pbm_ot=TRUE;
	}
	else
	{
		if ($tx=="i")
			$pbm_ot = TRUE;
	}
}

$fi="";
if (isset($_GET['fi']) && (trim($_GET['fi'])<>""))
	$fi=intval(strip_tags(trim($_GET['fi'])));
?>
<!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; ?> : Liste Ordres Sous-traitants</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 pour contrôle de champs -->
<script	type="text/javascript" src="../jscript/verif_field.js"></script>

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

</head>

<body onLoad="metFocus();">
<?php
if ($tx <> "i") 
	include_once("../inc/entete.inc.php");
switch (@$_SESSION["niv_log"])
{
	case 3 :
	case 4 :
		echo '<p align="center"><span class="titrepage">BONS DE TRAVAIL</span></p>';
		echo '<p align="center"><span class="annot_gras_it">Dont vous assurez le suivi de l\'intervention</span></p>';
		break;
	case 5 :
	case 9 :
		echo '<p align="center"><span class="titrepage">BONS DE TRAVAIL</span></p>';
		break;
	case 10 :
	case 11 :
		echo '<p align="center"><span class="titrepage">VOS BONS DE TRAVAIL</span></p>';
		break;
}

if (($pbm_ot==FALSE) AND ($pbm_cli==FALSE))
{
	if ($tx=="i")
	{
		// Récupération si rattachement à une intervention
		if (((@$_SESSION["niv_log"] <> 10) AND (@$_SESSION["niv_log"] <> 11))  OR ((@$_SESSION["niv_log"] == 3) AND (@$_SESSION["code_log"]==$tr)))
		{
			if (isset($_GET["cxi"]))
			{
				$cxi = intval(strip_tags(trim($_GET['cxi'])));
				// cxi=1 : une régularisation est demandée
				if ($cxi==1)
				{
					// Si le code bon de travail est affiché et est valide, on peut transférer
					if (isset($_GET["ot"]))
					{
						$row=lit_enr_ot(trim($_GET["ot"]));
						if (is_array($row))
						{
							extract($row);
							if ((trim($ot_codeint)=="--AR--") AND (trim($ot_codecli)==$cc) AND (trim($ot_idsite)==$si))
							{
								// Régularisation du bon de travail
								$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
								mysql_select_db(DBNAME);
								$rech = "UPDATE `" .TBOT. "` SET `ot_codeint`= '".$ci."' WHERE `ot_code`= '".$ot_code."'";
								$rs = mysql_query($rech) or die(mysql_error());
								mysql_close($conn);
							}
						}
					}
				}
				// cxi=-1 : une dissociation est demandée
				if ($cxi==-1)
				{
					// Si le code bon de travail est affiché et est valide, on peut transférer
					if (isset($_GET["ot"]))
					{
						$row=lit_enr_ot(trim($_GET["ot"]));
						if (is_array($row))
						{
							extract($row);
							if ((trim($ot_codeint)==$ci) AND (trim($ot_codecli)==$cc) AND (trim($ot_idsite)==$si))
							{
								// Dissociation du bon de travail
								$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
								mysql_select_db(DBNAME);
								$rech = "UPDATE `" .TBOT. "` SET `ot_codeint`= '--AR--' WHERE `ot_code`= '".$ot_code."'";
								$rs = mysql_query($rech) or die(mysql_error());
								mysql_close($conn);
							}
						}
					}
				}
				$url_query = eregi_replace("&cxi=-1","",$url_query);
				$url_query = eregi_replace("&cxi=0","",$url_query);
				$url_query = eregi_replace("&cxi=1","",$url_query);
			}
		}

		// On enregistre les codes obligatoires
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		// ->Code du contrat en cours (historique contrat)
		$rech = "SELECT * FROM " .TBCOCLH. " WHERE `coclh_codeint` = '$ci'";
		$rs = mysql_query($rech) or die(mysql_error());
		if (mysql_num_rows($rs) == 1)
		{
			$rech2 = "UPDATE `" .TBCOCLH. "` SET `coclh_codecocl`='".$co."'";
			$rech2 .=" WHERE `coclh_codeint` = '".$ci."'";
		}
		else
		{
			$rech2 = "INSERT INTO " .TBCOCLH;
			$rech2.=" (coclh_codecli,coclh_codecocl,coclh_codeint)";
			$rech2.=" VALUES";
			$rech2.=" ('$cc','$co','$ci')";
		}
		$rs2 = mysql_query($rech2) or die(mysql_error());
		mysql_free_result($rs);
		// ->code agence gestionnaire du compte
		// ->code technicien responsable du dossier
		// ->id site intervention
		$rech = "UPDATE `" .TBINT. "` SET `int_datemod`='".$datea."', `int_codemod`='".$_SESSION["code_log"]."', `int_codeage`='".$ca."',";
		$rech.= " `int_codeage`='".$ca."', `int_codetec`='".$tr."', `int_idsite`= '".$si."', `int_codecocl`= '".$co."'";
		$rech .=" WHERE `int_code` = '".$ci."'";
		$rs = mysql_query($rech) or die(mysql_error());
		mysql_close($conn);

		if ($ci<>"")
		{
			echo '<p align="center"><span class="annot_std_it">(Pour l\'intervention n°<span class="annot_std_gras">'.$ci.'</span>';
			echo ' - M&ecirc;me client, m&ecirc;me site d\'intervention)';
			echo '</span></p>';
		}
		echo '<p align="right"><input name="quit" type="button" class="bton_std" id="quit" value="'.$but_quit.'" style="text-decoration: none; font-size: 11px; color:White ;font-weight:bold;background-color: #666666;" onClick="javascript:; self.close();"></p>';
		if (($ci<>"") AND ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)))
			$url_add = "ot_maj.php?tx=".$tx."&td=add&ca=".$ca."&ci=".$ci."&cc=".$cc."&co=&si=".$si."&tr=".$tr;
	}
	else
	{
		$fic_imp = "ot_lsti.php";
		if ((@$_SESSION["niv_log"] <> 1) AND (@$_SESSION["niv_log"] <> 11) AND (@$_SESSION["niv_log"] <> 10))
			$url_add = "cli_lst.php?td=ot&tl=1";
		if (@$_SESSION["niv_log"] == 9)
			$url_rss = $rep_appli."/rss/rss.php?log=".$admin_code."&pw=".md5($admin_mdp)."&trss=ot";
	}

	$tab_fi[]="Tous les bons de travail";
	$tab_fi[]="Bons de travail non clos";
	$tab_fi[]="Bons de travail clos";

	include_once("formr.inc.php"); 

	$aff_full=TRUE;
	switch ($_SESSION["niv_log"])
	{
		case 10 :
		case 11 :
			$aff_full=FALSE;
			break;
		case 3 :
			if ($tx=="i")
			{
			}
			else
				$aff_full=FALSE;
			break;
		default :
			break;
	}
if ($aff_full==TRUE)
{
?>
<br />
<div id="menu_lstot" class="menu_ongletfull">
<a class="<?PHP if ($tl==2) echo 'ongleta'; else echo 'ongleti';?>" id="m2" href="javascript:;" onclick="set_mnu_lot(this.id);" onFocus="this.blur();"><?PHP echo $mnuo_otar; ?></a>
<a class="<?PHP if ($tl==1) echo 'ongleta'; else echo 'ongleti';?>" id="m1" href="javascript:;" onclick="set_mnu_lot(this.id);" onFocus="this.blur();"><?PHP echo $mnuo_ot; ?></a>
</div>
<br />

<div id="detailm2" style="display:<?PHP if ($tl==2) echo 'block'; else echo 'none';?>">
<?PHP
}
	if ($tl==2)
	{
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		
		switch (@$_SESSION["niv_log"])
		{
			case 10 :
			case 11 :
				$rech = cree_strrechlstotst($niv_urgence);
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
				else
					$rech .= " AND ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
				break;
			case 3 :
			case 4 :
				$rech = cree_strrechlstotr($niv_urgence);
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ".TBCLI.".cli_prop='".@$_SESSION["code_age"]."'";
				else
					$rech .= " AND ".TBCLI.".cli_prop='".@$_SESSION["code_age"]."'";
				break;
			default :
				$rech = cree_strrechlstotr($niv_urgence);
				break;
		}
		
		if ($tx=="i")
		{
			if(!stristr($rech,"WHERE "))
			{
				$rech .= " WHERE (".TBOT.".ot_codecli='".$cc."'";
				$rech .= " AND ".TBOT.".ot_idsite='".$si."')";
			}
			else
			{
				$rech .= " AND ".TBOT.".ot_codecli='".$cc."'";
				$rech .= " AND ".TBOT.".ot_idsite='".$si."'";
			}
		}
	
		switch ($fi)
		{
			case "1" :
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ot_datefin='0000-00-00'";
				else
					$rech .= " AND ot_datefin='0000-00-00'";
				break;
			case "2" :
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ot_datefin<>'0000-00-00'";
				else
					$rech .= " AND ot_datefin<>'0000-00-00'";
				break;
			default :
				break;
		}
		
		$rech .= crestr_triord($ot_titre_col,"ot_code",FALSE,$limit);
		$rs = mysql_query($rech) or die(mysql_error());
		$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
		
		if($numrows == 0)
			retpp();
		 else
		{
			switch (@$_SESSION["niv_log"])
			{
				case 10 :
				case 11 :
					$rech = cree_strrechlstotst($niv_urgence);
					if(!stristr($rech,"WHERE "))
						$rech .= " WHERE ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
					else
						$rech .= " AND ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
					break;
				case 3 :
				case 4 :
					$rech = cree_strrechlstotr($niv_urgence);
					if(!stristr($rech,"WHERE "))
						$rech .= " WHERE ".TBCLI.".cli_prop='".@$_SESSION["code_age"]."'";
					else
						$rech .= " AND ".TBCLI.".cli_prop='".@$_SESSION["code_age"]."'";
					break;
				default :
					$rech = cree_strrechlstotr($niv_urgence);
					break;
			}
			
			if ($tx=="i")
			{
				if(!stristr($rech,"WHERE "))
				{
					$rech .= " WHERE (".TBOT.".ot_codecli='".$cc."'";
					$rech .= " AND ".TBOT.".ot_idsite='".$si."')";
				}
				else
				{
					$rech .= " AND ".TBOT.".ot_codecli='".$cc."'";
					$rech .= " AND ".TBOT.".ot_idsite='".$si."'";
				}
			}
		
			switch ($fi)
			{
				case "1" :
					if(!stristr($rech,"WHERE "))
						$rech .= " WHERE ot_datefin='0000-00-00'";
					else
						$rech .= " AND ot_datefin='0000-00-00'";
					break;
				case "2" :
					if(!stristr($rech,"WHERE "))
						$rech .= " WHERE ot_datefin<>'0000-00-00'";
					else
						$rech .= " AND ot_datefin<>'0000-00-00'";
					break;
				default :
					break;
			}
			
			$rech .= crestr_triord($ot_titre_col,"ot_code",TRUE,$limit);
		
			$rs = mysql_query($rech) or die(mysql_error());
		
			// *** Pagination de pied
			pagine_lst($numrows,$limit);
		
			// *** Affichage de la table
			 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
		
			// Création entête
			if ((@$_SESSION["niv_log"] <> 11) AND (@$_SESSION["niv_log"] <> 10))
				titlst($ot_titre_col);
			else
				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>";

				// Affichage détail intervention rattachée
				if ($tx=="m")
				{
					// Icône si tâche rattachée
					$nb_tac_actives=nb_tac_actives(6,$row["ot_code"],FALSE);
					if ($nb_tac_actives>0)
					{
						$url_taclst="tac_lst.php?ord=DES&tri=Code&fi=8&search=".$row["ot_code"];
						$txt_tac=$nb_tac_actives." t&acirc;che";
						if ($nb_tac_actives>1)
							$txt_tac.="s";
						$txt_tac.=" non termin&eacute;e";
						if ($nb_tac_actives>1)
							$txt_tac.="s";
						$txt_tac.=" (cliquez pour la liste des t&acirc;ches rattach&eacute;es &agrave; ce bon de travail)";
						echo " <a href=\"".$url_taclst."\"><img src=\"../img/tacwarn.png\" title=\"".$txt_tac."\" border=\"0\" align=\"absmiddle\"></a>";
					}
					if ((@$_SESSION["niv_log"] <> 11) AND (@$_SESSION["niv_log"] <> 10))
					{
						echo "<div class=\"annot_petit_it\" align=\"right\">";
						echo Client." ".$row["ot_codecli"];
						echo " <a href=\"cli_maj.php?td=edit&cc=".$row["ot_codecli"]."\"><img src=\"../img/edit.png\" width=\"14\" height=\"14\" border=\"0\" align=\"absmiddle\" title=\"".$alt_editcli."\"></a>";
						echo "</div>";
					}
		
				}
				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 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)
				{
					 while ($rowlieu = mysql_fetch_array($rslieu)) 
					{
						extract ($rowlieu);
						if ($rowlieu["lieu_img"] <> "")
						{
							$lieuint = $rowlieu["lieu_desc"]." (".$lieu.")";
							echo "<div style=\"float:left;width:40px;\">";
							echo "<img src=\"".$rowlieu["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 "<div align=\"center\">";
				echo $niv_urgence[$row["ot_urg"]];
				echo "</td>\n";
				// Fin affichage détail urgence
		
				if ((@$_SESSION["niv_log"] <> 11) AND (@$_SESSION["niv_log"] <> 10))
				{
					echo "<td align=\"center\">";
					echo $row["ot_codest"];
					if ($tx=="m")
					{
						$rech2="SELECT st_dep FROM ".TBST." WHERE `st_code`='".$row["ot_codest"]."'";
						$rs2 = mysql_query($rech2) or die(mysql_error());
						if ($row2 = mysql_fetch_array($rs2))
						{
							echo " <a href=\"st_maj.php?td=edit&code=".$row["ot_codest"]."&dep=".$row2["st_dep"]."\"><img src=\"../img/edit.png\" width=\"14\" height=\"14\" border=\"0\" align=\"absmiddle\" title=\"Editer sous-traitant\"></a>";
						}
					}
					
					// Affichage détail sous-traitant
					$detailst = $row["st_nom"].", ";
					$detailst .= $row["st_resp_civilite"]." ".$row["st_resp_nom"];
					echo "<div class=\"annot_petit_it\" style=\"margin-left:5px;\">";
					echo $detailst;
					echo "</div>";
					// Fin affichage détail sous-trainat
					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\">";
				
				if ($tx=="m")
				{
					if ($row["ot_codestatut"] <> "CLOT")
					{
						$lst_maj = TRUE;
						echo "<a href=\"ot_maj.php?tx=".$tx."&td=edit&ci=&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_edit."\"></a>";
						echo " ";
					}
					else
					{
						$lst_voir = TRUE;
						echo "<a href=\"ot_maj.php?tx=".$tx."&td=view&ci=&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=\"><img src=\"../img/eye.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_voir."\"></a>";
						echo " ";
					}
				}
		
				$lst_otlnk = TRUE;
				if ($tx=="m")
					echo "<a href=\"int_maj.php?td=add&ci=&ot=".$row["ot_code"]."\"><img src=\"../img/ot_lnkadd.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter intervention\"></a>";
				else
					echo "<a href=\"ot_lst.php?".$url_query."&cxi=1&ot=".$row["ot_code"]."\"><img src=\"../img/ot_lnkadd.png\" border=\"0\" align=\"absmiddle\" title=\"Rattacher cette intervention\"></a>";
				echo " ";
	
				if ($tx=="m")
				{
					$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 le bon\" border=\"0\" align=\"absmiddle\"></a>";
					echo " ";
				}
		
				if ($row["ot_codestatut"] <> "CLOT")
				{
					$del=TRUE;
		
					if ((@$_SESSION["niv_log"] == 11) OR (@$_SESSION["niv_log"] == 10) OR ($tx=="i"))
						$del=FALSE;
			
					if ($del==TRUE)
					{
						$lst_del = TRUE;
						echo "<a href=\"ot_maj.php?tx=".$tx."&td=del&ci=&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_del."\"></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);
			mysql_close($conn);  
			
			// *** Pagination de pied
			pagine_lst($numrows,$limit);
			
			$taille_piedla="";
			include_once("piedla.inc.php"); 
		}

		if ($tx=="i")
		{
?>
		<script type="text/javascript">
		<!--
		verif_txtot(<?PHP echo nb_ot($ci); ?>,<?PHP echo nb_ot_actifs($ci); ?>);
		//-->
		</script>
<?PHP
		}
	}

if ($aff_full==TRUE)
{
?>
</div>
<div id="detailm1" style="display:<?PHP if ($tl==1) echo 'block'; else echo 'none';?>">
<?PHP
}
	if ($tl==1)
	{
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		
		switch (@$_SESSION["niv_log"])
		{
			case 10 :
			case 11 :
				$rech = cree_strrechlstotst($niv_urgence);
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
				else
					$rech .= " AND ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
				break;
			case 3 :
				$rech = cree_strrechlstot($niv_urgence);
				if(!stristr($rech,"WHERE "))
				{
					$rech .= " WHERE (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
					$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
					$rech .= " AND ".TBINT.".int_codetec='".@$_SESSION["code_log"]."'";
				}
				else
				{
					$rech .= " AND (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
					$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
					$rech .= " AND ".TBINT.".int_codetec='".@$_SESSION["code_log"]."'";
				}
				break;
			case 4 :
				$rech = cree_strrechlstot($niv_urgence);
				if(!stristr($rech,"WHERE "))
				{
					$rech .= " WHERE (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
					$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
				}
				else
				{
					$rech .= " AND (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
					$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
				}
				break;
			default :
				$rech = cree_strrechlstot($niv_urgence);
				break;
		}
		
		if ($ci<>"")
		{
			if(!stristr($rech,"WHERE "))
				$rech .= " WHERE ".TBOT.".ot_codeint='".$ci."'";
			else
				$rech .= " AND ".TBOT.".ot_codeint='".$ci."'";
		}
		
		switch ($fi)
		{
			case "1" :
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ot_datefin='0000-00-00'";
				else
					$rech .= " AND ot_datefin='0000-00-00'";
				break;
			case "2" :
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ot_datefin<>'0000-00-00'";
				else
					$rech .= " AND ot_datefin<>'0000-00-00'";
				break;
			default :
				break;
		}
		
		$rech .= crestr_triord($ot_titre_col,"ot_code",FALSE,$limit);
	
		$rs = mysql_query($rech) or die(mysql_error());
		$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
		
		if($numrows == 0)
			retpp();
		 else
		{
			switch (@$_SESSION["niv_log"])
			{
				case 10 :
				case 11 :
					$rech = cree_strrechlstotst($niv_urgence);
					if(!stristr($rech,"WHERE "))
						$rech .= " WHERE ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
					else
						$rech .= " AND ".TBOT.".ot_codest='".@$_SESSION["code_st"]."'";
					break;
				case 3 :
					$rech = cree_strrechlstot($niv_urgence);
					if(!stristr($rech,"WHERE "))
					{
						$rech .= " WHERE (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
						$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
						$rech .= " AND ".TBINT.".int_codetec='".@$_SESSION["code_log"]."'";
					}
					else
					{
						$rech .= " AND (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
						$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
						$rech .= " AND ".TBINT.".int_codetec='".@$_SESSION["code_log"]."'";
					}
					break;
				case 4 :
					$rech = cree_strrechlstot($niv_urgence);
					if(!stristr($rech,"WHERE "))
					{
						$rech .= " WHERE (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
						$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
					}
					else
					{
						$rech .= " AND (".TBINT.".int_codeage='".@$_SESSION["code_age"]."'";
						$rech .= " OR ".TBINT.".int_codeages='".@$_SESSION["code_age"]."')";
					}
					break;
				default :
					$rech = cree_strrechlstot($niv_urgence);
					break;
			}
			
			if ($ci<>"")
			{
				if(!stristr($rech,"WHERE "))
					$rech .= " WHERE ".TBOT.".ot_codeint='".$ci."'";
				else
					$rech .= " AND ".TBOT.".ot_codeint='".$ci."'";
			}
		
			switch ($fi)
			{
				case "1" :
					if(!stristr($rech,"WHERE "))
						$rech .= " WHERE ot_datefin='0000-00-00'";
					else
						$rech .= " AND ot_datefin='0000-00-00'";
					break;
				case "2" :
					if(!stristr($rech,"WHERE "))
						$rech .= " WHERE ot_datefin<>'0000-00-00'";
					else
						$rech .= " AND ot_datefin<>'0000-00-00'";
					break;
				default :
					break;
			}
			
			$rech .= crestr_triord($ot_titre_col,"ot_code",TRUE,$limit);
		
			$rs = mysql_query($rech) or die(mysql_error());
		
			// *** Pagination de pied
			pagine_lst($numrows,$limit);
		
			// *** Affichage de la table
			 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
		
			// Création entête
			if ((@$_SESSION["niv_log"] <> 11) AND (@$_SESSION["niv_log"] <> 10))
				titlst($ot_titre_col);
			else
				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>";
		
				// Affichage détail intervention rattachée
				if ($tx=="m")
				{
					// Icône si tâche rattachée
					$nb_tac_actives=nb_tac_actives(6,$row["ot_code"],FALSE);
					if ($nb_tac_actives>0)
					{
						$url_taclst="tac_lst.php?ord=DES&tri=Code&fi=8&search=".$row["ot_code"];
						$txt_tac=$nb_tac_actives." t&acirc;che";
						if ($nb_tac_actives>1)
							$txt_tac.="s";
						$txt_tac.=" non termin&eacute;e";
						if ($nb_tac_actives>1)
							$txt_tac.="s";
						$txt_tac.=" (cliquez pour la liste des t&acirc;ches rattach&eacute;es &agrave; ce bon de travail)";
						echo " <a href=\"".$url_taclst."\"><img src=\"../img/tacwarn.png\" title=\"".$txt_tac."\" border=\"0\" align=\"absmiddle\"></a>";
					}
					if ((@$_SESSION["niv_log"] <> 11) AND (@$_SESSION["niv_log"] <> 10))
					{
						echo "<div class=\"annot_petit_it\" align=\"right\">";
						$txtint="";
						if ($row["int_codedo"]<>"")
							$txtint="Ordre intervention";
						else
							$txtint="Intervention";
						echo $txtint." ".$row["ot_codeint"];
						if (formatedate($row["int_datefin"])<>"")
							echo " <img src=\"../img/ok.png\" border=\"0\" align=\"absmiddle\" title=\"Termin&eacute;\">";
						else
						{
							if (formatedate($row["int_dateprev"])<>"")
								echo " <img src=\"../img/phone.png\" border=\"0\" align=\"absmiddle\" title=\"Client pr&eacute;venu\">";
						}
						if (formatedate($row["int_datefin"])=="")
							echo " <a href=\"int_maj.php?td=edit&ci=".$row["int_code"]."&cc=".$row["int_codecli"]."&ca=".$row["int_codeage"]."\"><img src=\"../img/edit.png\" width=\"14\" height=\"14\" border=\"0\" align=\"absmiddle\" title=\"Editer/Voir ".$txtint."\"></a>";
						else
							echo " <a href=\"int_maj.php?td=view&ci=".$row["int_code"]."&cc=".$row["int_codecli"]."&ca=".$row["int_codeage"]."\"><img src=\"../img/eye.png\" width=\"14\" height=\"14\" border=\"0\" align=\"absmiddle\" title=\"Editer/Voir ".$txtint."\"></a>";
						echo "</div>";
						if ($row["int_codedo"]<>"")
						{
							 echo "<div align=\"right\" class=\"annot_upetit_it\">";
							 echo "Ordre de ".$row["int_codedo"];
							 echo "</div>";
						}
						if ($row["int_codeman"]<>"")
						{
							 echo "<div align=\"right\" class=\"annot_upetit_it\">";
							 echo "Saisie manuelle : ".$row["int_codeman"];
							 echo "</div>";
						}
						if ($row["int_codeext"]<>"")
						{
							 echo "<div align=\"right\" class=\"annot_upetit_it\">";
							 echo "Dossier : ".$row["int_codeext"];
							 echo "</div>";
						}
						echo "<div class=\"annot_petit_it\" align=\"right\">";
						echo Client." ".$row["int_codecli"];
						echo " <a href=\"cli_maj.php?td=edit&cc=".$row["int_codecli"]."\"><img src=\"../img/edit.png\" width=\"14\" height=\"14\" border=\"0\" align=\"absmiddle\" title=\"".$alt_editcli."\"></a>";
						echo "</div>";
					}
		
				}
				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 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)
				{
					 while ($rowlieu = mysql_fetch_array($rslieu)) 
					{
						extract ($rowlieu);
						if ($rowlieu["lieu_img"] <> "")
						{
							$lieuint = $rowlieu["lieu_desc"]." (".$lieu.")";
							echo "<div style=\"float:left;width:40px;\">";
							echo "<img src=\"".$rowlieu["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 "<div align=\"center\">";
				echo $niv_urgence[$row["ot_urg"]];
				echo "</td>\n";
				// Fin affichage détail urgence
		
				if ((@$_SESSION["niv_log"] <> 11) AND (@$_SESSION["niv_log"] <> 10))
				{
					echo "<td align=\"center\">";
					echo $row["ot_codest"];
					if ($tx=="m")
					{
						$rech2="SELECT st_dep FROM ".TBST." WHERE `st_code`='".$row["ot_codest"]."'";
						$rs2 = mysql_query($rech2) or die(mysql_error());
						if ($row2 = mysql_fetch_array($rs2))
						{
							echo " <a href=\"st_maj.php?td=edit&code=".$row["ot_codest"]."&dep=".$row2["st_dep"]."\"><img src=\"../img/edit.png\" width=\"14\" height=\"14\" border=\"0\" align=\"absmiddle\" title=\"Editer sous-traitant\"></a>";
						}
					}
					
					// Affichage détail sous-traitant
					$detailst = $row["st_nom"].", ";
					$detailst .= $row["st_resp_civilite"]." ".$row["st_resp_nom"];
					echo "<div class=\"annot_petit_it\" style=\"margin-left:5px;\">";
					echo $detailst;
					echo "</div>";
					// Fin affichage détail sous-trainat
					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\">";
				
				if ($row["ot_codestatut"] <> "CLOT")
				{
					$lst_maj = TRUE;
					if ((@$_SESSION["niv_log"] == 11) OR (@$_SESSION["niv_log"] == 10))
						echo "<a href=\"ot_maj.php?tx=".$tx."&td=edit&ca=".$ca."&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=".$row["int_codetec"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_edit."\"></a>";
					else
						echo "<a href=\"ot_maj.php?tx=".$tx."&td=edit&ca=".$ca."&ci=".$row["ot_codeint"]."&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=".$row["int_codetec"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_edit."\"></a>";
					echo " ";
				}
				else
				{
					$lst_voir = TRUE;
					if ((@$_SESSION["niv_log"] == 11) OR (@$_SESSION["niv_log"] == 10))
						echo "<a href=\"ot_maj.php?tx=".$tx."&td=view&ca=".$ca."&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=".$row["int_codetec"]."\"><img src=\"../img/eye.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_voir."\"></a>";
					else
						echo "<a href=\"ot_maj.php?tx=".$tx."&td=view&ca=".$ca."&ci=".$row["ot_codeint"]."&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=".$row["int_codetec"]."\"><img src=\"../img/eye.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_voir."\"></a>";
					echo " ";
				}
		
				if ($tx=="i")
				{
					$lst_otulnk = TRUE;
					echo "<a href=\"ot_lst.php?".$url_query."&cxi=-1&ot=".$row["ot_code"]."\"><img src=\"../img/ot_lnkdel.png\" border=\"0\" align=\"absmiddle\" title=\"Dissocier ce bon de travail\"></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 le bon\" 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&ca=".$ca."&ci=".$row["ot_codeint"]."&cc=".$row["ot_codecli"]."&co=".$row["ot_code"]."&si=".$row["ot_idsite"]."&tr=".$row["int_codetec"]."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_del."\"></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);
			mysql_close($conn);  
			
			// *** Pagination de pied
			pagine_lst($numrows,$limit);
			
			$taille_piedla="";
			include_once("piedla.inc.php"); 
		}

		if ($tx=="i")
		{
?>
		<script type="text/javascript">
		<!--
		verif_txtot(<?PHP echo nb_ot($ci); ?>,<?PHP echo nb_ot_actifs($ci); ?>);
		//-->
		</script>
<?PHP
		}
	}
	if ($aff_full==TRUE)
		echo "</div>";
}
else
{
	echo '<p align="center" class="annot_std_it">'.$alert_prm.'...</p>';
?>
	<script type="text/javascript">
	<!--
<?PHP	if ($tx=="i") { ?>
	setTimeout("self.close('fscomp');",2000);
<?PHP } else { ?>
	setTimeout("self.location.href=('index.php');",2000);
<?PHP } ?>
	//-->
	</script>
<?PHP
}
if ($tx == "m") 
	include_once("pied.php");
else
{
	echo '</body>';
	echo '</html>';
}
?>
