{% extends 'detail_view.html' %}
{% load i18n %}
{% block button_bar %}
    {{ block.super }}
    <a class="button" id="add_office_button"><span class="icon-plus on-left"></span>{% trans 'office'|capfirst %}</a>
{% endblock button_bar %}

{% block scripts %}
    {{ block.super }}
    <script>
        var office_base_url = '{% url 'client office_create' %}?forClient={{ object.id }}'
        $(document).ready(function () {
            $('#add_office_button').on('click', function () {

                $.Dialog({
                    shadow: true,
                    icon: '<span class="icon-help"></span>',
                    title: '',
                    padding: 10,
                    width: 340,
                    height: 150,
                    draggable: true,
                    content: '<p>{% trans 'Should the new office inherit the existing address data?' %}</p>' +
                            '<table align="right"><tr><td>' +
                    '<a class="button" onclick="window.location.href=office_base_url+\'&reuse_addr=1\'">{% trans 'yes'|capfirst %}</a></td>' +
                    '<td><a class="button" onclick="window.location.href=office_base_url;">{% trans 'no'|capfirst %}</a></td>' +
                    '<td><a class="button" onclick="$.Dialog.close();">{% trans 'cancel'|capfirst %}</a></td></table>'
                });
            });
        });
    </script>
{% endblock scripts %}


{% block extra %}
    {% with related_list=object.offices.all related_table_id='offices_table' %}
        {% include 'related_snippet.html' %}
    {% endwith %}
{% endblock extra %}