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

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.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_mque.inc.php");
include_once("../inc/fic_rel.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/fic_rel.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim($_GET['td'])); // Récupération type demande
$cr = strip_tags(trim($_GET['cr'])); // Récupération code Relevé (uniquement sur création)
$crp = strip_tags(trim($_GET['crp'])); // Récupération code Relevé Produit
$cc = strip_tags(trim($_GET['cc'])); // Récupération code Client
$ca = strip_tags(trim($_GET['ca'])); // Récupération code Agence

if ((@$_SESSION["niv_log"] == 3) OR (@$_SESSION["niv_log"] == 4))
	$ca = @$_SESSION["code_age"];

$pbm_rpdt=FALSE;

if (@$_SESSION["niv_log"] == 1)
	$td = "view";

if ($td<>"add")
{
	if ($crp <> "")
	{
		// Récupération des informations dossier relevé
		$row = lit_enr_rpdt($crp);
		if (is_array($row))
		{
			extract ($row);
	
			$row = lit_enr_cli($rpdt_codecli,TRUE);
			if (is_array($row))
			{
				extract($row);
				$ca=$cli_prop;
				$cc=$cli_code;
			}

			// Vérification des tentatives de hack
			switch (@$_SESSION["niv_log"])
			{
				// Contrôle qu'un client n'essaye pas de "hacker" un relevé
				case 1 :
					$tab_cli=give_tab_rcli($_SESSION["code_log"],TRUE);
					if (in_array($rpdt_codecli,$tab_cli)==FALSE)
						$pbm_rpdt=TRUE;
					break;
			// Contrôle qu'une agence n'essaye pas de "hacker" un relevé
				case 3 :
				case 4 :
					if (($rpdt_codeage <> @$_SESSION["code_age"]) OR ($cli_prop <> @$_SESSION["code_age"]))
						$pbm_rpdt = TRUE;
					break;
			}
			
			if ($pbm_rlic==FALSE)
			{
				$exist_in_rpbm = exist_rpdt_in_rpbm($crl);
				if ($exist_in_rpbm==TRUE)
					$exist_in_rpbm=1;
				else
					$exist_in_rpbm=0;
	
				$rpdt_daterelf = formatedate($rpdt_daterel);
				$rpdt_dateachf = formatedate($rpdt_dateach);
				$rpdt_fingarf = formatedate($rpdt_fingar);
				$rpdt_dateoutf = formatedate($rpdt_dateout);
				$rpdt_mdvalf = formatedate($rpdt_mdval);
				$rpdt_mdlmajf = formatedate($rpdt_mdlmaj);
			}
		}
		else
			$pbm_rpdt = TRUE;
	}
	else
		$pbm_rpdt = TRUE;
}
else
{
	if ($cc <> "")
	{
		// Contrôle qu'un client n'essaye pas de "hacker" un relevé
		if ((@$_SESSION["niv_log"] == 1) AND ($cc <> @$_SESSION["code_log"]))
			$pbm_rpdt = TRUE;

		$row = lit_enr_cli($cc,TRUE);
		if (is_array($row))
		{
			extract($row);
		
			$ca=$cli_prop;

			// Contrôle qu'une agence n'essaye pas de "hacker" un relevé
			switch(@$_SESSION["niv_log"])
			{
				case 3 :
				case 4 :
					if (client_age_ok($cli_code,@$_SESSION["code_age"],TRUE)==FALSE)
						$pbm_rpdt = TRUE;
					break;
				default :
					break;
			}
			
			$row = lit_enr_rel_cli($cli_code);
			if (is_array($row))
			{
				extract($row);
				if ($cli_ste<>"")
					$rpdt_idsite = -2;
				else
					$rpdt_idsite = 0;
				$ca=$cli_prop;
				$num = $row["rel_num"]+1;
				$rpdt_codep = $row["rel_rnum"].sprintf ("%'04s",$num);
			}

			$rpdt_daterelf = $datef;
			$rpdt_dateoutf = "";
			$rpdt_code = crecodesession("RP");
			$rpdt_coderel = $rel_code;
			$rpdt_codecli = $cc;
			$rpdt_codeage = $ca;
			$rpdt_mac = "00:00:00:00:00:00";
			$rpdt_ip1 = "000.000.000.000";
			$rpdt_ip2 = "000.000.000.000";
			$rpdt_mdhcp = "000.000.000.000";
			$rpdt_ip = "000.000.000.000";
			$rpdt_masq = "000.000.000.000";
			$rpdt_pass = "000.000.000.000";

	
		}
		else
			$pbm_rpdt=TRUE;
	}
}


switch ($td)
{
	case "add":
		$titre = "AJOUT FICHE RELEVE MATERIEL";
		$rpdt_gars=FALSE;
		$rpdt_prop=FALSE;
		break;
	case "edit":
		$titre = "MISE A JOUR FICHE RELEVE MATERIEL";
		break;
	case "view":
		$titre = "DETAIL FICHE RELEVE MATERIEL";
		break;
	case "del":
		$titre = "SUPPRESSION FICHE RELEVE MATERIEL";
		break;
	default :
		$pbm_rpdt=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; ?> : Fiche Relev&eacute; Mat&eacute;riel</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 vérifications -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

<!-- Définition Javascript pour calendrier popup -->
  <!-- Feuille de Style -->
  <link rel="stylesheet" type="text/css" media="all" href="../jscript/jscal/skins/aqua/theme.css" title="Aqua" />

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

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscript/jscal/lang/calendar-<?PHP echo $_SESSION["lng"]; ?>.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="../jscript/jscal/calendar-setup.js"></script>
<!-- Fin de la définition Javascript pour calendrier popup -->

<!-- Scripts Javascript pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:daterelf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date création ; stok:frmok ; stbad:frmbad",
<?PHP
if ((@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["niv_log"] <> 3))
{
?>
	"nom:codeage ; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:codeage ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> ; stok:frmok ; stbad:frmbad",
<?PHP 
}

if (($td == "add") or ($td=="edit"))
{ 
?>
	"nom:site ; format:liste ; req:Y ; txt:Lieu d'utilisation ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:site ; format:txt ; req:Y ; txt:Lieu d'utilisation ; stok:frmok ; stbad:frmbad",
<?PHP 
}
if ($td == "add")
{ 
?>
	"nom:codetec ; format:liste ; req:Y ; txt:Technicien ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:codetec ; format:txt ; req:Y ; txt:Technicien ; stok:frmok ; stbad:frmbad",
<?PHP 
}

if (($rpdt_dateoutf == "") and ($td <> "view"))
{ 
?>
	"nom:codecat ; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_cat); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:codema ; format:liste ; req:Y ; txt:Marque ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:codeet ; format:liste ; req:Y ; txt:Etat constaté ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:codeta ; format:liste ; req:N ; txt:Type d'accès ; vmn:0 ; stok:frmok ; stbad:frmbad",
	"nom:codel ; format:liste ; req:N ; txt:Log. Télémaintenance ; vmn:0 ; stok:frmok ; stbad:frmbad",
	"nom:codem ; format:liste ; req:N ; txt:Mode mises à jour ; vmn:0 ; stok:frmok ; stbad:frmbad",
	"nom:mper ; format:liste ; req:N ; txt:Fréquence mises à jour ; vmn:0 ; stok:frmok ; stbad:frmbad",
	"nom:mtype ; format:liste ; req:N ; txt:Type mises à jour ; vmn:0 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:codecat ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_cat); ?> ; stok:frmok ; stbad:frmbad",
	"nom:codema ; format:txt ; req:Y ; txt:Marque ; stok:frmok ; stbad:frmbad",
	"nom:codeet ; format:txt ; req:Y ; txt:Etat constaté ; stok:frmok ; stbad:frmbad",
	"nom:codeta ; format:txt ; req:Y ; txt:Type d'accès ; stok:frmok ; stbad:frmbad",
	"nom:codel ; format:txt ; req:Y ; txt:Log. Télémaintenance ; stok:frmok ; stbad:frmbad",
	"nom:codem; format:txt ; req:Y ; txt:Mode mises à jour ; stok:frmok ; stbad:frmbad",
	"nom:mper ; format:txt ; req:Y ; txt:Fréquence mises à jour ; stok:frmok ; stbad:frmbad",
	"nom:mtype ; format:txt ; req:Y ; txt:Type mises à jour ; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:modele ; format:txt ; req:Y ; txt:Modèle ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:ns ; format:txt ; req:Y ; txt:Numéro de série ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:empl ; format:txt ; req:Y ; txt:Emplacement ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:codep ; format:txt ; req:Y ; txt:Codage produit ; lmx:20 ; stok:frmok ; stbad:frmbad",
	"nom:util ; format:txt ; req:Y ; txt:Utilisateur ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:nomp ; format:txt ; req:N ; txt:Nom du poste ; lmx:20 ; stok:frmok ; stbad:frmbad",
	"nom:gt ; format:txt ; req:N ; txt:Groupe de travail ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:dom ; format:txt ; req:N ; txt:Domaine ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:login ; format:txt ; req:N ; txt:Login ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:mdp ; format:txt ; req:N ; txt:<?PHP echo html_entity_decode($txt_chp_mdp); ?> ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:mac ; format:mac ; req:N ; txt:Adresse MAC ; lmx:17 ; stok:frmok ; stbad:frmbad",
	"nom:ip1 ; format:ip ; req:N ; txt:Adresse IP DHCP N°1; lmx:15 ; stok:frmok ; stbad:frmbad",
	"nom:ip2 ; format:ip ; req:N ; txt:Adresse IP DHCP N°2; lmx:15 ; stok:frmok ; stbad:frmbad",
	"nom:mdhcp ; format:ip ; req:N ; txt:Masque IP DHCP; lmx:15 ; stok:frmok ; stbad:frmbad",
	"nom:ip ; format:ip ; req:N ; txt:Adresse IP ; lmx:15 ; stok:frmok ; stbad:frmbad",
	"nom:masq ; format:ip ; req:N ; txt:Masque IP ; lmx:15 ; stok:frmok ; stbad:frmbad",
	"nom:pass ; format:ip ; req:N ; txt:Adresse IP passerelle; lmx:15 ; stok:frmok ; stbad:frmbad",
	"nom:sid ; format:txt ; req:N ; txt:SID ; lmx:80 ; stok:frmok ; stbad:frmbad",
	"nom:wep ; format:txt ; req:N ; txt:Clef WEP ; lmx:80 ; stok:frmok ; stbad:frmbad",
	"nom:tlien ; format:txt ; req:N ; txt:Lien d'accès; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:tlogin ; format:txt ; req:N ; txt:Login télémaintenance ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:tmdp ; format:txt ; req:N ; txt:Mot de passe télémaintenance ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:mlogin ; format:txt ; req:N ; txt:Login mises à jour ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:mmdp ; format:txt ; req:N ; txt:Mot de passe mises à jour ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:signataire ; format:txt ; req:Y ; txt:Validé par ; lmx:50 ; stok:frmok ; stbad:frmbad");
//-->
</script>

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

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

</head>

<?PHP if ($td == "del"){ ?>
<body onload="warndel();metReadonly();">
<?PHP } else { ?>
<body onLoad="tst_modeip(document.getElementById('modeip').value);tst_sdhcp(document.getElementById('sdhcp').value);verif_pw(document.getElementById('mdp').value,false,'nivpw');verif_pw(document.getElementById('tmdp').value,false,'nivpwt');verif_pw(document.getElementById('mmdp').value,false,'nivpwm');metFocus();">
<?PHP 
}
include_once("../inc/entete.inc.php"); 
?>

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<?PHP
if ($pbm_rpdt==FALSE)
{
	// Récupération id site
	if (isset($_POST["site"]))
		$idscli = strip_tags(trim($_POST['site']));
	else
		$idscli=-1;
	
	// Récupération filtre problème
	if (isset($_POST["pbms"]))
		$pbm = intval(strip_tags(trim($_POST['pbms']))); 
	else
		$pbm=0;
?>
<!-- Affiché uniquement s'il y a un code client -->
<?PHP
if ($cc <> "")
{
?>
<table width="100%"  border="0">
<tr>
	<td width="33%">
	<?PHP
	if (@$_SESSION["niv_log"] <> 1)
		echo '<a href="rel_maj.php?td=edit&cr='.$rpdt_coderel.'">Retour au dossier de relev&eacute;';
	else
		echo '<a href="rel_maj.php">Retour au dossier de relev&eacute;';
	?>
    </td>
	<td width="33%" valign="top" id="oblig" align="center" class="annot_gras_it">
	(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>)
	</td>
	<td width="33%" align="right">
	<?PHP
	if (($td == "edit") OR ($td == "view"))
	{
	?>
	<select name="etats" size="1" id="etats" onChange="javascript:; lanceimp(this.value); this.value='';" class="annot_petit">
	<option value="" selected>&raquo; Etats &laquo;</option>
	<?PHP
		$urlimp = "rlp_pdf.php?cr=".$crp."&te=m&pbm=0";
		echo "<option value=\"".$urlimp."\" class=\"icone\" style=\"background-image: url(../img/sel_print.gif);\">Relev&eacute;</option>\n";

		$urlimp = "rlp_pdf.php?cr=".$crp."&te=m&pbm=1";
		echo "<option value=\"".$urlimp."\" class=\"icone\" style=\"background-image: url(../img/sel_rel.gif);\">Relev&eacute; et probl&egrave;mes</option>\n";
	?>		
	</select>
	<?PHP 
	} 
	else 
		echo "&nbsp;";
	?>
	</td>
</tr>
</table>

<form name="rpdt_maj" method="post" action="rpdt_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'','<?PHP echo $_SESSION["lng"]; ?>'));">
<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
<input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
<input name="codecli" type="hidden" id="codecli" value="<?PHP echo $rpdt_codecli ?>">
<?PHP if ($td == "add") { ?>
	<input name="code" type="hidden" id="code" value="<?PHP echo $rpdt_code ?>">
	<input name="dateoutf" type="hidden" id="dateoutf" value="<?PHP echo $rpdt_dateoutf ?>">
<?PHP } else {?>
	<input name="code" type="hidden" id="code" value="<?PHP echo $rpdt_code ?>">
	<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $rpdt_codeage ?>">
	<input name="codetec" type="hidden" id="codetec" value="<?PHP echo $rpdt_codetec ?>">
<?PHP } ?>


<!-- Date de création -->
<!-- Date de sortie du produit -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_daterelf" align="right">Date Cr&eacute;ation </td>
	<?PHP if ($td <> "add") { ?>
		<td width="240">
	<?PHP } else { ?>
		<td>
	<?PHP }?>
		<input name="daterelf" type="text" id="daterelf" value="<?PHP echo $rpdt_daterelf ?>" size="10" maxlength="10" readonly="1">
		<?PHP if ($td == "add") { ?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_daterelf" title="<?PHP echo $alt_chxdate; ?>">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<span class="annot_std_it">(
		<a href="javascript:;" onClick="document.rpdt_maj.daterelf.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="document.rpdt_maj.daterelf.value=''")> Annuler</a> )</span>
		<?PHP } ?>
	</td>
	<?PHP if ($td <> "add") { ?>
	<td width="160" class="rubfrm" id="f_dateoutf" align="right" align="right">Sorti du parc le </td>
	<td>
		<input name="dateoutf" type="text" id="dateoutf" value="<?PHP echo $rpdt_dateoutf ?>" size="10" maxlength="10" readonly="1">
		<?PHP
			if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
			{
		?>
			<img src="../img/calendar.png" align="absmiddle" id="f_img_dateoutf" title="<?PHP echo $alt_chxdate; ?>">
			<span class="annot_std_it">(
			<a href="javascript:;" onClick="document.rpdt_maj.dateoutf.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="document.rpdt_maj.dateoutf.value=''")> Annuler</a> )</span>
		<?PHP
			}
		?>
	</td>
	<?PHP } ?>
</tr>
</table>

<!-- Code du dossier de relevé -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_coderel" align="right">Dossier de relev&eacute; </td>
	<td width="240">
		<input name="coderel" type="text" id="coderel" value="<?PHP echo $rpdt_coderel ?>" size="20" maxlength="20" readonly="1">
	</td>
	<td>
	<?PHP if (($td <> "add") AND ($td <> "view") AND ($rpdt_dateoutf == "")) { ?>
		<span class="annot_petit_it">ATTENTION : d&egrave;s que le mat&eacute;riel est sorti du parc, la fiche n'est plus modifiable.<br> 
		Pensez &agrave; d&eacute;sinstaller les licences AVANT si vous voulez les r&eacute;affecter.</span>
	<?PHP } else {?>
	&nbsp;
	<?PHP } ?>
	</td>
</tr>
</table>

<!-- Code du relevé matériel client (affiché uniquement si édition ou suppression) -->
<?PHP if ($td <> "add") {?>
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_code" align="right">Code Fiche </td>
	<td>
		<input name="code" type="text" id="code" value="<?PHP echo $rpdt_code ?>" size="20" maxlength="20" readonly="1">
	</td>
</tr>
</table>
<?PHP }  ?>

<!-- Affichage du client -->
<table width="100%" border="0">
<tr>
	<td class="rubfrm" id="f_codecli" align="center">Client
	<?PHP
	if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
		echo " <img src=\"../img/".$ico_cpta[$cli_cpta]."\" title =\"".$mess_cpta[$cli_cpta]."\" border=\"0\" align=\"absmiddle\">";
	?>
	</td>
</tr>
</table>

<!-- Détails client -->
<table width="100%"  border="0">
<tr>
	<td valign="top" bgcolor="#C5CED7">
	<?PHP
	echo "<span class=\"annot_std_gras\">";
	if ($cli_ste <>"") 
		echo $cli_ste."<br>";
	else
		echo $cli_civilite." ".$cli_prenom." ".$cli_nom."<br>";
	echo "</span>";
	echo $cli_adr1."<br />";
	if ($cli_adr2 <>"") 
		echo $cli_adr2."<br />";
	echo Retournecp_openId($cli_ville,TRUE)." ".Retourneville_openId($cli_ville,TRUE)."<br />";
	$chemin_imagesco = $chemin_images."/telc.png"; 
	echo "<img src=\"".$chemin_imagesco."\" align=\"bottom\">";
	echo " ".$cli_telf."<br>";
	?>
	</td>
	<td width="60" valign="top">
	<?PHP 
	if (@$_SESSION["niv_log"] >= 3)
	{
	  $url_affnotesc = "aff_notesc.php?cc=".$cc;
	?>
	  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',930,380,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/eye.png" border="0" align="absmiddle"></a>
	  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',930,380,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> Notes</a>
	<?PHP
	}
	else
		echo "&nbsp;";
	?>
	</td>
	</tr>
</table>

<!-- Site d'usage du produit -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_site" align="right">Lieu d'utilisation</td>
	<td>
	<?PHP
		if (($rpdt_dateoutf == "") and ($cli_ste<>"") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc, professionnel, et si pas en visualisation
		{
	?>
			<select name="site" id="site" onChange="warnmovesclirlp('<?PHP echo $exist_in_rpbm; ?>',<?PHP echo $rpdt_idsite; ?>)">
			<option>---Choisissez le lieu d'utilisation--</option>
			<option value="-1" <?PHP if ($rpdt_idsite == -1) echo "selected"?>>Tous les sites</option>
			<option value="0" <?PHP if ($rpdt_idsite == 0) echo "selected"?>>Site principal</option>
			<?PHP
				// Création de la liste des sites actifs
				
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rech = "SELECT * FROM ".TBSCLI." WHERE `scli_actif` = '1' AND `scli_codecli`='".$cc."' ORDER BY scli_ste";
				$rs = mysql_query($rech) or die(mysql_error());
			
				if (mysql_num_rows($rs) <> 0)
				{
					while ($resultat = mysql_fetch_array($rs)) 
					{
						extract($resultat);
			
						if ($scli_adr2<>"")
							$nom_site = $scli_ste." (".$scli_adr1.", ".$scli_adr2.", ".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE).")";
						else
							$nom_site = $scli_ste." (".$scli_adr1.", ".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE).")";
						if ($rpdt_idsite == $scli_id)
							echo '<option value="'.$scli_id.'" selected>'.$nom_site.'</option>';
						else
							echo '<option value="'.$scli_id.'">'.$nom_site.'</option>';
					}
				}
				mysql_free_result($rs);
			?>
			</select>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP
			}
			else
			{
			?>
				<input name="site" type="hidden" id="site" value="<?PHP echo $rpdt_idsite; ?>">
			<?PHP
				switch ($rpdt_site)
				{
				case -1 :
				?>
						<input name="nsite" type="text" id="nsite" value="Tous les sites" readonly="1">
				<?PHP
					break;
				case 0 :
				?>
						<input name="nsite" type="text" id="nsite" value="Site principal" readonly="1">
				<?PHP
					break;
				default :
						$nom_site="";
						$row=lit_enr_scli_id($rpdt_idsite,TRUE);
						if (is_array($row))
						{
							extract($row);
							if ($scli_adr2<>"")
								$nom_site = $scli_ste." (".$scli_adr1.", ".$scli_adr2.", ".Retournecp_openId($scli_ville,TRUE)." ".Retourneville_openId($scli_ville,TRUE).")";
							else
								$nom_site = $scli_ste." (".$scli_adr1.", ".Retournecp_openId($scli_ville,TRUE)." ".Retourneville_openId($scli_ville,TRUE).")";
						}
				?>
						<input name="nsite" type="text" id="nsite" value="<?PHP echo htmlspecialchars($nom_site); ?>" size="100" readonly="1">
				<?PHP
					break;
				}
			}
		?>
	</td>
</tr>
</table>

<table width="100%"  border="0">
<tr>
	<td class="rubfrm" id="f_codecli" align="center">
		Relev&eacute; effectu&eacute; par
	</td>
	</tr>
</table>

<!-- Code de l'agence (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codeage" align="right">Agence</td>
	<td>
		<?PHP
			$row = lit_enr_age($ca,TRUE);
			if (is_array($row))
				extract($row);
			$nom_code = $age_nom." (".$age_code.")";
		?>
		<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $ca; ?>">
		<input name="nagence" type="text" id="nagence" value="<?PHP echo htmlspecialchars($nom_code); ?>" size="50" readonly="1">
	</td>
</tr>
</table>

<!-- Code du technicien (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codetec" align="right">Technicien</td>
	<td>
		<?PHP
		if ($td =="add")  // Ajout = zone modifiable (on peut choisir un technicien)
		{ 
			// Création de la liste des techniciens actifs
			
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM ".TBTEC." WHERE `tec_dateout`='0000-00-00' AND `tec_codeage` = '".$ca."' ORDER BY tec_nom ";
			$rs = mysql_query($rech) or die(mysql_error());

			if (mysql_num_rows($rs) <> 0)
			{
			?>
			
			<select name="codetec" id="codetec">

			<?PHP
				echo "<option value=\"\">".$sel_lst_tec."</option>";
	
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					$nom_prenom = $tec_nom." ".$tec_prenom;
					if ($rpdt_codetec == $tec_code)
						echo '<option value="'.$tec_code.'" selected>'.$nom_prenom.'</option>';
					else
						echo '<option value="'.$tec_code.'">'.$nom_prenom.'</option>';
				}
			?>
			</select>
			<?PHP
			}
			else
			{
			?>
				<select name="codetec" id="codetec">
				<option>-- Pas de technicien actif --</option>
				</select>
			<?PHP
			}
			mysql_free_result($rs);
			mysql_close($conn);
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP 
		} 
		else  // Edition ou suppression = zone non modifiable (affichage seul)
		{
			$row = lit_enr_tec($rpdt_codetec,TRUE);
			if (is_array($row))
				extract($row);
		?>
		<input name="nomtec" type="text" id="nomtec" value="<?PHP echo htmlspecialchars($tec_nom." ".$tec_prenom); ?>" size="50" readonly="1">
		<?PHP 
		} 
		?>
	</td>
</tr>
</table>


<!-- Délai du relevé -->
<table width="100%"  border="0">
<tr>
	<td class="rubfrm" >
		D&eacute;tail du relev&eacute;
	</td>
	</tr>
</table>

<!-- Catégorie -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codecat" align="right">Cat&eacute;gorie</td>
	<td>
		<?PHP
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
			
			// Création de la liste des catégories
			
			$rech = "SELECT * FROM ".TBRPCAT." ORDER BY rpcat_desc";
			$rs = mysql_query($rech) or die(mysql_error());
	
			?>
			
			<select name="codecat" id="codecat">
	
			<?PHP
				echo "<option value=\"\">-- Choisissez une catégorie --</option>";
	
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($rpdt_codecat == $rpcat_code)
						echo '<option value="'.$rpcat_code.'" selected>'.$rpcat_desc.'</option>';
					else
						echo '<option value="'.$rpcat_code.'">'.$rpcat_desc.'</option>';
				}
			?>
			</select>
			<?PHP
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBRPCAT." WHERE `rpcat_code` = '".$rpdt_codecat."'";
			$rs = mysql_query($rech) or die(mysql_error());
			if ($row = mysql_fetch_array($rs))
			{
				extract ($row);
			}
		?>
			<input name="codecat" type="hidden" id="codecat" value="<?PHP echo $rpdt_codecat; ?>">
			<input name="nomcat" type="text" id="nomcat" value="<?PHP echo htmlspecialchars($rpcat_desc); ?>" size="40" readonly="1">
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>


<!-- Marque/Nom du fabricant -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codema" align="right">Constructeur</td>
	<td>
		<?PHP
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
			// Création de la liste des marques
			
			$rech = "SELECT * FROM ".TBMQUE." WHERE `mque_code`<>'*' AND (`mque_type`='0' OR `mque_type`='1') ORDER BY mque_ste";
			$rs = mysql_query($rech) or die(mysql_error());
	
			?>
			
			<select name="codema" id="codema">
	
			<?PHP
				if ($rpdt_codema <> "")
					echo "<option value=\"\">-- Choisissez une marque --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez une marque --</option>";
	
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($rpdt_codema == $mque_code)
						echo '<option value="'.$mque_code.'" selected>'.$mque_ste.'</option>';
					else
						echo '<option value="'.$mque_code.'">'.$mque_ste.'</option>';
				}
			?>
			</select>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBMQUE." WHERE `mque_code` = '".$rpdt_codema."'";
			$rs = mysql_query($rech) or die(mysql_error());
			if ($row = mysql_fetch_array($rs))
			{
				extract ($row);
			}
		?>
			<input name="codema" type="hidden" id="codema" value="<?PHP echo $rpdt_codema; ?>">
			<input name="nomma" type="text" id="nomma" value="<?PHP echo htmlspecialchars($mque_ste); ?>" size="40" readonly="1">
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>


<!-- Modèle du produit -->
<!-- Numéro de série -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_modele">
		Mod&egrave;le / NS
	</td>
    <td>
	<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
	?>
			<input name="modele" type="text" id="modele" value="<?PHP echo htmlspecialchars($rpdt_modele); ?>" size="40"> <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> / 
			<input name="ns" type="text" id="ns" value="<?PHP echo htmlspecialchars($rpdt_ns); ?>" size="40"> <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
		}
		else
		{
	?>
			<input name="modele" type="text" id="modele" value="<?PHP echo htmlspecialchars($rpdt_modele); ?>" size="40" readonly="1"> / 
			<input name="ns" type="text" id="ns" value="<?PHP echo htmlspecialchars($rpdt_ns); ?>" size="40" readonly="1">
	<?PHP
		}
	?>
	</td>
</tr>
</table>

<!-- Etat du produit -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codeet" align="right">Etat constat&eacute;</td>
	<td>
		<?PHP
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
			// Création de la liste des états
			
			$rech = "SELECT * FROM ".TBRPET." ORDER BY rpet_desc";
			$rs = mysql_query($rech) or die(mysql_error());
	
			?>
			
			<select name="codeet" id="codeet">
	
			<?PHP
				if ($rpdt_codeet <> "")
					echo "<option value=\"\">-- Choisissez un état --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez un état --</option>";
	
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($rpdt_codeet == $rpet_code)
					{
						echo '<option value="'.$rpet_code.'" selected>'.$rpet_desc.'</option>';
					}
					else
					{
						echo '<option value="'.$rpet_code.'">'.$rpet_desc.'</option>';
					}
				}
			?>
			</select>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBRPET." WHERE `rpet_code` = '".$rpdt_codeet."'";
			$rs = mysql_query($rech) or die(mysql_error());
			if ($row = mysql_fetch_array($rs))
			{
				extract ($row);
			}
		?>
			<input name="codeet" type="hidden" id="codeet" value="<?PHP echo $rpdt_codeet; ?>">
			<input name="nommet" type="text" id="nomet" value="<?PHP echo htmlspecialchars($rpet_desc); ?>" size="40" readonly="1">
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>

