{% extends 'base.html.twig' %}

{% block title %}Suplování{% endblock %}

{% block body %}

    <h2>Suplování</h2>

    <hr>

    <a href="{{path('absence.all', {dateZ: "now"|date("d-m-Y"), dateK: "now"|date("d-m-Y") })}}" class="btn btn-outline-primary float-left">Seznam veškerého suplování</a>
    <br><br>

    <div class="shadow" style="width: max-content;">
        <table id="table" data-toggle="table" data-height="500"
               class="table table-bordered table-borderless">
            <thead class="thead-light">
            <tr>
                <th data-field="zaci">Učitelé</th>
                <th> Datum </th>
                <th> Hodina </th>
                <th> Předmět </th>
                <th> Supluje </th>
                <th> Přítomen </th>
            </tr>
            </thead>
            <tbody>

            {% set dat = NULL %}
            {% set poc = 0 %}
            {% set poc2 = 0 %}

            {% for v in vysledek %}
                {% if v[0].jmeno != "Admin" %}
                    <tr>
                        <td style="background-color: #808080; color: #f2f2f2">
                            <a href="#" style="color: #0d0d0d">{{ v[0].jmeno }} {{ v[0].prijmeni }}</a>
                        </td>

                        <td>
                            {% if v[2] == null %}
                                {{ datum|date("d-M-Y") }}
                            {% else %}
                                {{ v[2].datum|date("d-M-Y") }}
                            {% endif %}
                        </td>

                        <td>
                            {% if v[2] == null %}
                                {{ doba }}
                            {% else %}
                                {{ v[2].doba }}
                            {% endif %}
                        </td>

                        <td>
                            {% if v[2] == null %}
                                {{ v[1] }}
                            {% else %}
                                {{ v[2].predmet }}
                            {% endif %}
                        </td>

                        <td>
                            {% if v[2] == null %}
                                <span>N/A</span>
                            {% else %}
                                {% for s in suplovani %}
                                    {% if s.absence.id == v[2].id %}
                                        {{ s.ucitel.jmeno }} {{ s.ucitel.prijmeni }}
                                    {% endif %}
                                {% endfor %}
                            {% endif %}
                        </td>

                        <td style="background-color: #bfbfbf">
                            {% if v[1] == null %}
                                <span>N/A</span>
                            {% else %}
                                {% if v[2] == null %}
                                    <a href="{{path('absence.createUc', {ucitel: v[0].id, date: datum|date("d-m-Y"), doba: doba.id, predmet: v[1].id}) }}">Změnit</a>
                                    (Ano)
                                {% else %}
                                    <a href="{{path('absence.createUc', {ucitel: v[0].id, date: datum|date("d-m-Y"), doba: doba.id, predmet: v[1].id}) }}">Změnit</a>
                                    {% if v[2].pritomen %}
                                        (Ano)
                                    {% else %}
                                        (Ne)
                                    {% endif %}
                                {% endif %}
                            {% endif %}
                        </td>
                    </tr>
                {% endif %}
            {% endfor %}
            </tbody>
        </table>
    </div>

    <hr>

        <div class="text-left">
            {{ form_start(form) }}

            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    {{ form_widget(form.zobrazit) }}
                </div>
                {{ form_widget(form.doba) }}
                {{ form_widget(form.datum) }}
            </div>

            {{ form_end(form) }}
        </div>

{% endblock %}

