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


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

include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_cocl.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_int.inc.php");
include_once("../inc/fic_tac.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_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"] = "cocl";

// Variables Formulaire
fix_magic_quotes();
$_GET = clean_str($_GET);

$fi = "";
if (isset($_GET['fi']) && (trim($_GET['fi']) <> "")) {
    $fi = intval($_GET['fi']);
    switch (@$_SESSION["niv_log"]) {
        case 1 :
            if ($fi > 3) $fi = "";
            break;
        default :
            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 _("Liste Contrats Clients"); ?></title>

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

        <script type="text/javascript">
            <!--
            function init_all() {
                init_Body();
                init_autohref_classe('falselnkimg','');
                Focus_first();
            }

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

    </head>

    <body>

<?php
include_once("../inc/entete.inc.php");
switch (@$_SESSION["niv_log"]) {
    case 1 :
        $tab_cli = give_tab_rcli($_SESSION["code_log"], TRUE);
        echo '<p align="center"><span class="titrepage">' . _("VOS CONTRATS") . '</span></p>';
        break;
    default :
        echo '<p align="center"><span class="titrepage">' . _("CONTRATS") . '</span></p>';
        if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
            echo '<p align="center" class="annot_std_it">(' . _("Gérés par votre agence") . ')</p>';
        break;
}

if ((@$_SESSION["niv_log"] == 9) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 4))
    $url_add = "cli_lst.php?td=con";
$url_rss = lien_rss(@$_SESSION["code_log"], @$_SESSION["niv_log"], "cocl");


switch (@$_SESSION["niv_log"]) {
    case 1 :
        $fic_imp = "cocl_lsti.php";
        $tab_fi = $tab_fi_cocl_std;
        break;
    case 3 :
    case 4 :
    case 5 :
    case 9 :
        $fic_imp = "cocl_lsti.php";
        $tab_fi = $tab_fi_cocl_full;
        break;
}

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

switch (@$_SESSION["niv_log"]) {
    case 1 :
        if (count($tab_cli) == 1) {
            $rech = cree_strrechlstcoclc();
            if (!stristr($rech, "WHERE "))
                $rech .= " WHERE cocl_codecli='" . @$_SESSION["code_log"] . "'";
            else
                $rech .= " AND cocl_codecli='" . @$_SESSION["code_log"] . "'";
        } else {
            $rech = cree_strrechlstcocl();

            // On rajoute les comptes complémentaires (cas des regroupements de clients)
            if (!stristr($rech, "WHERE "))
                $rech .= " WHERE ";
            else
                $rech .= " AND ";
            if (count($tab_cli) > 1)
                $rech .= "(";
            foreach ($tab_cli as $key => $value) {
                $rech .= " " . TBCOCL . ".cocl_codecli='" . $value . "' OR";
            }
            // Suppression du dernier 'OR'
            $rech = substr($rech, 0, strlen($rech) - 3);

            if (count($tab_cli) > 1)
                $rech .= ")";
        }
        break;
    default :
        $rech = cree_strrechlstcocl();
        if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) {
            if (!stristr($rech, "WHERE "))
                $rech .= " WHERE " . TBCOCL . ".cocl_codeage='" . @$_SESSION["code_age"] . "'";
            else
                $rech .= " AND " . TBCOCL . ".cocl_codeage='" . @$_SESSION["code_age"] . "'";
        }
        break;
}

