{% load i18n %}
{% load custom_tags %}
<div class="card">
    <div class="card-header">
        <div class="card-header-title">
            <h2 class="title is-4">
                <a href="{{ rescue_org.get_absolute_url }}" target="_blank">{{ rescue_org.name }}</a>
            </h2>
        </div>
    </div>

    <div class="card-content">
        <div class="block">
            <p>
                <strong>{% translate 'Zuletzt geprüft:' %}</strong> {{ rescue_org.last_checked_hr }}
            </p>
            <p>
                <i class="fas fa-images"
                   aria-label="{% translate "Material verwenden?" %}"></i> {{ rescue_org.get_allows_using_materials_display }}
            </p>
            {% if rescue_org.website %}
                <a href="{{ rescue_org.website }}" id="rescue_org_website_{{ forloop.counter }}" target="_blank">
                    <i class="fas fa-globe" aria-label="{% translate "Website" %}"></i>
                    {{ rescue_org.website|domain }}
                </a>
            {% endif %}
            {% with rescue_org_counter=forloop.counter %}
                {% for species_url in rescue_org.species_urls %}
                    <p>{{ species_url.species }}:
                        <a href="{{ species_url.url }}"
                           id="species_url_{{ rescue_org_counter }}_{{ forloop.counter }}"
                           target="_blank">
                            {{ species_url.url }}
                        </a>
                    </p>
                {% endfor %}

            {% endwith %}
        </div>
        {% if set_internal_comment_available %}
            <div class="block">
                <form method="post">
                    {% csrf_token %}
                    {{ comment_forms|dictkey:rescue_org.id }}
                    <input type="hidden" name="rescue_organization_id" value="{{ rescue_org.id }}">
                    <input type="hidden" name="action" value="update_internal_comment">
                    <button class="button is-primary" type="submit">{% trans 'Kommentar speichern' %}</button>
                </form>
            </div>
        {% endif %}
        <div class="block">

            {% if set_species_url_available %}

                <form method="POST">
                    {% csrf_token %}
                    <input type="hidden" name="action" value="set_species_url">
                    <input type="hidden" name="rescue_organization_id" value={{ rescue_org.id }}>
                    {{ species_url_form }}
                    <input type="submit" class="button is-primary" value="{% trans 'Speichern' %}">
                </form>
            {% endif %}
        </div>
    </div>
    <div class="card-footer">
        <div class="card-footer-item is-confirm">
            <form method="post" id="mark_checked_{{ forloop.counter }}">
                {% csrf_token %}
                <input type="hidden"
                       name="rescue_organization_id"
                       value="{{ rescue_org.pk }}">
                <input type="hidden" name="action" value="checked">
                <button class="" type="submit">{% translate "Organisation geprüft" %}</button>
            </form>
        </div>
        <div class="card-footer-item is-warning">
            <form method="post">
                {% csrf_token %}
                <input type="hidden"
                       name="rescue_organization_id"
                       value="{{ rescue_org.pk }}">
                <input type="hidden" name="action" value="toggle_active_communication">
                <button class="" type="submit">
                    {% if rescue_org.ongoing_communication %}
                        {% translate "Aktive Kommunikation beendet" %}
                    {% else %}
                        {% translate "Aktive Kommunikation" %}
                    {% endif %}
                </button>
            </form>
        </div>
        <div class="card-footer-item is-danger">
            <a href="{% url 'rescue-organization-exclude' rescue_organization_id=rescue_org.pk %}">{% translate "Von Check exkludieren" %}</a>
        </div>
    </div>
</div>