<?php
/****************************************************************************************
 * SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV
 *
 * Version 1.0.4
 *
 * Copyright (C) 2006-2016  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) {
    header('Location: ../index.php');
}

include_once('../inc/config.inc.php');
include_once('../inc/fic_age.inc.php');
include_once('../inc/fic_do.inc.php');
include_once('../inc/fic_droits.inc.php');
include_once('../inc/fic_ope.inc.php');
include_once('../inc/fic_cli.inc.php');
include_once('../inc/fic_st.inc.php');
include_once('../inc/fic_tec.inc.php');
include_once('../inc/func.inc.php');
include_once('../inc/func_log.inc.php');
include_once('../inc/func_geo.inc.php');
include_once('../inc/func_txt.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(valsession('code_log'));
// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$orig = $_GET['ori']; // Récupération origine ('Public / Privé')

$ddeok = TRUE;

// Si origine de la demande est "privée", on récupère le code du Département du connecté et les données du demandeur
if ($orig == 'pr') {
    switch (valsession('niv_log')) {
        // Sous-traitant
        case 10 :
            $row = lit_enr_st(valsession('code_log'));
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);

                $ste = $st_nom;
                $nom = '';
                $prenom = '';
                $adr1 = $st_adr1;
                $adr2 = $st_adr2;
                $dep = $st_dep;
                $ville = $st_ville;
                $pays = $st_codepays;
                $telf = str_replace(' ', '', $st_telf);
                $fax = str_replace(' ', '', $st_fax);
                $email = $st_emaild;
            } else {
                $ddeok = FALSE;
            }
            break;

        // Donneur d'ordres
        case 6 :
            $row = lit_enr_do(valsession('code_log'));
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);

                $ste = $do_nom;
                $nom = '';
                $prenom = '';
                $adr1 = $do_adr1;
                $adr2 = $do_adr2;
                $dep = $do_dep;
                $ville = $do_ville;
                $pays = $do_codepays;
                $telf = str_replace(' ', '', $do_telf);
                $fax = str_replace(' ', '', $do_fax);
                $email = $do_emaild;
            } else {
                $ddeok = FALSE;
            }
            break;

        //Centre de gestion
        case 5 :
            $row = lit_enr_cdg();
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);

                $ste = $cge_nom;
                $nom = '';
                $prenom = '';
                $adr1 = $cge_adr1;
                $adr2 = $cge_adr2;
                $dep = $cge_dep;
                $ville = $cge_ville;
                $pays = $cge_codepays;
                $telf = str_replace(' ', '', $cge_telf);
                $fax = str_replace(' ', '', $cge_fax);
                $email = $cge_emaild;
            } else {
                $ddeok = FALSE;
            }
            break;

        //Agence
        case 4 :
            $row = lit_enr_age(valsession('code_log'), TRUE);
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);

                $ste = $age_nom;
                $nom = '';
                $prenom = '';
                $adr1 = $age_adr1;
                $adr2 = $age_adr2;
                $dep = $age_dep;
                $ville = $age_ville;
                $pays = $age_codepays;
                $telf = str_replace(' ', '', $age_telf);
                $fax = str_replace(' ', '', $age_fax);
                $email = $age_emaild;
            } else {
                $ddeok = FALSE;
            }
            break;

        // Technicien agence/sous-traitant/donneur d'ordres
        case 3 :
        case 11 :
        case 7 :
            $row = lit_enr_tec(valsession('code_log'), TRUE);
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);

                $civilite = $tec_civilite;
                $prenom = $tec_prenom;
                $nom = $tec_nom;
                $adr1 = $tec_adr1;
                $adr2 = $tec_adr2;
                $dep = $tec_dep;
                $ville = $tec_ville;
                $pays = $tec_codepays;
                $telf = str_replace(' ', '', $tec_telf);
                $telp = str_replace(' ', '', $tec_telp);
                $fax = str_replace(' ', '', $tec_fax);
                $email = $tec_email;
            } else {
                $ddeok = FALSE;
            }
            break;

        //Opérateur
        case 2 :
            $row = lit_enr_ope(valsession('code_log'));
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);

                $civilite = $ope_civilite;
                $prenom = $ope_prenom;
                $nom = $ope_nom;
                $adr1 = $ope_adr1;
                $adr2 = $ope_adr2;
                $dep = $ope_dep;
                $ville = $ope_ville;
                $pays = $ope_codepays;
                $telf = str_replace(' ', '', $ope_telf);
                $telp = str_replace(' ', '', $ope_telfp);
                $email = $ope_email;
            } else {
                $ddeok = FALSE;
            }
            break;

        //Client
        case 1 :
            $row = lit_enr_cli(valsession('code_log'), TRUE);
            if (is_array($row)) {
                $row = encode_str($row);
                extract($row);

                $ste = $cli_ste;
                $civilite = $cli_civilite;
                $prenom = $cli_prenom;
                $nom = $cli_nom;
                $adr1 = $cli_adr1;
                $adr2 = $cli_adr2;
                $dep = $cli_dep;
                $ville = $cli_ville;
                $pays = $cli_codepays;
                $telf = str_replace(' ', '', $cli_telf);
                $fax = str_replace(' ', '', $cli_fax);
                $telp = str_replace(' ', '', $cli_telfp);
                $email = $cli_email;
            } else {
                $ddeok = FALSE;
            }
            break;

        default :
            $ddeok = FALSE;
            break;
    }
}
$titre = _('MESSAGES & DEMANDES');
?>
<!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'); ?>

    <!-- affiché uniquement si demande cohérente -->
    <script language="javascript">
        <!--
        var tab1_champ = ["nom:objet ; format:liste ; req:Y ; txt:<?php echo _('Objet de la demande'); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            "nom:dest ; format:liste ; req:Y ; txt:<?php echo _('Destinataire'); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            "nom:ste ; format:txt ; req:N ; txt:<?php echo _('Société'); ?> ; stok:frmok ; stbad:frmbad",
            "nom:civilite ; format:liste ; req:Y ; txt:<?php echo _('Civilité'); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            "nom:prenom ; format:txt ; req:Y ; txt:<?php echo _('Prénom'); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
            "nom:nom ; format:txt ; req:Y ; txt:<?php echo _('Prénom'); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
            "nom:adr1 ; format:txt ; req:Y ; txt:<?php echo _('Adresse'); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
            "nom:adr2 ; format:txt ; req:N ; txt:<?php echo _('Adresse (2)'); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
            <?php
            // Espace privé
            if (valsession('niv_log') <> '')
            {
            ?>
            "nom:pays ; format:txt ; req:Y ; txt:<?php echo _('Ville'); ?> ; stok:frmok ; stbad:frmbad",
            "nom:dep ; format:txt ; req:Y ; <?php echo _('Département'); ?> ; stok:frmok ; stbad:frmbad",
            "nom:ville ; format:txt ; req:Y ; txt:<?php echo _('Ville'); ?> ; stok:frmok ; stbad:frmbad",
            <?php
            } else {
            ?>
            "nom:pays ; format:liste ; req:Y ; txt:<?php echo _('Pays'); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            "nom:dep ; format:liste ; req:Y ; <?php echo _('Département'); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            "nom:ville ; format:liste ; req:Y ; txt:<?php echo _('Ville'); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            <?php
            }
            ?>
            "nom:telf ; format:tel ; req:Y ; txt:<?php echo _('Téléphone Fixe'); ?> ; stok:frmok ; stbad:frmbad",
            "nom:fax ; format:tel ; req:N ; txt:<?php echo _('Télécopieur'); ?> ; stok:frmok ; stbad:frmbad",
            "nom:telp ; format:telp ; req:N ; txt:<?php echo _('Téléphone portable'); ?> ; stok:frmok ; stbad:frmbad",
            "nom:email ; format:mail ; req:Y ; txt:<?php echo _('Email'); ?> ; stok:frmok ; stbad:frmbad",
            <?php if ((valsession('niv_log') <> '') AND (valsession('niv_log')==1)) { ?>
            "nom:site ; format:liste ; req:Y ; txt:<?php echo _('Site concerné'); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
            <?php } ?>
            "nom:txtdde ; format:txt ; req:Y ; txt:<?php echo _('Votre demande'); ?> ; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

    <script type="text/javascript">
        <!--
        $(function () {
            $("#adr1").Setcase({caseValue: 'upper', changeonFocusout: true});
            $("#adr2").Setcase({caseValue: 'upper', changeonFocusout: true});
            $("#nom").Setcase({caseValue: 'upper', changeonFocusout: true});
            $("#email").Setcase({caseValue: 'lower', changeonFocusout: true});
            $("#prenom").Setcase({caseValue: 'allfirst', changeonFocusout: true});
        });

        function init_all() {
            init_Body();
            <?php
            echo "init_valid_form('enr','dde_maj','".valsession('date_fmtshort')."',tab1_champ,'pays','');";
            // Espace Publique
            if (valsession('niv_log') == '') { ?>
            init_ajax_ville();
            init_ajax_dep();
            <?php } ?>
            Focus_first();
        }

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

</head>

<body>
<?php
include_once('../inc/entete.inc.php');
cre_ent_form($titre, '', '', '', FALSE);
if ($ddeok == TRUE) {
    ?>
    <form name="dde_maj" id="dde_maj" method="post" action="dde_enr.php">
        <input name="titre" type="hidden" id="titre" value="<?php echo $titre ?>">
        <input name="ori" type="hidden" id="ori" value="<?php echo $orig ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">

        <!-- Objet -->
        <table width="100%" border="0">
            <tr>
                <td width="160" class="rubfrm" id="f_obj" align="right"><?php echo _('Objet'); ?></td>
                <td>
                    <?php
                    // création de la liste des type de demandes
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
                    if (valsession('niv_log') <> '') // Espace privé
                    {
                        switch (valsession('niv_log')) {
                            // Si Demandeur = Technicien sous-traitant
                            case 11 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_stt` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Sous-traitant
                            case 10 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_st` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Technicien donneur d'ordres
                            case 7 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_dot` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Donneur d'ordres
                            case 6 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_do` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Centre de gestion
                            case 5 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_cge` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Agence
                            case 4 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_age` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Client
                            case 1 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_cli` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Opérateur
                            case 2 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_ope` = '1' ORDER BY ddet_desc";
                                break;

                            // Si Demandeur = Technicien
                            case 3 :
                                $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_tec` = '1' ORDER BY ddet_desc";
                                break;
                        }
                    } else {
                        $rech = 'SELECT * FROM `' . TBDDET . "` WHERE `ddet_pub` = '1' ORDER BY ddet_desc";
                    }

                    $rows = $db->get_results($rech, ARRAY_A);
                    close_database();
                    cre_select_tab('objet', 'objet', $rows, 'ddet_code', 'ddet_desc', '', '', '', _('-- Faites votre choix --'));
                    ?>
                </td>
            </tr>
        </table>

        <!-- Destinataire -->
        <table width="100%" border="0">
            <tr>
                <td width="160" class="rubfrm" id="f_dest" align="right"><?php echo _('Destinataire'); ?></td>
                <td>
                    <?php
                    // création de la liste des destinataires demandes
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
                    if (valsession('niv_log') <> '') // Espace privé
                    {
                        switch (valsession('niv_log')) {
                            // Si Demandeur = Technicien sous-traitant
                            case 11 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_stt` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Sous-traitant
                            case 10 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_st` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Technicien donneur d'ordres
                            case 7 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_dot` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Donneur d'ordres
                            case 6 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_do` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Centre de gestion
                            case 5 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_cge` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Agence
                            case 4 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_age` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Client
                            case 1 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_cli` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Opérateur
                            case 2 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_ope` = '1' ORDER BY dded_desc";
                                break;

                            // Si Demandeur = Technicien agence
                            case 3 :
                                $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_tec` = '1' ORDER BY dded_desc";
                                break;
                        }
                    } else {
                        $rech = 'SELECT * FROM `' . TBDDED . "` WHERE `dded_pub` = '1' ORDER BY dded_desc";
                    }
                    $rows = $db->get_results($rech, ARRAY_A);
                    close_database();
                    cre_select_tab('dest', 'dest', $rows, 'dded_code', 'dded_desc', '', '', '', _('-- Faites votre choix --'));
                    ?>
                </td>
            </tr>
        </table>
        <br/>

        <!-- détails expéditeur-->
        <table width="100%" border="0">
            <tr>
                <td class="rubfrm" align="center">
                    <?php echo _('Vos coordonnées'); ?>
                </td>
            </tr>
        </table>

        <!-- Catégorie -->
        <?php
        // Espace privé
        if (valsession('niv_log') <> '') {
            ?>
            <input name="cat" type="hidden" id="cat" value="<?php echo str_majuscules($ddeur); ?>">
            <?php
        } else {
            ?>
            <table width="100%" border="0">
                <tr>
                    <td width="160" class="rubfrm" id="f_cat" align="right"><?php echo _('Vous êtes'); ?></td>
                    <td>
                        <?php
                        // création de la liste des catégories de demandeurs (espace privé uniquement)
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
                        $rech = 'SELECT ddec_code,ddec_desc FROM `' . TBDDEC . "` WHERE `ddec_pub` = '0' ORDER BY ddec_desc";
                        $rows = $db->get_results($rech, ARRAY_A);
                        close_database();
                        cre_select_tab('cat', 'cat', $rows, 'ddec_code', 'ddec_desc', '', '', '', _('-- Faites votre choix --'));
                        ?>
                    </td>
                </tr>
            </table>
            <?php
        }
        ?>

        <!-- Coordonnées -->
        <table width="100%" border="0">
            <tr>
                <td width="160" class="rubfrm" id="f_ste" align="right"><?php echo _('Société'); ?></td>
                <td>
                    <input name="ste" type="text" id="ste" value="<?php echo $ste ?>" size="50" maxlength="50">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_civilite" align="right"><?php echo _('Civilité'); ?></td>
                <td>
                    <?php
                    // création de la liste des civilités
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
                    $rech = 'SELECT * FROM `' . TBCIV . '` ORDER BY civ_desc';
                    $rows = $db->get_results($rech, ARRAY_A);
                    close_database();
                    cre_select_tab('civilite', 'civilite', $rows, 'civ_code', 'civ_desc', '', $civilite, '', _('-- Faites votre choix --'));
                    ?>
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_prenom" align="right"><?php echo _('Prénom'); ?></td>
                <td>
                    <input name="prenom" type="text" id="prenom" value="<?php echo $prenom ?>" size="50"">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_nom" align="right"><?php echo _('Nom'); ?></td>
                <td>
                    <input name="nom" type="text" id="nom" value="<?php echo $nom ?>" size="50">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_adr1" align="right"><?php echo _('Adresse'); ?></td>
                <td>
                    <input name="adr1" type="text" id="adr1" value="<?php echo $adr1 ?>" size="50">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_adr2" align="right"><?php echo _('Adresse (2)'); ?></td>
                <td>
                    <input name="adr2" type="text" id="adr2" value="<?php echo $adr2 ?>" size="50">
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_pays" align="right"><?php echo _('Pays'); ?></td>
                <td>
                    <?php
                    if (valsession('niv_log') == '') // Espace publique
                    {
                        // Création de la liste des pays
                        $rows = give_rows_pays();
                        cre_select_tab('pays', 'pays', $rows, 'pays_code', 'pays_nom', '', $pays, '', _('-- Faites votre choix --'), 1, FALSE, '-1', _('-- Inconnu --'));
                    } else {
                        echo '<input name="pays" type="hidden" id="pays" value="' . $pays . '">';
                        echo '<input name="npays" type="text" id="npays" value="' . str_majuscules(Retournepays($pays, TRUE)) . '" size="50" readonly>';
                    }
                    ?>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_dep" align="right"><?php echo _('Département'); ?></td>
                <td>
                    <?php
                    if (valsession('niv_log') == '') // Espace publique
                    {
                        // Création de la liste des départements
                        $rows = give_rows_dep($pays);
                        cre_select_tab('dep', 'dep', $rows, 'dep_code', 'dep_code', 'dep_nom', $dep, '', _('-- Faites votre choix --'), 1, FALSE, '-1', _('-- Inconnu --'));
                    } else {
                        $dep_nom = Retournedep($dep, $pays, TRUE);
                        $ndep = $dep_nom;
                        if ($dep_code <> $dep_nom) {
                            $ndep = $dep . ' (' . $dep_nom . ')';
                        }
                        echo '<input name="dep" type="hidden" id="dep" value="' . $dep . '">';
                        echo '<input name="ndep" type="text" id="ndep" value="' . str_majuscules($ndep) . '" size="50" readonly>';
                    }
                    ?>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_ville" align="right"><?php echo _('Ville'); ?></td>
                <td>
                    <?php
                    if (valsession('niv_log') == '') // Espace publique
                    {
                        // Création de la liste des villes
                        $rows = give_rows_villes($dep, $pays);
                        cre_select_tab('ville', 'ville', $rows, 'villes_id', 'villes_nom', 'villes_cp', $ville, '', _('-- Faites votre choix --'), 1, FALSE, '-1', _('-- Inconnu --'));
                    } else {
                        echo '<input name="ville" type="hidden" id="ville" value="' . $ville . '">';
                        echo '<input name="nville" type="text" id="nville" value="' . Retourneville_Id($ville, TRUE) . ' (' . Retournecp_Id($ville, TRUE) . ')' . '" size="40" readonly>';
                    }
                    ?>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_telf" align="right"><?php echo _('Téléphone Fixe'); ?> </td>
                <td>
                    <input name="telf" type="text" id="telf" value="<?php echo $telf ?>" size="20" maxlength="20">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>">
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_fax" align="right"><?php echo _('Télécopieur'); ?></td>
                <td>
                    <input name="fax" type="text" id="fax" value="<?php echo $fax ?>" size="20" maxlength="20">
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_telp" align="right"><?php echo _('Téléphone portable'); ?></td>
                <td>
                    <input name="telp" type="text" id="telp" value="<?php echo $telp ?>" size="20" maxlength="20">
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_email" align="right"><?php echo _('Email'); ?></td>
                <td>
                    <input name="email" type="text" id="email" value="<?php echo $email ?>" size="50" maxlength="50">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>">
                </td>
            </tr>
            <?php
            // Site uniquement si demande client depuis espace privé
            if ((valsession('niv_log') <> '') AND CheckNivLog('1')) {
                ?>
                <tr>
                    <td class="rubfrm" id="f_site" align="right"><?php echo _('Site concerné'); ?></td>
                    <td>
                        <?php
                        echo '<select name="site" size="1" id="site">';
                        echo '<option>' . _('-- Faites votre choix --') . '</option>';
                        echo '<option value="-1">' . _('-- Aucun site en particulier --') . '</option>';
                        echo '<option value="0">' . _('-- Faites votre choix --') . '</option>';

                        // création de la liste des site actifs du client
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
                        $rech = 'SELECT * FROM `' . TBSCLI . "` WHERE `scli_codecli` = '" . valsession('code_log') . "' AND `scli_actif`='1' ORDER BY scli_ste";
                        $rows = $db->get_results($rech, ARRAY_A);
                        if ($rows AND (count($rows) > 0)) {
                            foreach ($rows as $row) {
                                $row = encode_str($row);
                                extract($row);
                                $txt_scli = str_majuscules($scli_ste) . ', ' . str_majuscules($scli_adr1);
                                if (trim($scli_adr2) <> '') {
                                    $txt_scli .= ' ' . $scli_adr2;
                                }
                                $txt_scli .= ', ' . Retournecp_Id($scli_ville, FALSE) . ' ' . Retourneville_Id($scli_ville, FALSE);
                                $txt_scli .= ' (' . $scli_telf . ')';
                                echo '<option value="' . $scli_id . '">' . $txt_scli . '</option>';
                            }
                        }
                        close_database();
                        echo '</select>';
                        echo ' <img src="../img/oblig.png" align="absmiddle" alt="' . _('Champ obligatoire') . '">';
                        ?>
                    </td>
                </tr>
                <?php
            }
            ?>
            <tr>
                <td class="rubfrm" id="f_urg" align="right"><?php echo _("Niveau d'urgence"); ?></td>
                <td>
                    <?php
                    // création de la liste des Niveaux d'urgence
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
                    $rech = 'SELECT * FROM `' . TBURG . '` ORDER BY urg_niveau';
                    $rows = $db->get_results($rech, ARRAY_A);
                    close_database();
                    cre_select_tab('urgence', 'urgence', $rows, 'urg_niveau', 'urg_des', '', '');
                    ?>
                </td>
            </tr>
        </table>
        <br/>
        <!-- Texte de la demande -->
        <table width="100%" border="0">
            <tr>
                <td class="rubfrm" id="f_txtdde" align="center"><?php echo _('Votre message'); ?>
                    <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>">
                </td>
            </tr>
            <tr>
                <td>
                    <textarea name="txtdde" rows="5" id="txtdde"><?php echo $txtdde ?></textarea>
                </td>
            </tr>
        </table>

        <p align="center">
            <?php
            echo '<input name="enr" type="button" class="bton_std" id="enr" value="' . _('Envoyer') . '">';
            echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="' . _('Réinitialiser') . '">';
            ?>
        </p>
    </form>
    <!-- Fin affiché uniquement si demande cohérente -->
    <?php
} else {
    pop_ret_auto(_('Problème de paramètres'), 'warn', 'index.php');
}
include_once('pied.php');
?>
</body>
</html>