function output_all_modele_pivot($visible = 1)
{
    $modele_set = find_all_modele_pivot($visible);
    $page_name = "modele_export.php";
    // page which import the day
    $output = "";
    $stylegreen = "style=\" color: #2b9741;font-weight: bold;font-size: 120%;text-decoration: blink;\"";
    $now = strtotime("now");
    $tomorrow = strtotime("tomorrow");
    $now_no = day_eng_no(strftime("%A", $now));
    $tomorrow_no = day_eng_no(strftime("%A", $tomorrow));
    //
    //    $output= "<div class=\"CSSTableGeneratorYellow\">";
    //    $output .= "<table>";
    $output .= "<div class='table-responsive'>";
    $output .= "<table class='table table-striped table-bordered table-hover table-condensed'>";
    $output .= "<tr>";
    // $output .= "<td class='text-center alert-danger'>Jour</td>"; //Heure
    $output .= "<th class='text-center' style='vertical-align:middle;'>&nbsp;Heure&nbsp;</th>";
    for ($a = 1; $a <= 7; $a++) {
        $day = day_fr($a);
        // func return Lundi, Mardi...
        $today = strtotime("today");
        $today_day_name = strftime("%A", $today);
        $today_no = day_eng_no($today_day_name);
        $tomorrow = strtotime("tomorrow");
        $tomorrow_day_name = strftime("%A", $tomorrow);
        $tomorrow_no = day_eng_no($tomorrow_day_name);
        $b = day_eng($a);
        if ($today_no > $a) {
            $last_today_next = "Last {$b}";
        } elseif ($today_no == $a) {
            $last_today_next = "today";
        } else {
            $last_today_next = "Next {$b}";
        }
        $day_date = strtotime($last_today_next);
        // strftime("%d-%m-%Y" ,$day);
        $date = "";
        $date_sql = "";
        if ($today_no == $a) {
            $date .= strftime("%d-%m-%Y", $day_date);
            $date_sql = strftime("%Y-%m-%d", $day_date);
        } elseif ($tomorrow_no == $a) {
            $date .= strftime("%d-%m-%Y", $day_date);
            $date_sql = strftime("%Y-%m-%d", $day_date);
        } else {
            $date .= strftime("%d-%m-%Y", $day_date);
            $date_sql = strftime("%Y-%m-%d", $day_date);
        }
        $output .= "<td class='text-center alert-danger' style='color: white'><strong>";
        $output .= "<a href=\"{$page_name}?jour=";
        $output .= urlencode($a);
        $output .= "&";
        $output .= "modele_date=";
        $output .= urldecode($date_sql);
        $output .= "\" onclick=\"return confirm('Importer {$day}?');";
        $output .= "\">";
        $output .= $day . " <br> " . $date;
        $output .= "&nbsp;";
        $output .= "<span class='glyphicon glyphicon-plus'style='color:green;' aria-hidden='true'></span>";
        $output .= "</a>";
        $output .= "</strong></td>";
    }
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td></td>";
    for ($a = 1; $a <= 7; $a++) {
        $day = day_fr($a);
        // func return Lundi, Mardi...
        if ($a == $now_no) {
            $txt = "" . htmlentities("Aujourd'hui", ENT_COMPAT, 'utf-8');
        } elseif ($a == $tomorrow_no) {
            $txt = "" . htmlentities("Demain", ENT_COMPAT, 'utf-8');
        } else {
            $txt = "";
        }
        if ($a == $now_no) {
            $output .= "<td class='success text-center show-today' {$stylegreen}>";
            $output .= $txt;
            $output .= "</td>";
        } elseif ($a == $tomorrow_no) {
            $output .= "<td class='warning text-center show-tomorrow' {$stylegreen}>";
            $output .= $txt;
            $output .= "</td>";
        } else {
            $output .= "<td class='text-center show-others' {$stylegreen}>";
            $output .= $txt;
            $output .= "</td>";
        }
    }
    $output .= "</tr>";
    //   $output .="<tr>";
    //   $output .= "<th class='text-center'>Heure</th>";
    for ($a = 1; $a <= 7; $a++) {
        $today = strtotime("today");
        $today_day_name = strftime("%A", $today);
        $today_no = day_eng_no($today_day_name);
        $tomorrow = strtotime("tomorrow");
        $tomorrow_day_name = strftime("%A", $tomorrow);
        $tomorrow_no = day_eng_no($tomorrow_day_name);
        $b = day_eng($a);
        if ($today_no > $a) {
            $last_today_next = "Last {$b}";
        } elseif ($today_no == $a) {
            $last_today_next = "today";
        } else {
            $last_today_next = "Next {$b}";
        }
        $day = strtotime($last_today_next);
        // $day=strtotime("Last Monday");
        if ($today_no == $a) {
            //   $output .= "<th class=' text-center show-today'><strong>".strftime("%d-%m-%Y" ,$day)."</strong></th>";
        } elseif ($tomorrow_no == $a) {
            //        $output .= "<th class='text-center show-tomorrow'><strong>".strftime("%d-%m-%Y" ,$day)."</strong></th>";
        } else {
            //        $output .= "<th class='text-center show-others'><strong>" . strftime("%d-%m-%Y", $day) . "</strong></th>";
        }
    }
    //  $output .="</tr>";
    //    $output .= "<td {$style160px}>Samedi</td>";
    $old_heure = "";
    // TODO be able to include in table multiple client for same hour or same week
    while ($modele = mysqli_fetch_assoc($modele_set)) {
        $output .= "<tr>";
        $new_heure = $modele['heure'];
        if ($new_heure !== $old_heure) {
            $output .= "<th class='text-center' style='vertical-align:middle;'><strong>" . htmlentities(visu_heure($modele["heure"]), ENT_COMPAT, 'utf-8') . "</strong></th>";
        } else {
            $output .= "<th></th>";
        }
        $old_heure = $modele["heure"];
        $p_edit = "edit_course_modele.php";
        $p_del = "delete_course_modele.php";
        $p_new = "new_course_modele.php";
        $web_view = htmlentities($modele["web_view"], ENT_COMPAT, 'utf-8');
        $pseudo = htmlentities($modele["pseudo"], ENT_COMPAT, 'utf-8');
        $heure = $modele['heure'];
        $client_id = $modele['client_id'];
        if ($web_view) {
            $client_name = $web_view;
        } else {
            $client_name = $pseudo;
        }
        // $output .="<td>". htmlentities($modele["heure"])."</td>";
        $today = strtotime("today");
        $today_day_name = strftime("%A", $today);
        $today_no = day_eng_no($today_day_name);
        $today_french_name = day_fr($today_no);
        $tomorrow = strtotime("tomorrow");
        $tomorrow_day_name = strftime("%A", $tomorrow);
        $tomorrow_no = day_eng_no($tomorrow_day_name);
        $tomorrow_french_name = day_fr($tomorrow_no);
        for ($a = 1; $a <= 7; $a++) {
            $day = day_fr($a);
            // func return Lundi, Mardi...
            $modele_id = $modele[$day];
            // return value of array
            //------------------------------------------------------
            $today = strtotime("today");
            $today_day_name = strftime("%A", $today);
            $today_no = day_eng_no($today_day_name);
            $tomorrow = strtotime("tomorrow");
            $tomorrow_day_name = strftime("%A", $tomorrow);
            $tomorrow_no = day_eng_no($tomorrow_day_name);
            $b = day_eng($a);
            if ($today_no > $a) {
                $last_today_next = "Last {$b}";
            } elseif ($today_no == $a) {
                $last_today_next = "today";
            } else {
                $last_today_next = "Next {$b}";
            }
            $day_date = strtotime($last_today_next);
            // strftime("%d-%m-%Y" ,$day);
            $date = "";
            $date_sql = "";
            if ($today_no == $a) {
                $date .= strftime("%d-%m-%Y", $day_date);
                $date_sql = strftime("%Y-%m-%d", $day_date);
            } elseif ($tomorrow_no == $a) {
                $date .= strftime("%d-%m-%Y", $day_date);
                $date_sql = strftime("%Y-%m-%d", $day_date);
            } else {
                $date .= strftime("%d-%m-%Y", $day_date);
                $date_sql = strftime("%Y-%m-%d", $day_date);
            }
            // -------------------------------------------------------------
            if ($modele[$day]) {
                //  $old_heure=$modele['heure'];
                //  "<img src="/images_web/check.png" alt="Mountain View" style="width:304px;height:228px">";
                //   $output .="<td>". htmlentities($modele["heure"])."</td>";
                if ($day == $today_french_name) {
                    $output .= "<td class='success text-left show-today'>";
                } elseif ($day == $tomorrow_french_name) {
                    $output .= "<td class='text-left show-tomorrow'>";
                } else {
                    $output .= "<td class='text-left show-others'>";
                }
                //  $output .= htmlentities($client_name, ENT_COMPAT, 'utf-8') ;
                //  $output .= "                <p class='btn'><a class='btn btn-primary  btn-xm' href='{$p_edit}?modele_id=".urlencode($modele_id)."'>&nbsp;Edit&nbsp;</a></p>";
                //    $output .= "  &nbsp";
                $output .= "<p class='btn'>";
                if ($visible == 1) {
                    $output .= "<a class='btn btn-primary  btn-xm ' style='width:14em;' ";
                } else {
                    $output .= "<a class='btn btn-info btn-block btn-xm '  style='width:14em;' ";
                }
                $output .= get_modal_modele($modele_id, $date_sql);
                $output .= "</a>";
                $output .= "</p>";
                //   $output .= "  &nbsp";
                //  $output.= tooltips_modele($modele_id);
                //------------------- start before modal--------------------------------
                //                $output .= "<br>";
                //
                //                $output .= "<a href=\"{$p_edit}?client_id=";
                //                $output .= urlencode($client_id) . "&modele_id=" . urlencode($modele_id) . "&jour_id=" . urlencode($a);
                //                $output .= " \" onclick=\"return confirm('Editer modele {$pseudo} ?');";
                //                $output .= " \">";
                //                $output .= "<span class='glyphicon glyphicon-pencil'style='color:blue;' aria-hidden='true'></span>";
                //                $output .= "</a>";
                //                $output .= "  &nbsp &nbsp";
                //
                //                $output .= "<a href=\"{$p_new}?client_id=";
                //                $output .= urlencode($client_id) . "&modele_id=" . urlencode($modele_id);
                //                $output .= " \" onclick=\"return confirm('Nouveau modele {$pseudo} ?');";
                //                $output .= " \">";
                //                $output .= "<span class='glyphicon glyphicon-plus'style='color:green;' aria-hidden='true'></span>";
                //                $output .= "</a>";
                //                $output .= "  &nbsp &nbsp";
                //
                //                $output .= "<a href=\"{$p_del}?modele_id=" . urlencode($modele_id);
                //                $output .= " \" onclick=\"return confirm('Delete modele {$pseudo} {$day} à {$heure}?');";
                //                $output .= " \">";
                //                $output .= "<span class='glyphicon glyphicon-remove'style='color:red;' aria-hidden='true'></span>";
                //                $output .= "</a>";
                // -------------------------end before modale------------------------------
                $output .= "</td>";
            } else {
                if ($day == $today_french_name) {
                    $output .= "<td class='success'></td>";
                } else {
                    $output .= "<td></td>";
                }
            }
        }
        $output .= "</tr>";
    }
    $output .= "</table>";
    mysqli_free_result($modele_set);
    $output .= "</div>";
    return $output;
}
$layout_context = "admin";
$active_menu = "admin";
$stylesheets = "";
$fluid_view = true;
$javascript = "";
include "../includes/layouts/header_2.php";
include "../includes/layouts/nav.php";
?>


<?php 
// changed from
if (isset($_GET['date_next_last']) && isset($_GET['week_day'])) {
    $day = $_GET["week_day"];
    $day_french = day_fr($day);
    $day_english = day_eng($day);
    $date_next_last = $_GET["date_next_last"];
    $time = $_GET["date_next_last"] . " " . $day_english;
    if ($date_next_last == "next") {
        $text_fr = $day_french . " la semaine prochaine";
    } else {
        $text_fr = $day_french . " la semaine dernière";
    }
}
if (isset($_GET["modele_visible"])) {
    $visible = $_GET["modele_visible"];
} else {
    $visible = 1;
}
?>