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

Copyright (C) 2006  Sylvain FATOME

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

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

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

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

include ("../inc/config.inc.php");
?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_date.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php require ("../inc/fic.inc.php") ?>
<?php require ("../inc/lst.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$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 (@$HTTP_SESSION_VARS["niv_log"] == 1)
	{
		$td = "view";
		$cc = $HTTP_SESSION_VARS["code_log"];
	}

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

	if ($crp <> "")
	{
		// Récupération des informations relevé produit
		$row = lit_enr_rpdt($crp);
		if (is_array($row))
			extract ($row);

		$rpdt_daterelf = formatedate($rpdt_daterel);
		$rpdt_dateachf = formatedate($rpdt_dateach);
		$rpdt_fingarf = formatedate($rpdt_fingar);
		$rpdt_dateoutf = formatedate($rpdt_dateout);

		if ($td == "edit")
		{
			$cc=$rpdt_codecli;
			$ca=$rpdt_codeage;
			
			$titre = "MISE A JOUR FICHE RELEVE MATERIEL";
		}

		if ($td == "del")
			$titre = "SUPPRESSION FICHE RELEVE MATERIEL";

		if ($td == "view")
		{
			$titre = "VOIR FICHE RELEVE LICENCE";
		}

		if ($td == "add")
		{
			$rpdt_daterelf = $datef;
			$rpdt_code = $crp;
			$rpdt_codecli = $cc;
			$rpdt_codeage = $ca;
			
			$titre = "CREATION FICHE RELEVE MATERIEL";
		}

	}
	else
	{
		if ($td == "add")
		{
			$rpdt_daterelf = $datef;
			$rpdt_code = crecodesession("RP");
			$rpdt_coderel = $cr;
			$rpdt_code = $crp;
			$rpdt_codecli = $cc;
			$rpdt_codeage = $ca;
			$rpdt_ip = "000.000.000.000";
			$rpdt_masq = "000.000.000.000";
			$rpdt_pass = "000.000.000.000";
			
			$row = lit_enr_rel($cr);
			$num = $row["rel_num"]+1;
			$rpdt_codep = $row["rel_rnum"].sprintf ("%'04s",$num);

			$titre = "CREATION FICHE RELEVE MATERIEL";
		}

	}

	if ($cc <>"")
	{
			$row = lit_enr_cli($cc);
			extract ($row);

			$rpdt_codecli = $cc;
	}

	if	($td == "view")
	{
		$titre = "DETAIL FICHE RELEVE MATERIEL";
	}
?>

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

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

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

<!-- Scripts Javascript pour validation des formulaires -->
<script language="JavaScript" src="../inc/validator.js"></script>

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

<!-- Scripts Javascript pour vérifications -->
<script language="JavaScript" src="../inc/verif.js"></script>

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

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

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

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

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

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

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

<!-- Fonction afficher/cacher un bloc div -->
<script type="text/javascript">
	function display(idobjet,etat)
	{
		var objet = document.getElementById(idobjet);
		etat = objet.style.display;
		if (etat == 'none')
			objet.style.display = 'block';
		else
			objet.style.display = 'none';
	}
</script>

</head>

<?PHP if ($td == "del"){ ?>
<body onload=warndel();>
<?PHP } else { ?>
<body>
<?PHP } ?>

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

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<!-- Affiché uniquement s'il y a un code client -->
<?PHP
if ($cc <> "")
{
?>
<table width="100%"  border="0">
<tr>
	<td width="33%">
	<p><strong><em>
	<?PHP
	if (@$HTTP_SESSION_VARS["niv_log"] <> 1)
	{
	?>
		<a href="rel_maj.php?td=edit&cr=<?PHP echo $rpdt_coderel; ?>">Retour au dossier de relev&eacute; <br>
	<?PHP
	}
	else
	{
	?>
		<a href="rel_maj.php?td=view&cr=<?PHP echo $rpdt_coderel; ?>">Retour au dossier de relev&eacute; <br>
	<?PHP
	}
	?>
	</a></em></strong></p>
    </td>
	<td width="33%" valign="top"><div align="center"><span class="annot_gras_it">(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)</span> </div></td>
	<td width="33%">&nbsp;
	
	</td>
</tr>
</table>

<form name="rpdt_maj" method="post" action="rpdt_enr.php" onsubmit="return v.exec();">
<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
<input name="typdde" type="hidden" id="typdde" 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="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_daterelf"><div align="right">Date Cr&eacute;ation </div></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" id="f_img_daterelf" title="Choisir votre date" width="16" height="16">
		<img src="../img/oblig.gif" width="10" height="11">
		<span class="annot_std_it">(
		<a href="javascript:;" onClick="document.rpdt_maj.daterelf.value=''"><img src="../img/raz.gif" width="12" height="12" 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="tfvNormal" id="f_dateoutf" align="right"><div align="right">Sorti du parc le </div></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"))  // zone modifiable si pas sorti du parc et si pas en visualisation
			{
		?>
			<img src="../img/calendar.png" id="f_img_dateoutf" title="Choisir votre date" width="16" height="16">
			<span class="annot_std_it">(
			<a href="javascript:;" onClick="document.rpdt_maj.dateoutf.value=''"><img src="../img/raz.gif" width="12" height="12" 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="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_coderel"><div align="right">Dossier de relev&eacute; </div></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 ($rlic_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="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_coderlic"><div align="right">Code Fiche </div></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="800"  border="0">
<tr>
	<td width="400" class="tfvNormal" colspan="2"  id="f_codecli">
		<div align="center">Client</div>
	</td>
	</tr>
</table>

<!-- Détails client -->
<table width="800"  border="0">
<tr>
	<td width="370" valign="top" bgcolor="#CCFFCC">
	<?PHP
	if (($cli_ste <>"") OR ($cli_nom <> ""))
		echo "<img src=\"../img/".$ico_cpta[$cli_cpta]."\" title =\"".$mess_cpta[$cli_cpta]."\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\">";
	echo "<b>";
	if ($cli_ste <>"") 
	{
		echo $cli_ste."<br>";
		echo "<span class=\"annot_gras_it\">";
	}
	echo $cli_civilite." ".$cli_prenom." ".$cli_nom."<br>";
	if ($cli_ste <>"") 
	{
		echo "</span>";
	}
	echo "</b>";
	echo $cli_adr1."<br>";
	if ($cli_adr2 <>"") 
		echo $cli_adr2."<br>";
	echo Retournecp($cli_ville)." ".Retourneville($cli_ville)."<br>";
	echo "Tel : ".$cli_telf."<br>";
	?>
	</td>
	<td width="30" valign="top">
	<?PHP 
	if (@$HTTP_SESSION_VARS["niv_log"] >= 3)
	{
	  $url_affnotesc = "aff_notesc.php?cc=".$cc;
	?>
	  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',800,400,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/detail.gif" width="16" height="16" border="0" align="absmiddle"></a>
	  <a href="javascript:;" onclick="fensaisie('<?PHP echo $url_affnotesc; ?>',800,400,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> Notes</a><?PHP
	}
	else
		echo "&nbsp;";
	?>
	</td>
	</tr>
</table>

<table width="800"  border="0">
<tr>
	<td width="400" class="tfvNormal" colspan="2"  id="f_codecli">
		<div align="center">Relev&eacute; effectu&eacute; par</div>
	</td>
	</tr>
</table>

<!-- Code de l'agence (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_codeage"><div align="right">Agence</div></td>
	<td>
		<?PHP
		if ($td =="add")  // Ajout = zone modifiable (on peut choisir une agence)
		{ 
			if ((@$HTTP_SESSION_VARS["niv_log"] <> 4) AND (@$HTTP_SESSION_VARS["niv_log"] <> 3))
			{
			
				// Création de la liste des agences ouvertes
				
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rech = "SELECT * FROM ".TBAGE." WHERE `age_ouvert` = '1' ORDER BY age_nom";
				$rs = mysql_query($rech);
	
				if (mysql_num_rows($rs) <> 0)
				{
				?>
				
				<select name="codeage" id="codeage">
	
				<?PHP
					if ($rpdt_codeage <> "")
						echo "<option value=\"\">-- Choisissez une agence --</option>";
					else
						echo "<option value=\"\" selected>-- Choisissez une agence --</option>";
	
					while ($resultat = mysql_fetch_array($rs)) 
					{
						extract($resultat);
		
						$nom_code = $age_nom." (".$age_code.")";
						if ($rpdt_codeage == $age_code)
							echo '<option value="'.$age_code.'" selected>'.$nom_code.'</option>';
						else
							echo '<option value="'.$age_code.'">'.$nom_code.'</option>';
	
						$i++;
					}
				?>
				</select>
				<?PHP
				}
				else
				{
					echo "<span class=\"annot_gras_it\">";
					echo "Pas d'agence ouverte";
					echo "</span>";
				}
				mysql_free_result($rs);
				mysql_close($conn);
				?>
				<img src="../img/oblig.gif" width="10" height="11">
			<?PHP
			}
			else
			{
				$row = lit_enr_age($HTTP_SESSION_VARS["code_age"]);
				extract ($row);
				$nom_code = $age_nom." (".$age_code.")";
			?>
				<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $HTTP_SESSION_VARS["code_age"]; ?>">
				<input name="nagence" type="text" id="nagence" value="<?PHP echo $nom_code; ?>" size="50" maxlength="50" readonly="1">
			<?PHP
			}	
		} 
		else  // Edition ou suppression = zone non modifiable (affichage seul)
		{
			$row = lit_enr_age($rpdt_codeage);
			extract($row);
		?>
		<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nom." (".$age_code.")"; ?>" size="50" maxlength="50" readonly="1">
		<?PHP 
		} 
		?>
	</td>
</tr>
</table>

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

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

			<?PHP
				if ($rpdt_codeage <> "")
					echo "<option value=\"\">-- Choisissez un technicien --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez un technicien --</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
			{
				echo "<span class=\"annot_gras_it\">";
				echo "Pas de technicien actif";
				echo "</span>";
			}
			mysql_free_result($rs);
			mysql_close($conn);
			?>
			<img src="../img/oblig.gif" width="10" height="11">
		<?PHP 
		} 
		else  // Edition ou suppression = zone non modifiable (affichage seul)
		{
			$row = lit_enr_tec($rpdt_codetec);
			extract($row);
		?>
		<input name="nomtec" type="text" id="nomtec" value="<?PHP echo $tec_nom." ".$tec_prenom; ?>" size="50" maxlength="50" readonly="1">
		<?PHP 
		} 
		?>
	</td>
</tr>
</table>


<!-- Délai du relevé -->
<table width="800"  border="0">
<tr>
	<td width="400" class="tfvNormal" colspan="2">
		<div align="center">D&eacute;tail du relev&eacute;</div>
	</td>
	</tr>
</table>

<!-- Catégorie -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_codecat"><div align="right">Cat&eacute;gorie</div></td>
	<td>
		<?PHP
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // 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);
	
			?>
			
			<select name="codecat" id="codecat">
	
			<?PHP
				if ($rpdt_codecat <> "")
					echo "<option value=\"\">-- Choisissez une catégorie --</option>";
				else
					echo "<option value=\"\" selected>-- 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.gif" width="10" height="11">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBRPCAT." WHERE `rpcat_code` = '".$rpdt_codecat."'";
			$rs = mysql_query($rech);
			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 $rpcat_desc; ?>" size="40" maxlength="40" readonly="1">
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>


<!-- Marque/Nom du fabricant -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_codema"><div align="right">Marque</div></td>
	<td>
		<?PHP
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
			// Création de la liste des marques
			
			$rech = "SELECT * FROM ".TBRLPMA." ORDER BY rlpma_desc";
			$rs = mysql_query($rech);
	
			?>
			
			<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 == $rlpma_code)
						echo '<option value="'.$rlpma_code.'" selected>'.$rlpma_desc.'</option>';
					else
						echo '<option value="'.$rlpma_code.'">'.$rlpma_desc.'</option>';
				}
			?>
			</select>
			<img src="../img/oblig.gif" width="10" height="11">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBRLPMA." WHERE `rlpma_code` = '".$rpdt_codema."'";
			$rs = mysql_query($rech);
			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 $rlpma_desc; ?>" size="40" maxlength="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="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_modele">
		<div align="right">Mod&egrave;le / NS</div>
		<div align="right"></div>
	</td>
    <td>
	<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
	?>
			<input name="modele" type="text" id="modele" value="<?PHP echo $rpdt_modele ?>" size="40" maxlength="40"> <img src="../img/oblig.gif" width="10" height="11"> / 
			<input name="ns" type="text" id="ns" value="<?PHP echo $rpdt_ns ?>" size="40" maxlength="40"> <img src="../img/oblig.gif" width="10" height="11">
	<?PHP
		}
		else
		{
	?>
			<input name="modele" type="text" id="modele" value="<?PHP echo $rpdt_modele ?>" size="40" maxlength="40" readonly="1"> / 
			<input name="ns" type="text" id="ns" value="<?PHP echo $rpdt_ns ?>" size="40" maxlength="40" readonly="1">
	<?PHP
		}
	?>
	</td>
</tr>
</table>

<!-- Etat du produit -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_codeet"><div align="right">Etat constat&eacute;</div></td>
	<td>
		<?PHP
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // 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);
	
			?>
			
			<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.gif" width="10" height="11">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBRPET." WHERE `rpet_code` = '".$rpdt_codeet."'";
			$rs = mysql_query($rech);
			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 $rpet_desc; ?>" size="40" maxlength="40" readonly="1">
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>

<!-- Licences utilisées -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_coderlic"><div align="right">Licences utilis&eacute;es </div></td>
	<td>
		<?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);

		if (mysql_num_rows($rs) <> 0)
		{
		?>
			<div id="pas_detaill" style="display:block">
				<a href="javascript:;" onclick="display('detaill','block');display('pas_detaill','none');")><img src="../img/view+.gif" title="D&eacute;tail des licences" width="22" height="22" border="0" align="absmiddle"></a> 
				<a href="javascript:;" onclick="display('detaill','block');display('pas_detaill','none');"> D&eacute;tail des licences</a>
			</div>
			<div id="detaill" style="display:none">
				<a href="javascript:;" onclick="display('pas_detaill','block');display('detaill','none');")><img src="../img/view-.gif" title="Pas de d&eacute;tail des licences" width="22" height="22" border="0" align="absmiddle"></a> 
				<a href="javascript:;" onclick="display('pas_detaill','block');display('detaill','none');"> Pas de d&eacute;tail des licences</a>
				<br>
		        <span class="annot_gras_it">D&eacute;tail des licences utilis&eacute;es par ce mat&eacute;riel</span><span class="annot_std_it"> (Laisser la souris sur les icônes pour le détail)</span>

				<?PHP
				echo "<table class=\"MtableD\" border=\"0\" width=\"630\" 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èle / Version";
				echo "</th>\n";
				echo "<th>";
				echo "Validité";
				echo "</th>\n";
				echo "<th>";
				echo "Utilisée";
				echo "</th>\n";
				echo "<th>";
				echo "Cliquer";
				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/point_rouge_clignotant.gif\" title=\"Licence illégale...\" border=\"0\" align=\"absmiddle\">";
					$nb_rlic_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_rlic_utilisees++;
						}
					}
					if ($nb_rlic_utilisees >= $row["rlic_maxcli"])
					{
						$txtlic = "Licences installées : ".$nb_rlic_utilisees." / autorisées : ".$row["rlic_maxcli"].".";
						echo " <img src=\"../img/cd.gif\" title =\"".$txtlic."\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\">";
					}
					echo "</td>\n";
		
					echo "<td>\n";
					$rech2 = "SELECT * FROM ".TBRLPMA." WHERE `rlpma_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 $row2["rlpma_desc"];
						else
							echo "-";
					}
					else
						echo "-";
					mysql_free_result($rs2);
					echo "</td>\n";
		
					echo "<td>\n";
					echo $row["rlic_modele"];
					if ($row["rlic_version"] <> "")
					{
						echo "<br>";
						echo "Version : ".$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/exclam.gif\" title =\"Validité dépassée !\" border=\"0\" align=\"absmiddle\">";
					}
					echo "</td>\n";

					 echo "<td align=\"center\">\n";
					 if (ereg($row["rlic_code"],$rpdt_coderlic))
					 {
						if($j%2 == 0)
						{
							if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter1D\" checked>";
							else
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter1D\" checked disabled>";
						}
						else
						{
							if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter2D\" checked>";
							else
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter2D\" checked disabled>";
						}
					 }
					 else
					 {
						if($j%2 == 0)
						{
							if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter1D\">";
							else
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter1D\" disabled>";
						}
						else
						{
							if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter2D\">";
							else
								echo "<input type=\"checkbox\" name=\"rlic_choisi[]\" value=\"".$row["rlic_code"]."\" class=\"TRalter2D\" 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"]."&cc=".$row["rlic_codecli"]."&ca=".$row["rlic_codeage"]."\"><img src=\"../img/edit.png\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
					 }
					 else
					 {
						$lst_voir = TRUE;
						echo "<a href=\"rlic_maj.php?td=view&crl=".$row["rlic_code"]."&cc=".$row["rlic_codecli"]."&ca=".$row["rlic_codeage"]."\"><img src=\"../img/detail.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
					 }
					 if (($rpdt_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["rlic_code"]."&cap=1\"><img src=\"../img/addpbm.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
						 }
					 }
					 else
					 	echo "&nbsp;";
					 echo "</td>\n";
				
					echo "</tr>\n";
				
					$j++;
				}

				echo "</table>\n";
				// Fin affichage table détails licences
				$piedla ="small";
				include ("../inc/piedla.php");
				?>
			</div>
		<?PHP
		}
		else
		{
			echo "Pas de relevé de licences actif";
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>

<!-- Localisation -->
<table width="800"  border="0">
<tr>
	<td width="400" class="tfvNormal" colspan="2">
		<div align="center">Rep&eacute;rage / Garantie / Propri&eacute;t&eacute; </div>
	</td>
	</tr>
</table>

<!-- Emplacement -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_empl">
		<div align="right">Emplacement</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="empl" type="text" id="empl" value="<?PHP echo $rpdt_empl ?>" size="40" maxlength="40">
		  <img src="../img/oblig.gif" width="10" height="11"> <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 $rpdt_empl ?>" size="40" maxlength="40" readonly="1">
		 <?PHP
		 }
		 ?>
	</td>
