<?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");

// Tout est ok...on lance la routine
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_do.inc.php");
include_once("../inc/fic_pw.inc.php");
include_once("../inc/fic_zc.inc.php");
include_once("../inc/lst.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");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim($_GET['td'])); // Récupération type demande
$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;

$pbm_cli=FALSE;

switch(@$_SESSION["niv_log"])
{
	case 1 :
		$tab_cli=give_tab_rcli(@$_SESSION["code_log"],TRUE);
		if (in_array(@$_SESSION["code_log"],$tab_cli)==FALSE)
			$pbm_cli=TRUE;
		break;
	case 3 :
	case 4 :
		$ca = @$_SESSION["code_age"];
			
		$row = lit_enr_age($ca,TRUE);
		if (is_array($row))
			extract ($row);
		else
			$pbm_cli=TRUE;
		break;
	case 6 :
	case 7 :
		$cd = @$_SESSION["code_do"];
			
		$row = lit_enr_do($cd);
		if (is_array($row))
			extract ($row);
		else
			$pbm_cli=TRUE;
		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 - <?PHP echo $title_esp_prive; ?> : Liste Clients</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>

</head>

<body onLoad="metFocus();">

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

if ($pbm_cli==FALSE)
{
	echo '<p align="center"><span class="titrepage">COMPTES et SITES CLIENTS</span></p>';

if ((@$_SESSION["niv_log"] == 1) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3) OR (@$_SESSION["niv_log"] == 7) OR (@$_SESSION["niv_log"] == 6))
	echo '<p align="center" class="annot_std_it">(Que vous g&eacute;rez)</p>';

$txt='<p align="center" class="annot_gras_it">Merci de choisir un client pour saisir ';
switch ($td)
{
	case "con" :
		$txt.=' un contrat</p>';
		echo $txt;
		break;
	case "int" :
		$txt.=' une intervention</p>';
		echo $txt;
		break;
	case "loc" :
		$txt.=' un contrat de location</p>';
		echo $txt;
		break;
	case "rel" :
		$txt.=' ou &eacute;diter un relev&eacute;</p>';
		echo $txt;
		break;
	default :
		break;
}
if (($td<>"int") AND ($td<>"con") AND ($td<>"rel") AND ($td<>"loc"))
{
	if (@$_SESSION["niv_log"] >= 3)
		$fic_imp = "cli_lsti.php";
}
$url_add = "cli_maj.php?td=add";

include_once("formr.inc.php"); 

$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
mysql_select_db(DBNAME);

if (($td=="int") OR ($td=="ot") OR ($td==""))
{
?>
<br>
<div id="menu_lstcli" class="menu_ongletfull">
<a class="<?PHP if ($tl==1) echo 'ongleta'; else echo 'ongleti';?>" id="m1" href="javascript:;" onclick="set_mnu_lcli(this.id);" onFocus="this.blur();"><?PHP echo $mnuo_cli; ?></a>
<a class="<?PHP if ($tl==2) echo 'ongleta'; else echo 'ongleti';?>" id="m2" href="javascript:;" onclick="set_mnu_lcli(this.id);" onFocus="this.blur();"><?PHP echo $mnuo_scli; ?></a>
</div>
<br>

<div id="detailm1" style="display:<?PHP if ($tl==1) echo 'block'; else echo 'none';?>">
<?PHP
}

if ($tl==1)
{
	switch (@$_SESSION["niv_log"])
	{
		case 1 :
			$rech = cree_strrechlstclicli($tab_cli);
			$rech .= crestr_triord($cli_titre_col,"cli_code",FALSE,$limit);
			break;
		case 2 :
			$rech = cree_strrechlstcliope();
			$rech .= crestr_triord($cliope_titre_col,"cli_code",FALSE,$limit);
			break;
		default :
			$rech = cree_strrechlstcli(@$_SESSION["niv_log"],@$_SESSION["code_age"],@$_SESSION["code_do"]);
			$rech .= crestr_triord($cli_titre_col,"cli_code",FALSE,$limit);
			break;
	}	 
	$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 1 :
				$rech = cree_strrechlstclicli($tab_cli);
				$rech .= crestr_triord($cli_titre_col,"cli_code",TRUE,$limit);
				break;
			case 2 :
				$rech = cree_strrechlstcliope();
				$rech .= crestr_triord($cliope_titre_col,"cli_code",TRUE,$limit);
				break;
			default :
				$rech = cree_strrechlstcli(@$_SESSION["niv_log"],@$_SESSION["code_age"],@$_SESSION["code_do"]);
				$rech .= crestr_triord($cli_titre_col,"cli_code",TRUE,$limit);
				break;
		}	 
	
		$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
		switch (@$_SESSION["niv_log"])
		{
			case 2 :
				titlst($cliope_titre_col);
				break;
			default :
				titlst($cli_titre_col);
				break;
		}		

		echo "<th>".ucfirst($txt_ent_lst_clic)."</th>\n";
			
		$i = 0;
		while ($row = mysql_fetch_assoc($rs)) 
		{
			$affcli=TRUE;
			
			if (($td=="int") OR ($td=="con") OR ($td=="rel") OR ($td=="loc"))
			{
				if ((account_locked($row["cli_code"],FALSE)==TRUE) OR ($row["cli_cpta"] == 3))
					$affcli=FALSE;
			}
			
			if ($affcli==TRUE)
			{
				// Création de l'entête de ligne (TR)
				creetrlst($i);
				
				 echo "<td>".$row["cli_code"];
			
				 // CREATION d'icône en cas de problème potentiel
				 if  (@$_SESSION["niv_log"] <> 1)
				 {
					if ($row["cli_cpta"] >= 1)
					{
						$lst_sta = TRUE;
						echo " <a href=\"#\" class=\"popw\"><img src=\"../img/".$ico_cpta[$row["cli_cpta"]]."\" alt=\"".$mess_cpta[$row["cli_cpta"]]."\" border=\"0\" align=\"absmiddle\"><span>".$mess_cpta[$row["cli_cpta"]]."</span></a>";
					}
				}
			
				 // CREATION d'icône si client sous contrat
				if (nb_cocl_actifs_in_cli($row["cli_code"],FALSE) > 0)
				{
					$url_cocl = "cocl_lst.php?ord=DES&tri=Code&search=".$row["cli_code"]."&rech=Rechercher";
					echo ' <a href="'.$url_cocl.'" class="popw"><img src="../img/cli_con.png" alt="" border="0" align="absmiddle"><span>Client sous contrat actif. Cliquez pour la liste des contrats</span></a>';
				}

				 // Verrouillé ?
				 if  ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
				 {
					if (account_locked($row["cli_code"],FALSE)==TRUE)
					{
						echo " <a href=\"#\" class=\"popw\"><img src=\"../img/locked.png\" alt=\"".$cnx_comptedes."\" border=\"0\" align=\"absmiddle\"><span>".$cnx_comptedes."</span></a>";
						$locked=TRUE;
					}
				}
		
				 // Détail propriétaire
				 if  ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
				 {
					 echo "<div class=\"annot_petit_it\" align=\"right\">";
					 if ($row["cli_prop"] <> NULL)
					 {
						$txt = "G&eacute;r&eacute; par ".$row["cli_prop"];
					 }
					 else
						 $txt = "(Non affect&eacute;)";
					 echo $txt;
					 echo "</div>";
					 if ($row["cli_codedo"] <> NULL)
					 {
						echo "<div class=\"annot_petit_it\" align=\"right\">";
						$txt = "DO ".$row["cli_codedo"];
						echo $txt;
						echo "</div>";
					 }
				 }
				 echo "</td>\n";
			
				 echo "<td>";
				 if ($row["cli_ste"] <> "")
					echo $row["cli_ste"];
				 else
					echo "&nbsp;";
				 echo "</td>\n";
				 echo "<td>";
				 echo $row["cli_civilite"]." ".$row["cli_nom"]." ".$row["cli_prenom"];
				 echo "</td>\n";
				 switch(@$_SESSION["niv_log"])
				 {
				 	case 2 :
						break;
					default :
						echo "<td align=\"center\">".$row["cli_telf"]."</td>\n";
						echo "<td align=\"center\">";
						if ($row["cli_telp"] <> "")
							echo $row["cli_telp"];
						else
							echo "-";
						echo "</td>\n";
						
						// CREATION lien dynamique sur email
						echo "<td align=\"center\">";
						echo "<a href=\"mailto:".$row["cli_email"]."\">".$row["cli_email"]."</a>";
						echo "</td>\n";
						break;
				}
			
				// CREATION lien dynamique sur icône (édition, suppression, etc...)
				 echo "<td>";
				 echo "<div align=\"center\">";
			
				if (($td<>"int") AND ($td<>"con") AND ($td<>"rel") AND ($td<>"loc") AND ($td<>"dos") AND ($td<>"ot"))
				{
					 // Un opérateur ne peut pas modifier un compte bloqué
					 $editok=TRUE;
					 if  (@$_SESSION["niv_log"] == 2)
					 {
						 if ($row["cli_cpta"] == 3)
							$editok=FALSE;
					 }
					 if ($editok==TRUE)
					 {
						$lst_maj = TRUE;
						 echo "<a href=\"cli_maj.php?td=edit&cc=".$row["cli_code"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_edit."\"></a>";
					 }
				 }
								
				 if (($td=="int") OR ($td==""))
				 {
					if  (@$_SESSION["niv_log"] <> 1)
					{
						 $lst_int = TRUE;
						 echo " ";
						 echo "<a href=\"int_maj.php?td=add&ci=&cc=".$row["cli_code"]."\"><img src=\"../img/int.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter intervention\"></a>";
					}
				}		
	
				// Création de contrats uniquement pour agences, centre de gestion, et administrateur
				if  ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
				{
					if (($td=="con") OR ($td==""))
					{
						$lst_cocl = TRUE;
						echo " ";
						echo "<a href=\"cocl_maj.php?td=add&co=&cc=".$row["cli_code"]."&ca=\"><img src=\"../img/contrat.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter contrat maintenance\"></a>";
					}
				}
			
				// Création de dossiers uniquement pour agences, centre de gestion, et administrateur
				if  ((@$_SESSION["niv_log"] == 3) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
				{
					if (($td=="dos") OR ($td==""))
					{
						$lst_dos = TRUE;
						echo " ";
						echo "<a href=\"dos_maj.php?td=add&cd=&cc=".$row["cli_code"]."&ca=\"><img src=\"../img/dossier.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter dossier\"></a>";
					}
				}
			
				// Création de contrats de location uniquement pour techniciens, agences, centre de gestion, et administrateur
				// Création de relevés uniquement pour agences, techniciens agences, centre de gestion, et administrateur
				if  ((@$_SESSION["niv_log"] == 3) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
				{
					if (($td=="loc") OR ($td==""))
					{
						$lst_coloc = TRUE;
						echo " ";
						echo "<a href=\"coloc_maj.php?td=add&tc=0&co=&cc=".$row["cli_code"]."&ca=".@$_SESSION["code_age"]."\"><img src=\"../img/coloc.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter contrat location\"></a>";
					}

					if (($td=="rel") OR ($td==""))
					{
						echo " ";
						$rech2 = "SELECT * FROM `" .TBREL. "` WHERE `rel_codecli` = '".$row["cli_code"]."'";
						$rs2 = mysql_query($rech2)or die(mysql_error());
						if (mysql_num_rows($rs2) <> 0)
						{
							if ($row2 = mysql_fetch_array($rs2))
							{
								$lst_relexist = TRUE;
								echo "<a href=\"rel_maj.php?td=edit&cr=".$row2["rel_code"]."\"><img src=\"../img/relexist.png\" border=\"0\" align=\"absmiddle\" title=\"Editer relev&eacute; de parc\"></a>";
							}
						 }
						 else
						 {
							$lst_relcreer = TRUE;
							echo "<a href=\"rel_maj.php?td=add&cc=".$row["cli_code"]."\"><img src=\"../img/rel.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter relev&eacute; de parc\"></a>";
						 }
						mysql_free_result($rs2);
					}
				}

				// Création d'OT uniquement pour agences propriétaires, centre de gestion, et administrateur
				if  ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
				{
					if ((($td=="ot") OR ($td=="")) AND ($row["cli_prop"]<>NULL))
					{
						$lst_otadd = TRUE;
						echo " ";
						echo "<a href=\"ot_maj.php?td=add&tx=m&cc=".$row["cli_code"]."&ci=&co=&si=0&tr=\"><img src=\"../img/ot_add.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter bon de travail\"></a>";
					}
				 }
			
				if (($td<>"int") AND ($td<>"con") AND ($td<>"rel") AND ($td<>"loc") AND ($td<>"dos") AND ($td<>"ot"))
				{
					// Possibilité de suppression uniquement à partir du niveau "technicien"
					if  (@$_SESSION["niv_log"] >= 3)
					{
						 $lst_del = TRUE;
						 echo " ";
						 echo "<a href=\"cli_maj.php?td=del&cc=".$row["cli_code"]."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_del."\"></a>";
						 echo " ";
						 $lst_imp = TRUE;
						 $urlimp = "cli_maji.php?cc=".$row["cli_code"];
						 echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/print.png\" title=\"".$alt_impfic."\" border=\"0\" align=\"absmiddle\"></a>";
						 echo "</div>";
					}
				 }
						
				 echo "</td>\n";
			
				 echo "</tr>\n";
			}		
			$i++;
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
		
		if ($locked==TRUE)
		{
			echo " <img src=\"../img/locked.png\" alt=\"".$cnx_comptedes."\" border=\"0\" align=\"absmiddle\">";
			echo " : ".$cnx_comptedes;
		}
	
		// *** Pagination de pied
		pagine_lst($numrows,$limit);
		
		$taille_piedla="";
		include_once("piedla.inc.php");
	}
}

if (($td=="int") OR ($td=="ot") OR ($td==""))
{
?>
</div>
<div id="detailm2" style="display:<?PHP if ($tl==2) echo 'block'; else echo 'none';?>">
<?PHP
if ($tl==2)
{
	switch(@$_SESSION["niv_log"])
	{
		case 1 :
			$rech = cree_strrechlstsclicli($tab_cli);
			$rech .= crestr_triord($scli_titre_col2,"scli_ste",FALSE,$limit);
			break;
		 case 2 : 
			$rech = cree_strrechlstscliope();
			$rech .= crestr_triord($scliope_titre_col2,"scli_ste",FALSE,$limit);
		 	break;
		default :
			$rech = cree_strrechlstscli(@$_SESSION["niv_log"],@$_SESSION["code_age"],@$_SESSION["code_do"]);
			$rech .= crestr_triord($scli_titre_col2,"scli_ste",FALSE,$limit);
			break;
	}
	$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 1 :
				$rech = cree_strrechlstsclicli($tab_cli);
				$rech .= crestr_triord($scli_titre_col2,"scli_ste",TRUE,$limit);
				break;
			 case 2 : 
				$rech = cree_strrechlstscliope();
				$rech .= crestr_triord($scliope_titre_col2,"scli_ste",TRUE,$limit);
				break;
			default :
				$rech = cree_strrechlstscli(@$_SESSION["niv_log"],@$_SESSION["code_age"],@$_SESSION["code_do"]);
				$rech .= crestr_triord($scli_titre_col2,"scli_ste",TRUE,$limit);
				break;
		}
	
		$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 de l'entête de la table "sites secondaires"
		switch(@$_SESSION["niv_log"])
		{
			case 2 :
				titlst($scliope_titre_col2);
				break;
			default :
				titlst($scli_titre_col2);
				break;
		}
		echo "<th>".ucfirst($txt_ent_lst_clic)."</th>\n";
		
		$i = 0;
		while ($row = mysql_fetch_assoc($rs)) 
		{
			$affcli=TRUE;
			
			$row2=lit_enr_cli($row["scli_codecli"],FALSE);
			if (is_array($row2))
			{
				extract($row2);
				if (($td=="int") OR ($td=="con") OR ($td=="rel") OR ($td=="loc") OR ($_SESSION["niv_log"]==2))
				{
					if ((account_locked($cli_code,FALSE)==TRUE) OR ($cli_cpta == 3))
						$affcli=FALSE;
				}
				
				if ($affcli==TRUE)
				{
					// Création de l'entête de ligne (TR)
					creetrlst($i);
					
					echo "<td>\n";
					echo $row["scli_codecli"];
					echo "<div class=\"annot_petit_it\" style=\"padding-left: 10px;\">";
					if ($row["cli_ste"] <> "")
						echo $row["cli_ste"]."<br />";
					echo $row["cli_civilite"]." ".$row["cli_nom"]." ".$row["cli_prenom"];
					echo "</div>";
					echo "</td>\n";
					echo "<td>\n";
					echo htmlspecialchars($row["scli_ste"],ENT_NOQUOTES);
					echo "<br />";
					echo htmlspecialchars($row["scli_adr1"],ENT_NOQUOTES);
					echo "<br />";
					if ($row["scli_adr2"]<>"")
					{
						echo htmlspecialchars($row["scli_adr2"],ENT_NOQUOTES);
						echo "<br />";
					}
					echo Retournecp_openId($row["scli_ville"],FALSE)." ".Retourneville_openId($row["scli_ville"],FALSE);
					// Détail propriétaire
					if  (((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) OR (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($cli_prop=@$_SESSION["code_age"])))
					{
						echo "<div class=\"annot_petit_it\" align=\"right\">";
						$txt = "G&eacute;r&eacute; par ";
						switch ($row["scli_prop"])
						{
							case "-1" :
								$txt.= "agences couvrant le d&eacute;partement";
								break;
							case "0" :
								if (trim($cli_prop)<>"")
									$txt.= $cli_prop;
								else
									$txt = "Non affect&eacute;";
								break;
							default :
								if (trim($row["scli_prop"])<>"")
									$txt.= $row["scli_prop"];
								else
								{
									if (trim($cli_prop)<>"")
										$txt.= $cli_prop;
									else
										$txt = "Non affect&eacute;";
								}
								break;
						}
						echo $txt;
						echo "</div>";
					}
					echo "</td>\n";
					if ($_SESSION["niv_log"]<>2)
					{
						echo "<td align=\"center\">\n";
						echo "T.".$row["scli_telf"];
						echo "</td>\n";
						echo "<td align=\"center\">\n";
						if ($row["scli_fax"]<>"")
							echo "F.".$row["scli_fax"];
						else
							echo "-";
						echo "</td>\n";
						echo "<td align=\"center\">\n";
						echo "<a href=\"mailto:".$row["scli_email"]."\">".$row["scli_email"]."</a>";
						echo "</td>\n";
						echo "<td align=\"center\">\n";
						echo htmlspecialchars($row["scli_rcivil"],ENT_NOQUOTES)." ".htmlspecialchars($row["scli_rprenom"],ENT_NOQUOTES)." ".htmlspecialchars($row["scli_rnom"],ENT_NOQUOTES);
						echo "<br>";
						echo "T.".$row["scli_rtelf"];
						if ($row["scli_rfax"]<>"")
						{
							echo "<br>";
							echo "F.".$row["scli_rfax"];
						}
						if ($row["scli_rtelp"]<>"")
						{
							echo "<br />";
							echo "P.".$row["scli_rtelp"];
						}
						echo "</td>\n";
					}
				
					// CREATION lien dynamique sur icône (édition, suppression, etc...)
					 echo "<td align=\"center\">";
				
					if  (@$_SESSION["niv_log"] <> 1)
					{
						if (($td=="int") OR ($td==""))
						{
							 $lst_int = TRUE;
							 echo " ";
							 echo "<a href=\"int_maj.php?td=add&ci=&cc=".$cli_code."&sid=".$row["scli_id"]."\"><img src=\"../img/int.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter intervention\"></a>";
						}
					}
					else
						echo "-";
		
					// Création d'OT uniquement pour agences propriétaires, centre de gestion, et administrateur
					if  ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
					{
						if ((($td=="ot") OR ($td=="")) AND ($cli_prop<>NULL))
						{
							$lst_otadd = TRUE;
							echo " ";
							echo "<a href=\"ot_maj.php?td=add&tx=m&cc=".$cli_code."&ci=&co=&si=".$row["scli_id"]."&tr=\"><img src=\"../img/ot_add.png\" border=\"0\" align=\"absmiddle\" title=\"Ajouter bon de travail\"></a>";
						}
					 }

					 echo "</td>\n";
				
					 echo "</tr>\n";
				}		
				$i++;
			}
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
		
		if ($locked==TRUE)
		{
			echo " <img src=\"../img/locked.png\" alt=\"".$cnx_comptedes."\" border=\"0\" align=\"absmiddle\">";
			echo " : ".$cnx_comptedes;
		}
	
		// *** Pagination de pied
		pagine_lst($numrows,$limit);
		
		$taille_piedla="";
		include_once("piedla.inc.php");
	}
}
?>
</div>
<?PHP
}
mysql_close($conn);
}
else
	aff_ret_pbm_auto("index.php",2000);
include_once("pied.php");
?>
