<?php
/****************************************************************************************
 * SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV
 *
 * Version 1.0.0
 *
 * Copyright (C) 2006-2014  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://smi.no-ip.org
 ****************************************************************************************/


// 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_droits.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/fic_zc.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("../classes/phpmailer/class.smtp.php");
include_once("mail.inc.php");
include_once("../classes/ezSQL/shared/ez_sql_core.php");
include_once("../classes/ezSQL/mysqli/ez_sql_mysqli.php");
include_once("../inc/func_sql.inc.php");
Archivelog(@$_SESSION["code_log"]);
// Variables Formulaire
fix_magic_quotes();
$_POST = clean_str($_POST);

$titre = @$_POST["titre"];
$orig = @$_POST["ori"];
if ($orig == "pr")
    $orig = 1;
else
    $orig = 0;

$objet = str_majuscules(@$_POST["objet"]);
$dest = str_majuscules(@$_POST["dest"]);
$cat = str_majuscules(@$_POST["cat"]);
$ste = str_majuscules(@$_POST["ste"]);
$civil = str_majuscules(@$_POST["civilite"]);
$prenom = ucname(@$_POST["prenom"]);
$nom = str_majuscules(@$_POST["nom"]);
$adr1 = str_majuscules(@$_POST["adr1"]);
$adr2 = str_majuscules(@$_POST["adr2"]);
$dep = str_majuscules(@$_POST["dep"]);
$ville = str_majuscules(@$_POST["ville"]);
$pays = str_majuscules(@$_POST["pays"]);
$telf = @$_POST["telf"];
$fax = @$_POST["fax"];
$telp = @$_POST["telp"];
$email = strtolower(@$_POST["email"]);
$site = -1;
$site = intval(@$_POST["site"]);
$urg = intval(@$_POST["urgence"]);
$txtdde = @$_POST["txtdde"];

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

$coded = crecode("D", TRUE);

$db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

// 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,";
$rech .= "dde_codeddec,dde_codedded,dde_ste,dde_civilite,dde_prenom,";
$rech .= "dde_nom,dde_adr1,dde_adr2,";
$rech .= "dde_dep,dde_ville,dde_codepays,dde_telf,dde_fax,dde_telp,dde_email,dde_txtdde,dde_scli,dde_urg)";
$rech .= " VALUES ('$datea','$codeuser','$datea','$codeuser','$coded','$orig','" . $db->escape($objet) . "',";
$rech .= "'$cat','$dest','" . $db->escape($ste) . "','$civil','" . $db->escape($prenom) . "',";
$rech .= "'" . $db->escape($nom) . "','" . $db->escape($adr1) . "','" . $db->escape($adr2) . "',";
$rech .= "'$dep','$ville','$pays','$telf','$fax','$telp','" . $db->escape($email) . "','" . $db->escape($txtdde) . "','$site','$urg')";
$db->query($rech);
$db->disconnect();
$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=UTF-8">
    <title>SMI - <?PHP echo _("ESPACE PRIVE"); ?> : <?PHP echo _("Demande"); ?></title>

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

    <script type="text/javascript">
        <!--
        function init_all() {
            init_Body();
            Focus_first();
        }

        $(document).ready(function () {
            init_all();
        });
        //-->
    </script>

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

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

<p align="center">&nbsp;</p>
<?PHP
pop_ret_auto(_("Nous vous remercions de votre demande et ne manquerons pas de vous répondre sous les meilleurs délais"), 'ok', "index.php", 5000);
include_once("pied.php");
?>
</body>
</html>