<?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");

if (!isset($_SESSION["lng"])) $_SESSION["lng"]="fr";
include_once("../lng/".$_SESSION["lng"].".inc.php"); // Paramètres de language
include_once("../inc/config.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_do.inc.php");
include_once("../inc/fic_dos.inc.php");
include_once("../inc/fic_mque.inc.php");
include_once("../inc/fic_st.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim(@$_GET['td']));
$codedos = strip_tags(trim(@$_GET['cd']));
$iddosd = strip_tags(trim(@$_GET['nd']));
	
$pbm_dosd=FALSE;
$msg1_err_type=$ajx_nocmque;
$msg2_err_type=$ajx_nocdo;
$msg3_err_type=$ajx_nocst;

if ($codedos <> "")
{
	// Récupération des données de la fiche dossier
	$row = lit_enr_dos($codedos);
	if (is_array($row))
	{
		extract ($row);
		
		$row = lit_enr_doss($dos_codedoss);
		if (is_array($row))
			extract($row);
			
		if (formatedate($dosd_datefin)<>"")
			$td="view";
	
		if ($td == "add")
		{
			$dosd_codedos = $dos_code;
			$dosd_dateactf = $datef;
		}

		if (($td == "edit") OR ($td=="del") OR ($td=="view"))
		{
			$row = lit_enr_dosd_in_dos($iddosd,$codedos);
			if (is_array($row))
			{
				extract ($row);
				$dosd_dateactf = formatedate($dosd_dateact);
				$dosd_heured = substr($dosd_heured,0,5);
				$dosd_heuref = substr($dosd_heuref,0,5);
				$dosd_aheured=substr($dosd_aheured,0,5);
				$dosd_aheuref=substr($dosd_aheuref,0,5);
				$dosd_rheured=substr($dosd_rheured,0,5);
				$dosd_rheuref=substr($dosd_rheuref,0,5);
			}
			else
				$pbm_dosd=TRUE;
		}
	}
}			
else
	$pbm_dosd=TRUE;

switch ($td)
{
	case "add" :
		$titre = "SAISIE DETAIL";
		break;
	case "edit" :
		$titre = "EDITION DETAIL";
		break;
	case "del" :
		$titre = "SUPPRESSION DETAIL";
		break;
	case "view" :
		$titre = "VISUALISATION DETAIL";
		break;
	default :
		$pbm_dosd=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; ?> : Détail dossier</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>

<!-- 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=="add") or ($td=="edit")) { ?>
<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:typea ; format:liste ; req:Y ; txt:Type action ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:dateactf ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date ; stok:frmok ; stbad:frmbad",
	"nom:heured; format:liste ; req:Y ; txt:Heure début ; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:heuref; format:liste ; req:Y ; txt:Heure fin ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:obj; format:txt ; req:Y ; txt:Objectif ; stok:frmok ; stbad:frmbad");
//-->
</script>
<?PHP } ?>
<!-- Scripts Javascript divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

<!-- Scripts Javascript sur les champs -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

