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

$pbm_urg = FALSE;

if ($coderech <> "") {
    $row = lit_enr_urg($coderech);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);
    } else
        $pbm_urg = TRUE;
} else {
    if ($td <> "add") $pbm_urg = TRUE;
}

if ($pbm_urg == FALSE) {
    switch ($td) {
        case "add" :
            $titre = _("CREATION NIVEAU D'URGENCE");
            $urg_actif = 1;
            $urg_tduree = 3600;
            $urg_couleur = "#C5CED7";
            break;
        case "edit" :
            $titre = _("MODIFICATION NIVEAU D'URGENCE");
            break;
        case "del" :
            $titre = _("SUPPRESSION NIVEAU D'URGENCE");
            if (intval($row["urg_del"]) == 0)
                $pbm_urg = TRUE;
            break;
        default :
            $pbm_urg = 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 niveau d'urgence"); ?></title>

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

    <script language="javascript">
        <!--
        var tab_champ = ["nom:niveau ; format:unsigned ; req:Y ; txt:<?PHP echo _("Niveau"); ?> ; lmn:1 ; lmx:3 ; vmn:0 ; vmx:255 ; stok:frmok ; stbad:frmbad",
            "nom:desc ; format:txt ; req:Y ; txt:<?PHP echo _("Libellé"); ?>; lmn:1 ; lmx:50; stok:frmok ; stbad:frmbad",
            "nom:couleur ; format:hexacol ; req:Y ; txt:<?PHP echo _("Couleur"); ?>; lmn:7 ; lmx:7; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

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

            function init_all() {
                init_Body();
                <?php
                switch ($td)
                {
                    case "add" :
                        echo "init_valid_form('enr','urg_maj','".$_SESSION['date_fmtshort']."',tab_champ,'','');";
                        break;
                    case "edit" :
                        echo "init_valid_form('enr','urg_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;
                }
                ?>
                $('#boxpicker').hide();
                init_colorpicker();
                display_colorpicker();
                close_colorpicker();
                valid_colorpicker();
                Focus_first();
            }

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

    <?PHP } ?>
</head>

<body>
<?PHP
include_once("../inc/entete.inc.php");
if ($pbm_urg == FALSE) {
    cre_ent_form($titre, 'urg_lst.php', $_SERVER['HTTP_REFERER'], '');
    ?>
    <form name="urg_maj" id="urg_maj" method="post" action="urg_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="10%" class="rubfrm" id="f_niveau" align="right"><?PHP echo _("Niveau"); ?></td>
                <td width="47%">
                    <input name="niveau" type="text" id="niveau" value="<?PHP echo $urg_niveau; ?>" size="5">
                    <?PHP if ($td == "add")
                        echo '<img src="../img/oblig.png" align="absmiddle" alt="'._("Champ obligatoire").'">';
                    ?>
                    <span class="annot_petit_it">(<?PHP echo _("Entre 1 et 255"); ?>)</span>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_desc" align="right"><?PHP echo _("Libellé"); ?></td>
                <td><input name="desc" type="text" id="desc" value="<?PHP echo $urg_des; ?>" size="50">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>"></td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_couleur" align="right"><?PHP echo _("Couleur"); ?></td>
                <td>
                    <div id="boxpicker" class="pick_box">
                        <div style="float:right;">
                            <img id="colorpicker_valid" src="../img/ok.png" border="0" align="absmiddle" title="<?PHP echo _("Valider"); ?>" alt="<?PHP echo _("Valider"); ?>">
                            <img id="colorpicker_close" src="../img/rech_close.png" border="0" align="absmiddle" title="<?PHP echo _("Fermer"); ?>" alt="<?PHP echo _("Fermer"); ?>">
                        </div>
                        <div id="colorpicker" style="clear:both;">
                        </div>
                    </div>
                    <input id="couleur_init" name="couleur_init" type="hidden" value="<?PHP echo $urg_couleur; ?>"
                           readonly>
                    <input id="couleur" name="couleur" type="hidden" value="<?PHP echo $urg_couleur; ?>" readonly>
                    <input id="couleur_display" name="couleur_display" type="button" value=""
                           style="background-color:<?PHP echo $urg_couleur; ?>;" class="exemple_color">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">

                    <div class="annot_petit_it"><?PHP echo _("Cliquez sur la couleur pour la changer") ?></div>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_delai" align="right"><?PHP echo _("Délai"); ?></td>
                <td>
                    <?PHP
                    echo '<input name="nduree" type="text" id="nduree" value="' . $urg_nduree . '" size="3"> ';
                    cre_select('tduree', 'tduree', $lng_tduree, $urg_tduree);
                    ?>
                </td>
            </tr>
            <tr>
                <td class="rubfrm" id="f_actif" align="right"><?PHP echo _("Actif"); ?></td>
                <td>
                    <?PHP
                    if (($td == "add") OR ($td == "edit"))
                        cre_select('actif', 'actif', $non_oui, (int)$urg_actif);
                    else
                        echo '<input name="nvalide" type="text" id="nvalide" value="' . $non_oui[$urg_actif] . '">';
                    ?>
                </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', "urg_lst.php");
include_once("pied.php");
?>
</body>

</html>