</tr>
</table>


<!-- Codage produit -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_codep">
		<div align="right">Codage produit</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="codep" type="text" id="codep" value="<?PHP echo $rpdt_codep ?>" size="40" maxlength="40">
		  <img src="../img/oblig.gif" width="10" height="11"> <span class="annot_petit_it"><br>
		  Code 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 $rpdt_codep ?>" size="40" maxlength="40" readonly="1">
		 <?PHP
		 }
		 ?>
	</td>
</tr>
</table>

<!-- Utilisateur -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_util">
		<div align="right">Utilisateur</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="util" type="text" id="util" value="<?PHP echo $rpdt_util ?>" size="40" maxlength="40">
		  <img src="../img/oblig.gif" width="10" height="11">
		 <?PHP
		 }
		 else
		 {
		 ?>
			<input name="util" type="text" id="util" value="<?PHP echo $rpdt_util ?>" size="40" maxlength="40" readonly="1">
		 <?PHP
		 }
		 ?>
	</td>
</tr>
</table>

<!-- Date d'achat -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_dateachf"><div align="right">Date d'achat</div></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"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<img src="../img/calendar.png" id="f_img_dateachf" title="Choisir votre date" width="16" height="16">
			<span class="annot_std_it">(
			<a href="javascript:;" onClick="document.rpdt_maj.dateachf.value=''"><img src="../img/raz.gif" width="12" height="12" 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="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_datefgarf"><div align="right">Fin de garantie</div></td>
	<td>
		<input name="datefgarf" type="text" id="datefgarf" value="<?PHP echo $rpdt_fingarf ?>" size="10" maxlength="10" readonly="1">
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<img src="../img/calendar.png" id="f_img_datefgarf" title="Choisir votre date" width="16" height="16">
			<span class="annot_std_it">(
			<a href="javascript:;" onClick="document.rpdt_maj.datefgarf.value=''"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="document.rpdt_maj.datefgarf.value=''")> Annuler</a> )</span>
		<?PHP
		}
		?>
	</td>
