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


// vérification des tentatives de hack
$pos = strpos($_SERVER['PHP_SELF'], 'inc.php');
if ($pos !== FALSE) {
    header('Location: ../index.php');
}

include_once('../inc/func.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('../inc/fic_age.inc.php');
include_once('../inc/fic_cli.inc.php');
include_once('../inc/fic_fici.inc.php');
include_once('../inc/fic_int.inc.php');
include_once('../inc/fic_tec.inc.php');
include_once('../inc/fic_zc.inc.php');
include_once('../inc/lst.inc.php');
include_once('../inc/down.inc.php');
include_once('../classes/ephpu/upload_class.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);

$pbm_pj = FALSE;
$mode_pj = FALSE;
$rep_pj = '';
$ss_titre = '';
$codecli = '';
$codeint = '';

$tx = valget('tx');

$codecli = valget('cc');
if ($codecli <> '') {
    $row = lit_enr_cli($codecli, TRUE);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);
    } else {
        $pbm_pj = FALSE;
    }
} else {
    $pbm_pj = TRUE;
}

if (isset($_GET['ci'])) {
    $codeint = valget('ci');
    $row = lit_enr_int($codeint, TRUE);
    if (is_array($row)) {
        $row = encode_str($row);
        extract($row);
    } else {
        $pbm_pj = FALSE;
    }
} else {
    if ($tx == 'int') {
        $pbm_pj = TRUE;
    }
}

switch ($tx) {
    case 'cli' :
        $ss_titre = _('Pour le client') . ' ' . $codecli;
        break;
    case 'int' :
        $ss_titre = _("Pour l'intervention") . ' ' . $codeint;
        break;
    default :
        $pbm_pj = 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 _('Pièces jointes'); ?></title>

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

    <script language="javascript">
        <!--
        var tab1_champ = ["nom:upload ; format:txt ; req:Y ; txt:<?php echo _('Nom du fichier à télécharger'); ?> ; stok:frmok ; stbad:frmbad",
            "nom:name ; format:txt ; req:Y ; txt:<?php echo _('Nom du fichier sur le serveur'); ?> ; lmx:50 ; stok:frmok ; stbad:frmbad",
            "nom:desc ; format:txt ; req:Y ; txt:<?php echo _('Nom complet'); ?> ; lmx:100 ; stok:frmok ; stbad:frmbad",
            "nom:detail ; format:txt ; req:N ; txt:<?php echo _('Libellé'); ?> ; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

    <script type="text/javascript">
        <!--
        function init_datepicker() {
            <?php include_once ('../jscript/datepicker_prm.js.php'); ?>
            $("#date").datepicker();
        }

        function init_all() {
            init_Body();
            init_autohref_classe('falselnkimg', '');
            init_datepicker();
            check_length('name', 50);
            check_length('desc', 50);
            init_valid_form('val_upl', 'upl_maj', '<?php echo valsession('date_fmtshort'); ?>', tab1_champ, '', '');
            chk_valbut('check', 'fic_maj', '<?php echo _('Tous'); ?>', '<?php echo _('Aucun'); ?>');
            init_chk_valbut('check', 'fic_maj', '<?php echo _('Tous'); ?>', '<?php echo _('Aucun'); ?>');
            init_check_all('check', 'fic_maj', '<?php echo _('Tous'); ?>', '<?php echo _('Aucun'); ?>');
            Focus_first();
        }

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

</head>

<body>
<?php
if ($pbm_pj == FALSE) {
    switch ($tx) {
        case 'int' :
            switch ($_SESSION['niv_log']) {
                case 1 :
                    $msg = _('Voici le(s) fichier(s) rattachés');
                    break;
                default :
                    $msg = _('Veuillez cocher le(s) fichier(s) que vous souhaitez rattacher');
                    break;
            }
            break;
        default :
            $msg = _('Veuillez choisir le fichier que vous souhaitez télécharger');
            break;
    }

    cre_ent_form(_('PIECES JOINTES'), '', '', '', FALSE);
    ?>
    <p align="center"><span class="annot_gras"><?php echo $ss_titre; ?></span></p>
    <p align="center" class="annot_gras_it"><?php echo $msg; ?></p>
    <br/>
    <br/>
    <?php
    include_once('downr.inc.php');
    affiche_rep(valsession('niv_log'), valsession('code_log'), valsession('code_age'), valget('ope'), valget('date'));
}
?>
