{% extends 'base_widget.html.twig' %}

{% block title %}Reference{% endblock %}

{% block body %}
    {% set referer = app.request.get('ref')|default('/') %}

    <div class="reference-wrapper" data-controller="reference" data-ref="{{ referer }}">
        {% form_theme referenceForm 'bootstrap_4_layout.html.twig' %}
       {{ form_start(referenceForm) }}
            {{ form_row(referenceForm._token) }}
            <div class="form-group mb-2">
                {{ form_label(referenceForm.autorName, 'ФИО налогоплательщика:', {'label_attr': {'class': 'mb-0'}}) }}
                {{ form_widget(referenceForm.autorName, {'attr': {'class': 'form-control'}}) }}
                <div class="msg-valid valid-reference_autorName"></div>
            </div>
            <div class="form-group mb-2">
                {{ form_label(referenceForm.phone, 'Телефон:', {'label_attr': {'class': 'mb-0'}}) }}
                {{ form_widget(referenceForm.phone, {'attr': {
                    'class': 'form-control',
                    'data-controller': 'inputMask'
                }}) }}
                <div class="msg-valid valid-reference_phone"></div>
            </div>
            <div class="form-group mb-2">
                {{ form_label(referenceForm.birthDate, 'Дата рождения налогоплательщика:', {'label_attr': {'class': 'mb-0'}}) }}
                {{ form_widget(referenceForm.birthDate, {'attr': {
                    'class': 'form-control',
                    'data-controller': 'datePicker',
                    'range': 'false'
                }}) }}
                <div class="msg-valid valid-reference_birthDate"></div>
            </div>
            <div class="form-group mb-2">
                {{ form_label(referenceForm.inn, 'ИНН налогоплательщика:', {'label_attr': {'class': 'mb-0'}}) }}
                {{ form_widget(referenceForm.inn, {'attr': {'class': 'form-control'}}) }}
                <div class="msg-valid valid-reference_inn"></div>
            </div>

            <div class="responsible_filials responsible_filial_0">
                <div class="form-group mb-2">
                    {{ form_label(referenceForm.responsible, 'Получаю документы за:', {'label_attr': {'class': 'mb-0'}}) }}
                    {{ form_widget(referenceForm.responsible, {'attr': {
                        'class': 'reference-responsible form-control',
                        'data-count' : '0',
                    }}) }}
                </div>
                <div class="responsible_user"></div>
                <div class="form-group mb-2">
                    {{ form_label(referenceForm.filial, 'Клиника, где оказывались услуги:', {'label_attr': {'class': 'mb-0'}}) }}
                    {{ form_widget(referenceForm.filial, {'attr': {
                        'class': 'reference-filial form-control',
                    }}) }}
                    <div class="msg-valid valid-reference_filial"></div>
                </div>
                <div class="form-group mb-2">
                    {{ form_label(referenceForm.periodFirst, 'Начало периода:', {'label_attr': {'class': 'mb-0'}}) }}
                    {{ form_widget(referenceForm.periodFirst, {'attr': {
                        'class': 'reference-period-first',
                        'type' : 'date',
                        'value' : "now"|date_modify("-1 year")|date("Y-01-01")
                    }}) }}
                    <div class="msg-valid valid-reference_period-first"></div>
                </div>
                <div class="form-group mb-2">
                    {{ form_label(referenceForm.periodLast, 'Конец периода:', {'label_attr': {'class': 'mb-0'}}) }}
                    {{ form_widget(referenceForm.periodLast, {'attr': {
                        'class': 'reference-period-last',
                        'type' : 'date',
                        'value' : "now"|date_modify("-1 year")|date("Y-12-31") 
                    }}) }}
                    <div class="msg-valid valid-reference_period-last"></div>
                </div>
            </div>
            <div class="form-group mb-2">
                {{ form_label(referenceForm.sending, 'Пакет документов прошу выдать:', {'label_attr': {'class': 'mb-0'}}) }}
                {{ form_widget(referenceForm.sending, {'attr': {
                    'class': 'reference-sending',
                }}) }}
            </div>
            <div class="reference_sending">
                <div class="filial-sending">
                    <div class="form-group mb-2">
                        {{ form_label(referenceForm.filialSending, 'Клиника, где получить справку:', {'label_attr': {'class': 'mb-0'}}) }}
                        {{ form_widget(referenceForm.filialSending, {'attr': {'class': 'form-control'}}) }}
                        <div class="msg-valid valid-reference_filialSending"></div>
                    </div>
                </div>
                <div class="postal"></div>
            </div>
            <div class="accept">
                <div class="form-group">
                    <a class="staff-info__review license-link" href="{{ getPoliticaLink(regionId) }}" target="_blank">Отправляя данные, вы подтверждаете согласие на обработку персональных данных и принимаете условия политики их обработки</a>
                </div>
            </div>
            <button type="button" class="submit btn btn-secondary">Подать заявку</button>
            <button type="button" data-count="0" class="add-filial btn btn-outline-secondary">Добавить клинику</button>
       {{ form_end(referenceForm) }}
    </div>
{% endblock %}
