pileTV.php 27.7 KB
Newer Older
Hamza Arfaoui's avatar
Hamza Arfaoui committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once("../inc/confNetisse.php");
require_once("functions.php");

$has_entites = $GLOBALS["BO_CONF"]["ENTITIES"];
$has_motifs = $GLOBALS["BO_CONF"]["MOTIFS"];
$agence = load_agence();
$entites = $has_entites ? load_entites($agence) : array();
$motifs = $has_motifs ? load_motifs($agence) : array();
$colors_entites = getNotifsColors($entites, $motifs, false);

$entite = 0;
if (isset($_REQUEST['entite'])) {
    $entite = intval($_REQUEST['entite']);
}
/*
  function sec2hms ($sec, $padHours = false) {
  $hms = "";
  $hours = intval(intval($sec) / 3600);
  if ($hours > 0) {
  $hms .= ($padHours)
  ? str_pad($hours, 2, "0", STR_PAD_LEFT). 'h'
  : $hours. 'h';
  }
  $minutes = intval(($sec / 60) % 60);
  $hms .= $minutes.'m';
  $seconds = intval($sec % 60);
  $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT)."s";
  return $hms;
  }
 */


// To DO: Généraliser, RNETISSE spécifique à CASRA
$IDA = "";
if (isset($_REQUEST["RNETISSE"])) {
    $IDA = $_REQUEST["RNETISSE"];
} else if (isset($_REQUEST['IDA'])) {
    $IDA = $_REQUEST['IDA'];
}