</tr>
</table>



<!-- Garantie sur site ? -->
<!-- Propriétaire ? -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_gars">
		<div align="right">Gar/site ? </div>
	</td>
    <td width="100">
	<?PHP 
	if ($td == "add")
	{ 
		echo "<select name=\"gars\" size=\"1\" id=\"gars\">";
		echo "<option value=\"Oui\">Oui</option>";
		echo "<option value=\"Non\" selected>Non</option>";
		echo "</select>";
	}
	
	if (($td == "edit") OR ($td == "del"))
	{ 
		if ($rpdt_gars == TRUE)
		{
			echo "<select name=\"gars\" size=\"1\" id=\"gars\">";
			echo "<option value=\"Oui\" selected>Oui</option>";
			echo "<option value=\"Non\">Non</option>";
			echo "</select>";
		}
		else
		{
			echo "<select name=\"gars\" size=\"1\" id=\"gars\">";
			echo "<option value=\"Oui\">Oui</option>";
			echo "<option value=\"Non\" selected>Non</option>";
			echo "</select>";
		}
	}
	if (($td <> "view") AND ($td <> "del"))
	{
	?>
	<img src="../img/oblig.gif" width="10" height="11"> 
	<?PHP
	}
	if ($td == "view")
	{ 
		if ($rpdt_gars == TRUE)
		{
	?>
		<input name="gars" type="text" id="gars" value="Oui" size="3" maxlength="3" readonly="1">
	<?PHP
		}
		else
		{
	?>
		<input name="gars" type="text" id="gars" value="Non" size="3" maxlength="3" readonly="1">
	<?PHP
		}
	}
	?>		
	</td>
	<td width="160" class="tfvNormal" id="f_prop">
		<div align="right">Propriétaire ? </div>
	</td>
    <td>
	<?PHP 
	if ($td == "add")
	{ 
		echo "<select name=\"prop\" size=\"1\" id=\"prop\">";
		echo "<option value=\"Oui\" selected>Oui</option>";
		echo "<option value=\"Non\">Non</option>";
		echo "</select>";
	}
	
	if (($td == "edit") OR ($td == "del"))
	{ 
		if ($rpdt_prop == TRUE)
		{
			echo "<select name=\"prop\" size=\"1\" id=\"prop\">";
			echo "<option value=\"Oui\" selected>Oui</option>";
			echo "<option value=\"Non\">Non</option>";
			echo "</select>";
		}
		else
		{
			echo "<select name=\"prop\" size=\"1\" id=\"prop\">";
			echo "<option value=\"Oui\">Oui</option>";
			echo "<option value=\"Non\" selected>Non</option>";
			echo "</select>";
		}
	}
	if ($td <> "view")
	{
	?>
	<img src="../img/oblig.gif" width="10" height="11"> 
	<?PHP
	}
	if ($td == "view")
	{ 
		if ($rpdt_prop == TRUE)
		{
	?>
		<input name="prop" type="text" id="prop" value="Oui" size="3" maxlength="3" readonly="1">
	<?PHP
		}
		else
		{
	?>
		<input name="prop" type="text" id="prop" value="Non" size="3" maxlength="3" readonly="1">
	<?PHP
		}
	}
	?>		
	</td>
