<?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"] <> 4)) header("Location: ../index.php") ?>
<?PHP include ("../inc/config.inc.php") ?>
<?PHP require ("../inc/func.inc.php") ?>
<?PHP require ("../inc/func_log.inc.php") ?>
<?PHP require ("../inc/fic.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?PHP
	$coderech = @$HTTP_SESSION_VARS["code_log"];

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

		$titre = "MISE A JOUR 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 affichages -->
<script language="JavaScript" src="../inc/aff.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>


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


<table width="100%"  border="0">
  <tr>
    <td width="33%">&nbsp;</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
			$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="absmiddle"></a> <a href="javascript:;" onclick="lanceimp('<?PHP echo $urlimp; ?>');")> Imprimer la fiche </a></div>
	  </div>
	</td>
  </tr>
</table>
<div align="center">
    <span class="annot_gras_it">(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)</span>
</div>

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

<!-- Fiche principale -->
<table width="100%"  border="0">
<tr>
	<td width="20%" class="tfvNormal" id="f_code"><div align="right">Code</div></td>
	<td>
		<input name="code" type="text" id="code" value="<?PHP echo $age_code ?>" size="10" maxlength="10" readonly="1">
	</td>
</tr>
<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="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');")> Voir le logo</a>
	</td>
</tr>
<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" readonly="1">
	</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" readonly="1">
	</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" readonly="1">
  </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" readonly="1">
	</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" readonly="1">
	</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_cp"><div align="right">Code Postal</div></td>
	<td>
		<?PHP
			$cp = Retournecp($age_ville);
		?>
		<input name="cp" type="text" id="cp" value="<?PHP echo $cp ?>" size="5" maxlength="5" readonly="1">
	</td>
</tr>
<tr>
	<td width="20%" class="tfvNormal" id="f_ville"><div align="right">Ville</div></td>
	<td>
		<?PHP
			$ville = Retourneville($age_ville);
		?>
        <input name="ville" type="text" id="ville" value="<?PHP echo $ville; ?>" size="50" maxlength="50" readonly="1">
	</td>
</tr>
<tr>
	<td class="tfvNormal" id="f_pays"><div align="right">Pays</div></td>
	<td>
        <input name="pays" type="text" id="pays" value="<?PHP echo $age_pays ?>" size="20" maxlength="20" readonly="1">
	</td>
</tr>
<tr>
  <td class="tfvNormal" id="f_zone"><div align="right">Zone chalandise</div></td>
  <td>
  	<input name="zone" type="text" id="zone" value="<?PHP echo $age_zone ?>" size="50" maxlength="50" readonly="1">
  </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();">
		<a href="mailto:<?PHP echo $age_email ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="absmiddle"></a>
		<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();">
		<a href="mailto:<?PHP echo $age_emaild ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="absmiddle"></a>
		<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();">
		<a href="mailto:<?PHP echo $age_emailc ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="absmiddle"></a>
	<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();">
		<a href="mailto:<?PHP echo $age_emailt ?>"><img src="../img/mail.png" width="22" height="22" title="Envoyer e-mail" border ="0" align="absmiddle"></a>
		<img src="../img/oblig.gif" width="10" height="11">
	</td>
</tr>
</table>

<p align="center">
	<input name="RAZ" type="reset" id="RAZ" value="R&eacute;initialiser">
	<input name="submit" type="submit" id="submit" value="Enregistrer">
</p>
</form>
<!-- Fin de formulaire de saisie de la fiche -->

<script>
// form fields description structure
var a_fields = {
	'code':{'l':'Code','r':true,'f':'alphanum','t':'f_code','mx':10},
	'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},
	'zone':{'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 
	include_once ("pied.php")
?>

