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

session_start(); 
?>
<?php if ((@$HTTP_SESSION_VARS["etat_log"] <> "connecte") or ((@$HTTP_SESSION_VARS["niv_log"] <> 9) AND (@$HTTP_SESSION_VARS["niv_log"] <> 5))) header("Location: ../index.php") ?>
<?PHP include ("../inc/config.inc.php") ?>
<?PHP require ("../inc/func.inc.php") ?>
<?PHP require ("../inc/func_date.inc.php") ?>
<?PHP require ("../inc/func_log.inc.php") ?>
<?PHP require ("../inc/fic.inc.php") ?>
<?PHP include("../inc/geoip.inc"); ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?PHP
	$td = strip_tags(trim($_GET['typ']));
	$coderech = strip_tags(trim($_GET['code']));
	$age_dep = strip_tags(trim($_GET['dep']));

	if ($coderech <> "")
	{
		$row = lit_enr_age($coderech);
		extract ($row);

		if ($td == "edit")
			$titre = "MISE A JOUR AGENCE";

		if ($td == "del")
			$titre = "SUPPRESSION AGENCE";
	}
	else
	{
		if ($td == "add")
		{
			$age_ouvert = TRUE;
			$age_pays = pays_connect($_SERVER['REMOTE_ADDR']);
			
			$titre = "CREATION AGENCE";
		}
	}
?>

<!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 : Fiche Agence</title>

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

<!-- Feuille de style & Script pour le menu -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.js"></script>

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

<!-- Affichage nouvelle fenêtre pour impression -->
<script type="text/javascript">
	function lanceimp(page)
	{
	  window.open(page,'impression','width='+screen.width+' height='+screen.height);
	}
</script>

<script language="JavaScript" type="text/JavaScript">
function aff_zone()
{
	var selectedList = new Array();
	var selectBox = document.age_maj.zone; 
	var txtzone = "";
	var txtzonefinal = "";
	for (var i=1; i<selectBox.options.length; i++) { 
	  if (selectBox.options[i].selected) 
	  {
		txtzone += selectBox.options[i].value+"-";
	  } 
	}
	txtzonefinal = txtzone.substring(0,txtzone.length-1);
	window.document.age_maj.zonetxt.value=txtzonefinal;
}
</script>


<div id="patience" style="position:absolute; width:620px; height:50px; z-index:1; left: 50px; top: 120px;">
  <table width="100%"  border="1" cellspacing="0" bordercolor="#FFFF00">
    <tr>
      <td class="titrerubrique1"><div align="center">
        <p>Merci de patienter pendant le chargement des fichiers Villes et Pays</p>
        <p><img src="../img/baratt.gif" width="350" height="11"></p>
      </div></td>
    </tr>
  </table>
</div>

<script language="JavaScript" type="text/JavaScript">
var nava = (document.layers);
var dom = (document.getElementById);
var iex = (document.all);
if (nava) { cach = document.cache }
else if (dom) { cach = document.getElementById("patience").style }
else if (iex) { cach = cache.style }
largeur = screen.width;
cach.left = Math.round((largeur/2)-200);
cach.visibility = "visible";

function cacheOff()
	{
	cach.visibility = "hidden";
	}
window.onload = cacheOff
</script>

</head>

<body>

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

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>