</tr>
</table>

<div id="pas_detailr" style="display:block">
	<table width="800"  border="0">
	<tr>
		<td align="right">
			<a href="javascript:;" onclick="display('detailr','block');display('pas_detailr','none');")><img src="../img/view+.gif" title="D&eacute;tail r&eacute;seau" width="22" height="22" border="0" align="absmiddle"></a> 
			<a href="javascript:;" onclick="display('detailr','block');display('pas_detailr','none');"> D&eacute;tail r&eacute;seau</a>
		</td>
	</tr>
	</table>
</div>
<div id="detailr"  style="display:none">
	<table width="800"  border="0">
	<tr>
		<td align="right">
			<a href="javascript:;" onclick="display('pas_detailr','block');display('detailr','none');")><img src="../img/view-.gif" title="Pas de d&eacute;tail r&eacute;seau" width="22" height="22" border="0" align="absmiddle"></a> 
			<a href="javascript:;" onclick="display('pas_detailr','block');display('detailr','none');"> Pas de d&eacute;tail r&eacute;seau</a>
		</td>
	</tr>
	</table>
	<!-- Détail réseau -->
	<table width="800"  border="0">
	<tr>
		<td width="400" class="tfvNormal" colspan="2">
			<div align="center">D&eacute;tail r&eacute;seau</div>
		</td>
		</tr>
	</table>
	
	<!-- Nom du poste -->
	<table width="800"  border="0">
	<tr>
		<td width="160" class="tfvNormal" id="f_nomp">
			<div align="right">Nom du poste</div>
			<div align="right"></div>
		</td>
		<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{
		?>
			<input name="nomp" type="text" id="nomp" value="<?PHP echo $rpdt_nomp ?>" size="20" maxlength="20">
		<?PHP
		}
		else
		{
		?>
			<input name="nomp" type="text" id="nomp" value="<?PHP echo $rpdt_nomp ?>" size="20" maxlength="20" readonly="1">
		<?PHP
		}
		?>
		</td>
	</tr>
	</table>
	
	<!-- Groupe de travail -->
	<table width="800"  border="0">
	<tr>
		<td width="160" class="tfvNormal" id="f_gt">
			<div align="right">Groupe de travail</div>
			<div align="right"></div>
		</td>
		<td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{
		?>
			<input name="gt" type="text" id="gt" value="<?PHP echo $rpdt_gt ?>" size="40" maxlength="40">
		<?PHP
		}
		else
		{
		?>
			<input name="gt" type="text" id="gt" value="<?PHP echo $rpdt_gt ?>" size="40" maxlength="40" readonly="1">
		<?PHP
		}
		?>
		</td>
	</tr>
	</table>
	
	
	<!-- Domaine -->
	<table width="800"  border="0">
	<tr>
		<td width="160" class="tfvNormal" id="f_dom">
			<div align="right">Domaine</div>
			<div align="right"></div>
		</td>
		<td>
			<?PHP
			if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
			{ 
			?>
				<input name="dom" type="text" id="dom" value="<?PHP echo $rpdt_dom ?>" size="40" maxlength="40">
			<?PHP
			}
			else
			{
			?>
				<input name="dom" type="text" id="dom" value="<?PHP echo $rpdt_dom ?>" size="40" maxlength="40" readonly="1">
			<?PHP
			}
			?>
		</td>
	</tr>
	</table>
	
	<!-- Login / MDP -->
	<table width="800"  border="0">
	<tr>
		<td width="160" class="tfvNormal" id="f_login">
			<div align="right">Login / MDP</div>
		</td>
		<td>
			<?PHP
			if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
			{ 
			?>
				<input name="login" type="text" id="login" value="<?PHP echo $rpdt_login ?>" size="40" maxlength="40"> /
				<input name="mdp" type="text" id="mdp" value="<?PHP echo $rpdt_mdp ?>" size="40" maxlength="40">
			<?PHP
			}
			else
			{
			?>
				<input name="login" type="text" id="login" value="<?PHP echo $rpdt_login ?>" size="40" maxlength="40" readonly="1"> /
				<input name="mdp" type="text" id="mdp" value="<?PHP echo $rpdt_mdp ?>" size="40" maxlength="40" readonly="1">
			<?PHP
			}
			?>
		</td>
	</tr>
	</table>
	
	
	<!-- IP / MASQ / PASSERELLE -->
	<table width="800"  border="0">
	<tr>
		<td width="160" class="tfvNormal" id="f_ip">
			<div align="right">IP / Masque / Pass.</div>
		</td>
		<td>
			<?PHP
			if (($rpdt_dateoutf == "") and ($td <> "view"))  // 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" maxlength="15"> /
				<input name="masq" type="text" id="masq" value="<?PHP echo $rpdt_masq ?>" size="17" maxlength="15"> /
				<input name="pass" type="text" id="pass" value="<?PHP echo $rpdt_pass ?>" size="17" maxlength="15"> 
				<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" maxlength="15" readonly="1"> /
				<input name="masq" type="text" id="masq" value="<?PHP echo $rpdt_masq ?>" size="17" maxlength="15" readonly="1"> /
				<input name="pass" type="text" id="pass" value="<?PHP echo $rpdt_pass ?>" size="17" maxlength="15" readonly="1"> 
				<span class="annot_petit_it">(Formats xxx.xxx.xxx.xxx)</span>
			<?PHP
			}
			?>
		</td>
	</tr>
	</table>
	
	<!-- SID / WEP -->
	<table width="800"  border="0">
	<tr>
		<td width="160" class="tfvNormal" id="f_sid">
			<div align="right">SID<br>
			WEP</div>
		</td>
		<td>
			<?PHP
			if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
			{ 
			?>
				<input name="sid" type="text" id="sid" value="<?PHP echo $rpdt_sid ?>" size="80" maxlength="80">
				<input name="wep" type="text" id="wep" value="<?PHP echo $rpdt_wep ?>" size="80" maxlength="80">
			<?PHP
			}
			else
			{
			?>
				<input name="sid" type="text" id="sid" value="<?PHP echo $rpdt_sid ?>" size="80" maxlength="80" readonly="1">
				<input name="wep" type="text" id="wep" value="<?PHP echo $rpdt_wep ?>" size="80" maxlength="80" readonly="1">
			<?PHP
			}
			?>
		</td>
	</tr>
	</table>
