<?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/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_ints = 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_ints = TRUE;
                    break;
            }
        } else
            $pbm_ints = TRUE;
    } else
        $pbm_ints = TRUE;
} else
    $pbm_ints = 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 _("Statut intervention"); ?></title>

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

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

    <script type="text/javascript">
        <!--
        function init_all() {
            init_Body();
            init_valid_form('ints_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_ints == FALSE) {
    ?>
    <form name="ints_maj" id="ints_maj" method="post" action="ints_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 _("Statut actuel"); ?></td>
                <td>
                    <?PHP
                    $txt_statut = "";
                    if ($int_codestatut <> "") {
                        $row = lit_enr_statut($int_codestatut);
                        if (is_array($row)) {
                            extract($row);
                            $txt_statut = $statut_desc;
                        }
                    }

                    echo '<input name="statuta" type="hidden" id="statuta" value="' . $int_codestatut . '" readonly="readonly">';
                    echo '<input name="nstatuta" type="text" id="nstatuta" value="' . $txt_statut . '" size="50" readonly="readonly">';
                    ?>
                </td>
            </tr>
            <tr>
                <td width="160" class="rubfrm" id="f_statuta" align="right"><?PHP echo _("Nouveau statut"); ?></td>
                <td>
                    <?PHP
                    // Création de la liste des Statuts
                    $rows = give_rows_statut('CLOT');
                    cre_select_tab('codestatut', 'codestatut', $rows, 'statut_code', 'statut_desc', '', $int_codestatut, '', _("-- Faites votre choix --"));
                    ?>
                </td>
            </tr>
        </table>
        <br /><br />

        <p align="center">
            <input name="create" type="submit" class="bton_std" id="create" 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>