135 lines
5.0 KiB
Twig

{#
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
* * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "@ChillMain/layout.html.twig" %}
{% block title %}{{ 'Add a person'|trans }}{% endblock title %}
{% macro button_person_after(person) %}
{% set household = person.getCurrentHousehold %}
{% if household is not null %}
<li>
<a href="{{ path('chill_person_household_summary', { 'household_id': household.id }) }}" class="btn btn-sm btn-chill-beige"><i class="fa fa-home"></i></a>
</li>
{% endif %}
{% endmacro %}
{% block content %}
<div class="col-md-10 col-xxl person-new">
<h1>{{ 'Add a person'|trans }}</h1>
{% if alternatePersons is not empty %}
<div class="alert alert-warning flash_message">
<span>
{% transchoice alternatePersons|length with { '%nb%': alternatePersons|length } %}
%nb% person with similar name. Please verify that this is a new person
{% endtranschoice %}
</span>
</div>
<div class="flex-table">
{% for person in alternatePersons %}
<div class="item-bloc">
{{ person|chill_entity_render_box({
'render': 'bloc',
'addLink': true,
'addInfo': true,
'addAge': true,
'addAltNames': true,
'addCenter': true,
'address_multiline': false,
'customButtons': { 'after': _self.button_person_after(person) }
}) }}
</div>
{% endfor %}
</div>
{% endif %}
{{ form_start(form, {'attr' : {'id' : 'create-form'}}) }}
<div class="row mb-1" style="display:flex;">
{{ form_label(form.lastName, 'Last name'|trans) }}
<div class="col-sm-8">
{{ form_widget(form.lastName, {'attr': {'data-suggest-transform': 'uppercase_all' } }) }}
</div>
</div>
<div data-suggest-container="{{ form.lastName.vars.full_name|e('html_attr') }}" class="col-sm-8" style="margin-left: auto;"></div>
<div class="row mb-1" style="display:flex;">
{{ form_label(form.firstName, 'First name'|trans) }}
<div class="col-sm-8">
{{ form_widget(form.firstName, {'attr': {'data-suggest-transform': 'uppercase_first_letter' } }) }}
</div>
</div>
<div data-suggest-container="{{ form.firstName.vars.full_name|e('html_attr') }}" class="col-sm-8" style="margin-left: auto;"></div>
{% if form.altNames is defined %}
{% for altName in form.altNames %}
<div class="row mb-1" style="display:flex;">
{{ form_label(altName) }}
<div class="col-sm-8">
{{ form_widget(altName, {'attr': {'data-suggest-transform': 'uppercase_all' } }) }}
</div>
</div>
<div data-suggest-container="{{ altName.vars.full_name|e('html_attr') }}" class="col-sm-8" style="margin-left: auto;"></div>
{% endfor %}
{% endif %}
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
{{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }}
{{ form_row(form.phonenumber, { 'label' : 'Phonenumber'|trans }) }}
{{ form_row(form.mobilenumber, { 'label' : 'Mobilenumber'|trans }) }}
{{ form_row(form.email, { 'label' : 'Email'|trans }) }}
{% if form.center is defined %}
{{ form_row(form.center) }}
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="dropdown">
<a class="btn btn-create dropdown-toggle"
href="#" role="button" id="newPersonMore" data-bs-toggle="dropdown" aria-expanded="false">
{{ 'Add the person'|trans }}
</a>
<ul class="dropdown-menu" aria-labelledby="newPersonMore">
<li>
{{ form_widget(form.editPerson, { 'attr': { 'class': 'dropdown-item' }}) }}
</li>
<li>
{{ form_widget(form.createHousehold, { 'attr': { 'class': 'dropdown-item' }}) }}
</li>
<li>
{{ form_widget(form.createPeriod, { 'attr': { 'class': 'dropdown-item' }}) }}
</li>
</ul>
</li>
</ul>
{{ form_end(form) }}
</div>
{% endblock content %}
{% block js %}
{{ encore_entry_script_tags('page_suggest_names') }}
{% endblock js %}