<?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_ot.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");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);

$codeot = strip_tags(trim(@$_GET['co']));
if ($codeot == "")
	$codeot = strip_tags(trim(@$_POST['co']));
$td = strip_tags(trim(@$_GET['td']));
if ($td=="")
	$td = strip_tags(trim(@$_POST['td']));
$id = strip_tags(trim(@$_GET['id']));

$pbm_oth = FALSE;
$pbm_enr_oth = FALSE;

if ($codeot <> "")
{
	$row = lit_enr_ot($codeot);
	if (is_array($row))
		extract($row);
	else
		$pbm_oth=TRUE;

	// Si pas d'enregistrement de détail horaire, on ne peut que ajouter
	if ((nb_oth($codeot)==0) AND ((@$_SESSION["niv_log"] == 10) OR (@$_SESSION["niv_log"] == 11)  OR (@$_SESSION["niv_log"] == 9)))
		$td = "add";
		
	// Si intervention close ou si client/donneurs d'ordres, on ne peut que voir
	if (formatedate($ot_datefin) <> "")
		$td = "view";

	// Vérification tentative de hack d'un sous-traitant
	if (((@$_SESSION["niv_log"] == 10) OR (@$_SESSION["niv_log"] == 11)) AND ($ot_codest <> @$_SESSION["code_st"]))
		$pbm_oth = TRUE;
}
else
	$pbm_oth=TRUE;

if ($pbm_oth == FALSE)
{
	if ($id=="")
		$id = strip_tags(trim(@$_POST["id"]));

	if (((strip_tags(trim(@$_POST["enr"])) == html_entity_decode($but_add)) OR (strip_tags(trim(@$_POST["enr"])) == html_entity_decode($but_modif))))
	{
		$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"]));
		$heurea_full = $heurea.":00";
		$heured = strip_tags(trim(@$_POST["heured"]));
		$heured_full = $heured.":00";
		$offert = 0;
		if (strtolower(strip_tags(trim(@$_POST["offert"]))) == "on")
			$offert = 1;
		
		if (($date <> "") AND ($codelieu <> "") AND ($codetec <> "") AND ($heurea <> "") AND ($heured <> ""))
		{
			if (heure_sec($heured_full)>=heure_sec($heurea_full))
			{
				$codeuser = @$_SESSION["code_log"];
		
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				if (strip_tags(trim(@$_POST["enr"])) == html_entity_decode($but_add))
				{
					$rech = "INSERT INTO " .TBOTH;
					$rech .= " (oth_datecrea,oth_codecrea,oth_datemod,oth_codemod,oth_codeot,oth_date,oth_codetec,oth_codelieu,oth_heurea,oth_heured,oth_offert) VALUES";
					$rech .= " ('$datea','$codeuser','$datea','$codeuser','$codeot','$date','$codetec','$codelieu','$heurea_full','$heured_full','$offert')";
				}
				if (strip_tags(trim(@$_POST["enr"])) == html_entity_decode($but_modif))
				{
					if ($id <> "")
					{
						$rech = "UPDATE `" .TBOTH;
						$rech .= "` SET `oth_datemod`='".$datea."',`oth_codemod`='".$codeuser."', `oth_date`='".$date."', `oth_codetec`='".$codetec."', `oth_codelieu`='".$codelieu."', `oth_heurea`='".$heurea_full."', `oth_heured`='".$heured_full."', `oth_offert`='".$offert."'  WHERE `oth_id` = '".$id."'";
					}
				}
				$rs = mysql_query($rech) or die(mysql_error());
				mysql_close($conn);
				$td ="add";
			}
			else
			{
				$pbm_enr_oth = TRUE;
				$msg = "Problème sur les heures choisies.";
			}
		}
		else
		{
			$pbm_enr_oth = TRUE;
			$msg = "Merci de compléter les champs obligatoires.";
		}
	}
	else
	{
		if (strip_tags(trim(@$_POST["enr"])) == html_entity_decode($but_del))
		{
			if ($id <> "")
			{
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rech = "DELETE FROM `" .TBOTH. "` WHERE `oth_id` = '$id'";
				$rs = mysql_query($rech) or die(mysql_error());
				mysql_close($conn);
			}
			$td ="add";
		}
	}
}

