<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 0.9.9

Copyright (C) 2006-2009  Sylvain FATOME
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smitst.homelinux.com
****************************************************************************************/


// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_cocl.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/fic_loc.inc.php");
include_once("../inc/fic_st.inc.php");
include_once("../inc/fic_zc.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_geol.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("geoip.inc.php");
Archivelog(@$_SESSION["code_log"]);

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

if (@$_SESSION["niv_log"] == 4)
{
	$coderech = @$_SESSION["code_log"];
	$td = "edit";
}

$nbinterventions = 0;
$pbm_age=FALSE;
$nbcoloc = 0;

$msg1_err_type=$ajx_nodeppays;
$msg2_err_type=$ajx_novildep;
$msg3_err_type=$ajx_nodeppays;

if ($coderech <> "")
{
	// Vérification qu'il existe bien des interventions et nombre de celles-ci
	$nbinterventions = nb_int($coderech);

	// Récupération des informations agence
	$row = lit_enr_age($coderech,TRUE);
	if (is_array($row))
	{
		extract ($row);
		$nbcoloc = nb_coloc_cli($coderech,$_SESSION["niv_log"],"");

		if (($td<>"del") AND ($age_ouvert==FALSE))
			$td="view";

		if (@$_SESSION["niv_log"] >= 4)
		{
			if (@$_SESSION["niv_log"] == 4)
			{
				if ($coderech<>$_SESSION["code_age"])
					$pbm_age=TRUE;
			}
		}
		else
			$pbm_age=TRUE;
	}
	else
		$pbm_age=TRUE;
}
else
{
	if ($td == "add")
	{
		$age_ouvert = TRUE;
		$age_codepays = pays_connect_code($_SERVER['REMOTE_ADDR']);
	}
	else
		$pbm_age=TRUE;
}

switch ($td)
{
	case "add" :
		$titre = "CREATION AGENCE";
		break;
	case "edit" :
		$titre = "MISE A JOUR AGENCE";
		break;
	case "del" :
		$titre = "SUPPRESSION AGENCE";
		break;
	case "view" :
		$titre = "VISUALISATION AGENCE";
		break;
	default :
		$pbm_age=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; ?> : Fiche Agence</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 vérifications des champs -->
<script language="JavaScript" src="../jscript/verif_field.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(
<?PHP
if (@$_SESSION["niv_log"] >= 5)
{
?>
	"nom:acat ; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_cat); ?>; vmn:1; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_code); ?> ; lmn:1 ; lmx:9; stok:frmok ; stbad:frmbad",
	"nom:nom ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_code); ?>; lmn:1 ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:rcs ; format:siret ; req:N ; txt:<?PHP echo html_entity_decode($txt_chp_siret); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:ape ; format:naf ; req:N ; txt:<?PHP echo html_entity_decode($txt_chp_ape); ?> ; lmx:10; stok:frmok ; stbad:frmbad",
	"nom:tvai ; format:tva ; req:N ; txt:<?PHP echo html_entity_decode($txt_chp_tvai); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:tcom ; format:txt ; req:N ; txt:CodeTribunal de commerce; lmn:1 ; lmx:70; stok:frmok ; stbad:frmbad",
	"nom:adr1 ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_adr1); ?> ; lmn:1 ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:adr2 ; format:txt ; req:N ; txt:<?PHP echo html_entity_decode($txt_chp_adr2); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:ville ; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_ville); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:dep ; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_pays); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:pays ; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_pays); ?> ; vmn:1; stok:frmok ; stbad:frmbad",
<?PHP
if (@$_SESSION["niv_log"] >= 5)
{
?>
	"nom:zone[] ; format:listem ; req:Y ; txt:Zone de Chalandise; vmn:1; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:telf ; format:tel ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_telf); ?>; stok:frmok ; stbad:frmbad",
	"nom:txttelf ; format:txt ; req:N ; txt:Commentaire téléphone fixe; lmx:100 ; stok:frmok ; stbad:frmbad",
	"nom:fax ; format:tel ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_fax); ?>; stok:frmok ; stbad:frmbad",
	"nom:txtfax ; format:txt ; req:N ; txt:Commentaire télécopieur; lmx:100 ; stok:frmok ; stbad:frmbad",
	"nom:web ; format:url_npref ; req:N ; txt:Adresse site web; lmx:200; stok:frmok ; stbad:frmbad",
	"nom:heures ; format:txt ; req:Y ; txt:Horaires; lmx:200; stok:frmok ; stbad:frmbad",
	"nom:txtent ; format:txt ; req:N ; txt:Texte d'entête; stok:frmok ; stbad:frmbad",
	"nom:rcivil ; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_civil); ?> responsable d'agence; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:rprenom ; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_pnom); ?> responsable d'agence; lmn:1; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:rnom ; format:txt ; req:Y ; txt:Nom responsable d'agence; lmn:1; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:rtelf ; format:tel ; req:Y ; txt:N° tel fixe responsable d'agence; stok:frmok ; stbad:frmbad",
	"nom:rtelp ; format:telp ; req:N ; txt:N° tel portable responsable d'agence; stok:frmok ; stbad:frmbad",
	"nom:email ; format:mail ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_email)." ".html_entity_decode($txt_chp_emailgeneral); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emaild ; format:mail ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_email)." ".html_entity_decode($txt_chp_emaildir); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emailc ; format:mail ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_email)." ".html_entity_decode($txt_chp_emailcpta); ?> ; lmx:50; stok:frmok ; stbad:frmbad",
<?PHP
if (@$_SESSION["niv_log"] >= 5)
{
?>
	"nom:nota ; format:txt ; req:N ; txt:<?PHP echo html_entity_decode($txt_chp_notes); ?>; stok:frmok ; stbad:frmbad",
<?PHP
}
?>
	"nom:emailt ; format:mail ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_email)." ".html_entity_decode($txt_chp_emailtech); ?> ; 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>

<!-- Scripts Ajax -->
<script type="text/javascript" src="../ajax/util.js"></script>
<script type="text/javascript" src="../ajax/SelectUpdater.js"></script>

<?PHP if ($pbm_age==FALSE) { ?>
<script type="text/javascript">
<!--        
function updateVille()
{
	villeUpdater = new SelectUpdater("ville", "<?PHP echo $rep_appli.'/ajax/'; ?>recupville.php?dep=", "attn2", "msg2", "<?PHP echo $msg2_err_type; ?>");
	anciendep = "";
	document.getElementById("dep").onchange = function() {
		var listedep = document.getElementById("dep");
		var dep = listedep.options[listedep.selectedIndex].value;
		var listepays = document.getElementById("pays");
		var codepays = listepays.options[listepays.selectedIndex].value;
		if (dep.length > 0)
		{
			if (dep != anciendep)
			{
				// Faire l'appel Ajax
				var prmget=dep+"_"+codepays;
				villeUpdater.run(prmget);
				anciendep = dep;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			villeUpdater.reset();
			anciendep = "";
		}
	}
}

<?PHP if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)) { ?>
function updateDep()
{
	depUpdater = new SelectUpdater("dep", "<?PHP echo $rep_appli.'/ajax/'; ?>recupdep.php?pays=", "attn1", "msg1", "<?PHP echo $msg1_err_type; ?>");
	ZCUpdater = new SelectUpdater("zone", "<?PHP echo $rep_appli.'/ajax/'; ?>recupdep.php?pays=", "attn3", "msg3", "<?PHP echo $msg3_err_type; ?>");
	anciencodepays = "";
	anciendep = "";
	document.getElementById("pays").onchange = function() {
		var listepays = document.getElementById("pays");
		var codepays = listepays.options[listepays.selectedIndex].value;
		if (codepays.length > 0)
		{
			if (codepays != anciencodepays)
			{
				// Faire l'appel Ajax
				depUpdater.run(codepays);
				ZCUpdater.run(codepays);
				document.getElementById("ville").value='';
				var txthtml = "<option><?PHP echo $sel_lst_makechx; ?></option>\n";
				document.getElementById("ville").innerHTML=txthtml;
				document.getElementById("attn2").innerHTML = "";
				document.getElementById("msg2").innerHTML = "";
				anciencodepays = codepays;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			depUpdater.reset();
			ZCUpdater.reset();
			var txthtml = "<option><?PHP echo $sel_lst_makechx; ?></option>\n";
			document.getElementById("ville").innerHTML=txthtml;
			document.getElementById("attn2").innerHTML = "";
			document.getElementById("msg2").innerHTML = "";
			anciencodepays = "";
		}
	}
}
<?PHP } else { ?>
function updateDep()
{
	depUpdater = new SelectUpdater("dep", "<?PHP echo $rep_appli.'/ajax/'; ?>recupdep.php?pays=", "attn1", "msg1", "<?PHP echo $msg1_err_type; ?>");
	anciencodepays = "";
	anciendep = "";
	document.getElementById("pays").onchange = function() {
		var listepays = document.getElementById("pays");
		var codepays = listepays.options[listepays.selectedIndex].value;
		if (codepays.length > 0)
		{
			if (codepays != anciencodepays)
			{
				// Faire l'appel Ajax
				depUpdater.run(codepays);
				document.getElementById("ville").value='';
				var txthtml = "<option><?PHP echo $sel_lst_makechx; ?></option>\n";
				document.getElementById("ville").innerHTML=txthtml;
				document.getElementById("attn2").innerHTML = "";
				document.getElementById("msg2").innerHTML = "";
				anciencodepays = codepays;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			depUpdater.reset();
			var txthtml = "<option><?PHP echo $sel_lst_makechx; ?></option>\n";
			document.getElementById("ville").innerHTML=txthtml;
			document.getElementById("attn2").innerHTML = "";
			document.getElementById("msg2").innerHTML = "";
			anciencodepays = "";
		}
	}
}
<?PHP } ?>
//-->
</script>
<?PHP } ?>

</head>


<?PHP if ($td == "del"){ ?>
<body onLoad="verif_contacts('0','ctact','<?PHP echo nb_cage_in_age($coderech); ?>');warndelage();metReadonly();">
<?PHP } 
if ($td == "view"){ ?>
<body onLoad="metReadonly();">
<?PHP } 
if (($td == "add") OR ($td == "edit")) { ?>
<body onLoad="verif_contacts('0','ctact','<?PHP echo nb_cage_in_age($coderech); ?>');updateDep();updateVille();metFocus();">
<?PHP 
}
include_once("../inc/entete.inc.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 ($pbm_age==FALSE)
{
if ((nb_acat() <> 0) AND (nb_civ() <> 0))
{
?>
<table width="100%"  border="0">
  <tr>
    <td width="33%">
	<?PHP if (@$_SESSION["niv_log"] >= 5) { ?>
	<strong><em><a href="age_lst.php"><?PHP echo $txt_lnk_ret_liste; ?></a></em></strong>
	<?PHP } else echo "&nbsp;"; ?>
	</td>
    <td width="33%">&nbsp;</td>
	<td width="33%" align="right">
		<?PHP
		if (($td == "edit") OR ($td == "view"))
		{
		?>
		<select name="etats" size="1" id="etats" onChange="javascript:; lanceimp(this.value);  this.value='';" class="annot_petit">
		<option value="" selected>&raquo; Etats &laquo;</option>
		<?PHP
		if (@$_SESSION["niv_log"]<>2)
		{
			$urlimp = "age_maji.php?ca=".$coderech;
			echo "<option value=\"".$urlimp."\"  class=\"icone\" style=\"background-image: url(../img/sel_fiche.gif);\">Fiche Agence</option>\n";

			if ($nbinterventions <> 0)
			{
				echo "<optgroup label=\"Interventions\" class=\"icone\" style=\"background-image: url(../img/sel_int.gif);\">\n";
				if ((@$_SESSION["niv_log"]==5) OR (@$_SESSION["niv_log"]==9))
					$url_inter = "int_lsti.php?ord=DES&tri=Code&search=".$age_code."&rech=Rechercher";
				else
					$url_inter = "int_lsti.php?ord=DES&tri=Code";
				echo "<option value=\"".$url_inter."\">Liste</option>\n";
				echo "</optgroup>\n";
			}

			if (nb_cocl($age_code) <> 0)
			{
				echo "<optgroup label=\"Contrats\" class=\"icone\" style=\"background-image: url(../img/sel_con.gif);\">\n";
				if ((@$_SESSION["niv_log"]==5) OR (@$_SESSION["niv_log"]==9))
					$url_cocl = "cocl_lsti.php?ord=DES&tri=Code&search=".$age_code."&rech=Rechercher";
				else
					$url_cocl = "cocl_lsti.php?ord=DES&tri=Code";
				echo "<option value=\"".$url_cocl."\">Liste</option>\n";
				echo "</optgroup>\n";
			}
		}
		?>		
		</select>
		<?PHP } else { ?>
		&nbsp;
		<?PHP } ?>
	</td>
  </tr>
  <tr>
    <td width="33%">
    <?PHP if ($td == "edit")
	{
		$url_cage = "cage_maj.php?td=add&ca=".$age_code."&tx=age";
	?>
		<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_cage; ?>',950,560,'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="fensaisie('<?PHP echo $url_cage; ?>',950,560,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")> Ajouter un contact </a>
	<?PHP
		$url_cage = "cage_maj.php?td=lst&ca=".$age_code."&tx=age";

		if ($nbcontacts == 0)
			echo '<span id="ctact" style="display:none">';
		else
			echo '<span id="ctact" style="display:inline">';
	?>
		/
		<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_cage; ?>',950,560,'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no');")> Edition contacts</a>
	<?PHP
		echo '</span>';
	}
	?>
	</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>
  <tr>
    <td width="33%">
	<?PHP 
	if ((@$_SESSION["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.png" title="Aller dans le r&eacute;pertoire priv&eacute;" 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>
    <td width="33%" align="center">
	<?PHP if (($td == "edit") AND (@$_SESSION["niv_log"]>=5))
	{
		$url_addcoloc = "coloc_maj.php?td=add&tc=1&cc=".$age_code."&ca=";
	?>
		<img src="../img/coloc.png" align="absmiddle">
		<a href="javascript:;" onclick="self.location.href=('<?PHP echo $url_addcoloc; ?>');")> Saisir contrat location </a>
	<?PHP
		if ($nbcoloc <> 0)
		{
			$url_coloc = "coloc_lst.php?ord=DES&tri=Code&search=".$age_code."&rech=Rechercher";
	?>
		/
		<a href="javascript:;" onclick="self.location.href=('<?PHP echo $url_coloc; ?>');")> Voir contrats location (<?PHP echo sprintf ("%'03s",$nbcoloc);?>)</a>
	<?PHP
		}
	}
	else
		echo "&nbsp;";
	?>
	</td>
	<td width="33%" align="right">&nbsp;</td>
  </tr>
</table>

<!-- Formulaire de saisie de la fiche -->
<form name="age_maj" id="age_maj" method="post" action="age_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,document.age_maj.pays.value,'<?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 ?>">
<?PHP if ($td == "add") { ?>
<input name="ouvert" type="hidden" id="ouvert" value="1">
<?PHP } ?>

<!-- Ouverture (avec dates) de l'agence -->
<?PHP 
if (@$_SESSION["niv_log"] >= 5)
{
	if (($td == "edit") OR ($td == "del") OR ($td == "view"))
	{
?>
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_ouvert" align="right">Agence Ouverte</td>
	<td>
		<?PHP 
		if ($td == "edit")
		{ 
			echo '<select name="ouvert" id="ouvert">';
			foreach ($non_oui as $key=>$value)
			{
				echo '<option value="'.$key.'"'; 
				if ($age_ouvert == $key)
					echo ' selected';
				echo '>';
				echo $value."</option>";
			}
			echo '</select>';
			echo '<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">';
		}
		else
		{
			echo '<input name="ouvert" type="hidden" id="ouvert" value="'.$age_ouvert.'" readonly="readonly">';
			echo '<input name="nouvert" type="text" id="nouvert" value="'.$non_oui[$age_ouvert].'" size="3" readonly="readonly">';
		}

		echo "<span class=\"annot_petit_it\">";
		if ($age_ouvert==1)
		{
			echo "  (Depuis le : ".formatedate($age_datecrea).")";
			echo "<br />";
			echo "Le fait de fermer cette agence implique le licenciement des techniciens y travaillant.<br>";
			echo "Faites si besoin les modifications sur les fiches techniciens AVANT de fermer l'agence.";
		}
		else
			echo "  (Ouverte le : ".formatedate($age_datecrea).", ferm&eacute;e le : ".formatedate($age_datec).")";
		echo "</span>";
		?>
	</td>
	<td align="right" valign="top">
	<?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/vlogo.png" border="0" align="absmiddle"></a>
		<a href="javascript:;" onclick="fensaisie('<?PHP echo $url_img; ?>',500,300,'status=no,scrollbars=no,menubar=no,statusbar=no,location=no,locationbar=no');")> <?PHP echo $txt_lnk_view_logo; ?></a>
	<?PHP 
	if (!file_exists($chemin_logos."/log".strtolower($age_code).".png"))
	{
		echo "<div class=\"annot_petit_it\">";
		echo "Pas de logo pour cette agence";
		if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
			echo "<br />(<a href=\"logo_maj.php?td=age\">".$txt_lnk_conf."</a>)";
		echo "</div>";
	}
	?>
	</td>
</tr>
</table>
<?PHP }
}
?>

<!-- Fiche principale -->
<table width="100%"  border="0">
<?PHP 
if (@$_SESSION["niv_log"] >= 5)
{
?>
<tr>
  <td width="160" class="rubfrm" id="f_acat" align="right">Cat&eacute;gorie</td>
  <td>
		<select name="acat" size="1" id="acat">
		<?PHP
		
		echo "<option value=\"\">-- Choisissez une catégorie --</option>";

		// 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");
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			if ($age_cat == $acat_code)
			{
				echo '<option value="'.$acat_code.'" selected>'.$acat_desc.'</option>';
			}
			else
			{
				echo '<option value="'.$acat_code.'">'.$acat_desc.'</option>';
			}
		}
		mysql_free_result($rs);
		mysql_close($conn);
		?>
		</select>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
  </td>
</tr>
<?PHP
}
?>
<tr>
	<td width="160" class="rubfrm" id="f_code" align="right"><?PHP echo $txt_chp_code; ?></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.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP } else { ?>
			<input name="code" type="text" id="code" value="<?PHP echo $age_code ?>" size="10" maxlength="10" readonly="1">
		<?PHP } ?>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_nom" align="right"><?PHP echo $txt_chp_nom; ?></td>
	<td>
	<?PHP 
	if (@$_SESSION["niv_log"] >= 5)
	{
	?>
		<input name="nom" type="text" id="nom" value="<?PHP echo htmlspecialchars($age_nom) ?>" size="50" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	}
	else
	{
	?>
		<input name="nom" type="text" id="nom" value="<?PHP echo htmlspecialchars($age_nom) ?>" size="50" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_rcs" align="right"><?PHP echo $txt_chp_siret; ?></td>
	<td>
	<?PHP 
	if (@$_SESSION["niv_log"] >= 5)
	{
	?>
		<input name="rcs" type="text" id="rcs" value="<?PHP echo htmlspecialchars($age_rcs) ?>" size="50" onChange="javascript:this.value=this.value.toUpperCase();">
	<?PHP
	}
	else
	{
	?>
		<input name="rcs" type="text" id="rcs" value="<?PHP echo htmlspecialchars($age_rcs) ?>" size="50" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_ape" align="right"><?PHP echo $txt_chp_ape; ?></td>
	<td>
	<?PHP 
	if (@$_SESSION["niv_log"] >= 5)
	{
	?>
		<input name="ape" type="text" id="ape" value="<?PHP echo htmlspecialchars($age_ape) ?>" size="10" onChange="javascript:this.value=this.value.toUpperCase();">
	<?PHP
	}
	else
	{
	?>
		<input name="ape" type="text" id="ape" value="<?PHP echo htmlspecialchars($age_ape) ?>" size="10" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_tvai" align="right"><?PHP echo $txt_chp_tvai; ?></td>
	<td>
	<?PHP 
	if (@$_SESSION["niv_log"] >= 5)
	{
	?>
		<input name="tvai" type="text" id="tvai" value="<?PHP echo htmlspecialchars($age_tvai) ?>" size="50" onChange="javascript:this.value=this.value.toUpperCase();">
	<?PHP
	}
	else
	{
	?>
		<input name="tvai" type="text" id="tvai" value="<?PHP echo htmlspecialchars($age_tvai) ?>" size="50" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
<tr>
  <td class="rubfrm" id="f_tcom" align="right"><?PHP echo $txt_chp_tcom; ?></td>
  <td>
	<?PHP 
	if (@$_SESSION["niv_log"] >= 5)
	{
	?>
		<input name="tcom" type="text" id="tcom" value="<?PHP echo htmlspecialchars($age_tcom) ?>" size="70" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	}
	else
	{
	?>
	  	<input name="tcom" type="text" id="tcom" value="<?PHP echo htmlspecialchars($age_tcom) ?>" size="70" readonly="1">
	<?PHP
	}
	?>
  </td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_adr1" align="right"><?PHP echo $txt_chp_adr1; ?></td>
	<td>
	<?PHP 
	if (@$_SESSION["niv_log"] >= 5)
	{
	?>
		<input name="adr1" type="text" id="adr1" value="<?PHP echo htmlspecialchars($age_adr1) ?>" size="50" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	}
	else
	{
	?>
		<input name="adr1" type="text" id="adr1" value="<?PHP echo htmlspecialchars($age_adr1) ?>" size="50" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_adr2" align="right"><?PHP echo $txt_chp_adr2; ?></td>
	<td>
	<?PHP 
	if (@$_SESSION["niv_log"] >= 5)
	{
	?>
		<input name="adr2" type="text" id="adr2" value="<?PHP echo htmlspecialchars($age_adr2) ?>" size="50" onChange="javascript:this.value=this.value.toUpperCase();">
	<?PHP
	}
	else
	{
	?>
		<input name="adr2" type="text" id="adr2" value="<?PHP echo htmlspecialchars($age_adr2) ?>" size="50" readonly="1">
	<?PHP
	}
	?>
	</td>
</tr>
</tr>
	<tr>
		<td class="rubfrm" id="f_pays" align="right"><?PHP echo $txt_chp_pays; ?></td>
		<td>
		<?PHP
		if ($age_ouvert == TRUE)
		{
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rs = mysql_query("SELECT * FROM ".TBPAYS." ORDER BY pays_nom");
		?>			
			<select name="pays" id="pays">
		<?PHP
			echo "<option value=\"\">".$sel_lst_pays."</option>";
	
			// Création de la liste des pays
			
			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				if ($age_codepays == $pays_code)
					echo '<option value="'.$pays_code.'" selected>'.$pays_nom.'</option>';
				else
					echo '<option value="'.$pays_code.'">'.$pays_nom.'</option>';
			}
		?>
			</select>
			<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP
			mysql_free_result($rs);
			mysql_close($conn);
		}
		else
		{
			$pays = Retournepays_open($age_codepays,TRUE);
		?>
			<input name="pays" type="hidden" id="pays" value="<?PHP echo $age_codepays ?>">
			<input name="pays_nom" type="text" id="pays_nom" value="<?PHP echo $pays ?>" size="50"  readonly="1">
		<?PHP
		}
		?>
		</td>
	</tr>
	<tr>
		<td class="rubfrm" id="f_dep" align="right"><?PHP echo $txt_chp_dep; ?></td>
		<td>
		<?PHP
		if ($age_ouvert == TRUE) 
		{
			// Création de la liste des départements
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech="SELECT * FROM ".TBDEP." WHERE `dep_codepays`='".$age_codepays."' ORDER BY dep_code";
			$rs = mysql_query($rech) or die(mysql_error());
		?>
		<select name="dep" size="1" id="dep">
		<?PHP
		echo "<option>".$sel_lst_makechx."</option>";

		if (mysql_num_rows($rs)>0)
		{
			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				if ($dep_code<>$dep_nom)
					$dep=$dep_code." (".$dep_nom.")";
				else
					$dep=$dep_nom;
				if ($age_dep == $dep_code)
					echo "<option value=\"".$dep_code."\" selected>".$dep."</option>";
				else
					echo "<option value=\"".$dep_code."\">".$dep."</option>";
			}
		}
		else
			echo "<option value=\"-1\" selected>".$sel_lst_unknown."</option>";
		?>
		</select>
		 <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		 <span id="attn1"></span><span id="msg1" style="background-color:#FF0000; color:#FFFF00; font-weight:bold"><?PHP if ((mysql_num_rows($rs)==0) AND ($td<>"del")) echo htmlspecialchars($msg1_err_type)?></span>
		<?PHP
			mysql_free_result($rs);
			mysql_close($conn);
		}
		else
		{
			$dept=Retournedep_open($age_dep,$age_codepays,TRUE);
			if ($age_dep<>$dept)
				$dep=$age_dep." (".$dept.")";
			else
				$dep=$dept;
		?>
			<input name="dep" type="hidden" id="dep" value="<?PHP echo $age_dep ?>">
			<input name="dep_nom" type="text" id="dep_nom" value="<?PHP echo $dep ?>" size="40"  readonly="1">
		<?PHP
		}
		?>
		</td>
	</tr>
	<tr>
		<td class="rubfrm" id="f_ville" align="right"><?PHP echo $txt_chp_ville; ?></td>
		<td>
		<?PHP
		if ($age_ouvert == TRUE) 
		{
			// Création de la liste des villes
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
	
			$rech="";
			if ($age_dep<>"")
			{
				if ($age_dep<>"-1")
				{
					$filtre=$age_dep;
					if (($filtre == "2A") OR ($filtre == "2B"))
						$filtre = "20";
					$rech = "SELECT * FROM ".TBVILLES." WHERE `villes_dep` = '".str_majuscules($filtre)."' AND `villes_codepays`='".str_majuscules($age_codepays)."' ORDER BY villes_nom";
				}
				else
				{
					$rech = "SELECT * FROM ".TBVILLES." WHERE `villes_codepays`='".str_majuscules($age_codepays)."' ORDER BY villes_nom";
				}
			}
			if ($rech<>"")
				$rs = mysql_query($rech) or die(mysql_error());
		?>
		<select name="ville" size="1" id="ville">
		<?PHP
		echo "<option>".$sel_lst_makechx."</option>";

		if ($rech<>"")
		{
			if (mysql_num_rows($rs)>0)
			{
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
					if ($age_ville == $villes_id)
						echo '<option value="'.$villes_id.'" selected>'.str_majuscules($villes_nom).' ('.$villes_cp.')</option>';
					else
						echo '<option value="'.$villes_id.'">'.str_majuscules($villes_nom).' ('.$villes_cp.')</option>';
				}
			}
		}
		?>
		</select>
	     <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		 <span id="attn2"></span><span id="msg2" style="background-color:#FF0000; color:#FFFF00; font-weight:bold"><?PHP if ($rech<>"") {if ((mysql_num_rows($rs)==0) AND ($td<>"del")) echo htmlspecialchars($msg2_err_type);}?></span>
		<?PHP
			mysql_close($conn);
		}
		else
		{
			$ville = Retourneville_openId($age_ville,TRUE);
		?>
			<input name="ville" type="hidden" id="ville" value="<?PHP echo $age_ville ?>">
			<input name="ville_nom" type="text" id="ville_nom" value="<?PHP echo $ville ?>" size="40"  readonly="1">
		<?PHP
		}
		?>
		</td>
	</tr>
<tr>
  <td class="rubfrm" id="f_zone" align="right">Zone chalandise</td>
  <td>
	<?PHP 
	// Création de la liste des départements
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech="";
	if ($age_codepays<>"")
	{
		$rech = "SELECT * FROM ".TBDEP." WHERE dep_codepays='".str_majuscules($age_codepays)."' ORDER BY dep_code";
		$rs = mysql_query($rech) or die(mysql_error());
	}

	$viewonly=FALSE;
	if (($td=="edit") OR ($td=="add"))
	{
		if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
		{
			echo '<span class="annot_petit_it">';
			echo '(S&eacute;lectionnez les d&eacute;partements avec Ctrl + clic gauche)';
			echo '</span>';
			echo '<br />';
			echo '<select name="zone[]" size="5" id="zone" multiple="multiple" onChange="utxtfromselm(this.id,\'zonetxt\');">';
			echo '<option>'.$sel_lst_makechx.'</option>';
		}
		else
		{
			$viewonly=TRUE;
			echo '<select name="zone[]" size="5" id="zone" multiple="multiple" disabled="disabled">';
			echo '<option>'.$sel_lst_makechx.'</option>';
		}
	}
	else
	{
		$viewonly=TRUE;
		echo '<select name="zone[]" size="5" id="zone" multiple="multiple" disabled="disabled">';
		echo '<option>'.$sel_lst_makechx.'</option>';
	}

	if ($rech<>"")
	{
		if (mysql_num_rows($rs)>0)
		{
			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				$chaine_dep = $dep_code." (".$dep_nom.")";
				if ($viewonly==FALSE)
				{
					echo '<option value="'.$dep_code.'"';
					if (dep_in_zcc_age_open($dep_code,$dep_codepays,$age_code,FALSE)==TRUE)
						echo ' selected';
					echo '>'.$chaine_dep.'</option>';
				}
				else
				{
					if (dep_in_zcc_age_open($dep_code,$dep_codepays,$age_code,FALSE)==TRUE)
					{
						echo '<option value="'.$dep_code.'"';
						echo ' selected>'.$chaine_dep.'</option>';
					}
				}
			}
		}
	}

	echo '</select>';
	mysql_close($conn);
	
	if ($viewonly==FALSE)
	{
	?>
		  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		 <span id="attn3"></span><span id="msg3" style="background-color:#FF0000; color:#FFFF00; font-weight:bold">
		 <?PHP if ((($rech<>"") AND (mysql_num_rows($rs)==0) AND ($td<>"del")) OR ($rech=="")) echo htmlspecialchars($msg3_err_type);?>
		 </span>
	<?PHP
	}
	?>
	 <br />
	 <span class="annot_petit_it">
	 D&eacute;partement(s) choisi(s) 
	 <input name="zonetxt" type="text" id="zonetxt" value="<?PHP echo str_zcc_age_open($age_code,TRUE); ?>" size="50" readonly="1" style="background : #FFFFFF;" onFocus="window.document.age_maj.telf.focus();">
	 </span>
  </td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_telf" align="right">
		<?PHP echo $txt_chp_telf; ?><br>
	    (<?PHP echo $txt_div_comment; ?>)</div>
	</td>
	<td>
		  <input name="telf" type="text" id="telf" value="<?PHP echo $age_telf ?>" size="20" maxlength="20">
		  <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"><br>
		  <input name="txttelf" type="text" id="txttelf" value="<?PHP echo htmlspecialchars($age_txttelf) ?>" size="100">
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_fax" align="right">
		<?PHP echo $txt_chp_fax; ?><br>
		(<?PHP echo $txt_div_comment; ?>)</div>
	</td>
	<td>
		<input name="fax" type="text" id="fax" value="<?PHP echo $age_fax ?>" size="20" maxlength="20">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"><br>
		<input name="txtfax" type="text" id="txtfax" value="<?PHP echo htmlspecialchars($age_txtfax) ?>" size="100">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_web" align="right">Site Web <span class="annot_petit_it">(<?PHP echo $txt_div_nopref; ?>)</span></td>
	<td>
		<input name="web" type="text" id="web" value="<?PHP echo $age_web ?>" size="80" maxlength="200">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_heures" align="right"><?PHP echo $txt_chp_horaires; ?></td>
	<td>
		<input name="heures" type="text" id="heures" value="<?PHP echo htmlspecialchars($age_heures) ?>" size="80">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
  <td class="rubfrm" id="f_com" align="right">Texte d'ent&ecirc;te</td>
  <td><textarea name="txtent" id="txtent"><?PHP echo htmlspecialchars($age_txtent) ?></textarea></td>
</tr>
<tr>
	<td colspan="2">&nbsp;</td>
</tr>
<tr>
	<td colspan="2" class="rubfrm" id="f_web" align="center">
	Responsable d'agence
	<?PHP
	if (($td=="edit") AND ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9)))
	{
		$url_agepr = "agepr_maj.php?td=add&ca=".$age_code;
		echo ' <a href="javascript:;" onclick="fensaisie(\''.$url_agepr.'\',800,500,\'status=no,scrollbars=yes,menubar=no,statusbar=no,location=no,locationbar=no\');"><img src="../img/pr.png" border="0" align="top" title="Prix de revient"></a>';
	}
	?>
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_rcivil" align="right"><?PHP echo $txt_chp_civil; ?></td>
	<td>
		<select name="rcivil" size="1" id="rcivil">
		<?PHP
		
		echo "<option>".$sel_lst_civil."</option>";

		// 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");
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			if ($age_resp_civilite == $civ_code)
			{
				echo '<option value="'.$civ_code.'" selected>'.$civ_desc.'</option>';
			}
			else
			{
				echo '<option value="'.$civ_code.'">'.$civ_desc.'</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 class="rubfrm" id="f_rprenom" align="right"><?PHP echo $txt_chp_pnom; ?></td>
	<td>
		<input name="rprenom" type="text" id="rprenom" value="<?PHP echo htmlspecialchars($age_resp_prenom) ?>" size="50" onChange="javascript:this.value=ucWords(this.value,true);">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_rnom" align="right"><?PHP echo $txt_chp_nom; ?></td>
	<td>
		<input name="rnom" type="text" id="rnom" value="<?PHP echo htmlspecialchars($age_resp_nom )?>" size="50" onChange="javascript:this.value=this.value.toUpperCase();">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_rtelf" align="right"><?PHP echo $txt_chp_telf; ?></td>
	<td>
		<input name="rtelf" type="text" id="rtelf" value="<?PHP echo $age_resp_telf ?>" size="20" maxlength="20">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td class="rubfrm" id="f_rtelp" align="right"><?PHP echo $txt_chp_telp; ?></td>
	<td>
		<input name="rtelp" type="text" id="rtelp" value="<?PHP echo $age_resp_telp ?>" size="20" maxlength="20">
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
</tr>
<tr>
	<td colspan="2" class="rubfrm" align="center"><?PHP echo $txt_chp_emails; ?></td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_email" align="right"><?PHP echo $txt_chp_emailgeneral; ?></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" title="<?PHP echo $alt_envemail; ?>" border ="0" align="absmiddle"></a>
		<?PHP } ?>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> <span class="annot_std_it">(<?PHP echo $txt_div_ctactcli; ?>)</span>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_emaild" align="right"><?PHP echo $txt_chp_emaildir; ?></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" title="<?PHP echo $alt_envemail; ?>" border ="0" align="absmiddle"></a>
		<?PHP } ?>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_emailc" align="right">Comptabilit&eacute;</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" title="<?PHP echo $alt_envemail; ?>" border ="0" align="absmiddle"></a>
		<?PHP } ?>
	<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_emailt" align="right"><?PHP echo $txt_chp_emailtech; ?></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" title="<?PHP echo $alt_envemail; ?>" border ="0" align="absmiddle"></a>
		<?PHP } ?>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	</td>
</tr>
<tr>
	<td colspan="2">&nbsp;</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_nota" align="right"><?PHP echo $txt_chp_notes; ?></td>
	<td><textarea name="nota" id="nota"><?PHP echo htmlspecialchars($age_nota) ?></textarea></td>
</tr>
</table>

<?PHP
if (@$_SESSION["niv_log"] >= 5)
{
?>
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_factures" align="right">Emet ses factures </td>
<td>
	<?PHP 
	if (($td == "add") OR ($td == "edit"))
	{ 
		echo "<select name=\"factures\" size=\"1\" id=\"factures\">";
		foreach ($non_oui as $key=>$value)
		{
			echo '<option value="'.$key.'"'; 
			if ($age_fact == $key)
				echo ' selected';
			echo '>';
			echo $value."</option>";
		}
		echo '</select>';
		echo '<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">';
	}
	else
	{
		echo '<input name="factures" type="hidden" id="factures" value="'.$age_fact.'" readonly="readonly">';
		echo '<input name="nfactures" type="text" id="nfactures" value="'.$non_oui[$age_fact].'" size="3" readonly="readonly">';
	}
	?>
	<br /><span class="annot_petit_it">'Non' : Le centre de gestion sera pr&eacute;venu pour facturer.</span>
	</td>
	<td width="160" class="rubfrm" id="f_dloc" align="right">Location / Pr&ecirc;t</td>
	<td>
	<?PHP 
	if (exist_age_in_coloc($age_code,TRUE)==FALSE)
	{
		if (($td == "add") OR ($td == "edit"))
		{ 
			echo '<select name="loc" id="loc">';
			foreach ($non_oui as $key=>$value)
			{
				echo '<option value="'.$key.'"'; 
				if ($age_loc == $key)
					echo ' selected';
				echo '>';
				echo $value."</option>";
			}
			echo '</select>';
			echo '<img src="../img/oblig.png" align="absmiddle" alt="'.$alt_chp_oblig.'">';
		}
		else
		{
			echo '<input name="loc" type="hidden" id="loc" value="'.$age_loc.'" readonly="readonly">';
			echo '<input name="nloc" type="text" id="nloc" value="'.$non_oui[$age_loc].'" size="3" readonly="readonly">';
		}
	}
	else
	{
		echo '<input name="loc" type="hidden" id="loc" value="'.$age_loc.'" readonly="readonly">';
		echo '<input name="nloc" type="text" id="nloc" value="'.$non_oui[$age_loc].'" size="3" readonly="readonly">';
	}
	?>
	<br /><span class="annot_petit_it">'Oui' : L'agence loue ou pr&ecirc;te du mat&eacute;riel</span>
	</td>
</tr>
<tr>
	<td width="160" class="rubfrm" id="f_st" align="right">Sous-traitant ?</td>
	<td>
	<?PHP 
	$exist_st=exist_age_st($age_code);
	if ($exist_st==FALSE)
	{
		if (($td == "add") OR ($td == "edit"))
		{ 
			echo '<select name="st" id="st">';
			foreach ($non_oui as $key=>$value)
			{
				echo '<option value="'.$key.'"'; 
				echo '>';
				echo $value."</option>";
			}
			echo '</select>';
			echo '<img src="../img/oblig.png" align="absmiddle" alt="'.$alt_chp_oblig.'">';
		}
		else
		{
			echo '<input name="st" type="hidden" id="st" value="'.intval($exist_st).'" readonly="readonly">';
			echo '<input name="nst" type="text" id="nst" value="'.$non_oui[intval($exist_st)].'" size="3" readonly="readonly">';
		}
	}
	else
	{
		echo '<input name="st" type="hidden" id="st" value="'.intval($exist_st).'" readonly="readonly">';
		echo '<input name="nst" type="text" id="nst" value="'.$non_oui[intval($exist_st)].'" size="3" readonly="readonly">';
		$row=lit_enr_stage($age_code);
		if (is_array($row))
		{
			extract($row);
			echo "<span class=\"annot_petit_it\">";
			echo " Rattach&eacute;e au sous-traitant  ".$st_code;
			echo " <a href=\"st_maj.php?td=edit&code=".$st_code."&dep=".$st_dep."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\"></a>";
			echo "</span>";
		}
	}
	?>
	<br /><span class="annot_petit_it">'Oui' : L'agence est aussi sous-traitant</span>
	</td>
</tr>
</table>
<?PHP
}
?>

<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 }
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>
<!-- Fin affiché uniquement s'il y a au moins une catégorie agence et au moins une civilité -->
<?PHP if ($td=="edit") { ?>
	<script type="text/javascript">
	<!--
	warnnbagepr(<?PHP echo nb_agepr($coderech,TRUE); ?>);
	//-->
	</script>
<?PHP
	}
}
else
{
	if (nb_acat() == 0)
	{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('acat_lst.php');",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');",2000)
	//-->
	</script>
	<p align="center" class="annot_std_it"><?PHP echo $alert_nociv; ?></p>
 <?PHP
	}
}
}
else
	aff_ret_pbm_auto("index.php",2000);
include_once("pied.php");
?>
