<?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é
	$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 ($crl <> "")
	{
		// Récupération des informations relevé licence
		$row = lit_enr_rlic($crl);
		if (is_array($row))
			extract ($row);

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

		if ($td == "edit")
		{
			$cc=$rlic_codecli;
			$ca=$rlic_codeage;
			$titre = "MISE A JOUR FICHE RELEVE LICENCE";
		}

		if ($td == "del")
		{
			$cc=$rlic_codecli;
			$ca=$rlic_codeage;
			$titre = "SUPPRESSION FICHE RELEVE LICENCE";
		}
		
		if ($td == "view")
		{
			$titre = "VOIR FICHE RELEVE LICENCE";
		}

		if ($td == "add")
		{
			$rlic_daterelf = $datef;
			$rlic_code = $crl;
			$rlic_codecli = $cc;
			$rlic_codeage = $ca;
			$rlic_maxcli = 1;
			
			$titre = "CREATION FICHE RELEVE LICENCE";
		}

	}
	else
	{
		if ($td == "add")
		{
			$rlic_daterelf = $datef;
			$rlic_code = crecodesession("RL");
			$rlic_coderel = $cr;
			$rlic_code = $crl;
			$rlic_codecli = $cc;
			$rlic_codeage = $ca;
			$rlic_maxcli = 1;

			$titre = "CREATION FICHE RELEVE LICENCE";
		}

	}

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

			$rlic_codecli = $cc;
	}

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

<!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="../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 $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="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 $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="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 $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="tfvNormal" 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"))  // 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="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 $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="tfvNormal" 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="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 ($rlic_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 ($rlic_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($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="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 ($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
				if ($rlic_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 ($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
			{
				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($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="tfvNormal" 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="tfvNormal" 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"))  // 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
				if ($rlic_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 ($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="tfvNormal" id="f_modele">
		<div align="right">Mod&egrave;le</div>
		<div align="right"></div>
	</td>
    <td>
	<?PHP
		if (($rlic_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 $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="tfvNormal" id="f_version">
		<div align="right">Version</div>
		<div align="right"></div>
	</td>
    <td>
	<?PHP		if (($rlic_dateoutf == "") and ($td <> "view"))  // 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="tfvNormal" 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"))  // 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
				if ($rlic_codetl <> "")
					echo "<option value=\"\">-- Choisissez un type --</option>";
				else
					echo "<option value=\"\" selected>-- 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="tfvNormal" id="f_maxcli">
		<div align="right">Maximum de postes</div>
	</td>
    <td>
		<?PHP		if (($rlic_dateoutf == "") and ($td <> "view"))  // 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

					$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="tfvNormal" 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"))  // 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="tfvNormal" id="f_numlic">
		<div align="right">Num&eacute;ro</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP		if (($rlic_dateoutf == "") and ($td <> "view"))  // 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="tfvNormal" id="f_cleflic">
		<div align="right">Clef Activation </div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP		if (($rlic_dateoutf == "") and ($td <> "view"))  // 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="tfvNormal" 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") OR ($td == "del"))
	{ 
		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")
	{ 
		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="tfvNormal" 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") OR ($td == "del"))
	{ 
		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")
	{ 
		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
		}
	}
	?>		
	</td>
</tr>
</table>

<!-- Date de validité -->
<table width="800"  border="0">
<tr>
	<td width="160" class="tfvNormal" 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"))  // 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="tfvNormal" id="f_nota"><div align="right">Notes </div></td>
    <td>
		<?PHP		if (($rlic_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 $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="tfvNormal" id="f_signataire">
		<div align="right">Valid&eacute; par</div>
		<div align="right"></div>
	</td>
    <td>
		<?PHP		if (($rlic_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 $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="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 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";
					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")
					{
						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

				$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>

	<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'},
		'codema':{'l':'Matériel','r':true,'t':'f_codema'},
		'modele':{'l':'Modèle','r':true,'t':'f_modele','mx':40},
		'version':{'l':'Version','r':true,'t':'f_version','mx':10},
		'codetl':{'l':'Type Licence','r':true,'t':'f_codetl'},
		'maxcli':{'l':'Nb maximum de postes','r':true,'f':'unsigned','t':'f_maxcli','mx':4},
		'codemed':{'l':'Type Média','r':true,'t':'f_codemed'},
		'numlic':{'l':'Numéro de Licence','r':false,'t':'f_numlic','mx':40},
		'cleflic':{'l':'Clef de Débridage','r':false,'t':'f_cleflic','mx':40},
		'ajour':{'l':'A jour','r':true,'t':'f_ajour'},
		'legale':{'l':'Licence Légale','r':true,'t':'f_legale'},
		'datevalf':{'l':'Date Validité','r':false,'f':'date','t':'f_datevalf'},
		'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('rlic_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     :    "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>
		
	<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'},
		'codema':{'l':'Matériel','r':true,'t':'f_codema'},
		'modele':{'l':'Modèle','r':true,'t':'f_modele','mx':40},
		'version':{'l':'Version','r':true,'t':'f_version','mx':10},
		'codetl':{'l':'Type Licence','r':true,'t':'f_codetl'},
		'maxcli':{'l':'Nb maximum de postes','r':true,'f':'unsigned','t':'f_maxcli','mx':4},
		'codemed':{'l':'Type Média','r':true,'t':'f_codemed'},
		'numlic':{'l':'Numéro de Licence','r':false,'t':'f_numlic','mx':40},
		'cleflic':{'l':'Clef de Débridage','r':false,'t':'f_cleflic','mx':40},
		'ajour':{'l':'A jour','r':true,'t':'f_ajour'},
		'legale':{'l':'Licence Légale','r':true,'t':'f_legale'},
		'datevalf':{'l':'Date Validité','r':false,'f':'date','t':'f_datevalf'},
		'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('rlic_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() ?>);
	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?ta=m');",2000)
	</script>
	<p align="center" class="annot_std_it">Merci de choisir un client...</p>
<?PHP
}
?>