if ($pbm_oth == FALSE)
{
	if ($td == "add")
	{
		$titre = "Ajouter Détail horaire";
	}
	if ($td == "edit")
	{
		if ($id <> "")
		{
			$row = lit_enr_oth($id);
			if (is_array($row))
			{
				extract($row);
				$oth_heurea=substr($oth_heurea,0,5);
				$oth_heured=substr($oth_heured,0,5);
			}	
			$datef = datefr($oth_date);	
		}
		$titre = "Editer Détail horaire";
	}
	if ($td == "view")
	{
		if ($id <> "")
		{
			$row = lit_enr_oth($id);
			if (is_array($row))
			{
				extract($row);
				$oth_heurea=substr($oth_heurea,0,5);
				$oth_heured=substr($oth_heured,0,5);
			}	
			$datef = datefr($oth_date);	
		}
		$titre = "Voir Détail horaire";
	}
	if ($td == "del")
	{
		if ($id <> "")
		{
			$row = lit_enr_oth($id);
			if (is_array($row))
			{
				extract($row);
				$oth_heurea=substr($oth_heurea,0,5);
				$oth_heured=substr($oth_heured,0,5);
			}	
			$datef = datefr($oth_date);	
		}

		$titre = "Supprimer Détail horaire";
	}

	// Récupération du total travaillé & Techniciens traitants
	$nbtotalsec = 0;
	$nbtotalsecoff = 0;
	$str_tec_traitants = "";
	if (($td == "add") OR ($td == "edit") OR ($td == "view") OR ($td == "del"))
	{
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);

		// Récupération total travaillé
		$rech = "SELECT * FROM `" .TBOTH. "` WHERE `oth_codeot`= '".$codeot."'";
		$rs = mysql_query($rech) or die(mysql_error());
		if (mysql_num_rows($rs) <> 0)
		{
			while ($row = mysql_fetch_assoc($rs)) 
			{         
				$nbtotalsec = $nbtotalsec + diff_time_sec($row["oth_heurea"],$row["oth_heured"]);
				if ($row["oth_offert"] == 1)
					$nbtotalsecoff = $nbtotalsecoff + diff_time_sec($row["oth_heurea"],$row["oth_heured"]);
			}
		}

		// Chaîne des techniciens traitants
		$rech = "SELECT DISTINCT oth_codetec FROM `" .TBOTH. "` WHERE `oth_codeot`= '".$codeot."'";
		$rs = mysql_query($rech) or die(mysql_error());
		if (mysql_num_rows($rs) <> 0)
		{
			while ($row = mysql_fetch_assoc($rs)) 
			{
				$rech2 = "SELECT tec_nom, tec_prenom FROM `" .TBTEC. "` WHERE `tec_code`= '".$row["oth_codetec"]."' ORDER BY tec_nom";
				$rs2 = mysql_query($rech2) or die(mysql_error());
				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);
			}
		}
		if ($str_tec_traitants!="")
			$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 - <?PHP echo $title_esp_prive; ?> : D&eacute;tail Horaire Ordre de Travail</title>

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

<!-- Scripts Javascript pour fenêtres -->
<script language="JavaScript" src="../jscript/fen.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>

<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:date ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date ; stok:frmok ; stbad:frmbad",
	"nom:codetec ; format:liste ; req:Y ; txt:Technicien ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:codelieu ; format:liste ; req:Y ; txt:Lieu ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:heurea ; format:liste ; req:Y ; txt:Heure de début ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:heured ; format:liste ; req:Y ; txt:Heure de fin ; vmn:1 ; stok:frmok ; stbad:frmbad");
//-->
</script>

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

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

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

</head>

