{% load i18n %}
{% load humanize %}
{% load evelinks %}
{% load ledger %}

<!--############################## SUMMARY #######################-->
<div class="tab-pane panel panel-default active" id="tab-summary">
    <div class="card-body modal-tab">
        {% for key, label in character.income_types %}
            {% with value=character|get_item:key %}
                {% if value %}
                    <div class="row description-row">
                        <div class="col-sm-6 {% if label == 'Not Defined Category' %}text-warning{% endif %}">
                            {{ label }}
                            <i class="fa-regular fa-circle-question"
                                data-bs-toggle="info-popover"
                                data-bs-html="true"
                                data-bs-trigger="hover focus"
                                data-bs-placement="top"
                                title="{% trans 'Included Categories' %}"
                                data-bs-content="{{ value.ref_types|join:', ' }}">
                            </i>
                            :
                        </div>                        <div class='col-sm-4 text-end'>
                            <span class="{% if not key == 'mining_income' %}text-success{% else %}text-info{% endif %}">
                            {% if key == 'mining_income' %}
                                <i class="fa-regular fa-circle-question"
                                    data-tooltip-toggle="info-tooltip" data-bs-placement="right"
                                    title="{% trans 'This amount is displayed for information only' %}"
                                >
                                </i>
                            {% endif %}
                            {{ value.total_amount|floatformat:0|intcomma }}
                            </span> ISK
                        </div>
                    </div>
                {% endif %}
            {% endwith %}
        {% endfor %}

        <!--############################## Costs #######################-->

        {% for key, label in character.cost_types %}
            {% with value=character|get_item:key %}
                {% if value %}
                    <div class="row description-row">
                        <div class="col-sm-6 {% if label == 'Not Defined Category' %}text-warning{% endif %}">
                            {{ label }} {% trans "Cost" %}
                            <i class="fa-regular fa-circle-question"
                                data-bs-toggle="info-popover"
                                data-bs-html="true"
                                data-bs-trigger="hover focus"
                                data-bs-placement="top"
                                title="{% trans 'Included Categories' %}"
                                data-bs-content="{{ value.ref_types|join:', ' }}">
                            </i>
                            :
                        </div>
                        <div class='col-sm-4 text-end'>
                            <span class="text-danger">{{ value.total_amount|floatformat:0|intcomma }}</span> ISK
                        </div>
                    </div>
                {% endif %}
            {% endwith %}
        {% endfor %}

        <!--############################## SUMMARY #######################-->
        <hr>
        <div class="row description-row">
            <div class="col-sm-6">{% trans "Summary" %}:</div>
            <div class='col-sm-4 text-end'>
            <span class="{% if character.summary.total_amount < 0 %}text-danger{% else %}text-success{% endif %}">
                {{ character.summary.total_amount|floatformat:0|intcomma }}
            </span> ISK</div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function() {
        $('[data-bs-toggle="info-popover"]').popover({
            trigger: 'hover',
            html: true,
        });
        $('[data-tooltip-toggle="info-tooltip"]').tooltip({
            trigger: 'hover'
        });
    });
</script>
