<?php
const BR_END = "<br>\n";

if (isValidConstant() != 1) {
    fermeSessionUtilisateur();
}

$jeton = filter_input(INPUT_POST, 'jeton');
if (empty($jeton)) {
    $jeton = filter_input(INPUT_GET, 'jeton');
}

$modeAdmin= ($_SESSION['gestion_site']>="Oui"?"Oui":"Non");
if ($modeAdmin!=="Oui") {
    exit;
}


$datedebut = getPeriodeCourante("début");
$datefin = getPeriodeCourante("fin");
$periode_en_cours = $datedebut . " au " . $datefin;

function creer_menu_item_admin($modeAdmin, $etiquette, $menuName, $jeton, $icone) {
    if ($modeAdmin === "Oui") {
        $alignement = "center";
        print "<td style='vertical-align: top;' style='min-width:315px; max-width:315px;'>\n";
        print "<div style='text-align: $alignement;'>\n";
        print "<button class='styled bouton_menu' onclick='versMenu(\"$menuName\", \"$jeton\");' tabindex='$menuName' type='button'>\n";
        print "<div align='center'><i class='fa $icone'><span  class='espace_icone_menu'>$etiquette</span></i></div>\n";
        print "</button>\n";
        print "</div>\n";
        print "</td>\n";
    } else {
        print "<td style='width:300px;'></td>";
    }
}
?>
<table style='border:0px; text-align:center; margin:auto; width:auto;' cellpadding='0' cellspacing='0'>
    <tbody>
        <tr>
            <td>
                <table style='width:900px; margin:0; padding:0; height:850px;' cellpadding='0' cellspacing='0'>
                    <thead>
                        <tr>
                            <td class="img_center" colspan='3'>
                                <img id="logoweb" src="images/logoweb.png" alt="<?php print $APPLICATION; ?>">
                            </td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <!-- Ligne vide pour espacement vertical -->
                            <td style='vertical-align: top;' colspan='3'>&nbsp;</td>
                        </tr>
                        <tr>
                            <td style='vertical-align: top;' colspan='3'>
                                <div style='width:360px; height:163px; margin:auto; padding:0;'>
                                    <?php
                                    print "<img alt='SYNDICAT' src='logo/" . $_SESSION["syndicat"] . "." . $_SESSION['logo'] . "' width='360px;' height='163px;'>\n";
                                    print "</div>\n";
                                    ?>
                            </td>
                        </tr>


                        <?php
                        print "<tr>\n";
                        //Copie de la base de données principales
                        creer_menu_item_admin($modeAdmin, "Copie la base de données #1", "execute_copie_db1", $jeton, "fa-wpforms");
                        //Copie de la base de données du syndicat
                        creer_menu_item_admin($modeAdmin, "Copie la base de données #2", "execute_copie_db2", $jeton, "fa-wpforms");
                        print "</tr>\n";

                        //Sortie
                        print "<tr>\n";
                        print "<td style='vertical-align: top;' colspan='3'>\n";
                        print "   <form name='horloge3' action='index2.php?page=utilitaires' method='POST'>\n";
                        print "      <input class='styled' type=\"submit\" style='cursor:pointer;' value=\"Fermer\">\n";
                        print "      <input type='hidden' name='jeton' value='" . $_SESSION['jeton'] . "'>\n";
                        print "   </form>";
                        print "</td>\n";
                        print "</tr>\n";
                        ?>

                        <tr> 
                            <td colspan='2'> 
                                <table style='text-align:center; margin:auto; padding-top:30px;'> 
                                    <tr> 
                                        <td style="vertical-align: top;"> 
                                            <div style="text-align:left;">Période en cours : </div> 
                                        </td> 
                                        <td style="vertical-align: top;" colspan="2"> 
                                            <div style="text-align:left;"> 
                                                <input style="direction: ltr; background-color: rgb(204, 204, 204);" size="30" readonly="readonly" name="info2" value="<?= $periode_en_cours; ?>">
                                            </div> 
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td style='vertical-align: top;'> 
                                            <div style='text-align:left;'>Utilisateur branché : </div> 
                                        </td> 
                                        <td style='vertical-align: top;'> 
                                            <div style='text-align:left;'> 
                                                <input style='background-color: rgb(204, 204, 204);' size='30' readonly='readonly' name='info3' value='<?= htmlspecialchars($_SESSION['utilisateur'], ENT_SUBSTITUTE, "UTF-8"); ?>'> 
                                            </div> 
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td style='vertical-align: top;'> 
                                            <div style='text-align:left;'>Prénom et nom : </div> 
                                        </td> 
                                        <td style='vertical-align: top;'> 
                                            <div style='text-align:left;'> 
                                                <input style='background-color: rgb(204, 204, 204);' size='30' readonly='readonly' name='info4' value='<?= htmlentities($_SESSION['nomreel'], ENT_SUBSTITUTE, "UTF-8"); ?>'> 
                                            </div> 
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td style='vertical-align: top;'> 
                                            <div align='left'>Temps restant :</div> 
                                        </td> 
                                        <td style='vertical-align: top;'> 
                                            <div align='left'> 
                                                <form action='' name='horloge' enctype='text/plain'>
                                                    <input readonly='readonly' style='background-color: rgb(204, 204, 204);' name='clock' value='' size='3' dir='rtl' type='text'> 
                                                    min:sec avant la fermeture automatique de la session. 
                                                </form>
                                            </div> 
                                        </td> 
                                    </tr> 
                                </table> 
                            </td> 
                            <td style='vertical-align: middle;'> 
                            </td> 
                        </tr> 
                    </tbody> 
                </table> 

            </td> 
        </tr> 
    </tbody> 
</table>
<script type='text/javascript' language='JavaScript'>
    demarreHorloge();
    function versMenu(lien, jeton) {
        lien = 'index2.php?page=' + lien + "&jeton=" + jeton;
        ouvrefenetre2(lien, 500, "Copie_BD");
    }
</script>