<!-- Localisation -->
<table width="100%"  border="0">
<tr>
	<td class="rubfrm" align="center">
		Rep&eacute;rage / Garantie / Propri&eacute;t&eacute;
	</td>
	</tr>
</table>

<!-- Emplacement -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_empl" align="right">
		Emplacement
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="empl" type="text" id="empl" value="<?PHP echo htmlspecialchars($rpdt_empl); ?>" size="40">
		  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> <span class="annot_petit_it">(Pi&egrave;ce, bureau, &eacute;tage, etc...)</span>
		 <?PHP
		 }
		 else
		 {
		 ?>
			<input name="empl" type="text" id="empl" value="<?PHP echo htmlspecialchars($rpdt_empl); ?>" size="40" readonly="1">
		 <?PHP
		 }
		 ?>
	</td>
</tr>
</table>


<!-- Codage produit -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codep" align="right">
		Codage inventaire
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="codep" type="text" id="codep" value="<?PHP echo htmlspecialchars($rpdt_codep); ?>" size="40" >
		  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> <span class="annot_petit_it"><br>
		  Code est sugg&eacute;r&eacute; en fonction du param&eacute;trage du dossier de relev&eacute; rattach&eacute; et du nombre de fiches relev&eacute;s mat&eacute;riels d&eacute;j&agrave; saisies.<br>
		  On peut saisir autre chose, notamment si le client utilise son propre codage.</span>
		 <?PHP
		 }
		 else
		 {
		 ?>
			<input name="codep" type="text" id="codep" value="<?PHP echo htmlspecialchars($rpdt_codep); ?>" size="40" readonly="1">
		 <?PHP
		 }
		 ?>
	</td>
