<?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/func_log.inc.php');
if ((CheckURLLog(TRUE) == FALSE) OR (CheckNivLog('6-7') == FALSE)) {
    header('Location: ../index.php');
}
include_once('../inc/fic_age.inc.php');
include_once('../inc/fic_cocl.inc.php');
include_once('../inc/fic_droits.inc.php');
include_once('../inc/fic_fici.inc.php');
include_once('../inc/fic_int.inc.php');
include_once('../inc/fic_plan.inc.php');
include_once('../inc/fic_prm.inc.php');
include_once('../inc/fic_rdv.inc.php');
include_once('../inc/fic_statut.inc.php');
include_once('../inc/fic_tac.inc.php');
include_once('../inc/fic_tec.inc.php');
include_once('../inc/func.inc.php');
include_once('../inc/func_date.inc.php');
include_once('../inc/func_time.inc.php');
include_once('../inc/func_txt.inc.php');
include_once('../inc/func_geo.inc.php');
include_once('../inc/lst.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'));
$pbm_conf = FALSE;
if ((!exist_logo('cge')) OR (!exist_logo(valsession('code_do'))) OR (!existe_cdg())) {
    $pbm_conf = TRUE;
}
?>
    <!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 _("Index Donneur d'Ordres"); ?></title>

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

        <script type="text/javascript">
            <!--
            function init_all() {
                init_Body();
                $("#onglets_idx").tabs();
                init_autohref_classe('falselnkimg', '<?php echo str_escape(_('Merci de confirmer').'<br />'.str_escape("Sinon, cliquez sur 'Annuler'")); ?>');
                Focus_first();
            }

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

    </head>

<body>

<?php
if ($pbm_conf == FALSE) {
    include_once('../inc/entete.inc.php');
    cre_ent_form(_('TABLEAU DE BORD'), '', '', '', FALSE);
    ?>
    <div id="onglets_idx">
        <ul>
            <li><a href="#idx_intc"><?php echo _('Interventions en cours'); ?></a></li>
        </ul>
        <div id="idx_intc">
            <?php
            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');

            $rech = cree_strrechlstint($_SESSION['niv_log']);
            if (!stristr($rech, 'WHERE ')) /** @noinspection PhpUndefinedMethodInspection */ {
                $rech .= ' WHERE ' . TBINT . ".int_codedo='" . $db->escape(valsession('code_do')) . "' AND " . TBINT . ".int_datefin = '0000-00-00'";
            } else /** @noinspection PhpUndefinedMethodInspection */ {
                $rech .= ' AND ' . TBINT . ".int_codedo='" . $db->escape(valsession('code_do')) . "' AND " . TBINT . ".int_datefin = '0000-00-00'";
            }

            $rech .= 'ORDER BY ' . TBINT . '.int_code DESC';
            // *** Fin de chaîne de Recherche

            /** @noinspection PhpUndefinedMethodInspection */
            $rows = $db->get_results($rech, ARRAY_A);

            if ($rows AND (count($rows) > 0)) {
                $numrows = count($rows);
                echo '<span class="annot_petit_it">';
                echo _('Laisser la souris sur une icône pour le détail') . '<br />';
                echo '</span>';

                // *** Affichage de la table
                echo '<table class="Mtable" border="0" width="100%" cellpadding="0" cellspacing="0">';

                // création entête
                titlst($int_titre_col);
                echo '<th>' . _('Cliquer') . '</th>';

                $i = 0;

                // Inclusion module affichage liste interventions
                include_once('../inc/intr_lst.inc.php');

                echo '</table>';
                // *** Fin affichage de la table
            } else {
                echo '<div class="annot_gras_it">';
                echo '<br />' . _("Pas d'intervention en cours");
                echo '</div>';
            }

            /** @noinspection PhpUndefinedMethodInspection */
            close_database();

            $taille_piedla = '';
            include('../inc/piedla.inc.php'); ?>
        </div>
    </div>
    <?php
    include_once('pied.php');
} else {
    ?>
    <p align="center"><span class="titrepageerr"><?php echo _('PROBLEME DE CONFIGURATION'); ?></span></p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <?php
    pop_ret_auto(_("SMI n'a pas encore été totalement configuré pour votre compte") . '<br />' . _("Merci de contacter l'administrateur ou le centre de gestion"), 'warn', 'index.php');
}
?>