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

Version 0.9.7

Copyright (C) 2006-2007  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_cli.inc.php");
include_once("../inc/fic_dde.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/fic_prm.inc.php");
include_once("../inc/fic_txt.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_mail.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/func_txtcm.inc.php");
include_once("../classes/phpmailer/class.phpmailer.php");
include_once("mail.inc.php");
Archivelog(@$_SESSION["code_log"]);

// Variables Formulaire
$titre = strip_tags(trim(@$_POST["titre"]));
$orig = strip_tags(trim(@$_POST["ori"]));
if ($orig == "pr")
	$orig = 1;
else
	$orig = 0;

$objet = str_majuscules(strip_tags(trim(@$_POST["objet"])));
$dest = str_majuscules(strip_tags(trim(@$_POST["dest"])));
$cat = str_majuscules(strip_tags(trim(@$_POST["cat"])));
$ste = str_majuscules(str_escape(trim(@$_POST["ste"])));
$civil = str_majuscules(strip_tags(trim(@$_POST["civilite"])));
$prenom = ucwords(strtolower(str_escape(trim(@$_POST["prenom"]))));
$nom = str_majuscules(str_escape(trim(@$_POST["nom"])));
$adr1 = str_majuscules(str_escape(trim(@$_POST["adr1"])));
$adr2 = str_majuscules(str_escape(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"])));
$txtdde = str_escape(trim(@$_POST["txtdde"]));

$codeuser = @$_SESSION["code_log"];

$coded = crecode("D");

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

// Ajout de la fiche type de demande
$rech = "INSERT INTO " .TBDDE. " (dde_datecrea,dde_codecrea,dde_datemod,dde_codemod,dde_code,dde_orig,dde_codeddet,dde_codeddec,dde_codedded,dde_ste,dde_civilite,dde_prenom,dde_nom,dde_adr1,dde_adr2,dde_dep,dde_ville,dde_codepays,dde_telf,dde_fax,dde_telp,dde_email,dde_txtdde)";
$rech.= " VALUES ('$datea','$codeuser','$datea','$codeuser','$coded','$orig','$objet','$cat','$dest','$ste','$civil','$prenom','$nom','$adr1','$adr2','$dep','$ville','$pays','$telf','$fax','$telp','$email','$txtdde')";
$rs = mysql_query($rech) or die(mysql_error());
mysql_close($conn);
$msg = "Demande enregistrée.";			

// Envoi d'email vers le destinataire
$niv_util=@$_SESSION["niv_log"];
$code_util=@$_SESSION["code_log"];
if ($orig == 1)
	envoi_mail("Nouvelle demande","dde","cre","pri","xxx",$coded,"","",TRUE);
else
	envoi_mail("Nouvelle demande","dde","cre","pub","xxx",$coded,"","",TRUE);

// Envoi d'email vers l'expéditeur
envoi_mail("Accusé de réception","dde","ar","xxx","xxx",$coded,"","",TRUE);
?>
<!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 : Demande</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>

</head>
<body>
<?php 
include_once("entete.inc.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');",5000)
</script>
<p align="center" class="annot_std_gras">Nous vous remercions de votre demande et ne manquerons pas d'y r&eacute;pondre sous les meilleurs d&eacute;lais </p>
<p align="center" class="annot_std_it">Retour à l'accueil dans 5 secondes...</p>
<?PHP
include_once("pied.php");
?>