<?PHP 
if ($td <> "edit")
{
	if ($pbm_oth == FALSE)
	{
?>
		<body onLoad="javascript:; window.focus();">
<?PHP
	}
	else
	{
?>
		<body>
<?PHP
	}
}
else
{
?>
	<body onLoad="javascript:; window.focus();metFocus();">
<?PHP
}
if (($pbm_oth == FALSE) AND ($pbm_enr_oth == FALSE))
{
?>
<p align="center"> <span class="titrepage">DETAIL HORAIRE</span></p>
<p align="center"><span class="titre_gras">Pour l'ordre : <?php echo $codeot; ?> </span></p>
<div align="right">
<input name="quit" type="button" class="bton_std" id="quit" value="<?PHP echo $but_quit; ?>" style="text-decoration: none; font-size: 11px; color:White ;font-weight:bold;background-color: #666666;" onClick="javascript:; self.close();">
</div>
	<p>
	  <?PHP
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM `" .TBOTH. "` WHERE `oth_codeot`= '".$codeot."' ORDER BY oth_date, oth_heurea";
		
		$rs = mysql_query($rech) or die(mysql_error());
		
		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 "détail intervention"
			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 $txt_ent_lst_clic;
			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["oth_date"]);
				echo "<td>\n";
				echo $row["oth_codetec"];
				// Récupération et affichage détail technicien
				$rech2 = "SELECT * FROM `" .TBTEC. "` WHERE `tec_code`= '".$row["oth_codetec"]."'";
				$rs2 = mysql_query($rech2) or die(mysql_error());
				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["oth_codelieu"]."'";
				$rs2 = mysql_query($rech2) or die(mysql_error());
				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 substr($row["oth_heurea"],0,5);
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				echo substr($row["oth_heured"],0,5);
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				echo heure_to_hhmm(sec_heure(diff_time_sec($row["oth_heurea"],$row["oth_heured"])));
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				echo $non_oui2[$row["oth_offert"]];
				echo "</td>\n";
				echo "<td align=\"center\">\n";
				if ($td <> "view")
				{
					$lst_maj = TRUE;
			
					echo "<a href=\"oth_maj.php?td=edit&co=".$codeot."&id=".$row["oth_id"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\"></a>";
					echo " ";
	
					$lst_del = TRUE;
		
					echo "<a href=\"oth_maj.php?td=del&co=".$codeot."&id=".$row["oth_id"]."\"><img src=\"../img/del.png\" 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 heure_to_hhmm(sec_heure($nbtotalsec,3,TRUE));
			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 heure_to_mmm(sec_heure($nbtotalsecoff,3,TRUE));
				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 heure_to_hhmm(sec_heure($nbtotalsec-$nbtotalsecoff,3,TRUE));
			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étail horaire
			
			$pas_horaire=FALSE;
		}
		else
		{
			$pas_horaire=TRUE;
		?>
			<p class="annot_petit_it">Aucun d&eacute;tail horaire enregistr&eacute; </p>
		<?PHP
		}
		mysql_free_result($rs);
		mysql_close($conn);

		$taille_piedla="";
		include_once("piedla.inc.php"); 
	?>
	</p>
	<?PHP 
	if ($td <> "view")
	{
	?>
		<br>
		<form name="oth_maj" class="form_pointilles" method="post" action="oth_maj.php" onSubmit="javascript:; return (verif_oth(this,tab1_champ,'',''));">
		<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 $td; ?>">
			<input name="co" type="hidden" id="co" value="<?PHP echo $codeot; ?>">
			<input name="id" type="hidden" id="id" value="<?PHP echo $id; ?>">
			<table width="580"  border="0" align="center">
				<tr>
					<td width="30%" class="rubfrm" 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" align="absmiddle" id="f_img_date" title="<?PHP echo $alt_chxdate; ?>">
						<a href="javascript:;" onclick="document.oth_maj.date.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
					</td>
				</tr>
				<tr>
					<td width="30%" class="rubfrm" 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 ot_codest FROM ".TBOT." WHERE `ot_code` =  '".$codeot."'";
						$rs = mysql_query($rech) or die(mysql_error());
						
						if (mysql_num_rows($rs) >0)
						{
							if ($row = mysql_fetch_array($rs)) 
							{
								extract($row);
								$rech2 = "SELECT * FROM ".TBTEC." WHERE `tec_codest`= '".$ot_codest."' AND `tec_out` = '0' ORDER BY tec_nom";
								$rs2 = mysql_query($rech2) or die(mysql_error());
						
								if (mysql_num_rows($rs2) >0)
								{
								?>
									<select name="codetec" id="codetec">
								<?PHP
									echo "<option value=\"\">".$sel_lst_tec."</option>";
							
									while ($resultat = mysql_fetch_array($rs2)) 
									{
										extract($resultat);
										$txt_tec = $tec_nom." ".$tec_prenom;
										
										if ($oth_codetec == $tec_code)
											echo '<option value="'.$tec_code.'" selected>'.$txt_tec.'</option>';
										else
											echo '<option value="'.$tec_code.'">'.$txt_tec.'</option>';
									}
								?>
									</select>
								<?PHP
								}
								else
								{
								?>
									<select name="codetec" id="codetec">
									<option>-- Pas de technicien actif sur cette agence --</option>
									</select>
								<?PHP
								}
							}
						}
						mysql_free_result($rs);
						mysql_close($conn);
					?>
					</td>
				</tr>
				<tr>
					<td width="30%" class="rubfrm" id="f_lieu" align="right">
						Lieu
					</td>
					<td align="left">
					<select name="codelieu" id="codelieu">
					<?PHP
						
						echo "<option>-- Choisissez un lieu --</option>";

						// 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) or die(mysql_error());
				
						while ($resultat = mysql_fetch_array($rs)) 
						{
							extract($resultat);
							if ($oth_codelieu == $lieu_code)
								echo '<option value="'.$lieu_code.'" selected>'.$lieu_desc.'</option>';
							else
								echo '<option value="'.$lieu_code.'">'.$lieu_desc.'</option>';
						}
						mysql_free_result($rs);
						mysql_close($conn);
					?>
					  </select>
					</td>
				</tr>
				<tr>
					<td width="30%" class="rubfrm" id="f_horaires" align="right">
						Horaires
					</td>
					<td align="left">
						 D&eacute;but 
						<select name="heurea" id="heurea">
						<?PHP
						if ($oth_heurea=="00:00:00")
							echo "<option value=\"\" selected></option>";
						else
							echo "<option value=\"\"></option>";
						
						// Création de la liste des heures
						for ($i=0; $i<86400 ;$i+=300)
						{
							$heure=heure_to_hhmm(sec_heure($i));
		
							if ($oth_heurea == $heure)
								echo '<option value="'.$heure.'" selected>'.$heure.'</option>';
							else
								echo '<option value="'.$heure.'">'.$heure.'</option>';
						/* <a href="javascript:;" onclick="document.oth_maj.heurea.value='00:00'"><img src="../img/raz.png" border="0" align="absmiddle"></a> */
						}
						?>
						</select>
						<a href="javascript:;" onclick="document.oth_maj.heurea.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
						/ Fin 
						<select name="heured" id="heured">
						<?PHP
						if ($oth_heured=="00:00:00")
							echo "<option value=\"\" selected></option>";
						else
							echo "<option value=\"\"></option>";
						
						// Création de la liste des heures
						for ($i=0; $i<86400 ;$i+=300)
						{
							$heure=heure_to_hhmm(sec_heure($i));
		
							if ($oth_heured == $heure)
								echo '<option value="'.$heure.'" selected>'.$heure.'</option>';
							else
								echo '<option value="'.$heure.'">'.$heure.'</option>';
						/* <a href="javascript:;" onclick="document.oth_maj.heured.value='00:00'"><img src="../img/raz.png" border="0" align="absmiddle"></a> */
						}
						?>
						</select>
						<a href="javascript:;" onclick="document.oth_maj.heured.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
						<span class="annot_petit_it">
						 (hh:mm)
						</span>
					</td>
				</tr>
				<tr>
					<td width="30%" class="rubfrm" id="f_offert" align="right">
						Offert
					</td>
					<td align="left">
					<?PHP if ($oth_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" class="bton_std" id="annul" value="<?PHP echo $but_cancel; ?>" onclick="javascript:; self.location.href='oth_maj.php?td=add&ci=<?PHP echo $codeot; ?>';">
			<?PHP
				if ($td == "add")
				{
			?>
					<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_add; ?>">
			<?PHP
				}
				if ($td == "edit")
				{
			?>
					<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_modif; ?>">
			<?PHP
				}
				if ($td == "del")
				{
			?>
				<input name="enr" type="submit" class="bton_std" id="enr" value="<?PHP echo $but_del; ?>">
			<?PHP
				}
			?>
			</p>
		</form>
		
		<script type="text/javascript">
		<!--
			Calendar.setup({
				inputField     :    "date",     	// id of the input field
				ifFormat       :    "<?PHP echo $datefmtc; ?>",     // format of the input field
				button         :    "f_img_date",  	// trigger for the calendar (button ID)
				align          :    "Ll",           // alignment (defaults to "Bl")
				electric	   :	false,
				singleClick    :    true
			});
		//-->
		</script>

		<script type="text/javascript">
		<!--
		maj_ot('<?PHP echo heure_to_hhmm(sec_heure($nbtotalsec,3,TRUE)); ?>','<?PHP echo heure_to_hhmm(sec_heure($nbtotalsecoff,3,TRUE)); ?>','<?PHP echo $str_tec_traitants; ?>');
		//-->
		</script>
<?PHP
	}
}
else
{
	if ($pbm_oth == TRUE)
	{
?>
		<script type="text/javascript">
		<!--
		self.close();
		//-->
		</script>
<?PHP
	}
	if ($pbm_enr_oth == TRUE)
	{
?>
		<p align="center" class="annot_std_it"><?PHP echo $msg; ?></p>
		<script type="text/javascript">
		<!--
		window.setTimeout("location=('oth_maj.php?ci=<?PHP echo $codeot; ?>&td=<?PHP echo $td; ?>&id=<?PHP echo $id; ?>');",3000)
		//-->
		</script>
<?PHP
	}
}
?>
</body>
</html>