<!-- Affiché uniquement s'il y a au moins une catégorie agence et au moins une civilité -->
<?PHP
if ((nb_acat() <> 0) AND (nb_civ() <> 0))
{
?>
<!-- Formulaire de demande du numéro de département (uniquement si n'existe pas) -->
<?PHP if ($age_dep == "") { ?>
<form name="dde_dep" id="dde_dep" method="GET" action="age_maj.php">
	<p>
	  <input name="typ" type="hidden" id="typ" value="<?PHP echo $td ?>">
	  <input name="code" type="hidden" id="code" value="<?PHP echo $coderech ?>">
</p>
	<p align="center">Merci de choisir le d&eacute;partement auquel appartiendra cette agence.</p>
	<table width="100%"  border="0">
<tr>
	<td width="20%" class="tfvNormal" id="f_ouvert"><div align="right">D&eacute;partement</div></td>
	<td>
		<select name="dep" size="1" id="dep">
		<?PHP
		
		// Création de la liste des départements
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBDEP." ORDER BY dep_nom");
		
		$i=0;
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			if ($i == 0)
			{
				echo "<option value=\"\" selected>-- Choisissez un département --</option>";
			}				
			$chaine_dep = $dep_nom." (".$dep_num.")";
			echo "<option value=\"".$dep_num."\">".$chaine_dep."</option>";
			
			$i++;
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
          <img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
</table>
<p align="center">
	<input type="submit" name="Submit" value="Valider">
</p>
</form>

<script>
// form fields description structure
var a_fields = {
	'dep':{'l':'Code','r':true,'f':'integer','t':'f_dep','mx':3}
},

o_config = {
	'to_disable' : ['submit'],
	'alert' : 1
}

// validator constructor call
var v = new validator('dde_dep', a_fields, o_config);

</script>
<?PHP } ?>
<!-- Fin de formulaire de demande du numéro de département (uniquement si n'existe pas) -->

<!-- Affichage uniquement si numéro de département saisi -->
<?PHP if ($age_dep <> "") { ?>
<table width="100%"  border="0">
  <tr>
    <td width="33%"><strong><em><a href="age_lst.php?ta=m">Retour &agrave; la liste</a></em></strong></td>
    <td width="33%" bgcolor="#FF0000"><div align="center"><span class="titrerubrique1">Coordonn&eacute;es</span></div></td>
    <td width="33%"><div align="right">
      <div align="right">
        <?PHP
		if ($td == "edit")
		{
		$urlimp = "age_maji.php?ca=".$coderech;
		?>
        <a href="javascript:;" onclick="lanceimp('<?PHP echo $urlimp; ?>');")><img src="../img/print.gif" title="Imprimer la fiche" width="22" height="22" border="0" align="abddle"></a> <a href="javascript:;" onclick="lanceimp('<?PHP echo $urlimp; ?>');")> Imprimer la fiche </a></div>
      <?PHP } ?>
	  </div>
	</td>
  </tr>
  <tr>
    <td width="33%">&nbsp;</td>
    <td width="33%" align="center">
    <span class="annot_gras_it">(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)</span>
	</td>
	<td width="33%" align="right">
	<?PHP 
	if ((@$HTTP_SESSION_VARS["niv_log"] >= 3) AND ($td == "edit"))
	{
	  $url_repcli = "fic_down.php?dir=agences/".strtolower($age_code);
	?>
		 <a href="javascript:;" onclick="self.location.href=('<?PHP echo $url_repcli; ?>');")><img src="../img/rep_priv.gif" title="Aller dans le r&eacute;pertoire priv&eacute;" width="22" height="22" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="self.location.href=('<?PHP echo $url_repcli; ?>');")> Aller dans le r&eacute;pertoire priv&eacute;</a>
	<?PHP
	}
	else
		echo "&nbsp;";
	?>
	</td>
  </tr>
</table>

<!-- Formulaire de saisie de la fiche -->
<form name="age_maj" id="age_maj" method="post" action="age_enr.php" onsubmit="return v.exec()">
	<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
	<input name="typdde" type="hidden" id="typdde" value="<?PHP echo $td ?>">
<?PHP if ($td == "add") { ?>
	<input name="ouvert" type="hidden" id="ouvert" value="Oui">
<?PHP } ?>

<!-- Ouverture (avec dates) de l'agence -->
<?PHP if (($td == "edit") OR ($td == "del")) {?>
<table width="100%"  border="0">
<tr>
	<td width="20%" class="tfvNormal" id="f_ouvert"><div align="right">Agence Ouverte</div></td>
	<td>
		<?PHP 
		if (($td == "edit") OR ($td == "del"))
		{ 
			if ($age_ouvert == 1)
			{
				echo "<select name=\"ouvert\" size=\"1\" id=\"ouvert\">";
				echo "<option value=\"Oui\" selected>Oui</option>";
				echo "<option value=\"Non\">Non</option>";
				echo "</select>";
				
				echo "<span class=\"annot_std_it\">";
				echo "  (Depuis le : ".formatedate($age_datecrea).")";
				echo "</span>";
			}
			else
			{
				echo "<input name=\"ouvert\" type=\"text\" id=\"ouvert\" value=\"Non\" size=\"3\" maxlength=\"3\" readonly=\"1\">";
				
				echo "<span class=\"annot_std_it\">";
				echo "  (Ouverte le : ".formatedate($age_datecrea).", fermée le : ".formatedate($age_datec).")";
				echo "</span>";
			}
		}
		?>
		<br>
		<span class="annot_std_it">
		Le fait de fermer cette agence implique le licenciement des techniciens y travaillant.<br>
		Faites si besoin les modifications sur les fiches techniciens AVANT de fermer l'agence.
		</span>
	</td>
</tr>
</table>
<?PHP } ?>

