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

Version 0.9.9

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

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

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

Contact : galawa@free.fr

Web : http://smitst.homelinux.com
****************************************************************************************/


// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_int.inc.php");
include_once("../inc/fic_mque.inc.php");
include_once("../inc/fic_ret.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim($_GET['td'])); // Récupération type demande
$cpr = strip_tags(trim($_GET['cpr'])); // Récupération code Produit à Retourner
$ca = strip_tags(trim($_GET['ca'])); // Récupération code Agence
$cm = strip_tags(trim($_GET['cm'])); // Récupération code Marque

$msg_err_int="Aucune intervention en cours";
$pbm_retp = FALSE;
$nbartint = 0;

if ($ca<> "")
{
	// Contrôle qu'une agence n'essaye pas de "hacker" une fiche
	if (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($ca <> @$_SESSION["code_age"]))
		$pbm_retp = TRUE;
	$retp_codeage=$ca;
}

if ($cpr <> "")
{
	// Récupération des informations produit à retourner
	$row = lit_enr_retp($cpr,TRUE);
	if (is_array($row))
	{
		extract ($row);

		if ($td <> "add")
		{
			// Contrôle qu'une agence n'essaye pas de "hacker" un retour
			if (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($retp_codeage <> @$_SESSION["code_age"]))
				$pbm_retp = TRUE;
		}

		// Formatage des dates en français
		$retp_datecreaf = formatedate($retp_datecrea);
		$retp_datemodf = formatedate($retp_datemod);
		$retp_dblff = formatedate($retp_dblf);
		
		// Si retour demandé, ou envoyé, ou déjà traité, on force le mode "view"
		if ((exist_enr_retd($cpr,TRUE) == TRUE) OR (exist_enr_rete($cpr,TRUE) == TRUE) OR (exist_enr_retr($cpr,TRUE) == TRUE))
			$td="view";

		if ($td == "edit")
			$ca=$retp_codeage;

		if ($td == "add")
		{
			$retp_datecreaf = $datef;
			$retp_code = $cpr;
			$retp_codeage = $ca;
			$retp_codeenv = "";
		}
	}
	else
		$pbm_retp = TRUE;
}
else
{
	if ($td == "add")
	{
		$retp_datecreaf = $datef;
		$retp_code = crecodesession("PR");
		$cpr = $retp_code;
		$retp_blf = "";
		$retp_codeenv = "";
	}
	else
		$pbm_retp=TRUE;
}

switch ($td)
{
	case "add" :
		$titre = "SAISIE PRODUIT A RETOURNER";
		break;
	case "edit" :
		$titre = "MISE A JOUR PRODUIT A RETOURNER";
		break;
	case "view" :
			$titre = "DETAIL PRODUIT A RETOURNER";
		break;
	case "del":
		$titre = "SUPPRESSION PRODUIT A RETOURNER";
		break;
	default:
			$titre = "PROBLEME";
			$pbm_retp=TRUE;
		break;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMI - <?PHP echo $title_esp_prive; ?> : Fiche Produit &agrave; Retourner</title>

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

<!-- Feuille de style & Script pour le menu -->

<script language="JavaScript" src="../jscript/coolmenus/coolmenus4.js"></script>

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

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

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

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

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscript/jscal/lang/calendar-<?PHP echo $_SESSION["lng"]; ?>.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="../jscript/jscal/calendar-setup.js"></script>
<!-- Fin de la définition Javascript pour calendrier popup -->


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


<?PHP 
if (($td == "edit")  OR ($td=="add"))
{
?>
<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:datecreaf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date demande ; stok:frmok ; stbad:frmbad",
<?PHP if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) { ?>
	"nom:codeage; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> demandeuse ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP } ?>	
	"nom:des; format:txt ; req:Y ; txt:Code produit distributeur ; lmx:50 ; stok:frmok ; stbad:frmbad",
	"nom:ns; format:txt ; req:Y ; txt:Numéro de série; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:nint; format:txt ; req:N ; txt:Numéro interne; lmx:50 ; stok:frmok ; stbad:frmbad",
	"nom:gar; format:liste ; req:Y ; txt:Sous garantie ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:pbm; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_lib); ?> problème ; stok:frmok ; stbad:frmbad",
	"nom:blf; format:liste ; req:Y ; txt:Type de document ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:nblf; format:txt ; req:Y ; txt:Numéro de document ; lmx:20 ; stok:frmok ; stbad:frmbad",
	"nom:dblf; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date document; stok:frmok ; stbad:frmbad",
	"nom:codeint; format:liste ; req:Y ; txt:Intervention concernée ; vmn:1 ; stok:frmok ; stbad:frmbad");
//-->
</script>
<?PHP
}
?>

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

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

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

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

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

<!-- Scripts Ajax -->
<script type="text/javascript" src="../ajax/util.js"></script>
<script type="text/javascript" src="../ajax/SelectUpdater.js"></script>
<script type="text/javascript" src="../ajax/SelectUpdater2.js"></script>

<?PHP if (($td=="add") OR ($td=="edit")) { ?>
<script type="text/javascript">
<!--        
function updateint()
{
	intUpdater = new SelectUpdater2("codeint", "<?PHP echo $rep_appli.'/ajax/'; ?>recupint.php?age=", "attn", "msg", "<?PHP echo $msg_err_int; ?>", "--- Merci de choisir une agence ---");
	anciencodeage = "";
	document.getElementById("codeage").onchange = function() {
		var listeage = document.getElementById("codeage");
		var codeage = listeage.options[listeage.selectedIndex].value;
		if (codeage.length > 0)
		{
			if (codeage != anciencodeage)
			{
				// Faire l'appel Ajax
				intUpdater.run(codeage);
				anciencodeage = codeage;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			intUpdater.reset();
			anciencodeage = "";
		}
	}
}
//-->
</script>
<?PHP } ?>

</head>

<?PHP
switch ($td)
{
case "del" :
case "view" :
	echo '<body onLoad="metReadonly();updateint(document.retp_maj.codeage.selectedIndex);">';
	break;
default :
	echo '<body onLoad="metFocus();updateint(document.retp_maj.codeage.selectedIndex);">';
	break;
}
	
include_once("../inc/entete.inc.php"); 
?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<!-- Affiché uniquement s'il y a au moins un distributeur -->
<?PHP
if ($pbm_retp == FALSE)
{
?>
<table width="100%"  border="0">
<tr>
	<td width="40%"><strong><em><a href="retp_lst.php?ord=DES&tri=Code"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong></td>
	<td width="160" valign="top">
	<div id="oblig" align="center" class="annot_petit_it">(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>)</div>
	</td>
	<td width="40%" align="right">
	<?PHP  if (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) AND ($td=="edit")) { ?>
	<a href="retd_maj.php?td=add&cpr=<?PHP echo $retp_code; ?>">Demande de retour</a></em></strong>
	<?PHP } else echo "&nbsp;" ?>
    </td>
</tr>
</table>
<form name="retp_maj" method="post" action="retp_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'','<?PHP echo $_SESSION["lng"]; ?>'));">
<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
<input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
<input name="codeenv" type="hidden" id="codeenv" value="<?PHP echo $retp_codeenv ?>">
<input name="cm" type="hidden" id="cm" value="<?PHP echo $cm ?>">
<?PHP if ($td == "add") { ?>
	<input name="code" type="hidden" id="code" value="<?PHP echo $retp_code ?>">
<?PHP } ?>

<!-- Code de de la fiche (affiché uniquement si édition ou suppression) -->
<?PHP if ($td <> "add") {?>
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_coderetp" align="right">Code </td>
	<td>
		<input name="code" type="text" id="code" value="<?PHP echo $retp_code ?>" size="20" maxlength="20" readonly="1">
	<?PHP if (clos_retr($retp_code,TRUE)==TRUE)
	{
		echo "<span class=\"alerte1\">";
		echo "Trait&eacute;";
		echo "</span>";
	} 
	else
	{
		if (exist_enr_rete($retp_code,TRUE)==TRUE)
		{
			echo "<span class=\"alerte1\">";
			if (exist_enr_rete_clos($retp_code,TRUE)==TRUE)
				echo "Envoy&eacute;";
			else
				echo "Pr&ecirc;t &agrave; partir";
			echo "</span>";
		}
		else
		{
			if (exist_enr_retd($retp_code,TRUE)==TRUE)
			{
				echo "<span class=\"alerte1\">";
				echo "Demande envoy&eacute;e";
				echo "</span>";
			}
		}
	}
	?>
	</td>
</tr>
</table>
<?PHP }  ?>

<!-- Date de demande -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datecreaf" align="right">Date Demande </td>
	<td>
		<input name="datecreaf" type="text" id="datecreaf" value="<?PHP echo $retp_datecreaf ?>" size="10" maxlength="10" readonly="1">
		<?PHP if ($td == "add") { ?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_datecreaf" title="<?PHP echo $alt_chxdate; ?>">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP } ?>
	</td>
</tr>
</table>

<!-- Code de l'agence (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_agence" align="right">Agence demandeuse</td>
	<td>
		<?PHP
		if (($td == "add") OR ($td == "edit")) // Ajout/Edition = zone modifiable (on peut choisir une agence)
		{ 
			if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
			{
				// Création de la liste des agences ouvertes et couvrant le département du client
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				// Filtre sur agences ouvertes
				$rech = "SELECT * FROM ".TBAGE." WHERE `age_ouvert` = '1' ORDER BY age_nom";
				$rs = mysql_query($rech) or die(mysql_error());
	
				if (mysql_num_rows($rs) <> 0)
				{
				?>
					<select name="codeage" id="codeage">
					<?PHP
						echo "<option value=\"\">".$sel_lst_age."</option>";

						while ($resultat = mysql_fetch_array($rs)) 
						{
							extract($resultat);
			
							$age_nomcode = $age_nom." (".$age_code.")";
							echo '<option value="'.$age_code.'"';
							if ($retp_codeage == $age_code)
								echo ' selected';
							echo '>'.$age_nomcode.'</option>';
						}
					?>
					</select>
					<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
				<?PHP
				}
				else
				{
				?>
					<select name="codeage" id="codeage">
					<option>-- Pas d'agence active --</option>
					</select>
				<?PHP
				}
				mysql_free_result($rs);
				mysql_close($conn);
			}
			else
			{
				$row = lit_enr_age(@$_SESSION["code_age"],TRUE);
				if (is_array($row))
					extract($row);
				$age_nomcode = $age_nom." (".$age_code.")";
			?>
				<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $age_code ?>">
				<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nomcode ?>" size="50" maxlength="50" readonly="1">
			<?PHP
			}
		} 
		else  // Edition ou suppression = zone non modifiable (affichage seul)
		{
			$row = lit_enr_age($retp_codeage,TRUE);
			if (is_array($row))
				extract($row);
			$age_nomcode = $age_nom." (".$age_code.")";
		?>
		<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $retp_codeage ?>">	
		<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nomcode ?>" size="50" maxlength="50" readonly="1">
		<?PHP 
		} 
		?>
	</td>
</tr>
</table>

<!-- Désignation du produit -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_des" align="right"><?PHP echo $txt_chp_lib; ?></td>
	<td>
		<input name="des" type="text" id="des" value="<?PHP echo $retp_des ?>" size="50" maxlength="50"  onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
</table>

<!-- N° de série -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_ns" align="right">N° s&eacute;rie</td>
	<td>
		<input name="ns" type="text" id="ns" value="<?PHP echo $retp_ns ?>" size="40" maxlength="40">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
</table>

<!-- N° interne -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_nint" align="right">N° interne</td>
	<td>
		<input name="nint" type="text" id="nint" value="<?PHP echo $retp_nint ?>" size="50" maxlength="50">
		<br><span class="annot_petit_it">(Code interne de marquage du produit)</span>
	</td>
</tr>
</table>

<!-- Problème -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_pbm" align="right">Probl&egrave;me</td>
	<td>
		<?PHP
		if (($td == "add") OR ($td == "edit"))
		{
		?>
		<textarea name="pbm" rows="5" id="pbm"><?PHP echo htmlspecialchars($retp_pbm,ENT_QUOTES); ?></textarea>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP
		}
		else
		{
		?>
		<textarea name="pbm" rows="5" id="pbm" readonly="readonly"><?PHP echo htmlspecialchars($retp_pbm,ENT_QUOTES); ?></textarea>
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- BL ou Facture ? -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_blf" align="right">Document client</td>
	<td>
	<?PHP
	if (($td =="add") OR ($td =="edit"))  // Ajout/Edition = zone modifiable (on peut choisir un type)
	{ 
	?>
		<select name="blf" id="blf">
		<option>-- Choisissez le type --</option>
		<?PHP
		foreach ($doc_types as $key=>$value)
		{
			echo '<option value="'.$key.'"'; 
			if (($retp_blf == $key) AND (trim($retp_blf)<>""))
				echo ' selected';
			echo '>';
			echo $value."</option>";
		}
		?>
		</select>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<br><span class="annot_petit_it">(Type du document d'origine)</span>
	<?PHP
	}
	else
	{
	?>
	<input name="blf" type="hidden" id="blf" value="<?PHP echo $retp_blf; ?>">
	<input name="nomblf" type="text" id="nomblf" value="<?PHP echo $doc_types[$retp_blf]; ?>" size="20" maxlength="20" readonly="readonly">
	<?PHP
	}
	?>
	</td>
</tr>
</table>

<!-- N° de BL ou de facture -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_nblf" align="right">N° document</td>
	<td>
		<input name="nblf" type="text" id="nblf" value="<?PHP echo $retp_nblf ?>" size="20" maxlength="20">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
</table>

<!-- Date du document -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_dblf" align="right">Date document</td>
	<td>
		<input name="dblf" type="text" id="dblf" value="<?PHP echo $retp_dblff ?>" size="10" maxlength="10" readonly="1">
		<?PHP if (($td == "add") OR ($td=="edit")) { ?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_dblf" title="<?PHP echo $alt_chxdate; ?>">
		<?PHP } ?>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
</table>

<!-- Sous garantie ?-->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_gar" align="right">Garantie client?</td>
	<td>
	<?PHP
	if (($td =="add") OR ($td =="edit"))  // Ajout/Edition = zone modifiable (on peut choisir la garantie)
	{ 
	?>
		<select name="gar" id="gar">
		<option>-- Choisissez si garanti --</option>
		<?PHP
		foreach ($non_oui as $key=>$value)
		{
			echo '<option value="'.$key.'"'; 
			if (($td=="edit") AND ($retp_gar == $key))
				echo ' selected';
			echo '>';
			echo $value."</option>";
		}
		?>
		</select>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	}
	else
	{
	?>
	<input name="gar" type="hidden" id="gar" value="<?PHP echo $retp_gar; ?>">
	<input name="ngar" type="text" id="ngar" value="<?PHP echo $non_oui[$retp_gar]; ?>" size="3" maxlength="3" readonly="readonly">
	<?PHP
	}
	?>
	</td>
</tr>
</table>

<!-- Intervention éventuellement concernée (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_codeint" align="right">Intervention</td>
	<td>
		<?PHP
		if (($td =="add") OR ($td =="edit"))  // Ajout/Edition = zone modifiable (on peut choisir une intervention)
		{
			echo '<select name="codeint" id="codeint">';
			// Création de la liste des interventions non terminées
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM ".TBINT." WHERE `int_datefin` = '0000-00-00' AND `int_codeage` = '".$retp_codeage."'";
			// Filtre sur l'agence (si nécessaire)
			if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
				$rech.= " AND `int_codeage` = '".@$_SESSION["code_age"]."'";
			$rech.=" ORDER BY int_code";
			$rs = mysql_query($rech) or die(mysql_error());
			echo "<option>-- Choisissez l'intervention  rattachée à ce problème --</option>";
			echo "<option value=\"-1\"";
			if ($retp_codeint == "-1")
				echo ' selected';
			echo">-- Pas d'intervention concernée --</option>";

			if (mysql_num_rows($rs) <> 0)
			{
					while ($resultat = mysql_fetch_array($rs)) 
					{
						extract($resultat);
		
						$txt_int = $int_code." (client : ".$int_codecli.")";
						echo '<option value="'.$int_code.'"';
						if ($retp_codeint == $int_code)
							echo ' selected';
						echo '>'.$txt_int.'</option>';
					}
			}
			mysql_free_result($rs);
			mysql_close($conn);
			echo '</select>';
		?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
			<span id="attn"></span><span id="msg" style="background-color:#FF0000; color:#FFFF00; font-weight:bold"></span>
		<?PHP
		} 
		else  // Suppression = zone non modifiable (affichage seul)
		{
			$txt_int="";
			if ($retp_codeint <> "-1")
			{
				$row = lit_enr_int($retp_codeint);
				if (is_array($row))
					extract($row);
				$txt_int = $int_code." (client : ".$int_codecli.")";
			}
			else
				$txt_int = "Pas d'intervention concern&eacute;e";
		?>
		<input name="codeint" type="hidden" id="codeint" value="<?PHP echo $retp_codeint ?>" size="20" maxlength="20" readonly="1">
		<input name="nomint" type="text" id="nomint" value="<?PHP echo $txt_int ?>" size="40" maxlength="40" readonly="1">
		<?PHP 
		} 
		?>
	</td>
</tr>
</table>

<p align="center">
<?PHP
if (($td == "edit") OR ($td == "add"))
{
?>
	<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
	<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_enr; ?>">
	<?PHP if (trim($cm)<>"") { ?>
	<input name="enrd" type="submit" class="bton_std" id="enrd" value="<?PHP echo $but_enrdder; ?>">
	<?PHP } ?>
<?PHP
}
if ($td == "del") // Bouton si en mode suppression
{ 
?>
	<input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
<?PHP 
} 
?>
</p>
</form>
<?PHP 
	if (($td <> "view") AND ($td<>"del"))
	{
	?>
		<script type="text/javascript">
		<!--
		<?PHP
		if ($td=="add")
		{
		?>
		Calendar.setup({
			inputField     :    "datecreaf",     // id of the input field
			ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
			button         :    "f_img_datecreaf",  // trigger for the calendar (button ID)
			align          :    "Br",           // alignment (defaults to "Bl")
			electric	   :	false,
			singleClick    :    true
		});
		<?PHP
		}
	
		if (($td=="add") OR ($td=="edit"))
		{
		?>
		Calendar.setup({
			inputField     :    "dblf",     // id of the input field
			ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
			button         :    "f_img_dblf",  // trigger for the calendar (button ID)
			align          :    "Br",           // alignment (defaults to "Bl")
			electric	   :	false,
			singleClick    :    true
		});
		<?PHP
		}
		?>
		//-->
		</script>
<?PHP
	}
}
else
{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('index.php');",2000)
	//-->
	</script>
	<p align="center" class="annot_std_it">Probl&egrave;me de param&egrave;tres</p>
<?PHP
}
include_once("pied.php");
?>