$q = "SELECT id_agence, code_agence, nom_agence,pile_tv_info FROM ca_agences WHERE code_agence=:code";
$values = array(':code' => $IDA);
$result = excuteQuery($q, $values);
$res = $result['stmt'];
$o = $res->fetchObject();
$n = $res->rowCount();
if ($n != 1) {
    echo "<html><head><style type=\"text/css\">body {font-family:Arial,sans-serif;font-size:14px;color:#000;}</style></head><body><center><img src=\"/assets/img/logo.png\" width=\"110\" height=\"90\" alt=\"Credit Agricole\" title=\"Credit Agricole\"/><br/><br/>Erreur de configuration.<br/>Contactez le Service informatique de votre caisse.</center></body></html>";
} else {
    $AGENCE = $o->nom_agence;
    $IDAGENCE = $o->id_agence;
    $CODEAGENCE = $o->code_agence;
    $INFOAGENCE = $o->pile_tv_info;
    $TIMER = 60;

    $clientQ = $GLOBALS["BORNE_CONF"]["CLIENT_TYPE"] ? "client, " : "";

    $q = "SELECT cl.id_client, cl.nbr, DATE_FORMAT(cl.date_arrivee, '%Hh%i') as date_arrivee, cl.date_priseencharge, cl.date_cloture, cl.rdv, cl.rdv_type, cl.civ, cl.nom, cl.prenom, cl.id_conseiller, cs.nom as conseillerNom,
			" . ($has_entites ? "cl.entite," : "") . $clientQ . "
			GROUP_CONCAT(m.titre SEPARATOR ',') AS motifs
			FROM ca_clients cl
			LEFT OUTER JOIN ca_conseillers cs ON cl.id_conseiller=cs.id_conseiller
			LEFT JOIN ca_client_motifs cm ON cl.id_client=cm.id_client LEFT JOIN ca_motifs m ON cm.id_motif=m.id_motif
			WHERE DATEDIFF(cl.date_arrivee,now())=:date_arrivee
			AND cl.date_priseencharge=:date_priseencharge
			AND cl.id_agence=:id_agence
			" . ($entite ? "AND cl.entite=:entite" : "") . "
			GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12
			" . ($has_entites ? ",13" : "") . "
			ORDER BY cl.id_client ASC";
//echo "<li>".$q;
    $values = [':date_arrivee' => 0,':date_priseencharge' => '0000-00-00 00:00:00',':id_agence' => $IDAGENCE];
    if($entite){
        $values[':entite'] = $entite;
    }
    $result = excuteQuery($q, $values);
    $res = $result['stmt'];
    $n = $res->rowCount();

    $NBCLIENTSATTENTE = $n . " client en attente";
    if ($n > 1)
        $NBCLIENTSATTENTE = $n . " clients en attente";

    $TOTALCLIENTS = $n;


    $q = "SELECT cl.id_client, cl.nbr, DATE_FORMAT(cl.date_arrivee, '%Hh%i') as date_arrivee, cl.date_priseencharge, cl.date_cloture, cl.rdv, cl.rdv_type, cl.civ, cl.nom, cl.prenom, cl.id_conseiller, cs.nom as conseillerNom,
			" . ($has_entites ? "cl.entite," : "") . $clientQ . "
			GROUP_CONCAT(m.titre SEPARATOR ',') AS motifs
			FROM ca_clients cl
			LEFT OUTER JOIN ca_conseillers cs ON cl.id_conseiller=cs.id_conseiller
			LEFT JOIN ca_client_motifs cm ON cl.id_client=cm.id_client LEFT JOIN ca_motifs m ON cm.id_motif=m.id_motif
			WHERE DATEDIFF(cl.date_arrivee,now())=:date_arrivee
			AND cl.date_priseencharge=:date_priseencharge
			AND cl.id_agence=:id_agence
			" . ($entite ? "AND cl.entite=:entite" : "") . "
			AND cl.rdv=:rdv
			GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12
			" . ($has_entites ? ",13" : "") . "
			ORDER BY cl.id_client ASC";
//echo "<li>".$q;
    $values = [':date_arrivee' => 0,':date_priseencharge'=>'0000-00-00 00:00:00', ':id_agence' => $IDAGENCE];
    if($entite){
        $values[':entite'] = $entite;
    }
    $values[':rdv'] = 1;
    $result = excuteQuery($q, $values);
    $res = $result['stmt'];
    $TOTALRDVNB = $res->rowCount();

    $q = "SELECT cl.id_client, cl.nbr, DATE_FORMAT(cl.date_arrivee, '%Hh%i') as date_arrivee, cl.date_priseencharge, cl.date_cloture, cl.rdv, cl.rdv_type, cl.civ, cl.nom, cl.prenom, cl.id_conseiller, cs.nom as conseillerNom,
			" . ($has_entites ? "cl.entite," : "") . $clientQ . "
			GROUP_CONCAT(m.titre SEPARATOR ',') AS motifs
			FROM ca_clients cl
			LEFT OUTER JOIN ca_conseillers cs ON cl.id_conseiller=cs.id_conseiller
			LEFT JOIN ca_client_motifs cm ON cl.id_client=cm.id_client LEFT JOIN ca_motifs m ON cm.id_motif=m.id_motif
			WHERE DATEDIFF(cl.date_arrivee,now())=:date_arrivee
			AND cl.date_priseencharge=:date_priseencharge
			AND cl.id_agence=:id_agence
			" . ($entite ? "AND cl.entite=:entite" : "") . "
			AND cl.rdv=:rdv
			GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12
			" . ($has_entites ? ",13" : "") . "
			ORDER BY cl.id_client ASC";
//echo "<li>".$q;
    $values = [':date_arrivee' => 0,':date_priseencharge'=>'0000-00-00 00:00:00', ':id_agence' => $IDAGENCE];
    if($entite){
        $values[':entite'] = $entite;
    }

    $values[':rdv'] = 0;
    $result = excuteQuery($q, $values);
    $res = $result['stmt'];
    $TOTALSRDVNB = $res->rowCount();

    // DMA RDV
//echo "<!-- ".$q2." -->";
    $stock = 0;
    $count = 0;
    $q2 = "SELECT date_arrivee as da, date_priseencharge as dp FROM ca_clients WHERE date_arrivee > :date_arrivee1 AND date_arrivee < :date_arrivee2 AND date_priseencharge != :date_priseencharge AND rdv=:rdv AND id_agence=:id_agence";
    $date_arrivee1_sql = date('Y-m-d') . " 07:00:00";
    $date_arrivee2_sql = date('Y-m-d') . " 23:59:59";
    $date_priseencharge_sql = "0000-00-00 00:00:00";
    $rdv_sql = 1;
    $values2 = [':date_arrivee1' => $date_arrivee1_sql, ':date_arrivee2'=>$date_arrivee2_sql, ':date_priseencharge' =>$date_priseencharge_sql, ':rdv' => $rdv_sql, ':id_agence' => $IDAGENCE];
    $result2 = excuteQuery($q2, $values2);
    $res2 = $result2['stmt'];
    while ($d2 = $res2->fetchObject()) {
        //echo "<li>".$d2->da." - ".$d2->dp;
        $stock += (strtotime($d2->dp) - strtotime($d2->da));
        $count++;
    }
    $DMAR = 0;
    if (($stock > 0) && ($count > 0)) {
        $TOTALRDVDMA = sec2hms(($stock / $count));
    } else {
        $TOTALRDVDMA = 0;
    }

    // DMA SRDV
    $q3 = "SELECT date_arrivee as da, date_priseencharge as dp FROM ca_clients WHERE date_arrivee > :date_arrivee1 AND date_arrivee < :date_arrivee2 AND date_priseencharge != :date_priseencharge AND rdv=:rdv AND id_agence=:id_agence";
    //$stmt2 = $GLOBALS["cnx"]->prepare($q3) or wts_die(show_error());
    $date_arrivee1_sql = date('Y-m-d') . " 07:00:00";
    $date_arrivee2_sql = date('Y-m-d') . " 23:59:59";
    $date_priseencharge_sql = "0000-00-00 00:00:00";
    $rdv_sql = 0;
    $values3 = [':date_arrivee1' => $date_arrivee1_sql, ':date_arrivee2'=>$date_arrivee2_sql, ':date_priseencharge' =>$date_priseencharge_sql, ':rdv' => $rdv_sql, ':id_agence' => $IDAGENCE];
    $result3 = excuteQuery($q3, $values3);
    $res3 = $result3['stmt'];
    $stock = 0;
    $count = 0;
    while ($d2 = $res3->fetchObject()) {
        //echo "<li>".$d2->da." - ".$d2->dp;
        $stock += (strtotime($d2->dp) - strtotime($d2->da));
        $count++;
    }
    $DMAS = 0;
    if (($stock > 0) && ($count > 0)) {
        $TOTALSRDVDMA = sec2hms(($stock / $count));
    } else {
        $TOTALSRDVDMA = 0;
    }




    $DATEJOUR = date('Y-m-d');
//$DATEJOUR = "2015-02-20";
    $DATEREF = "now()";
//$DATEREF = "'2015-02-20 18:00:00'";
    ?>
    <html>

        <head>
            <meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1">
            <meta name="apple-mobile-web-app-capable" content="yes">
            <meta name="mobile-web-app-capable" content="yes">
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta http-equiv="refresh" content="<?php echo $TIMER; ?>">
            <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
            <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
            <META HTTP-EQUIV="EXPIRES" CONTENT="0">
            <title><?php echo $NBCLIENTSATTENTE; ?></title>

            <style>

                /* latin-ext */
                @font-face {
                    font-family: 'Viga';
                    font-style: normal;
                    font-weight: 400;
                    src:	url('fonts/viga_ext.eot'); /* IE9 Compat Modes */
                    src:	url('fonts/viga_ext.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
                        url('fonts/viga_ext.woff2') format('woff2'), /* Super Modern Browsers */
                        url('fonts/viga_ext.ttf')  format('truetype'); /* Safari, Android, iOS */
                    /*src: local('Viga-Regular'), url('fonts/viga_ext.woff2') format('woff2'),
                    src: local('Viga-Regular'), url('fonts/viga_ext.ttf') format('ttf');*/
                    unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
                }

                /* latin */
                @font-face {
                    font-family: 'Viga';
                    font-style: normal;
                    font-weight: 400;
                    /*src: local('Viga-Regular'), url('fonts/viga.woff2') format('woff2');*/
                    src:	url('fonts/viga.eot'); /* IE9 Compat Modes */
                    src:	url('fonts/viga.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
                        url('fonts/viga.woff2') format('woff2'), /* Super Modern Browsers */
                        url('fonts/viga.ttf')  format('truetype'); /* Safari, Android, iOS */
                    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
                }

                html {margin:0 !important;padding:0 !important;}
                body {margin:0 !important;padding:0 !important; width:100%;text-align:center;background-color:#FFFFFF; color:#000000; font-family:'Viga', serif;font-size:120px;}
                #wts {text-align:right;}
                #timer {width:95px;margin-left:auto;margin-right:auto;}

                #header {font-family:'Viga',serif;width:100%; height:290px;margin-left:auto;margin-right:auto;border:0px solid red;text-align:center;z-index:1000;position:fixed;top:0;background-color:#ffffff; }

                #ligne1 {width:100%; height:90px;text-align:center;background-color:#ffffff; } /* #cfe1f2 */
                #ligne2 {width:100%; height:90px;text-align:center;background-color:#80b740; }
                #ligne3 {width:100%; height:90px;text-align:center;background-color:#80b740;}
                #CWT {margin-top:250px;}

                .space {padding-left:10px;padding-right:10px;}
                .nbclients {font-family:'Viga', serif;font-size:60px;padding-right:10px;}
                .nbrdv {font-family:'Viga', serif;font-size:60px;color:#ffffff;}
                .dmar {font-family:'Viga', serif;font-size:60px;color:#ffffff;padding-right:10px;}
                .nbsrdv {font-family:'Viga', serif;font-size:60px;color:#ffffff;}
                .dmas {font-family:'Viga', serif;font-size:60px;padding-right:10px;}
                .spacer {width:100%;height:10px;background-color:#FFFFFF;border:0px solid lime;}

                #wrapper {border:0px solid lime;margin-top:290px;background-color:#ffffff;}

                .rdv {width:100%;}
                .rdvtoppicto {width:50px;background-color:#009bc9; color:#ffffff; font-size:60px;padding-left:10px;}
                .rdvtop {font-family:'Viga', serif; background-color:#009bc9; color:#ffffff; font-size:60px;padding-left:10px;}
                .rdvtopright {font-family:'Viga', serif; background-color:#009bc9; color:#ffffff; font-size:65px;padding-right:20px;}
                .rdvbot {font-family:'Viga', serif; background-color:#009bc9; color:#ffffff; font-size:65px;}

                .rdv2 {width:100%;}
                .rdv2top {font-family:'Viga', serif; background-color:#5b96c5; color:#ffffff; font-size:60px;padding-left:10px;}
                .rdv2topright {font-family:'Viga', serif; background-color:#5b96c5; color:#ffffff; font-size:65px;padding-right:20px;}
                .rdv2bot {font-family:'Viga', serif; background-color:#5b96c5; color:#ffffff; font-size:65px;}

                .srdv {width:100%;}
                .srdvtop {font-family:'Viga', serif; background-color:#5f5f62; color:#ffffff; font-size:60px;padding-left:10px;}
                .srdvtopright {font-family:'Viga', serif; background-color:#5f5f62; color:#ffffff; font-size:65px;padding-right:20px;}
                .srdvbot {font-family:'Viga', serif; background-color:#5f5f62; color:#ffffff; font-size:65px;}

                .srdv2 {width:100%;}
                .srdv2top {font-family:'Viga', serif; background-color:#335a80; color:#ffffff; font-size:60px;padding-left:10px;}
                .srdv2topright {font-family:'Viga', serif; background-color:#335a80; color:#ffffff; font-size:65px;padding-right:20px;}
                .srdv2bot {font-family:'Viga', serif; background-color:#335a80; color:#ffffff; font-size:65px;}

                .coupdur {width:100%;}
                .coupdurtop {font-family:'Viga', serif; background-color:#eb292f; color:#ffffff; font-size:60px;padding-left:10px;}
                .coupdurtopright {font-family:'Viga', serif; background-color:#eb292f; color:#ffffff; font-size:65px;padding-right:20px;}
                .coupdurbot {font-family:'Viga', serif; background-color:#eb292f; color:#ffffff; font-size:65px;}

                .coupdur2 {width:100%;}
                .coupdur2top {font-family:'Viga', serif; background-color:#ab0e30; color:#ffffff; font-size:60px;padding-left:10px;}
                .coupdur2topright {font-family:'Viga', serif; background-color:#ab0e30; color:#ffffff; font-size:65px;padding-right:20px;}
                .coupdur2bot {font-family:'Viga', serif; background-color:#ab0e30; color:#ffffff; font-size:65px;}

                .prospect {width:100%;}
                .prospecttop {font-family:'Viga', serif; background-color:#3366CC; color:#ffffff; font-size:60px;padding-left:10px;}
                .prospecttopright {font-family:'Viga', serif; background-color:#3366CC; color:#ffffff; font-size:65px;padding-right:20px;}
                .prospectbot {font-family:'Viga', serif; background-color:#3366CC; color:#ffffff; font-size:65px;}

                #refMsg{font-size:10px; color:#666; position:fixed; left:0em; bottom:0em;background-color:#fff;width:100%;padding:.5em;text-align:left;}

                #clients table
                {
                    border-top: solid 1px white;
                }

                .type-agence-0 #header, .type-agence-2 #header{ height : 190px;}
                .type-agence-0 #wrapper, .type-agence-2 #wrapper{ margin-top : 200px;}

                @media (max-width: 1366px)
                {
                    body{
                        font-size: 80px
                    }
                    .nbclients,.nbrdv,.dmar,.nbsrdv,.dmas,.rdvtoppicto,.rdvtop,.rdv2top,.srdvtop,.srdv2top,.coupdurtop,.coupdur2top
                    {
                        font-size:40px;
                    }
                    .rdvtopright,.rdvbot,.srdvtopright,.srdvbot,.rdv2topright,.rdv2bot,.srdvtopright,.srdvbot,.srdv2topright,.srdv2bot,.coupdurtopright,.coupdurbot,.coupdur2topright,.coupdur2bot{
                        font-size:45px;
                    }
                    #header{height:230px;}
                    #ligne1,#ligne2,#ligne3  {height:70px;}
                    #CWT {margin-top:190px;}
                    #wrapper{margin-top:230px;}
                }
            </style>
            <!--[if IE]>
                    <style>

                    </style>
            <![endif]-->
            <?php if ($GLOBALS["BO_CONF"]["MOTIFSCOLORS"]) { ?>
                <link rel="stylesheet" href="css/motifs.php" />
            <?php } ?>
            <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
            <script type="text/javascript" src="js/progress.min.js"></script>
            <script type="text/javascript">
                $(document).ready(function () {

                    initScroll();

                    $(window).on('beforeunload', function () {
                        $(window).scrollTop(0);
                        //$('html, body').animate({scrollTop: '0px'}, 800);
                    });
                    msieversion();
                });

                function msieversion() {
                    if ((navigator.userAgent.indexOf("MSIE") != -1) || (!!document.documentMode == true)) //IF IE > 10
                    {
                        $("td").css('font-size', '55px');
                    }
                    return false;
                }

                function initScroll() {
                    setTimeout(pageScroll, 10000);
                }

                function pageScroll() {

                    window.scrollBy(0, 2); // horizontal and vertical scroll increments

                    var scrollPercent = 100 * $(window).scrollTop() / ($(document).height() - $(window).height());
                    if (scrollPercent == 100) {
                        //alert("Bas atteint !");
                        $('html, body').animate({scrollTop: '0px'}, 800);
                        initScroll();
                    } else {
                        scrolldelay = setTimeout('pageScroll()', 100); // scrolls every 100 milliseconds
                    }
                }
            </script>
        </head>

        <?php // onLoad="initScroll()"  ?>
        <body>



            <input type="hidden" id="IDA" value="<?php echo $IDA; ?>"/>

            <table width="100%" cellspacing="0" cellpadding="0" class="type-agence-<?php echo $agence->type_agence; ?>">
                <tr>
                    <td>
                        <div id="attente">
                            <?php
                            $html = "<div id='header'>";
                            $html .= "<div id='ligne1' valign='top'><table width='100%' class='space'><tr><td align='left'><img src='/assets/img/logo.png' height='85' valign='middle' style='object-fit: contain'></td><td align='right' class='nbclients'>Nombre de clients en attente : " . $TOTALCLIENTS . "</td></tr></table></div>";
                            $html .= "<div class='spacer'></div>";
                            $html .= "<div id='ligne2' valign='top'><table width='100%' class='space'><tr><td align='left' class='nbrdv'>Rendez-vous : " . $TOTALRDVNB . "</td><td align='right' class='dmar'>Dur&#233;e Moyenne d'Attente : " . $TOTALRDVDMA . "</td></tr></table></div>";
                            $html .= "<div class='spacer'></div>";
                            if (!$GLOBALS["BO_CONF"]["AGENCE"]["MULTIPLE_TYPES"] || $agence->type_agence == 1) {
                                $html .= "<div id='ligne3' valign='top'><table width='100%' class='space'><tr><td align='left' class='nbsrdv'>Sans rendez-vous : " . $TOTALSRDVNB . "</td><td align='right' class='dmas' style='color:#ffffff;'>Dur&#233;e Moyenne d'Attente : " . $TOTALSRDVDMA . "</td></tr></table></div>";
                            }
                            $html .= "</div>";
                            $html .= "<div id='wrapper'><div id='clients' style='overflow:auto;' >";

                            $afaQ = $GLOBALS["BO_CONF"]["AFA"] ? " is_afa," : "";
                            $motifsQ = $GLOBALS["BO_CONF"]["AFA"] ? " is_motif," : "";

                            $q = "SELECT cl.id_client, cl.nbr, DATE_FORMAT(cl.date_arrivee, '%Hh%i') as date_arrivee, cl.date_priseencharge, cl.date_cloture, cl.rdv, cl.rdv_type, cl.civ, cl.nom, cl.prenom, cl.id_conseiller, cs.nom as conseillerNom, cs.prenom as conseillerPrenom,
								" . ($has_entites ? "cl.entite," : "") . $afaQ . $motifsQ . $clientQ . "
								GROUP_CONCAT(m.titre SEPARATOR ',') AS motifs,
								GROUP_CONCAT(m.couleur SEPARATOR ',') AS couleursMotifs
								FROM ca_clients cl
								LEFT OUTER JOIN ca_agences a ON a.id_agence=cl.id_agence
								LEFT OUTER JOIN ca_conseillers cs ON cl.id_conseiller=cs.id_conseiller
								LEFT JOIN ca_client_motifs cm ON cl.id_client=cm.id_client LEFT JOIN ca_motifs m ON cm.id_motif=m.id_motif
								WHERE DATEDIFF(cl.date_arrivee,now())=0
								AND cl.date_priseencharge=:date_priseencharge
								AND cl.id_agence=:id_agence
								" . ($entite ? "AND cl.entite=:entite " : "") . "
								GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12
								" . ($has_entites ? ",13" : "") . "
								ORDER BY cl.id_client ASC";
//echo "<li>".$q;
                            $values = [':date_priseencharge'=>'0000-00-00 00:00:00', ':id_agence' => $IDAGENCE];
                            if($entite){
                                $values[':entite'] = $entite;
                            }
                            $result = excuteQuery($q, $values);
                            $res = $result['stmt'];
                            $n = $res->rowCount();
                            $i = 0;
                            while ($o = $res->fetchObject()) {
                                $IDCLIENT = $o->id_client;
                                $CIV = str_replace("_", " & ", $o->civ);
                                $CLINOM = $CIV . " " . $o->prenom . " " . $o->nom;
                                $CLICLASS = "srdv";
                                $CLASS = "srdv";

                                $venue = join(" | ", explode(",", $o->motifs));
								$couleur = explode(",",$o->couleursMotifs);
                                $objetVenue = " | " . $venue;
                                if ($venue == "Coup dur") {
                                    $cliClass = "coupdur";
                                    $CLICLASS = "coupdur";
                                    $CLASS = "coupdur";
                                }
                                $motif = getMotifByTitle($venue, $motifs);
                                $dm = $GLOBALS["BO_CONF"]["DYNAMIC_MOTIFS"] && $o->is_motif;
                                if ($o->is_afa && $o->rdv_type == 1 && !$dm) {
                                    $actions = load_actions();
                                    $action = $actions[$o->rdv_type];
                                    $objetVenue = " | " . $action->titre;
                                }
                                $CLIOBJET = "Sans RDV" . $objetVenue;


                                if ($o->rdv == 1) {
                                    $CLICLASS = "rdv";
                                    $CLASS = "rdv";
                                    if ($o->id_conseiller == 0) {
                                        if ($GLOBALS["BO_CONF"]["AGENCE"]["MULTIPLE_TYPES"] && $agence->type_agence == 2) { // Type Borne RH
                                            $CLIOBJET = "RDV |&#8594; Votre interlocuteur n'est pas présent sur la borne";
                                        } else {
                                            $CLIOBJET = "RDV |&#8594; Conseiller inconnu";
                                        }
                                    } else {
                                        $CLIOBJET = "RDV |&#8594; " . $o->conseillerPrenom . " " . $o->conseillerNom;
                                    }
                                }

                                $heure_serveur = date('H\hi');
                                $da = ((substr($o->date_arrivee, 0, 2) * 3600) + (substr($o->date_arrivee, 3, 2) * 60));
                                $ds = ((substr($heure_serveur, 0, 2) * 3600) + (substr($heure_serveur, 3, 2) * 60));
                                $diff = ($ds - $da);
                                $attente = "";
                                $attente = round($diff / 60);
                                if ($attente < 1) {
                                    $attente = "";
                                } else {
                                    if ($attente > 59) {
                                        $h = floor($attente / 60);
                                        $m = ($attente % 60);
                                        if ($m < 10)
                                            $m = "0" . $m;
                                        $attente = "Attente : " . $h . "h" . $m . "m ";
                                    } else {
                                        $attente = "Attente : " . $attente . "m ";
                                    }
                                }
                                $CLIATTENTE = $attente;

                                $background_style = "";
                                if ($o->id_conseiller && $has_entites && $o->entite && $colors_entites["ENTITE_" . $o->entite]) {
                                    $background_style = ' style="background-color: #' . $colors_entites["ENTITE_" . $o->entite] . '"';
                                } else {
                                    if ($o->rdv == 1) {
                                        if ($o->id_conseiller == 0) {
                                            $background_style = ' style="background-color: #' . $colors_entites["MYST"] . '"';
                                        } else {
                                            $background_style = ' style="background-color: #' . $colors_entites["RDV"] . '"';
                                        }
                                    } else if ($o->rdv == 2) {
                                        $background_style = ' style="background-color: #' . $colors_entites["MEET"] . '"';
                                    } else {
                                        if($GLOBALS["BO_CONF"]["MOTIFSCOLORS"]){
                                            $background_style = ' style="background-color: ' . $couleur[0] . '"';
                                        } else {
                                            $background_style = ' style="background-color: #' . $colors_entites["SRDV"] . '"';
                                        }
                                    }
                                }

                                if (isset($GLOBALS["BORNE_CONF"]["CLIENT_TYPE"]) && $GLOBALS["BORNE_CONF"]["CLIENT_TYPE"]) {
                                    $clientType = ($o->client == 1) ? "Client" : "Prospect";
                                    $cliNomClient .= " (" . $clientType . ")";
                                    if ($o->client == 0) {
                                        $cliClass = strtolower($clientType);
                                        $CLICLASS = strtolower($clientType);
                                        $CLASS = strtolower($clientType);
                                        $background_style = ' style="background-color: ' . $GLOBALS["PILE_CONF"]["COLORS"]["PROSPECT"] . '"';
                                    }
                                }
                                $html .= "<table id='CWT" . $IDCLIENT . "' align='center' cellspacing='0' cellspacing='0' class='" . $CLICLASS . "' width='100%' $background_style><tr width='50%'><td width='50%' class='" . $CLASS . "top' $background_style>" . $CLINOM . "</td><td width='50%' class='" . $CLASS . "topright' align='right' $background_style>" . $CLIATTENTE . "</td></tr><tr><td colspan='2' align='center' class='" . $CLASS . "bot' $background_style>" . $CLIOBJET . "</td></tr></table>";
                            }

                            $html .= "</div></div>";
                            echo $html;
                            ?>
                        </div>
                    </td>
                </tr>
            </table>
            <div id="refMsg"><?php echo $INFOAGENCE; ?></div>
        </body>

    </html>

    <?php
}
?>