<!-- Fiche principale -->
<table width="100%"  border="0">
<tr>
  <td width="20%" class="tfvNormal" id="f_acat"><div align="right">Cat&eacute;gorie</div></td>
  <td>
		<select name="acat" size="1" id="acat">
		<?PHP
		
		// Création de la liste des catégories
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBACAT." ORDER BY acat_desc");
		
		$i=0;
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			if ($i == 0)
			{
				if ($age_cat <> "")
					echo "<option value=\"\">-- Choisissez une catégorie --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez une catégorie --</option>";
			}

			if ($age_cat == $acat_code)
			{
				echo '<option value="'.$acat_code.'" selected>'.$acat_desc.'</option>';
			}
			else
			{
				echo '<option value="'.$acat_code.'">'.$acat_desc.'</option>';
			}

			$i++;
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
		<img src="../img/oblig.gif" width="10" height="11">
  </td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_code"><div align="right">Code</div></td>
	<td>
		<?PHP if ($td == "add") { ?>
			<strong>A</strong>
			<input name="code" type="text" id="code" value="<?PHP echo $age_code ?>" size="9" maxlength="9" onChange="javascript:this.value=this.value.toUpperCase();">
			<img src="../img/oblig.gif" width="10" height="11">
		<?PHP } else { ?>
			<input name="code" type="text" id="code" value="<?PHP echo $age_code ?>" size="10" maxlength="10" readonly="1">
		<?PHP } ?>
	</td>
