<?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_once ("../inc/config.inc.php") ?>
<?php include_once ("../inc/func.inc.php") ?>
<?php include_once ("../inc/func_date.inc.php") ?>
<?php include_once ("../inc/func_log.inc.php") ?>
<?php include_once ("../inc/fic.inc.php") ?>
<?php require_once ("../classes/xpm/smtp.php"); ?>
<?php include_once ("../inc/mail.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	 	// Variables Formulaire
		$titre = strip_tags(trim(@$_POST["titre"]));

		$code = str_majuscules(strip_tags(trim(@$_POST["code"])));
		$nom = str_majuscules(strip_tags(trim(@$_POST["nom"])));
		$rcs = str_majuscules(strip_tags(trim(@$_POST["rcs"])));
		$tcom = str_majuscules(strip_tags(trim(@$_POST["tcom"])));
		$adr1 = str_majuscules(strip_tags(trim(@$_POST["adr1"])));
		$adr2 = str_majuscules(strip_tags(trim(@$_POST["adr2"])));
		$dep = strip_tags(trim(@$_POST["dep"]));
		$ville = str_majuscules(strip_tags(trim(@$_POST["ville"])));
		$pays = str_majuscules(strip_tags(trim(@$_POST["pays"])));
		$zone = str_majuscules(strip_tags(trim(@$_POST["zone"])));
		$telf = strip_tags(trim(@$_POST["telf"]));
		$txttelf = strip_tags(trim(@$_POST["txttelf"]));
		$fax = strip_tags(trim(@$_POST["fax"]));
		$txtfax = strip_tags(trim(@$_POST["txtfax"]));
		$web = strip_tags(trim(@$_POST["web"]));
		$heures = strip_tags(trim(@$_POST["heures"]));
		$txtent = strip_tags(trim(@$_POST["txtent"]));
		$rcivil = strip_tags(trim(@$_POST["rcivil"]));
		$rprenom = strip_tags(trim(@$_POST["rprenom"]));
		$rnom = strip_tags(trim(@$_POST["rnom"]));
		$rtelf = strip_tags(trim(@$_POST["rtelf"]));
		$email = strtolower(strip_tags(trim(@$_POST["email"])));
		$emaild = strtolower(strip_tags(trim(@$_POST["emaild"])));
		$emailc = strtolower(strip_tags(trim(@$_POST["emailc"])));
		$emailt = strtolower(strip_tags(trim(@$_POST["emailt"])));

		$codeuser = @$HTTP_SESSION_VARS["code_log"];
		$retourliste = TRUE;

		$msg = "";

		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);

		// MAJ de la fiche Agence
	
		$rech = "UPDATE `" .TBAGE. "` SET `age_datemod`='".$datea."', `age_codemod`='".$codeuser."', `age_telf`='".$telf."', `age_txttelf`='".$txttelf."', `age_fax`='".$fax."', `age_txtfax`='".$txtfax."', `age_txtent`='".$txtent."', `age_resp_civilite`='".$rcivil."', `age_resp_prenom`='".$rprenom."', `age_resp_nom`='".$rnom."', `age_resp_telf`='".$rtelf."', `age_email`='".$email."', `age_emaild`='".$emaild."', `age_emailc`='".$emailc."', `age_emailt`='".$emailt."', `age_heures`='".$heures."', `age_web`='".$web."', `age_datec`='".$datea."'   WHERE `age_code` = '".$code."'";
		$rs = mysql_query($rech) or die(mysql_error());

		$msg = "Fiche modifiée avec succès !";
			
		// mysql_free_result($rs);
		mysql_close($conn);

		// Envoi d'email vers le centre de gestion
		envoi_mail("Modification d'agence","age","mod","xxx","cdg",$code,"","",TRUE);
?>

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

</head>
<body>

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


<p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
<p align="center">&nbsp;</p>
<p align="center" class="annot_gras_it"><?PHP echo $msg ?></p>

<script type="text/javascript">
window.setTimeout("location=('index.php');",2000)
</script>
<p align="center" class="annot_std_it">Retour à la liste dans 2 secondes...</p>

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