</tr>
</table>

<!-- Utilisateur -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_util" align="right">
		Utilisateur
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="util" type="text" id="util" value="<?PHP echo htmlspecialchars($rpdt_util) ?>" size="40" >
		  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		 <?PHP
		 }
		 else
		 {
		 ?>
			<input name="util" type="text" id="util" value="<?PHP echo htmlspecialchars($rpdt_util) ?>" size="40" readonly="1">
		 <?PHP
		 }
		 ?>
	</td>
</tr>
</table>

<!-- Date d'achat -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_dateachf" align="right">Date d'achat</td>
	<td>
		<input name="dateachf" type="text" id="dateachf" value="<?PHP echo $rpdt_dateachf ?>" size="10" maxlength="10" readonly="1">
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<img src="../img/calendar.png" align="absmiddle" id="f_img_dateachf" title="<?PHP echo $alt_chxdate; ?>">
			<span class="annot_std_it">(
			<a href="javascript:;" onClick="document.rpdt_maj.dateachf.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="document.rpdt_maj.dateachf.value=''")> Annuler</a> )</span>
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Fin de garantie -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datefgarf" align="right">Fin de garantie</td>
	<td>
		<input name="datefgarf" type="text" id="datefgarf" value="<?PHP echo $rpdt_fingarf ?>" size="10" maxlength="10" readonly="1" onChange="verif_dout(this.value,'wgarfout','2');">
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<img src="../img/calendar.png" align="absmiddle" id="f_img_datefgarf" title="<?PHP echo $alt_chxdate; ?>">
			<span class="annot_std_it">(
			<a href="javascript:;" onClick="document.rpdt_maj.datefgarf.value='';verif_dout(document.rpdt_maj.datefgarf.value,'wgarfout','2');"><img src="../img/raz.png" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="document.rpdt_maj.datefgarf.value='';verif_dout(document.rpdt_maj.datefgarf.value,'wgarfout','2');")> Annuler</a> )</span>
		<?PHP
		}
		?>
		<span id="wgarfout">
		<?PHP
		if ($rpdt_fingarf <> "")
		{
			if (echeance_depassee_date($datea,$rpdt_fingar) == TRUE)
			{
				echo "<span class=\"alerte1\">";
				echo "Plus sous garantie";
				echo "</span>";
			}
		}
		?>
		</span>
	</td>
</tr>
</table>



<!-- Garantie sur site ? -->
<!-- Propriétaire ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_gars" align="right">
		Gar/site ?
	</td>
    <td width="100">
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"gars\" size=\"1\" id=\"gars\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_gars)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
	}
	else
	{ 
	?>
	<input name="gars" type="text" id="gars" value="<?PHP echo $non_oui[$rpdt_gars]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
	<td width="160" class="rubfrm" id="f_prop">
		<div align="right">Propriétaire ? </div>
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"prop\" size=\"1\" id=\"prop\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_prop)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
	}
	else
	{ 
	?>
	<input name="prop" type="text" id="prop" value="<?PHP echo $non_oui[$rpdt_prop]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>

<!-- Signé par -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_signataire" align="right">
		Valid&eacute; par
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="signataire" type="text" id="signataire" value="<?PHP echo htmlspecialchars($rpdt_signataire); ?>" size="50">
		  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP
		}
		else
		{
		?>
			<input name="signataire" type="text" id="signataire" value="<?PHP echo htmlspecialchars($rpdt_signataire); ?>" size="50" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<p align="center">
<?PHP 
if (($td == "edit") or ($td == "add")) // Boutons si en édition ou création
{ 
?>
	<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="Tout r&eacute;initialiser">
	<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_enr; ?>">
<?PHP
}
if ($td == "del") // Bouton si en mode suppression
{ 
?>
	<input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
<?PHP 
} 
?>
</p>


<input name="maxmnu" type="hidden" id="maxmnu" value="8">

<!-- Compléments -->
<table width="100%"  border="0" cellspacing="0">
<tr>
	<td height="25" class="rubfrm" align="center">
		Informations compl&eacute;mentaires
	</td>
	<td height="25" width="25" class="rubfrm" >
		<div align="center">
		 <span id="close_menu" style="display:none"><img src="../img/top.png" border="0" title="Fermer menu" alt="Fermer menu" align="absmiddle" onClick="javascript:;close_mnu_rel();"></span>
		</div>
	</td>
</tr>
</table>

<div id="menu_rel" class="menu_ongletfull">
<a class="ongleti" id="m1" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();"><?PHP echo $txt_chp_notes; ?></a>
<a class="ongleti" id="m2" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();">Licences</a>
<a class="ongleti" id="m3" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();">R&eacute;seau</a>
<a class="ongleti" id="m4" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();">T&eacute;l&eacute;maintenance</a>
<a class="ongleti" id="m5" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();">Mises &agrave; jour</a>
<a class="ongleti" id="m6" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();">Connexions</a>
<a class="ongleti" id="m7" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();">Contrats</a>
<a class="ongleti" id="m8" href="javascript:;" onclick="set_mnu_rel(this.id);" onFocus="this.blur();">Probl&egrave;mes</a>
</div>
<br />

<div id="detailm1" style="display:none">
<!-- Notes -->
<table width="100%"  border="0">
  <tr>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<textarea name="nota" rows="5" id="nota"><?PHP echo htmlspecialchars($rpdt_nota); ?></textarea>
		<?PHP
		}
		else
		{
		?>
			<textarea name="nota" rows="5" id="nota" readonly><?PHP echo htmlspecialchars($rpdt_nota); ?></textarea>
		<?PHP
		}
		?>
	</td>
  </tr>