<!-- Scripts Javascript pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/verif_form.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 (($pbm_dosd==FALSE) AND (($td == "edit") OR ($td == "add"))) { ?>
<script type="text/javascript">
<!--        
function updatecmque()
{
	cmqueUpdater = new SelectUpdater2("cmque", "<?PHP echo $rep_appli.'/ajax/'; ?>recupcmque.php?mque=", "attn1", "msg1", "<?PHP echo $msg1_err_type; ?>", "--- Merci de choisir une marque ---");
	anciencodemque = "";
	document.getElementById("mque").onchange = function() {
		var listemque = document.getElementById("mque");
		var codemque = listemque.options[listemque.selectedIndex].value;
		if (codemque.length > 0)
		{
			if (codemque != anciencodemque)
			{
				// Faire l'appel Ajax
				cmqueUpdater.run(codemque);
				anciencodemque = codemque;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			cmqueUpdater.reset();
			anciencodemque = "";
		}
		verif_lnk_addctact('0','mque','addcmque');
	}
}

function updatecdo()
{
	cdoUpdater = new SelectUpdater2("cdo", "<?PHP echo $rep_appli.'/ajax/'; ?>recupcdo.php?do=", "attn2", "msg2", "<?PHP echo $msg2_err_type; ?>", "--- Merci de choisir un donneur d'ordres ---");
	anciencodedo = "";
	document.getElementById("do").onchange = function() {
		var listedo = document.getElementById("do");
		var codedo = listedo.options[listedo.selectedIndex].value;
		if (codedo.length > 0)
		{
			if (codedo != anciencodedo)
			{
				// Faire l'appel Ajax
				cdoUpdater.run(codedo);
				anciencodedo = codedo;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			cdoUpdater.reset();
			anciencodedo = "";
		}
		verif_lnk_addctact('0','do','addcdo');
	}
}

function updatecst()
{
	cstUpdater = new SelectUpdater2("cst", "<?PHP echo $rep_appli.'/ajax/'; ?>recupcst2.php?st=", "attn3", "msg3", "<?PHP echo $msg3_err_type; ?>", "--- Merci de choisir un sous-traitant ---");
	anciencodest = "";
	document.getElementById("st").onchange = function() {
		var listest = document.getElementById("st");
		var codest = listest.options[listest.selectedIndex].value;
		if (codest.length > 0)
		{
			if (codest != anciencodest)
			{
				// Faire l'appel Ajax
				cstUpdater.run(codest);
				anciencodest = codest;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			cstUpdater.reset();
			anciencodest = "";
		}
		verif_lnk_addctact('0','st','addcst');
	}
}
//-->
</script>
<?PHP } ?>

</head>
<?PHP
switch ($td)
{
	case "add" :
	case "edit" :
		echo "<body onLoad=\"verif_ta(document.dosd_maj.typea.value);verif_fa('a');verif_fa('r');updatecmque();verif_lnk_addctact('0','mque','addcmque');updatecdo();verif_lnk_addctact('0','do','addcdo');updatecst();verif_lnk_addctact('0','st','addcst');verif_pour(document.getElementById('exproba').value,'nivexproba','1');verif_pour(document.getElementById('exave').value,'nivexave','2');verif_switch(document.getElementById('exstatut').value,this.value,'swstatut');verif_switch(document.getElementById('exurg').value,this.value,'swurg');verif_switch(document.getElementById('exproba').value,this.value,'swproba');verif_switch(document.getElementById('exave').value,this.value,'swave');metFocus();\">";
		break;
	case "view" :
	case "del" :
		echo "<body onLoad=\"verif_ta(document.dosd_maj.typea.value);metReadonly();\">";
		break;
	default :
		break;
}

if ($pbm_dosd==FALSE)
{
?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<p align="center"><span class="titre_gras">Pour le dossier : <?PHP echo $dos_code; ?> </span><br />
<span class="annot_petit_it"><?PHP echo $dos_titre; ?> </span></p>

<form name="dosd_maj" method="post" action="dosd_enr.php" <?PHP if (($td=="add") or ($td=="edit")) echo "onSubmit=\"javascript:; return (verif_dosd(this,tab1_champ,'','".$_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="codeage" type="hidden" id="codeage" value="<?PHP echo $dos_codeage ?>">
<input name="codecli" type="hidden" id="codecli" value="<?PHP echo $dos_codecli ?>">
<input name="codedos" type="hidden" id="codedos" value="<?PHP echo $dos_code ?>">
<input name="nd" type="hidden" id="nd" value="<?PHP echo $iddosd ?>">
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_typea" align="right">Type action</td>
	<td >
	<?PHP
	// Création de la liste cachée des types
	// pour savoir si déplacement = "_"+codetype
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBDOSTA;
	$rs = mysql_query($rech) or die(mysql_error());
	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		echo '<input name="_'.$dosta_code.'" type="hidden" id="_'.$dosta_code.'" value="'.$dosta_depl.'">';
	}
	mysql_free_result($rs);
	mysql_close($conn);

	if (($td == "add") OR ($td == "edit"))
	{ 
		echo '<select name="typea" id="typea" onChange="verif_ta(this.value);">';
		echo "<option value=\"\">-- Choisissez un type --</option>";
	
		// Création de la liste des Types
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBDOSTA." ORDER BY dosta_desc");
	
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			if ($dosd_codedosta == $dosta_code)
				echo '<option value="'.$dosta_code.'" selected>'.$dosta_desc.'</option>';
			else
				echo '<option value="'.$dosta_code.'">'.$dosta_desc.'</option>';
		}
		mysql_free_result($rs);
		mysql_close($conn);
		echo '</select>';
		echo '<img src="../img/oblig.png" align="absmiddle" alt="'.$alt_chp_oblig.'">';
	}
	else // Si c'est clot, on se contente d'afficher la catégorie
	{
		$txt_typa = "";
		if ($dosd_codedosta <> "")
		{
			$row = lit_enr_dosta($dosd_codedosta);
			if (is_array($row))
			{
				extract($row);
				$txt_typa = $dosta_desc;
			}
		}
	
		if ($txt_typa<>"")
		{
	?>
		<input name="typea" type="hidden" id="typea" value="<?PHP echo $dosd_codedosta ?>" readonly="1">
		<input name="ntypea" type="text" id="ntypea" value="<?PHP echo $txt_typa ?>" size="50" readonly="1">
	<?PHP
		}
		else
		{
	?>
			<span class="annot_gras_it">
			Pas de type affect&eacute; &agrave; ce d&eacute;tail dossier.
			</span>
	<?PHP
		}
	}
	?>
	</td>
	<td width="15%" id="f_clore" align="right">
	<?PHP if (($td == "add") OR ($td == "edit")) { ?>
	Clore fiche <input type="checkbox" name="clore" id="clore" value="clos" align="bottom" style="background-color:#FFFFFF;" <?PHP if ($dosd_clos==1) echo 'checked'; else echo 'onChange="verif_aff_obl();" readonly="readonly"';?>>
	<?PHP }else { ?>
		<input name="clore" type="hidden" id="clore" value="<?PHP if ($dosd_clos==1) echo 'clos'; else echo ''; ?>">
		&nbsp;	
	<?PHP } ?>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_dta" align="right">Date/heures action </td>
	<td>
	<input name="dateactf" type="text" id="dateactf" value="<?PHP echo $dosd_dateactf ?>" size="10" maxlength="10" readonly="1">
	<?PHP
	if (($td == "add") OR ($td == "edit"))
	{
	?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_dateactf" title="<?PHP echo $alt_chxdate; ?>">
		<span class="annot_std_gras">
		<a href="javascript:;" onclick="document.dosd_maj.dateactf.value='';document.dosd_maj.heured.value='';document.dosd_maj.heuref.value='';"><img src="../img/raz.png" border="0" align="absmiddle"></a>
		</span> 
		 heure d&eacute;but :
			<select name="heured" id="heured">
	<?PHP
			if ($dosd_heured=="")
				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 ($dosd_heured == $heure)
					echo '<option value="'.$heure.'" selected>'.$heure.'</option>';
				else
					echo '<option value="'.$heure.'">'.$heure.'</option>';
			}
	?>
			</select>
		<a href="javascript:;" onclick="document.dosd_maj.heured.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
		  / (heure fin :
			<select name="heuref" id="heuref">
	<?PHP
			if ($dosd_heured=="")
				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 ($dosd_heuref == $heure)
					echo '<option value="'.$heure.'" selected>'.$heure.'</option>';
				else
					echo '<option value="'.$heure.'">'.$heure.'</option>';
			}
			?>
			</select>
		)		
		<a href="javascript:;" onclick="document.dosd_maj.heuref.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
	<?PHP } else { ?>
		 heure d&eacute;but :
		<input name="heured" type="text" id="heured" value="<?PHP echo heure_to_hhmm($dosd_heured); ?>" size="5" maxlength="8" readonly="1">
		  / heure fin :
		<input name="heuref" type="text" id="heuref" value="<?PHP echo heure_to_hhmm($dosd_heuref); ?>" size="5" maxlength="8" readonly="1">
		)
	<?PHP } ?>
	<span class="annot_petit_it">hh:mm</span>
	</td>
</tr>
</table>
<div id="det_depl" style="display:none">
<table width="100%"  border="0">
<tr>
	<td colspan="2" class="rubfrm" align="center">D&eacute;tail d&eacute;placement</td>