</div>

<!-- Notes -->
<table width="800"  border="0">
  <tr>
    <td width="160" valign="top" class="tfvNormal" id="f_nota"><div align="right">Notes </div></td>
    <td>
		<?PHP
			if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<textarea name="nota" cols="95" rows="5" id="nota"><?PHP echo $rpdt_nota ?></textarea>
		<?PHP
		}
		else
		{
		?>
			<textarea name="nota" cols="95" rows="5" id="nota" readonly><?PHP echo $rpdt_nota ?></textarea>
		<?PHP
		}
		?>
	</td>
  </tr>
</table>

<!-- Signé par -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" id="f_signataire">
		<div align="right">Valid&eacute; par</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP
		if (($rpdt_dateoutf == "") and ($td <> "view"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="signataire" type="text" id="signataire" value="<?PHP echo $rpdt_signataire ?>" size="50" maxlength="50">
		  <img src="../img/oblig.gif" width="10" height="11">
		<?PHP
		}
		else
		{
		?>
			<input name="signataire" type="text" id="signataire" value="<?PHP echo $rpdt_signataire ?>" size="50" maxlength="50" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>


<!-- Liste des problèmes déclarés -->
<?PHP
if (exist_rpbm($rpdt_code) == TRUE)
{
?>
	<div id="pas_detailp" style="display:block">
	<?PHP
		if (($td <> "del") AND ($rlic_dateoutf == ""))
		{
	?>
		<a href="javascript:;" onclick="display('detailp','block');display('pas_detailp','none');")><img src="../img/view+.gif" title="Voir/G&eacute;rer les probl&egrave;mes de ce mat&eacute;riel" width="22" height="22" border="0" align="absmiddle"></a> 
		<a href="javascript:;" onclick="display('detailp','block');display('pas_detailp','none');"> Voir/G&eacute;rer les probl&egrave;mes de ce mat&eacute;riel</a>
	<?PHP
		}
		else
		{
	?>
		<a href="javascript:;" onclick="display('detailp','block');display('pas_detailp','none');")><img src="../img/view+.gif" title="Historique des probl&egrave;mes de ce mat&eacute;riel" width="22" height="22" border="0" align="absmiddle"></a> 
		<a href="javascript:;" onclick="display('detailp','block');display('pas_detailp','none');">Historique des probl&egrave;mes de ce mat&eacute;riel</a>
	<?PHP
		}
	?>
	</div>
	<div id="detailp" style="display:none">
		<a href="javascript:;" onclick="display('pas_detailp','block');display('detailp','none');")><img src="../img/view-.gif" title="Pas de d&eacute;tail Probl&egrave;mes" width="22" height="22" border="0" align="absmiddle"></a> 
		<a href="javascript:;" onclick="display('pas_detailp','block');display('detailp','none');"> Pas de d&eacute;tail des probl&egrave;mes</a>
		<br>
	<table width="800"  border="0">
	<tr>
		<td width="400" class="tfvNormal" colspan="2">
			<div align="center">Historique des probl&egrave;mes</div>
		</td>
		</tr>
	</table>

	<table width="800"  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/point_rouge_clignotant.gif" 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.gif" title ="D&eacute;clarer un probl&egrave;me" width="<?PHP echo $hl_vign ?>"  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="800"  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);
			$rech = "SELECT * FROM ".TBRPBM." WHERE `rpbm_coderlp` = '".$rpdt_code."' ORDER BY `rpbm_datecrea`";
			$rs = mysql_query($rech);
	
			if (mysql_num_rows($rs) <> 0)
			{
				echo "<table class=\"MtableD\" border=\"0\" width=\"800\" 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";
				echo "</th>\n";
				echo "<th>";
				echo "Résolu le";
				echo "</th>\n";
				echo "<th>";
				echo "Cliquer";
				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/point_rouge_clignotant.gif\" border=\"0\" align=\"absmiddle\" title =\"Intervention ".$row["rpbm_codeint"]."\">";
					echo "</td>\n";
					echo "<td>\n";
					echo $row["rpbm_signale"];
					echo "</td>\n";
					echo "<td>\n";
					echo $row["rpbm_pbm"];
					echo "</td>\n";
					echo "<td align=\"center\">\n";
					echo formatedate($row["rpbm_datett"]);
					if (formatedate($row["rpbm_datett"]) <> "")
					{
						echo "<span class=\"annot_petit_it\">";
						echo "<br>Int. ".$row["rpbm_codeint"];
						echo "</span>";
					}
					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\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" 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.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" 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/detail.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
						}
					}
					else
					{
						echo "-";
					}
					echo "</tr>\n";
				
					$j++;
				}

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

				$piedla ="small";
				include ("../inc/piedla.php");
			}
			mysql_free_result($rs);
			mysql_close($conn);
			?>
		</td>
	</tr>
	</table>
	</div>