</table>
</div>

<div id="detailm2"  style="display:none">
<!-- Licences utilisées -->
<?PHP
// Création de la liste des relevés licences actifs
$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
mysql_select_db(DBNAME);
$rech = "SELECT * FROM ".TBRLIC." WHERE rlic_dateout = '0000-00-00' AND rlic_codecli = '".$rpdt_codecli."' ORDER BY rlic_code";
$rs = mysql_query($rech) or die(mysql_error());

if (mysql_num_rows($rs) <> 0)
{
	echo "<table class=\"MtableD\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
	 
	// Création de l'entête de la table "détails licences"
	echo "<th>";
	echo "Code Fiche";
	echo "</th>\n";
	echo "<th>";
	echo "Marque";
	echo "</th>\n";
	echo "<th>";
	echo "Mod&egrave;le / Version";
	echo "</th>\n";
	echo "<th>";
	echo "Validit&eacute;";
	echo "</th>\n";
	echo "<th>";
	echo "Utilis&eacute;e";
	echo "</th>\n";
	echo "<th>";
	echo $txt_ent_lst_clic;
	echo "</th>\n";

	$j = 0;
	
	while ($row = mysql_fetch_assoc($rs)) 
	{         
		// Création de l'entête de ligne (TR)
		creetrlstdet($j);
		
		echo "<td>\n";
		echo $row["rlic_code"]." ";
		if ($row["rlic_legal"] == FALSE)
			echo "<img src=\"../img/warn.png\" title=\"Licence illégale...\" border=\"0\" align=\"absmiddle\">";
		$nb_rpdt_utilisees = 0;
		$rech2 = "SELECT * FROM `" .TBRPDT. "` WHERE `rpdt_codecli` = '".$rpdt_codecli."'";
		$rs2 = mysql_query($rech2) or die(mysql_error());
		if (mysql_num_rows($rs2) <> 0)
		{
			while ($resultat = mysql_fetch_array($rs2)) 
			{
				if (ereg($row["rlic_code"],$resultat["rpdt_coderlic"]))
					$nb_rpdt_utilisees++;
			}
		}
		if ($nb_rpdt_utilisees >= $row["rlic_maxcli"])
		{
			$txtlic = "Licences installées : ".$nb_rpdt_utilisees." / autorisées : ".$row["rlic_maxcli"].".";
			echo " <img src=\"../img/cd.png\" title =\"".$txtlic."\" border=\"0\" align=\"absmiddle\">";
		}
		echo "</td>\n";

		echo "<td>\n";
		$rech2 = "SELECT * FROM ".TBMQUE." WHERE `mque_code` = '".$row["rlic_codema"]."'";
		$rs2 = mysql_query($rech2) or die(mysql_error());
		if (mysql_num_rows($rs2) <> 0)
		{
			if ($row2 = mysql_fetch_array($rs2))
				echo htmlspecialchars($row2["mque_ste"]);
			else
				echo "-";
		}
		else
			echo "-";
		mysql_free_result($rs2);
		echo "</td>\n";

		echo "<td>\n";
		echo htmlspecialchars($row["rlic_modele"]);
		if ($row["rlic_version"] <> "")
		{
			echo "<br>";
			echo "Version : ".htmlspecialchars($row["rlic_version"]);
		}
		echo "</td>\n";

		echo "<td align=\"center\">\n";
		echo formatedate($row["rlic_dateval"]);
		if  (formatedate($row["rlic_dateval"]) <> "")
		{
			if ((echeance_depassee_date($datea,$row["rlic_dateval"]) == TRUE)  AND (formatedate($row["rlic_dateout"]) == ""))
				echo " <img src=\"../img/dateout.png\" title =\"Validité dépassée\" border=\"0\" align=\"absmiddle\">";
		}
		echo "</td>\n";

		 echo "<td align=\"center\">\n";
		if($j%2 == 0)
			$classe_aff="TRalter1D";
		else
			$classe_aff="TRalter2D";
		 if (ereg($row["rlic_code"],$rpdt_coderlic))
		 {
			if (($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
				echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"".$classe_aff."\" checked>";
			else
				echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"".$classe_aff."\" checked disabled>";
		 }
		 else
		 {
			if (($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
				echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"".$classe_aff."\">";
			else
				echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"".$classe_aff."\" disabled>";
		 }
		 echo "</td>\n";
		 echo "<td align=\"center\">\n";
		 if (($td <> "view") AND ($td <> "del"))
		 {
			 $lst_maj = TRUE;
			 echo "<a href=\"rlic_maj.php?td=edit&crl=".$row["rlic_code"]."\"><img src=\"../img/edit.png\" title=\"Voir ou Modifier\" border=\"0\" align=\"absmiddle\"></a>";
		 }
		 else
		 {
			$lst_voir = TRUE;
			echo "<a href=\"rlic_maj.php?td=view&crl=".$row["rlic_code"]."\"><img src=\"../img/eye.png\" title=\"".$alt_voir."\" border=\"0\" align=\"absmiddle\"></a>";
		 }
		 if (($rlic_dateoutf == "") AND ($td <> "del"))
		 {
			 if (ereg($row["rlic_code"],$rpdt_coderlic))
			 {
				 $lst_pbmrel = TRUE;
				 echo " ";
				 echo "<a href=\"rpbm_maj.php?td=add&tr=1&cr=".$row["rpdt_code"]."&ca=".$row["rpdt_codeage"]."&cap=1\"><img src=\"../img/addpbm.png\" title=\"D&eacute;clarer un probl&egrave;me\" border=\"0\" align=\"absmiddle\"></a>";
			 }
		 }
		 else
			echo "&nbsp;";
		 echo "</td>\n";
	
		echo "</tr>\n";
	
		$j++;
	}

	echo "</table>\n";
	// Fin affichage table détails licences
	$taille_piedla ="small";
	include_once("piedla.inc.php");
}
else
{
	echo "Pas de licence active install&eacute;e sur ce mat&eacute;riel";
}
mysql_free_result($rs);
mysql_close($conn);
?>
</div>

<div id="detailm3"  style="display:none">
<!-- Détail réseau -->

<!-- Nom du poste -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_nomp" align="right">
		Nom du poste
	</td>
	<td>
	<?PHP
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{
	?>
		<input name="nomp" type="text" id="nomp" value="<?PHP echo htmlspecialchars($rpdt_nomp); ?>" size="20">
	<?PHP
	}
	else
	{
	?>
		<input name="nomp" type="text" id="nomp" value="<?PHP echo htmlspecialchars($rpdt_nomp); ?>" size="20" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
</table>

<!-- Groupe de travail -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_gt" align="right">
		Groupe de travail
	</td>
	<td>
	<?PHP
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{
	?>
		<input name="gt" type="text" id="gt" value="<?PHP echo htmlspecialchars($rpdt_gt); ?>" size="40" >
	<?PHP
	}
	else
	{
	?>
		<input name="gt" type="text" id="gt" value="<?PHP echo htmlspecialchars($rpdt_gt); ?>" size="40" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
</table>


<!-- Domaine -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_dom" align="right">
		Domaine</div>
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="dom" type="text" id="dom" value="<?PHP echo htmlspecialchars($rpdt_dom); ?>" size="40" >
		<?PHP
		}
		else
		{
		?>
			<input name="dom" type="text" id="dom" value="<?PHP echo htmlspecialchars($rpdt_dom); ?>" size="40" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Login / MDP -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_login" align="right">
		Login / MDP
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="login" type="text" id="login" value="<?PHP echo htmlspecialchars($rpdt_login); ?>" size="40" > /
			<input name="mdp" type="text" id="mdp" value="<?PHP echo htmlspecialchars($rpdt_mdp); ?>" size="40" onChange="verif_pw(this.value,true,'nivpw');">
		<?PHP
		}
		else
		{
		?>
			<input name="login" type="text" id="login" value="<?PHP echo htmlspecialchars($rpdt_login); ?>" size="40" readonly="1"> /
			<input name="mdp" type="text" id="mdp" value="<?PHP echo htmlspecialchars($rpdt_mdp); ?>" size="40" readonly="1">
		<?PHP
		}
		?>
		<span id="nivpw"></span>
	</td>
</tr>
</table>


<!-- Adresse MAC -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mac" align="right">
		Adresse MAC
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="mac" type="text" id="mac" value="<?PHP echo $rpdt_mac ?>" size="19"> /
			<span class="annot_petit_it">(Format xx:xx:xx:xx:xx:xx ou xx-xx-xx-xx-xx-xx)</span>
		<?PHP
		}
		else
		{
		?>
			<input name="mac" type="text" id="mac" value="<?PHP echo $rpdt_mac ?>" size="19" readonly="1"> /
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Mode IP  -->
<!-- Serveur DHCP + Plage IP -->
<!-- IP / MASQ / PASSERELLE -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_modeip" align="right">
		Mode IP
	</td>
	<td>
	<select id="modeip" name="modeip" onChange="tst_modeip(this.value);">
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		foreach ($maj_modeip as $key=>$value)
		{
			echo "<option value=\"".$key."\"";
			if ($key==$rpdt_modeip)
				echo " selected";
			echo ">".$value."</option>";
		}
	}
	?>		
	</td>
	</select>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_sdhcp" align="right">
		Serveur DHCP ?
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"sdhcp\" size=\"1\" id=\"sdhcp\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_sdhcp)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
	}
	else
	{ 
	?>
	<input name="sdhcp" type="text" id="sdhcp" value="<?PHP echo $non_oui[$rpdt_sdhcp]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_pdhcp" align="right">
		Plage DHCP (IP1/IP2/MASQ.)
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="ip1" type="text" id="ip1" value="<?PHP echo $rpdt_ip1 ?>" size="17"> /
			<input name="ip2" type="text" id="ip2" value="<?PHP echo $rpdt_ip2 ?>" size="17"> /
			<input name="mdhcp" type="text" id="mdhcp" value="<?PHP echo $rpdt_mdhcp ?>" size="17"> /
			<span class="annot_petit_it">(Formats xxx.xxx.xxx.xxx)</span>
		<?PHP
		}
		else
		{
		?>
			<input name="ip1" type="text" id="ip1" value="<?PHP echo $rpdt_ip1 ?>" size="17" readonly="1"> /
			<input name="ip2" type="text" id="ip2" value="<?PHP echo $rpdt_ip2 ?>" size="17" readonly="1"> /
			<input name="mdhcp" type="text" id="mdhcp" value="<?PHP echo $rpdt_mdhcp ?>" size="17" readonly="1"> /
		<?PHP
		}
		?>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_ip" align="right">
		IP / Masque / Pass.
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="ip" type="text" id="ip" value="<?PHP echo $rpdt_ip ?>" size="17"> /
			<input name="masq" type="text" id="masq" value="<?PHP echo $rpdt_masq ?>" size="17"> /
			<input name="pass" type="text" id="pass" value="<?PHP echo $rpdt_pass ?>" size="17"> 
			<span class="annot_petit_it">(Formats xxx.xxx.xxx.xxx)</span>
		<?PHP
		}
		else
		{
		?>
			<input name="ip" type="text" id="ip" value="<?PHP echo $rpdt_ip ?>" size="17" readonly="1"> /
			<input name="masq" type="text" id="masq" value="<?PHP echo $rpdt_masq ?>" size="17" readonly="1"> /
			<input name="pass" type="text" id="pass" value="<?PHP echo $rpdt_pass ?>" size="17" readonly="1"> 
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Numéro de ports -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_np" align="right">
		Num&eacute;ro de prise
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			Murale : <input name="npm" type="text" id="npm" value="<?PHP echo htmlspecialchars($rpdt_npm); ?>" size="14">
			Baie : <input name="npb" type="text" id="npb" value="<?PHP echo htmlspecialchars($rpdt_npb); ?>" size="14">
			Commutateur : <input name="npc" type="text" id="npc" value="<?PHP echo htmlspecialchars($rpdt_npc); ?>" size="14">
		<?PHP
		}
		else
		{
		?>
			Murale : <input name="npm" type="text" id="npm" value="<?PHP echo htmlspecialchars($rpdt_npm); ?>" size="14" readonly="1">
			Baie : <input name="npb" type="text" id="npb" value="<?PHP echo htmlspecialchars($rpdt_npb); ?>" size="14" readonly="1">
			Commutateur : <input name="npc" type="text" id="npc" value="<?PHP echo htmlspecialchars($rpdt_npc); ?>" size="14" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- SNMP ? -->
<!-- WOL ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_snmp" align="right">
		SNMP ?
	</td>
    <td width="100">
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"snmp\" size=\"1\" id=\"snmp\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_snmp)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
	}
	else
	{ 
	?>
	<input name="snmp" type="text" id="snmp" value="<?PHP echo $non_oui[$rpdt_snmp]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
	<td width="160" class="rubfrm" id="f_wol" align="right">
		Wake-On-Lan ?
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"wol\" size=\"1\" id=\"wol\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_wol)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
	}
	else
	{ 
	?>
	<input name="wol" type="text" id="wol" value="<?PHP echo $non_oui[$rpdt_wol]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>

<!-- SID / WEP -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_sid" rowspan="2" align="right">
		WiFi
	</td>
	<td width="40"align="right">
		SID :
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="sid" type="text" id="sid" value="<?PHP echo htmlspecialchars($rpdt_sid); ?>" size="80">
		<?PHP
		}
		else
		{
		?>
			<input name="sid" type="text" id="sid" value="<?PHP echo htmlspecialchars($rpdt_sid); ?>" size="80" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
<tr>
	<td width="40" align="right">
		WEP :
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="wep" type="text" id="wep" value="<?PHP echo htmlspecialchars($rpdt_wep); ?>" size="80">
		<?PHP
		}
		else
		{
		?>
			<input name="wep" type="text" id="wep" value="<?PHP echo htmlspecialchars($rpdt_wep); ?>" size="80" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>
</div>


<div id="detailm4"  style="display:none">
<!-- Détail télémaintenance -->

<!-- Type d'accès -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_ta" align="right">
		Type d'acc&egrave;s
	</td>
	<td>
	<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{ 
		// Création de la liste des types d'accès
		
		$rech = "SELECT * FROM ".TBRLPTMTA." ORDER BY rlptmta_desc";
		$rs = mysql_query($rech) or die(mysql_error());

		?>
		
		<select name="codeta" id="codeta">

		<?PHP
			if ($rpdt_codeta <> "")
				echo "<option value=\"\">-- Choisissez un type d'accès --</option>";
			else
				echo "<option value=\"\" selected>-- Choisissez un type d'accès --</option>";

			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);

				if ($rpdt_codeta == $rlptmta_code)
				{
					echo '<option value="'.$rlptmta_code.'" selected>'.$rlptmta_desc.'</option>';
				}
				else
				{
					echo '<option value="'.$rlptmta_code.'">'.$rlptmta_desc.'</option>';
				}
			}
		?>
		</select>
	<?PHP
	}
	else
	{
		$rech = "SELECT * FROM ".TBRLPTMTA." WHERE `rlptmta_code` = '".$rpdt_codeta."'";
		$rs = mysql_query($rech) or die(mysql_error());
		if ($row = mysql_fetch_array($rs))
		{
			extract ($row);
		}
	?>
		<input name="codeta" type="hidden" id="codeta" value="<?PHP echo $rpdt_codeta; ?>">
		<input name="nomta" type="text" id="nomta" value="<?PHP echo htmlspecialchars($rlptmta_desc); ?>" size="40" readonly="1">
	<?PHP
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</td>
</tr>
</table>

<!-- Mode d'accès -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_tma" align="right">
		Mode d'acc&egrave;s
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td == "edit"))
	{ 
		echo "<select id=\"tma\" name=\"tma\">";
		foreach ($maj_typesma as $key=>$value)
		{
			echo "<option value=\"".$key."\"";
			if ($key==$rpdt_tma)
				echo" selected=\"selected\"";
			echo ">".$value."</option>";
		}
		echo "</select>";
		echo "<span class=\"annot_petit_it\">(Depuis o&ugrave; peut-on effectuer une t&eacute;l&eacute;maintenance sur ce mat&eacute;riel)</span>";
	}
	else
	{
	?>
		<input name="tta" type="text" id="tta" value="<?PHP echo $maj_typesma[$rpdt_tma]; ?>" size="20" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>

<!-- Logiciel de télémaintenance -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_tl" align="right">
		Logiciel t&eacute;l&eacute;m.
	</td>
	<td>
	<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{ 
		// Création de la liste des logiciels télémaintenance
		$rech = "SELECT * FROM ".TBRLPTML." ORDER BY rlptml_desc";
		$rs = mysql_query($rech) or die(mysql_error());

		?>
		
		<select name="codel" id="codel">

		<?PHP
			if ($rpdt_codel <> "")
				echo "<option value=\"\">-- Choisissez un logiciel de télémaintenance --</option>";
			else
				echo "<option value=\"\" selected>-- Choisissez un logiciel de télémaintenance --</option>";

			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);

				if ($rpdt_codel == $rlptml_code)
				{
					echo '<option value="'.$rlptml_code.'" selected>'.$rlptml_desc.'</option>';
				}
				else
				{
					echo '<option value="'.$rlptml_code.'">'.$rlptml_desc.'</option>';
				}
			}
		?>
		</select>
	<?PHP
	}
	else
	{
		$rech = "SELECT * FROM ".TBRLPTML." WHERE `rlptml_code` = '".$rpdt_codel."'";
		$rs = mysql_query($rech) or die(mysql_error());
		if ($row = mysql_fetch_array($rs))
		{
			extract ($row);
		}
	?>
		<input name="codel" type="hidden" id="codel" value="<?PHP echo $rpdt_codel; ?>">
		<input name="noml" type="text" id="noml" value="<?PHP echo htmlspecialchars($rlptml_desc); ?>" size="40" readonly="1">
	<?PHP
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</td>
</tr>
</table>

<!-- Mode service ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_tser" align="right">
		Mode service ?
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"tser\" size=\"1\" id=\"tser\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_tser)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
		echo "<span class=\"annot_petit_it\">(Le logiciel se charge-t'il en mode normal ou en mode service ?)</span>";
	}
	else
	{ 
	?>
	<input name="tser" type="text" id="tser" value="<?PHP echo $non_oui[$rpdt_tser]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>

<!-- Lien accès -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_tlien" align="right">
		Lien d'acc&egrave;s
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="tlien" type="text" id="tlien" value="<?PHP echo htmlspecialchars($rpdt_tlien); ?>" size="40" >
		<?PHP
		}
		else
		{
		?>
			<input name="tlien" type="text" id="tlien" value="<?PHP echo htmlspecialchars($rpdt_tlien); ?>" size="40" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Login / MDP -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_tlogin" align="right">
		Login / MDP
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="tlogin" type="text" id="tlogin" value="<?PHP echo htmlspecialchars($rpdt_tlogin); ?>" size="40" > /
			<input name="tmdp" type="text" id="tmdp" value="<?PHP echo htmlspecialchars($rpdt_tmdp); ?>" size="40" onChange="verif_pw(this.value,true,'nivpwt');">
		<?PHP
		}
		else
		{
		?>
			<input name="tlogin" type="text" id="tlogin" value="<?PHP echo htmlspecialchars($rpdt_tlogin); ?>" size="40" readonly="1"> /
			<input name="tmdp" type="text" id="tmdp" value="<?PHP echo htmlspecialchars($rpdt_tmdp); ?>" size="40" readonly="1">
		<?PHP
		}
		?>
		<span id="nivpwt"></span>
	</td>
