{% extends "jgo/manage/man_list_matcher.html" %}
{% load i18n %}
{% load static %}
{% load juntagrico.config %}
{% block page_title %}
    <h3>
        {% blocktrans %}Gotte & Götti vermitteln{% endblocktrans %}
    </h3>
{% endblock %}
{% block list %}
    {% if form_result == "success" %}
        <div class="alert alert-success">
            {% trans "Neumitglied und Gotte/Götti wurden vermittelt." %}
        </div>
    {% endif %}
    <div class="mb-4">
        {% blocktrans with rp=available_godparents.count rpc=available_godparents.remaining_capacity %}
            {{ rp }} Gotte/Götti(s) kann/können noch {{ rpc }} Neumitglied(er) betreuen.
        {% endblocktrans %}
        <br>
        {% blocktrans with rc=remaining_godchildren %}
            {{ rc }} Neumitglied(er) ist/sind noch unbetreut.
        {% endblocktrans %}
    </div>
    <form action="" method="post">
        {% csrf_token %}
        <button type="submit" class="btn btn-success">
            {% trans "Vermitteln" %}
        </button>
        <table id="filter-table" class="list table" style="display: table;">
            <thead>
                <tr>
                    <th></th>
                    <th class="filter">
                        {% trans "Gotte/Götti" %}
                    </th>
                    <th>
                        {% trans "Verbleibend" %}
                    </th>
                    <th>
                        {% trans "Gleiches Depot" %}
                    </th>
                    <th>
                        {% trans "Passende Tätigkeitsbereiche" %}
                    </th>
                    <th class="filter">
                        {% trans "Neumitglied" %}
                    </th>
                    <th class="filter">
                        {% trans "Optionen" %}
                    </th>
                    <th class="filter">
                        {% trans "Angemeldet am" %}
                    </th>
                    <th class="filter">
                        {% trans "Notizen" %}
                    </th>
                    <th class="d-none">
                        {% trans "E-Mail" %}
                    </th>
                </tr>
            </thead>
            <tbody>
                {% for possible_match in management_list %}
                    {% with godparent=possible_match.godparent godchild=possible_match.godchild %}
                        <tr class="possible-match godparent-{{ godparent.id }} godchild-{{ godchild.id }}">
                            <td>
                                <input type="checkbox" id="match-{{ godparent.id }}-{{ godchild.id }}"
                                       name="match-{{ godparent.id }}-{{ godchild.id }}">
                            </td>
                            <td>
                                {% include 'jgo/snippets/match_entry.html' with subject=godparent matching_slots=godchild.slots %}
                            </td>
                            <td class="remaining-godchildren">
                                {{ godparent.remaining_godchildren }}
                            </td>
                            <td>
                                {% if possible_match.same_depot %}
                                    {% trans "Ja" %}
                                {% else %}
                                    {% trans "Nein" %}
                                {% endif %}
                            </td>
                            <td>
                                {{ possible_match.matching_areas }}
                            </td>
                            <td>
                                {% include 'jgo/snippets/match_entry.html' with subject=godchild matching_slots=godparent.slots %}
                            </td>
                            <td>
                                {{ godchild.num_options }}
                            </td>
                            <td>
                                {{ godchild.creation_date }}
                            </td>
                            <td>
                                {{ godchild.notes }}
                                <a href="{% url godchild.admin_change_url_name godchild.id %}" class="fas fa-pen"></a>
                            </td>
                            <td class="email d-none">
                                {{ godparent.member.email }},{{ godchild.member.email }}
                            </td>
                        </tr>
                    {% endwith %}
                {% endfor %}
            </tbody>
        </table>
        <button type="submit" class="btn btn-success">
            {% trans "Vermitteln" %}
        </button>
    </form>
{% endblock %}
{% block scripts %}
    {{ block.super }}
    <script type="text/javascript" src="{% static 'jgo/js/initMatchMaker.js' %}">
    </script>
{% endblock %}