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

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) header("Location: ../index.php");
if (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(@$_SESSION["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");
?>
<div align="center"><span class="titrepage"><?PHP echo _("OPERATEURS TELEPHONIQUE"); ?></span></div>

<?php
$fic_imp = "ope_lsti.php";
$url_add = "ope_maj.php?td=add&code=";

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

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

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

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);

    $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\">\n";

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

    $i = 0;

    foreach ($rows as $row) {
        $row = encode_str($row);
        // création de l'entête de ligne (TR)
        creetrlst($i);

        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>\n";
        echo "<td>" . $row["ope_prenom"] . "</td>\n";
        echo "<td>" . $row["ope_nom"] . "</td>\n";
        echo "<td>";
        if ($row["ope_telf"] <> "")
            echo $row["ope_telf"];
        else
            echo "&nbsp;";
        echo "</td>\n";
        echo "<td>";
        if ($row["ope_telp"] <> "")
            echo $row["ope_telp"];
        else
            echo "&nbsp;";
        echo "</td>\n";

        // 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 (@$_SESSION["niv_log"] == 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>\n";

        echo "</tr>\n";

        $i++;
    }
    echo "</table>\n";
    // *** Fin affichage de la table

    $db->disconnect();

    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>