{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "customer/actions.html.twig" as actions %}

{% block page_title %}{{ 'customers'|trans }}{% endblock %}
{% block page_actions %}{{ actions.customer(customer, 'edit') }}{% endblock %}

{% block main %}
    {% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
    {% set formOptions = {
        'title': (customer.id is null ? 'create'|trans : 'edit'|trans({}, 'actions')),
        'form': form,
        'back': path('admin_customer')
    } %}
    {% embed formEditTemplate with formOptions %}
        {% block form_body %}
            <div class="row">
                <div class="col-md-10">
                    {{ form_row(form.name) }}
                </div>
                <div class="col-md-2">
                    {{ form_row(form.color) }}
                </div>
            </div>
            {{ form_row(form.comment) }}
            {{ form_row(form.address) }}
            <div class="row">
                <div class="col-md-4">
                    {{ form_row(form.company) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.number) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.vatId) }}
                </div>
            </div>
            <div class="row">
                <div class="col-md-4">
                    {{ form_row(form.country) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.currency) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.timezone) }}
                </div>
            </div>
            <div class="row">
                <div class="col-md-4">
                    {{ form_row(form.contact) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.email) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.homepage) }}
                </div>
            </div>
            <div class="row">
                <div class="col-md-4">
                    {{ form_row(form.mobile) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.phone) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.fax) }}
                </div>
            </div>
            {% if form.budgetType is defined %}
                <div class="row">
                    {% if form.budget is defined %}
                        <div class="col-md-4">
                            {{ form_row(form.budget) }}
                        </div>
                    {% endif %}
                    {% if form.timeBudget is defined %}
                        <div class="col-md-4">
                            {{ form_row(form.timeBudget) }}
                        </div>
                    {% endif %}
                    <div class="col-md-4">
                        {{ form_row(form.budgetType) }}
                    </div>
                </div>
            {% endif %}
            <div class="row">
                <div class="col-md-6">
                    {{ form_row(form.visible) }}
                </div>
                <div class="col-md-6">
                    {{ form_row(form.billable) }}
                </div>
            </div>
            {% if form.metaFields is defined and form.metaFields is not empty %}
                {% for meta in form.metaFields|sort((a, b) => a.vars.data.order <=> b.vars.data.order) %}
                    {{ form_row(meta) }}
                {% endfor %}
            {% endif %}
            {{ form_widget(form) }}
        {% endblock %}
    {% endembed %}
{% endblock %}