switch ($fi) {
    case "1" :
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE cocl_datesig<>'0000-00-00' AND cocl_dated<='" . $datea . "' AND (cocl_datef>='" . $datea . "' OR cocl_datef='0000-00-00') AND cocl_datefin='0000-00-00'";
        else
            $rech .= " AND cocl_datesig<>'0000-00-00' AND cocl_dated<='" . $datea . "' AND (cocl_datef>='" . $datea . "' OR cocl_datef='0000-00-00') AND cocl_datefin='0000-00-00'";
        break;
    case "2" :
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE cocl_dateenv<>'0000-00-00' AND cocl_daterec='0000-00-00'";
        else
            $rech .= " AND cocl_dateenv<>'0000-00-00' AND cocl_daterec='0000-00-00'";
        break;
    case "3" :
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE cocl_renouv=0";
        else
            $rech .= " AND cocl_renouv=0";
        break;
    case "4" :
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE cocl_datef<>'0000-00-00' AND cocl_datef<'" . $datea . "'";
        else
            $rech .= " AND cocl_datef<>'0000-00-00' AND cocl_datef<'" . $datea . "'";
        break;
    case "5" :
        $dateech = nouv_date_plus_jours($datea, 15);
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE cocl_datef<>'0000-00-00' AND cocl_datef>='" . $datea . "' AND cocl_datef<='" . $dateech . "'";
        else
            $rech .= " AND cocl_datef<>'0000-00-00' AND cocl_datef>='" . $datea . "' AND cocl_datef<='" . $dateech . "'";
        break;
    case "6" :
        $dateech = nouv_date_plus_jours($datea, 30);
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE cocl_datef<>'0000-00-00' AND cocl_datef>='" . $datea . "' AND cocl_datef<='" . $dateech . "'";
        else
            $rech .= " AND cocl_datef<>'0000-00-00' AND cocl_datef>='" . $datea . "' AND cocl_datef<='" . $dateech . "'";
        break;
    case "7" :
        $dateech = nouv_date_plus_jours($datea, 60);
        if (!stristr($rech, "WHERE "))
            $rech .= " WHERE cocl_datef<>'0000-00-00' AND cocl_datef>='" . $datea . "' AND cocl_datef<='" . $dateech . "'";
        else
            $rech .= " AND cocl_datef<>'0000-00-00' AND cocl_datef>='" . $datea . "' AND cocl_datef<='" . $dateech . "'";
        break;
    default :
        break;
}

switch (@$_SESSION["niv_log"]) {
    case 1 :
        if (count($tab_cli) == 1)
            $rech .= crestr_triord($coclc_titre_col, "cocl_code", FALSE, $limit);
        else
            $rech .= crestr_triord($cocl_titre_col, "cocl_code", FALSE, $limit);
        break;
    default :
        $rech .= crestr_triord($cocl_titre_col, "cocl_code", FALSE, $limit);
        break;
}

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