</tr>
</table>

<!-- Arrêt d'exploitation ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_tae" align="right">
		Arr&ecirc;t exploitation ?
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"tae\" size=\"1\" id=\"tae\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_tae)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
		echo "<span class=\"annot_petit_it\">(Doit-on arr&ecirc;ter l'exploitation de ce mat&eacute;riel en cas de t&eacute;l&eacute;maintenance ?)</span>";
	}
	else
	{ 
	?>
	<input name="tae" type="text" id="tae" value="<?PHP echo $non_oui[$rpdt_tae]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>

<!-- Redémarrage ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_tred" align="right">
		Red&eacute;marrage ?
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"tred\" size=\"1\" id=\"tred\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_tred)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
		echo "<span class=\"annot_petit_it\">(Doit-on red&eacute;marrer ce mat&eacute;riel en cas de t&eacute;l&eacute;maintenance ?)</span>";
	}
	else
	{ 
	?>
	<input name="tred" type="text" id="tred" value="<?PHP echo $non_oui[$rpdt_tred]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>
</div>

<div id="detailm5"  style="display:none">
<!-- Détail Mises à jour -->

<!-- Mode  -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mode" align="right">
		Mode
	</td>
	<td>
	<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{ 
		// Création de la liste des modes de mises à jour
		
		$rech = "SELECT * FROM ".TBRLPMM." ORDER BY rlpmm_desc";
		$rs = mysql_query($rech) or die(mysql_error());

		?>
		
		<select name="codem" id="codem">

		<?PHP
			if ($rpdt_codem <> "")
				echo "<option value=\"\">-- Choisissez un mode de mise à jour --</option>";
			else
				echo "<option value=\"\" selected>-- Choisissez un mode de mise à jour --</option>";

			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);

				if ($rpdt_codem == $rlpmm_code)
				{
					echo '<option value="'.$rlpmm_code.'" selected>'.$rlpmm_desc.'</option>';
				}
				else
				{
					echo '<option value="'.$rlpmm_code.'">'.$rlpmm_desc.'</option>';
				}
			}
		?>
		</select>
	<?PHP
	}
	else
	{
		$rech = "SELECT * FROM ".TBRLPMM." WHERE `rlpmm_code` = '".$rpdt_codem."'";
		$rs = mysql_query($rech) or die(mysql_error());
		if ($row = mysql_fetch_array($rs))
		{
			extract ($row);
		}
	?>
		<input name="codem" type="hidden" id="codem" value="<?PHP echo $rpdt_codem; ?>">
		<input name="nommm" type="text" id="nommm" value="<?PHP echo htmlspecialchars($rlpmm_desc); ?>" size="40" readonly="1">
	<?PHP
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</td>
</tr>
</table>

<!-- Fréquence et type  -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_per" align="right">
		Fr&eacute;quence / Type
	</td>
	<td>
	<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{ 
		// Création de la liste des fréquence
		$rech = "SELECT * FROM ".TBPER." ORDER BY per_nbj";
		$rs = mysql_query($rech) or die(mysql_error());

		if (mysql_num_rows($rs) <> 0)
		{
	?>
		<select name="mper" id="mper">
	<?PHP
			if ($rpdt_mper <> "")
				echo "<option value=\"\">-- Choisissez une fréquence de mise à jour--</option>";
			else
				echo "<option value=\"\" selected>-- Choisissez une fréquence de mise à jour--</option>";

			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);

				if ($per_nbj <> 0)
					$txt_nbj = " (tous les ".$per_nbj." jours)";
				else
					$txt_nbj = " (à la demande)";

				if ($rpdt_mper == $per_code)
					echo '<option value="'.$per_code.'" selected>'.$per_desc.$txt_nbj.'</option>';
				else
					echo '<option value="'.$per_code.'">'.$per_desc.$txt_nbj.'</option>';
			}
		?>
		</select>
	<?PHP
		}
		else
		{
	?>
			<select name="mper" id="mper">
			<option>-- Pas de fr&eacute;quence à choisir --</option>
			</select>
	<?PHP
		}
	}
	else
	{
		$rech = "SELECT * FROM ".TBPER." WHERE `per_code` = '".$rpdt_mper."'";
		$rs = mysql_query($rech) or die(mysql_error());
		if ($row = mysql_fetch_array($rs))
		{
			extract ($row);
		}
	?>
		<input name="mper" type="hidden" id="mper" value="<?PHP echo $rpdt_mper ?>">
		<input name="tper" type="text" id="tper" value="<?PHP echo htmlspecialchars($per_desc); ?>" size="20" maxlength="20" readonly="1">
	<?PHP
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	 / 
	<select id="mtype" name="mtype">
	<?PHP
	foreach ($maj_types as $key=>$value)
	{
		echo "<option value=\"".$key."\"";
		if ($key==$rpdt_mmode)
			echo" selected=\"selected\"";
		echo ">".$value."</option>";
	}
	?>
	</select>
	</td>
</tr>
</table>

<!-- Login / MDP -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mlogin" align="right">
		Login / MDP
	</td>
	<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="mlogin" type="text" id="mlogin" value="<?PHP echo htmlspecialchars($rpdt_mlogin); ?>" size="40" > /
			<input name="mmdp" type="text" id="mmdp" value="<?PHP echo htmlspecialchars($rpdt_mmdp); ?>" size="40" onChange="verif_pw(this.value,true,'nivpwm');">
		<?PHP
		}
		else
		{
		?>
			<input name="mlogin" type="text" id="mlogin" value="<?PHP echo htmlspecialchars($rpdt_mlogin); ?>" size="40" readonly="1"> /
			<input name="mmdp" type="text" id="mmdp" value="<?PHP echo htmlspecialchars($rpdt_mmdp); ?>" size="40" readonly="1">
		<?PHP
		}
		?>
		<span id="nivpwm"></span>
	</td>
