household: add household accompanying periods

This commit is contained in:
nobohan 2021-06-29 19:41:00 +02:00
parent 5553c7314c
commit f05f7415bd
7 changed files with 211 additions and 147 deletions

View File

@ -30,7 +30,7 @@ class HouseholdController extends AbstractController
$this->translator = $translator;
$this->positionRepository = $positionRepository;
}
/**
* @Route(
* "/{household_id}/summary",
@ -47,7 +47,7 @@ class HouseholdController extends AbstractController
->findByActiveOrdered()
;
// little performance improvement:
// little performance improvement:
// initialize members collection, which will avoid
// some queries
$household->getMembers()->initialize();
@ -67,6 +67,31 @@ class HouseholdController extends AbstractController
);
}
/**
* @Route(
* "/{household_id}/accompanying-period",
* name="chill_person_household_accompanying_period",
* methods={"GET", "HEAD"}
* )
* @ParamConverter("household", options={"id" = "household_id"})
*/
public function accompanyingPeriod(Request $request, Household $household)
{
// TODO ACL
$members = $household->getMembers();
foreach($members as $m) {
$accompanyingPeriods = $m->getPerson()->getAccompanyingPeriods();
}
return $this->render('@ChillPerson/Household/accompanying_period.html.twig',
[
'household' => $household,
'accompanying_periods' => $accompanyingPeriods
]
);
}
/**
* @Route(
* "/{household_id}/addresses",

View File

@ -9,22 +9,22 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class HouseholdMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var TranslatorInterface
*/
protected $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
public static function getMenuIds(): array
{
return [ 'household' ];
}
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
{
$household = $parameters['household'];
@ -35,15 +35,22 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
'household_id' => $household->getId()
]])
->setExtras(['order' => 10]);
$menu->addChild($this->translator->trans('household.Accompanying period'), [
'route' => 'chill_person_household_accompanying_period',
'routeParameters' => [
'household_id' => $household->getId()
]])
->setExtras(['order' => 20]);
$menu->addChild($this->translator->trans('household.Addresses'), [
'route' => 'chill_person_household_addresses',
'routeParameters' => [
'household_id' => $household->getId()
]])
->setExtras(['order' => 30]);
}
}

View File