</tr>
	<?PHP if (($td == "edit") OR ($td == "del")) { ?>
<tr>
	<td height="21" class="tfvNormal" id="f_logo"><div align="right">Logo</div></td>
	<td>
		<?PHP
			$url_img = "age_logo.php?ca=".$age_code;
		?>
			<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_img; ?>',500,300,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")><img src="../img/view.gif" width="22" height="22" border="0" align="abddle"></a>
			<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_img; ?>',500,300,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> Voir le logo</a>
	</td>
</tr>
<?PHP } ?>
<tr>
	<td width="20%" class="tfvNormal" id="f_nom"><div align="right">Nom</div></td>
	<td>
		<input name="nom" type="text" id="nom" value="<?PHP echo $age_nom ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_rcs"><div align="right">RCS / APE </div></td>
	<td>
		<input name="rcs" type="text" id="rcs" value="<?PHP echo $age_rcs ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
  <td class="tfvNormal" id="f_tcom"><div align="right">Tribunal com. </div></td>
  <td><input name="tcom" type="text" id="tcom" value="<?PHP echo $age_tcom ?>" size="70" maxlength="70" onChange="javascript:this.value=this.value.toUpperCase();">
    <img src="../img/oblig.gif" width="10" height="11"> </td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_adr1"><div align="right">Adresse (1) </div></td>
	<td>
		<input name="adr1" type="text" id="adr1" value="<?PHP echo $age_adr1 ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_adr2"><div align="right">Adresse (2) </div></td>
	<td>
		<input name="adr2" type="text" id="adr2" value="<?PHP echo $age_adr2 ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_dep"><div align="right">D&eacute;partement</div></td>
	<td>
		<input name="dep" type="text" id="dep" value="<?PHP echo $age_dep ?>" size="3" maxlength="3" readonly="1">
	</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_ville"><div align="right">Ville</div></td>
	<td>
		<select name="ville" size="1" id="ville">
		<?PHP
		
		// Création de la liste des villes
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$filtre = $age_dep;
		if (($filtre == "2A") OR ($filtre == "2B"))
			$filtre = "20";
		$rs = mysql_query("SELECT * FROM ".TBVILLES." WHERE `villes_cp` LIKE '".$filtre."%' ORDER BY villes_nom");
		
		$i=0;
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			if ($i == 0)
			{
				if ($age_ville <> "")
					echo "<option value=\"\">-- Choisissez une ville --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez une ville --</option>";
			}

			if ($age_ville == $villes_insee)
			{
				echo '<option value="'.$villes_insee.'" selected>'.str_majuscules($villes_nom).' ('.$villes_cp.')</option>';
			}
			else
			{
				echo '<option value="'.$villes_insee.'">'.str_majuscules($villes_nom).' ('.$villes_cp.')</option>';
			}

			$i++;
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_pays"><div align="right">Pays</div></td>
	<td>
		<select name="pays" size="1" id="pays">
	<?PHP
		
		// Création de la liste des pays
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBPAYS." ORDER BY pays_nom");
		
		$i=0;
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			if ($i == 0)
			{
				if ($age_pays <> "")
					echo "<option value=\"\">-- Choisissez un pays --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez un pays --</option>";
			}

			if ($age_pays == $pays_nom)
			{
				echo '<option value="'.$pays_nom.'" selected>'.$pays_nom.'</option>';
			}
			else
			{
				echo '<option value="'.$pays_nom.'">'.$pays_nom.'</option>';
			}

			$i++;
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
  <td class="tfvNormal" id="f_zone"><div align="right">Zone chalandise</div></td>
  <td>
	<select name="zone[]" size="5" id="zone" multiple="multiple" onBlur="aff_zone();">

	<?PHP
	// Création de la liste des départements
	
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rs = mysql_query("SELECT * FROM ".TBDEP." ORDER BY dep_num");
	
	$i=0;
	
	while ($resultat = mysql_fetch_array($rs)) 
	{
		extract($resultat);

		if ($i == 0)
		{
			if ($age_zone <> "")
				echo "<option value=\"\">-- Choisissez un ou des département(s) --</option>";
			else
				echo "<option value=\"\" selected>-- Choisissez un ou des département(s) --</option>";
		}				
		$chaine_dep = $dep_num." (".$dep_nom.")";
		
		if (dep_in_zc($dep_num,$age_zone) == TRUE)
			echo "<option value=\"".$dep_num."\" selected>".$chaine_dep."</option>";
		else
			echo "<option value=\"".$dep_num."\">".$chaine_dep."</option>";
		
		$i++;
	}
	mysql_free_result($rs);
	mysql_close($conn);
	?>
	</select>
	  <img src="../img/oblig.gif" width="10" height="11">
	 <span class="annot_petit_it">
	  (S&eacute;lectionnez les d&eacute;partements avec Ctrl + clic gauche)
	 <br>
	 D&eacute;partement(s) choisi(s) 
  	 <input name="zonetxt" type="text" id="zonetxt" value="<?PHP echo $age_zone ?>" size="50" maxlength="50" readonly="1" style="background : #FFFFFF;" onFocus="window.document.age_maj.telf.focus();">
	 </span>
  </td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_telf"><div align="right">
		T&eacute;l&eacute;phone Fixe<br>
	    (Commentaire)</div>
	</td>
	<td>
		  <input name="telf" type="text" id="telf" value="<?PHP echo $age_telf ?>" size="20" maxlength="20">
		  <img src="../img/oblig.gif" width="10" height="11"><br>
		  <input name="txttelf" type="text" id="txttelf" value="<?PHP echo $age_txttelf ?>" size="100" maxlength="100">
	</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_fax"><div align="right">
		T&eacute;l&eacute;copieur<br>
		(Commentaire)</div>
	</td>
	<td>
		<input name="fax" type="text" id="fax" value="<?PHP echo $age_fax ?>" size="20" maxlength="20">
		<img src="../img/oblig.gif" width="10" height="11"><br>
		<input name="txtfax" type="text" id="txtfax" value="<?PHP echo $age_txtfax ?>" size="100" maxlength="100">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_web"><div align="right">Site Web </div></td>
	<td>
		<input name="web" type="text" id="web" value="<?PHP echo $age_web ?>" size="80" maxlength="200">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_heures"><div align="right">Horaires</div></td>
	<td>
		<input name="heures" type="text" id="heures" value="<?PHP echo $age_heures ?>" size="80" maxlength="200">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
  <td class="tfvNormal" id="f_com"><div align="right">Texte d'ent&ecirc;te</div></td>
  <td><textarea name="txtent" cols="90" id="txtent"><?PHP echo $age_txtent ?></textarea></td>
