<?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
****************************************************************************************/

session_start(); 
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/func_log.inc.php");
if (CheckURLLog(FALSE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("5-9")==FALSE) header("Location: ../index.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_dde.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim($_GET['td']));
$coderech = strip_tags(trim($_GET['code']));

$pbm_dded = FALSE;

if ($coderech <> "")
{
	if ($coderech <> "VA")
	{
		// Récupération des informations type de demande
		$row = lit_enr_dded($coderech);
		if (is_array($row))
			extract ($row);
		else
			$pbm_dded = TRUE;
	}
	else
		$pbm_dded = TRUE;
}
else
{
	if ($td <> "add")
		$pbm_dded=TRUE;
}
switch ($td)
{
	case "add" :
		$titre = $titlein_dded_maj_add;
		break;
	case "edit" :
		$titre = $titlein_dded_maj_edit;
		break;
	case "del" :
		$titre = $titlein_dded_maj_del;
		break;
	default:
		$pbm_dded=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; ?> : <?PHP echo $title_dded_maj; ?></title>

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

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

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

<!-- Scripts Javascript pour fenêtres -->

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

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

<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_code); ?> ; lmx:10 ; stok:frmok ; stbad:frmbad",
	"nom:desc ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_lib); ?> ; lmx:40 ; stok:frmok ; stbad:frmbad",
	"nom:email ; format:mail ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_email); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad");
//-->
</script>

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

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

</head>

<?PHP if ($td == "del") 
{
?>
<body onLoad="warndelddet();metReadonly();">
<?PHP } else { ?>
<body onLoad="metFocus();">
<?PHP } ?>

<?php 
	include_once("../inc/entete.inc.php"); 

if ($pbm_dded == FALSE)
{
?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<table width="100%"  border="0">
  <tr>
	<td width="33%"><strong><em><a href="dded_lst.php"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong></td>
	<td width="33%"align="center" class="annot_petit_it">(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>)</td>
	<td width="33%">&nbsp;</td>
  </tr>
</table>
<form name="dded_maj" id="dded_maj" method="post" action="dded_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'','<?PHP echo $_SESSION["lng"]; ?>'));">
		  <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
		  <input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
	
	<table width="100%"  border="0">
		<tr>
		  <td width="160" class="rubfrm" id="f_code" align="right"><?PHP echo $txt_chp_code; ?></td>
		  <td>
		  <?PHP if ($td == "add") { ?>
			  <input name="code" type="text" id="code" value="<?PHP echo $dded_code ?>" size="10" maxlength="10" onChange="javascript:this.value=this.value.toUpperCase();">
			  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		  <?PHP } else { ?>
			  <input name="code" type="text" id="code" value="<?PHP echo $dded_code ?>" size="10" maxlength="10" readonly="1">
		  <?PHP } ?>
		  </td>
		</tr>
		<tr>
			<td width="160" class="rubfrm" id="f_desc" align="right"><?PHP echo $txt_chp_lib; ?></td>
			<td>
				<input name="desc" type="text" id="desc" value="<?PHP echo htmlspecialchars($dded_desc) ?>" size="40" onChange="javascript:this.value=this.value.toUpperCase();"> <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
			</td>
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_pub" align="right"><?PHP echo $txt_chp_accpub; ?></td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"pub\" size=\"1\" id=\"pub\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_pub == 1)
				{
					echo "<select name=\"pub\" size=\"1\" id=\"pub\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"pub\" size=\"1\" id=\"pub\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
			</td>
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_cli" align="right"><?PHP echo $txt_chp_acccli; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"client\" size=\"1\" id=\"client\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_cli == 1)
				{
					echo "<select name=\"client\" size=\"1\" id=\"client\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"client\" size=\"1\" id=\"client\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
			</td>
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_age" align="right"><?PHP echo $txt_chp_accage; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"age\" size=\"1\" id=\"age\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_age == 1)
				{
					echo "<select name=\"age\" size=\"1\" id=\"age\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"age\" size=\"1\" id=\"age\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_tec" align="right"><?PHP echo $txt_chp_acctec; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"tec\" size=\"1\" id=\"tec\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_tec == 1)
				{
					echo "<select name=\"tec\" size=\"1\" id=\"tec\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"tec\" size=\"1\" id=\"tec\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_ope" align="right"><?PHP echo $txt_chp_accope; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"ope\" size=\"1\" id=\"ope\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_ope == 1)
				{
					echo "<select name=\"ope\" size=\"1\" id=\"ope\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"ope\" size=\"1\" id=\"ope\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_cge" align="right"><?PHP echo $txt_chp_accsge; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"cge\" size=\"1\" id=\"cge\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_cge == 1)
				{
					echo "<select name=\"cge\" size=\"1\" id=\"cge\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"cge\" size=\"1\" id=\"cge\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_stt" align="right"><?PHP echo $txt_chp_acctecst; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"stt\" size=\"1\" id=\"stt\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_stt == 1)
				{
					echo "<select name=\"stt\" size=\"1\" id=\"stt\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"stt\" size=\"1\" id=\"stt\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_st" align="right"><?PHP echo $txt_chp_accst; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"st\" size=\"1\" id=\"st\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_st == 1)
				{
					echo "<select name=\"st\" size=\"1\" id=\"st\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"st\" size=\"1\" id=\"st\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_dot" align="right"><?PHP echo $txt_chp_acctecdo; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"dot\" size=\"1\" id=\"dot\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_dot == 1)
				{
					echo "<select name=\"dot\" size=\"1\" id=\"dot\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"dot\" size=\"1\" id=\"dot\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_do" align="right"><?PHP echo $txt_chp_accdo; ?>*</td>
		  <td>
			<?PHP 
			if ($td == "add")
			{ 
				echo "<select name=\"do\" size=\"1\" id=\"do\">";
				echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
				echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
				echo "</select>";
			}
			
			if (($td == "edit") OR ($td == "del"))
			{ 
				if ($dded_do == 1)
				{
					echo "<select name=\"do\" size=\"1\" id=\"do\">";
					echo "<option value=\"Oui\" selected>".$sel_lst_oui."</option>";
					echo "<option value=\"Non\">".$sel_lst_non."</option>";
					echo "</select>";
				}
				else
				{
					echo "<select name=\"do\" size=\"1\" id=\"do\">";
					echo "<option value=\"Oui\">".$sel_lst_oui."</option>";
					echo "<option value=\"Non\" selected>".$sel_lst_non."</option>";
					echo "</select>";
				}
			}
			?>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
		<tr>
		  <td width="160" class="rubfrm" id="f_email" align="right"><?PHP echo $txt_chp_email; ?>**</td>
		  <td>
			  <input name="email" type="text" id="email" value="<?PHP echo $dded_email ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
			  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		</tr>
	  </table>
	  <span class="annot_petit_it">* <?PHP echo $txt_div_paresppri; ?>/ ** <?PHP echo $txt_div_noappdde; ?>.</span><br>
	  
	  <p align="center">
		<?PHP if (($td == "add") OR ($td == "edit")) { ?>
		<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
		<input name="submit" type="submit" class="bton_std" id="submit" value="<?PHP echo $but_enr; ?>">
		<?PHP } ?>
		<?PHP if ($td == "del") { ?>
		<input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo $but_del; ?>">
		<input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo $but_cancel; ?>" onclick="javascript:; history.back();">
		<?PHP } ?>
	  </p>
	</form>
<?php 
}
else
{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('dded_lst.php');",2000)
	//-->
	</script>
<?PHP
}
include_once("pied.php");
?>