{% extends "accounting/layout.html" %}
{% load currency_filters %}

{% block container %}
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12 main">
            <h1 class="page-header text-center">Organization Selector</h1>

            <div class="row">
                {% for orga in organizations %}
                <div class="col-md-4">
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            <h3 class="panel-title">
                                {% ifequal orga.owner request.user %}
                                <span class="label label-warning pull-right">owned</span>
                                {% else %}
                                <span class="label label-info pull-right">member</span>
                                {% endifequal %}
                                {{ orga.display_name }}
                            </h3>
                        </div>
                        <div class="panel-body">
                            <dl class="dl-horizontal">

                                <dt>Turn over (excl. tax)</dt>
                                <dd>{{ orga.turnover_excl_tax|currency|default:"-" }}</dd>

                                <dt>Due payments</dt>
                                <dd>{{ orga.overdue_total|currency|default:0 }}</dd>

                            </dl>
                            <form action="{% url 'books:organization-select' orga.pk %}" method="post">
                                {% csrf_token %}
                                <button type="submit" class="btn btn-success btn-block" role="button">Select</button>
                            </form>
                        </div>
                    </div>
                </div>
                {% endfor %}
                <div class="col-md-4">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">Add an organization</h3>
                        </div>
                        <div class="panel-body">
                            <a class="btn btn-default btn-block" role="button" href="{% url 'books:organization-create' %}">New organization</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock container %}
