<?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_time.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
	$typdde = strip_tags(trim(@$_GET['td']));
	$codeint = strip_tags(trim(@$_GET['ci']));
	$id = strip_tags(trim(@$_GET['id']));

	if ($typdde == "")
		$typdde = strip_tags(trim(@$_POST['td']));
	if ($codeint == "")
		$codeint = strip_tags(trim(@$_POST['ci']));
	if ($id == "")
		$id = strip_tags(trim(@$_POST['id']));

	if (@$HTTP_SESSION_VARS["niv_log"] == 1)
		$typdde = "view";

	$pbm_inth = FALSE;
	$pbm_enr_inth = FALSE;

	if ($codeint <> "")
	{
		$row = lit_enr_int($codeint);
		if (is_array($row))
			extract($row);
		if (formatedate($int_datefin) <> "")
			$typdde = "view";
		if (((@$HTTP_SESSION_VARS["niv_log"] == 4) OR (@$HTTP_SESSION_VARS["niv_log"] == 3)) AND ($int_codeage <> @$HTTP_SESSION_VARS["code_age"]))
			$pbm_inth = TRUE;
			
		if (((strip_tags(trim(@$_POST["enr"])) == "Ajouter") OR (strip_tags(trim(@$_POST["enr"])) == "Modifier")) AND ($pbm_inth == FALSE))
		{
			$id = strip_tags(trim(@$_POST["id"]));
			$datef = strip_tags(trim(@$_POST["date"]));
			if ($datef <> "")
				$date = datefrang($datef);
			else
				$date ="";
			$codetec = strip_tags(trim(@$_POST["codetec"]));
			$codelieu = strip_tags(trim(@$_POST["codelieu"]));
			$heurea = strip_tags(trim(@$_POST["heurea"]));
			$heured = strip_tags(trim(@$_POST["heured"]));
			$offert = 0;
			if (strtolower(strip_tags(trim(@$_POST["offert"]))) == "on")
				$offert = 1;
			
			if (($date <> "") AND ($codelieu <> "") AND ($codetec <> "") AND ($heurea <> "") AND (heurea <> "00:00:00") AND ($heured <> "") AND (heured <> "00:00:00"))
			{
				if (heure_sec($heured)>heure_sec($heurea))
				{
					$codeuser = @$HTTP_SESSION_VARS["code_log"];
			
					$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
					if (strip_tags(trim(@$_POST["enr"])) == "Ajouter")
					{
						$rech = "INSERT INTO " .TBINTH;
						$rech .= " (inth_datecrea,inth_codecrea,inth_datemod,inth_codemod,inth_codeint,inth_date,inth_codetec,inth_codelieu,inth_heurea,inth_heured,inth_offert) VALUES";
						$rech .= " ('$datea','$codeuser','$datea','$codeuser','$codeint','$date','$codetec','$codelieu','$heurea','$heured','$offert')";
					}
					if (strip_tags(trim(@$_POST["enr"])) == "Modifier")
					{
						if ($id <> "")
						{
							$rech = "UPDATE `" .TBINTH;
							$rech .= "` SET `inth_datemod`='".$datea."',`inth_codemod`='".$codeuser."', `inth_date`='".$date."', `inth_codetec`='".$codetec."', `inth_codelieu`='".$codelieu."', `inth_heurea`='".$heurea."', `inth_heured`='".$heured."', `inth_offert`='".$offert."'  WHERE `inth_id` = '".$id."'";
						}
					}
					$rs = mysql_query($rech) or die(mysql_error());
					mysql_close($conn);
					$typdde ="add";
				}
				else
				{
					$pbm_enr_inth = TRUE;
					$msg = "Problème sur les heures choisies.";
				}
			}
			else
			{
				$pbm_enr_inth = TRUE;
				$msg = "Merci de compléter les champs obligatoires.";
			}
		}
		else
		{
			if ((strip_tags(trim(@$_POST["enr"])) == "Supprimer") AND ($pbm_inth == FALSE))
			{
				if ($id <> "")
				{
					$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
					$rech = "DELETE FROM `" .TBINTH. "` WHERE `inth_id` = '$id'";
					$rs = mysql_query($rech) or die(mysql_error());
					mysql_close($conn);
				}
				$typdde ="add";
			}
		}
	}
	else
	{
		$pbm_inth = TRUE;
	}
	
	if ($pbm_inth == FALSE)
	{
		if ($typdde == "add")
		{
			$inth_heurea = "00:00:00";
			$inth_heured = "00:00:00";
			$titre = "Ajouter Détail horaire";
		}
		if ($typdde == "edit")
		{
			if ($id <> "")
			{
				$row = lit_enr_inth($id);
				if (is_array($row))
					extract($row);
					
				$datef = datefr($inth_date);	
			}
			$titre = "Editer Détail horaire";
		}
		if ($typdde == "view")
		{
			if ($id <> "")
			{
				$row = lit_enr_inth($id);
				if (is_array($row))
					extract($row);
					
				$datef = datefr($inth_date);	
			}
			$titre = "Voir Détail horaire";
		}
		if ($typdde == "del")
		{
			if ($id <> "")
			{
				$row = lit_enr_inth($id);
				if (is_array($row))
					extract($row);
					
				$datef = datefr($inth_date);	
			}
	
			$titre = "Supprimer Détail horaire";
		}
	
		// Récupération du total travaillé & Techniciens traitants
		$nbtotalsec = 0;
		$nbtotalsecoff = 0;
		$str_tec_traitants = "";
		if (($typdde == "add") OR ($typdde == "edit") OR ($typdde == "view") OR ($typdde == "del"))
		{
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
	
			// Récupération total travaillé
			$rech = "SELECT * FROM `" .TBINTH. "` WHERE `inth_codeint`= '".$codeint."'";
			$rs = mysql_query($rech);
			if (mysql_num_rows($rs) <> 0)
			{
				while ($row = mysql_fetch_assoc($rs)) 
				{         
					if ($row["inth_offert"] == 0)
						$nbtotalsec = $nbtotalsec + diff_time_sec($row["inth_heurea"],$row["inth_heured"]);
					else
						$nbtotalsecoff = $nbtotalsecoff + diff_time_sec($row["inth_heurea"],$row["inth_heured"]);
				}
			}
	
			// Chaîne des techniciens traitants
			$rech = "SELECT DISTINCT inth_codetec FROM `" .TBINTH. "` WHERE `inth_codeint`= '".$codeint."'";
			$rs = mysql_query($rech);
			if (mysql_num_rows($rs) <> 0)
			{
				while ($row = mysql_fetch_assoc($rs)) 
				{
					$rech2 = "SELECT tec_nom, tec_prenom FROM `" .TBTEC. "` WHERE `tec_code`= '".$row["inth_codetec"]."' ORDER BY tec_nom";
					$rs2 = mysql_query($rech2);
					if (mysql_num_rows($rs2) <> 0)
					{
						if ($row2 = mysql_fetch_assoc($rs2))
							$str_tec_traitants .= $row2["tec_nom"]." ".$row2["tec_prenom"].", ";
					}
					mysql_free_result($rs2);
				}
			}
			$str_tec_traitants = substr($str_tec_traitants,0,strlen($str_tec_traitants)-2).".";
			mysql_free_result($rs);
			mysql_close($conn);
		}	
	}