</tr>
</table>

<!-- Date validité -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mdval" align="right">
		Date d'&eacute;ch&eacute;ance
	</td>
	<td>
	<input name="mdvalf" type="text" id="mdvalf" value="<?PHP echo $rpdt_mdvalf ?>" size="10" maxlength="10" readonly="1" onChange="verif_dout(this.value,'wmdvalfout','0');">
	<?PHP
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{ 
	?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_mdvalf" title="<?PHP echo $alt_chxdate; ?>">
		<span class="annot_std_it">(
		<a href="javascript:;" onClick="document.rpdt_maj.mdvalf.value='';verif_dout(document.rpdt_maj.mdvalf.value,'wmdvalfout','0');"><img src="../img/raz.png" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="document.rpdt_maj.mdvalf.value='';verif_dout(document.rpdt_maj.mdvalf.value,'wmdvalfout','0');")> Annuler</a> )</span>
		<span class="annot_petit_it">(Ne rien mettre si illimit&eacute;)</span>
	<?PHP
	}
	?>
	<span id="wmdvalfout">
	<?PHP
	if ($rpdt_mdvalf <> "")
	{
		if (echeance_depassee_date($datea,$rpdt_mdval) == TRUE)
		{
			echo "<span class=\"alerte1\">";
			echo "Ech&eacute;ance d&eacute;pass&eacute;e";
			echo "</span>";
		}
	}
	?>
	</span>
	</td>
</tr>
</table>

<!-- Date dernière mise à jour -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mlmaj" align="right">
		Derni&egrave;re mise &agrave; jour
	</td>
	<td>
	<input name="mdlmajf" type="text" id="mdlmajf" value="<?PHP echo $rpdt_mdlmajf ?>" size="10" maxlength="10" readonly="1">
	<?PHP
	if (($rpdt_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
	{ 
	?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_mdlmajf" title="<?PHP echo $alt_chxdate; ?>">
		<span class="annot_std_it">(
		<a href="javascript:;" onClick="document.rpdt_maj.mdlmajf.value='';verif_dout(document.rpdt_maj.mdlmajf.value,'wmdvalfout','1');"><img src="../img/raz.png" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="document.rpdt_maj.mdlmajf.value=''verif_dout(document.rpdt_maj.mdlmajf.value,'wmdvalfout','1');")> Annuler</a> )</span>
	<?PHP
	}
	?>
	</td>
</tr>
</table>

<!-- Arrêt d'exploitation ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mae" align="right">
		Arr&ecirc;t exploitation ?
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"mae\" size=\"1\" id=\"mae\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_mae)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
		echo "<span class=\"annot_petit_it\">(Doit-on arr&ecirc;ter l'exploitation de ce mat&eacute;riel en cas de mise &agrave; jour ?)</span>";
	}
	else
	{ 
	?>
	<input name="mae" type="text" id="mae" value="<?PHP echo $non_oui[$rpdt_mae]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>

<!-- Redémarrage ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mred" align="right">
		Red&eacute;marrage ?
	</td>
    <td>
	<?PHP 
	if (($td == "add") OR ($td=="edit"))
	{ 
		echo "<select name=\"mred\" size=\"1\" id=\"mred\">";
		foreach ($non_oui as $key=>$value)
		{
			echo "<option value=\"".$value."\"";
			if ($key==$rpdt_mred)
				echo " selected";
			echo ">".$value."</option>";
		}
		echo "</select>";
		echo "<span class=\"annot_petit_it\">(Doit-on red&eacute;marrer ce mat&eacute;riel en cas de mise &agrave; jour ?)</span>";
	}
	else
	{ 
	?>
	<input name="mred" type="text" id="mred" value="<?PHP echo $non_oui[$rpdt_mred]; ?>" size="3" readonly="1">
	<?PHP
	}
	?>		
	</td>
</tr>
</table>
</div>

<div id="detailm6"  style="display:none">
<!-- Liste des connexions de ce matériel -->
<table width="100%"  border="0">
<tr>
	<td>
<?PHP
	// Création de la liste des connexions
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBRPDT.", ".TBMQUE.", ".TBRPCAT." WHERE ";
	$rech.= TBRPDT.".rpdt_codema = ".TBMQUE.".mque_code AND ".TBRPDT.".rpdt_codecat = ".TBRPCAT.".rpcat_code";
	$rech.= " AND ".TBRPDT.".rpdt_codecli='".$rpdt_codecli."' AND ".TBRPDT.".rpdt_dateout='0000-00-00' AND ".TBRPDT.".rpdt_code<>'".$rpdt_code."'";
	$rech.= " ORDER BY ".TBRPDT.".rpdt_code";
	$rs = mysql_query($rech) or die(mysql_error());

	if (mysql_num_rows($rs) <> 0)
	{
	?>
		<a href="#" class="pop">L&eacute;gende<span>
		"Connect&eacute; sur" : Vous consid&eacute;rez que <?PHP echo $rpdt_code; ?> est un accessoire ou un p&eacute;riph&eacute;rique du mat&eacute;riel.<br>
		"Contr&ocirc;leur de" : Vous consid&eacute;rez le matériel est un accessoire ou un p&eacute;riph&eacute;rique de <?PHP echo $rpdt_code; ?>.<br>
		"Install&eacute; dans" : Vous consid&eacute;rez que <?PHP echo $rpdt_code; ?> est install&eacute; dans le mat&eacute;riel.<br>
		"Conteneur de" : Vous consid&eacute;rez le matériel est install&eacute; dans <?PHP echo $rpdt_code; ?>.<br>
		"Reli&eacute; &agrave;" : Vous consid&eacute;rez que <?PHP echo $rpdt_code; ?> est reli&eacute; au mat&eacute;riel (exemple du r&eacute;seau).<br>
		</span></a>
	<?PHP
		echo "<table class=\"MtableD\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
		 
		// Création de l'entête de la table "détails connexions"
		echo "<th>";
		echo $rpdt_code." est";
		echo "</th>\n";
		echo "<th>";
		echo "Code Fiche / Inventaire";
		echo "</th>\n";
		echo "<th>";
		echo "Catégorie";
		echo "</th>\n";
		echo "<th>";
		echo "Marque / Modèle / NS / Emplacement ";
		echo "</th>\n";

		$j = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
			// Création de l'entête de ligne (TR)
			creetrlstdet($j);
			
			$rexist2 = "SELECT * FROM ".TBCNX."  WHERE (cnx_p1 = '".$rpdt_code."' AND cnx_p2 = '".$row["rpdt_code"]."'";
			$rexist2.= " AND (cnx_type = '1' OR cnx_type = '2' OR cnx_type = '3' OR cnx_type = '4'))";
			$rexist2.= " OR ((cnx_p1 = '".$rpdt_code."' AND cnx_p2 = '".$row["rpdt_code"]."')";
			$rexist2.= " OR  (cnx_p1 = '".$row["rpdt_code"]."' AND cnx_p2 = '".$rpdt_code."')";
			$rexist2.= " AND cnx_type = '5')";
			$rs2 = mysql_query($rexist2) or die(mysql_error());
			if (mysql_num_rows($rs2) > 0)
			{
				if ($row2 = mysql_fetch_array($rs2))
					extract($row2);
			}
			else
				$cnx_type=0;

			echo "<td align=\"center\">\n";
			echo "<select id=\"".$row["rpdt_code"]."\" name=\"".$row["rpdt_code"]."\">";
			foreach ($cnxm_types as $key=>$value)
			{
				echo "<option value=\"".$key."\"";
				if ($key==$cnx_type)
					echo" selected=\"selected\"";
				echo ">".$value."</option>";
			}
			echo "</select>";
			echo "</td>\n";

			echo "<td>\n";
			echo $row["rpdt_code"]."<br>";
			echo "(".$row["rpdt_codep"].") ";
			echo "</td>\n";

			echo "<td>\n";
			echo htmlspecialchars($row["rpcat_desc"],ENT_NOQUOTES);
			echo "</td>\n";

			echo "<td>\n";
			echo htmlspecialchars($row["mque_ste"],ENT_NOQUOTES);
			if ($row["rpdt_modele"] <> "")
			{
				echo "<br>";
				echo htmlspecialchars($row["rpdt_modele"],ENT_NOQUOTES);
			}
			if ($row["rpdt_empl"] <> "")
			{
				echo "<br>";
				echo "Empl. : ".htmlspecialchars($row["rpdt_empl"],ENT_NOQUOTES);
			}
			if ($row["rpdt_ns"] <> "")
			{
				echo "<br>";
				echo "NS : ".htmlspecialchars($row["rpdt_ns"],ENT_NOQUOTES);
			}
			echo "</td>\n";

			echo "</tr>\n";
		
			$j++;
		}

		echo "</table>\n";
		// Fin affichage table détails licences

		$taille_piedla ="small";
		include_once("piedla.inc.php");
	}
	else
		echo "Aucun mat&eacute;riel autre que celui-ci.<br>";
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</td>
</tr>
</table>
</div>
</form>

