{% extends request.is_ajax|yesno:"base_ajax.html,base_rigs.html" %}
{% load widget_tweaks %}
{% load paginator from filters %}
{% load url_replace from filters %}
{% load orderby from filters %}

{% block title %}People{% endblock %}

{% block content %}
    <div class="col-sm-10 col-sm-offset-1">
        <div class="row">
            <div class="col-sm-10">
                <h3>People</h3>
            </div>
            <div class="col-sm-2">
                <a href="{% url 'person_create' %}" class="btn btn-default pull-right">New <span
                        class="glyphicon glyphicon-plus"></span></a>
            </div>
            <div class="col-sm-3 col-sm-offset-9">
                <form class="form form-horizontal col-sm-12">
                    <div class="form-group">
                        <input type="search" name="q" placeholder="Search" value="{{ request.GET.q }}"
                               class="form-control"/>
                    </div>
                </form>
            </div>
            <div class="text-right col-sm-12">{% paginator %}</div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                <tr>
                    <td></td>
                    <td>Name<a href="?{% orderby request 'orderBy' 'name' %}"><span class="caret"></span></a></td>
                    <td>Email</td>
                    <td>Phone</td>
                    <td>Notes</td>
                    <td></td>
                </tr>
                </thead>
                <tbody>
                {% for person in person_list %}
                    <tr>
                        <td>{{ person.pk }}</td>
                        <td>{{ person.name }}</td>
                        <td>{{ person.email }}</td>
                        <td><a href="tel:{{ person.phone }}">{{ person.phone }}</a></td>
                        <td>{{ person.notes|yesno|capfirst }}</td>
                        <td>
                            <a href="{% url 'person_detail' person.pk %}" class="btn btn-default modal-href">
                                <span class="glyphicon glyphicon-eye-open"></span>
                            </a>
                            <a href="{% url 'person_update' person.pk %}" class="btn btn-default"><span
                                    class="glyphicon glyphicon-pencil"></span></a>
                        </td>
                    </tr>
                {% empty %}
                    <tr>
                        <td></td>
                        <td colspan="5">No people stored</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
        <div class="align-right">{% paginator %}</div>
    </div>
{% endblock %}