{% extends "payslip/payslip_base.html"  %}
{% load i18n %}
{% load url from future %}

{% block head %}<h1>{% trans "Payslip dashboard" %}</h1>{% endblock %}

{% block backlink %}{% endblock %}

{% block content %}
<a class="btn btn-success" href="{% url "payslip_generator" %}">{% trans "Generate payslip" %}</a>
<hr />
<div class="row">
    <div class="col-sm-6">
        <h2>{% trans "Companies" %}</h2>
        <p>{% trans "Host multiple companies or divisions." %}</p>
        <table class="table table-bordered table-striped">
            <tr>
                <th>{% trans "Name" %}</th>
                <th>{% trans "Action" %}</th>
            </tr>
            {% for company in companies %}
                <tr>
                    <td>{{ company }}</td>
                    <td>
                        <a class="label label-default" href="{% url "payslip_company_update" pk=company.pk %}">{% trans "Update" %}</a>
                        <a class="label label-danger" href="{% url "payslip_company_delete" pk=company.pk %}">{% trans "Delete" %}</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="2">{% trans "No companies defined." %}</td>
                </tr>
            {% endfor %}
        </table>
        <a class="btn btn-default" href="{% url "payslip_company_create" %}">{% trans "Create new company" %}</a>
    </div>
    <div class="col-sm-6">
        <h2>{% trans "Employees" %}</h2>
        <p>{% trans "Add personal data of the employees." %}</p>
        <table class="table table-bordered table-striped">
            <tr>
                <th>{% trans "Name" %}</th>
                <th>{% trans "Company" %}</th>
                <th>{% trans "Action" %}</th>
            </tr>
            {% for employee in employees %}
                <tr>
                    <td>{{ employee }}</td>
                    <td>{{ employee.company }}</td>
                    <td>
                        <a class="label label-default" href="{% url "payslip_employee_update" pk=employee.pk %}">{% trans "Update" %}</a>
                        <a class="label label-danger" href="{% url "payslip_employee_delete" pk=employee.pk %}">{% trans "Delete" %}</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="3">{% trans "No employees defined." %}</td>
                </tr>
            {% endfor %}
        </table>
        <a class="btn btn-default" href="{% url "payslip_employee_create" %}">{% trans "Create new employee" %}</a>
    </div>
</div>
<hr />
<div class="row">
    <div class="col-sm-4">
        <h2>{% trans "Payment types" %}</h2>
        <p>{% trans "Define single or recurring payment types." %}</p>
        <table class="table table-bordered table-striped">
            <tr>
                <th>{% trans "Name" %}</th>
                <th>{% trans "Action" %}</th>
            </tr>
            {% for payment_type in payment_types %}
                <tr>
                    <td>{{ payment_type }}</td>
                    <td>
                        <a class="label label-default" href="{% url "payslip_payment_type_update" pk=payment_type.pk %}">{% trans "Update" %}</a>
                        <a class="label label-danger" href="{% url "payslip_payment_type_delete" pk=payment_type.pk %}">{% trans "Delete" %}</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="2">{% trans "No payment types defined." %}</td>
                </tr>
            {% endfor %}
        </table>
        <a class="btn btn-default" href="{% url "payslip_payment_type_create" %}">{% trans "Create new payment type" %}</a>
    </div>
    <div class="col-sm-8">
        <h2>{% trans "Payments" %}</h2>
        <p>{% trans "Add payments to an employee." %}</p>
        <table class="table table-bordered table-striped">
            <tr>
                <th>{% trans "Type" %}</th>
                <th>{% trans "Employee" %}</th>
                <th>{% trans "Amount" %}</th>
                <th>{% trans "Date" %}</th>
                <th>{% trans "End" %}</th>
                <th>{% trans "Action" %}</th>
            </tr>
            {% for payment in payments %}
                <tr>
                    <td>{{ payment.payment_type }}</td>
                    <td>{{ payment.employee }}</td>
                    <td>{{ payment.amount }}</td>
                    <td>{{ payment.date|date }}</td>
                    <td>{{ payment.end_date|date }}</td>
                    <td>
                        <a class="label label-default" href="{% url "payslip_payment_update" pk=payment.pk %}">{% trans "Update" %}</a>
                        <a class="label label-danger" href="{% url "payslip_payment_delete" pk=payment.pk %}">{% trans "Delete" %}</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="6">{% trans "No payments defined." %}</td>
                </tr>
            {% endfor %}
        </table>
        <a class="btn btn-default" href="{% url "payslip_payment_create" %}">{% trans "Create new payment" %}</a>
    </div>
</div>
<hr />
<div class="row">
    <div class="col-sm-6">
        <h2>{% trans "Extra fields" %}</h2>
        <p>{% trans "Define extra field types for companies, employees and payments." %}</p>
        <table class="table table-bordered table-striped">
            <tr>
                <th>{% trans "Name" %}</th>
                <th>{% trans "Action" %}</th>
            </tr>
            {% for type in extra_field_types %}
                <tr>
                    <td>{{ type }}</td>
                    <td>
                        <a class="label label-default" href="{% url "payslip_extra_field_type_update" pk=type.pk %}">{% trans "Update" %}</a>
                        <a class="label label-danger" href="{% url "payslip_extra_field_type_delete" pk=type.pk %}">{% trans "Delete" %}</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="2">{% trans "No extra field types defined." %}</td>
                </tr>
            {% endfor %}
        </table>
        <a class="btn btn-default" href="{% url "payslip_extra_field_type_create" %}">{% trans "Create new extra field type" %}</a>
    </div>
    <div class="col-sm-6">
        <h2>{% trans "Fixed value extra fields" %}</h2>
        <p>{% trans "Define fixed values for extra field types." %}</p>
        <table class="table table-bordered table-striped">
            <tr>
                <th>{% trans "Name" %}</th>
                <th>{% trans "Action" %}</th>
            </tr>
            {% for field in fixed_value_extra_fields %}
                <tr>
                    <td>{{ field }}</td>
                    <td>
                        <a class="label label-default" href="{% url "payslip_extra_field_update" pk=field.pk %}">{% trans "Update" %}</a>
                        <a class="label label-danger" href="{% url "payslip_extra_field_delete" pk=field.pk %}">{% trans "Delete" %}</a>
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="2">{% trans "No extra fields defined." %}</td>
                </tr>
            {% endfor %}
        </table>
        <a class="btn btn-default" href="{% url "payslip_extra_field_create" %}">{% trans "Create new extra field" %}</a>
    </div>
</div>
<hr />
{% endblock %}