</tr>
<table width="100%"  border="0" align="center">
<tr>
	<td width="20%"></td>
	<td width="40%" class="rubfrm" id="f_aller" align="center" >Aller</td>
	<td class="rubfrm" id="f_retour" align="center">Retour</td>
</tr>
<tr>
	<td width="20%" class="rubfrm" id="f_transmt" align="right">Transport</td>
	<td width="40%" align="centerleft">
	<?PHP
	// Création de la liste cachée des moyens de transport
	// pour savoir si coût à saisir = "M_"+codemt
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBMT." WHERE `mt_valid`='1'";
	$rs = mysql_query($rech) or die(mysql_error());
	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		echo '<input name="M_'.$mt_code.'" type="hidden" id="M_'.$mt_code.'" value="'.$mt_coutas.'">';
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	<select name="a_mt" id="a_mt">
	<?PHP
	echo "<option value=\"\">-- Moyen de transport --</option>";

	// Création de la liste des moyens de transport
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBMT." WHERE `mt_valid`='1' ORDER BY mt_des";
	$rs = mysql_query($rech) or die(mysql_error());

	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		echo '<option value="'.$mt_code.'"';
		if ($dosd_acodemt==$mt_code)
			echo ' selected';
		echo '>'.$mt_des;
		if ($mt_coutas==1)
			echo ' (AS)';
		echo '</option>';
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</select>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
	<td align="left">
	<select name="r_mt" id="r_mt">
	<?PHP
	echo "<option value=\"\">-- Moyen de transport --</option>";

	// Création de la liste des moyens de transport
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBMT." ORDER BY mt_des";
	$rs = mysql_query($rech) or die(mysql_error());

	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);
		echo '<option value="'.$mt_code.'"';
		if ($dosd_rcodemt==$mt_code)
			echo ' selected';
		echo '>'.$mt_des;
		if ($mt_coutas==1)
			echo ' (AS)';
		echo '</option>';
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</select>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td width="20%" class="rubfrm" id="f_transh" align="right">Horaires</td>
	<td width="40%" align="left">
	De <select name="a_heured" id="a_heured">
	<?PHP
	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));
		echo '<option value="'.$heure.'"';
		if ($dosd_aheured == $heure)
			echo ' selected';
		echo '>'.$heure.'</option>';
	}
	?>
	</select>
	<a href="javascript:;" onclick="document.inth_maj.a_heured.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
	 &agrave; 
	<select name="a_heuref" id="a_heuref">
	<?PHP
	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));
		echo '<option value="'.$heure.'"';
		if ($dosd_aheuref == $heure)
			echo ' selected';
		echo '>'.$heure.'</option>';
	}
	?>
	</select>
	<a href="javascript:;" onclick="document.inth_maj.a_heuref.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
	<td align="left">
	De <select name="r_heured" id="r_heured">
	<?PHP
	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));
		echo '<option value="'.$heure.'"';
		if ($dosd_rheured == $heure)
			echo ' selected';
		echo '>'.$heure.'</option>';
	}
	?>
	</select>
	<a href="javascript:;" onclick="document.inth_maj.r_heured.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
	 &agrave; 
	<select name="r_heuref" id="r_heuref">
	<?PHP
	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));
		echo '<option value="'.$heure.'"';
		if ($dosd_rheuref == $heure)
			echo ' selected';
		echo '>'.$heure.'</option>';
	}
	?>
	</select>
	<a href="javascript:;" onclick="document.inth_maj.r_heuref.value=''"><img src="../img/raz.png" border="0" align="absmiddle"></a>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td width="20%" class="rubfrm" id="f_transkm" align="right">Distance</td>
	<td width="40%" align="left">
	<input name="a_km" type="text" id="a_km" value="<?PHP echo format_num($dosd_akm,2); ?>" size="10" onChange="formatedeci(this.id,2);"> km
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
	<td align="left">
	<input name="r_km" type="text" id="r_km" value="<?PHP echo format_num($dosd_rkm,2); ?>" size="10" onChange="formatedeci(this.id,2);"> km
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td width="20%" class="rubfrm" id="f_transcd" align="right">Co&ucirc;t transport</td>
	<td width="40%" align="left">
	<input name="a_cd" type="text" id="a_cd" value="<?PHP echo format_num($dosd_acd,2); ?>" size="10" onChange="formatedeci(this.id,2);"> <?PHP echo $lang['symbole_monnaie']; ?>
	<br /><span class="annot_petit_it">Uniquement si co&ucirc;t &agrave; saisir (AS)</span>
	</td>
	<td align="left">
	<input name="r_cd" type="text" id="r_cd" value="<?PHP echo format_num($dosd_rcd,2); ?>" size="10" onChange="formatedeci(this.id,2);"> <?PHP echo $lang['symbole_monnaie']; ?>
	<br /><span class="annot_petit_it">Uniquement si co&ucirc;t &agrave; saisir (AS)</span>
	</td>
</tr>
<tr>
	<td width="20%" class="rubfrm" id="f_transfa" align="right">Frais annexes</td>
	<td width="40%" align="left">
	<input name="a_fa" type="text" id="a_fa" value="<?PHP echo format_num($dosd_afrais,2); ?>" size="10" onChange="formatedeci(this.id,2);verif_fa('a');"> <?PHP echo $lang['symbole_monnaie']; ?>
	<br /><span class="annot_petit_it">Ne pas saisir de co&ucirc;t kilom&eacute;trique suppl&eacute;mentaire car il est automatiquement calcul&eacute;</span>
	</td>
	<td align="left">
	<input name="r_fa" type="text" id="r_fa" value="<?PHP echo format_num($dosd_rfrais,2); ?>" size="10" onChange="formatedeci(this.id,2);verif_fa('r');"> <?PHP echo $lang['symbole_monnaie']; ?>
	<br /><span class="annot_petit_it">Ne pas saisir de co&ucirc;t kilom&eacute;trique suppl&eacute;mentaire car il est automatiquement calcul&eacute;</span>
	</td>
</tr>
<tr>
	<td width="20%" class="rubfrm" id="f_transfad" align="right">D&eacute;tail frais annexes</td>
	<td width="40%" align="left">
	<textarea name="a_fad" id="a_fad" rows="3"><?PHP echo htmlspecialchars($dosd_afraisd,ENT_QUOTES); ?></textarea>
	</td>
	<td align="center">
	<textarea name="r_fad" id="r_fad" rows="3"><?PHP echo htmlspecialchars($dosd_rfraisd,ENT_QUOTES); ?></textarea>
	</td>
