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

Version 0.9.6
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/func_txt.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é
	$crl = strip_tags(trim($_GET['crl'])); // Récupération code Relevé Licence
	$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 ($cc <>"")
	{
			$row = lit_enr_cli($cc);
			extract ($row);

			$rlic_codecli = $cc;
	}

	if ($crl <> "")
	{
		// Récupération des informations relevé licence
		$row = lit_enr_rlic($crl);
		if (is_array($row))
			extract ($row);
		$exist_in_rpbm = exist_rlic_in_rpbm($crl);
		if ($exist_in_rpbm==TRUE)
			$exist_in_rpbm=1;
		else
			$exist_in_rpbm=0;

		$rlic_daterelf = formatedate($rlic_daterel);
		$rlic_datevalf = formatedate($rlic_dateval);
		$rlic_dateoutf = formatedate($rlic_dateout);

		if ($td == "edit")
		{
			$cc=$rlic_codecli;
			$ca=$rlic_codeage;
		}

		if ($td == "del")
		{
			$cc=$rlic_codecli;
			$ca=$rlic_codeage;
		}
		
		if ($td == "add")
		{
			$rlic_daterelf = $datef;
			$rlic_dateoutf = "";
			$rlic_code = $crl;
			$rlic_codecli = $cc;
			$rlic_codeage = $ca;
			$rlic_maxcli = 1;
			if ($cli_ste<>"")
				$rlic_idsite = -2;
			else
				$rlic_idsite = 0;
		}

	}
	else
	{
		if ($td == "add")
		{
			$rlic_daterelf = $datef;
			$rlic_dateoutf = "";
			$rlic_code = crecodesession("RL");
			$rlic_coderel = $cr;
			$rlic_code = $crl;
			$rlic_codecli = $cc;
			$rlic_codeage = $ca;
			$rlic_maxcli = 1;
			if ($cli_ste<>"")
				$rlic_idsite = -2;
			else
				$rlic_idsite = 0;
		}

	}

	switch ($td)
	{
		case "add":
			$titre = "AJOUT FICHE RELEVE LICENCE";
			break;
		case "edit":
			$titre = "MISE A JOUR FICHE RELEVE LICENCE";
			break;
		case "view":
			$titre = "DETAIL FICHE RELEVE LICENCE";
			break;
		case "del":
			$titre = "SUPPRESSION FICHE RELEVE LICENCE";
			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 - ESPACE PRIVE : Fiche Relev&eacute; Licence</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 -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.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>

<!-- Fenêtre avertissement sur changement site client dans fiche relevé -->
<script type="text/javascript">
	function warnmovesclirlp(pbm,oldval)
	{
		var mess='';
		if (pbm==1)
		{
			mess='Vous ne pouvez pas affecter un nouveau lieu si des problèmes non résolus ont été déclarés.';
			alert(mess);
			document.rlic_maj.site.value=oldval;
		}	
	}
</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>

<!-- 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:jj-mm-aaaa ; req:Y ; txt:Date création ; stok:frmok ; stbad:frmbad",
<?PHP
if ((@$HTTP_SESSION_VARS["niv_log"] <> 4) AND (@$HTTP_SESSION_VARS["niv_log"] <> 3))
{
?>
	"nom:codeage ; format:liste ; req:Y ; txt:Agence ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:codeage ; format:txt ; req:Y ; txt:Agence ; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
<?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
}
?>
<?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
}
?>
<?PHP
if (($rlic_dateoutf == "") and ($td <> "view"))
{ 
?>
	"nom:codema ; format:liste ; req:Y ; txt:Marque ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:codema ; format:txt ; req:Y ; txt:Marque ; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:modele ; format:txt ; req:Y ; txt:Modèle ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:version ; format:txt ; req:Y ; txt:Version ; lmx:10 ; stok:frmok ; stbad:frmbad",
<?PHP
if (($rlic_dateoutf == "") and ($td <> "view"))
{ 
?>
	"nom:codetl ; format:liste ; req:Y ; txt:Type de licence ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:codetl ; format:txt ; req:Y ; txt:Type de licence ; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:maxcli ; format:unsigned ; req:Y ; txt:Nombre maximum de postes ; lmx:4 ; stok:frmok ; stbad:frmbad",
<?PHP
if (($rlic_dateoutf == "") and ($td <> "view"))
{ 
?>
	"nom:codemed ; format:liste ; req:Y ; txt:Type de média ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
}
else
{
?>
	"nom:codemed ; format:txt ; req:Y ; txt:Type de média ; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:numlic ; format:txt ; req:N ; txt:Numéro de licence ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:cleflic ; format:txt ; req:N ; txt:Clef de débridage ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:nota ; format:txt ; req:N ; txt:Notes ; stok:frmok ; stbad:frmbad",
	"nom:signataire ; format:txt ; req:Y ; txt:Validé par ; lmx:50 ; stok:frmok ; stbad:frmbad");
</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 $rlic_coderel; ?>">Retour au dossier de relev&eacute; <br>
	<?PHP
	}
	else
	{
	?>
		<a href="rel_maj.php?td=view&cr=<?PHP echo $rlic_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="rlic_maj" method="post" action="rlic_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,''));">
