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


// 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/func.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_int.inc.php");
include_once("../inc/fic_statut.inc.php");
include_once("../inc/func_date.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);

$pbm_intcat = FALSE;

$ci = $_GET['ci']; // Récupération code Intervention

if ($ci <> "") {
    // Récupération des informations intervention
    $row = lit_enr_int($ci);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);

        if (datetolocal($int_datefin) == "") // On ne peut pas modifier une intervention terminée
        {
            switch ($_SESSION["niv_log"]) {
                // Contrôle qu'une agence n'essaye pas de "hacker" une intervention
                case 4 :
                    if (($int_codeage <> @$_SESSION["code_age"]) AND ($int_codeages <> @$_SESSION["code_age"]))
                        $pbm_intcat = TRUE;
                    break;
            }
        } else
            $pbm_intcat = TRUE;
    } else
        $pbm_intcat = TRUE;
} else
    $pbm_intcat = TRUE;

$titre = _("STATUT INTERVENTION") . ' (';
$titre .= $int_code . ')';
?>
<!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 _("Catégorie intervention"); ?></title>

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

    <script language="javascript">
        <!--
        var tab_champ = new Array(
            "nom:codecat; format:liste ; req:Y ; txt:<?PHP echo _("Catégorie intervention"); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad");
        //-->
    </script>

    <script type="text/javascript">
        <!--
        function init_all() {
            init_Body();
            init_valid_form('enr','intcat_maj', '<?PHP echo $_SESSION['date_fmtshort']; ?>', tab_champ, '', '');
            add_func_click('quit', 'sclose','');
            Focus_first();
        }

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

<body>
<p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
<br />
<?PHP
if ($pbm_intcat == FALSE) {
    ?>
    <form name="intcat_maj" id="intcat_maj" method="post" action="intcat_enr.php">
        <input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
        <input name="ci" type="hidden" id="ci" value="<?PHP echo $ci ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">
        <table border="0" align="center">
            <tr>
                <td align="right" colspan="2">
                    <input name="quit" type="button" class="bton_std" id="quit" value="<?PHP echo _("Quitter"); ?>"
                           style="text-decoration: none; font-size: 11px; color:White ;font-weight:bold;background-color: #666666;">
                </td>
            </tr>
            <tr>
                <td align="right" colspan="2">&nbsp;</td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_statuta" align="right"><?PHP echo _("Catégorie actuelle"); ?></td>
                <td>
                    <?PHP
                    $txt_cat = "";
                    if ($int_codecat <> "") {
                        $row = lit_enr_intcat($int_codecat, TRUE);
                        if (is_array($row)) {
                            $row = encode_str($row);
                            extract($row);
                            $txt_cat = $intc_desc;
                        }
                    }

                    echo '<input name="cata" type="hidden" id="cata" value="' . $int_codecat . '" readonly="readonly">';
                    echo '<input name="ncata" type="text" id="ncata" value="' . $txt_cat . '" size="50" readonly="readonly">';
                    ?>
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_statuta" align="right"><?PHP echo _("Nouvelle catégorie"); ?></td>
                <td>
                    <?PHP
                    // création de la liste des Catégories
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                    $rech = "SELECT * FROM `" . TBINTC . "` ORDER BY intc_desc";
                    $rows = $db->get_results($rech, ARRAY_A);
                    $db->disconnect();

                    cre_select_tab('codecat', 'codecat', $rows, 'intc_code', 'intc_desc', '', $int_codecat, '', _("-- Faites votre choix --"));
                    ?>
                </td>
            </tr>
        </table>

        <p align="center">
            <input name="enr" type="button" class="bton_std" id="enr" value="<?PHP echo _("Valider"); ?>">
            <input name="init" type="reset" class="bton_std" id="init" value="<?PHP echo _("Réinitialiser"); ?>">
        </p>
    </form>
<?PHP
} else
    close_fen_auto('', '');
?>
</body>
</html>