</tr>
</table>
</div>
<table width="100%"  border="0">
<tr>
	<td colspan="2" class="rubfrm" align="center">D&eacute;roulement</td>
</tr>
</table>
<div id="menu1_dosd" class="menu_ongletfull">
<input name="maxmnu1" type="hidden" id="maxmnu1" value="3">
<a class="ongleti" id="m1_1" href="javascript:;" onclick="set_mnu_dosd(this.id,'');" onFocus="this.blur();">Objectif</a>
<a class="ongleti" id="m1_2" href="javascript:;" onclick="set_mnu_dosd(this.id,'');" onFocus="this.blur();">Synth&egrave;se</a>
<a class="ongleti" id="m1_3" href="javascript:;" onclick="set_mnu_dosd(this.id,'');" onFocus="this.blur();">Conclusion</a>
</div>

<div id="detail1_m1" style="display:none">
<table width="100%"  border="0">
<tr>
	<td>
	<?PHP
	if (($td == "add") OR ($td == "edit"))
	{ 
	?>
		<textarea name="obj" rows="7" id="obj" style="width:95%;"><?PHP echo htmlspecialchars($dosd_obj,ENT_QUOTES) ?></textarea>
		<img src="../img/oblig.png" align="top" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	} 
	else 
	{ 
	?>
		<textarea name="obj" rows="7" id="obj" style="width:95%;" readonly="1"><?PHP echo htmlspecialchars($dosd_obj,ENT_QUOTES) ?></textarea>
	<?PHP 
	}
	?>
	</td>
</tr>
</table>
</div>

<div id="detail1_m2" style="display:none">
<table width="100%"  border="0">
<tr>
	<td>
	<?PHP
	if (($td == "add") OR ($td == "edit"))
	{ 
	?>
		<textarea name="res" rows="7" id="res" style="width:95%;"><?PHP echo htmlspecialchars($dosd_res,ENT_QUOTES) ?></textarea>
		<span id="obl1" style="display:none;"><img src="../img/oblig.png" align="top" alt="<?PHP echo $alt_chp_oblig; ?>"></span>
	<?PHP
	} 
	else 
	{ 
	?>
		<textarea name="res" rows="7" id="res" style="width:95%;" readonly="1"><?PHP echo htmlspecialchars($dosd_res,ENT_QUOTES) ?></textarea>
	<?PHP 
	}
	?>
	</td>
</tr>
</table>
</div>

<div id="detail1_m3" style="display:none">
<table width="100%"  border="0">
<tr>
	<td>
	<?PHP
	if (($td == "add") OR ($td == "edit"))
	{ 
	?>
		<textarea name="concl" rows="7" id="concl" style="width:95%;"><?PHP echo htmlspecialchars($dosd_concl,ENT_QUOTES) ?></textarea>
		<span id="obl2" style="display:none;"><img src="../img/oblig.png" align="top" alt="<?PHP echo $alt_chp_oblig; ?>"></span>
	<?PHP
	} 
	else 
	{ 
	?>
		<textarea name="concl" rows="7" id="concl" style="width:95%;" readonly="1"><?PHP echo htmlspecialchars($dosd_concl,ENT_QUOTES) ?></textarea>
	<?PHP 
	}
	?>
	</td>
</tr>
</table>
</div>


<table width="100%"  border="0">
<tr>
	<td colspan="2" class="rubfrm" align="center">Intervenants</td>
</tr>
<?PHP if (($td=="add") or ($td=="edit")) { ?>
<tr>
	<td colspan="2" align="center" class="annot_petit_it">
	(Pour plusieurs contacts, s&eacute;lectionnez les personnes concern&eacute;es avec Ctrl + clic gauche, cat&eacute;gorie par cat&eacute;gorie)
	</td>
</tr>
<?PHP } ?>
</table>
<input name="maxmnu2" type="hidden" id="maxmnu2" value="6">
<div id="menu2_dosd" class="menu_ongletfull">
<a class="ongleti" id="m2_1" href="javascript:;" onclick="set_mnu_dosd('',this.id);" onFocus="this.blur();">Agence</a>
<a class="ongleti" id="m2_2" href="javascript:;" onclick="set_mnu_dosd('',this.id);" onFocus="this.blur();">Technicien(s)</a>
<a class="ongleti" id="m2_3" href="javascript:;" onclick="set_mnu_dosd('',this.id);" onFocus="this.blur();">Client</a>
<a class="ongleti" id="m2_4" href="javascript:;" onclick="set_mnu_dosd('',this.id);" onFocus="this.blur();">Fabriquant / Editeur</a>
<a class="ongleti" id="m2_5" href="javascript:;" onclick="set_mnu_dosd('',this.id);" onFocus="this.blur();">Donneur d'ordres</a>
<a class="ongleti" id="m2_6" href="javascript:;" onclick="set_mnu_dosd('',this.id);" onFocus="this.blur();">Sous-traitant</a>
</div>

<div id="detail2_m1" style="display:none">
<table width="100%"  border="0">
<tr>
	<td>&nbsp;</td>
	<td align="right">
	<?PHP if (($td=="add") or ($td=="edit")) { ?>
	<a href="javascript:;" onclick="fensaisie2('cage_maj.php?td=add&ca=<?PHP echo $dos_codeage; ?>&tx=dosd_cage',900,500,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');"><img src="../img/ctacts.png" border="0" align="absmiddle"></a>
	<a href="javascript:;" onclick="fensaisie2('cage_maj.php?td=add&ca=<?PHP echo $dos_codeage; ?>&tx=dosd_cage',900,500,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');"> Ajouter un contact </a>
	<?PHP } else echo "&nbsp;"; ?>
	</td>
