<?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_droits.inc.php");
include_once("../inc/fic_ret.inc.php");
include_once("../inc/func.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(@$_SESSION["code_log"]);
// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$td = $_GET['td'];
$coderech = $_GET['code'];
$tx = $_GET['tx']; // Source de l'appel
//  	tx="r" -> depuis une fiche envoi ou traitement
//  	tx="f" -> depuis une fiche suivi facture

$pbm_me = FALSE;

if ($coderech <> "") {
    $row = lit_enr_me($coderech, TRUE);
    if (is_array($row) == FALSE)
        $pbm_me = TRUE;
    else
        extract($row);
} else {
    if ($td <> "add") $pbm_me = TRUE;
}

switch ($td) {
    case "add" :
        $titre = _("CREATION MOYEN ENVOI");
        break;
    case "edit" :
        $titre = _("MODIFICATION MOYEN ENVOI");
        break;
    case "del" :
        $titre = _("SUPPRESSION MOYEN ENVOI");
        break;
    default :
        $pbm_me = 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 Moyen d'envoi"); ?></title>

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

    <script language="javascript">
        <!--
        var tab_champ = ["nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo _("Code"); ?> ; lmn:1 ; lmx:10; stok:frmok ; stbad:frmbad",
            "nom:nom ; format:txt ; req:Y ; txt:<?PHP echo _("Nom"); ?> ; lmn:1 ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:delai; format:unsigned ; req:Y ; txt:<?PHP echo _("Délai moyen"); ?>; lmn:1 ; lmx:2; stok:frmok ; stbad:frmbad",
            "nom:lien; format:url_pref ; req:N ; txt:<?PHP echo _("Lien"); ?>; lmx:200; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

    <script type="text/javascript">
        <!--
        function init_all() {
            init_Body();
            <?php
            switch ($td)
            {
                case "add" :
                    echo "init_lien_ext('lnk_me','','lien');";
                    echo "init_valid_form('enr','me_maj','".$_SESSION['date_fmtshort']."',tab_champ,'','');";
                    break;
                case "edit" :
                    echo "init_lien_ext('lnk_me','','lien');";
                    echo "init_valid_form('enr','me_maj','".$_SESSION['date_fmtshort']."',tab_champ,'','');";
                    echo "readonly_id('code',false);";
                    break;
                case "view" :
                    echo "readonly_all();";
                    break;
                case "del" :
                    echo "readonly_all();";
                    echo "warn_del('');";
                    break;
            }
            ?>
            add_func_click('quit', 'sclose','');
            Focus_first();
        }

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

</head>

<body>
<?php
if (($tx <> "r") AND ($tx <> "f"))
    include_once("../inc/entete.inc.php");
if ($pbm_me == FALSE) {
    cre_ent_form($titre, 'me_lst.php', $_SERVER['HTTP_REFERER'], '');
    ?>
    <form id="me_maj" name="me_maj" method="post" action="me_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="tx" type="hidden" id="tx" value="<?PHP echo $tx ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">
        <table border="0" align="center">
            <tr>
                <td width="160" class="rubfrm" id="f_code" align="right"><?PHP echo _("Code"); ?></td>
                <td>
                    <input name="code" type="text" id="code" value="<?PHP echo $me_code ?>" size="10">
                    <?PHP
                    if ($td == "add")
                         echo ' <img src="../img/oblig.png" align="absmiddle" alt="'._("Champ obligatoire").'">';
                    ?>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_nom" align="right"><?PHP echo _("Nom"); ?></td>
                <td><input name="nom" type="text" id="nom" value="<?PHP echo $me_nom ?>" size="50">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"></td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_delai" align="right"><?PHP echo _("Délai moyen"); ?></td>
                <td><input name="delai" type="text" id="delai" value="<?PHP echo $me_delai ?>" size="3"><?PHP echo ' '._("jours"); ?>
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"></td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_lien" align="right"><?PHP echo _("Lien contrôle colis"); ?></td>
                <td>
                    <input name="lien" type="text" id="lien" value="<?PHP echo $me_lien ?>" size="80" maxlength="200">
                    <?PHP
                    echo ' <img src="../img/web_go.png" id ="lnk_me" border="0" align="absmiddle" alt="'._("Se connecter au site du transporteur").'">';
                    ?>
                    <div class="annot_petit_it">(<?PHP echo _("Merci de saisir sous la forme http://xxx.xxx.xxx)"); ?></div>
                </td>
            </tr>
        </table>
        <p align="center">
        <?PHP
        switch ($td)
        {
            case "add" :
            case "edit" :
                echo '<input name="enr" type="button" class="bton_std" id="enr" value="'._("Valider").'">';
                break;
            case "del" :
                echo '<input name="del" type="submit" class="bton_std" id="del" value="'._("Supprimer").'">';
                break;
        }
        echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="'._("Réinitialiser").'">';
        if (($tx == "r") OR ($tx == "f"))
            echo '<input name="quit" type="button" class="bton_std" id="quit" value="'._("Quitter").'">';
        ?>
        </p>
    </form>
<?PHP
} else {
    switch ($tr) {
        case "r" :
        case "f" :
            close_fen_auto('', 'fscomp');
            break;
        default :
            pop_ret_auto(_("Problème de paramètres"), 'warn', "index.php");
            break;
    }
}
if (($tx <> "r") AND ($tx <> "f"))
    include_once("pied.php");
?>
</body>
</html>