<?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
 ****************************************************************************************/

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("../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'];
$tx = $_GET['tx'];
$coderech = $_GET['code'];
$is = $_GET['is'];

$pbm_ta = FALSE;
$pbm_tx = FALSE;

if ($coderech <> "") {
    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
    $rech = "SELECT * FROM `" . TBTA . "` WHERE ta_code = '" . $db->escape($coderech) . "'";
    $row = $db->get_row($rech, ARRAY_A);
    if ($row) {
        $row = encode_str($row);
        extract($row);
    } else
        $pbm_ta = TRUE;
    $db->disconnect();
} else {
    if ($td == "add") {
        $ta_img = $is;
        $ta_code = "";
        $ta_desc = "";
        $ta_doss = 1;
        $ta_tra = 0;
    } else
        $pbm_ta = TRUE;
}

switch ($tx) {
    case "doss" :
        break;

    case "tra" :
        break;

    default :
        $pbm_ta = TRUE;
        $pbm_tx = TRUE;
        break;
}

switch ($td) {
    case "add" :
        $titre = _("CREATION TYPE ACTION");
        break;
    case "edit" :
        $titre = _("MISE A JOUR TYPE ACTION");
        break;
    case "view" :
        $titre = _("VISUALISATION TYPE ACTION");
        break;
    case "del" :
        $titre = _("SUPPRESSION TYPE ACTION");
        if ($ta_delok == 0)
            $pbm_ta = TRUE;
        break;
    default :
        $pbm_ta = TRUE;
        break;
}

$lst_id_readonly = '';
if ($td <> "add")
    $lst_id_readonly = 'code';
else
    $lst_id_readonly = 'tra';
if ($ta_doss == 0)
    $lst_id_readonly.='-depl';
if ($ta_tra == 1)
    $lst_id_readonly.='-doss';
?>
<!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 type action"); ?></title>

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

    <script language="javascript">
        <!--
        var tab1_champ = ["nom:image ; format:txt ; req:Y ; txt:<?PHP echo _("Icône"); ?> ; lmx:200 ; stok:frmok ; stbad:frmbad",
            "nom:code ; format:alphanum ; req:Y ; txt:<?PHP echo _("Code"); ?> ; lmx:5 ; stok:frmok ; stbad:frmbad",
            "nom:desc; format:txt ; req:Y ; txt:<?PHP echo _("Libellé"); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

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

            function init_all() {
                init_Body();
                <?php
                switch($td)
                {
                    case "add" :
                        echo "init_valid_ta('enr','ta_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                        break;
                    case "edit" :
                        echo "readonly_id('".$lst_id_readonly."',false);";
                        echo "init_valid_ta('enr','ta_maj','".$_SESSION['date_fmtshort']."',tab1_champ,'','');";
                        break;
                    case "view" :
                        echo "readonly_all();";
                        break;
                    case "del" :
                        echo "readonly_all();";
                        echo "warn_del('');";
                        break;
                }
                ?>
                Focus_first();
            }

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

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

if ($pbm_ta == FALSE) {
    cre_ent_form($titre, 'ta_lst.php?td=' . $tx, $_SERVER['HTTP_REFERER'], '');
    ?>
    <form name="ta_maj" id="ta_maj" method="post" action="ta_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 width="100%" border="0">
            <tr>
                <td width="10%" class="rubfrm" id="f_img" align="right"><?PHP echo _("Icône"); ?></td>
                <td>
                    <input name="image" type="hidden" id="image" value="<?PHP echo $ta_img ?>">
                    <?PHP
                    if (($td == "add")  OR ($td == "edit")) {
                        if ($ta_img <> "") {
                            ?>
                            <img src="<?PHP echo $ta_img ?>" border="0" align="absmiddle">
                        <?PHP
                        } else {
                            ?>
                            <img src="../img/vide.png" align="absmiddle">
                            <a href="icota_lst.php?tx=<?PHP echo $tx; ?>"><?PHP echo _("Choisir Icône"); ?></a> <img
                                src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                            <span class="annot_std_it"><?PHP echo _("(impératif en 1er !)"); ?></span>
                        <?PHP
                        }
                    } else {
                        ?>
                        <img src="<?PHP echo $ta_img ?>" border="0" align="absmiddle">
                    <?PHP
                    }
                    ?>
                </td>
            </tr>
            <tr>
                <td width="10%" class="rubfrm" id="f_code" align="right"><?PHP echo _("Code"); ?></td>
                <td width="47%">
                    <?PHP
                    echo '<input name="code" type="text" id="code" value="' . $ta_code . '" size="5" maxlength="5">';
                    echo ' <img src="../img/oblig.png" align="absmiddle" alt="' . _("Champ obligatoire") . '">';
                    ?>
                </td>
            </tr>
            <tr>
                <td width="10%" class="rubfrm" id="f_desc" align="right"><?PHP echo _("Libellé"); ?></td>
                <td>
                    <?PHP
                    echo '<input name="desc" type="text" id="desc" value="' . $ta_desc . '" size="50">';
                    echo ' <img src="../img/oblig.png" align="absmiddle" alt="' . _("Champ obligatoire") . '">';
                    ?>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_depl" align="right"><?PHP echo _("Déplacement"); ?></td>
                <td>
                    <?PHP cre_select('depl', 'depl', $non_oui, $ta_depl); ?>
                    <div class="annot_petit_it">(<?PHP echo _("'Oui' : Nécessite un déplacement"); ?>)</div>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_doss" align="right"><?PHP echo _("Dossiers de suivi"); ?></td>
                <td>
                    <?PHP cre_select('doss', 'doss', $non_oui, intval($ta_doss)); ?>
                    <div class="annot_petit_it">(<?PHP echo _("'Oui' : Utilisable dans les dossiers de suivi"); ?>)</div>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_tra" align="right"><?PHP echo _("Traçabilité"); ?></td>
                <td>
                    <?PHP cre_select('tra', 'tra', $non_oui, intval($ta_tra)); ?>
                    <div class="annot_petit_it">(<?PHP echo _("'Oui' : Utilisable dans la traçabilité"); ?>)</div>
                </td>
            </tr>
        </table>
        <?PHP
        if (intval($ta_univ) == 1)
            echo '<div class="annot_petit_gras_rouge" align="center">' . _("Type universel non modifiable") . '</div>';
        ?>
        <p align="center">
            <?PHP
            switch ($td)
            {
                case "add" :
                case "edit" :
                    echo '<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="'._("Réinitialiser").'">';
                    echo ' <input name="enr" type="button" class="bton_std" id="enr" value="'._("Enregistrer").'">';
                    break;
                case "del" :
                    echo '<input name="del" type="submit" class="bton_std" id="del" value="'._("Supprimer").'">';
                    break;
            }
            ?>
        </p>
    </form>
<?PHP
} else {
    if ($pbm_tx == FALSE)
        pop_ret_auto(_("Problème de paramètres"), 'warn', "ta_lst.php");
    else
        pop_ret_auto(_("Problème de paramètres"), 'warn', "index.php");
}

include_once("pied.php");
?>
</body>

</html>