{% if items %}
    <h4>{{ title }}</h4>
    {% if key == 'tool_usage' or key == 'area_access' or key == 'staff_charges' or key == 'trainings' or key == 'missed_reservations' %}
        <table class="invoice-details-table table table-hover">
            <thead>
                <tr>
                    <th>User</th>
                    <th>
                        {% if key == 'tool_usage' or key == 'trainings' %}
                            Tool
                        {% elif key == 'area_access' %}
                            Area
                        {% elif key == 'missed_reservations' %}
                            Reservation
                        {% elif key == 'staff_charge' %}
                            Item
                        {% endif %}
                    </th>
                    <th>Rate</th>
                    {% if key != 'missed_reservation' %}<th>Quantity</th>{% endif %}
                    {% if key == 'trainings' %}
                        <th>Date</th>
                    {% else %}
                        <th>Start</th>
                        <th>End</th>
                    {% endif %}
                    <th class="button-column-minimum">Amount</th>
                </tr>
            </thead>
            <tbody>
                {% for detail_item in items %}
                    <tr class="detail-item-{{ detail_item.get_item_type_display }}">
                        <td class="detail-item-user">{{ detail_item.user|default_if_none:'' }}</td>
                        <td class="detail-item-name">{{ detail_item.name|default_if_none:'' }}</td>
                        <td class="detail-item-rate">{{ detail_item.rate|default_if_none:'' }}</td>
                        {% if key != 'missed_reservation' %}
                            <td class="detail-item-quantity">{{ detail_item.quantity_display|default_if_none:'' }}</td>
                        {% endif %}
                        <td class="detail-item-start">{{ detail_item.start|default_if_none:'' }}</td>
                        {% if key != 'trainings' %}<td class="detail-item-end">{{ detail_item.end|default_if_none:'' }}</td>{% endif %}
                        <td class="detail-item-amount">{{ detail_item.amount_display|default_if_none:'' }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% elif key == 'consumable_withdrawals' %}
        <table class="invoice-details-table table table-hover">
            <thead>
                <tr>
                    <th>User</th>
                    <th>Supply</th>
                    <th>Rate</th>
                    <th>Quantity</th>
                    <th>Date</th>
                    <th class="button-column-minimum">Amount</th>
                </tr>
            </thead>
            <tbody>
                {% for detail_item in items %}
                    <tr class="detail-item-{{ detail_item.get_item_type_display }}">
                        <td class="detail-item-user">{{ detail_item.user|default_if_none:'' }}</td>
                        <td class="detail-item-name">{{ detail_item.name|default_if_none:'' }}</td>
                        <td class="detail-item-rate">{{ detail_item.rate|default_if_none:'' }}</td>
                        <td class="detail-item-quantity">{{ detail_item.quantity_display|default_if_none:'' }}</td>
                        <td class="detail-item-start">{{ detail_item.start|default_if_none:'' }}</td>
                        <td class="detail-item-amount">{{ detail_item.amount_display|default_if_none:'' }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% elif key == 'custom_charges' %}
        <table class="invoice-details-table table table-hover">
            <thead>
                <tr>
                    <th>User</th>
                    <th>Charge</th>
                    <th>Date</th>
                    <th class="button-column-minimum">Amount</th>
                </tr>
            </thead>
            <tbody>
                {% for detail_item in items %}
                    <tr class="detail-item-{{ detail_item.get_item_type_display }}">
                        <td class="detail-item-user">{{ detail_item.user|default_if_none:'' }}</td>
                        <td class="detail-item-name">{{ detail_item.name|default_if_none:'' }}</td>
                        <td class="detail-item-start">{{ detail_item.start|default_if_none:'' }}</td>
                        <td class="detail-item-amount">{{ detail_item.amount_display|default_if_none:'' }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endif %}
