{% extends kimai_context.modalRequest ? 'form.html.twig' : 'base.html.twig' %}

{% block main %}
    {% set formEditTemplate = kimai_context.modalRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
    {% set formOptions = {
        'title': (customer.id is null ? 'create'|trans : 'edit'|trans),
        'form': form,
        'back': path('admin_customer')
    } %}
    {% embed formEditTemplate with formOptions %}
        {% import "macros/form_helper.html.twig" as form_helper %}
        {% block form_body %}
            <div class="row">
                <div class="col-md-9">
                    {{ form_row(form.name) }}
                </div>
                <div class="col-md-3">
                    {{ form_row(form.color) }}
                </div>
            </div>
            {{ form_row(form.comment) }}
            <div class="row">
                <div class="col-md-4">
                    {{ form_row(form.number) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.vatId) }}
                </div>
                <div class="col-md-4">
                    {{ form_row(form.currency) }}
                </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 %}
            {% if form.teams is defined %}
            <div class="row">
                <div class="col-12">
                    {{ form_row(form.teams) }}
                </div>
            </div>
            {% endif %}
            {{ form_helper.metafields(form, null) }}
            {% embed '@theme/embeds/collapsible.html.twig' with {id: 'customer_address_settings'} %}
                {% import "macros/widgets.html.twig" as widgets %}
                {% import "macros/form_helper.html.twig" as form_helper %}
                {% block title %}{{ 'address'|trans }}{% endblock %}
                {% block body %}
                    <div class="row">
                        <div class="col-12">
                            {{ form_row(form.company) }}
                        </div>
                    </div>
                    {% if form.address is defined %}
                    <div class="row">
                        <div class="col-12">
                            {{ form_row(form.address) }}
                        </div>
                    </div>
                    {% endif %}
                    <div class="row">
                        <div class="col-12">
                            {{ form_row(form.addressLine1, {attr: {placeholder: 'address_row'|trans({'%row%': 1})}}) }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-12">
                            {{ form_row(form.addressLine2, {attr: {placeholder: 'address_row'|trans({'%row%': 2})}}) }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-12">
                            {{ form_row(form.addressLine3, {attr: {placeholder: 'address_row'|trans({'%row%': 3})}}) }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-3">
                            {{ form_row(form.postCode) }}
                        </div>
                        <div class="col-md-9">
                            {{ form_row(form.city) }}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            {{ form_row(form.country) }}
                        </div>
                        <div class="col-md-6">
                            {{ form_row(form.timezone) }}
                        </div>
                    </div>
                    {{ form_helper.metafields(form, 'address') }}
                {% endblock %}
            {% endembed %}
            {% embed '@theme/embeds/collapsible.html.twig' with {id: 'customer_invoice_settings'} %}
                {% import "macros/widgets.html.twig" as widgets %}
                {% import "macros/form_helper.html.twig" as form_helper %}
                {% block title %}{{ 'invoices'|trans }}{% endblock %}
                {% block body %}
                    {% if form.buyerReference is defined %}
                        {{ form_row(form.buyerReference) }}
                    {% endif %}
                    {% if form.invoiceTemplate is defined %}
                        {{ form_row(form.invoiceTemplate) }}
                    {% endif %}
                    {% if form.invoiceText is defined %}
                        {{ form_row(form.invoiceText) }}
                    {% endif %}
                    {{ form_helper.metafields(form, 'invoice') }}
                {% endblock %}
            {% endembed %}
            <div class="row">
                <div class="col-md-6">
                    {{ form_row(form.visible) }}
                </div>
                <div class="col-md-6">
                    {{ form_row(form.billable) }}
                </div>
            </div>
            {{ form_rest(form) }}
        {% endblock %}
    {% endembed %}
{% endblock %}
