{% load custom_tags_and_filters %}
{% if request.session.withdrawals %}
    <p>Current order:</p>
    <table class="table table-condensed table-striped thead-light">
        <thead>
            <tr>
                <th>Customer</th>
                <th>Project</th>
                <th>Consumable</th>
                <th>Quantity</th>
                <th aria-label="Action"></th>
            </tr>
        </thead>
        {% for withdraw in request.session.withdrawals %}
            <tr>
                <td>{{ withdraw.customer }}</td>
                <td>{{ withdraw.project }}</td>
                <td>{{ withdraw.consumable }}</td>
                <td>{{ withdraw.quantity }}</td>
                <td style="vertical-align: middle">
                    <span class="glyphicon glyphicon-remove pull-right"
                          style="cursor:pointer"
                          onclick="$('#consumables_order').load('{% url 'remove_consumable' forloop.counter0 %}')"
                          title="Remove this withdrawal"></span>
                </td>
            </tr>
        {% endfor %}
    </table>
    <div class="pull-left">
        {% url 'clear_withdrawals' as clear_withdrawals_url %}
        {% button type="delete" size="small" value="Clear" title="Remove all items in current order" onclick="$('#consumables_order').load('"|concat:clear_withdrawals_url|concat:"')" %}
    </div>
    <form action="{% url 'withdraw_consumables' %}" class="form-horizontal pull-right" method="post">
        {% csrf_token %}
        {% button type="save" size="small" value="Confirm" %}
    </form>
{% endif %}
