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

Version 0.9.6
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_log.inc.php") ?>
<?php include ("../inc/func_txt.inc.php") ?>
<?PHP include("../inc/geoip.inc"); ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	// Récupération des informations centre de gestion

	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM " .TBCG;
	$rs = mysql_query($rech)or die(mysql_error());
	$nb_enr=mysql_num_rows($rs);
	if ($nb_enr == 1) // Uniquement UN SEUL enregistrement !
	{
		if ($row = mysql_fetch_array($rs))
		{
			extract ($row);
		}
		$creation = 0;

		$titre = "MODIF. CENTRE DE GESTION";
	}
	mysql_free_result($rs);
	mysql_close($conn);

	if ($nb_enr == 0) // Si pas encore créé
	{
		$creation = 1;
		$cge_pays = pays_connect($_SERVER['REMOTE_ADDR']);

		$titre = "CREATION CENTRE DE GESTION";
	}
	
	$cge_datemod = $datea;

?>

<!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 Centre de Gestion</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 -->
<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 contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

<script language="javascript">
var tab1_champ=new Array(
	"nom:dep ; format:liste ; req:Y ; txt:Département ; vmn:1 ; stok:frmok ; stbad:frmbad");
var tab2_champ=new Array(
	"nom:nom ; format:txt ; req:Y ; txt:Nom; lmx:50 ; stok:frmok ; stbad:frmbad",
	"nom:rcs ; format:txt ; req:Y ; txt:RCS /APE; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:tcom ; format:txt ; req:Y ; txt:Tribunal de commerce; lmx:70; stok:frmok ; stbad:frmbad",
	"nom:adr1 ; format:txt ; req:Y ; txt:Adresse(1); lmx:50; stok:frmok ; stbad:frmbad",
	"nom:adr2 ; format:txt ; req:N ; txt:Adresse(2); lmx:50; stok:frmok ; stbad:frmbad",
	"nom:ville ; format:liste ; req:Y ; txt:Ville; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:pays ; format:liste ; req:Y ; txt:Pays; vmn:1; stok:frmok ; stbad:frmbad",
	"nom:telf ; format:tel_fr ; req:Y ; txt:Téléphone Fixe; 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_fr ; req:Y ; txt:Télécopieur; 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_pref ; req:Y ; txt:Adresse site web; lmx:200; stok:frmok ; stbad:frmbad",
	"nom:heures ; format:txt ; req:Y ; txt:Adresse site web; lmx:200; stok:frmok ; stbad:frmbad",
	"nom:email ; format:mail ; req:Y ; txt:Email général ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emaild ; format:mail ; req:Y ; txt:Email direction ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emailc ; format:mail ; req:Y ; txt:Email service comptabilité ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emailt ; format:mail ; req:Y ; txt:Email service technique ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emailf ; format:mail ; req:Y ; txt:Email service franchise ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emaili ; format:mail ; req:Y ; txt:Email service investisseurs ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:emailrh ; format:mail ; req:Y ; txt:Email servcue ressources humaines ; lmx:50; stok:frmok ; stbad:frmbad",
	"nom:nota ; format:txt ; req:N ; txt:Notes; stok:frmok ; stbad:frmbad");

</script>



</head>

<body>

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

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

