{% extends 'base.html' %}
{% load i18n l10n static fontawesome_5 humanize ksp_filters %}

{% block head %}

    {% comment %}
        dal documentation (django-autocomplete-light) states using form.media for adding needed scripts.
        This does not work properly with modal forms, as the scripts are not loaded properly inside the modal.
        Therefore the script linkages from form.media have been extracted and put inside dal/scripts.html to ensure
        these scripts are loaded when needed.
    {% endcomment %}
    {% include 'dal/scripts.html' %}
{% endblock %}

{% block body %}

    <div id="detail-header" class="row">
        <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
            <h3>{% trans 'Compensation' %}<br> {{obj.identifier}}</h3>
        </div>
        <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
            {% include 'compensation/detail/compensation/includes/controls.html' %}
        </div>
    </div>
    <hr>
    <div id="data" class="row">
        <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
            <div class="table-container">
                <table class="table table-hover">
                    <tr>
                        <th class="w-25" scope="row">{% trans 'Title' %}</th>
                        <td class="align-middle">{{obj.title}}</td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'compensates intervention' %}</th>
                        <td class="align-middle">
                            <a href="{% url 'intervention:detail' obj.intervention.id %}">
                                {{obj.intervention.identifier}}
                            </a>
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'Is PIK' %}</th>
                        <td class="align-middle">
                            {% if obj.is_pik %}
                                {% trans 'Yes' %}
                            {% else %}
                                {% trans 'No' %}
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'Is CEF compensation' %}</th>
                        <td class="align-middle">
                            {% if obj.is_cef %}
                                {% trans 'Yes' %}
                            {% else %}
                                {% trans 'No' %}
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'Is Coherence keeping compensation' %}</th>
                        <td class="align-middle">
                            {% if obj.is_coherence_keeping %}
                                {% trans 'Yes' %}
                            {% else %}
                                {% trans 'No' %}
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'Checked' %}</th>
                        <td class="align-middle">
                            {% if obj.intervention.checked is None %}
                                <span>
                                    {% fa5_icon 'star' 'far' %}
                                </span>
                                {% if last_checked %}
                                    <span class="rlp-gd-inv" title="{{last_checked_tooltip}}">
                                        {% fa5_icon 'star' 'fas' %}
                                    </span>
                                {% endif %}
                            {% else %}
                                <span class="check-star" title="{% trans 'Checked on '%} {{obj.intervention.checked.timestamp}} {% trans 'by' %} {{obj.intervention.checked.user}}">
                                    {% fa5_icon 'star' %}
                                </span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'Recorded' %}</th>
                        <td class="align-middle">
                            {% if obj.intervention.recorded is None %}
                                <span title="{% trans 'Not recorded yet' %}">
                                    {% fa5_icon 'bookmark' 'far' %}
                                </span>
                            {% else %}
                                <span class="registered-bookmark" title="{% trans 'Recorded on '%} {{obj.intervention.recorded.timestamp}} {% trans 'by' %} {{obj.intervention.recorded.user}}">
                                    {% fa5_icon 'bookmark' %}
                                </span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'Last modified' %}</th>
                        <td class="align-middle">
                            {% if obj.modified %}
                                {{obj.modified.timestamp|default_if_none:""}}
                                <br>
                                {{obj.modified.user.username}}
                            {% else %}
                                {{obj.created.timestamp|default_if_none:""}}
                                <br>
                                {{obj.created.user.username}}
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">{% trans 'Shared with' %}</th>
                        <td class="align-middle">
                            {% for team in obj.intervention.shared_teams %}
                                {% include 'user/includes/team_data_modal_button.html' %}
                            {% endfor %}
                            <hr>
                            {% if is_entry_shared %}
                                {% for user in obj.intervention.shared_users %}
                                    {% include 'user/includes/contact_modal_button.html' %}
                                {% endfor %}
                            {% else %}
                            <span title="{% trans 'The data must be shared with you, if you want to see which other users have shared access as well.' %}">
                                {% fa5_icon 'eye-slash' %}
                                {{obj.intervention.users.count}} {% trans 'other users' %}
                            </span>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
            <div class="col">
                <div class="row">
                    <div class="col-sm-12">
                        {% include 'map/geom_form.html' %}
                    </div>
                </div>
                <div class="row">
                    {% include 'konova/includes/parcels/parcels.html' %}
                </div>
                <div class="row">
                    {% include 'konova/includes/comment_card.html' %}
                </div>
            </div>
        </div>
    </div>
    <hr>
    <div id="related_data">
        <div class="row">
            <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
                {% include 'compensation/detail/compensation/includes/states-before.html' %}
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
                {% include 'compensation/detail/compensation/includes/states-after.html' %}
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
                {% include 'compensation/detail/compensation/includes/actions.html' %}
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
                {% include 'compensation/detail/compensation/includes/deadlines.html' %}
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 col-md-12 col-lg-12 col-xl-6">
                {% include 'compensation/detail/compensation/includes/documents.html' %}
            </div>
        </div>
    </div>


{% with 'btn-modal' as btn_class %}
    {% include 'modal/modal_form_script.html' %}
{% endwith %}

{% endblock %}