255 lines
11 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 "ChillPersonBundle::layout.html.twig" %}
{% import 'ChillMainBundle:Address:macro.html.twig' as address %}
{% set activeRouteKey = 'chill_person_view' %}
{#
This view should receive those arguments:
- person
#}
{% block title %}{{ 'Person details'|trans|capitalize ~ ' ' ~ person.firstName|capitalize ~
' ' ~ person.lastName }}{% endblock %}
{#
we define variables to include an edit form repeated multiple time across
the page
#}
{% set edit_tmp_name = 'ChillPersonBundle:Form:go_to_form.html.twig' %}
{% set edit_tmp_args = { 'form_path_args' : { 'person_id': person.id },
'form_path_key' : 'chill_person_general_edit' } %}
{% block personcontent %}
<div class="person-view">
<div class="grid-10 push-1 grid-mobile-12 grid-tablet-12 push-mobile-0 push-tablet-0 parent">
{% if person.memo is not empty and chill_person.fields.memo == 'visible' %}
<div class="grid-12">
<figure class="person-details">
<h2 class="chill-red">{{ 'Memo'|trans }}</h2>
<p>
<blockquote>{{ person.memo|nl2br }}</blockquote>
</p>
</figure>
</div>
{% endif %}
<div class="grid-6">
<figure class="person-details">
<h2 class="chill-red">{{ 'General information'|trans }}</h2>
<dl>
<dt>{{ 'First name'|trans }}&nbsp;:</dt>
<dd>{{ person.firstName }}</dd>
<dt>{{ 'Last name'|trans }}&nbsp;:</dt>
<dd>{{ person.lastName }}</dd>
<dt>{{ 'Gender'|trans }}&nbsp;:</dt>
<dd>{{ ( person.gender|default('Not given'))|trans }}</dd>
</dl>
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
{{ include(edit_tmp_name, edit_tmp_args) }}
{% endif %}
</figure>
</div>
<div class="grid-6">
<figure class="person-details">
<h2 class="chill-green"><i class="fa fa-birthday-cake"></i>&nbsp;{{ 'Birth information'|trans }}</h2>
<dl>
<dt>{{ 'Date of birth'|trans }}&nbsp;:</dt>
<dd>
{%- if person.birthdate is not null -%}
{{ person.birthdate|localizeddate('long', 'none') }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'Unknown date of birth'|trans }}</span>
{%- endif -%}
</dd>
{%- if chill_person.fields.place_of_birth == 'visible' -%}
<dt>{{ 'Place of birth'|trans }}&nbsp;:</dt>
<dd>{{ person.placeOfBirth }}</dd>
{%- endif -%}
{%- if chill_person.fields.country_of_birth == 'visible' -%}
<dt>{{ 'Country of birth'|trans }}&nbsp;:</dt>
<dd>{% spaceless %}
{% if person.countryOfBirth is not null %}
{{ person.countryOfBirth.name|localize_translatable_string }}
{% else %}
<span class="chill-no-data-statement">{{ 'Unknown country of birth'|trans }}</span>
{% endif %}
{% endspaceless %}</dd>
{%- endif -%}
</dl>
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
{{ include(edit_tmp_name, edit_tmp_args) }}
{% endif %}
</figure>
</div>
</div>
<div class="grid-10 push-1 grid-mobile-12 grid-tablet-12 push-mobile-0 push-tablet-0 parent">
{%- if chill_person.fields.nationality == 'visible' or chill_person.fields.spoken_languages == 'visible'-%}
<div class="grid-6">
<figure class="person-details">
<h2 class="chill-orange">{{ 'Administrative information'|trans }}</h2>
{%- if chill_person.fields.nationality == 'visible' -%}
<dl>
<dt>{{ 'Nationality'|trans }}&nbsp;:</dt>
<dd>
{% if person.nationality is not null %}
{{ person.nationality.name|localize_translatable_string }}
{% else %}
<span class="chill-no-data-statement">{{ 'Without nationality'|trans }}</span>
{% endif %}
</dd>
</dl>
{%- endif -%}
{%- if chill_person.fields.spoken_languages == 'visible' -%}
<dl>
<dt>{{'Spoken languages'|trans}}&nbsp;:</dt>
<dd>
{% if person.spokenLanguages|length == 0 %}
<span class="chill-no-data-statement">{{ 'Unknown spoken languages'|trans }}</span>
{% else %}
{% for lang in person.spokenLanguages %}
{{ lang.name|localize_translatable_string }}{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
</dd>
</dl>
{%- endif -%}
{%- if chill_person.fields.marital_status == 'visible' -%}
<dl>
<dt>{{'Marital status'|trans}}&nbsp;:</dt>
<dd>
{% if person.maritalStatus is not null %}
{{ person.maritalStatus.name|localize_translatable_string }}
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
</dd>
</dl>
{%- endif -%}
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
{{ include(edit_tmp_name, edit_tmp_args) }}
{% endif %}
</figure>
</div>
{%- endif -%}
{%- if chill_person.fields.email == 'visible' or chill_person.fields.phonenumber == 'visible' or chill_person.fields.mobilenumber == 'visible' or chill_person.fields.contact_info == 'visible' -%}
<div class="grid-6">
<figure class="person-details">
<h2 class="chill-blue"><i class="fa fa-envelope-o"></i>&nbsp;{{ 'Contact information'|trans }}</h2>
{%- if chill_person.fields.address == 'visible' -%}
<dl>
<dt>{{ 'Address'|trans }}</dt>
<dd>
{%- if person.lastAddress is not empty -%}
{{ address._render(person.lastAddress) }}
<ul class="record_actions record_actions_small">
<li>
<a href="{{ path('chill_person_address_edit', { 'person_id': person.id, 'address_id' : person.lastAddress.id } ) }}" class="sc-button has-hidden button-small bt-edit">
<span class="show-on-hover">{{ 'Edit'|trans }}</span>
</a>
</li>
<li>
<a href="{{ path('chill_person_address_list', { 'person_id': person.id } ) }}" class="sc-button has-hidden button-small">
<i class="fa fa-list" aria-hidden="true"></i><span class="show-on-hover">{{ "Addresses'history"|trans }}</span>
</a>
</li>
</ul>
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
<a href="{{ path('chill_person_address_new', { 'person_id' : person.id } ) }}" class="">
{{ 'Add an address'|trans }}
</a>
{%- endif -%}
</dd>
</dl>
{%- endif -%}
{%- if chill_person.fields.email == 'visible' -%}
<dl>
<dt>{{ 'Email'|trans }}&nbsp;:</dt>
<dd>{% if person.email is not empty %}<blockquote class="chill-user-quote">{{ person.email|nl2br }}</blockquote>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>{% endif %}</dd>
</dl>
{%- endif -%}
{%- if chill_person.fields.phonenumber == 'visible' -%}
<dl>
<dt>{{ 'Phonenumber'|trans }}&nbsp;:</dt>
<dd>{% if person.phonenumber is not empty %}<a href="tel:{{ person.phonenumber }}"><pre>{{ person.phonenumber|chill_format_phonenumber }}</pre></a>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}{% endif %}</dd>
</dl>
{% endif %}
{%- if chill_person.fields.mobilenumber == 'visible' -%}
<dl>
<dt>{{ 'Mobilenumber'|trans }}&nbsp;:</dt>
<dd>{% if person.mobilenumber is not empty %}<a href="tel:{{ person.mobilenumber }}"><pre>{{ person.mobilenumber|chill_format_phonenumber }}</pre></a>{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}{% endif %}</dd>
</dl>
{% endif %}
{%- if chill_person.fields.contact_info == 'visible' -%}
<dl>
<dt>{{ 'Notes on contact information'|trans }}&nbsp;:</dt>
<dd>{% if person.contactInfo is not empty %}{{ person.contactInfo|nl2br }}{% else %}<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>{% endif %}</dd>
</dl>
{%- endif -%}
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
{{ include(edit_tmp_name, edit_tmp_args) }}
{% endif %}
</figure>
</div>
{%- endif -%}
</div>
{% if cFGroup and (cFGroup.getActiveCustomFields|length > 0) %}
<div class="grid-10 push-1 grid-mobile-12 grid-tablet-12 push-mobile-0 push-tablet-0 parent">
<div class="grid-12 custom-fields">
<figure class="person-details">
{{ chill_custom_fields_group_widget(person.cFData, cFGroup) }}
</figure>
</div>
</div>
<div class="grid-10 push-1 grid-mobile-12 grid-tablet-12 push-mobile-0 push-tablet-0 parent">
<figure class="person-details">
{% if is_granted('CHILL_PERSON_UPDATE', person) %}
{{ include(edit_tmp_name, edit_tmp_args) }}
{% endif %}
</figure>
</div>
{% endif %}
</div> <!-- end of div.person-view -->
{% endblock %}