</tr>
<tr>
	<td colspan="2">
	<?PHP
	// Création de la liste des contacts de l'agence
	echo '<select name="cage[]" id="cage" size="5" class="annot_petit" multiple="multiple" style="width:95%;"';
	if (($td=="del") or ($td=="view"))
		echo ' disabled';
	echo '>';
	$row=lit_enr_age($dos_codeage,TRUE);
	if (is_array($row))
		extract($row);
		
	// Contact principal
	$txt_cage = $age_resp_nom." ".$age_resp_prenom." (Contact principal)";
	if (($td=="add") or ($td=="edit"))
	{
		echo '<option value="-1"';
		if (exist_inter_id_in_dosdi($dosd_id,0,"-1",$dos_codeage,TRUE))
			echo ' selected';
		echo '>'.$txt_cage.'</option>';
	}
	else
	{
		if (exist_inter_id_in_dosdi($dosd_id,0,"-1",$dos_codeage,TRUE))
		{
			echo '<option value="-1" selected';
			echo '>'.$txt_cage.'</option>';
		}
	}
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	// Contacts secondaires
	$rech = "SELECT * FROM ".TBCAGE." WHERE `cage_codeage` = '".$dos_codeage."' ORDER BY cage_nom";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
	
			$txt_cage = $cage_nom." ".$cage_prenom;
			$row2=lit_enr_fonc($cage_codefonc,FALSE);
			if (is_array($row2))
			{
				extract($row2);
				$txt_fonc=$fonc_desc;
			}
			else
				$txt_fonc=$cage_codefonc;
			$txt_cage.=" (".$txt_fonc.")";
			if (($td=="add") or ($td=="edit"))
			{
				echo '<option value="'.$cage_id.'"';
				if ($td=="edit")
				{
					if (exist_inter_id_in_dosdi($dosd_id,0,$cage_id,$dos_codeage,FALSE))
						echo ' selected';
				}
				echo '>'.$txt_cage.'</option>';
			}
			else
			{
				if (exist_inter_id_in_dosdi($dosd_id,0,$cage_id,$dos_codeage,FALSE))
				{
					echo '<option value="'.$cage_id.'" selected';
					echo '>'.$txt_cage.'</option>';
				}
			}
		}
	}
	mysql_free_result($rs);
	
	mysql_close($conn);
	echo '</select>';
	?>
	</td>
</tr>
</table>
</div>

<div id="detail2_m2" style="display:none">
<table width="100%" height="50px" border="0">
<tr>
	<td>&nbsp;</td>
</tr>
<tr>
	<td>
	<?PHP
	// Création de la liste des Techniciens de l'agence
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBTEC." WHERE `tec_codeage` = '$dos_codeage' AND `tec_out` = '0' ORDER BY tec_nom";
	$rs = mysql_query($rech) or die(mysql_error());

	echo '<select name="codetec[]" id="codetec" class="annot_petit" multiple="multiple" size="5" style="width:95%;"';
	if (($td=="del") or ($td=="view"))
		echo ' disabled';
	echo '>';
	if (mysql_num_rows($rs) <> 0)
	{

		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			$txt_tec = $tec_nom." ".$tec_prenom;
			if (($td=="add") or ($td=="edit"))
			{
				echo '<option value="'.$tec_id.'"';
				if (exist_inter_id_in_dosdi($dosd_id,'1',$tec_id,$tec_code,FALSE))
					echo ' selected';
				echo '>'.$txt_tec.'</option>';
			}
			else
			{
				if (exist_inter_id_in_dosdi($dosd_id,'1',$tec_id,$tec_code,FALSE))
				{
					echo '<option value="'.$tec_id.'" selected';
					echo '>'.$txt_tec.'</option>';
				}
			}
		}
	}
	echo '</select>';
	?>
	</td>
</tr>
</table>
</div>

<div id="detail2_m3" style="display:none">
<table width="100%"  border="0">
<tr>
	<td>
	<span class="annot_petit_it">Les contacts sites sont en fin de liste</span>
	</td>
	<td align="right">
	<?PHP if (($td=="add") or ($td=="edit")) { ?>
	<a href="javascript:;" onclick="fensaisie2('ccli_maj.php?td=add&cc=<?PHP echo $dos_codecli; ?>&tx=dosd_ccli',900,500,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');"><img src="../img/ctacts.png" border="0" align="absmiddle"></a>
	<a href="javascript:;" onclick="fensaisie2('ccli_maj.php?td=add&cc=<?PHP echo $dos_codecli; ?>&tx=dosd_ccli',900,500,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');"> Ajouter un contact </a>
	<?PHP } else echo "&nbsp;"; ?>
	</td>
</tr>
<tr>
	<td colspan="2">
	<?PHP
	// Création de la liste des contacts du client
	echo '<select name="ccli[]" id="ccli" size="5" class="annot_petit" multiple="multiple" style="width:95%;"';
	if (($td=="del") or ($td=="view"))
		echo ' disabled';
	echo '>';
	$row=lit_enr_cli($dos_codecli,TRUE);
	if (is_array($row))
		extract($row);

	// Contact principal
	$txt_ccli = $cli_nom." ".$cli_prenom." (Contact principal)";
	if (($td=="add") or ($td=="edit"))
	{
		echo '<option value="-1"';
		if (exist_inter_id_in_dosdi($dosd_id,2,"-1",$cli_code,TRUE))
			echo ' selected';
		echo '>'.$txt_ccli.'</option>';
	}
	else
	{
		if (exist_inter_id_in_dosdi($dosd_id,2,"-1",$cli_code,TRUE))
		{
			echo '<option value="-1" selected';
			echo '>'.$txt_ccli.'</option>';
		}
	}
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	// Contacts secondaires
	$rech = "SELECT * FROM ".TBCCLI." WHERE `ccli_codecli` = '".$cli_code."' ORDER BY ccli_nom";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
	
			$txt_ccli = $ccli_nom." ".$ccli_prenom;
			$row2=lit_enr_fonc($ccli_codefonc,FALSE);
			if (is_array($row2))
			{
				extract($row2);
				$txt_fonc=$fonc_desc;
			}
			else
				$txt_fonc=$ccli_codefonc;
			$txt_ccli.=" (".$txt_fonc.")";
			if (($td=="add") or ($td=="edit"))
			{
				echo '<option value="'.$ccli_id.'"';
				if ($td=="edit")
				{
					if (exist_inter_id_in_dosdi($dosd_id,2,$ccli_id,$cli_code,FALSE))
						echo ' selected';
				}
				echo '>'.$txt_ccli.'</option>';
			}
			else
			{
				if (exist_inter_id_in_dosdi($dosd_id,2,$ccli_id,$cli_code,FALSE))
				{
					echo '<option value="'.$ccli_id.'" selected';
					echo '>'.$txt_ccli.'</option>';
				}
			}
		}
	}
	mysql_free_result($rs);
	
	// Contacts sites client
	if (($td=="add") or ($td=="edit"))
		echo "<optgroup label=\"Sites secondaires\">\n";
	$rech = "SELECT * FROM ".TBSCLI." WHERE `scli_codecli` = '".$cli_code."' ORDER BY scli_ste,scli_rnom";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		$siteact="";
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			$txt_ccli = $scli_rnom." ".$scli_rprenom;
			$row2=lit_enr_fonc($scli_rcodefonc,FALSE);
			if (is_array($row2))
			{
				extract($row2);
				$txt_fonc=$fonc_desc;
			}
			else
				$txt_fonc=$scli_rcodefonc;
			$txt_ccli.=" (".$txt_fonc.")";
			if (($td=="add") or ($td=="edit"))
			{
				if ($siteact<>$scli_ste)
				{
					if ($siteact<>"")
						echo "</optgroup>\n";
					echo "<optgroup label=\">>Site : ".$scli_ste."\">\n";
				}
				echo '<option value="S_'.$scli_id.'"';
				if ($td=="edit")
				{
					if (exist_inter_id_in_dosdi($dosd_id,6,$scli_id,$cli_code,FALSE))
						echo ' selected';
				}
				echo '>'.$txt_ccli.'</option>';
			}
			else
			{
				if (exist_inter_id_in_dosdi($dosd_id,6,$scli_id,$cli_code,FALSE))
				{
					echo '<option value="S_'.$scli_id.'" selected';
					$txt_ccli.=" - site ".$scli_ste;
					echo '>'.$txt_ccli.'</option>';
				}
			}
			$siteact=$scli_ste;
		}
	}
	if (($td=="add") or ($td=="edit"))
		echo "</optgroup>\n";
	mysql_free_result($rs);
	
	mysql_close($conn);
	echo '</select>';
	?>
	</td>