@ -0,0 +1,136 @@
{% block content %}
{% for accompanying_period in accompanying_periods %}
<div class="flex-table">
<div class="item-bloc">
<div class="item-row">
<div class="item-col">
{{'period'|trans}} <b>#{{ accompanying_period.id }}</b>
{% if accompanying_period.emergency %}
&nbsp;
<span class="badge badge-primary">
{{- 'Emergency'|trans|upper -}}
</span>
{% endif %}
{% if accompanying_period.confidential %}
&nbsp;
<span class="badge badge-primary">
{{- 'Confidential'|trans|upper -}}
</span>
{% endif %}
{% if accompanying_period.step == 'DRAFT' %}
&nbsp;
<span class="badge badge-primary">
{{- 'Draft'|trans|upper -}}
</span>
{% else %}
<span class="badge badge-primary">
{{- 'Confirmed'|trans|upper -}}
</span>
{% endif %}
</div>
<div class="item-col">
{% if chill_accompanying_periods.fields.user == 'visible' %}
{% if accompanying_period.user %}
{{ accompanying_period.user.username }}
{% else %}
<span class="chill-no-data-statement">{{ 'No accompanying user'|trans }}</span>
{% endif %}
{% endif %}
</div>
</div>
<div class="item-row">
{% if accompanying_period.closingDate == null %}
{{ 'accompanying_period.dates_from_%opening_date%'|trans({ '%opening_date%': accompanying_period.openingDate|format_date('long') } ) }}
{% else %}
{{ 'accompanying_period.dates_from_%opening_date%_to_%closing_date%'|trans({
'%opening_date%': accompanying_period.openingDate|format_date('long'),
'%closing_date%': accompanying_period.closingDate|format_date('long')}
) }}
{% if accompanying_period.isOpen == false %}
<dl class="chill_view_data">
<dt>{{ 'Closing motive'|trans }}&nbsp;:</dt>
<dd>{{ accompanying_period.closingMotive|chill_entity_render_box }}</dd>
</dl>
{% endif %}
{% endif %}
</div>
<div class="item-col">
<h3>{{ 'Participants'|trans }}</h3>
{% if accompanying_period.participations.count > 0 %}
{% for p in accompanying_period.participations %}
<p>
<a href="{{ path('chill_person_accompanying_period_list', { person_id: p.person.id }) }}">
{{ p.person.firstname ~ ' ' ~ p.person.lastname }}
</a>
</p>
{% endfor %}
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
</div>
<div class="item-col">
<h3>{{ 'Requestor'|trans }}</h3>
{% if accompanying_period.requestorPerson is not null or accompanying_period.requestorThirdParty is not null %}
{% if accompanying_period.requestorPerson is not null %}
<p>{{ accompanying_period.requestorPerson.firstname ~ ' ' ~ accompanying_period.requestorPerson.lastname }}</p>
{% endif %}
{% if accompanying_period.requestorThirdParty is not null %}
<p>{{ accompanying_period.requestorThirdParty.name }}</p>
{% endif %}
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
</div>
<div class="item-col">
<h3>{{ 'Social issues'|trans }}</h3>
{% if accompanying_period.socialIssues.count > 0 %}
{% for si in accompanying_period.socialIssues %}
<p>{{ si.title|localize_translatable_string }}</p>
{% endfor %}
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
</div>
<div class="item-row">
<ul class="record_actions">
{# TODO if enable_accompanying_course_with_multiple_persons is true ... #}
<li>
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': accompanying_period.id }) }}" class="sc-button bt-show"></a>
</li>
{#
<li>
<a href="{{ path('chill_person_accompanying_period_update', {'person_id' : person.id, 'period_id' : accompanying_period.id } ) }}" class="sc-button bt-update no-content"></a>
</li>
{% if accompanying_period.isOpen == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_close', {'person_id' : person.id}) }}" class="sc-button bt-update has-hidden change-icon">
<i class="fa fa-lock" aria-hidden="true"></i><span class="show-on-hover">{{'Close accompanying period'|trans }}</span>
</a>
</li>
{% endif %}
{% if accompanying_period.canBeReOpened(person) == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_re_open', {'person_id' : person.id, 'period_id' : accompanying_period.id } ) }}" class="sc-button bt-create change-icon has-hidden">
<i class="fa fa-unlock" aria-hidden="true"></i><span class="show-on-hover">{{'Re-open accompanying period'|trans }}</span>
</a>
</li>
{% endif %}
#}
</ul>
</div>
</div>
</div>
<p></p>
{% endfor %}
{% endblock content %}

View File

@ -5,143 +5,11 @@
{% block title %}{{ 'Person accompanying period - %name%'|trans({ '%name%' : person.__toString}) }}{% endblock title %}
{% block personcontent %}
<h1>{{ 'Accompanying period list'|trans }}</h1>
{% for accompanying_period in accompanying_periods %}
<div class="flex-table">
<div class="item-bloc">
<div class="item-row">
<div class="item-col">
{{'period'|trans}} <b>#{{ accompanying_period.id }}</b>
{% if accompanying_period.emergency %}
&nbsp;
<span class="badge badge-primary">
{{- 'Emergency'|trans|upper -}}
</span>
{% endif %}
{% if accompanying_period.confidential %}
&nbsp;
<span class="badge badge-primary">
{{- 'Confidential'|trans|upper -}}
</span>
{% endif %}
{% if accompanying_period.step == 'DRAFT' %}
&nbsp;
<span class="badge badge-primary">
{{- 'Draft'|trans|upper -}}
</span>
{% else %}
<span class="badge badge-primary">
{{- 'Confirmed'|trans|upper -}}
</span>
{% endif %}
</div>
{% include 'ChillPersonBundle:AccompanyingPeriod:_list.html.twig' %}
<div class="item-col">
{% if chill_accompanying_periods.fields.user == 'visible' %}
{% if accompanying_period.user %}
{{ accompanying_period.user.username }}
{% else %}
<span class="chill-no-data-statement">{{ 'No accompanying user'|trans }}</span>
{% endif %}
{% endif %}
</div>
</div>
<div class="item-row">
{% if accompanying_period.closingDate == null %}
{{ 'accompanying_period.dates_from_%opening_date%'|trans({ '%opening_date%': accompanying_period.openingDate|format_date('long') } ) }}
{% else %}
{{ 'accompanying_period.dates_from_%opening_date%_to_%closing_date%'|trans({
'%opening_date%': accompanying_period.openingDate|format_date('long'),
'%closing_date%': accompanying_period.closingDate|format_date('long')}
) }}
{% if accompanying_period.isOpen == false %}
<dl class="chill_view_data">
<dt>{{ 'Closing motive'|trans }}&nbsp;:</dt>
<dd>{{ accompanying_period.closingMotive|chill_entity_render_box }}</dd>
</dl>
{% endif %}
{% endif %}
</div>
<div class="item-col">
<h3>{{ 'Participants'|trans }}</h3>
{% if accompanying_period.participations.count > 0 %}
{% for p in accompanying_period.participations %}
<p>
<a href="{{ path('chill_person_accompanying_period_list', { person_id: p.person.id }) }}">
{{ p.person.firstname ~ ' ' ~ p.person.lastname }}
</a>
</p>
{% endfor %}
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
</div>
<div class="item-col">
<h3>{{ 'Requestor'|trans }}</h3>
{% if accompanying_period.requestorPerson is not null or accompanying_period.requestorThirdParty is not null %}
{% if accompanying_period.requestorPerson is not null %}
<p>{{ accompanying_period.requestorPerson.firstname ~ ' ' ~ accompanying_period.requestorPerson.lastname }}</p>
{% endif %}
{% if accompanying_period.requestorThirdParty is not null %}
<p>{{ accompanying_period.requestorThirdParty.name }}</p>
{% endif %}
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
</div>
<div class="item-col">
<h3>{{ 'Social issues'|trans }}</h3>
{% if accompanying_period.socialIssues.count > 0 %}
{% for si in accompanying_period.socialIssues %}
<p>{{ si.title|localize_translatable_string }}</p>
{% endfor %}
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
</div>
<div class="item-row">
<ul class="record_actions">
{# TODO if enable_accompanying_course_with_multiple_persons is true ... #}
<li>
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': accompanying_period.id }) }}" class="sc-button bt-show"></a>
</li>
{#
<li>
<a href="{{ path('chill_person_accompanying_period_update', {'person_id' : person.id, 'period_id' : accompanying_period.id } ) }}" class="sc-button bt-update no-content"></a>
</li>
{% if accompanying_period.isOpen == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_close', {'person_id' : person.id}) }}" class="sc-button bt-update has-hidden change-icon">
<i class="fa fa-lock" aria-hidden="true"></i><span class="show-on-hover">{{'Close accompanying period'|trans }}</span>
</a>
</li>
{% endif %}
{% if accompanying_period.canBeReOpened(person) == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_re_open', {'person_id' : person.id, 'period_id' : accompanying_period.id } ) }}" class="sc-button bt-create change-icon has-hidden">
<i class="fa fa-unlock" aria-hidden="true"></i><span class="show-on-hover">{{'Re-open accompanying period'|trans }}</span>
</a>
</li>
{% endif %}
#}
</ul>
</div>
</div>
</div>
<p></p>
{% endfor %}
<div class="form_control">
<div class="form_control">
<ul class="record_actions">
<li class="cancel">
<a href="{{ path ('chill_person_view', {'person_id' : person.id } ) }}" class="sc-button bt-cancel">
@ -171,4 +39,4 @@
</ul>
</div>
{% endblock personcontent %}
{% endblock %}

View File

@ -0,0 +1,25 @@
{% extends '@ChillPerson/Household/layout.html.twig' %}
{% block title 'Household accompanying period'|trans %}
{% block content %}
<h1>{{ block('title') }}</h1>
{% include 'ChillPersonBundle:AccompanyingPeriod:_list.html.twig' %}
<div class="form_control">
<ul class="record_actions">
<li class="cancel">
<a href="{{ path ('chill_person_household_summary', {'household_id' : household.id } ) }}" class="sc-button bt-cancel">
{{ 'Household summary'|trans }}
</a>
</li>
{#<li>
<a href="{{ path ('chill_person_household_accompanying_course_new', {'household_id' : [ household.id ] } ) }}" class="sc-button bt-create">
{{ 'Create an accompanying period'|trans }}
</a>
</li>#}
</ul>
</div>
{% endblock %}

View File

@ -38,12 +38,13 @@ household:
Edit member household: Modifier l'appartenance au ménage
Current household members: Membres actuels
Household summary: Résumé
Accompanying period: Parcours d'accompagnement
Addresses: Adresses
Current address: Adresse actuelle
Household does not have any address currently: Le ménage n'a pas d'adresse renseignée actuellement
Edit household members: Modifier l'appartenance au ménage
and x other persons: >-
{x, plural,
{x, plural,
one {et une autre personne}
many {et # autres personnes}
other {et # autres personnes}
@ -59,7 +60,7 @@ household:
data_saved: Données enregistrées
Household history for %name%: Historique des ménages pour {name}
Household shared: Ménages domiciliés
Household not shared: Ménage non domiciliés
Household not shared: Ménage non domiciliés
Never in any household: Membre d'aucun ménage
Membership currently running: En cours
from: Depuis

View File

@ -344,6 +344,8 @@ Members: Membres
Addresses: Adresses
Move household: Nouveau déménagement
Addresses history for household: Historique des adresses
Household accompanying period: Parcours d'accompagnement du ménage
Household summary: Résumé du ménage
# accompanying course work
Accompanying Course Actions: Actions d'accompagnements