</tr>
<tr>
	<td colspan="2">&nbsp;</td>
</tr>
<tr>
	<td colspan="2" class="tfvNormal" id="f_web"><div align="center">Responsable d'agence </div></td>
</tr>
<tr>
	<td class="tfvNormal" id="f_rcivil"><div align="right">Civilit&eacute;</div></td>
	<td>
		<select name="rcivil" size="1" id="rcivil">
		<?PHP
		
		// Création de la liste des civilités
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rs = mysql_query("SELECT * FROM ".TBCIV." ORDER BY civ_desc");
		
		$i=0;
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);

			if ($i == 0)
			{
				if ($age_resp_civilite <> "")
					echo "<option value=\"\">-- Choisissez une civilité --</option>";
				else
					echo "<option value=\"\" selected>-- Choisissez une civilité --</option>";
			}

			if ($age_resp_civilite == $civ_code)
			{
				echo '<option value="'.$civ_code.'" selected>'.$civ_desc.'</option>';
			}
			else
			{
				echo '<option value="'.$civ_code.'">'.$civ_desc.'</option>';
			}

			$i++;
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_rprenom"><div align="right">Pr&eacute;nom</div></td>
	<td>
		<input name="rprenom" type="text" id="rprenom" value="<?PHP echo $age_resp_prenom ?>" size="50" maxlength="50">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_rnom"><div align="right">Nom</div></td>
	<td>
		<input name="rnom" type="text" id="rnom" value="<?PHP echo $age_resp_nom ?>" size="50" maxlength="50">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_rtelf"><div align="right">Tel. Fixe </div></td>
	<td>
		<input name="rtelf" type="text" id="rtelf" value="<?PHP echo $age_resp_telf ?>" size="20" maxlength="20">
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</tr>
<tr>
	<td colspan="2" class="tfvNormal"><div align="center">Emails</div></td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_email"><div align="right">G&eacute;n&eacute;ral</div></td>
	<td>
		<input name="email" type="text" id="email" value="<?PHP echo $age_email ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
		<?PHP if ($td == "edit") { ?>
			<a href="mailto:<?PHP echo $age_email ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="abddle"></a>
		<?PHP } ?>
		<img src="../img/oblig.gif" width="10" height="11"> <span class="annot_std_it">(Pour contacts clients)</span>
	</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_emaild"><div align="right">Direction</div></td>
	<td>
		<input name="emaild" type="text" id="emaild" value="<?PHP echo $age_emaild ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
		<?PHP if ($td == "edit") { ?>
			<a href="mailto:<?PHP echo $age_emaild ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="abddle"></a>
		<?PHP } ?>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_emailc"><div align="right">Comptabilit&eacute;</div></td>
	<td>
		<input name="emailc" type="text" id="emailc" value="<?PHP echo $age_emailc ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
		<?PHP if ($td == "edit") { ?>
			<a href="mailto:<?PHP echo $age_emailc ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="abddle"></a>
		<?PHP } ?>
	<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_emailt"><div align="right">Technique</div></td>
	<td>
		<input name="emailt" type="text" id="emailt" value="<?PHP echo $age_emailt ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
		<?PHP if ($td == "edit") { ?>
			<a href="mailto:<?PHP echo $age_emailt ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="abddle"></a>
		<?PHP } ?>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
<tr>
	<td width="20%">&nbsp;</td>
	<td>&nbsp;</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_nota"><div align="right">Notes</div></td>
	<td><textarea name="nota" cols="90" id="nota"><?PHP echo $age_nota ?></textarea></td>
</tr>
<tr>
	<td width="20%">&nbsp;</td>
	<td>&nbsp;</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_factures"><div align="right">Emet ses factures </div></td>
<td>
	<?PHP 
	if ($td == "add")
	{ 
		echo "<select name=\"factures\" size=\"1\" id=\"factures\">";
		echo "<option value=\"Oui\">Oui</option>";
		echo "<option value=\"Non\" selected>Non</option>";
		echo "</select>";
	}
	
	if (($td == "edit") OR ($td == "del"))
	{ 
		if ($age_fact == TRUE)
		{
			echo "<select name=\"factures\" size=\"1\" id=\"factures\">";
			echo "<option value=\"Oui\" selected>Oui</option>";
			echo "<option value=\"Non\">Non</option>";
			echo "</select>";
		}
		else
		{
			echo "<select name=\"factures\" size=\"1\" id=\"factures\">";
			echo "<option value=\"Oui\">Oui</option>";
			echo "<option value=\"Non\" selected>Non</option>";
			echo "</select>";
		}
	}
	?>
	<img src="../img/oblig.gif" width="10" height="11"> </td>