<?PHP
}
else
{
	if ($td <> "add")
	{
?>
	<table width="800"  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.gif" title ="D&eacute;clarer un probl&egrave;me" width="<?PHP echo $hl_vign ?>"  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
	}
}
?>


<p align="center">
<?PHP 
if (($td == "edit") or ($td == "add")) // Boutons si en édition ou création
{ 
?>
	<input name="RAZ" type="reset" id="RAZ" value="R&eacute;initialiser">
	<input name="enr" type="submit" id="enr" value="Enregistrer">
<?PHP 
} 
?>

<?PHP 
if ($td == "del") // Bouton si en mode suppression
{ 
?>
	<input name="del" type="submit" id="del" value="Supprimer">
<?PHP 
} 
?>
</p>
</form>
<?PHP
if ($td == "add")
{
?>
	  <script type="text/javascript">
		Calendar.setup({
			inputField     :    "daterelf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_daterelf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
		Calendar.setup({
			inputField     :    "dateachf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_dateachf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
		Calendar.setup({
			inputField     :    "datefgarf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_datefgarf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
	</script>

	<script>
	// form fields description structure
	var a_fields = {
		'daterelf':{'l':'Date Création','r':true,'f':'date','t':'f_daterelf'},
		'coderel':{'l':'Code dossier relevé','r':true,'t':'f_coderel'},
		'codecli':{'l':'Client','r':true,'t':'f_codecli'},
		'codeage':{'l':'Agence','r':true,'t':'f_codeage'},
		'codetec':{'l':'Technicien','r':true,'t':'f_codetec'},
		'codecat':{'l':'Catégorie','r':true,'t':'f_codecat'},
		'codema':{'l':'Matériel','r':true,'t':'f_codema'},
		'modele':{'l':'Modèle','r':true,'t':'f_modele','mx':40},
		'ns':{'l':'Version','r':true,'t':'f_modele','mx':10},
		'codeet':{'l':'Type Licence','r':true,'t':'f_codeet'},
		'empl':{'l':'Emplacement','r':true,'t':'f_empl','mx':40},
		'codep':{'l':'Codage produit','r':true,'t':'f_codep','mx':20},
		'util':{'l':'Utilisateur','r':true,'t':'f_util','mx':40},
		'nomp':{'l':'Nom du poste','r':false,'t':'f_nomp','mx':20},
		'gt':{'l':'Groupe de travail','r':false,'t':'f_gt','mx':40},
		'dom':{'l':'Nom du poste','r':false,'t':'f_dom','mx':40},
		'login':{'l':'Login','r':false,'t':'f_login','mx':40},
		'mdp':{'l':'Mot de Passe','r':false,'t':'f_login','mx':40},
		'ip':{'l':'Adresse IP','r':false,'t':'f_ip','mn':15,'mx':15},
		'masq':{'l':'Masque IP','r':false,'t':'f_ip','mn':15,'mx':15},
		'pass':{'l':'Passerelle IP','r':false,'t':'f_ip','mn':15,'mx':15},
		'sid':{'l':'SID','r':false,'t':'f_sid','mx':80},
		'wep':{'l':'WEP','r':false,'t':'f_sid','mx':80},
		'dateachf':{'l':'Date Achat','r':false,'f':'date','t':'f_dateachf'},
		'datefgarf':{'l':'Date Fin de garantie','r':false,'f':'date','t':'f_datefgarf'},
		'gars':{'l':'Garantie sur site','r':true,'t':'f_gars'},
		'prop':{'l':'Propriétaire','r':true,'t':'f_prop'},
		'nota':{'l':'Notes','r':false,'t':'f_nota'},
		'signataire':{'l':'Validé par','r':true,'t':'f_signataire','mx':50}
	},
	
	o_config = {
		'to_disable' : ['enr', 'RAZ'],
		'alert' : 1
	}
	
	// validator constructor call
	var v = new validator('rpdt_maj', a_fields, o_config);
	</script>
<?PHP
}
?>
<?PHP
if ($td == "edit")
{
?>
	  <script type="text/javascript">
		Calendar.setup({
			inputField     :    "dateoutf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_dateoutf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
		Calendar.setup({
			inputField     :    "dateachf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_dateachf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
		Calendar.setup({
			inputField     :    "datefgarf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_datefgarf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
	</script>
		
	<script>
	// form fields description structure
	var a_fields = {
		'daterelf':{'l':'Date Création','r':true,'f':'date','t':'f_daterelf'},
		'dateoutf':{'l':'Date Suppression','r':false,'f':'date','t':'f_dateoutf'},
		'coderel':{'l':'Code dossier relevé','r':true,'t':'f_coderel'},
		'codecli':{'l':'Client','r':true,'t':'f_codecli'},
		'codeage':{'l':'Agence','r':true,'t':'f_codeage'},
		'codetec':{'l':'Technicien','r':true,'t':'f_codetec'},
		'codecat':{'l':'Catégorie','r':true,'t':'f_codecat'},
		'codema':{'l':'Matériel','r':true,'t':'f_codema'},
		'modele':{'l':'Modèle','r':true,'t':'f_modele','mx':40},
		'ns':{'l':'Version','r':true,'t':'f_modele','mx':10},
		'codeet':{'l':'Type Licence','r':true,'t':'f_codeet'},
		'empl':{'l':'Emplacement','r':true,'t':'f_empl','mx':40},
		'codep':{'l':'Codage produit','r':true,'t':'f_codep','mx':20},
		'util':{'l':'Utilisateur','r':true,'t':'f_util','mx':40},
		'nomp':{'l':'Nom du poste','r':false,'t':'f_nomp','mx':20},
		'gt':{'l':'Groupe de travail','r':false,'t':'f_gt','mx':40},
		'dom':{'l':'Nom du poste','r':false,'t':'f_dom','mx':40},
		'login':{'l':'Login','r':false,'t':'f_login','mx':40},
		'mdp':{'l':'Mot de Passe','r':false,'t':'f_login','mx':40},
		'ip':{'l':'Adresse IP','r':false,'t':'f_ip','mn':15,'mx':15},
		'masq':{'l':'Masque IP','r':false,'t':'f_ip','mn':15,'mx':15},
		'pass':{'l':'Passerelle IP','r':false,'t':'f_ip','mn':15,'mx':15},
		'sid':{'l':'SID','r':false,'t':'f_sid','mx':80},
		'wep':{'l':'WEP','r':false,'t':'f_sid','mx':80},
		'dateachf':{'l':'Date Achat','r':false,'f':'date','t':'f_dateachf'},
		'datefgarf':{'l':'Date Fin de garantie','r':false,'f':'date','t':'f_datefgarf'},
		'gars':{'l':'Garantie sur site','r':true,'t':'f_gars'},
		'prop':{'l':'Propriétaire','r':true,'t':'f_prop'},
		'nota':{'l':'Notes','r':false,'t':'f_nota'},
		'signataire':{'l':'Validé par','r':true,'t':'f_signataire','mx':50}
	},
	
	o_config = {
		'to_disable' : ['enr', 'RAZ'],
		'alert' : 1
	}
	
	// validator constructor call
	var v = new validator('rpdt_maj', a_fields, o_config);
	</script>

<?PHP
}
?>

<?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() ?>);
	warnnbetat(<?PHP echo nb_etatpdt() ?>);
	</script>
<?PHP
}
else
{
	if ($td == "edit")
	{
?>
	<script type="text/javascript">
	warnedit(<?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?ta=m');",2000)
	</script>
	<p align="center" class="annot_std_it">Merci de choisir un client...</p>
<?PHP
}
?>