<div id="detailm7"  style="display:none">
<!-- Liste des contrats gérant ce matériel -->
<table width="100%"  border="0">
<tr>
	<td>
<?PHP
	// Création de la liste des contrats actifs
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBCOCL." WHERE `cocl_coderlp` LIKE '%".$rpdt_code."%'";
	$rech.=" ORDER BY `cocl_code`";
	$rs = mysql_query($rech) or die(mysql_error());

	if (mysql_num_rows($rs) <> 0)
	{
		echo "<table class=\"MtableD\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
		 
		// Création de l'entête de la table "détails contrats"
		echo "<th>";
		echo "Code";
		echo "</th>\n";
		echo "<th>";
		echo "Cr&eacute;&eacute; le";
		echo "</th>\n";
		echo "<th>";
		echo "D&eacute;but";
		echo "</th>\n";
		echo "<th>";
		echo "Fin";
		echo "</th>\n";
		echo "<th>";
		echo $txt_ent_lst_clic;
		echo "</th>\n";

		$j = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
			// Création de l'entête de ligne (TR)
			creetrlstdet($j);
			
			 $echeance_ok = TRUE;
			 if (formatedate($row["cocl_datef"]) <> "")
			 {
				if (echeance_depassee_date($datea,$row["cocl_datef"]) == TRUE)
					$echeance_ok = FALSE;
			 }
	
			 echo "<td>".$row["cocl_code"];
	
			 // CREATION d'icône si signé
			  if (formatedate($row["cocl_datesig"]) <> "")
			  {
				$lst_sig = TRUE;
				 echo " <img src=\"../img/ok.png\" title =\"Signé le ".formatedate($row["cocl_datesig"])."\" border=\"0\" align=\"absmiddle\">";
			  }
	
			 // CREATION d'icône si terminé
			  if ((formatedate($row["cocl_datefin"]) <> "") OR ($echeance_ok == FALSE))
			  {
				$lst_fini = TRUE;
				if (formatedate($row["cocl_datefin"]) <> "")
					echo " <img src=\"../img/warn.png\" title =\"Terminé le ".formatedate($row["cocl_datefin"])."\" border=\"0\" align=\"absmiddle\">";
				else
					echo " <img src=\"../img/warn.png\" title =\"Terminé le ".formatedate($row["cocl_datef"])."\" border=\"0\" align=\"absmiddle\">";
			  }
	
			 // Détail contrat
			 echo "<br>";
			 echo "<span class=\"annot_petit_it\">";
			 $rech2 = "SELECT * FROM " .TBCO. " WHERE co_code = '".$row["cocl_codeco"]."'";
			 $rs2 = mysql_query($rech2) or die(mysql_error());
			 if ($row2 = mysql_fetch_array($rs2))
			 {
				$txt = formatetxt($row2["co_nom"]);
				echo "->".htmlspecialchars($txt,ENT_NOQUOTES);
			 }
	
			 echo "</span>";
			 echo "</td>\n";

			 echo "<td>";
			 echo "<div align=\"center\">";
			 echo formatedate($row["cocl_datecrea"]);
			 echo "</div>";
			 echo "</td>\n";
			 echo "<td>";
			 echo "<div align=\"center\">";
			 echo formatedate($row["cocl_dated"]);
			 echo "</div>";
			 echo "</td>\n";
			 echo "<td>";
			 echo "<div align=\"center\">";
			 if (formatedate($row["cocl_datef"]) == "")
				echo "&nbsp;";
			 else
				echo formatedate($row["cocl_datef"]);
			 echo "</div>";
			 echo "</td>\n";

			// CREATION lien dynamique sur icône (édition, impression, etc...)
			 echo "<td>";
			 echo "<div align=\"center\">";
	
	
			 if (@$_SESSION["niv_log"] >= 4) // Edition uniquement si >=agence
			 {
				if ((formatedate($row["cocl_datefin"]) == "") AND ($echeance_ok == TRUE))
				{
					$lst_maj = TRUE;
					
					echo "<a href=\"cocl_maj.php?td=edit&co=".$row["cocl_code"]."&cc=".$row["cocl_codecli"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\"></a>";
				}
				else
				{
					$lst_voir = TRUE;
					
					echo "<a href=\"cocl_maj.php?td=view&co=".$row["cocl_code"]."&cc=".$row["cocl_codecli"]."\"><img src=\"../img/eye.png\" border=\"0\" align=\"absmiddle\"></a>";
				}
			 }	
	
			 if (@$_SESSION["niv_log"] <= 3) // Voir si <=Technicien
			 {
				$lst_voir = TRUE;
				
				echo "<a href=\"cocl_maj.php?td=view&co=".$row["cocl_code"]."&cc=".$row["cocl_codecli"]."\"><img src=\"../img/eye.png\" border=\"0\" align=\"absmiddle\"></a>";
			 }	
	
			 if (@$_SESSION["niv_log"] >= 3) // Création intervention uniquement si  >=technicien et pas fini
			 {
				 if ((formatedate($row["cocl_datefin"]) == "") AND (formatedate($row["cocl_datesig"]) <> "") AND ($echeance_ok == TRUE))
				 {
					$lst_int = TRUE;
					
					echo " ";
					$url_int = "int_maj.php?td=add&ci=&cc=".$row["cocl_codecli"]."&ca=".$row["cocl_codeage"]."&co=".$row["cocl_code"];
					echo "<a href=\"".$url_int."\"><img src=\"../img/int.png\" title=\" ".$alt_saisintcocl.$row["cocl_code"]."\"  border=\"0\" align=\"absmiddle\"></a>";
				 }
			 }
			
			 $lst_imp = TRUE;
			
			 $urlimp = "cocl_pdf.php?code=".$row["cocl_code"];
			 echo " ";
			 echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/print.png\" title=\"".$alt_impcocl."\" border=\"0\" align=\"absmiddle\"></a>";
		
			 echo "</div>";
			 echo "</td>\n";

			echo "</tr>\n";
		
			$j++;
		}

		echo "</table>\n";
		// Fin affichage table détails licences

		$taille_piedla ="small";
		include_once("piedla.inc.php");
	}
	else
		echo "Aucun contrat couvrant ce mat&eacute;riel.<br>";
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</td>
</tr>
</table>
</div>

<div id="detailm8"  style="display:none">
<!-- Liste des problèmes déclarés -->
<?PHP
if (exist_rpbm($rpdt_code) == TRUE)
{
?>
<form name="pbm_lst" id="pbm_lst" method="post" action="rpdt_maj.php?td=<?PHP echo $td; ?>&crp=<?PHP echo $crp; ?>">
<table width="100%"  border="0">
<tr>
	<td width="180" class="rubfrm" id="f_site" align="right">Filtre par lieu </td>
	<?PHP 
	if ($cli_ste<>"")
	{
	?>
	<td>
		<select name="site" id="site" onChange="document.getElementById('pbm_lst').submit();">
		<option value="-1" <?PHP if ($idscli == -1) echo "selected"?>>Tous les sites</option>
		<option value="0" <?PHP if ($idscli == 0) echo "selected"?>>Site principal</option>
		<?PHP
			// Création de la liste des sites actifs
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM ".TBSCLI." WHERE `scli_actif` = '1' AND `scli_codecli`='".$cli_code."' ORDER BY scli_ste";
			$rs = mysql_query($rech) or die(mysql_error());
		
			if (mysql_num_rows($rs) <> 0)
			{
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
		
					if ($scli_adr2<>"")
						$nom_site = $scli_ste." (".$scli_adr1.", ".$scli_adr2.", ".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE).")";
					else
						$nom_site = $scli_ste." (".$scli_adr1.", ".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE).")";
					if ($idscli == $scli_id)
						echo '<option value="'.$scli_id.'" selected>'.$nom_site.'</option>';
					else
						echo '<option value="'.$scli_id.'">'.$nom_site.'</option>';
				}
			}
			mysql_free_result($rs);
		?>
		</select>
	</td>
	<?PHP
	}
	else
	{
	?>
	<td>
	<input name="site" type="hidden" id="site" value="0">
	<input name="nsite" type="text" id="nsite" value="Site principal" readonly="1">
	</td>
	<?PHP
	}
	?>
</tr>
<tr>
	<td width="180" class="rubfrm" id="f_pbm" align="right">Filtre par probl&egrave;mes </td>
	<td>
	<input type="radio" name="pbms" style="background : #FFFFFF;" value="0" <?PHP if ($pbm==0) echo "checked"?>  onClick="document.getElementById('pbm_lst').submit();">
	<?PHP if ($pbm==0) echo "<span class=\"annot_petit_gras\">"; else echo "<span class=\"annot_petit\">"; ?>
	 Toutes les fiches
	<?PHP echo "</span>"; ?>
	<input type="radio" name="pbms" style="background : #FFFFFF;" value="1" <?PHP if ($pbm==1) echo "checked"?>  onClick="document.getElementById('pbm_lst').submit();">
	<?PHP if ($pbm==1) echo "<span class=\"annot_petit_gras\">"; else echo "<span class=\"annot_petit\">"; ?>
	 Avec pbm(s) non trait&eacute;(s) 
	<?PHP echo "</span>"; ?>
	<input type="radio" name="pbms" style="background : #FFFFFF;" value="2" <?PHP if ($pbm==2) echo "checked"?>  onClick="document.getElementById('pbm_lst').submit();">
	<?PHP if ($pbm==2) echo "<span class=\"annot_petit_gras\">"; else echo "<span class=\"annot_petit\">"; ?>
	 Avec pbms(s) trait&eacute;(s) ou en cours de traitement
	<?PHP echo "</span>"; ?>
	<br>
	<span class="annot_upetit_it">
	(&quot;Avec pbm(s) non trait&eacute;(s)&quot; = contient des probl&egrave;mes non affect&eacute;s &agrave; des interventions / &quot;Avec pbm(s) trait&eacute;(s) ou en cours de traitement&quot; = contient des probl&egrave;me r&eacute;solus ou affect&eacute;s)
	</span>
	</td>
</tr>
<tr>
	<td width="180" class="rubfrm" id="f_search" align="right">Filtre par mot </td>
<td>
	<input type="text" name="search" value="<?php if(!empty($_POST['search']))echo $_POST['search']; ?>" onChange="document.getElementById('pbm_lst').submit();"> 
	<a href="javascript:;" onclick="document.pbm_lst.search.value='';document.getElementById('pbm_lst').submit();"><img src="../img/raz.png" border="0" align="absmiddle"></a>
</td>
</tr>
</table>
</form>