?>

<!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 : D&eacute;tail Horaire Intervention</title>

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

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

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

</head>

<?PHP 
if ($typdde <> "edit")
{
	if ($pbm_inth == FALSE)
	{
?>
		<body onLoad="javascript:; window.focus();" onBlur="javascript:; window.opener.document.int_maj.duree.value='<?PHP echo sec_heure($nbtotalsec); ?>'; window.opener.document.int_maj.dureeoff.value='<?PHP echo sec_heure($nbtotalsecoff); ?>'; window.opener.document.int_maj.tect.value='<?PHP echo $str_tec_traitants; ?>';">
<?PHP
	}
	else
	{
?>
		<body>
<?PHP
	}
}
else
{
?>
	<body onLoad="javascript:; window.focus();" onBlur="javascript:; window.opener.document.int_maj.duree.value='<?PHP echo sec_heure($nbtotalsec); ?>'; window.opener.document.int_maj.dureeoff.value='<?PHP echo sec_heure($nbtotalsecoff); ?>'; window.opener.document.int_maj.tect.value='<?PHP echo $str_tec_traitants; ?>';">
<?PHP
}
?>

<?PHP
if (($pbm_inth == FALSE) AND ($pbm_enr_inth == FALSE))
{
?>
	<p align="center"> <span class="titrepage">DETAIL HORAIRE</span></p>
	<p align="center"><span class="titre_gras">Pour l'intervention : <?php echo $codeint; ?> </span></p>
	
	<p>
	  <?PHP
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM `" .TBINTH. "` WHERE `inth_codeint`= '".$codeint."' ORDER BY inth_date, inth_heurea";
		
		$rs = mysql_query($rech);
		
		if (mysql_num_rows($rs) <> 0)
		{
		
			echo "<table class=\"MtableD\" border=\"0\" width=\"890\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
			 
			// Création de l'entête de la table "relevés de problèmes"
			echo "<th>";
			echo "Date";
			echo "</th>\n";
			echo "<th>";
			echo "Technicien";
			echo "</th>\n";
			echo "<th>";
			echo "Lieu";
			echo "</th>\n";
			echo "<th>";
			echo "Heure début";
			echo "</th>\n";
			echo "<th>";
			echo "Heure fin";
			echo "</th>\n";
			echo "<th>";
			echo "Temps passé";
			echo "</th>\n";
			echo "<th>";
			echo "Offert ?";
			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["inth_date"]);
				echo "<td>\n";
				echo $row["inth_codetec"];
				// Récupération et affichage détail technicien
				$rech2 = "SELECT * FROM `" .TBTEC. "` WHERE `tec_code`= '".$row["inth_codetec"]."'";
				$rs2 = mysql_query($rech2);
				if (mysql_num_rows($rs2) <> 0)
				{
					if ($row2 = mysql_fetch_assoc($rs2)) 
					{
						extract($row2);
						echo "<br>";
						echo "<span class=\"annot_petit_it\">";
						echo $tec_nom." ".$tec_prenom;
						echo "</span>";
					}
				}
				else
					echo "&nbsp;";
				echo "</td>\n";
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				// Récupération et affichage libellé lieu
				$rech2 = "SELECT * FROM `" .TBLIEU. "` WHERE `lieu_code`= '".$row["inth_codelieu"]."'";
				$rs2 = mysql_query($rech2);
				if (mysql_num_rows($rs2) <> 0)
				{
					if ($row2 = mysql_fetch_assoc($rs2)) 
					{
						extract($row2);
						echo $lieu_desc;
					}
				}
				else
					echo "&nbsp;";
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				echo $row["inth_heurea"];
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				echo $row["inth_heured"];
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				echo sec_heure(diff_time_sec($row["inth_heurea"],$row["inth_heured"]));
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				if ($row["inth_offert"] == 1)
					echo "Oui";
				else
					echo "-";
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				if ($typdde <> "view")
				{
					$lst_maj = TRUE;
			
					echo "<a href=\"inth_maj.php?td=edit&ci=".$codeint."&id=".$row["inth_id"]."\"><img src=\"../img/edit.png\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
					echo " ";
	
					$lst_del = TRUE;
		
					echo "<a href=\"inth_maj.php?td=del&ci=".$codeint."&id=".$row["inth_id"]."\"><img src=\"../img/del.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
				}
				else
					echo "-";
				echo "</td>\n";

				echo "</tr>\n";
			
				$j++;
			}
			
			/* Totaux */
			
			// Total Général

			// Création de l'entête de ligne (TR)
			creetrlstdet($j);

			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td align=\"right\">";
			echo "<span class=\"annot_std_gras\">";
			echo "Temps total : ";
			echo "</span>";
			echo "</td>\n";
			echo "<td align=\"center\">";
			echo "<span class=\"annot_std_gras\">";
			echo sec_heure($nbtotalsec+$nbtotalsecoff);
			echo "</span>";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";

			// Temps offert

			// Création de l'entête de ligne (TR)
			$j++;
			creetrlstdet($j);

			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td align=\"right\">";
			echo "<span class=\"annot_std_gras\">";
			echo "Temps offert : ";
			echo "</span>";
			echo "</td>\n";
			echo "<td align=\"center\">";
			if ($nbtotalsecoff <> 0)
			{
				echo "<span class=\"annot_std_gras\">";
				echo sec_heure($nbtotalsecoff);
				echo "</span>";
			}
			else
				echo "-";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";

			// Temps retenu

			// Création de l'entête de ligne (TR)
			$j++;
			creetrlstdet($j);

			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td align=\"right\">";
			echo "<span class=\"annot_std_gras\">";
			echo "Temps retenu : ";
			echo "</span>";
			echo "</td>\n";
			echo "<td align=\"center\">";
			echo "<span class=\"annot_std_gras\">";
			echo sec_heure($nbtotalsec);
			echo "</span>";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";
			echo "<td>";
			echo "&nbsp;";
			echo "</td>\n";

			echo "</table>\n";
			// Fin affichage table détails licences
			
		}
		else
		{
		?>
			<p class="annot_petit_it">Aucun d&eacute;tail horaire enregistr&eacute; </p>
			<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);

		include_once ("piedla.php"); 
	?>
	</p>
	<?PHP 
	if ($typdde <> "view")
	{
	?>
		<br>
		<form name="inth_maj" class="form_pointilles" method="post" action="inth_maj.php" onsubmit="return v.exec()">
		<p align="center" class="annot_std_gras"><?PHP echo $titre; ?></p>
		<p align="center" class="annot_petit_it">Tous les champs sont obligatoires</p>
			<input name="td" type="hidden" id="td" value="<?PHP echo $typdde; ?>">
			<input name="ci" type="hidden" id="ci" value="<?PHP echo $codeint; ?>">
			<input name="id" type="hidden" id="id" value="<?PHP echo $id; ?>">
			<table width="580"  border="0" align="center">
				<tr>
					<td width="30%" class="tfvNormal" id="f_date" align="right">
						Date
					</td>
					<td align="left">
						<input name="date" type="text" id="date" value="<?PHP echo $datef; ?>" size="10" maxlength="10" readonly="1">
						<img src="../img/calendar.png" id="f_img_date" title="Choisir votre date" width="16" height="16">
						<a href="javascript:;" onclick="document.inth_maj.date.value=''"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a>
					</td>
				</tr>
				<tr>
					<td width="30%" class="tfvNormal" id="f_tec" align="right">
						Technicien
					</td>
					<td align="left">
					<?PHP
						
						// Création de la liste des Techniciens
						
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
						$rech = "SELECT int_codeage FROM ".TBINT." WHERE `int_code` =  '".$codeint."'";
						$rs = mysql_query($rech);
						
						if (mysql_num_rows($rs) >0)
						{
							if ($row = mysql_fetch_array($rs)) 
							{
								extract($row);
								$rech2 = "SELECT * FROM ".TBTEC." WHERE `tec_codeage`= '".$int_codeage."' AND `tec_out` = '0' ORDER BY tec_nom";
								$rs2 = mysql_query($rech2);
						
								if (mysql_num_rows($rs2) >0)
								{
								?>
									<select name="codetec" id="codetec">
								<?PHP
									$i=0;
							
									while ($resultat = mysql_fetch_array($rs2)) 
									{
										extract($resultat);
							
										if ($i == 0)
										{
											if ($int_codelieu <> "")
												echo "<option value=\"\">-- Choisissez un technicien --</option>";
											else
												echo "<option value=\"\" selected>-- Choisissez un technicien --</option>";
										}
							
										$txt_tec = $tec_nom." ".$tec_prenom;
										
										if ($inth_codetec == $tec_code)
											echo '<option value="'.$tec_code.'" selected>'.$txt_tec.'</option>';
										else
											echo '<option value="'.$tec_code.'">'.$txt_tec.'</option>';
										
										$i++;
									}
								?>
									</select>
								<?PHP
								}
								else
								{
									echo "<span class=\"annot_std_it\">";
									echo "Pas de technicien actif sur cette agence.";
									echo "</span>";
								}
							}
						}
						mysql_free_result($rs);
						mysql_close($conn);
					?>
					</td>
				</tr>
				<tr>
					<td width="30%" class="tfvNormal" id="f_lieu" align="right">
						Lieu
					</td>
					<td align="left">
					<select name="codelieu" id="codelieu">
					<?PHP
						
						// Création de la liste des Lieux
						
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
						$rech = "SELECT * FROM ".TBLIEU." ORDER BY lieu_desc";
						$rs = mysql_query($rech);
				
						$i=0;
				
						while ($resultat = mysql_fetch_array($rs)) 
						{
							extract($resultat);
				
							if ($i == 0)
							{
								if ($int_codelieu <> "")
									echo "<option value=\"\">-- Choisissez un lieu --</option>";
								else
									echo "<option value=\"\" selected>-- Choisissez un lieu --</option>";
							}
				
							if ($inth_codelieu == $lieu_code)
								echo '<option value="'.$lieu_code.'" selected>'.$lieu_desc.'</option>';
							else
								echo '<option value="'.$lieu_code.'">'.$lieu_desc.'</option>';
							
							$i++;
						}
						mysql_free_result($rs);
						mysql_close($conn);
					?>
					  </select>
					</td>
				</tr>
				<tr>
					<td width="30%" class="tfvNormal" id="f_horaires" align="right">
						Horaires
					</td>
					<td align="left">
						 D&eacute;but 
						 <input name="heurea" type="text" id="heurea" value="<?PHP echo $inth_heurea ?>" size="8" maxlength="8">
						<a href="javascript:;" onclick="document.inth_maj.heurea.value='00:00:00'"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a>
						/ Fin 
						<input name="heured" type="text" id="heured" value="<?PHP echo $inth_heured ?>" size="8" maxlength="8">
						<a href="javascript:;" onclick="document.inth_maj.heured.value='00:00:00'"><img src="../img/raz.gif" width="12" height="12" border="0" align="absmiddle"></a>
						<span class="annot_petit_it">
						 (hh:mm:ss)
						</span>
					</td>
				</tr>
				<tr>
					<td width="30%" class="tfvNormal" id="f_offert" align="right">
						Offert
					</td>
					<td align="left">
					<?PHP if ($inth_offert == 1)
					{
					?>
						<input type="checkbox" name="offert" style="background : #FFFFFF;" checked>
					<?PHP
					}
					else
					{
					?>
						<input type="checkbox" name="offert" style="background : #FFFFFF;">
					<?PHP
					}
					?>
					</td>
				</tr>
			</table>
			<p align="center">
			<input name="annul" type="button" id="annul" value="Annuler" onclick="javascript:; self.location.href='inth_maj.php?ci=<?PHP echo $codeint; ?>';">
			<?PHP
				if ($typdde == "add")
				{
			?>
					<input name="enr" type="submit" id="enr" value="Ajouter">
			<?PHP
				}
				if ($typdde == "edit")
				{
			?>
					<input name="enr" type="submit" id="enr" value="Modifier">
			<?PHP
				}
				if ($typdde == "del")
				{
			?>
				<input name="enr" type="submit" id="enr" value="Supprimer">
			<?PHP
				}
			?>
				<input name="quit" type="button" id="quit" value="Quitter" onclick="javascript:; self.close('fscomp');">
			</p>
		</form>
		
		<script type="text/javascript">
			Calendar.setup({
				inputField     :    "date",     	// id of the input field
				ifFormat       :    "%d-%m-%Y",     // format of the input field
				button         :    "f_img_date",  	// trigger for the calendar (button ID)
				align          :    "Ll",           // alignment (defaults to "Bl")
				singleClick    :    true
			});
		</script>
<?PHP
	}
}
else
{
	if ($pbm_inth == TRUE)
	{
?>
		<script type="text/javascript">
		self.close('fscomp');
		</script>
<?PHP
	}
	if ($pbm_enr_inth == TRUE)
	{
?>
		<p align="center" class="annot_std_it"><?PHP echo $msg; ?></p>
		<script type="text/javascript">
		window.setTimeout("location=('inth_maj.php?ci=<?PHP echo $codeint; ?>&td=<?PHP echo $typdde; ?>&id=<?PHP echo $id; ?>');",3000)
		</script>
<?PHP
	}
}
?>
</body>
</html>
