<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 1.0.2

Copyright (C) 2006-2015  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(FALSE) == FALSE) header("Location: ../index.php");
if (CheckNivLog("3-4") == 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(@$_SESSION["code_log"]);
check_modules();
$pbm_conf = FALSE;
$tab_int = [];

if (!exist_logo("cge")) $pbm_conf = TRUE;
if (!exist_logo(@$_SESSION["code_age"])) $pbm_conf = TRUE;
if (!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 Agences"); ?></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 />Sinon, cliquez sur 'Annuler'")); ?>');
            <?php
            if ((@$_SESSION["niv_log"] == 4) AND ($pbm_conf == FALSE))
            {
                echo "init_warn('".pbm_tecspr(@$_SESSION["code_age"],TRUE)."tecspr','','','','');";
                echo "init_warn('".nb_agepr(@$_SESSION["code_age"],TRUE)."agepr','','','','');";
                echo "init_warn('".pbm_cagespr('',TRUE)."cagespr','','','','');";
            }
            ?>
            warn_taches("<?PHP echo $nbtaches; ?>", 'tac');
            Focus_first();
        }

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

<?php
if ($pbm_conf == FALSE) {
    include_once("../inc/entete.inc.php");
    ?>
    <p align="center"><span class="titrepage"><?PHP echo _("TABLEAU DE BORD"); ?></span><br></p>
    <div id="onglets_idx">
    <ul>
        <li><a href="#idx_tac"><?PHP echo _("Tâches à effectuer"); ?></a></li>
        <li><a href="#idx_intc"><?PHP echo _("Interventions en cours"); ?></a></li>
        <li><a href="#idx_intag"><?PHP echo _("Inter. à gérer"); ?></a></li>
        <li><a href="#idx_relp"><?PHP echo _("Relevés avec problèmes"); ?></a></li>
        <li><a href="#idx_cocle"><?PHP echo _("Contrats à échéance"); ?></a></li>
        <li><a href="#idx_dosc"><?PHP echo _("Dossiers en cours"); ?></a></li>
    </ul>
    <div id="idx_tac">
    <?PHP
    // RAZ variables pour les pieds de liste
    include("../inc/init_varpl.inc.php");

    if (url_ok('tac_lst.php', TRUE) == TRUE) {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

        $rech = cree_strrechlsttac();
        switch (@$_SESSION["niv_log"]) {
            // Filtre pour les techniciens agences
            case 3 :
                if (!stristr($rech, "WHERE "))
                    $rech .= " WHERE " . TBTAC . ".tac_codedest='" . @$_SESSION["code_log"] . "'";
                else
                    $rech .= " AND " . TBTAC . ".tac_codedest='" . @$_SESSION["code_log"] . "'";
                break;
            // Filtre pour les agences
            case 4 :
                // On construit la liste des techniciens actifs de l'agence
                $tab_lst_tec = [];
                $rech2 = "SELECT tec_code FROM `" . TBTEC . "` WHERE tec_codeage='" . @$_SESSION["code_log"] . "' AND tec_out=0";
                /** @noinspection PhpUndefinedMethodInspection */
                $rows2 = $db->get_results($rech2, ARRAY_A);
                if (count($rows2) > 0) {
                    foreach ($rows2 as $row2) {
                        extract($row2);
                        $tab_lst_tec[] = $tec_code;
                    }
                }
                if (!stristr($rech, "WHERE "))
                    $rech .= " WHERE (" . TBTAC . ".tac_codedest='" . @$_SESSION["code_log"] . "'";
                else
                    $rech .= " AND (" . TBTAC . ".tac_codedest='" . @$_SESSION["code_log"] . "'";
                if (count($tab_lst_tec) > 0) {
                    foreach ($tab_lst_tec as $key => $value) {
                        $rech .= " OR " . TBTAC . ".tac_codedest='" . $value . "'";
                    }
                }
                $rech .= ")";
                break;
        }

        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE tac_datefin='0000-00-00'";
        else
            $rech .= " AND tac_datefin='0000-00-00'";
        $rech .= "ORDER BY " . TBTAC . ".tac_code DESC";

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

        if ($rows) {
            // *** Affichage de la table
            echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";

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

            $i = 0;

            // Inclusion module affichage liste tâches
            include_once("../inc/tacr_lst.inc.php");

            echo "</table>\n";
            // *** Fin affichage de la table
        } else {
            echo "<div class=\"annot_gras_it\">";
            echo "<br />" . _("Pas de tâche en cours");
            echo "</div>";
        }

        /** @noinspection PhpUndefinedMethodInspection */
        $db->disconnect();

        $taille_piedla = "";
        include("../inc/piedla.inc.php");
    } else
        echo "Sans objet";
    ?>
    </div>

    <div id="idx_intc">
    <?PHP
    // RAZ variables pour les pieds de liste
    include("../inc/init_varpl.inc.php");

    if (url_ok('int_lst.php', TRUE) == TRUE) {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
        $rech = cree_strrechlstint($_SESSION["niv_log"]);
        switch ($_SESSION["niv_log"]) {
            // Techniciens
            case 3 :
                // création du tableau des interventions affichables
                $tab_int = give_tab_int_ok_tec(@$_SESSION["code_log"], @$_SESSION["code_age"], FALSE);

                if (count($tab_int) > 0) {
                    if (!stristr($rech, "WHERE "))
                        $rech .= " WHERE ";
                    else
                        $rech .= " AND ";
                    if (count($tab_int) > 1)
                        $rech .= "(";

                    foreach ($tab_int as $value) {
                        $rech .= " " . TBINT . ".int_code='" . $value . "' OR";
                    }

                    // Suppression du dernier 'OR'
                    $rech = substr($rech, 0, strlen($rech) - 3);

                    if (count($tab_int) > 1)
                        $rech .= ")";
                }
                break;
            // Agences
            case 4 :
                if (!stristr($rech, "WHERE "))
                    $rech .= " WHERE (" . TBINT . ".int_codeage='" . @$_SESSION["code_age"] . "' OR " . TBINT . ".int_codeages='" . @$_SESSION["code_age"] . "'";
                else
                    $rech .= " AND (" . TBINT . ".int_codeage='" . @$_SESSION["code_age"] . "' OR " . TBINT . ".int_codeages='" . @$_SESSION["code_age"] . "'";

                // On rajoute les interventions non affectées à une agence
                $rech .= " OR " . TBINT . ".int_codeage='')";
                $row = lit_enr_age($_SESSION["code_age"], FALSE);
                if (is_array($row)) {
                    extract($row);
                    if ((int)$age_fact == 1)
                        $aff_sfact = TRUE;
                }
                break;
        }
        $rech .= " AND " . TBINT . ".int_codetec <> '-1' AND " . TBINT . ".int_codetec <> ''";
        $rech .= " AND " . TBINT . ".int_datefin = '0000-00-00'";
        $rech .= "ORDER BY " . TBINT . ".int_code DESC";
        // *** Fin de chaîne de Recherche

        $numrows = 0;
        /** @noinspection PhpUndefinedMethodInspection */
        $rows = $db->get_results($rech, ARRAY_A);
        if ($rows)
            $numrows = count($rows); // Nombre de résultats à la requête

        switch (@$_SESSION["niv_log"]) {
            case 3 :
                if (count($tab_int) == 0)
                    $numrows = 0;
                break;
            default :
                break;
        }

        if ($numrows > 0) {
            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\">\n";

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

            $i = 0;

            // Inclusion module affichage liste interventions
            include("../inc/intr_lst.inc.php");

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

        /** @noinspection PhpUndefinedMethodInspection */
        $db->disconnect();

        $taille_piedla = "";
        include("../inc/piedla.inc.php");
    } else
        echo _("Sans objet");
    ?>
    </div>

    <div id="idx_intag" style="display:none">
    <?PHP
    // RAZ variables pour les pieds de liste
    include("../inc/init_varpl.inc.php");

    if (url_ok('int_lst.php', TRUE) == TRUE) {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

        $rech = cree_strrechlstint($_SESSION["niv_log"]);
        switch ($_SESSION["niv_log"]) {
            // Techniciens
            case 3 :
                // création du tableau des interventions affichables
                $tab_int = give_tab_int_ok_tec(@$_SESSION["code_log"], @$_SESSION["code_age"], FALSE);

                if (count($tab_int) > 0) {
                    if (!stristr($rech, "WHERE "))
                        $rech .= " WHERE ";
                    else
                        $rech .= " AND ";
                    if (count($tab_int) > 1)
                        $rech .= "(";

                    foreach ($tab_int as $value) {
                        $rech .= " " . TBINT . ".int_code='" . $value . "' OR";
                    }

                    // Suppression du dernier 'OR'
                    $rech = substr($rech, 0, strlen($rech) - 3);

                    if (count($tab_int) > 1)
                        $rech .= ")";
                }
                break;
            // Agences
            case 4 :
                if (!stristr($rech, "WHERE "))
                    $rech .= " WHERE (" . TBINT . ".int_codeage='" . @$_SESSION["code_age"] . "' OR " . TBINT . ".int_codeages='" . @$_SESSION["code_age"] . "'";
                else
                    $rech .= " AND (" . TBINT . ".int_codeage='" . @$_SESSION["code_age"] . "' OR " . TBINT . ".int_codeages='" . @$_SESSION["code_age"] . "'";

                // On rajoute les interventions non affectées à une agence
                $rech .= " OR " . TBINT . ".int_codeage='')";
                $row = lit_enr_age($_SESSION["code_age"], FALSE);
                if (is_array($row)) {
                    extract($row);
                    if ((int)$age_fact == 1)
                        $aff_sfact = TRUE;
                }
                break;
        }


        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE (" . TBINT . ".int_codetec='-1' OR " . TBINT . ".int_codetec='')";
        else
            $rech .= " AND (" . TBINT . ".int_codetec='-1' OR " . TBINT . ".int_codetec='')";
        $rech .= " ORDER BY " . TBINT . ".int_code DESC";
        // *** Fin de chaîne de Recherche

        $numrows = 0;
        /** @noinspection PhpUndefinedMethodInspection */
        $rows = $db->get_results($rech, ARRAY_A);
        if ($rows)
            $numrows = count($rows); // Nombre de résultats à la requête
        switch (@$_SESSION["niv_log"]) {
            case 3 :
                if (count($tab_int) == 0)
                    $numrows = 0;
                break;
            default :
                break;
        }


        if ($numrows > 0) {
            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\">\n";

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

            $i = 0;

            // Inclusion module affichage liste interventions
            include("../inc/intr_lst.inc.php");

            echo "</table>\n";
            // *** Fin affichage de la table
        } else {
            echo "<div class=\"annot_gras_it\">";
            echo "<br />" . _("Pas d'intervention à gérer");
            echo "</div>";
        }

        /** @noinspection PhpUndefinedMethodInspection */
        $db->disconnect();

        $taille_piedla = "";
        include("../inc/piedla.inc.php");
    } else
        echo _("Sans objet");
    ?>
    </div>

    <div id="idx_relp" style="display:none">
    <span class="annot_std_it"><?PHP echo _("Déclarés et non affectés à une intervention"); ?></span>
    <?PHP
    // RAZ variables pour les pieds de liste
    include("../inc/init_varpl.inc.php");

    if (url_ok('rel_lst.php', TRUE) == TRUE) {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

        $rech = cree_strrechlstrrel();
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE " . TBREL . ".rel_codeage='" . @$_SESSION["code_age"] . "'";
        else
            $rech .= " AND " . TBREL . ".rel_codeage='" . @$_SESSION["code_age"] . "'";
        $rech .= crestr_triord($rel_titre_col, "rel_code", FALSE, $limit);
        // *** Fin de chaîne de Recherche

        $numrows = 0;
        /** @noinspection PhpUndefinedMethodInspection */
        $rows = $db->get_results($rech, ARRAY_A);
        if ($rows)
            $numrows = count($rows); // Nombre de résultats à la requête

        if ($numrows > 0) {
            $first = TRUE;
            $i = 0;

            foreach ($rows as $row) {
                $row = encode_str($row);
                // Affichage résumé relevé

                // vérification si problème(s) non affecté(s)
                // Si oui, on affiche (sinon, non)
                $rech2 = "SELECT COUNT(*) FROM `" . TBRPBM . "`  WHERE rpbm_codecli = '" . $row["cli_code"] . "' AND rpbm_codeint IS NULL";
                /** @noinspection PhpUndefinedMethodInspection */
                $nb_pbm = $db->get_var($rech2);
                if ($nb_pbm > 0) {
                    if ($first == TRUE) {
                        // *** Affichage de la table
                        echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";

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

                        $first = FALSE;
                    }

                    // création de l'entête de ligne (TR)
                    creetrlst($i);

                    echo "<td>";
                    echo $row["rel_code"];
                    echo "</td>\n";
                    echo "<td>" . datetolocal($row["rel_datecrea"]) . "</td>\n";
                    echo "<td>" . datetolocal($row["rel_datemod"]) . "</td>\n";
                    echo "<td>" . $row["rel_codecli"];

                    // Affichage détail client

                    $detailcli = "->";
                    if ($row["cli_ste"] <> "")
                        $detailcli .= $row["cli_ste"] . ", ";
                    $detailcli .= $row["cli_civilite"] . " " . $row["cli_nom"];
                    echo "<br>";
                    echo "<span class=\"annot_std_it\">";
                    echo $detailcli;
                    echo "</span>";

                    // Fin affichage détail client

                    echo "</td>\n";
                    if ($row["rel_codeage"] <> "")
                        echo "<td>" . $row["rel_codeage"] . "</td>\n";
                    else
                        echo "<td>&nbsp;</td>\n";

                    // CREATION lien dynamique sur icône (édition, suppression, etc...)
                    echo "<td align=\"center\">";

                    if (url_ok('rel_maj.php?td=edit', FALSE) == TRUE) {
                        $lst_maj = TRUE;
                        cre_falselnk_img('', 'rel_edit_'.$row["rel_id"], 'span', 'center', _("Edition"), 'lnk', 'rel_maj.php?td=edit&cr=' . $row["rel_code"] . '&cc=' . $row["rel_codecli"] . '&ca=' . $row["rel_codeage"] , '../img/edit.png');
                    }

                    $urlimp = "rel_pdf.php?cr=" . $row["rel_code"] . "&pbm=0";
                    if (url_ok($urlimp, FALSE) == TRUE) {
                        $lst_imp = TRUE;
                        cre_falselnk_img('', 'rel_prn_'.$row["rel_id"], 'span', 'center', _("Imprimer le dossier relevé"), 'lnkpop', $urlimp, '../img/print.png');
                    }

                    $urlimp = "rel_pdf.php?cr=" . $row["rel_code"] . "&pbm=1";
                    if (url_ok($urlimp, FALSE) == TRUE) {
                        $lst_impp = TRUE;
                        cre_falselnk_img('', 'rel_prnp_'.$row["rel_id"], 'span', 'center', _("Imprimer le dossier relevé avec les problèmes"), 'lnkpop', $urlimp, '../img/printc.png');
                    }

                    if (url_ok('rel_maj.php?td=del', FALSE) == TRUE) {
                        $lst_del = TRUE;
                        $lst_del = TRUE;
                        cre_falselnk_img('', 'rel_del_'.$row["rel_id"], 'span', 'center', _("Suppression"), 'lnk', 'rel_maj.php?td=edit&cr=' . $row["rel_code"] . '&cc=' . $row["rel_codecli"] . '&ca=' . $row["rel_codeage"] , '../img/del.png');
                    }

                    echo "</td>\n";

                    echo "</tr>\n";
                    // Fin affichage résumé intervention

                    $i++;
                }
            }

            if ($first == FALSE)
                echo "</table>\n"; // *** Fin affichage de la table
            else {
                echo "<div class=\"annot_gras_it\">";
                echo "<br />";
                echo _("Pas de problème déclaré non affecté");
                echo "</div>";
            }
        } else {
            echo "<div class=\"annot_gras_it\">";
            echo "<br />" . _("Pas de Relevé sur cette agence");
            echo "</div>";
        }

        /** @noinspection PhpUndefinedMethodInspection */
        $db->disconnect();

        $taille_piedla = "";
        include("../inc/piedla.inc.php");
    } else
        echo _("Sans objet");
    ?>
    </div>

    <div id="idx_cocle">
    <span class="annot_std_it"><?PHP echo _("Signés, non renouvelés, avec moins de 60 minutes de solde sur quota horaire ou à échéance dans 30 jours maximum"); ?></span>
    <?PHP
    // RAZ variables pour les pieds de liste
    include("../inc/init_varpl.inc.php");

    if (url_ok('cocl_lst.php', TRUE) == TRUE) {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

        $rech = cree_strrechlstcocl();
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE ";
        else
            $rech .= " AND ";
        $rech .= TBCOCL . ".cocl_codeage='" . @$_SESSION["code_age"] . "'";
        $rech .= " AND " . TBCOCL . ".cocl_datefin ='0000-00-00' AND " . TBCOCL . ".cocl_datesig <>'0000-00-00' AND " . TBCOCL . ".cocl_renouv ='0'";
        $rech .= "  AND " . TBCOCL . ".cocl_dated<='" . $datea . "'";
        $rech .= " AND (" . TBCOCL . ".cocl_typh=1";
        $rech .= " OR (" . TBCOCL . ".cocl_datef <='" . nouv_date_plus_jours($datea, 30) . "' AND " . TBCOCL . ".cocl_datef<>'0000-00-00'))";
        $rech .= " ORDER BY " . TBCOCL . ".cocl_code DESC";
        // *** Fin de chaîne de Recherche

        $numrows = 0;
        /** @noinspection PhpUndefinedMethodInspection */
        $rows = $db->get_results($rech, ARRAY_A);
        if ($rows)
            $numrows = count($rows); // Nombre de résultats à la requête

        if ($numrows > 0) {
            echo "<div class=\"annot_petit_it\">";
            echo _("Laisser la souris sur une icône pour le détail") ;
            echo "</div>";

            if (@$_SESSION["niv_log"] == 4) {
                echo "<a href=\"coclren_lst.php?ord=DES&tri=Code\">" . _("Renouveler des contrats") . "</a>";
            }

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

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

            $i = 0;
            foreach ($rows as $row) {
                $row = encode_str($row);
                // Affichage résumé Contrat Client

                // création de l'entête de ligne (TR)
                creetrlst($i);

                $aff_ok = TRUE;

                $soldes_reel = solde_contrat_sec($row["cocl_code"], FALSE);
                if (($row["cocl_typh"] == 1) AND ($soldes_reel > 3600))
                    $aff_ok = FALSE;

                if ($aff_ok == TRUE) {
                    $echeance_ok = TRUE;
                    if ((datetolocal($row["cocl_datef"]) <> "")  AND (echeance_depassee_date($datea, $row["cocl_datef"]) == TRUE))
                        $echeance_ok = FALSE;

                    echo "<td>" . $row["cocl_code"];

                    // détail contrat
                    echo "<br>";
                    echo "<span class=\"annot_petit_it\">";
                    $txt = formatetxt($row["co_nom"]);
                    echo "->" . _("Type") . " : " . $txt;
                    echo "</span>";

                    echo "</td>\n";

                    // Type de contrat
                    echo "<td align=\"center\">" . $typ_horaire[$row["cocl_typh"]] . "</td>\n";

                    echo "<td>";
                    echo $row["cocl_codecli"];
                    cre_falselnk_img('', 'cli_edit_'.$row["cli_id"], 'span', 'center', _("Edition client"), 'lnk', 'cli_maj.php?td=edit&cc=' . $row["cocl_codecli"] . '&dep=' . $row["cli_dep"] , '../img/edit.png');

                    // Affichage détail client

                    $detailcli = "->";
                    if ($row["cli_ste"] <> "")
                        $detailcli .= $row["cli_ste"] . ", ";
                    $detailcli .= $row["cli_civilite"] . " " . $row["cli_nom"];
                    echo "<br>";
                    echo "<span class=\"annot_petit_it\">";
                    echo $detailcli;
                    echo "</span>";

                    // Fin affichage détail client

                    echo "</td>\n";

                    // création
                    echo "<td>";
                    echo "<div align=\"center\">";
                    echo datetolocal($row["cocl_datecrea"]);
                    echo "</div>";
                    echo "</td>\n";
                    // début
                    echo "<td>";
                    echo "<div align=\"center\">";
                    echo datetolocal($row["cocl_dated"]);
                    echo "</div>";
                    echo "</td>\n";
                    // Fin
                    echo "<td>";
                    echo "<div align=\"center\">";
                    if (datetolocal($row["cocl_datef"]) == "")
                        echo "&nbsp;";
                    else
                        echo datetolocal($row["cocl_datef"]);
                    echo "</div>";
                    echo "</td>\n";
                    // Temps
                    echo "<td>";
                    echo "<div align=\"center\">";
                    echo "<span class=\"annot_petit_it\">";
                    if ($row["cocl_typh"] == 1) {
                        echo _("Solde initial") . " : " . heure_to_hhmm(sec_heure($row["cocl_nbs"], 3, TRUE));
                        if (datetolocal($row["cocl_datesig"]) <> "") {
                            $soldes = solde_contrat_sec($row["cocl_code"], FALSE);
                            $soldeass = $soldes_reel - $soldes;
                            echo "<br />" . _("Solde actuel") . " : " . heure_to_hhmm(sec_heure($soldes, 3, TRUE));
                            echo "<br />" . _("A sortir") . " : " . heure_to_hhmm(sec_heure($soldeass, 3, TRUE));
                            echo "<br />" . _("Solde réel") . " : ";
                            echo heure_to_hhmm(sec_heure($soldes_reel, 3, TRUE));
                        }
                    } else
                        echo "-";
                    echo "</span>";
                    echo "</div>";
                    echo "</td>\n";
                    // relancé le
                    echo "<td>";
                    echo "<div align=\"center\">";
                    if (datetolocal($row["cocl_daterel"]) == "")
                        echo "-";
                    else
                        echo datetolocal($row["cocl_daterel"]);
                    echo "</div>";
                    echo "</td>\n";

                    // Renouvellement
                    echo "<td>";

                    // Affichage détail renouvelé
                    echo "<div align=\"center\">";
                    echo $non_oui[$row["cocl_renouv"]];

                    if ($row["cocl_renouv"] == 1) {
                        // Affichage détail renouvellement

                        $detailren = "(" . $row["cocl_rnum"] . ")";
                        echo "<br>";
                        echo "<span class=\"annot_petit_it\">";
                        echo $detailren;
                        echo "</span>";

                        // Fin affichage détail renouvellement
                    }

                    echo "</div>";
                    // Fin affichage détail renouvelé

                    echo "</td>\n";

                    // CREATION lien dynamique sur icône (édition, suppression, etc...)
                    echo "<td align=\"center\">";

                    if ((datetolocal($row["cocl_datefin"]) == "") AND ($echeance_ok == TRUE)) {
                        if (url_ok('cocl_maj.php?td=edit', FALSE) == TRUE) {
                            $lst_maj = TRUE;
                            cre_falselnk_img('', 'cocl_edit_'.$row["cocl_id"], 'span', 'center', _("Edition"), 'lnk', 'cocl_maj.php?td=edit&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"] , '../img/edit.png');
                        }
                    } else {
                        if (url_ok('cocl_maj.php?td=view', FALSE) == TRUE) {
                            $lst_voir = TRUE;
                            cre_falselnk_img('', 'cocl_view_'.$row["cocl_id"], 'span', 'center', _("Visualisation"), 'lnk', 'cocl_maj.php?td=view&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"] , '../img/eye.png');
                        }
                    }
                    if ((datetolocal($row["cocl_datesig"]) <> "") AND (datetolocal($row["cocl_datefin"]) == "") AND (tps_trav_non_clot_sec($row["cocl_code"], FALSE) == 0) AND (url_ok('coclclos_maj.php', FALSE) == TRUE)) {
                        $lst_clore = TRUE;
                        cre_falselnk_img('', 'cocl_clore_'.$row["cocl_id"], 'span', 'center', _("Clore"), 'lnk', 'coclclos_maj.php?co=' . $row["cocl_code"] , '../img/clore.png');
                    }

                    if ((datetolocal($row["cocl_datefin"]) == "") AND (datetolocal($row["cocl_datesig"]) <> "") AND ($echeance_ok == TRUE) AND (url_ok('int_maj.php?td=add', FALSE) == TRUE)) {
                        $lst_int = TRUE;
                        $url_int = "int_maj.php?td=add&ci=&cc=" . $row["cocl_codecli"] . "&ca=" . $row["cocl_codeage"] . "&co=" . $row["cocl_code"];
                        cre_falselnk_img('', 'int_add_'.$row["cocl_id"], 'span', 'center', _("Saisir intervention sur le contrat") . $row["cocl_code"], 'lnk', $url_int , '../img/int.png');
                    }

                    $urlhisto = "cocls_pdf.php?co=" . $row["cocl_code"];
                    if (url_ok($urlhisto, FALSE) == TRUE) {
                        $lst_histo = TRUE;
                        cre_falselnk_img('', 'cocl_syn_'.$row["cocl_id"], 'span', 'center', _("Synthèse du contrat"), 'lnkpop', $urlhisto , '../img/histo.png');
                    }

                    $urlimp = "cocl_pdf.php?code=" . $row["cocl_code"];
                    if (url_ok($urlimp, FALSE) == TRUE) {
                        $lst_imp = TRUE;
                        cre_falselnk_img('', 'cocl_prn_'.$row["cocl_id"], 'span', 'center', _("Imprimer"), 'lnkpop', $urlimp , '../img/print.png');
                    }

                    echo "</tr>\n";
                    // Fin affichage résumé Contrat Client

                    $i++;
                }
            }
            echo "</table>\n";
            // *** Fin affichage de la table
        } else {
            echo "<div class=\"annot_gras_it\">";
            echo "<br />" . _("Pas de contrat bientôt à échéance");
            echo "</div>";
        }

        /** @noinspection PhpUndefinedMethodInspection */
        $db->disconnect();

        $taille_piedla = "";
        include("../inc/piedla.inc.php");
    }
    ?>
    </div>

    <div id="idx_dosc" style="display:none">
    <?PHP
    // RAZ variables pour les pieds de liste
    include("../inc/init_varpl.inc.php");

    if (url_ok('dos_lst.php', TRUE) == TRUE) {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

        $rech = cree_strrechlstdos();
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE " . TBDOS . ".dos_codeage='" . @$_SESSION["code_age"] . "'";
        else
            $rech .= " AND " . TBDOS . ".dos_codeage='" . @$_SESSION["code_age"] . "'";
        $rech .= " AND " . TBDOS . ".dos_datefin ='0000-00-00'";
        $rech .= " ORDER BY " . TBDOS . ".dos_datefinp ASC";
        // *** Fin de chaîne de Recherche

        $numrows = 0;
        /** @noinspection PhpUndefinedMethodInspection */
        $rows = $db->get_results($rech, ARRAY_A);
        if ($rows)
            $numrows = count($rows); // Nombre de résultats à la requête

        if ($numrows > 0) {
            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\">\n";

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

            $i = 0;

            // Inclusion module affichage liste dossiers
            include_once("../inc/dosr_lst.inc.php");

            echo "</table>\n";
            // *** Fin affichage de la table
        } else {
            echo "<div class=\"annot_gras_it\">";
            echo "<br />" . _("Pas de dossier de suivi en cours");
            echo "</div>";
        }

        /** @noinspection PhpUndefinedMethodInspection */
        $db->disconnect();

        $taille_piedla = "";
        include("../inc/piedla.inc.php");
    } else
        echo _("Sans objet");
    ?>
    </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");
}
?>