wip render box person thirdparty display bloc

This commit is contained in:
Mathieu Jaumotte 2021-07-27 23:15:52 +02:00
parent 89dfea74b3
commit df3d32c653
12 changed files with 412 additions and 264 deletions

View File

@ -84,6 +84,7 @@ div.flex-table {
/* /*
* Bloc appearance * Bloc appearance
*/ */
/*
div.flex-bloc { div.flex-bloc {
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
@ -134,6 +135,8 @@ div.flex-bloc {
margin: auto 0; margin: auto 0;
} }
} }
*/
/* /*
* Table appearance * Table appearance

View File

@ -7,6 +7,7 @@ require('./scss/person_with_period.scss');
require('./scss/household_banner.scss'); require('./scss/household_banner.scss');
require('./scss/accompanying_period_work.scss'); require('./scss/accompanying_period_work.scss');
require('./scss/person_by_phonenumber.scss'); require('./scss/person_by_phonenumber.scss');
require('./scss/render_box.scss');
require('./svg/phone-alt-solid.svg'); require('./svg/phone-alt-solid.svg');
require('./svg/mobile-alt-solid.svg'); require('./svg/mobile-alt-solid.svg');

View File

@ -2,24 +2,11 @@
div.list-with-period, div.list-with-period,
div.list-household-members { div.list-household-members {
.chill-entity__person {
.chill-entity__person__first-name,
.chill-entity__person__last-name {
font-size: 1.3em;
font-weight: 700;
}
}
.chill_denomination {
font-size: 1.3em;
font-weight: 700;
}
div.comment { div.comment {
// for the comment for household-members // for the comment for household-members
} }
div.periods { div.periods {
div.header, div.header,
div.list-content { div.list-content {
width: calc(100% - 40px); width: calc(100% - 40px);
margin-left: 40px; margin-left: 40px;
@ -28,17 +15,17 @@ div.list-household-members {
position: relative; position: relative;
a.sc-button { a.sc-button {
position: absolute; position: absolute;
width: 30px; width: 30px;
height: 30px; height: 30px;
top: 10px; top: 10px;
left: -40px; left: -40px;
padding: 0; padding: 0;
i { i {
padding: 5px; padding: 5px;
} }
} }
abbr.referrer { abbr.referrer {
font-size: 70%; font-size: 70%;
} }
span.user { span.user {
margin-left: 1em; margin-left: 1em;
@ -51,3 +38,6 @@ div.list-household-members {
} }
} }
} }

View File

@ -0,0 +1,20 @@
div.chill-entity {
&.person {
&.label {
h3.denomination {
font-size: 1.3em;
font-weight: 700;
a {
text-decoration: none;
}
span.firstname, span.lastname, span.altname {}
span.badge {
margin-left: 0.3em;
}
}
p.moreinfo {}
}
&.row {}
&.bloc {}
}
}

View File

@ -222,103 +222,28 @@
<h2>{{ 'Resources'|trans }}</h2> <h2>{{ 'Resources'|trans }}</h2>
{% if accompanyingCourse.resources|length == 0 %} {% if accompanyingCourse.resources|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any resource for this accompanying course'|trans }}</p> <p class="chill-no-data-statement">{{ 'Any resource for this accompanying course'|trans }}</p>
{% else %} {% else %}
<div class="flex-bloc"> <div class="flex-bloc">
{% for r in accompanyingCourse.resources %} {% for r in accompanyingCourse.resources %}
<div class="item-bloc"> <div class="item-bloc">
{% if r.person %} {% if r.person %}
<div class="item-row"> {{ r.person|chill_entity_render_box({
<div class="item-col"> 'display': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
<h3> }) }}
{{ r.person.firstname ~ ' ' ~ r.person.lastname }}
<span class="badge rounded-pill bg-secondary">{{ 'Usager' }}</span>
</h3>
<p>
{% set born = (r.person.gender == 'woman') ? 'née': 'né' %}
{% set gender = (r.person.gender == 'woman') ? 'fa-venus' :
(r.person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
{% set genderTitle = (r.person.gender == 'woman') ? 'femme' :
(r.person.gender == 'homme') ? 'fa-mars' : 'neutre' %}
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle }}"></i>{{ born ~ ' le ' ~ r.person.birthdate|format_date('short') }}
</p>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li>
{% if r.person.mobilenumber %}
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ r.person.mobilenumber }}">{{ r.person.mobilenumber }}</a>
{% else %}
<i class="fa fa-li fa-phone"></i>
{% if r.person.phonenumber %}
<a href="{{ 'tel:' ~ r.person.phonenumber }}">{{ r.person.phonenumber }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
{% endif %}
</li>
<li>
<i class="fa fa-li fa-map-marker"></i>
{%- if r.person.lastAddress is not empty -%}
{{ r.person.getLastAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_view', { person_id: r.person.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{% endif %} {% endif %}
{% if r.thirdParty %} {% if r.thirdParty %}
<div class="item-row"> {{ r.thirdParty|chill_entity_render_box({
<div class="item-col"> 'display': 'bloc', 'addLink': true, 'addEntity': true, 'addInfo': true
<h3> }) }}
{{ r.thirdParty.name }}
<span class="badge rounded-pill bg-secondary">{{ 'Tiers' }}</span>
</h3>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li><i class="fa fa-li fa-envelope-o"></i>
<a href="{{ 'mailto:' ~ r.thirdParty.email }}">
{{ r.thirdParty.email|chill_print_or_message("thirdparty.No_email") }}
</a>
</li>
<li><i class="fa fa-li fa-phone"></i>
{% if r.thirdParty.telephone %}
<a href="{{ 'tel:' ~ r.thirdParty.telephone }}">{{ r.thirdParty.telephone }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'thirdparty.No_phonenumber'|trans }}</span>
{% endif %}
</li>
<li><i class="fa fa-li fa-map-marker"></i>
{%- if r.thirdParty.address is not empty -%}
{{ r.thirdParty.getAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_3party_3party_show', { thirdparty_id: r.thirdParty.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
<h2>{{ 'Social actions'|trans }}</h2> <h2>{{ 'Social actions'|trans }}</h2>

View File

@ -1,17 +1,115 @@
<span class="chill-entity chill-entity__person"> {#
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%} Template to render a person
{%- set showLink = true -%}<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">{%- endif -%} OPTIONS
<span class="chill_denomination">{{ person.firstName }}</span> * display [raw|label|row|bloc]
<span class="chill_denomination">{{ person.lastName }}</span> * addAltNames bool
* addLink bool
* addEntity bool
* addInfo bool
#}
{% macro raw(person, addAltNames) %}
<span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span>
{%- if addAltNames -%} {%- if addAltNames -%}
{%- for n in person.altNames -%} {%- for n in person.altNames -%}
{%- if loop.first -%}({% else %} {%- endif -%} {%- if loop.first -%}({% else %} {%- endif -%}
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}"> <span class="altname altname-{{ n.key }}">
{{- n.label -}} {{- n.label -}}
</span> </span>
{%- if loop.last -%}) {%- endif -%} {%- if loop.last -%}){%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- endif -%} {%- endif -%}
{%- if showLink is defined -%}</a>{%- endif -%} {% endmacro raw %}
{#- tricks to remove easily whitespace after template -#}
{%- if true -%}</span>{%- endif -%} {% macro label(person, addLink, addAltNames, addEntity, addInfo) %}
<div class="chill-entity person label">
<h3 class="denomination">
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">
{{ _self.raw(person, addAltNames) }}
</a>
{%- else -%}
{{ _self.raw(person, addAltNames) }}
{%- endif -%}
{%- if addEntity -%}
<span class="badge rounded-pill bg-secondary">{{ 'Person'|trans }}</span>
{%- endif -%}
</h3>
{%- if addInfo -%}
{% set born = (person.gender == 'woman') ? 'née le ': 'né le ' %}
{% set gender = (person.gender == 'woman') ? 'fa-venus' :
(person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
{% set genderTitle = (person.gender == 'woman') ? 'woman' :
(person.gender == 'man') ? 'man' : 'neuter' %}
<p class="moreinfo">
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle|trans }}"></i>
{{ born|trans }}
<time datetime="{{ person.birthdate|date('Y-m-d') }}">
{{ person.birthdate|format_date('medium') }}
</time>
{# TODO
{{ 'Born the %date%'|transchoice(person.genderNumeric, {
'%date%': person.birthdate|format_date("medium") }) }}
#}
</p>
{%- endif -%}
{#- tricks to remove easily whitespace after template -#}
{%- if true -%}</div>{%- endif -%}
{% endmacro label %}
{%- if display == 'raw' -%}
{{ _self.raw(person, addAltNames) }}
{%- endif -%}
{%- if display == 'label' -%}
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
{%- endif -%}
{%- if display == 'row' -%}
<div class="chill-entity person row">
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
</div>
{%- endif -%}
{%- if display == 'bloc' -%}
<div class="chill-entity person bloc">
<div class="item-row">
<div class="item-col">
{{ _self.label(person, addLink, addAltNames, addEntity, addInfo) }}
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li>
{% if person.mobilenumber %}
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ person.mobilenumber }}">{{ person.mobilenumber }}</a>
{% else %}
<i class="fa fa-li fa-phone"></i>
{% if person.phonenumber %}
<a href="{{ 'tel:' ~ person.phonenumber }}">{{ person.phonenumber }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
{% endif %}
</li>
<li>
<i class="fa fa-li fa-map-marker"></i>
{%- if person.lastAddress is not empty -%}
{{ person.getLastAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
{%- if is_granted('CHILL_PERSON_SEE', person) -%}
<ul class="record_actions">
<li><a class="btn btn-show" target="_blank" title="{{ 'Show'|trans }}"
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
</li>
</ul>
{%- endif -%}
</div>
</div>
</div>
{%- endif -%}

View File

@ -39,21 +39,24 @@
<div class="flex-table list-with-period"> <div class="flex-table list-with-period">
{% for person in persons %} {% for person in persons %}
<div class="item-bloc"> <div class="item-bloc">
<div class="item-row person"> <div class="item-row person">
<div class="item-col box-person"> <div class="item-col box-person">
<div>{{ person|chill_entity_render_box({'addLink': true}) }}</div> <div>
<div>{{ 'Born the %date%'|transchoice(person.genderNumeric, { '%date%': person.birthdate|format_date("medium") }) }}</div> {{ person|chill_entity_render_box({
'display': 'label', 'addLink': true, 'addInfo': true
}) }}
</div>
</div> </div>
<div class="item-col box-where"> <div class="item-col box-where">
<ul class="list-content fa-ul"> <ul class="list-content fa-ul">
<li><i class="fa fa-li fa-long-arrow-right"></i> <li><i class="fa fa-li fa-long-arrow-right"></i>
{{ person.center }} {{ person.center }}
</li> </li>
<li> <li>
{% if person.mobilenumber is not empty %} {% if person.mobilenumber is not empty %}
<i class="fa fa-li fa-mobile"></i> <a href="{{ 'tel:' ~ person.mobilenumber }}">{{ person.mobilenumber|chill_format_phonenumber }}</a> <i class="fa fa-li fa-mobile"></i> <a href="{{ 'tel:' ~ person.mobilenumber }}">{{ person.mobilenumber|chill_format_phonenumber }}</a>
@ -66,7 +69,7 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
</li> </li>
<li> <li>
<i class="fa fa-li fa-map-marker"></i> <i class="fa fa-li fa-map-marker"></i>
{% if person.getLastAddress is not null %} {% if person.getLastAddress is not null %}
@ -75,7 +78,7 @@
<span class="chill-no-data-statement">{{ 'No address'|trans }}</span> <span class="chill-no-data-statement">{{ 'No address'|trans }}</span>
{% endif %} {% endif %}
</li> </li>
</ul> </ul>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
@ -89,7 +92,7 @@
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
{#- 'apps' is for AccompanyingPeriodParticipationS #} {#- 'apps' is for AccompanyingPeriodParticipationS #}
@ -100,40 +103,40 @@
{%- set apps = apps|merge([app]) %} {%- set apps = apps|merge([app]) %}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
{% if apps|length > 0 %} {% if apps|length > 0 %}
{% for app in apps %} {% for app in apps %}
<div class="item-row periods"> <div class="item-row periods">
<div class="header"> <div class="header">
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': app.accompanyingPeriod.id }) }}" <a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': app.accompanyingPeriod.id }) }}"
class="btn btn-chill-green" title="{{ 'See accompanying period'|trans }}"> class="btn btn-chill-green" title="{{ 'See accompanying period'|trans }}">
<i class="fa fa-random"></i> <i class="fa fa-random"></i>
</a> </a>
<span>{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}</span> <span>{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}</span>
{% if app.accompanyingPeriod.user is not null %} {% if app.accompanyingPeriod.user is not null %}
<span class="user"> <span class="user">
<abbr class="referrer" title="{{ 'Referrer'|trans }}">ref:</abbr> <abbr class="referrer" title="{{ 'Referrer'|trans }}">ref:</abbr>
{{ app.accompanyingPeriod.user|chill_entity_render_box }} {{ app.accompanyingPeriod.user|chill_entity_render_box }}
</span> </span>
{% endif %} {% endif %}
</div> </div>
<div class="list-content"> <div class="list-content">
{% for issue in app.accompanyingPeriod.socialIssues|slice(0,2) %} {% for issue in app.accompanyingPeriod.socialIssues|slice(0,2) %}
<span>{{ issue|chill_entity_render_box }}</span> <span>{{ issue|chill_entity_render_box }}</span>
{% endfor %} {% endfor %}
{% if app.accompanyingPeriod.socialIssues|length > 2 %} {% if app.accompanyingPeriod.socialIssues|length > 2 %}
<span class="more">{{ 'and %number% other'|transchoice(app.accompanyingPeriod.socialIssues|length-2) }}</span> <span class="more">{{ 'and %number% other'|transchoice(app.accompanyingPeriod.socialIssues|length-2) }}</span>
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}
@ -162,7 +165,7 @@
</li> </li>
{% endif %} {% endif %}
</ul> </ul>
{% else %} {% else %}
<ul class="record_actions"> <ul class="record_actions">
<li> <li>

View File

@ -2,7 +2,7 @@
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014-2019, Champs Libres Cooperative SCRLFS, * Copyright (C) 2014-2019, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop> * <http://www.champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -35,7 +35,7 @@ class PersonRender extends AbstractChillEntityRender
private ConfigPersonAltNamesHelper $configAltNamesHelper; private ConfigPersonAltNamesHelper $configAltNamesHelper;
private EngineInterface $engine; private EngineInterface $engine;
public function __construct( public function __construct(
ConfigPersonAltNamesHelper $configAltNamesHelper, ConfigPersonAltNamesHelper $configAltNamesHelper,
EngineInterface $engine EngineInterface $engine
@ -43,9 +43,9 @@ class PersonRender extends AbstractChillEntityRender
$this->configAltNamesHelper = $configAltNamesHelper; $this->configAltNamesHelper = $configAltNamesHelper;
$this->engine = $engine; $this->engine = $engine;
} }
/** /**
* *
* @param Person $person * @param Person $person
* @param array $options * @param array $options
* @return string * @return string
@ -56,13 +56,16 @@ class PersonRender extends AbstractChillEntityRender
[ [
'person' => $person, 'person' => $person,
'addAltNames' => $this->configAltNamesHelper->hasAltNames(), 'addAltNames' => $this->configAltNamesHelper->hasAltNames(),
'addLink' => $options['addLink'] ?? false 'addLink' => $options['addLink'] ?? false,
'addEntity' => $options['addEntity'] ?? false,
'addInfo' => $options['addInfo'] ?? false,
'display' => $options['display'] ?? 'raw'
] ]
); );
} }
/** /**
* *
* @param Person $person * @param Person $person
* @param array $options * @param array $options
* @return string * @return string
@ -76,7 +79,7 @@ class PersonRender extends AbstractChillEntityRender
protected function addAltNames(Person $person, bool $addSpan) protected function addAltNames(Person $person, bool $addSpan)
{ {
$str = ''; $str = '';
if ($this->configAltNamesHelper->hasAltNames()) { if ($this->configAltNamesHelper->hasAltNames()) {
$altNames = $this->configAltNamesHelper->getChoices(); $altNames = $this->configAltNamesHelper->getChoices();
$isFirst = true; $isFirst = true;
@ -94,18 +97,18 @@ class PersonRender extends AbstractChillEntityRender
$str .= '<span class="chill-entity__person__alt-name chill-entity__person__altname--'.$altName->getKey().'">'; $str .= '<span class="chill-entity__person__alt-name chill-entity__person__altname--'.$altName->getKey().'">';
} }
$str .= $altName->getLabel(); $str .= $altName->getLabel();
if ($addSpan) { if ($addSpan) {
$str .= "</span>"; $str .= "</span>";
} }
} }
} }
if (!$isFirst) { if (!$isFirst) {
$str .= ")"; $str .= ")";
} }
} }
return $str; return $str;
} }

View File

@ -1,51 +1,79 @@
div.chill-entity {
&.thirdparty {
&.label {
h3.denomination {
font-size: 1.3em;
font-weight: 700;
a {
text-decoration: none;
}
span.name {}
span.badge {
margin-left: 0.3em;
}
}
p.moreinfo {}
}
&.row {}
&.bloc {}
/*
border: 1px solid black;
background-color: rgba(255, 255, 255, 0.65);
padding: 1em;
margin: 1em 0;
max-width: 500px;
div.name {
font-variant: small-caps;
}
div.category {
margin: 0.5em 0;
font-size: 85%;
span.category {
font-style: italic;
}
span::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'ForkAwesome';
content: '\f02e';
font-style: normal;
}
}
div.comment {
font-size: 85%;
font-style: italic;
}
div.chill_address {
div.chill_address_address::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'ForkAwesome';
content: '\f015';
}
}
div.contact {
font-variant: small-caps;
span::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'ForkAwesome';
}
span.email::before {
content: '\f1fa';
}
span.telephone::before {
content: '\f095';
}
}
*/
div.chill_contact {
border: 1px solid black;
background-color: rgba(255, 255, 255, 0.65);
padding: 1em;
margin: 1em 0;
max-width: 500px;
div.chill_contact_name {
font-variant: small-caps;
}
div.chill_contact_category {
margin: 0.5em 0;
font-size: 85%;
span.category {
font-style: italic;
} }
span::before { }
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'ForkAwesome';
content: '\f02e';
font-style: normal;
}
}
div.chill_contact_comment {
font-size: 85%;
font-style: italic;
}
div.chill_address {
div.chill_address_address::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'ForkAwesome';
content: '\f015';
}
}
div.chill_contact_contact {
font-variant: small-caps;
span::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'ForkAwesome';
}
span.email::before {
content: '\f1fa';
}
span.telephone::before {
content: '\f095';
}
}
}