if (($rows) AND (count($rows) > 0)) {
    include_once("formr.inc.php");

    $numrows = count($rows);

    switch (@$_SESSION["niv_log"]) {
        case 1 :
            if (count($tab_cli) == 1)
                $rech = modstr_triord($rech, $coclc_titre_col, "cocl_code", TRUE, $limit);
            else
                $rech = modstr_triord($rech, $cocl_titre_col, "cocl_code", TRUE, $limit);
            break;
        default :
            $rech = modstr_triord($rech, $cocl_titre_col, "cocl_code", TRUE, $limit);
            break;
    }

    $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
    switch (@$_SESSION["niv_log"]) {
        case 1 :
            if (count($tab_cli) == 1)
                titlst($coclc_titre_col);
            else
                titlst($cocl_titre_col);
            break;
        default :
            titlst($cocl_titre_col);
            break;
    }
    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);

        // Test si toujours valide
        $echeance_ok = TRUE;

        // Il y a une date de fin au contrat
        // On contrôle si elle est dépassée
        if (datetolocal($row["cocl_datef"]) <> "") {
            if (echeance_depassee_date($datea, $row["cocl_datef"]) == TRUE)
                $echeance_ok = FALSE;
        } else {
            // Il n'y a pas de date de fin de contrat
            // On vérifie s'il y a une date de clôture
            if (datetolocal($row["cocl_datefin"]) <> "")
                $echeance_ok = FALSE;
        }

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

        // CREATION d'icône si signé
        if (datetolocal($row["cocl_datesig"]) <> "") {
            $lst_sig = TRUE;
            echo ' <a href="#" class="popa"><img src="../img/ok.png" alt="' . _("Signé le") . ' ' . datetolocal($row["cocl_datesig"]) . '" border="0" align="absmiddle"><span>' . _("Signé le") . ' ' . datetolocal($row["cocl_datesig"]) . '</span></a>';
        }

        // CREATION d'icône si terminé
        if ($echeance_ok == FALSE) {
            $lst_fini = TRUE;
            if (datetolocal($row["cocl_datefin"]) <> "")
                echo ' <a href="#" class="popw"><img src="../img/warn.png" alt="' . _("Terminé le") . ' ' . datetolocal($row["cocl_datefin"]) . '" border="0" align="absmiddle"><span>' . _("Terminé le") . ' ' . datetolocal($row["cocl_datefin"]) . '</span></a>';
            else
                echo ' <a href="#" class="popw"><img src="../img/warn.png" alt="' . _("Terminé le") . ' ' . datetolocal($row["cocl_datef"]) . '" border="0" align="absmiddle"><span>' . _("Terminé le") . ' ' . datetolocal($row["cocl_datef"]) . '</span></a>';
        }

        // icône si tâches non terminées
        if (@$_SESSION["niv_log"] <> 1) {
            $nb_tac_actives = nb_tac_actives(2, $row["cocl_code"], FALSE);
            if ($nb_tac_actives > 0) {
                $url_taclst = "tac_lst.php?ord=DES&tri=Code&fi=4&search=" . $row["cocl_code"];
                if ($nb_tac_actives > 1) {
                    $txt_tac = $nb_tac_actives . " ";
                    _("tâches");
                    $txt_tac .= " " . _("non terminées");
                } else {
                    $txt_tac = $nb_tac_actives . " ";
                    _("tâche");
                    $txt_tac .= " " . _("non terminée");
                }
                $txt_tac .= " (" . _("cliquez pour la liste des tâches rattachées à ce contrat") . ")";
                if (url_ok($url_taclst, FALSE) == TRUE)
                    echo ' <a href="' . $url_taclst . '"><img src="../img/tacwarn.png" title="' . $txt_tac . '" border="0" align="absmiddle"></a>';
                else
                    echo ' <img src="../img/tacwarn.png" title="' . $txt_tac . '" border="0" align="absmiddle">';
            }
        }
        // détail contrat
        echo "<br />";
        echo "<span class=\"annot_petit_it\">";
        $txt = formatetxt($row["co_nom"]);
        echo "->" . _("Type") . " : " . $txt;
        echo "</span>";

        // Géré par
        if ((@$_SESSION["niv_log"] <> 3) AND (@$_SESSION["niv_log"] <> 4)) {
            echo "<br />";
            echo "<span class=\"annot_petit_it\">";
            $txt = formatetxt($row["cocl_codeage"]);
            echo "->" . _("Agence") . " : " . $txt;
            echo "</span>";
        }
        echo "</td>\n";

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

        switch (@$_SESSION["niv_log"]) {
            case 1 :
                if (count($tab_cli) > 1) {
                    echo "<td align=\"center\">\n";
                    echo $row["cocl_codecli"];
                    if (url_ok('cli_maj.php?td=edit&cc=' . $row["cocl_codecli"] . '&dep=' . $row["cli_dep"], FALSE) == TRUE)
                        cre_falselnk_img('', 'cli_edit_'.$row["cocl_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"] . "<br />";
                    $detailcli .= $row["cli_civilite"] . " " . $row["cli_nom"] . " " . $row["cli_prenom"];
                    echo "<div class=\"annot_petit_itgras\" style=\"margin-left:5px;\">";
                    echo $detailcli;
                    echo "</div>";
                    // Fin affichage détail client

                    echo "</td>\n";
                }
                break;
            default :
                echo "<td align=\"center\">\n";
                echo $row["cocl_codecli"];
                if (url_ok('cli_maj.php?td=edit&cc=' . $row["cocl_codecli"] . '&dep=' . $row["cli_dep"], FALSE) == TRUE)
                    cre_falselnk_img('', 'cli_edit_'.$row["cocl_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"] . "<br />";
                $detailcli .= $row["cli_civilite"] . " " . $row["cli_nom"] . " " . $row["cli_prenom"];
                echo "<div class=\"annot_petit_itgras\" style=\"margin-left:5px;\">";
                echo $detailcli;
                echo "</div>";
                // Fin affichage détail client

                echo "</td>\n";
                break;
        }

        // 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));
            $solde = solde_contrat_sec($row["cocl_code"], FALSE);
            $soldeas = tps_trav_non_clot_sec($row["cocl_code"], FALSE);
            echo "<br />" . _("Solde actuel") . " : ";
            echo heure_to_hhmm(sec_heure($solde, 3, TRUE));
            echo "<br />" . _("A sortir") . " : ";
            echo heure_to_hhmm(sec_heure($soldeas, 3, TRUE));
            $solde_reel = $solde - $soldeas;
            echo "<br />" . _("Solde réel") . " : ";
            echo heure_to_hhmm(sec_heure($solde_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 "&nbsp;";
        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 (@$_SESSION["niv_log"] >= 4) // Edition, cloture, et annexes uniquement si >=agence
        {
            if (($echeance_ok == TRUE) AND (datetolocal($row["cocl_datesig"]) == "")) {
                if (url_ok('cocl_maj.php?td=edit&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"], 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');
                }
                if (url_ok('coclclos_maj.php?co=' . $row["cocl_code"], FALSE) == TRUE) {
                    echo " ";
                    $lst_clore = TRUE;
                    cre_falselnk_img('', 'cocl_clos_'.$row["cocl_id"], 'span', 'center', _("Clore"), 'lnk', 'coclclos_maj.php?co=' . $row["cocl_code"] , '../img/clore.png');
                }
            } else {
                if (url_ok('cocl_maj.php?td=view&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"], 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 (($echeance_ok == TRUE) AND (datetolocal($row["cocl_datesig"]) <> "")) {
                // if ((datetolocal($row["cocl_datesig"]) <> "") AND (datetolocal($row["cocl_datefin"]) == "")) {
                if (url_ok('cocla_maj.php?td=add&co=' . $row["cocl_code"] . '&coa=', FALSE) == TRUE) {
                    echo " ";
                    $lst_add_annexe = TRUE;
                    cre_falselnk_img('', 'cocla_add_' . $row["cocl_id"], 'span', 'center', _("Ajouter annexe"), 'lnk', 'cocla_maj.php?td=add&co=' . $row["cocl_code"] . '&coa=', '../img/annexe_add.png');
                }
            }

            if ($echeance_ok == FALSE ) {
                if (nb_cocla_cocl($row["cocl_code"], FALSE) > 0) {
                    if (url_ok('cocla_lst.php?co=' . $row["cocl_code"], FALSE) == TRUE) {
                        echo " ";
                        $lst_view_annexe = TRUE;
                        cre_falselnk_img('', 'cocla_lst_'.$row["cocl_id"], 'span', 'center', _("Voir annexes"), 'lnk', 'cocla_lst.php?co=' . $row["cocl_code"] , '../img/annexe_lst.png');
                    }
                }
            }
        }

        if (@$_SESSION["niv_log"] <= 3) // Voir si <=Technicien
        {
            if (url_ok('cocl_maj.php?td=view&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"].'&ca='.$_SESSION["code_age"], FALSE) == TRUE) {
                $lst_voir = TRUE;
                cre_falselnk_img('', 'cocla_view_'.$row["cocl_id"], 'span', 'center', _("Visualisation"), 'lnk', 'cocl_maj.php?td=view&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"].'&ca='.$_SESSION["code_age"] , '../img/eye.png');
            }
        }

        if (@$_SESSION["niv_log"] >= 3) // création intervention uniquement si >=technicien et pas fini
        {
            if ((datetolocal($row["cocl_datefin"]) == "") AND (datetolocal($row["cocl_datesig"]) <> "") AND ($echeance_ok == TRUE)) {
                $url_int = "int_maj.php?td=add&ci=&cc=" . $row["cocl_codecli"] . "&ca=" . $row["cocl_codeage"] . "&co=" . $row["cocl_code"];
                if (url_ok($url_int, FALSE) == TRUE) {
                    $lst_int = TRUE;
                    cre_falselnk_img('', 'cocl_intadd_'.$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") . $row["cocl_code"], 'lnkpop', $urlhisto, '../img/histo.png');
        }

        if (@$_SESSION["niv_log"] <> 1) {
            $renouv = TRUE;

            // Si le contrat n'a pas encore été renouvelé, on peut renouveler
            if (intval($row["cocl_renouv"]) == 1)
                $renouv = FALSE;

            if ($renouv == TRUE) {
                if (url_ok('coclren_maj.php?co=' . $row["cocl_code"], FALSE) == TRUE) {
                    $lst_ren = TRUE;
                    cre_falselnk_img('', 'cocl_ren_'.$row["cocl_id"], 'span', 'center', _("Renouveler") , 'lnk', 'coclren_maj.php?co=' . $row["cocl_code"], '../img/renouv.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');
        }

        $urlmail = "cocl_pdf.php?code=" . $row["cocl_code"] . "&timp=1&tact=cop";
        if (url_ok($urlmail, FALSE) == TRUE) {
            $lst_mail = TRUE;
            $title = '';
            if (@$_SESSION["niv_log"] <> 1)
                $title = _("Renvoyer une copie par email au client");
            else
                $title = _("Obtenir une copie par email");
            cre_falselnk_img('', 'cocl_mail_'.$row["cocl_id"], 'span', 'center', $title , 'lnkpop', $urlmail, '../img/mail.png',1,1);
        }

        if (@$_SESSION["niv_log"] >= 4) // Suppression uniquement si >=agence et si pas signé
        {
            if ((datetolocal($row["cocl_datefin"]) == "") AND ($echeance_ok == TRUE) AND (datetolocal($row["cocl_datesig"]) == "")) {
                if (url_ok('cocl_maj.php?td=del&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"] . '&ca=' . $row["cocl_codeage"], FALSE) == TRUE) {
                    $lst_del = TRUE;
                    cre_falselnk_img('', 'cocl_del_'.$row["cocl_id"], 'span', 'center', _("Suppression") . $row["cocl_code"], 'lnk', 'cocl_maj.php?td=del&co=' . $row["cocl_code"] . '&cc=' . $row["cocl_codecli"] . '&ca=' . $row["cocl_codeage"], '../img/del.png');
                }
            }
        }

        echo "</td>\n";

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

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

    $db->disconnect();

    echo "<table width=\"100%\" border=\"0\">";
    echo "<tr>";
    echo "<td width=\"50%\">";
    if (($numrows > 0) AND (@$_SESSION["niv_log"] >= 4)) {
        if (url_ok('coclrel_maj.php', TRUE) == TRUE) {
            echo "<a href=\"coclrel_maj.php\">" . _("Relancer les contrats non reçus") . "</a>";
            echo " / ";
            echo "<a href=\"coclrec_maj.php\">" . _("Accuser réception des contrats reçus") . "</a>";
        }
    } else
        echo "&nbsp;";
    echo "</td>";
    echo "<td align=\"right\">";
    echo "&nbsp;";
    echo "</td>";
    echo "</tr>";
    echo "</table>\n";

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

    $taille_piedla = "";
    include_once("piedla.inc.php");
} else
    retpp();

include_once("pied.php");
?>