<?php
/****************************************************************************************
 * SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV
 *
 * Version 1.0.4
 *
 * Copyright (C) 2006-2016  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) OR (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(valsession('code_log'));
// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$td = $_GET['td'];
$coderech = $_GET['code'];
$is = $_GET['is'];

$pbm_dosc = FALSE;

if ($coderech <> '') {
    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
    $rech = 'SELECT * FROM `' . TBDOSS . "` WHERE doss_code = '$coderech'";
    $row = $db->get_row($rech, ARRAY_A);
    if ($row) {
        $row = encode_str($row);
        extract($row);
    } else {
        $pbm_dosc = TRUE;
    }
    close_database();
} else {
    if ($td == 'add') {
        $doss_img = $is;
        $doss_code = '';
        $doss_desc = '';
    } else {
        $pbm_dosc = TRUE;
    }
}

$titre = '';
switch ($td) {
    case 'add' :
        $titre = _('CREATION STATUT DOSSIER');
        break;
    case 'edit' :
        $titre = _('MISE A JOUR STATUT DOSSIER');
        break;
    case 'del' :
        $titre = _('SUPPRESSION STATUT DOSSIER');
        if ($doss_delok == 0) {
            $pbm_dosc = TRUE;
        }
        break;
    default :
        $pbm_dosc = 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 statut dossier'); ?></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_dosc == FALSE) { ?>
        <script type="text/javascript">
            <!--
            $(function () {
                $("#code").Setcase({caseValue: 'upper', changeonFocusout: true});
                $("#desc").Setcase({caseValue: 'upper', changeonFocusout: true});
            });

            function init_all() {
                init_Body();
                <?php if (($td=='view') OR ($td=='del')) {echo 'readonly_all();';} ?>
                <?php if ($td=='del') {echo "warn_del('');";} ?>
                Focus_first();
            }

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

    <?php } ?>
</head>

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

if ($pbm_dosc == FALSE) {
    cre_ent_form($titre, 'doss_lst.php', $_SERVER['HTTP_REFERER'], '');
    ?>
    <form name="doss_maj" method="post" action="doss_enr.php">
        <input name="titre" type="hidden" id="titre" value="<?php echo $titre ?>">
        <input name="td" type="hidden" id="td" value="<?php echo $td ?>">
        <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 $doss_img ?>">
                    <?php
                    if (($td == 'add') OR ($td == 'edit')) {
                        if ($doss_img <> '') {
                            ?>
                            <img src="<?php echo $doss_img ?>" border="0" align="absmiddle">
                            <?php
                        } else {
                            ?>
                            <img src="../img/vide.png" align="absmiddle">
                            <a href="icodoss_lst.php"><?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 $doss_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 if ($td == 'add') { ?>
                        <input name="code" type="text" id="code" value="<?php echo $doss_code ?>" size="5"
                               maxlength="5">
                        <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>">
                    <?php } else { ?>
                        <input name="code" type="text" id="code" value="<?php echo $doss_code ?>" size="5" maxlength="5"
                               readonly="1">
                    <?php } ?>
                </td>
            </tr>
            <tr>
                <td width="10%" class="rubfrm" id="f_desc" align="right"><?php echo _('Libellé'); ?></td>
                <td><input name="desc" type="text" id="desc" value="<?php echo $doss_desc ?>" size="50">
                    <img src="../img/oblig.png" align="absmiddle" alt="<?php echo _('Champ obligatoire'); ?>"></td>
            </tr>
        </table>
        <p align="center">
            <?php if (($td == 'add') OR ($td == 'edit')) { ?>
                <input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?php echo _('Réinitialiser'); ?>">
                <input name="submit" type="submit" class="bton_std" id="submit" value="<?php echo _('Enregistrer'); ?>">
            <?php } ?>
            <?php if ($td == 'del') { ?>
                <input name="del" type="submit" class="bton_std" id="del" value="<?php echo _('Supprimer'); ?>">
            <?php } ?>
        </p>
    </form>
    <?php
} else {
    pop_ret_auto(_('Problème de paramètres'), 'warn', 'doss_lst.php');
}
include_once('pied.php');
?>
</body>
</html>