{% load i18n %}
{% load static %}
{% load humanize %}
{% load moonmining %}

<div class="table-responsive">
    {% if ledger|length > 0 %}
        <table class="table table-striped table-width-fix" id="table-ledger-ledger">
            <thead>
                <tr>
                    <th>{% translate 'Day' %}</th>
                    <th>{% translate 'Main' %}</th>
                    <th>{% translate 'Character' %}</th>
                    <th>{% translate 'Corporation' %}</th>
                    <th>{% translate 'Ore' %}</th>
                    <th class="text-right">{% translate 'Total Volume' %}</th>
                    <th class="text-right">{% translate 'Unit Price' %}</th>
                    <th class="text-right">{% translate 'Quantity' %}</th>
                    <th class="text-right">{% translate 'Total Price' %}</th>
                </tr>
            </thead>
            <tbody>
                {% for record in ledger %}
                    <tr>
                        <td>{{ record.day }}</td>
                        <td>{{ record.user.profile.main_character.character_name }}</td>
                        <td>{{ record.character.name }}</td>
                        <td>{{ record.corporation.name }}</td>
                        <td>{{ record.ore_type.name }}</td>
                        <td class="text-right" data-order="{{ record.total_volume }}">
                            {{ record.total_volume|intcomma }}
                        </td>
                        <td class="text-right" data-order="{{ record.ore_type.extras.current_price }}">
                            {{ record.ore_type.extras.current_price|floatformat:"0"|intcomma }}
                        </td>
                        <td class="text-right" data-order="{{ record.quantity }}">
                            {{ record.quantity|intcomma }}
                        </td>
                        <td class="text-right" data-order="{{ record.total_price }}">
                            {{ record.total_price|formatisk:"m" }}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
            <tfoot>
                <tr class="info">
                    <th>{% translate 'Total' %}</th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th class="text-right">{{ total_volume|intcomma }}</th>
                    <th class="text-right"></th>
                    <th class="text-right"></th>
                    <th class="text-right">{{ total_value|formatisk:"m" }}</th>
                </tr>
            </tfoot>
        </table>
    {% else %}
        <p class="text-muted">{% translate 'No data.' %}</p>
    {% endif %}
</div>
