<?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 : htdp://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/config.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_do.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/fic_st.inc.php");
include_once("../inc/fic_tec.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"]);
// Variables Formulaire
fix_magic_quotes();
$_POST = clean_str($_POST);
$_GET = clean_str($_GET);

$pbm_stat = FALSE;
$aff_stat = FALSE;
$aff_stat = FALSE;
$ts = 0;
$date1 = '';
$date2 = '';
$cle_rech = '';
$tab_ts = [];
$typ_stat = '';
$titre = '';

// On a choisi le type de technicien
$td = '';
if ((isset($_GET['td'])) OR (isset($_POST['td']))) {
    if (isset($_GET['td']))
        $td = $_GET['td'];
    else
        $td = $_POST['td'];
}
else
    $pbm_stat = TRUE;

if ($pbm_stat == FALSE)
{
    $ageseldefault = '*';
    $doseldefault = '*';
    $stseldefault = '*';

    switch ($td)
    {
        case "teca" :
            $titre = _("STATISTIQUES TECHNICIENS");
            if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
            {
                $tab_ts = $tab_txt_stat_tec;
                $typ_stat = 'age';
                $cle_rech = 'tec_codeage';
                if (@$_SESSION["niv_log"] == 4)
                    $ageseldefault = @$_SESSION["code_log"];
            }
            else
                $pbm_stat = TRUE;
            break;
        case "tecd" :
            $titre = _("STATISTIQUES TECHNICIENS DONNEURS D'ORDRES");
            if ((@$_SESSION["niv_log"] == 6) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
            {
                $tab_ts = $tab_txt_stat_tec;
                $typ_stat = 'do';
                $cle_rech = 'tec_codedo';
                if (@$_SESSION["niv_log"] == 6)
                    $doseldefault = @$_SESSION["code_log"];
            }
            else
                $pbm_stat = TRUE;
            break;
        case "tecs" :
            $titre = _("STATISTIQUES TECHNICIENS SOUS-TRAITANTS");
            if ((@$_SESSION["niv_log"] == 10) OR (@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
            {
                $tab_ts = $tab_txt_stat_tecs;
                $typ_stat = 'st';
                $cle_rech = 'tec_codest';
                if (@$_SESSION["niv_log"] == 10)
                    $stseldefault = @$_SESSION["code_log"];
            }
            else
                $pbm_stat = TRUE;
            break;
        default :
            $pbm_stat = TRUE;
            break;
    }

    if ($pbm_stat == FALSE)
    {
        // On a validé
        if (@$_POST["nbutton"] == "calc") {
            $aff_stat = TRUE;

            $ts = intval($_POST['ts']);

            $tec_select_tab = [];
            for ($i = 0; $i < count($_POST["tec"]); $i++) {
                $tec_select_tab[] = $_POST["tec"][$i];
            }

            $date1 = datetomysql($_POST["date1f"]);
            $date2 = datetomysql($_POST["date2f"]);

            $age_select_tab = [];
            $do_select_tab = [];
            $st_select_tab = [];
            switch ($td)
            {
                case "teca" :
                    for ($i = 0; $i < count($_POST["age"]); $i++) {
                        $age_select_tab[] = $_POST["age"][$i];
                    }
                    break;
                case "tecd" :
                    for ($i = 0; $i < count($_POST["do"]); $i++) {
                        $do_select_tab[] = $_POST["do"][$i];
                    }
                    break;
                case "tecs" :
                    for ($i = 0; $i < count($_POST["st"]); $i++) {
                        $st_select_tab[] = $_POST["st"][$i];
                    }
                    break;
            }

            switch ($ts) {
                /* Nombre de créations de clients sur une période donnée */
                case 1 :
                    // Analyse des données et traitements statistiques
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

                    /* Initialisation des totaux généraux */

                    $nb_cli_crees_total = 0;
                    $nb_cli_prospects_crees_total = 0;
                    $nb_cli_ddeint_crees_total = 0;
                    $nb_cli_inter_crees_total = 0;

                    /* Calcul des totaux généraux */

                    $rech = "SELECT tec_code FROM `" . TBTEC . "`";
                    $rech .= " WHERE ".$cle_rech." <> ''";
                    $rech .= " ORDER BY tec_code";
                    $rows = $db->get_results($rech, ARRAY_A);

                    if ($rows) {
                        foreach ($rows as $row) {
                            $row = encode_str($row);
                            extract($row);

                            // Détermination du nombre de clients créés par les techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBCLI . "`";
                            $rech2 .= " WHERE cli_codecrea='" . $tec_code . "'";
                            $rech2 .= " AND cli_datecrea>='" . $date1 . "' AND cli_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_cli_crees_total += $nbres2;

                            // Détermination du nombre de clients encore prospects et créés par les techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBCLI . "`";
                            $rech2 .= " WHERE cli_codecrea='" . $tec_code . "'";
                            $rech2 .= " AND cli_type=0";
                            $rech2 .= " AND cli_datecrea>='" . $date1 . "' AND cli_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_cli_prospects_crees_total += $nbres2;

                            // Détermination du nombre de client ayant demandé une intervention (non effectuée) et créés par les techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBCLI . "`";
                            $rech2 .= " WHERE cli_codecrea='" . $tec_code . "'";
                            $rech2 .= " AND cli_type=1";
                            $rech2 .= " AND cli_datecrea>='" . $date1 . "' AND cli_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_cli_ddeint_crees_total += $nbres2;

                            // Détermination du nombre total de clients ayant demandé une intervention (effectuée) et créés par les techniciens sur la période
                            $nb_cli_inter_crees_total = $nb_cli_crees_total - $nb_cli_prospects_crees_total - $nb_cli_ddeint_crees_total;
                        }
                    }

                    /* Traitement par technicien */
                    $rech2 = "SELECT tec_code FROM `" . TBTEC . "`";

                    // Traitement de multiples
                    if (!in_array("*", $tec_select_tab)) {
                        $rech2 .= " WHERE (";
                        for ($i = 0; $i < count($tec_select_tab); $i++) {
                            $rech2 .= " tec_code='" . $tec_select_tab[$i] . "' OR";
                        }
                        // Suppression du dernier 'OR'
                        $rech2 = substr($rech2, 0, strlen($rech) - 3);
                        $rech2 .= ")";
                    }

                    if (count($age_select_tab)> 0)
                    {
                        if (!in_array("*", $age_select_tab)) {
                            $rech2 .= " WHERE (";
                            for ($i = 0; $i < count($age_select_tab); $i++) {
                                $rech2 .= " ".$cle_rech."='" . $age_select_tab[$i] . "' OR";
                            }
                            // Suppression du dernier 'OR'
                            $rech2 = substr($rech2, 0, strlen($rech2) - 3);
                            $rech2 .= ")";
                        }
                    }

                    if (count($do_select_tab)> 0)
                    {
                        if (!in_array("*", $do_select_tab)) {
                            $rech2 .= " WHERE (";
                            for ($i = 0; $i < count($do_select_tab); $i++) {
                                $rech2 .= " ".$cle_rech."='" . $do_select_tab[$i] . "' OR";
                            }
                            // Suppression du dernier 'OR'
                            $rech2 = substr($rech2, 0, strlen($rech2) - 3);
                            $rech2 .= ")";
                        }
                    }

                    if (count($st_select_tab)> 0)
                    {
                        if (!in_array("*", $st_select_tab)) {
                            $rech2 .= " WHERE (";
                            for ($i = 0; $i < count($st_select_tab); $i++) {
                                $rech2 .= " ".$cle_rech."='" . $st_select_tab[$i] . "' OR";
                            }
                            // Suppression du dernier 'OR'
                            $rech2 = substr($rech2, 0, strlen($rech2) - 3);
                            $rech2 .= ")";
                        }
                    }
                    $rech2 .= " ORDER BY tec_nom";

                    $nbres2 = $db->get_results($rech2, ARRAY_A);

                    $i = 0;

                    if ($rows) {
                        foreach ($rows as $row) {
                            $row = encode_str($row);
                            extract($row);

                            // Récupération du code technicien
                            $code_tec[$i] = $tec_code;

                            // Détermination du nombre de clients créés par le technicien sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBCLI . "`";
                            $rech2 .= " WHERE cli_codecrea='" . $tec_code . "'";
                            $rech2 .= " AND cli_datecrea>='" . $date1 . "' AND cli_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_cli_crees_tec[$i] = $nbres2;

                            // Détermination du nombre de clients encore prospects et créés par le technicien sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBCLI . "`";
                            $rech2 .= " WHERE cli_codecrea='" . $tec_code . "'";
                            $rech2 .= " AND cli_type=0";
                            $rech2 .= " AND cli_datecrea>='" . $date1 . "' AND cli_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_cli_prospects_crees_tec[$i] = $nbres2;

                            // Détermination du nombre de client ayant demandé une intervention (non effectuée) et créés par le techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBCLI . "`";
                            $rech2 .= " WHERE cli_codecrea='" . $tec_code . "'";
                            $rech2 .= " AND cli_type=1";
                            $rech2 .= " AND cli_datecrea>='" . $date1 . "' AND cli_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_cli_ddeint_crees_tec[$i] = $nbres2;

                            // Détermination du nombre total de clients ayant demandé une intervention (effectuée) et créés par le techniciens sur la période
                            $nb_cli_inter_crees_tec[$i] = $nb_cli_crees_tec[$i] - $nb_cli_prospects_crees_tec[$i] - $nb_cli_ddeint_crees_tec[$i];

                            $i++;
                        }
                    }
                    $db->disconnect();
                    break;

                /* Nombre de créations d'interventions sur une période donnée */
                case 2 :
                    // Analyse des données et traitements statistiques
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

                    switch ($td)
                    {
                        case "teca" :
                        case "tecd" :
                            /* Initialisation des totaux généraux */
                            $nb_int_crees_total = 0;
                            $nb_int_ouv_crees_total = 0;
                            $nb_int_prev_crees_total = 0;
                            $nb_int_clos_crees_total = 0;

                            /* Calcul des totaux généraux */
                            $rech = "SELECT tec_code FROM `" . TBTEC . "`";
                            $rech .= " WHERE ".$cle_rech." <> ''";
                            $rech .= " ORDER BY tec_code";

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

                            if ($rows) {
                                foreach ($rows as $row) {
                                    $row = encode_str($row);
                                    extract($row);

                                    // Détermination du nombre d'interventions créées par les techniciens sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                                    $rech2 .= " WHERE int_codecrea='" . $tec_code . "'";
                                    $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_int_crees_total = $nb_int_crees_total + $nbres2;

                                    // Détermination du nombre d'interventions encore ouvertes et créées par les techniciens sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                                    $rech2 .= " WHERE int_codecrea='" . $tec_code . "'";
                                    $rech2 .= " AND int_dateprev='0000-00-00'";
                                    $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_int_ouv_crees_total = $nb_int_ouv_crees_total + $nbres2;

                                    // Détermination du nombre d'interventions, où le client a été prévenu, et créées par les techniciens sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                                    $rech2 .= " WHERE int_codecrea='" . $tec_code . "'";
                                    $rech2 .= " AND int_dateprev<>'0000-00-00'";
                                    $rech2 .= " AND int_datefin='0000-00-00'";
                                    $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_int_prev_crees_total = $nb_int_prev_crees_total + $nbres2;

                                    // Détermination du nombre total d'interventions closes et créés par les techniciens sur la période
                                    $nb_int_clos_crees_total = $nb_int_crees_total - $nb_int_ouv_crees_total - $nb_int_prev_crees_total;
                                }
                            }

                            /* Traitement par technicien */

                            /* Initialisation des totaux par technicien */
                            $nb_int_crees_tec = [];
                            $nb_int_ouv_crees_tec = [];
                            $nb_int_prev_crees_tec = [];
                            $nb_int_clos_crees_tec = [];

                            $rech = "SELECT * FROM `" . TBTEC . "`";

                            // Traitement de multiples
                            if (!in_array("*", $tec_select_tab)) {
                                $rech .= " WHERE (";
                                for ($i = 0; $i < count($tec_select_tab); $i++) {
                                    $rech .= " tec_code='" . $tec_select_tab[$i] . "' OR";
                                }
                                // Suppression du dernier 'OR'
                                $rech = substr($rech, 0, strlen($rech) - 3);
                                $rech .= ")";
                            }

                            if (count($age_select_tab) >0 )
                            {
                                if (!in_array("*", $age_select_tab)) {
                                    if (!stristr($rech, "WHERE "))
                                        $rech .= " WHERE (";
                                    else
                                        $rech .= " AND (";
                                    for ($i = 0; $i < count($age_select_tab); $i++) {
                                        $rech .= " ".$cle_rech."='" . $age_select_tab[$i] . "' OR";
                                    }
                                    // Suppression du dernier 'OR'
                                    $rech = substr($rech, 0, strlen($rech) - 3);
                                    $rech .= ")";
                                }
                            }

                            if (count($do_select_tab) >0 )
                            {
                                if (!in_array("*", $do_select_tab)) {
                                    if (!stristr($rech, "WHERE "))
                                        $rech .= " WHERE (";
                                    else
                                        $rech .= " AND (";
                                    for ($i = 0; $i < count($do_select_tab); $i++) {
                                        $rech .= " ".$cle_rech."='" . $do_select_tab[$i] . "' OR";
                                    }
                                    // Suppression du dernier 'OR'
                                    $rech = substr($rech, 0, strlen($rech) - 3);
                                    $rech .= ")";
                                }
                            }

                            $rech .= " ORDER BY tec_nom";

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

                            if ($rows) {
                                foreach ($rows as $row) {
                                    $row = encode_str($row);
                                    extract($row);

                                    // Récupération du code technicien
                                    $code_tec[$i] = $tec_code;

                                    // Détermination du nombre d'interventions créées par le technicien  sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                                    $rech2 .= " WHERE int_codecrea='" . $tec_code . "'";
                                    $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_int_crees_tec[$i] = $nbres2;

                                    // Détermination du nombre d'interventions encore ouvertes et créées par le technicien sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                                    $rech2 .= " WHERE int_codecrea='" . $tec_code . "'";
                                    $rech2 .= " AND int_dateprev='0000-00-00'";
                                    $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_int_ouv_crees_tec[$i] = $nbres2;

                                    // Détermination du nombre d'interventions, où le client a été prévenu, et créées par le technicien sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                                    $rech2 .= " WHERE int_codecrea='" . $tec_code . "'";
                                    $rech2 .= " AND int_dateprev<>'0000-00-00'";
                                    $rech2 .= " AND int_datefin='0000-00-00'";
                                    $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_int_prev_crees_tec[$i] = $nbres2;

                                    // Détermination du nombre total d'interventions closes et créées par les techniciens sur la période
                                    $nb_int_clos_crees_tec[$i] = $nb_int_crees_tec[$i] - $nb_int_ouv_crees_tec[$i] - $nb_int_prev_crees_tec[$i];

                                    $i++;
                                }
                            }
                            break;
                        case "tecs" :
                            /* Initialisation des totaux généraux */
                            $nb_ot_crees_total = 0;
                            $nb_ot_ouv_crees_total = 0;
                            $nb_ot_prev_crees_total = 0;
                            $nb_ot_clos_crees_total = 0;

                            /* Calcul des totaux généraux */
                            $rech = "SELECT tec_code FROM `" . TBTEC . "`";
                            $rech .= " WHERE ".$cle_rech." <> ''";
                            $rech .= " ORDER BY tec_code";

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

                            if ($rows) {
                                foreach ($rows as $row) {
                                    $row = encode_str($row);
                                    extract($row);

                                    // Détermination du nombre d'ordres créées par les techniciens sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBOT . "`";
                                    $rech2 .= " WHERE ot_codetec='" . $tec_code . "'";
                                    $rech2 .= " AND ot_datecrea>='" . $date1 . "' AND ot_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_ot_crees_total = $nb_ot_crees_total + $nbres2;

                                    // Détermination du nombre d'ordres encore ouverts et créées par les techniciens sur la période
                                    $rech2 = "SELECT * FROM `" . TBOT . "`";
                                    $rech2 .= " WHERE ot_codetec='" . $tec_code . "'";
                                    $rech2 .= " AND ot_dateprev='0000-00-00'";
                                    $rech2 .= " AND ot_datecrea>='" . $date1 . "' AND ot_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_ot_ouv_crees_total = $nb_ot_ouv_crees_total + $nbres2;

                                    // Détermination du nombre d'ordres, où le client a été prévenu, et créées par les techniciens sur la période
                                    $rech2 = "SELECT * FROM `" . TBOT . "`";
                                    $rech2 .= " WHERE ot_codetec='" . $tec_code . "'";
                                    $rech2 .= " AND ot_dateprev<>'0000-00-00'";
                                    $rech2 .= " AND ot_datefin='0000-00-00'";
                                    $rech2 .= " AND ot_datecrea>='" . $date1 . "' AND ot_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_ot_prev_crees_total = $nb_ot_prev_crees_total + $nbres2;

                                    // Détermination du nombre total d'interventions closes et créés par les techniciens sur la période
                                    $nb_ot_clos_crees_total = $nb_ot_crees_total - $nb_ot_ouv_crees_total - $nb_ot_prev_crees_total;
                                }
                            }

                            /* Traitement par technicien */

                            /* Initialisation des totaux par technicien */
                            $nb_ot_crees_tec = [];
                            $nb_ot_ouv_crees_tec = [];
                            $nb_ot_prev_crees_tec = [];
                            $nb_ot_clos_crees_tec = [];

                            $rech = "SELECT * FROM `" . TBTEC . "`";

                            // Traitement de multiples
                            if (!in_array("*", $tec_select_tab)) {
                                $rech .= " WHERE (";
                                for ($i = 0; $i < count($tec_select_tab); $i++) {
                                    $rech .= " tec_code='" . $tec_select_tab[$i] . "' OR";
                                }
                                // Suppression du dernier 'OR'
                                $rech = substr($rech, 0, strlen($rech) - 3);
                                $rech .= ")";
                            }

                            if (count($age_select_tab) >0 )
                            {
                                if (!in_array("*", $age_select_tab)) {
                                    if (!stristr($rech, "WHERE "))
                                        $rech .= " WHERE (";
                                    else
                                        $rech .= " AND (";
                                    for ($i = 0; $i < count($age_select_tab); $i++) {
                                        $rech .= " ".$cle_rech."='" . $age_select_tab[$i] . "' OR";
                                    }
                                    // Suppression du dernier 'OR'
                                    $rech = substr($rech, 0, strlen($rech) - 3);
                                    $rech .= ")";
                                }
                            }

                            if (count($st_select_tab) >0 )
                            {
                                if (!in_array("*", $st_select_tab)) {
                                    if (!stristr($rech, "WHERE "))
                                        $rech .= " WHERE (";
                                    else
                                        $rech .= " AND (";
                                    for ($i = 0; $i < count($st_select_tab); $i++) {
                                        $rech .= " ".$cle_rech."='" . $st_select_tab[$i] . "' OR";
                                    }
                                    // Suppression du dernier 'OR'
                                    $rech = substr($rech, 0, strlen($rech) - 3);
                                    $rech .= ")";
                                }
                            }
                            $rech .= " ORDER BY tec_nom";

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

                            if ($rows) {
                                foreach ($rows as $row) {
                                    $row = encode_str($row);
                                    extract($row);

                                    // Récupération du code sous-traitant
                                    $code_tec[$i] = $tec_code;

                                    // Détermination du nombre d'ordres créées par le technicien sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBOT . "`";
                                    $rech2 .= " WHERE ot_codetec='" . $tec_code . "'";
                                    $rech2 .= " AND ot_datecrea>='" . $date1 . "' AND ot_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_ot_crees_tec[$i] = $nbres2;

                                    // Détermination du nombre d'ordres encore ouvertes et créées par le technicien sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBOT . "`";
                                    $rech2 .= " WHERE ot_codetec='" . $tec_code . "'";
                                    $rech2 .= " AND ot_dateprev='0000-00-00'";
                                    $rech2 .= " AND ot_datecrea>='" . $date1 . "' AND ot_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_ot_ouv_crees_tec[$i] = $nbres2;

                                    // Détermination du nombre d'ordres, où l'agence a été prévenue, et créées par les techniciens sur la période
                                    $rech2 = "SELECT COUNT(*) FROM `" . TBOT . "`";
                                    $rech2 .= " WHERE ot_codetec='" . $tec_code . "'";
                                    $rech2 .= " AND ot_dateprev<>'0000-00-00'";
                                    $rech2 .= " AND ot_datefin='0000-00-00'";
                                    $rech2 .= " AND ot_datecrea>='" . $date1 . "' AND ot_datecrea<='" . $date2 . "'";

                                    $nbres2 = $db->get_var($rech2);
                                    $nb_ot_prev_crees_tec[$i] = $nbres2;

                                    // Détermination du nombre total d'ordres closes et créées par les techniciens sur la période
                                    $nb_ot_clos_crees_tec[$i] = $nb_ot_crees_tec[$i] - $nb_ot_ouv_crees_tec[$i] - $nb_ot_prev_crees_tec[$i];

                                    $i++;
                                }
                            }
                            break;
                    }
                    $db->disconnect();
                    break;

                /* Nombre de traitements d'interventions sur une période donnée */
                case 3 :
                    // Analyse des données et traitements statistiques
                    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

                    /* Initialisation des totaux généraux */
                    $nb_int_trait_total = 0;
                    $nb_int_ouv_trait_total = 0;
                    $nb_int_prev_trait_total = 0;
                    $nb_int_clos_trait_total = 0;

                    /* Calcul des totaux généraux */
                    $rech = "SELECT tec_code FROM `" . TBTEC . "`";
                    $rech .= " WHERE ".$cle_rech." <> ''";
                    $rech .= " ORDER BY tec_code";

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

                    if ($rows) {
                        foreach ($rows as $row) {
                            $row = encode_str($row);
                            extract($row);

                            // Détermination du nombre d'interventions créées par les techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                            $rech2 .= " WHERE int_codetec='" . $tec_code . "'";
                            $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_int_trait_total = $nb_int_trait_total + $nbres2;

                            // Détermination du nombre d'interventions encore ouvertes et créées par les techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                            $rech2 .= " WHERE int_codetec='" . $tec_code . "'";
                            $rech2 .= " AND int_dateprev='0000-00-00'";
                            $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_int_ouv_trait_total = $nb_int_ouv_trait_total + $nbres2;

                            // Détermination du nombre d'interventions, où le client a été prévenu, et créées par les techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                            $rech2 .= " WHERE int_codetec='" . $tec_code . "'";
                            $rech2 .= " AND int_dateprev<>'0000-00-00'";
                            $rech2 .= " AND int_datefin='0000-00-00'";
                            $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_int_prev_trait_total = $nb_int_prev_trait_total + $nbres2;

                            // Détermination du nombre total d'interventions closes et créés par les techniciens sur la période
                            $nb_int_clos_trait_total = $nb_int_trait_total - $nb_int_ouv_trait_total - $nb_int_prev_trait_total;
                        }
                    }

                    /* Traitement par technicien */

                    /* Initialisation des totaux par technicien */
                    $nb_int_trait_tec = [];
                    $nb_int_ouv_trait_tec = [];
                    $nb_int_prev_trait_tec = [];
                    $nb_int_clos_trait_tec = [];


                    $rech = "SELECT * FROM `" . TBTEC . "`";

                    // Traitement de multiples
                    if (count($age_select_tab) >0 )
                    {
                        if (!in_array("*", $age_select_tab)) {
                            if (!stristr($rech, "WHERE "))
                                $rech .= " WHERE (";
                            else
                                $rech .= " AND (";
                            for ($i = 0; $i < count($age_select_tab); $i++) {
                                $rech .= " ".$cle_rech."='" . $age_select_tab[$i] . "' OR";
                            }
                            // Suppression du dernier 'OR'
                            $rech = substr($rech, 0, strlen($rech) - 3);
                            $rech .= ")";
                        }
                    }

                    if (count($st_select_tab) >0 )
                    {
                        if (!in_array("*", $st_select_tab)) {
                            if (!stristr($rech, "WHERE "))
                                $rech .= " WHERE (";
                            else
                                $rech .= " AND (";
                            for ($i = 0; $i < count($st_select_tab); $i++) {
                                $rech .= " ".$cle_rech."='" . $st_select_tab[$i] . "' OR";
                            }
                            // Suppression du dernier 'OR'
                            $rech = substr($rech, 0, strlen($rech) - 3);
                            $rech .= ")";
                        }
                    }

                    $rech .= " ORDER BY tec_nom";

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

                    $i = 0;

                    if ($rows) {
                        foreach ($rows as $row) {
                            $row = encode_str($row);
                            extract($row);

                            // Récupération du code agence
                            $code_tec[$i] = $tec_code;

                            // Détermination du nombre d'interventions créées par le technicien sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                            $rech2 .= " WHERE int_codetec='" . $tec_code . "'";
                            $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_int_trait_tec[$i] = $nbres2;

                            // Détermination du nombre d'interventions encore ouvertes et créées par le technicien sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                            $rech2 .= " WHERE int_codetec='" . $tec_code . "'";
                            $rech2 .= " AND int_dateprev='0000-00-00'";
                            $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_int_ouv_trait_tec[$i] = $nbres2;

                            // Détermination du nombre d'interventions, où le client a été prévenu, et créées par les techniciens sur la période
                            $rech2 = "SELECT COUNT(*) FROM `" . TBINT . "`";
                            $rech2 .= " WHERE int_codetec='" . $tec_code . "'";
                            $rech2 .= " AND int_dateprev<>'0000-00-00'";
                            $rech2 .= " AND int_datefin='0000-00-00'";
                            $rech2 .= " AND int_datecrea>='" . $date1 . "' AND int_datecrea<='" . $date2 . "'";

                            $nbres2 = $db->get_var($rech2);
                            $nb_int_prev_trait_tec[$i] = $nbres2;

                            // Détermination du nombre total d'interventions closes et créées par les techniciens sur la période
                            $nb_int_clos_trait_tec[$i] = $nb_int_trait_tec[$i] - $nb_int_ouv_trait_tec[$i] - $nb_int_prev_trait_tec[$i];

                            $i++;
                        }
                    }
                    $db->disconnect();
                    break;

                default :
                    $pbm_stat = TRUE;
                    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 _("Statistiques Techniciens"); ?></title>

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

    <script language="javascript">
    <!--
    var tab_champ = [];
    //-->
    </script>

    <script type="text/javascript">
        <!--
        <?PHP
        if ($aff_stat == FALSE)
        {
        ?>
        function init_datepicker() {
            $.datepicker.setDefaults({
                closeText: "<?PHP echo _("Fermer"); ?>",
                prevText: "<?PHP echo _("Précédent"); ?>",
                nextText: "<?PHP echo _("Suivant"); ?>",
                currentText: "<?PHP echo _("Aujourd'hui"); ?>",
                monthNames: ["<?PHP echo implode('","',$lng_tmoisf); ?>"],
                monthNamesShort: ["<?PHP echo implode('","',$lng_tmoism); ?>"],
                dayNames: ["<?PHP echo implode('","',$lng_tjourf); ?>"],
                dayNamesShort: ["<?PHP echo implode('","',$lng_tjourm); ?>"],
                dayNamesMin: ["<?PHP echo implode('","',$lng_tjours); ?>"],
                weekHeader: "<?PHP echo _("Sem."); ?>",
                dateFormat: "<?PHP echo $_SESSION['date_fmtshort']; ?>",
                firstDay: 1,
                isRTL: !1,
                changeMonth: true,
                changeYear: true,
                showMonthAfterYear: !1,
                yearSuffix: "",
                showButtonPanel: true,
                showOn: "both",
                buttonImageOnly: true,
                buttonImage: "../img/calendar.png",
                buttonText: "<?PHP echo _("Calendrier"); ?>"
            });
            $("#date1f").datepicker({
                onSelect: function (datesel) {
                    $("#date1f").blur();
                    chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, '', '', 'date2f',false);
                }
            });
            $("#date2f").datepicker({
                onSelect: function (datesel) {
                    $("#date2f").blur();
                    chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, 'date1f', '', '',false);
                }
            });
        }
        <?PHP } ?>

        function init_all() {
            init_Body();
            <?PHP
            if ($aff_stat == TRUE)
            {
                echo "init_autohref('newstat', 'click', '', true);";
                echo "readonly_all_id('prm_stat');";
            }
            else
            {
                echo "init_datepicker();";
                echo "init_stats_tec('calc','prm_stat','".$_SESSION['date_fmtshort']."',tab_champ,'','');";
                echo "init_autoraz('razdate1f','date1f','click');";
                echo "init_autoraz('razdate2f','date2f','click');";
            }
            ?>
            Focus_first();
        }

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

<body>
<?php include_once("../inc/entete.inc.php"); ?>
<p align="center"><span class="titrepage"><?PHP echo $titre; ?></span>
</p>
<?PHP
if ($pbm_stat == FALSE) {
    $total_tec = 0;
    switch ($td)
    {
        case "teca" :
            if (@$_SESSION["niv_log"] >= 5)
                $total_tec = nb_tec("");
            else {
                if (@$_SESSION["niv_log"] == 4)
                    $total_tec = nb_tec(@$_SESSION["code_log"]);
            }
            break;
        case "tecd" :
            if (@$_SESSION["niv_log"] > 4)
                $total_tec = nb_tec_do("");
            else {
                if (@$_SESSION["niv_log"] == 6)
                    $total_tec = nb_tec_do(@$_SESSION["code_log"]);
            }
            break;
        case "tecs" :
            if (@$_SESSION["niv_log"] > 4)
                $total_tec = nb_tec_st("");
            else {
                if (@$_SESSION["niv_log"] == 10)
                    $total_tec = nb_tec_st(@$_SESSION["code_log"]);
            }
            break;
    }


    if ($total_tec > 0) {
        if ($aff_stat == TRUE)
            cre_falselnk('', 'newstat', 'div', '', _("Autre statistique"), 'tec_stat.php?td='.$td, '../img/stat.png', _("Autre statistique"));
        ?>
        <div align="center" style="margin-top: 5px; margin-bottom: 5px;">
        <form name="prm_stat" id="prm_stat" class="bord_pointilles" method="post" action="tec_stat.php">
        <input name="td" type="hidden" id="td" value="<?PHP echo $td; ?>">
        <input name="today" type="hidden" id="today" value="<?PHP echo $datef; ?>">
        <input name="nbutton" type="hidden" id="nbutton" value="">
            <?PHP
            cre_select('ts', 'ts', $tab_ts, (int)$ts, '', _("-- Faites votre choix --"));
            if ($aff_stat == FALSE)
            {
                ?>
                <table width="100%" border="0">
                    <tr>
                        <td width="50%" align="center">
                            <?PHP echo _("Choisissez un technicien (sélections multiples possibles)"); ?>
                            <div class="annot_petit_it"><?PHP echo "("._("Si 'Tous', les techniciens licenciés seront aussi analysés").")"; ?></div>
                        </td>
                        <td width="50%" align="center">
                            <?PHP
                            switch ($td)
                            {
                                case "teca" :
                                    echo _("Choisissez une agence (sélections multiples possibles)");
                                    break;
                                case "tecd" :
                                    echo _("Choisissez un donneur d'ordres (sélections multiples possibles)");
                                    break;
                                case "tecs" :
                                    echo _("Choisissez un sous-traitant (sélections multiples possibles)");
                                    break;
                            }
                            ?>
                        </td>
                    </tr>
                    <tr>
                        <td width="50%" align="center">
                            <?PHP
                            // Création de la liste des techniciens actifs
                            $tab_tec = give_tab_tec($typ_stat, '');
                            cre_select('tec[]', 'tec', $tab_tec, '*', '*', _("---------- Tous ----------"), 5, TRUE);
                            ?>
                        </td>
                        <td width="50%" align="center">
                            <?PHP
                            switch ($td)
                            {
                            case "teca" :
                                // Création de la liste des agences actives
                                $tab_age = give_tab_age_cli('');
                                cre_select('age[]', 'age', $tab_age, '*', '*', _("---------- Toutes ----------"), 5, TRUE);
                                break;
                            case "tecd" :
                                // Création de la liste des donneurs d'ordres actifs
                                $tab_do = give_tab_do('');
                                cre_select('do[]', 'do', $tab_do, '*', '*', _("---------- Tous ----------"), 5, TRUE);
                                break;
                            case "tecs" :
                                // Création de la liste des sous-traitants actifs
                                $tab_st = give_tab_st('');
                                cre_select('st[]', 'st', $tab_st, '*', '*', _("---------- Tous ----------"), 5, TRUE);
                                break;
                            }
                            ?>
                        </td>
                    </tr>
                </table>
            <?PHP
            } else
                echo '<br /><br />';
            ?>
            <div id = "dates">
                <span class="rubfrm" id="f_date1" style="margin-right: 5px;"><?PHP echo ' '._("Du").'... '; ?></span>
                <input name="date1f" type="text" id="date1f" size="10" value="<?PHP echo datetolocal($date1); ?>" maxlength="10" readonly>
                <?PHP
                if ($aff_stat == FALSE)
                {
                    echo ' <img src="../img/oblig.png" align="absmiddle" alt="'._("Champ obligatoire").'">';
                    echo ' <img src="../img/raz.png" id ="razdate2f" border="0" align="absmiddle">';
                }
                ?>
                <span class="rubfrm" id="f_date2f" style="margin-right: 5px;"><?PHP echo ' '._("Au").'... '; ?></span>
                <input name="date2f" type="text" id="date2f" size="10" value="<?PHP echo datetolocal($date1); ?>" maxlength="10" readonly>
                <?PHP
                if ($aff_stat == FALSE)
                {
                    echo ' <img src="../img/oblig.png" align="absmiddle" alt="'._("Champ obligatoire").'">';
                    echo ' <img src="../img/raz.png" id ="razdate2f" border="0" align="absmiddle">';
                }
                ?>
            </div>
            <?PHP
            if ($aff_stat == FALSE)
            {
                echo '<p align="center">';
                echo '<input name="calc" type="button" class="bton_std" id="calc" value="'._("Calculer").'">';
                echo '<input name="init" type="reset" class="bton_std" id="init" value="'._("Réinitialiser").'">';
                echo '</p>';
            }
            ?>
        </form>

        <?PHP
        // Définition et entête de la table
        echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
        switch ($ts)
        {
            /* Nombre de créations de clients sur une période donnée */
            case 1 :

                echo "<th>";
                echo _("Technicien");
                echo "</th>\n";
                echo "<th>";
                echo _("Total créés");
                echo "</th>\n";
                echo "<th>";
                echo _("Encore prospects");
                echo "</th>\n";
                echo "<th>";
                echo _("Atdente intervention");
                echo "</th>\n";
                echo "<th>";
                echo _("Intervention");
                echo "</th>\n";

                $i = 0;

                /* données pour tous les techniciens */

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

                echo "<td>";
                echo "<span class=\"annot_std_it\">";
                echo _("Tous les techniciens");
                echo "</span>";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_cli_crees_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_cli_crees_total;
                    echo "</span>";
                } else
                    echo "-";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_cli_prospects_crees_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_cli_prospects_crees_total;
                    echo "</span>";
                    if ($nb_cli_crees_total <> 0) {
                        echo "<span class=\"annot_petit_it\">";
                        echo " (" . round((($nb_cli_prospects_crees_total / $nb_cli_crees_total) * 100), 2) . "%)";
                        echo "</span>";
                    }
                } else
                    echo "-";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_cli_ddeint_crees_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_cli_ddeint_crees_total;
                    echo "</span>";
                    if ($nb_cli_crees_total <> 0) {
                        echo "<span class=\"annot_petit_it\">";
                        echo " (" . round((($nb_cli_ddeint_crees_total / $nb_cli_crees_total) * 100), 2) . "%)";
                        echo "</span>";
                    }
                } else
                    echo "-";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_cli_inter_crees_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_cli_inter_crees_total;
                    echo "</span>";
                    if ($nb_cli_crees_total <> 0) {
                        echo "<span class=\"annot_petit_it\">";
                        echo " (" . round((($nb_cli_inter_crees_total / $nb_cli_crees_total) * 100), 2) . "%)";
                        echo "</span>";
                    }
                } else
                    echo "-";
                echo "</td>\n";

                echo "</tr>\n";

                $i++;

                /* Saut de ligne pour lisibilité */

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

                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";

                echo "</tr>\n";

                $i++;

                if ($nb_tec_select > 0) {
                    for ($j = 0; $j < $nb_tec_select; $j++) {
                        // création de l'entête de ligne (TR)
                        creetrlst($i);

                        echo "<td>";
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                        $rech = "SELECT * FROM `" . TBTEC . "` WHERE `tec_code` = '" . $code_tec[$j] . "'";
                        $row = $db->get_row($rech, ARRAY_A);
                        if ($row) {
                            $row = encode_str($row);
                            extract($row);
                            $txt_tec = $tec_nom . " " . $tec_prenom;
                        }
                        $db->disconnect();
                        echo "<span class=\"annot_std_gras\">";
                        echo $txt_tec . " (" . $code_tec[$j] . ")";
                        echo "</span>";
                        if ($tec_out == 1) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " " . _("Licencié");
                            echo "</span>";
                        }
                        echo "<br />";
                        if ($nb_cli_crees_tec[$j] <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo "<div align=\"right\">";
                            echo _("Par rapport technicien") . " : ";
                            echo "<br />" . _("Par rapport total") . " : ";
                            echo "</div>";
                            echo "</span>";
                        }
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_cli_crees_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_cli_crees_tec[$j];
                            echo "</span>";
                            if ($nb_cli_crees_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "<br />-<br />(" . round((($nb_cli_crees_tec[$j] / $nb_cli_crees_total) * 100), 2) . "%)";
                                echo "</span>";
                            }
                        } else
                            echo "-";
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_cli_prospects_crees_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_cli_prospects_crees_tec[$j];
                            echo "</span>";
                            echo "<br />";
                            if ($nb_cli_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_cli_prospects_crees_tec[$j] / $nb_cli_crees_tec[$j]) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                            echo "<br />";
                            if ($nb_cli_prospects_crees_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_cli_prospects_crees_tec[$j] / $nb_cli_prospects_crees_total) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                        } else
                            echo "-";
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_cli_ddeint_crees_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_cli_ddeint_crees_tec[$j];
                            echo "</span>";
                            echo "<br />";
                            if ($nb_cli_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo " (" . round((($nb_cli_ddeint_crees_tec[$j] / $nb_cli_crees_tec[$j]) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                            echo "<br />";
                            if ($nb_cli_ddeint_crees_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_cli_ddeint_crees_tec[$j] / $nb_cli_ddeint_crees_total) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                        } else
                            echo "-";
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_cli_inter_crees_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_cli_inter_crees_tec[$j];
                            echo "</span>";
                            echo "<br />";
                            if ($nb_cli_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo " (" . round((($nb_cli_inter_crees_tec[$j] / $nb_cli_crees_tec[$j]) * 100), 2) . "%)";
                                echo "</span>";
                            }
                            echo "<br />";
                            if ($nb_cli_inter_crees_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_cli_inter_crees_tec[$j] / $nb_cli_inter_crees_total) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                        } else
                            echo "-";
                        echo "</td>\n";

                        echo "</tr>\n";

                        $i++;
                }
            }
            break;

        /* Nombre de créations d'interventions sur une période donnée */
        case 2 :
            switch ($td)
            {
                case "teca" :
                case "tecd":
                    echo "<th>";
                    echo _("Technicien");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Total créées");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Ouvertes");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Clients prévenus");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Closes");
                    echo "</th>\n";

                    $i = 0;

                    /* données pour tous les techniciens */

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

                    echo "<td>";
                    echo "<span class=\"annot_std_it\">";
                    echo _("Tous les techniciens");
                    echo "</span>";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_int_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_int_crees_total;
                        echo "</span>";
                    } else
                        echo "-";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_int_ouv_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_int_ouv_crees_total;
                        echo "</span>";
                        if ($nb_int_crees_total <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " (" . round((($nb_int_ouv_crees_total / $nb_int_crees_total) * 100), 2) . "%)";
                            echo "</span>";
                        }
                    } else
                        echo "-";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_int_prev_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_int_prev_crees_total;
                        echo "</span>";
                        if ($nb_int_crees_total <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " (" . round((($nb_int_prev_crees_total / $nb_int_crees_total) * 100), 2) . "%)";
                            echo "</span>";
                        }
                    } else
                        echo "-";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_int_clos_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_int_clos_crees_total;
                        echo "</span>";
                        if ($nb_int_crees_total <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " (" . round((($nb_int_clos_crees_total / $nb_int_crees_total) * 100), 2) . "%)";
                            echo "</span>";
                        }
                    } else
                        echo "-";
                    echo "</td>\n";

                    echo "</tr>\n";

                    $i++;

                    /* Saut de ligne pour lisibilité */

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

                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";

                    echo "</tr>\n";

                    $i++;

                    if ($nb_tec_select > 0) {
                        for ($j = 0; $j < $nb_tec_select; $j++) {
                            // création de l'entête de ligne (TR)
                            creetrlst($i);

                            echo "<td>";
                            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                            $rech = "SELECT * FROM `" . TBTEC . "` WHERE `tec_code` = '" . $code_tec[$j] . "'";
                            $row = $db->get_row($rech, ARRAY_A);
                            if ($row) {
                                $row = encode_str($row);
                                extract($row);
                                $txt_tec = $tec_nom . " " . $tec_prenom;
                            }
                            $db->disconnect();
                            echo "<span class=\"annot_std_gras\">";
                            echo $txt_tec . " (" . $code_tec[$j] . ")";
                            echo "</span>";
                            if ($tec_out == 1) {
                                echo "<span class=\"annot_petit_it\">";
                                echo " " . _("Licencié");
                                echo "</span>";
                            }
                            echo "<br />";
                            if ($nb_int_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "<div align=\"right\">";
                                echo _("Par rapport technicien") . " : ";
                                echo "<br />" . _("Par rapport total") . " : ";
                                echo "</div>";
                                echo "</span>";
                            }
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_int_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_int_crees_tec[$j];
                                echo "</span>";
                                if ($nb_int_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "<br />-<br />(" . round((($nb_int_crees_tec[$j] / $nb_int_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                }
                            } else
                                echo "-";
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_int_ouv_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_int_ouv_crees_tec[$j];
                                echo "</span>";
                                echo "<br />";
                                if ($nb_int_crees_tec[$j] <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_int_ouv_crees_tec[$j] / $nb_int_crees_tec[$j]) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                                echo "<br />";
                                if ($nb_int_ouv_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_int_ouv_crees_tec[$j] / $nb_int_ouv_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                            } else
                                echo "-";
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_int_prev_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_int_prev_crees_tec[$j];
                                echo "</span>";
                                echo "<br />";
                                if ($nb_int_crees_tec[$j] <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo " (" . round((($nb_int_prev_crees_tec[$j] / $nb_int_crees_tec[$j]) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                                echo "<br />";
                                if ($nb_int_prev_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_int_prev_crees_tec[$j] / $nb_int_prev_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                            } else
                                echo "-";
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_int_clos_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_int_clos_crees_tec[$j];
                                echo "</span>";
                                echo "<br />";
                                if ($nb_int_crees_tec[$j] <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo " (" . round((($nb_int_clos_crees_tec[$j] / $nb_int_crees_tec[$j]) * 100), 2) . "%)";
                                    echo "</span>";
                                }
                                echo "<br />";
                                if ($nb_int_clos_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_int_clos_crees_tec[$j] / $nb_int_clos_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                            } else
                                echo "-";
                            echo "</td>\n";

                            echo "</tr>\n";

                            $i++;
                        }
                    }
                    break;
                case "tecs" :
                    echo "<th>";
                    echo _("Sous-traitant");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Total traités");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Ouverts");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Agences prévenues");
                    echo "</th>\n";
                    echo "<th>";
                    echo _("Clots");
                    echo "</th>\n";

                    $i = 0;

                    /* Données pour tous les techniciens */

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

                    echo "<td>";
                    echo "<span class=\"annot_std_it\">";
                    echo _("Tous les techniciens");
                    echo "</span>";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_ot_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_ot_crees_total;
                        echo "</span>";
                    } else
                        echo "-";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_ot_ouv_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_ot_ouv_crees_total;
                        echo "</span>";
                        if ($nb_ot_crees_total <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " (" . round((($nb_ot_ouv_crees_total / $nb_ot_crees_total) * 100), 2) . "%)";
                            echo "</span>";
                        }
                    } else
                        echo "-";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_ot_prev_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_ot_prev_crees_total;
                        echo "</span>";
                        if ($nb_ot_crees_total <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " (" . round((($nb_ot_prev_crees_total / $nb_ot_crees_total) * 100), 2) . "%)";
                            echo "</span>";
                        }
                    } else
                        echo "-";
                    echo "</td>\n";
                    echo "<td align=\"center\">";
                    if ($nb_ot_clos_crees_total <> 0) {
                        echo "<span class=\"annot_std_it\">";
                        echo $nb_ot_clos_crees_total;
                        echo "</span>";
                        if ($nb_ot_crees_total <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " (" . round((($nb_ot_clos_crees_total / $nb_ot_crees_total) * 100), 2) . "%)";
                            echo "</span>";
                        }
                    } else
                        echo "-";
                    echo "</td>\n";

                    echo "</tr>\n";

                    $i++;

                    /* Saut de ligne pour lisibilité */

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

                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";
                    echo "<td>";
                    echo "&nbsp;";
                    echo "</td>\n";

                    echo "</tr>\n";

                    $i++;

                    if ($nb_tec_select > 0) {
                        for ($j = 0; $j < $nb_tec_select; $j++) {
                            // création de l'entête de ligne (TR)
                            creetrlst($i);

                            echo "<td>";
                            $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                            $rech = "SELECT * FROM `" . TBTEC . "` WHERE `tec_code` = '" . $code_tec[$j] . "'";
                            $row = $db->get_row($rech, ARRAY_A);
                            if ($row)
                            {
                                $row = encode_str($row);
                                extract($row);
                                $txt_tec = $tec_nom . " " . $tec_prenom;
                            }
                            $db->disconnect();
                            echo "<span class=\"annot_std_gras\">";
                            echo $txt_tec . " (" . $code_tec[$j] . ")";
                            echo "</span>";
                            if ($tec_out == 1) {
                                echo "<span class=\"annot_petit_it\">";
                                echo " "._("Licencié");
                                echo "</span>";
                            }
                            echo "<br />";
                            if ($nb_ot_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "<div align=\"right\">";
                                echo _("Par rapport technicien")." : ";
                                echo "<br />" . _("Par rapport total") . " : ";
                                echo "</div>";
                                echo "</span>";
                            }
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_ot_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_ot_crees_tec[$j];
                                echo "</span>";
                                if ($nb_ot_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "<br />-<br />(" . round((($nb_ot_crees_tec[$j] / $nb_ot_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                }
                            } else
                                echo "-";
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_ot_ouv_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_ot_ouv_crees_tec[$j];
                                echo "</span>";
                                echo "<br />";
                                if ($nb_ot_crees_tec[$j] <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_ot_ouv_crees_tec[$j] / $nb_ot_crees_tec[$j]) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                                echo "<br />";
                                if ($nb_ot_ouv_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_ot_ouv_crees_tec[$j] / $nb_ot_ouv_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                            } else
                                echo "-";
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_ot_prev_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_ot_prev_crees_tec[$j];
                                echo "</span>";
                                echo "<br />";
                                if ($nb_ot_crees_tec[$j] <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo " (" . round((($nb_ot_prev_crees_tec[$j] / $nb_ot_crees_tec[$j]) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                                echo "<br />";
                                if ($nb_ot_prev_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_ot_prev_crees_tec[$j] / $nb_ot_prev_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                            } else
                                echo "-";
                            echo "</td>\n";
                            echo "<td align=\"center\">";
                            if ($nb_ot_clos_crees_tec[$j] <> 0) {
                                echo "<span class=\"annot_std_gras\">";
                                echo $nb_ot_clos_crees_tec[$j];
                                echo "</span>";
                                echo "<br />";
                                if ($nb_ot_crees_tec[$j] <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo " (" . round((($nb_ot_clos_crees_tec[$j] / $nb_ot_crees_tec[$j]) * 100), 2) . "%)";
                                    echo "</span>";
                                }
                                echo "<br />";
                                if ($nb_ot_clos_crees_total <> 0) {
                                    echo "<span class=\"annot_petit_it\">";
                                    echo "(" . round((($nb_ot_clos_crees_tec[$j] / $nb_ot_clos_crees_total) * 100), 2) . "%)";
                                    echo "</span>";
                                } else
                                    echo "-";
                            } else
                                echo "-";
                            echo "</td>\n";

                            echo "</tr>\n";

                            $i++;
                        }
                    }
                    break;
            }
            break;

            /* Nombre de traitements d'interventions sur une période donnée */
            case 3 :
                echo "<th>";
                echo _("Agence");
                echo "</th>\n";
                echo "<th>";
                echo _("Total traitées");
                echo "</th>\n";
                echo "<th>";
                echo _("Ouvertes");
                echo "</th>\n";
                echo "<th>";
                echo _("Clients prévenus");
                echo "</th>\n";
                echo "<th>";
                echo _("Closes");
                echo "</th>\n";

                $i = 0;

                /* données pour tous les techniciens */

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

                echo "<td>";
                echo "<span class=\"annot_std_it\">";
                echo _("Tous les techniciens");
                echo "</span>";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_int_trait_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_int_trait_total;
                    echo "</span>";
                } else
                    echo "-";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_int_ouv_trait_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_int_ouv_trait_total;
                    echo "</span>";
                    if ($nb_int_trait_total <> 0) {
                        echo "<span class=\"annot_petit_it\">";
                        echo " (" . round((($nb_int_ouv_trait_total / $nb_int_trait_total) * 100), 2) . "%)";
                        echo "</span>";
                    }
                } else
                    echo "-";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_int_prev_trait_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_int_prev_trait_total;
                    echo "</span>";
                    if ($nb_int_trait_total <> 0) {
                        echo "<span class=\"annot_petit_it\">";
                        echo " (" . round((($nb_int_prev_trait_total / $nb_int_trait_total) * 100), 2) . "%)";
                        echo "</span>";
                    }
                } else
                    echo "-";
                echo "</td>\n";
                echo "<td align=\"center\">";
                if ($nb_int_clos_trait_total <> 0) {
                    echo "<span class=\"annot_std_it\">";
                    echo $nb_int_clos_trait_total;
                    echo "</span>";
                    if ($nb_int_trait_total <> 0) {
                        echo "<span class=\"annot_petit_it\">";
                        echo " (" . round((($nb_int_clos_trait_total / $nb_int_trait_total) * 100), 2) . "%)";
                        echo "</span>";
                    }
                } else
                    echo "-";
                echo "</td>\n";

                echo "</tr>\n";

                $i++;

                /* Saut de ligne pour lisibilité */

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

                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";
                echo "<td>";
                echo "&nbsp;";
                echo "</td>\n";

                echo "</tr>\n";

                $i++;

                if ($nb_tec_select > 0) {
                    for ($j = 0; $j < $nb_tec_select; $j++) {
                        // création de l'entête de ligne (TR)
                        creetrlst($i);

                        echo "<td>";
                        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);
                        $rech = "SELECT * FROM `" . TBTEC . "` WHERE `tec_code` = '" . $code_tec[$j] . "'";
                        $row = $db->get_row($rch, ARRAY_A);
                        if ($row) {
                            $row = encode_str($row);
                            extract($row);
                            $txt_tec = $tec_nom . " " . $tec_prenom;
                        }
                        $db->disconnect();
                        echo "<span class=\"annot_std_gras\">";
                        echo $txt_tec . " (" . $code_tec[$j] . ")";
                        echo "</span>";
                        if ($tec_out == 1) {
                            echo "<span class=\"annot_petit_it\">";
                            echo " " . _("Licencié");
                            echo "</span>";
                        }
                        echo "<br />";
                        if ($nb_int_trait_tec[$j] <> 0) {
                            echo "<span class=\"annot_petit_it\">";
                            echo "<div align=\"right\">";
                            echo _("Par rapport technicien") . " : ";
                            echo "<br />" . _("Par rapport total") . " : ";
                            echo "</div>";
                            echo "</span>";
                        }
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_int_trait_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_int_trait_tec[$j];
                            echo "</span>";
                            if ($nb_int_trait_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "<br />-<br />(" . round((($nb_int_trait_tec[$j] / $nb_int_trait_total) * 100), 2) . "%)";
                                echo "</span>";
                            }
                        } else
                            echo "-";
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_int_ouv_trait_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_int_ouv_trait_tec[$j];
                            echo "</span>";
                            echo "<br />";
                            if ($nb_int_trait_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_int_ouv_trait_tec[$j] / $nb_int_trait_tec[$j]) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                            echo "<br />";
                            if ($nb_int_ouv_trait_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_int_ouv_trait_tec[$j] / $nb_int_ouv_trait_total) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                        } else
                            echo "-";
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_int_prev_trait_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_int_prev_trait_tec[$j];
                            echo "</span>";
                            echo "<br />";
                            if ($nb_int_trait_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo " (" . round((($nb_int_prev_trait_tec[$j] / $nb_int_trait_tec[$j]) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                            echo "<br />";
                            if ($nb_int_prev_trait_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_int_prev_trait_tec[$j] / $nb_int_prev_trait_total) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                        } else
                            echo "-";
                        echo "</td>\n";
                        echo "<td align=\"center\">";
                        if ($nb_int_clos_trait_tec[$j] <> 0) {
                            echo "<span class=\"annot_std_gras\">";
                            echo $nb_int_clos_trait_tec[$j];
                            echo "</span>";
                            echo "<br />";
                            if ($nb_int_trait_tec[$j] <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo " (" . round((($nb_int_clos_trait_tec[$j] / $nb_int_trait_tec[$j]) * 100), 2) . "%)";
                                echo "</span>";
                            }
                            echo "<br />";
                            if ($nb_int_clos_trait_total <> 0) {
                                echo "<span class=\"annot_petit_it\">";
                                echo "(" . round((($nb_int_clos_trait_tec[$j] / $nb_int_clos_trait_total) * 100), 2) . "%)";
                                echo "</span>";
                            } else
                                echo "-";
                        } else
                            echo "-";
                        echo "</td>\n";

                        echo "</tr>\n";

                        $i++;
                    }
                }
                break;

            default :
                break;
        }

        echo "</table>\n";
        // *** Fin affichage de la table

        if ($nb_tec_select == 0)
        {
            echo "<div class=\"annot_petit_it\">";
            echo _("Aucun résultat à cetde demande") . ".";
            echo "</div>";
        }
    } else
        pop_ret_auto(_("Aucun technicien"), 'warn', "index.php");
}
else
    pop_ret_auto(_("Problème de paramètres"), 'warn', "index.php");
include_once("pied.php")
?>
