<?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/fic_pw.inc.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/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'));
$_SESSION['typ_filtres'] = 'ope';
?>
<!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 _('Liste opérateurs'); ?></title>

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

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

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

</head>

<body>

<?php
include_once('../inc/entete.inc.php');
cre_ent_form(_('OPERATEURS TELEPHONIQUES'), '', '', '', FALSE);
$fic_imp = 'ope_lsti.php';
$url_add = 'ope_maj.php?td=add&code=';

$db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');

$rech = cree_strrechlstope();
$rech .= crestr_triord($ope_titre_col, 'ope_code', FALSE, $limit);

$rows = $db->get_results($rech, ARRAY_A);
close_database();

if ($rows) {
    include_once('../inc/formr.inc.php');

    $numrows = count($rows);

    $rech = modstr_triord($rech, $ope_titre_col, 'ope_code', TRUE, $limit);

    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');

    $rows = $db->get_results($rech, ARRAY_A);

    // *** Pagination de pied
    pagine_lst($numrows, $limit);


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

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

    $i = 0;

    foreach ($rows as $row) {
        $row = encode_str($row);
        // création de l'entête de ligne (TR)
        echo '<tr>';

        echo '<td>' . $row['ope_code'];

        // CREATION d'icône en cas de congés
        if ((comp_date($row['ope_congd'], $datea) == TRUE) AND (comp_date($datea, $row['ope_congf']) == TRUE)) {
            $lst_vac = TRUE;
            echo ' <img src="../img/vac.png" title ="' . _('Congés du') . ' ' . datetolocal($row['ope_congd']) . ' ' . _('au') . ' ' . datetolocal($row['ope_congf']) . '" border="0" align="absmiddle">';
        }

        // CREATION d'icône si le technicien n'est plus salarié
        if ($row['ope_out'] == TRUE) {
            $lst_lic = TRUE;
            echo ' <img src="../img/out.png" title ="' . _("N'est plus salarié depuis le") . ' ' . datetolocal($row['ope_dateout']) . '" border="0" align="absmiddle">';
        }

        // Verrouillé ?
        if (account_locked($row['ope_code'], FALSE) == TRUE) {
            echo ' <img src="../img/locked.png" title="' . _('Compte désactivé') . '" alt="' . _('Compte désactivé') . '" border="0" align="absmiddle">';
            $locked = TRUE;
        }

        echo '</td>';
        echo '<td>' . $row['ope_prenom'] . '</td>';
        echo '<td>' . $row['ope_nom'] . '</td>';
        echo '<td>';
        if ($row['ope_telf'] <> '') {
            echo $row['ope_telf'];
        } else {
            echo '&nbsp;';
        }
        echo '</td>';
        echo '<td>';
        if ($row['ope_telp'] <> '') {
            echo $row['ope_telp'];
        } else {
            echo '&nbsp;';
        }
        echo '</td>';

        // CREATION lien dynamique sur icône (édition, suppression, etc...)
        echo '<td>';
        echo '<div align="center">';
        if ($row['ope_out'] == FALSE) {
            $lst_maj = TRUE;
            cre_falselnk_img('', 'ope_edit_' . $row['ope_id'], 'span', 'center', _('Edition'), 'lnk', 'ope_maj.php?td=edit&code=' . $row['ope_code'] . '&dep=' . $row['ope_dep'], '../img/edit.png');
        } else {
            $lst_voir = TRUE;
            cre_falselnk_img('', 'ope_view_' . $row['ope_id'], 'span', 'center', _('Visualisation'), 'lnk', 'ope_maj.php?td=view&code=' . $row['ope_code'] . '&dep=' . $row['ope_dep'], '../img/eye.png');
        }

        if ($row['ope_out'] == FALSE) {
            $lst_del = TRUE;
            cre_falselnk_img('', 'ope_del_' . $row['ope_id'], 'span', 'center', _('Suppression'), 'lnk', 'ope_maj.php?td=del&code=' . $row['ope_code'] . '&dep=' . $row['ope_dep'], '../img/del.png');
        }

        if ($row['ope_out'] == TRUE) {
            if (CheckNivLog('9')) {
                $lst_reopen = TRUE;
                cre_falselnk_img('', 'ope_reopen_' . $row['ope_id'], 'span', 'center', _('Réouverture compte'), 'lnkwpop', 'ope_reopen.php?co=' . $row['ope_code'], '../img/reopen.png', 900, 400);
            }
        }


        echo '</div>';
        echo '</td>';

        echo '</tr>';

        $i++;
    }
    echo '</table>';
    // *** Fin affichage de la table

    close_database();

    if ($locked == TRUE) {
        echo ' <img src="../img/locked.png" title="' . _('Compte désactivé') . '" alt="' . _('Compte désactivé') . '" border="0" align="absmiddle">';
        echo ' : ' . _('Compte désactivé');
    }

    // *** Pagination de pied
    pagine_lst($numrows, $limit);

    $taille_piedla = '';
    include_once('../inc/piedla.inc.php');
} else {
    retpp();
}

include_once('pied.php');
?>
</body>
</html>