<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 $rlic_codecli ?>">
<?PHP if ($td == "add") { ?>
	<input name="code" type="hidden" id="code" value="<?PHP echo $rlic_code ?>">
	<input name="dateoutf" type="hidden" id="dateoutf" value="<?PHP echo $rlic_dateoutf ?>">
<?PHP } else {?>
	<input name="code" type="hidden" id="code" value="<?PHP echo $rlic_code ?>">
	<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $rlic_codeage ?>">
	<input name="codetec" type="hidden" id="codetec" value="<?PHP echo $rlic_codetec ?>">
<?PHP } ?>


<!-- Date de création -->
<!-- Date de sortie de la licence -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" 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 $rlic_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.rlic_maj.daterelf.value=''"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="document.rlic_maj.daterelf.value=''")> Annuler</a> )</span>
		<?PHP } ?>
	</td>
	<?PHP if ($td <> "add") { ?>
	<td width="160" class="rubfrm" id="f_dateoutf"><div align="right">Sortie du parc le</div></td>
	<td>
		<input name="dateoutf" type="text" id="dateoutf" value="<?PHP echo $rlic_dateoutf ?>" size="10" maxlength="10" readonly="1">
		<?PHP
			if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // 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.rlic_maj.dateoutf.value=''"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="document.rlic_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="rubfrm" 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 $rlic_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 la licence est sortie du parc, la fiche n'est plus modifiable.</span>
	<?PHP } else {?>
	&nbsp;
	<?PHP } ?>
	</td>
</tr>
</table>

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