</tr>
</table>
</div>

<div id="detail2_m4" style="display:none">
<table width="100%"  border="0">
<tr>
	<td width="33%">
	<?PHP
	$codemque="";
	if ($td<>"add")
		$codemque=donne_code_mds($iddosd,3,TRUE);
	if (($td == "add") OR ($td == "edit"))
	{ 
		// Création de la liste des marques
		echo '<select name="mque" id="mque" class="annot_petit">';
		echo '<option value="">-- Choisissez une marque --</option>';
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		
		$rech = "SELECT * FROM ".TBMQUE." ORDER BY mque_ste";
		$rs = mysql_query($rech) or die(mysql_error());
		if (mysql_num_rows($rs) <> 0)
		{
			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				if ($mque_code<>"*")
				{
					echo '<option value="'.$mque_code.'"';
					if (($codemque==$mque_code) AND ($codemque<>""))
						echo ' selected';
					echo '>'.$mque_ste.'</option>';
				}
			}
		}
		mysql_free_result($rs);
		mysql_close($conn);
		echo '</select>';
	}
	else // Si c'est clot, on n'affiche pas de choix
	{
		$row=lit_enr_mque($codemque,TRUE);
		if (is_array($row))
			extract($row);
		echo '<input name="mque" type="hidden" id="mque" value="'.$mque_code.'" readonly="1">';
		echo '<input name="nmque" type="text" id="nmque" value="'.$mque_ste.'" size="50" readonly="1">';
	}
	?>
	</td>
	<td width="33%">
	<?PHP
	echo '<span id="attn1"></span>';
	echo '<span id="msg1" style="background-color:#FF0000; color:#FFFF00; font-weight:bold">';
	if (($td<>"del") AND ($td<>"view") AND ($codemque==""))
		echo htmlspecialchars($msg1_err_type);
	echo '</span>';
	?>
	</td>
	<td align="right">
	<span id="addcmque" style="display:none;">
	<?PHP if (($td=="add") OR ($td=="view") OR ($codemque<>"")) { ?>
	<a href="javascript:;" onclick="fen_cmque_dosd();"><img src="../img/ctacts.png" border="0" align="absmiddle"></a>
	<a href="javascript:;" onclick="fen_cmque_dosd();"> Ajouter un contact </a>
	<?PHP } ?>
	</span>
	</td>
</tr>
<tr>
	<td colspan="3">
	<?PHP
	// Création de la liste des contacts marques
	echo '<select name="cmque[]" id="cmque" size="5" class="annot_petit" multiple="multiple" style="width:95%;">';
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	$rech = "SELECT * FROM ".TBCMQUE." WHERE `cmque_codemque` = '".$codemque."' ORDER BY cmque_nom";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			$txt = $cmque_nom." ".$cmque_prenom;
			$row2=lit_enr_fonc($cmque_codefonc,FALSE);
			if (is_array($row2))
			{
				extract($row2);
				$txt_fonc=$fonc_desc;
			}
			else
				$txt_fonc=$cmque_codefonc;
			$txt.=" (".$txt_fonc.")";
	
			if (($td=="add") or ($td=="edit"))
			{
				echo '<option value="'.$cmque_id.'"';
				if ($td=="edit")
				{
					if (exist_inter_id_in_dosdi($dosd_id,3,$cmque_id,$codemque,FALSE))
						echo ' selected';
				}
				echo '>'.$txt.'</option>';
			}
			else
			{
				if (exist_inter_id_in_dosdi($dosd_id,3,$cmque_id,$codemque,FALSE))
				{
					echo '<option value="'.$cmque_id.'" selected';
					echo '>'.$txt.'</option>';
				}
			}
		}
	}
	mysql_free_result($rs);
	mysql_close($conn);
	echo '</select>';
	?>
	</td>
</tr>
</table>
</div>

