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

Version 1.0.2

Copyright (C) 2006-2015  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
 ****************************************************************************************/

session_start();

require_once("../lib/gettext/gettext.inc");
include_once("../inc/config.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/func_log.inc.php");
if (CheckURLLog(FALSE) == FALSE) header("Location: ../index.php");
if (CheckNivLog("5-9") == FALSE) header("Location: ../index.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_dde.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();
$_GET = clean_str($_GET);

$td = $_GET['td'];
$coderech = $_GET['code'];

$pbm_dded = FALSE;

if ($coderech <> "") {
    if ($coderech <> "VA") {
        // Récupération des informations type de demande
        $row = lit_enr_dded($coderech);
        if (is_array($row)) {
            $row = encode_str($row);
            extract($row);
        } else
            $pbm_dded = TRUE;
    } else
        $pbm_dded = TRUE;
} else {
    if ($td <> "add")
        $pbm_dded = TRUE;
}
switch ($td) {
    case "add" :
        $titre = _("CREATION DESTINATAIRE DE DEMANDE");
        break;
    case "edit" :
        $titre = _("MISE A JOUR DESTINATAIRE DE DEMANDE");
        break;
    case "del" :
        $titre = _("SUPPRESSION DESTINATAIRE DE DEMANDE");
        break;
    default:
        $pbm_dded = TRUE;
        break;
}
?>
    <!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 _("Fiche Destinataire de Demande"); ?></title>

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

        <script language="javascript">
            <!--
            var tab1_champ = ["nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo _("Code"); ?> ; lmx:10 ; stok:frmok ; stbad:frmbad",
                "nom:desc ; format:txt ; req:Y ; txt:<?PHP echo _("Libellé"); ?> ; lmx:40 ; stok:frmok ; stbad:frmbad",
                "nom:email ; format:mail ; req:Y ; txt:<?PHP echo _("Email"); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad"];
            //-->
        </script>

        <?PHP if ($pbm_dded == FALSE) { ?>
            <script type="text/javascript">
                <!--
                $(function () {
                    $("#code").Setcase({caseValue: 'upper', changeonFocusout: true});
                    $("#desc").Setcase({caseValue: 'upper', changeonFocusout: true});
                    $("#email").Setcase({caseValue: 'lower', changeonFocusout: true});
                });

                function init_all() {
                    init_Body();
                    <?php
                     switch ($td)
                     {
                        case "add" :
                            echo "init_valid_form('enr','dded_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                            break;
                        case "edit" :
                            echo "init_valid_form('enr','dded_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                            break;
                        case "view" :
                            echo "readonly_all();";
                            break;
                        case "del" :
                            echo "readonly_all();";
                            echo "warn_del('');";
                            break;
                     }
                     ?>
                    init_autohref('annul', 'click', 'index.php',false);
                    Focus_first();
                }

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

        <?PHP } ?>
    </head>

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

if ($pbm_dded == FALSE) {
    cre_ent_form($titre, 'dded_lst.php', $_SERVER['HTTP_REFERER'], '');
    ?>
    <form name="dded_maj" id="dded_maj" method="post" action="dded_enr.php">
        <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
        <input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">
        <table width="100%" border="0">
            <tr>
                <td width="160" class="rubfrm" id="f_code" align="right"><?PHP echo _("Code"); ?></td>
                <td>
                    <?PHP if ($td == "add") { ?>
                        <input name="code" type="text" id="code" value="<?PHP echo $dded_code ?>" size="10"
                               maxlength="10">
                        <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                    <?PHP } else { ?>
                        <input name="code" type="text" id="code" value="<?PHP echo $dded_code ?>" size="10"
                               maxlength="10" readonly="1">
                    <?PHP } ?>
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_desc" align="right"><?PHP echo _("Libellé"); ?></td>
                <td>
                    <input name="desc" type="text" id="desc" value="<?PHP echo $dded_desc ?>" size="40">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_pub" align="right"><?PHP echo _("Accessible publiquement"); ?></td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('pub', 'pub', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('pub', 'pub', $non_oui, (int)$dded_pub);
                    ?>
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_cli" align="right"><?PHP echo _("Accessible par les clients"); ?>
                    *
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('client', 'client', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('client', 'client', $non_oui, (int)$dded_cli);
                    ?>
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_age" align="right"><?PHP echo _("Accessible par les agences"); ?>
                    *
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('age', 'age', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('age', 'age', $non_oui, (int)$dded_age);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_tec"
                    align="right"><?PHP echo _("Accessible par les techniciens"); ?>*
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('tec', 'tec', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('tec', 'tec', $non_oui, (int)$dded_tec);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_ope"
                    align="right"><?PHP echo _("Accessible par les opérateurs"); ?>*
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('ope', 'ope', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('ope', 'ope', $non_oui, (int)$dded_ope);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_cge" align="right"><?PHP echo _("Accessible par le siège"); ?>*
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('cge', 'cge', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('cge', 'cge', $non_oui, (int)$dded_cge);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_stt"
                    align="right"><?PHP echo _("Accessible par les techniciens sous-traitants"); ?>*
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('stt', 'stt', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('stt', 'stt', $non_oui, (int)$dded_stt);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_st"
                    align="right"><?PHP echo _("Accessible par les sous-traitants"); ?>*
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('st', 'st', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('st', 'st', $non_oui, (int)$dded_st);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_dot"
                    align="right"><?PHP echo _("Accessible par les techniciens donneurs d'ordres"); ?>*
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('dot', 'dot', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('dot', 'dot', $non_oui, (int)$dded_dot);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_do"
                    align="right"><?PHP echo _("Accessible par les donneurs d'ordres"); ?>*
                </td>
                <td>
                    <?PHP
                    if ($td == "add")
                        cre_select('do', 'do', $non_oui, 0);

                    if (($td == "edit") OR ($td == "del"))
                        cre_select('do', 'do', $non_oui, (int)$dded_do);
                    ?>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_email" align="right"><?PHP echo _("Email"); ?>**</td>
                <td>
                    <input name="email" type="text" id="email" value="<?PHP echo $dded_email ?>" size="50"
                           maxlength="50">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
            </tr>
        </table>
        <span class="annot_petit_it">* <?PHP echo _("Par l'espace privé"); ?>
            / ** <?PHP echo _("N'apparaîtra pas sur les demandes"); ?>.</span><br />

        <p align="center">
            <?PHP if (($td == "add") OR ($td == "edit")) { ?>
                <input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo _("Réinitialiser"); ?>">
                <input name="enr" type="button" class="bton_std" id="enr" value="<?PHP echo _("Enregistrer"); ?>">
            <?PHP } ?>
            <?PHP if ($td == "del") { ?>
                <input name="del" type="submit" class="bton_std" id="del" value="<?PHP echo _("Supprimer"); ?>">
                <input name="annul" type="button" class="bton_std" id="annul" value="<?PHP echo _("Annuler"); ?>">
            <?PHP } ?>
        </p>
    </form>
<?php
} else
    pop_ret_auto(_("Problèmes de paramètres"), 'warn', "dded_lst.php");
include_once("pied.php");
?>