<?php 
    $paramAlert = cron::getParameter();
?>

<header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light ">
    <h2 class="bd-title" id="content">
        <span>Paramètrer l'envoie des alertes emails</span>
    </h2>
</header>
<?php
echo core::filAriane(array(
    "current" => "Paramétrage des jours/heures",
    "arbo" => array(
        "Vos règles d'alertes" => NULL,
        "Paramétrage des jours/heures" => "/alertes.html"
    )
));
?>
<style>
    .table thead th {
        text-align: center;
    }
    .table td, .table th {
        text-align: center;
    }
    .hour-column {
        font-weight: bold;
    }
</style>

<?php
    $callout = [
        "type" => "info",
        "h4" => "Description",
        "p" => "Cet espace permet de sélectionner les moments ou vous voulez générer et recevoir les alertes emails provenant du CMS. A ce jour cela ne concerne que les <a href=\"/documents-my-assign.html\">documents à traiter</a>.",
    ];
    callout::print($callout);
?>

<div class="tab-content">
    <div class="form-group">
        <form method="post" action="/submit.php">
            <input type="hidden" name="from" value="alertes-emails">
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th></th>
                        <th>Lundi</th>
                        <th>Mardi</th>
                        <th>Mercredi</th>
                        <th>Jeudi</th>
                        <th>Vendredi</th>
                        <th>Samedi</th>
                        <th>Dimanche</th>
                    </tr>
                </thead>
                <tbody>
                    <!-- Heures de 00:00 à 23:00 -->
                    <?php for ($i = 0; $i < 24; $i++): ?>
                        <tr>
                            <td class="hour-column"><?= str_pad($i, 2, '0', STR_PAD_LEFT) ?>:00</td>
                            <?php for ($j = 0; $j < 7; $j++): ?>
                                <td>
                                    <input type="checkbox" name="heure[<?= $i ?>][<?= $j ?>]" value="1" <?php if(isset($paramAlert[$i][$j])){ echo "checked"; } ?>>
                                </td>
                            <?php endfor; ?>
                        </tr>
                    <?php endfor; ?>
                    <tr>
                        <td></td>
                        <td class="fw-bold">Lundi</th>
                        <th class="fw-bold">Mardi</td>
                        <td class="fw-bold">Mercredi</td>
                        <td class="fw-bold">Jeudi</td>
                        <td class="fw-bold">Vendredi</td>
                        <td class="fw-bold">Samedi</td>
                        <td class="fw-bold">Dimanche</td>
                    </tr>
                </tbody>
            </table>
            <button class="btn btn-primary btn-lg" style="width: 100%" type="submit">Enregistrer</button>
        </form>
    </div>
</div>
<br />