<!-- Formulaire de demande du numéro de département (uniquement si n'existe pas) -->
<?PHP if ($cge_dep == "") { ?>
<form name="dde_dep" id="dde_dep" method="GET" action="cge_maj.php" onSubmit="javascript:; return (VForm(this,tab1_champ,''));">
	<p align="center">Merci de choisir le d&eacute;partement dans lequel est implant&eacute; le centre de gestion.</p>
	<table width="100%"  border="0">
<tr>
	<td width="20%" class="rubfrm" id="f_ouvert"><div align="right">D&eacute;partement</div></td>
	<td>
		<select name="dep" size="1" id="dep">
		<?PHP
		echo "<option>-- Choisissez un département --</option>";

		// 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");
		
		while ($resultat = mysql_fetch_array($rs)) 
		{
			extract($resultat);
			$chaine_dep = $dep_num." (".$dep_nom.")";
			echo "<option value=\"".$dep_num."\">".$chaine_dep."</option>";
		}
		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>

<?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 ($cge_dep <> "") { ?>
<div align="center">
    <span class="annot_gras_it">(<img src="../img/oblig.gif" width="10" height="11"> : Saisie obligatoire)</span>
</div>
<form name="cge_maj" id="cge_maj" method="post" action="cge_enr.php" onSubmit="javascript:; return (VForm(this,tab2_champ,''));">
      <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
      <input name="creation" type="hidden" id="creation" value="<?PHP echo $creation ?>">
	<?PHP
	if ($creation == 0)
	{
	?>
	  <input name="code" type="hidden" id="code" value="<?PHP echo $cge_code ?>">
	  <input name="pass" type="hidden" id="pass" value="<?PHP echo $cge_pass ?>">
	<?PHP
	}
	?>
<table width="100%"  border="0">
	<?PHP if ($creation == 0) { ?>
    <tr>
      <td height="21" class="rubfrm" id="f_logo"><div align="right">Logo</div></td>
      <td>
		<?PHP
		  $url_img = "cge_logo.php";
		?>
	  	<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 } ?>
	<?PHP if ($creation == 1) { ?>
    <tr>
      <td class="rubfrm" id="f_code"><div align="right">Code Connexion </div></td>
      <td>
	  	<input name="code" type="text" id="code" value="<?PHP echo $cge_code ?>" size="10" maxlength="10" onChange="javascript:this.value=this.value.toUpperCase();">
        <img src="../img/oblig.gif" width="10" height="11">
	  </td>
    </tr>
    <tr>
      <td class="rubfrm" id="f_pass"><div align="right">Mot de Passe </div></td>
      <td>
	  	<input name="pass" type="text" id="pass" value="<?PHP echo $cge_pass ?>" size="10" maxlength="10">
        <img src="../img/oblig.gif" width="10" height="11">
	  </td>
    </tr>
	<?PHP } ?>
    <tr>
      <td class="rubfrm" id="f_nom"><div align="right">Nom</div></td>
      <td><input name="nom" type="text" id="nom" value="<?PHP echo $cge_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="rubfrm" id="f_rcs"><div align="right">RCS / APE </div></td>
      <td><input name="rcs" type="text" id="rcs" value="<?PHP echo $cge_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="rubfrm" id="f_tcom"><div align="right">Tribunal com. </div></td>
      <td><input name="tcom" type="text" id="tcom" value="<?PHP echo $cge_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 class="rubfrm" id="f_adr1"><div align="right">Adresse (1) </div></td>
      <td><input name="adr1" type="text" id="adr1" value="<?PHP echo $cge_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 class="rubfrm" id="f_adr2"><div align="right">Adresse (2) </div></td>
      <td><input name="adr2" type="text" id="adr2" value="<?PHP echo $cge_adr2 ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toUpperCase();"></td>
    </tr>
<tr>
	<td class="rubfrm" id="f_dep"><div align="right">D&eacute;partement</div></td>
	<td>
		<input name="dep" type="text" id="dep" value="<?PHP echo $cge_dep ?>" size="3" maxlength="3" readonly="1">
	</td>
</tr>
    <tr>
      <td class="rubfrm" id="f_ville"><div align="right">Ville</div></td>
      <td>
		  <select name="ville" size="1" id="ville">
          <?PHP
				echo '<option>-- Choisissez une ville --</option>';

				// Création de la liste des villes
	
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$filtre = $cge_dep;
				if (($filtre == "2A") OR ($filtre == "2B"))
					$filtre = "20";
				$rs = mysql_query("SELECT * FROM ".TBVILLES." WHERE `villes_cp` LIKE '".$filtre."%' ORDER BY villes_nom");
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
					if ($cge_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>';
					}
				}
				mysql_free_result($rs);
				mysql_close($conn);
			?>
   	    </select>
      <img src="../img/oblig.gif" width="10" height="11">
	  </td>
    </tr>
    <tr>
      <td class="rubfrm" id="f_pays"><div align="right">Pays</div></td>
      <td>
		  <select name="pays" size="1" id="pays">
          <?PHP
				echo '<option>-- Choisissez un pays --</option>';
				
				// 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");
				while ($resultat = mysql_fetch_array($rs)) 
				{
					extract($resultat);
					if ($cge_pays == $pays_nom)
					{
						echo '<option value="'.$pays_nom.'" selected>'.$pays_nom.'</option>';
					}
					else
					{
						echo '<option value="'.$pays_nom.'">'.$pays_nom.'</option>';
					}
				}
				mysql_free_result($rs);
				mysql_close($conn);
			?>
   	    </select>
	  <img src="../img/oblig.gif" width="10" height="11">
	  </td>
    </tr>
    <tr>
      <td class="rubfrm" 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 $cge_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 $cge_txttelf ?>" size="50" maxlength="50"></td>
    </tr>
    <tr>
      <td width="30%" class="rubfrm" 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 $cge_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 $cge_txtfax ?>" size="50" maxlength="50"></td>
    </tr>
    <tr>
      <td class="rubfrm" id="f_web"><div align="right">Site Web </div></td>
      <td><input name="web" type="text" id="web" value="<?PHP echo $cge_web ?>" size="80" maxlength="200">
      <img src="../img/oblig.gif" width="10" height="11"></td>
    </tr>
    <tr>
      <td class="rubfrm" id="f_heures"><div align="right">Horaires</div></td>
      <td><input name="heures" type="text" id="heures" value="<?PHP echo $cge_heures ?>" size="80" maxlength="200">
        <img src="../img/oblig.gif" width="10" height="11"></td>
    </tr>
    <tr>
      <td colspan="2" class="rubfrm"><div align="center">Emails</div></td>
      <td>    
    </tr>
    <tr>
      <td class="rubfrm" id="f_email"><div align="right">G&eacute;n&eacute;ral</div></td>
      <td><input name="email" type="text" id="email" value="<?PHP echo $cge_email ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
	  <?PHP if ($creation == 0) { ?>
      	<a href="mailto:<?PHP echo $cge_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 class="rubfrm" id="f_emaild"><div align="right">Direction</div></td>
      <td><input name="emaild" type="text" id="emaild" value="<?PHP echo $cge_emaild ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
	  <?PHP if ($creation == 0) { ?>
        <a href="mailto:<?PHP echo $cge_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 class="rubfrm" id="f_emailc"><div align="right">Comptabilit&eacute; / Finances</div></td>
      <td><input name="emailc" type="text" id="emailc" value="<?PHP echo $cge_emailc ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
	  <?PHP if ($creation == 0) { ?>
        <a href="mailto:<?PHP echo $cge_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 class="rubfrm" id="f_emailt"><div align="right">Technique</div></td>
      <td><input name="emailt" type="text" id="emailt" value="<?PHP echo $cge_emailt ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
	  <?PHP if ($creation == 0) { ?>
        <a href="mailto:<?PHP echo $cge_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 class="rubfrm" id="f_emailf"><div align="right">Franchise / Partenariat </div></td>
      <td><input name="emailf" type="text" id="emailf" value="<?PHP echo $cge_emailf ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
	  <?PHP if ($creation == 0) { ?>
        <a href="mailto:<?PHP echo $cge_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 class="rubfrm" id="f_emaili"><div align="right">Investisseurs</div></td>
      <td><input name="emaili" type="text" id="emaili" value="<?PHP echo $cge_emaili ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
	  <?PHP if ($creation == 0) { ?>
        <a href="mailto:<?PHP echo $cge_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 class="rubfrm" id="f_emailrh"><div align="right">Ressources Humaines</div></td>
      <td><input name="emailrh" type="text" id="emailrh" value="<?PHP echo $cge_emailrh ?>" size="50" maxlength="50" onChange="javascript:this.value=this.value.toLowerCase();">
	  <?PHP if ($creation == 0) { ?>
        <a href="mailto:<?PHP echo $cge_emailrh ?>"><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>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="rubfrm" id="f_nota"><div align="right">Notes</div></td>
      <td><textarea name="nota" cols="110" id="nota"><?PHP echo $cge_nota ?></textarea></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>
	
<?PHP } ?>
<!-- Fin affichage uniquement si numéro de département saisi -->

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