<?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/func_log.inc.php");
if (CheckURLLog(FALSE) == FALSE) header("Location: ../index.php");
if (CheckNivLog("9") == FALSE) header("Location: ../index.php");
include_once("../inc/fic_droits.inc.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_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'];

$pbm_txt = FALSE;

if ($coderech <> "") {
    // Récupération des informations périodicité
    $row = lit_enr_txt($coderech);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);

        switch ($td) {
            case "add" :
                $txt_code = "(2)" . $txt_code;
                $txt_code = substr($txt_code, 0, 19); // Le code ne doit pas dépasser 20 caractères
                break;

            default :
                break;
        }
    } else
        $pbm_txt = TRUE;
}

switch ($td) {
    case "add" :
        $titre = _("CREATION TEXTE TYPE");
        break;

    case "edit" :
        $titre = _("MODIFICATION TEXTE TYPE");
        break;

    case "del" :
        $titre = _("SUPPRESSION TEXTE TYPE");
        break;

    default :
        $pbm_txt = 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 Texte Type"); ?></title>

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

    <script language="javascript">
        <!--
        var tab1_champ = ["nom:code ; format:txt ; req:Y ; txt:<?PHP echo _("Code"); ?> ; lmx:20 ; stok:frmok ; stbad:frmbad",
            "nom:desc; format:txt ; req:Y ; txt:<?PHP echo _("Libellé"); ?> ; lmx:100 ; stok:frmok ; stbad:frmbad",
            "nom:ent; format:txt ; req:N ; txt:<?PHP echo _("Entête"); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

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

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

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

    <?PHP } ?>
</head>

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

if ($pbm_txt == FALSE) {
    cre_ent_form($titre, 'txt_lst.php', $_SERVER['HTTP_REFERER'], '');
    ?>
    <form name="txt_maj" id="txt_maj" method="post" action="txt_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>
                    <input name="code" type="text" id="code" value="<?PHP echo $txt_code ?>" size="20" maxlength="20">
                    <?PHP if ($td == "add")
                        echo '<img src="../img/oblig.png" align="absmiddle" alt="'._("Champ obligatoire").'">';
                    ?>
                </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 $txt_desc ?>" size="80" maxlength="200">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_ent" align="right"><?PHP echo _("Entête"); ?></td>
                <td>
                    <input name="ent" type="text" id="ent" value="<?PHP echo $txt_entete ?>" size="50" maxlength="50">
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_texte" align="right"><?PHP echo _("Texte"); ?></td>
                <td>
                <textarea name="texte" rows="10" readonly id="texte"><?PHP echo $txt_texte ?></textarea>
                 <img src="../img/oblig.png" align="absmiddle" align="top">
                </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").'">';
            ?>
        </p>
    </form>
<?PHP
} else
    pop_ret_auto(_("Problème de paramètres"), 'warn', "txt_lst.php");
include_once("pied.php");
?>
</body>

</html>