<!-- Affichage du client -->
<table width="800"  border="0">
<tr>
	<td width="400" class="rubfrm" 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; ?>',930,380,'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; ?>',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 de la licence -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_site"><div align="right">Lieu d'utilisation</div></td>
	<td>
	<?PHP
		if (($rlic_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 $rlic_idsite; ?>)">
			<option>---Choisissez le lieu d'utilisation--</option>
			<option value="-1" <?PHP if ($rlic_idsite == -1) echo "selected"?>>Tous les sites</option>
			<option value="0" <?PHP if ($rlic_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);
			
				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($scli_ville)." ".Retourneville($scli_ville).")";
						else
							$nom_site = $scli_ste." (".$scli_adr1.", ".Retournecp($scli_ville)." ".Retourneville($scli_ville).")";
						if ($rlic_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.gif" width="10" height="11">
		<?PHP
			}
			else
			{
			?>
				<input name="site" type="hidden" id="site" value="<?PHP echo $rlic_idsite; ?>">
			<?PHP
				switch ($rlic_idsite)
				{
				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($rlic_idsite);
						if (is_array($row))
						{
							extract($row);
							if ($scli_adr2<>"")
								$nom_site = $scli_ste." (".$scli_adr1.", ".$scli_adr2.", ".Retournecp($scli_ville)." ".Retourneville($scli_ville).")";
							else
								$nom_site = $scli_ste." (".$scli_adr1.", ".Retournecp($scli_ville)." ".Retourneville($scli_ville).")";
						}
				?>
						<input name="nsite" type="text" id="nsite" value="<?PHP echo $nom_site; ?>" size="100" readonly="1">
				<?PHP
					break;
				}
			}
		?>
	</td>
</tr>
</table>

<table width="800"  border="0">
<tr>
	<td width="400" class="rubfrm" 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="rubfrm" 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
					echo "<option>-- Choisissez une agence --</option>";

					while ($resultat = mysql_fetch_array($rs)) 
					{
						extract($resultat);
		
						$nom_code = $age_nom." (".$age_code.")";
						if ($rlic_codeage == $age_code)
							echo '<option value="'.$age_code.'" selected>'.$nom_code.'</option>';
						else
							echo '<option value="'.$age_code.'">'.$nom_code.'</option>';
					}
				?>
				</select>
				<?PHP
				}
				else
				{
				?>
					<select name="codeage" id="codeage">
					<option>-- Pas d'agence ouverte --</option>
					</select>
				<?PHP
				}
				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($rlic_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="rubfrm" 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 ($rlic_codeage <> "")
				$rech = "SELECT * FROM ".TBTEC." WHERE `tec_dateout` = '0000-00-00' AND `tec_codeage` = '".$rlic_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
				echo "<option>-- Choisissez un technicien --</option>";
	
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					$nom_prenom = $tec_nom." ".$tec_prenom;
					if ($rlic_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.gif" width="10" height="11">
		<?PHP 
		} 
		else  // Edition ou suppression = zone non modifiable (affichage seul)
		{
			$row = lit_enr_tec($rlic_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="rubfrm" colspan="2">
		<div align="center">D&eacute;tail du relev&eacute;</div>
	</td>
	</tr>
</table>

<!-- Marque/Nom de l'éditeur -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codema"><div align="right">Marque</div></td>
	<td>
		<?PHP
		
		// Création de la liste des marques
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
			$rech = "SELECT * FROM ".TBRLPMA." ORDER BY rlpma_desc";
			$rs = mysql_query($rech);
		?>
			
			<select name="codema" id="codema">
	
			<?PHP
				echo "<option value=\"\">-- Choisissez une marque --</option>";
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($rlic_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` = '".$rlic_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 de la licence -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_modele">
		<div align="right">Mod&egrave;le</div>
		<div align="right"></div>
	</td>
    <td>
	<?PHP
		if (($rlic_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 $rlic_modele ?>" 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 $rlic_modele ?>" size="40" maxlength="40" readonly="1">
	<?PHP
		}
	?>
	</td>
</tr>
</table>

<!-- Version de la licence -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_version">
		<div align="right">Version</div>
		<div align="right"></div>
	</td>
    <td>
	<?PHP if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
	?>
		<input name="version" type="text" id="version" value="<?PHP echo $rlic_version ?>" size="10" maxlength="10"> <img src="../img/oblig.gif" width="10" height="11">
	<?PHP
		}
		else
		{
	?>
		<input name="version" type="text" id="version" value="<?PHP echo $rlic_version ?>" size="10" maxlength="10" readonly="1">
	<?PHP
		}
	?>
	</td>
</tr>
</table>

<!-- Type de la licence -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codetl"><div align="right">Type</div></td>
	<td>
		<?PHP
		
		// Création de la liste des types
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);		
		if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
			$rech = "SELECT * FROM ".TBRLTL." ORDER BY rltl_desc";
			$rs = mysql_query($rech);

		?>
		
			<select name="codetl" id="codetl">
	
			<?PHP
				echo "<option value=\"\">-- Choisissez un type --</option>";
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($rlic_codetl == $rltl_code)
					{
						echo '<option value="'.$rltl_code.'" selected>'.$rltl_desc.'</option>';
					}
					else
					{
						echo '<option value="'.$rltl_code.'">'.$rltl_desc.'</option>';
					}
				}
			?>
			</select>
			<img src="../img/oblig.gif" width="10" height="11">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBRLTL." WHERE `rltl_code` = '".$rlic_codetl."'";
			$rs = mysql_query($rech);
			if ($row = mysql_fetch_array($rs))
			{
				extract ($row);
			}
		?>
			<input name="codetl" type="hidden" id="codetl" value="<?PHP echo $rlic_codetl; ?>">
			<input name="nomtl" type="text" id="nomtl" value="<?PHP echo $rltl_desc; ?>" size="40" maxlength="40" readonly="1">
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>

<!-- Nb Maximum de clients -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_maxcli">
		<div align="right">Maximum de postes</div>
	</td>
    <td>
		<?PHP if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="maxcli" type="text" id="maxcli" value="<?PHP echo $rlic_maxcli ?>" size="4" maxlength="4" align="right"> 
			<img src="../img/oblig.gif" width="10" height="11">
		<?PHP 
		}
		else
		{
		?>
			<input name="maxcli" type="text" id="maxcli" value="<?PHP echo $rlic_maxcli ?>" size="4" maxlength="4" align="right" readonly="1"> 
		<?PHP
		}
		if ($td <> "add")
		{
			$nb_rlic_utilisees = nb_rlic($rlic_codecli,$rlic_code);
		?>
			<span class="annot_petit_it">(Utilis&eacute; : <?PHP echo $nb_rlic_utilisees; ?> )</span>
		<?PHP 
			if ($nb_rlic_utilisees > $rlic_maxcli)
			{
		?>
			<span style="background-color:#FF0000; color:#FFFF00; font-weight:bold"> Maximum d&eacute;pass&eacute; </span>
		<?PHP		
			}
			if ($nb_rlic_utilisees == $rlic_maxcli)
			{
		?>
			<span style="background-color:#FF0000; color:#FFFF00; font-weight:bold"> Maximum atteint </span>
		<?
			}
			if ($nb_rlic_utilisees <> 0)
			{
				// Création de la liste des relevés produits utilisant ce relevé licences
				
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rech = "SELECT * FROM ".TBRPDT." WHERE rpdt_codecli = '".$rlic_codecli."' ORDER BY rpdt_code";
				$rs = mysql_query($rech);
		
				if (mysql_num_rows($rs) <> 0)
				{
		?>
				<div id="pas_detailm" style="display:block">
					<a href="javascript:;" onclick="display('detailm','block');display('pas_detailm','none');")><img src="../img/view+.gif" title="D&eacute;tail mat&eacute;riel" width="22" height="22" border="0" align="absmiddle"></a> 
					<a href="javascript:;" onclick="display('detailm','block');display('pas_detailm','none');"> D&eacute;tail mat&eacute;riel</a>
				</div>
				<div id="detailm" style="display:none">
					<a href="javascript:;" onclick="display('pas_detailm','block');display('detailm','none');")><img src="../img/view-.gif" title="Pas de d&eacute;tail mat&eacute;riel" width="22" height="22" border="0" align="absmiddle"></a> 
					<a href="javascript:;" onclick="display('pas_detailm','block');display('detailm','none');"> Pas de d&eacute;tail mat&eacute;riel</a>
					<br>
					<span class="annot_gras_it">Mat&eacute;riel(s) utilisant cette licence</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 matériels"
					echo "<th>";
					echo "Code Fiche";
					echo "</th>\n";
					echo "<th>";
					echo "Catégorie";
					echo "</th>\n";
					echo "<th>";
					echo "Marque / Modèle / NS / Emplacement ";
					echo "</th>\n";
					echo "<th>";
					echo "Fin Gar.";
					echo "</th>\n";
					echo "<th>";
					echo "Editer";
					echo "</th>\n";
	
					$j = 0;
					
					while ($row = mysql_fetch_assoc($rs)) 
					{         
						if (ereg($rlic_code,$row["rpdt_coderlic"]))
						{
							// Création de l'entête de ligne (TR)
							creetrlstdet($j);
							
							echo "<td>\n";
							echo $row["rpdt_code"]." ";
							echo "</td>\n";
				
							echo "<td>\n";
							$rech2 = "SELECT * FROM ".TBRPCAT." WHERE `rpcat_code` = '".$row["rpdt_codecat"]."'";
							$rs2 = mysql_query($rech2) or die(mysql_error());
							if (mysql_num_rows($rs2) <> 0)
							{
								if ($row2 = mysql_fetch_array($rs2))
									echo $row2["rpcat_desc"];
								else
									echo "-";
							}
							else
								echo "-";
							mysql_free_result($rs2);
							echo "</td>\n";
				
							echo "<td>\n";
							$rech2 = "SELECT * FROM ".TBRLPMA." WHERE `rlpma_code` = '".$row["rpdt_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);

							if ($row["rpdt_modele"] <> "")
							{
								echo "<br>";
								echo $row["rpdt_modele"];
							}
							if ($row["rpdt_ns"] <> "")
							{
								echo "<br>";
								echo "NS : ".$row["rpdt_ns"];
							}
							if ($row["rpdt_empl"] <> "")
							{
								echo "<br>";
								echo "Empl. : ".$row["rpdt_empl"];
							}
							echo "</td>\n";
				
							echo "<td align=\"center\">\n";
							echo formatedate($row["rpdt_fingar"]);
							echo "</td>\n";
				
							echo "<td align=\"center\">\n";
							if (($td <> "view") AND ($td <> "del"))
							{
								$lst_maj = TRUE;
								echo "<a href=\"rpdt_maj.php?td=edit&crp=".$row["rpdt_code"]."&cc=".$row["rpdt_codecli"]."&ca=".$row["rpdt_codeage"]."\"><img src=\"../img/edit.png\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
							}
							else
							{
								$lst_voir = TRUE;
								echo "<a href=\"rpdt_maj.php?td=view&crp=".$row["rpdt_code"]."&cc=".$row["rpdt_codecli"]."&ca=".$row["rpdt_codeage"]."\"><img src=\"../img/detail.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
							}
							if (($rlic_dateoutf == "") AND ($td <> "del"))
							{
								$lst_pbmrel = TRUE;
								echo " ";
								echo "<a href=\"rpbm_maj.php?td=add&tr=2&cr=".$row["rpdt_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

					$taille_piedla ="small";
					include ("../inc/piedla.php");
					?>
				</div>
		<?PHP
				}
				mysql_free_result($rs);
				mysql_close($conn);
			}
		}
		?>

	</td>
</tr>
</table>

<!-- Type de média -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codemed"><div align="right">Type M&eacute;dia</div></td>
	<td>
		<?PHP
		
		// Création de la liste des types
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);		
		
		if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
			$rech = "SELECT * FROM ".TBRLMED." ORDER BY rlmed_desc";
			$rs = mysql_query($rech);
	
		?>
			
			<select name="codemed" id="codemed">
	
			<?PHP
				if ($rlic_codemed <> "")
					echo "<option value=\"\">-- Choisissez un média --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez un média --</option>";
	
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
	
					if ($rlic_codemed == $rlmed_code)
					{
						echo '<option value="'.$rlmed_code.'" selected>'.$rlmed_desc.'</option>';
					}
					else
					{
						echo '<option value="'.$rlmed_code.'">'.$rlmed_desc.'</option>';
					}
				}
			?>
			</select>
			<img src="../img/oblig.gif" width="10" height="11">
		<?PHP
		}
		else
		{
			$rech = "SELECT * FROM ".TBRLMED." WHERE `rlmed_code` = '".$rlic_codemed."'";
			$rs = mysql_query($rech);
			if ($row = mysql_fetch_array($rs))
			{
				extract ($row);
			}
		?>
			<input name="codemed" type="hidden" id="codemed" value="<?PHP echo $rlic_codemed; ?>">
			<input name="nommed" type="text" id="nommed" value="<?PHP echo $rlmed_desc; ?>" size="40" maxlength="40" readonly="1">
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
	</td>
</tr>
</table>

<!-- Numéro de la licence -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_numlic">
		<div align="right">Num&eacute;ro</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP		
		if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="numlic" type="text" id="numlic" value="<?PHP echo $rlic_numlic ?>" size="40" maxlength="40">
		<?PHP
		}
		else
		{
		?>
			<input name="numlic" type="text" id="numlic" value="<?PHP echo $rlic_numlic ?>" size="40" maxlength="40" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>


<!-- Clef de la licence -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_cleflic">
		<div align="right">Clef Activation </div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP		
		if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<input name="cleflic" type="text" id="cleflic" value="<?PHP echo $rlic_cleflic ?>" size="40" maxlength="40">
		<?PHP
		}
		else
		{
		?>
			<input name="cleflic" type="text" id="cleflic" value="<?PHP echo $rlic_cleflic ?>" size="40" maxlength="40" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Licence à jour ? -->
<!-- Licence Légale ? -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_ajour">
		<div align="right">A Jour ? </div>
		<div align="right"></div>
	</td>
    <td width="100">
	<?PHP 
	if ($td == "add")
	{ 
		echo "<select name=\"ajour\" size=\"1\" id=\"ajour\">";
		echo "<option value=\"Oui\" selected>Oui</option>";
		echo "<option value=\"Non\">Non</option>";
		echo "</select>";
	}
	
	if ($td == "edit")
	{ 
		if ($rlic_ajour == TRUE)
		{
			echo "<select name=\"ajour\" size=\"1\" id=\"ajour\">";
			echo "<option value=\"Oui\" selected>Oui</option>";
			echo "<option value=\"Non\">Non</option>";
			echo "</select>";
		}
		else
		{
			echo "<select name=\"ajour\" size=\"1\" id=\"ajour\">";
			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") OR ($td == "del"))
	{ 
		if ($rlic_ajour == TRUE)
		{
	?>
		<input name="ajour" type="text" id="ajour" value="Oui" size="3" maxlength="3" readonly="1">
	<?PHP
		}
		else
		{
	?>
		<input name="ajour" type="text" id="ajour" value="Oui" size="3" maxlength="3" readonly="1">
	<?PHP
		}
	}
	?>		
	</td>
	<td width="160" class="rubfrm" id="f_legale">
		<div align="right">L&eacute;gale ? </div>
		<div align="right"></div>
	</td>
    <td>
	<?PHP 
	if ($td == "add")
	{ 
		echo "<select name=\"legale\" size=\"1\" id=\"legale\">";
		echo "<option value=\"Oui\" selected>Oui</option>";
		echo "<option value=\"Non\">Non</option>";
		echo "</select>";
	}
	
	if ($td == "edit")
	{ 
		if ($rlic_legal == TRUE)
		{
			echo "<select name=\"legale\" size=\"1\" id=\"legale\">";
			echo "<option value=\"Oui\" selected>Oui</option>";
			echo "<option value=\"Non\">Non</option>";
			echo "</select>";
		}
		else
		{
			echo "<select name=\"legale\" size=\"1\" id=\"legale\">";
			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") OR ($td=="del"))
	{ 
		if ($rlic_legal == TRUE)
		{
	?>
		<input name="legale" type="text" id="legale" value="Oui" size="3" maxlength="3" readonly="1">
	<?PHP
		}
		else
		{
	?>
		<input name="legale" type="text" id="legale" value="Non" size="3" maxlength="3" readonly="1">
	<?PHP
		}
	}
	?>
	<span class="annot_petit_it">
	(Non : pas légale ou pas pu avoir de confirmation)
	</span>
	</td>
</tr>
</table>

<!-- Date de validité -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datevalf"><div align="right">Date Validit&eacute; </div></td>
	<td>
		<input name="datevalf" type="text" id="datevalf" value="<?PHP echo $rlic_datevalf ?>" size="10" maxlength="10" readonly="1">
		<?PHP		
		if (($rlic_dateoutf == "") and ($td <> "view") and ($td<>"del"))  // zone modifiable si pas sorti du parc et si pas en visualisation
		{ 
		?>
			<img src="../img/calendar.png" id="f_img_datevalf" title="Choisir votre date" width="16" height="16">
			<span class="annot_std_it">(
			<a href="javascript:;" onClick="document.rlic_maj.datevalf.value=''"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a>
			<a href="javascript:;" onclick="document.rlic_maj.datevalf.value=''")> Annuler</a> )</span>
		<?PHP 
			if ((echeance_depassee_date($datea,$rlic_dateval)) AND ($rlic_datevalf <>"") AND ($rlic_dateoutf == ""))
			{
		?>
			<span style="background-color:#FF0000; color:#FFFF00; font-weight:bold"> Ech&eacute;ance d&eacute;pass&eacute;e </span>
		<?PHP		
			}
		}
		?>
	</td>
</tr>
</table>

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

<!-- Signé par -->
<table width="800"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_signataire">
		<div align="right">Valid&eacute; par</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP		
		if (($rlic_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 $rlic_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 $rlic_signataire ?>" size="50" maxlength="50" readonly="1">
		 <?PHP
		 }
		 ?>
	</td>
</tr>
</table>

<!-- Liste des problèmes déclarés -->
<?PHP
if (exist_rpbm($rlic_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 cette licence" 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 cette licence</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 cette licence" 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 cette licence</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="rubfrm" 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 cette licence</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 ($rlic_dateoutf == ""))
			{
				$url_add = "rpbm_maj.php?td=add&tr=1&cr=".$rlic_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` = '".$rlic_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";
					$tab_txtpbm = cesuretxt_tab($row["rpbm_pbm"],100);
					$txtpbm="";
					foreach ($tab_txtpbm as $index_ligne=>$ligne)
						$txtpbm .= $ligne."<br>";
					echo $txtpbm;
					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")
					{
						if ($row["rpbm_codeint"] == "") // On peut éditer ou supprimer uniquement si aucune intervention n'est rattachée
						{
							$lst_maj = TRUE;
							echo "<a href=\"rpbm_maj.php?td=edit&tr=1&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=1&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=1&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

				$taille_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 ($rlic_dateoutf == ""))
			{
				$url_add = "rpbm_maj.php?td=add&tr=1&cr=".$rlic_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     :    "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     :    "datevalf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_datevalf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
	</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     :    "datevalf",     // id of the input field
			ifFormat       :    "%d-%m-%Y",      // format of the input field
			button         :    "f_img_datevalf",  // trigger for the calendar (button ID)
			align          :    "Ll",           // alignment (defaults to "Bl")
			singleClick    :    true
		});
	</script>
<?PHP
}
?>

<?PHP if ($td == "add") 
{
?>
	<script type="text/javascript">
	warnnbage(<?PHP echo nb_age_actives(); ?>,"cont");
	warnnbtec(<?PHP echo nb_tec_actifs() ?>);
	warnnbmarque(<?PHP echo nb_marques() ?>);
	warnnbtype(<?PHP echo nb_typlic() ?>);
	</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');",2000)
	</script>
	<p align="center" class="annot_std_it">Merci de choisir un client...</p>
<?PHP
}
?>