View File

@ -0,0 +1,130 @@
{#
Template to render a thirdparty
OPTIONS
* display [raw|label|row|bloc]
* with_valid_from bool
* addAltNames bool
* addLink bool
* addEntity bool
* addInfo bool
#}
{% macro raw(thirdparty) %}
<span class="name">{{ thirdparty.name }}</span>
{% endmacro raw %}
{% macro label(thirdparty, addLink, addEntity, addInfo, options) %}
<div class="chill-entity thirdparty label">
<h3 class="denomination">
{%- if addLink and is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) -%}
<a href="{{ chill_path_add_return_path('chill_3party_3party_show', { 'thirdparty_id': thirdparty.id }) }}">
{{ _self.raw(thirdparty) }}
</a>
{%- else -%}
{{ _self.raw(thirdparty) }}
{%- endif -%}
{%- if addEntity -%}
<span class="badge rounded-pill bg-secondary">{{ 'Third party'|trans }}</span>
{%- endif -%}
</h3>
{# AVANT
<div class="name">
{{ _self.raw(thirdparty) }}
</div>
<div class="category">
{% for type in thirdparty.type %}
<span class="category">
{{ ('chill_3party.key_label.'~type)|trans }}
</span>
{% endfor %}
</div>
{% if thirdparty.comment is not empty %}
<div class="comment">
{{ thirdparty.comment }}
</div>
{% endif %}
{% if thirdparty.address %}
<div class="chill_address">
<div class="chill_address_address">
{% if thirdparty.address.streetAddress1 %}<p class="street street1">{{ thirdparty.address.streetAddress1 }}</p>{% endif %}
{% if thirdparty.address.streetAddress2 is not empty %}<p class="street street2">{{ thirdparty.address.streetAddress2 }}</p>{% endif %}
{% if thirdparty.address.postCode is not empty %}
<p class="postalCode"><span class="code">{{ thirdparty.address.postCode.code }}</span> <span class="name">{{ thirdparty.address.postCode.name }}</span></p>
<p class="country">{{ thirdparty.address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
</div>
{%- if options['with_valid_from'] is defined and options['with_valid_from'] == true -%}
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : thirdparty.address.validFrom|format_date('long') } ) }}</span>
{%- endif -%}
</div>
{% endif %}
{% if thirdparty.email or thirdparty.telephone is not empty %}
<div class="contact">
<span class="email">
<a href="mailto:{{ thirdparty.email }}">{{ thirdparty.email }}</a>
</span>
<span class="telephone">
<a href="tel:{{ thirdparty.telephone }}">{{ thirdparty.telephone|chill_format_phonenumber }}</a>
</span>
</div>
{% endif %}
#}
{#- tricks to remove easily whitespace after template -#}
{%- if true -%}</div>{%- endif -%}
{% endmacro label %}
{%- if display == 'raw' -%}
{{ _self.raw(thirdparty) }}
{%- endif -%}
{%- if display == 'label' -%}
{{ _self.label(thirdparty, addLink, addEntity, addInfo, options) }}
{%- endif -%}
{%- if display == 'row' -%}
<div class="chill-entity thirdparty row">
{{ _self.label(thirdparty, addLink, addEntity, addInfo, options) }}
</div>
{%- endif -%}
{%- if display == 'bloc' -%}
<div class="chill-entity thirdparty bloc">
<div class="item-row">
<div class="item-col">
{{ _self.label(thirdparty, addLink, addEntity, addInfo, options) }}
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li><i class="fa fa-li fa-envelope-o"></i>
<a href="{{ 'mailto:' ~ thirdparty.email }}">
{{ thirdparty.email|chill_print_or_message("thirdparty.No_email") }}
</a>
</li>
<li><i class="fa fa-li fa-phone"></i>
{% if thirdparty.telephone %}
<a href="{{ 'tel:' ~ thirdparty.telephone }}">{{ thirdparty.telephone|chill_format_phonenumber }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'thirdparty.No_phonenumber'|trans }}</span>
{% endif %}
</li>
<li><i class="fa fa-li fa-map-marker"></i>
{%- if thirdparty.address is not empty -%}
{{ thirdparty.getAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_3party_3party_show', { thirdparty_id: thirdparty.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
</div>
{%- endif -%}

View File

@ -1,52 +0,0 @@
{# template to render a person #}
{%- if options['only_denomination'] == true -%}
<div class="chill_denomination">
{{ contact.name }}
</div>
{%- else -%}
<div class="chill_contact">
<div class="chill_contact_name">
{{ contact.name }}
</div>
<div class="chill_contact_category">
{% for type in contact.type %}
<span class="category">
{{ ('chill_3party.key_label.'~type)|trans }}
</span>
{% endfor %}
</div>
{% if contact.comment is not empty %}
<div class="chill_contact_comment">
{{ contact.comment }}
</div>
{% endif %}
{% if contact.address %}
<div class="chill_address">
<div class="chill_address_address">
{% if contact.address.streetAddress1 %}<p class="street street1">{{ contact.address.streetAddress1 }}</p>{% endif %}
{% if contact.address.streetAddress2 is not empty %}<p class="street street2">{{ contact.address.streetAddress2 }}</p>{% endif %}
{% if contact.address.postCode is not empty %}
<p class="postalCode"><span class="code">{{ contact.address.postCode.code }}</span> <span class="name">{{ contact.address.postCode.name }}</span></p>
<p class="country">{{ contact.address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
</div>
{%- if options['with_valid_from'] == true -%}
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : contact.address.validFrom|format_date('long') } ) }}</span>
{%- endif -%}
</div>
{% endif %}
{% if contact.email or contact.telephone is not empty %}
<div class="chill_contact_contact">
<span class="email">
<a href="mailto:{{ contact.email }}">{{ contact.email }}</a>
</span>
<span class="telephone">
<a href="tel:{{ contact.telephone }}">{{ contact.telephone|chill_format_phonenumber }}</a>
</span>
</div>
{% endif %}
</div>
{%- endif -%}

View File

@ -2,7 +2,7 @@
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014-2020 , Champs Libres Cooperative SCRLFS, * Copyright (C) 2014-2020 , Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop> * <http://www.champs-libres.coop>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -25,7 +25,7 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Symfony\Bridge\Twig\TwigEngine; use Symfony\Bridge\Twig\TwigEngine;
/** /**
* *
* *
*/ */
class ThirdPartyRender extends AbstractChillEntityRender class ThirdPartyRender extends AbstractChillEntityRender
@ -35,37 +35,36 @@ class ThirdPartyRender extends AbstractChillEntityRender
* @var TwigEngine * @var TwigEngine
*/ */
protected $templating; protected $templating;
public function __construct(TwigEngine $templating) public function __construct(TwigEngine $templating)
{ {
$this->templating = $templating; $this->templating = $templating;
} }
/** /**
* *
* @param ThirdParty $entity * @param ThirdParty $entity
* @param array $options * @param array $options
* @return string * @return string
*/ */
public function renderBox($entity, array $options): string public function renderBox($entity, array $options): string
{ {
$params = \array_merge(
[ 'with_valid_from' => true ],
$options
);
return return
$this->getDefaultOpeningBox('_3party'). $this->getDefaultOpeningBox('_3party').
$this->templating->render('@ChillThirdParty/ThirdParty/_render.html.twig', [ $this->templating->render('@ChillThirdParty/Entity/thirdparty.html.twig', [
'contact' => $entity, 'thirdparty' => $entity,
'options' => $params 'with_valid_from' => $options['with_valid_from'] ?? true,
'addLink' => $options['addLink'] ?? false,
'addEntity' => $options['addEntity'] ?? false,
'addInfo' => $options['addInfo'] ?? false,
'display' => $options['display'] ?? 'raw',
'options' => $options
]). ]).
$this->getDefaultClosingBox(); $this->getDefaultClosingBox();
} }
/** /**
* *
* @param ThirdParty $entity * @param ThirdParty $entity
* @param array $options * @param array $options
* @return string * @return string