</tr>
</table>

<p align="center">
<?PHP if (($td == "add") OR ($td == "edit")) { ?>
	<input name="RAZ" type="reset" id="RAZ" value="R&eacute;initialiser">
	<input name="submit" type="submit" id="submit" value="Enregistrer">
<?PHP } ?>
<?PHP if ($td == "del") { ?>
	<input name="del" type="submit" id="del" value="Supprimer">
	<input name="annul" type="button" id="annul" value="Annuler" onclick="javascript:; history.back();">
<?PHP } ?>
</p>
</form>
<!-- Fin de formulaire de saisie de la fiche -->

<?PHP if ($td == "del") 
{
?>
	<script>
	warndelage();
	</script>
<?PHP
}
?>
	
<script>
// form fields description structure
var a_fields = {
	'acat':{'l':'Catégorie','r':true,'f':'alphanum','t':'f_acat','mx':5},
	'code':{'l':'Code','r':true,'f':'alphanum','t':'f_code','mx':9},
	'nom':{'l':'Nom','r':true,'t':'f_nom','mx':50},
	'rcs':{'l':'RCS / APE','r':true,'t':'f_rcs','mx':50},
	'tcom':{'l':'Tribunal de Commerce','r':true,'t':'f_tcom','mx':70},
	'adr1':{'l':'Adresse (1)','r':true,'t':'f_adr1','mx':50},
	'adr2':{'l':'Adresse (2)','r':false,'t':'f_adr2','mx':50},
	'ville':{'l':'Ville','r':true,'t':'f_ville','mx':20},
	'pays':{'l':'Ville','r':true,'t':'f_ville','mx':20},
	'zonetxt':{'l':'Zone de chalandise','r':true,'t':'f_zone','mx':50},
	'telf':{'l':'Téléphone Fixe','r':true,'t':'f_telf','mx':20},
	'fax':{'l':'Télécopieur','r':true,'t':'f_fax','mx':20},
	'rcivil':{'l':'Civilité Responsable','r':true,'t':'f_rcivil'},
	'rprenom':{'l':'Prénom Responsable','r':true,'t':'f_rprenom','mx':50},
	'rnom':{'l':'Nom Responsable','r':true,'t':'f_rnom','mx':50},
	'rtelf':{'l':'Téléphone Responsable','r':true,'t':'f_rtelf','mx':20},
	'heures':{'l':'Détail Horaires','r':true,'t':'f_heures','mx':200},
	'email':{'l':'Email','r':true,'f':'email','t':'f_email','mx':50},
	'emaild':{'l':'Email Direction','r':true,'f':'email','t':'f_emaild','mx':50},
	'emailc':{'l':'Email Service Comptabilité','r':true,'f':'email','t':'f_emailc','mx':50},
	'emailt':{'l':'Email Service Technique','r':true,'f':'email','t':'f_emailt','mx':50}
},

o_config = {
	'to_disable' : ['submit', 'RAZ'],
	'alert' : 1
}

// validator constructor call
var v = new validator('age_maj', a_fields, o_config);

</script>
<?PHP } ?>
<!-- Fin affichage uniquement si numéro de département saisi -->
<!-- Fin affiché uniquement s'il y a au moins une catégorie agence et au moins une civilité -->
<?PHP
}
else
{
	if (nb_acat() == 0)
	{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('acat_lst.php?ta=m');",2000)
	</script>
	<p align="center" class="annot_std_it">Merci de cr&eacute;er au moins une cat&eacute;gorie d'agence...</p>
<?PHP
	}

	if (nb_civ() == 0)
	{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('civ_lst.php?ta=m');",2000)
	</script>
	<p align="center" class="annot_std_it">Merci de cr&eacute;er au moins une civilit&eacute;...</p>
    <?PHP
	}
}
?>


<?php 
	include_once ("pied.php")
?>