<div id="detail2_m5" style="display:none">
<table width="100%" border="0">
<tr>
	<td width="33%">
	<?PHP
	$codedo="";
	if ($td<>"add")
		$codedo=donne_code_mds($iddosd,4,TRUE);
	if (($td == "add") OR ($td == "edit"))
	{ 
		// Création de la liste des donneurs d'ordres
		echo '<select name="do" id="do" class="annot_petit">';
		echo '<option value="">-- Choisissez un donneur d\'ordres --</option>';
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		
		$rech = "SELECT * FROM ".TBDO." ORDER BY do_nom";
		$rs = mysql_query($rech) or die(mysql_error());
		if (mysql_num_rows($rs) <> 0)
		{
			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				echo '<option value="'.$do_code.'"';
				if (($codedo==$do_code) AND ($codedo<>""))
					echo ' selected';
				echo '>'.$do_nom.'</option>';
			}
		}
		mysql_free_result($rs);
		mysql_close($conn);
		echo '</select>';
	}
	else // Si c'est clot, on n'affiche pas de choix
	{
		$row=lit_enr_do($codedo,TRUE);
		if (is_array($row))
			extract($row);
		echo '<input name="do" type="hidden" id="do" value="'.$do_code.'" readonly="1">';
		echo '<input name="ndo" type="text" id="ndo" value="'.$do_nom.'" size="50" readonly="1">';
	}
	?>
	</td>
	<td width="33%">
	<?PHP
	echo '<span id="attn2"></span>';
	echo '<span id="msg2" style="background-color:#FF0000; color:#FFFF00; font-weight:bold">';
	if (($td<>"del") AND ($td<>"view") AND ($codedo==""))
		echo htmlspecialchars($msg2_err_type);
	echo '</span>';
	?>
	</td>
	<td align="right">
	<span id="addcdo" style="display:none;">
	<?PHP if (($td=="add") OR ($td=="view") OR ($codedo<>"")) { ?>
	<a href="javascript:;" onclick="fen_cdo_dosd();"><img src="../img/ctacts.png" border="0" align="absmiddle"></a>
	<a href="javascript:;" onclick="fen_cdo_dosd();"> Ajouter un contact </a>
	<?PHP } ?>
	</span>
	</td>
</tr>
<tr>
	<td colspan="3">
	<?PHP
	// Création de la liste des contacts donneurs d'ordres
	echo '<select name="cdo[]" id="cdo" size="5" class="annot_petit" multiple="multiple" style="width:95%;">';
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	$rech = "SELECT * FROM ".TBCDO." WHERE `cdo_codedo` = '".$codedo."' ORDER BY cdo_nom";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			$txt = $cdo_nom." ".$cdo_prenom;
			$row2=lit_enr_fonc($cdo_codefonc,FALSE);
			if (is_array($row2))
			{
				extract($row2);
				$txt_fonc=$fonc_desc;
			}
			else
				$txt_fonc=$cdo_codefonc;
			$txt.=" (".$txt_fonc.")";
	
			if (($td=="add") or ($td=="edit"))
			{
				echo '<option value="'.$cdo_id.'"';
				if ($td=="edit")
				{
					if (exist_inter_id_in_dosdi($dosd_id,4,$cdo_id,$codedo,FALSE))
						echo ' selected';
				}
				echo '>'.$txt.'</option>';
			}
			else
			{
				if (exist_inter_id_in_dosdi($dosd_id,4,$cdo_id,$codedo,FALSE))
				{
					echo '<option value="'.$cdo_id.'" selected';
					echo '>'.$txt.'</option>';
				}
			}
		}
	}
	mysql_free_result($rs);
	mysql_close($conn);
	echo '</select>';
	?>
	</td>
</tr>
</table>
</div>

<div id="detail2_m6" style="display:none">
<table width="100%" border="0">
<tr>
	<td width="33%">
	<?PHP
	$codest="";
	if ($td<>"add")
		$codest=donne_code_mds($iddosd,5,TRUE);
	if (($td == "add") OR ($td == "edit"))
	{ 
		// Création de la liste des sous-traitants
		echo '<select name="st" id="st" class="annot_petit">';
		echo '<option value="">-- Choisissez un sous-traitant --</option>';
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		
		$rech = "SELECT * FROM ".TBST." ORDER BY st_nom";
		$rs = mysql_query($rech) or die(mysql_error());
		if (mysql_num_rows($rs) <> 0)
		{
			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				echo '<option value="'.$st_code.'"';
				if (($codest==$st_code) AND ($codest<>""))
					echo ' selected';
				echo '>'.$st_nom.'</option>';
			}
		}
		mysql_free_result($rs);
		mysql_close($conn);
		echo '</select>';
	}
	else // Si c'est clot, on n'affiche pas de choix
	{
		$row=lit_enr_st($codest,TRUE);
		if (is_array($row))
			extract($row);
		echo '<input name="st" type="hidden" id="st" value="'.$st_code.'" readonly="1">';
		echo '<input name="nst" type="text" id="nst" value="'.$st_nom.'" size="50" readonly="1">';
	}
	?>
	</td>
	<td width="33%">
	<?PHP
	echo '<span id="attn3"></span>';
	echo '<span id="msg3" style="background-color:#FF0000; color:#FFFF00; font-weight:bold">';
	if (($td<>"del") AND ($td<>"view") AND ($codest==""))
		echo htmlspecialchars($msg3_err_type);
	echo '</span>';
	?>
	</td>
	<td align="right">
	<span id="addcst" style="display:none;">
	<?PHP if (($td=="add") OR ($td=="view") OR ($codest<>"")) { ?>
	<a href="javascript:;" onclick="fen_cst_dosd();"><img src="../img/ctacts.png" border="0" align="absmiddle"></a>
	<a href="javascript:;" onclick="fen_cst_dosd();"> Ajouter un contact </a>
	<?PHP } ?>
	</span>
	</td>
</tr>
<tr>
	<td colspan="3">
	<?PHP
	echo '<select name="cst[]" id="cst" size="5" class="annot_petit" multiple="multiple" style="width:95%;">';
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	$rech = "SELECT * FROM ".TBCST." WHERE `cst_codest` = '".$codest."' ORDER BY cst_nom";
	$rs = mysql_query($rech) or die(mysql_error());
	if (mysql_num_rows($rs) <> 0)
	{
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			$txt = $cst_nom." ".$cst_prenom;
			$row2=lit_enr_fonc($cst_codefonc,FALSE);
			if (is_array($row2))
			{
				extract($row2);
				$txt_fonc=$fonc_desc;
			}
			else
				$txt_fonc=$cst_codefonc;
			$txt.=" (".$txt_fonc.")";
	
			if (($td=="add") or ($td=="edit"))
			{
				echo '<option value="'.$cst_id.'"';
				if ($td=="edit")
				{
					if (exist_inter_id_in_dosdi($dosd_id,5,$cst_id,$codest,FALSE))
						echo ' selected';
				}
				echo '>'.$txt.'</option>';
			}
			else
			{
				if (exist_inter_id_in_dosdi($dosd_id,5,$cst_id,$codest,FALSE))
				{
					echo '<option value="'.$cst_id.'" selected';
					echo '>'.$txt.'</option>';
				}
			}
		}
	}
	mysql_free_result($rs);
	mysql_close($conn);
	echo '</select>';
	?>
	</td>