<table width="100%"  border="0">
<tr>
	<td>
		<span class="annot_gras_it">Liste des probl&egrave;mes d&eacute;clar&eacute;s sur ce mat&eacute;riel</span> (<img src="../img/rpbmint.png" border="0" align="absmiddle" > = en cours d&rsquo;intervention)</span>
	</td>
	<td align="right">
		<?PHP
		if (($td <> "del") AND ($rpdt_dateoutf == ""))
		{
			$url_add = "rpbm_maj.php?td=add&tr=2&cr=".$rpdt_code."&cap=1";
		?>
			<a href="<?PHP echo $url_add; ?>"><img src="../img/add.png" title ="D&eacute;clarer un probl&egrave;me" border="0" align="absmiddle"></a>
			<a href="<?PHP echo $url_add; ?>"> D&eacute;clarer un probl&egrave;me</a>
		<?PHP } else { ?>
			&nbsp;
		<?PHP } ?>
	</td>
</tr>
</table>

<table width="100%"  border="0">
<tr>
	<td>
		<?PHP
		// Création de la liste des problèmes déclarés
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);

		switch($pbm)
		{
			case 0 :
				$rech = "SELECT * FROM ".TBRPBM." WHERE `rpbm_coderlp` = '".$rpdt_code."'";
				break;
			case 1 :
				$rech = "SELECT * FROM ".TBRPBM." WHERE `rpbm_coderlp` = '".$rpdt_code."'";
				$rech.=" AND (".TBRPBM.".rpbm_codeint IS NULL)";
				break;
			case 2 :
				$rech = "SELECT * FROM ".TBRPBM." WHERE `rpbm_coderlp` = '".$rpdt_code."'";
				$rech.=" AND (".TBRPBM.".rpbm_codeint IS NOT NULL)";
				break;
		}
	
		if ($idscli!=-1)
			$rech.=" AND (".TBRPBM.".rpbm_idsite = '".$idscli."' OR ".TBRPBM.".rpbm_idsite = '-1')";

		if(isset($_POST['search']) && !empty($_POST['search']))  
		{
			$rech .= " AND (";
			 if (datefrcorrecte(trim($_POST['search'])) == TRUE)
			 {
				 $daterech = datefrang(trim($_POST['search']));
				 $rech .= " rpbm_datecrea LIKE '%".addslashes($daterech)."%' OR";
				 $rech .= " rpbm_datett LIKE '%".addslashes($daterech)."%' OR";
			 }
			$rech .= " rpbm_signale LIKE '%".str_escape(trim($_POST['search']))."%' OR";
			$rech .= " rpbm_pbm LIKE '%".str_escape(trim($_POST['search']))."%' OR";
			$rech .= " rpbm_codeint LIKE '%".str_escape(trim($_POST['search']))."%' OR";
			$rech = substr($rech,0,strlen($rech)-3);
			$rech.=")";
		}
		$rech.=" ORDER BY `rpbm_datecrea`";
		$rs = mysql_query($rech) or die(mysql_error());

		if (mysql_num_rows($rs) <> 0)
		{
			echo "<table class=\"MtableD\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
			 
			// Création de l'entête de la table "détails problèmes"
			echo "<th>";
			echo "Déclaré le";
			echo "</th>\n";
			echo "<th>";
			echo "Déclaré par";
			echo "</th>\n";
			echo "<th>";
			echo "Problème";
			if ($idscli<0)
				echo"<div align=\"right\">(site)</div>";
			echo "</th>\n";
			echo "<th>";
			echo "Résolu le";
			echo "</th>\n";
			echo "<th>";
			echo $txt_ent_lst_clic;
			echo "</th>\n";

			$j = 0;
			
			while ($row = mysql_fetch_assoc($rs)) 
			{         
				// Création de l'entête de ligne (TR)
				creetrlstdet($j);
				
				echo "<td align=\"center\">\n";
				echo formatedate($row["rpbm_datecrea"]);
				if (($row["rpbm_codeint"] <> "") AND (formatedate($row["rpbm_datett"]) == ""))
					echo "<img src=\"../img/rpbmint.png\" border=\"0\" align=\"absmiddle\" title =\"Intervention ".$row["rpbm_codeint"]."\" border=\"0\">";
				echo "</td>\n";
				echo "<td>\n";
				echo htmlspecialchars($row["rpbm_signale"],ENT_NOQUOTES);
				echo "</td>\n";
				echo "<td>\n";
				$tab_txtpbm = cesuretxt_tab(htmlspecialchars($row["rpbm_pbm"],ENT_NOQUOTES),100);
				$txtpbm="";
				foreach ($tab_txtpbm as $index_ligne=>$ligne)
					$txtpbm .= $ligne."<br>";
				echo $txtpbm;
				if ($idscli<0)
				{
					if ($row["rpbm_idsite"]<>0)
					{
						$row2=lit_enr_scli_id($row["rpbm_idsite"],FALSE);
						if (is_array($row2))
						{
							extract($row2);
							echo "<div align=\"right\" class=\"annot_petit_it\">";
							if ($scli_adr2<>"")
								$nom_site = $scli_ste."<br>".$scli_adr1."<br>".$scli_adr2."<br>".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE);
							else
								$nom_site = $scli_ste."<br>".$scli_adr1."<br>".Retournecp_openId($scli_ville,FALSE)." ".Retourneville_openId($scli_ville,FALSE);
							echo $nom_site;
							echo "</div>";
						}
					}
					else
					{
						echo "<div align=\"right\" class=\"annot_petit_it\">";
						echo "Site principal";
						echo "</div>";
					}
				}
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				if (formatedate($row["rpbm_datett"]) <> "")
				{
					echo formatedate($row["rpbm_datett"]);
					echo "<span class=\"annot_petit_it\">";
					echo "<br>Int. ".$row["rpbm_codeint"];
					echo "</span>";
				}
				else
					echo "&nbsp;";
				echo "</td>\n";

				echo "<td align=\"center\">\n";
				if ($td <> "del")
				{
					// On peut éditer ou supprimer uniquement si aucune intervention n'est rattachée
					// et si la fiche n'est pas sortie du parc
					if (($row["rpbm_codeint"] == "") AND ($rpdt_dateoutf == ""))
					{
						$lst_maj = TRUE;
						echo "<a href=\"rpbm_maj.php?td=edit&tr=2&cr=".$row["rpbm_coderlp"]."&id=".$row["rpbm_id"]."&cap=1\"><img src=\"../img/edit.png\" title=\"Voir ou Modifier\" border=\"0\" align=\"absmiddle\"></a>";
	
						$lst_del = TRUE;
						echo " ";					
						echo "<a href=\"rpbm_maj.php?td=del&tr=2&cr=".$row["rpbm_coderlp"]."&id=".$row["rpbm_id"]."&cap=1\"><img src=\"../img/del.png\" title=\"".$alt_del."\" border=\"0\" align=\"absmiddle\"></a>";
					}
					else
					{
						$lst_voir = TRUE;
						echo "<a href=\"rpbm_maj.php?td=view&tr=2&cr=".$row["rpbm_coderlp"]."&id=".$row["rpbm_id"]."&cap=1\"><img src=\"../img/eye.png\" title=\"".$alt_voir."\" border=\"0\" align=\"absmiddle\"></a>";
					}
				}
				else
				{
					echo "-";
				}
				echo "</tr>\n";
			
				$j++;
			}

			echo "</table>\n";
			// Fin affichage table détails licences

			$taille_piedla ="small";
			include_once("piedla.inc.php");
		}
		else
			echo "Aucun probl&egrave;me avec le filtre demand&eacute;.<br>";
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>
<?PHP
}
else
{
	if ($td <> "add")
	{
?>
	<table width="100%"  border="0">
	<tr>
		<td>
			<span class="annot_gras_it">Aucun probl&egrave;me d&eacute;clar&eacute;</span>
		</td>
		<td align="right">
			<?PHP
			if (($td <> "del") AND ($rpdt_dateoutf == ""))
			{
				$url_add = "rpbm_maj.php?td=add&tr=2&cr=".$rpdt_code."&cap=1";
			?>
				<a href="<?PHP echo $url_add; ?>"><img src="../img/add.png" title ="D&eacute;clarer un probl&egrave;me" border="0" align="absmiddle"></a>
				<a href="<?PHP echo $url_add; ?>"> D&eacute;clarer un probl&egrave;me</a>
			<?PHP } else { ?>
				&nbsp;
			<?PHP } ?>
		</td>
	</tr>
	</table>
<?PHP
	}
}
?>
</div>

<?PHP
if (($idscli!=-1) OR ($pbm!=0) OR (isset($_POST['search']) && !empty($_POST['search'])))
{
?>
<script type="text/javascript">
<!--
set_mnu_rel('m8');
//-->
</script>
<?PHP
}
?>

<script type="text/javascript">
<!--
<?PHP if ($td == "add") { ?>
Calendar.setup({
	inputField     :    "daterelf",     // id of the input field
	ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
	button         :    "f_img_daterelf",  // trigger for the calendar (button ID)
	align          :    "Br",           // alignment (defaults to "Bl")
	electric	   :	false,
	singleClick    :    true
});
<?PHP } ?>
Calendar.setup({
	inputField     :    "dateachf",     // id of the input field
	ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
	button         :    "f_img_dateachf",  // trigger for the calendar (button ID)
	align          :    "Br",           // alignment (defaults to "Bl")
	electric	   :	false,
	singleClick    :    true
});
Calendar.setup({
	inputField     :    "datefgarf",     // id of the input field
	ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
	button         :    "f_img_datefgarf",  // trigger for the calendar (button ID)
	align          :    "Br",           // alignment (defaults to "Bl")
	electric	   :	false,
	singleClick    :    true
});
Calendar.setup({
	inputField     :    "mdvalf",     // id of the input field
	ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
	button         :    "f_img_mdvalf",  // trigger for the calendar (button ID)
	align          :    "Br",           // alignment (defaults to "Bl")
	electric	   :	false,
	singleClick    :    true
});
Calendar.setup({
	inputField     :    "mdlmajf",     // id of the input field
	ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
	button         :    "f_img_mdlmajf",  // trigger for the calendar (button ID)
	align          :    "Br",           // alignment (defaults to "Bl")
	electric	   :	false,
	singleClick    :    true
});
//-->
</script>
<?PHP if ($td == "add") 
{
?>
	<script type="text/javascript">
	<!--
	warnnbage(<?PHP echo nb_age_actives(); ?>,"cont");
	warnnbtec(<?PHP echo nb_tec_actifs() ?>);
	warnnbpcat(<?PHP echo nb_catpdt() ?>);
	warnnbmarque(<?PHP echo nb_marques("","rel") ?>);
	warnnbetat(<?PHP echo nb_etatpdt() ?>);
	//-->
	</script>
<?PHP
}
else
{
	if ($td == "edit")
	{
?>
	<script type="text/javascript">
	<!--
	warncpta(<?PHP echo $cli_cpta; ?>,"cont");
	//-->
	</script>
<?PHP
	}
}
?>  

<!-- Fin Affiché uniquement s'il y a un code client -->
<?PHP
}
else
{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('cli_lst.php');",2000)
	//-->
	</script>
	<p align="center" class="annot_std_it">Merci de choisir un client...</p>
<?PHP
}
}
else
{
	if (@$_SESSION["niv_log"] == 1)
	{
?>
		<script type="text/javascript">
		<!--
		setTimeout("self.location.href=('index.php');",2000)
		//-->
		</script>
		<p align="center" class="annot_std_it">Ce n'est pas votre compte...</p>
<?PHP
	}
	else
	{
?>
		<script type="text/javascript">
		<!--
		setTimeout("self.location.href=('rel_lst.php');",2000)
		//-->
		</script>
		<p align="center" class="annot_std_it"><?PHP echo $alert_prm; ?>...</p>
<?PHP
	}
}
include_once("pied.php");
?>
