<?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"] <> 1)) 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 require_once ("../classes/xpm/smtp.php"); ?>
<?php require ("../inc/mail.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	 	// Variables Formulaire
		$titre = strip_tags(trim(@$_POST["titre"]));
		$typdde = strip_tags(trim(@$_POST["typdde"]));

		$type = str_majuscules(strip_tags(trim(@$_POST["typ"])));
		$cat = str_majuscules(strip_tags(trim(@$_POST["cat"])));
		$code = strip_tags(trim(@$_POST["code"]));
		$ste = str_majuscules(strip_tags(trim(@$_POST["ste"])));
		$rcs = str_majuscules(strip_tags(trim(@$_POST["rcs"])));
		$civil = str_majuscules(strip_tags(trim(@$_POST["civil"])));
		$prenom = ucwords(strtolower(strip_tags(trim(@$_POST["prenom"]))));
		$nom = str_majuscules(strip_tags(trim(@$_POST["nom"])));
		$adr1 = str_majuscules(strip_tags(trim(@$_POST["adr1"])));
		$adr2 = str_majuscules(strip_tags(trim(@$_POST["adr2"])));
		$dep = str_majuscules(strip_tags(trim(@$_POST["dep"])));
		$ville = str_majuscules(strip_tags(trim(@$_POST["ville"])));
		$pays = str_majuscules(strip_tags(trim(@$_POST["pays"])));
		$telf = strip_tags(trim(@$_POST["telf"]));
		$fax = strip_tags(trim(@$_POST["fax"]));
		$telp = strip_tags(trim(@$_POST["telp"]));
		$email = strtolower(strip_tags(trim(@$_POST["email"])));
		$mess = strtolower(strip_tags(trim(@$_POST["mess"])));
		$notaa = strip_tags(trim(@$_POST["notaa"]));
		$notat = strip_tags(trim(@$_POST["notat"]));
		$cpta = strip_tags(trim(@$_POST["cpta"]));
		
		$codeuser = @$HTTP_SESSION_VARS["code_log"];

		$pass = cremdp(FALSE);
		$passcrypt = md5($pass);

		$retourliste = TRUE;

		// MAJ de la fiche Client
	
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "UPDATE `" .TBCLI. "` SET `cli_datemod`='".$datea."', `cli_codemod`='".$codeuser."', `cli_cat`='".$cat."', `cli_type`='".$type."', `cli_ste`='".$ste."', `cli_rcs`='".$rcs."', `cli_civilite`='".$civil."', `cli_prenom`='".$prenom."', `cli_nom`='".$nom."', `cli_adr1`='".$adr1."', `cli_adr2`='".$adr2."', `cli_ville`='".$ville."', `cli_pays`='".$pays."', `cli_telf`='".$telf."', `cli_fax`='".$fax."', `cli_telp`='".$telp."', `cli_email`='".$email."', `cli_mess`='".$mess."', `cli_notaa`='".$notaa."', `cli_notat`='".$notat."', `cli_cpta`='".$cpta."'  WHERE `cli_code` = '".$code."'";
		$rs = mysql_query($rech) or die(mysql_error());
		mysql_close($conn);

		// Si pas professionnel, suppression des contacts
		if ($ste == "")
			del_ccli_in_cli($code);

		$msg = "Fiche modifiée avec succès !";

		// Envoi d'email vers le centre de gestion
		envoi_mail("Modification de client","cli","mod","xxx","cdg",$code,"","",TRUE);

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMI - ESPACE PRIVE : Fiche Client</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 à l'accueil dans 2 secondes...</p>

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