</tr>
</table>
</div>

<?PHP if (($td == "add") OR ($td == "edit")) { ?>
<table width="100%"  border="0">
<tr>
	<td colspan="4" class="rubfrm" align="center">Nouveaux param&egrave;tres dossier <?PHP echo $codedos; ?></td>
</tr>
<tr>
	<td width="160">&nbsp;</td>
	<td class="rubfrm" align="center">Actuellement</td>
	<td width="16px">&nbsp;</td>
	<td width="40%" class="rubfrm" align="center">Nouveau</td>
</tr>
<tr>
	<td width="160" class="rubfrm" align="right">Statut</td>
	<td>
	<input name="exstatut" type="hidden" id="exstatut" value="<?PHP echo $doss_code; ?>" readonly="1">
	<input name="nexstatut" type="text" id="nexstatut" value="<?PHP echo $doss_desc; ?>" size="50" readonly="1">
	</td>
	<td width="16px"><span id="swstatut"></span></td>
	<td width="40%">
	<select name="codestatut" id="codestatut" onChange="verif_switch(document.getElementById('exstatut').value,this.value,'swstatut');">
	<?PHP
		
		echo "<option value=\"\" selected>-- Choisissez un statut --</option>";

		// Création de la liste des Statuts
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBDOSS." ORDER BY doss_desc");

		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			if ($doss_code<>"CLOT")
				echo '<option value="'.$doss_code.'">'.$doss_desc.'</option>';
		}
		mysql_free_result($rs);
		mysql_close($conn);
	?>
	</select>
	<span id="obl3" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" align="right">Urgence</td>
	<td>
	<input name="exurg" type="hidden" id="exurg" value="<?PHP echo $dos_urg; ?>" readonly="1">
	<input name="nexurg" type="text" id="nexurg" value="<?PHP echo $niv_urgence[$dos_urg]; ?>" size="20" readonly="1">
	</td>
	<td width="16px"><span id="swurg"></span></td>
	<td width="40%">
	<?PHP
	if (($td == "add") OR ($td == "edit"))
	{ 
	?>
	<select name="urgence" id="urgence" onChange="verif_switch(document.getElementById('exurg').value,this.value,'swurg');">
	<?PHP
	
	// Création du niveau d'urgence
	for ($i=0; $i<4; $i++)
	{
		if ($dos_urg == $i)
			echo '<option value="'.$i.'" selected>'.$niv_urgence[$i].'</option>';
		else
			echo '<option value="'.$i.'">'.$niv_urgence[$i].'</option>';
	}
	?>
	</select>
	<span id="obl4" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span>
	<?PHP } else echo "&nbsp;"; ?>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" align="right">Probabilit&eacute;</td>
	<td>
	<input name="exproba" type="text" id="exproba" value="<?PHP echo $dos_proba; ?>" size="5" readonly="1">%
	<span id="nivexproba"></span>
	</td>
	<td width="16px"><span id="swproba"></span></td>
	<td width="40%">
	<select name="proba" id="proba" onChange="verif_pour(this.value,'nivnproba','1');verif_switch(document.getElementById('exproba').value,this.value,'swproba');">
	<option value="" selected><?PHP echo $sel_lst_makechx; ?></option>';
	<?PHP
	
	// Création des niveaux de probabilité
	for ($i=0; $i<110; $i+=10)
	{
		echo '<option value="'.$i.'">'.$i.'%</option>';
	}
	?>
	</select>
	 <span id="obl5" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span>
	<span id="nivnproba"></span>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" align="right">Etat Avancement</td>
	<td>
	<input name="exave" type="text" id="exave" value="<?PHP echo $dos_avance; ?>" size="5" readonly="1">%
	<span id="nivexave"></span>
	</td>
	<td width="16px"><span id="swave"></span></td>
	<td width="40%">
	<select name="ave" id="ave" onChange="verif_pour(this.value,'nivnave','2');verif_switch(document.getElementById('exave').value,this.value,'swave');">
	<option value="" selected><?PHP echo $sel_lst_makechx; ?></option>';
	<?PHP
	
	// Création des niveaux d'avancement
	for ($i=0; $i<110; $i+=10)
	{
		echo '<option value="'.$i.'">'.$i.'%</option>';
	}
	?>
	</select>
	 <span id="obl6" style="display:none;"><img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"></span>
	<span id="nivnave"></span>
	</td>
</tr>
</table>
<?PHP } ?>
<p align="center">
<?PHP if ($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_add; ?>">
<?PHP } if ($td == "edit") { ?>
<input name="mod" type="submit" class="bton_std" id="mod" value="<?PHP echo $but_modif; ?>">
<?PHP } if ($td == "del") { ?>
<input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
<?PHP } ?>
<input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo $but_cancel; ?>" onclick="javascript:; self.close('fscomp');">
</p>
</form>
<script type="text/javascript">
<!--
set_mnu_dosd('m1_1','m2_1');
//-->
</script>
<?PHP 
if (($td <> "view") AND ($td<>"del"))
{
?>
	<script type="text/javascript">
	<!--
	Calendar.setup({
		inputField     :    "dateactf",     // id of the input field
		ifFormat       :    "<?PHP echo $datefmtc; ?>",      // format of the input field
		button         :    "f_img_dateactf",  // trigger for the calendar (button ID)
		align          :    "Br",           // alignment (defaults to "Bl")
		electric	   :	false,
		singleClick    :    true
	});
	//-->
	</script>
<?PHP
}
}
else
{
?>
	<script type="text/javascript">
	<!--
	self.close('fscomp');
	//-->
	</script>
<?PHP
}
?>
</body>
</html>
