{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
{% load widget_tweaks %}

{% block title %}{{ object.name }}{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-sm-6">
            <h4>Details</h4>
            {% if not request.is_ajax %}
                <h3>{{ object.name }}<br/>
                    <span class="small">Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}</span>
                </h3>
                <div class="pull-right">
                    <a href="{% url 'person_update' object.pk %}" class="btn btn-primary">Edit <span
                            class="glyphicon glyphicon-pencil"></span></a>
                </div>
            {% endif %}
            <div class="">
                <dl class="dl-horizontal">
                    <dt>Name</dt>
                    <dd>{{ object.name }}</dd>

                    <dt>Phone</dt>
                    <dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>

                    <dt>Email</dt>
                    <dd><a href="mailto:{{ object.email }}">{{ object.email }}</a></dd>

                    <dt>Address</dt>
                    <dd>{{ object.address|linebreaksbr }}</dd>

                    <dt>Notes</dt>
                    <dd>{{ object.notes|linebreaksbr }}</dd>
                </dl>
            </div>
        </div>
        <div class="col-sm-6">
            <h4>Organisations</h4>
            <ul class="list-unstyled">
                {% for organisation in object.organisations %}
                    <li><a href="{% url 'organisation_detail' organisation.pk %}">{{ organisation.name }}</a></li>
                {% endfor %}
            </ul>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-12">
            <h4>Events</h4>
            {% with object.latest_events as events %}
                {% include 'RIGS/event_table.html' %}
            {% endwith %}
        </div>
    </div>
{% endblock %}

{% if request.is_ajax %}
    {% block footer %}
        <div class="row">
            <div class="col-sm-10 align-left">
                Lasted edited at {{ object.last_edited_at|date:"SHORT_DATE_FORMAT" }} by {{ object.last_edited_by.name }}
            </div>
            <div class="col-sm-2">
                <div class="pull-right">
                    <a href="{% url 'person_update' object.pk %}" class="btn btn-primary">Edit <span
                            class="glyphicon glyphicon-pencil"></span></a>
                </div>
            </div>
        </div>
    {% endblock %}
{% endif %}