mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add accompanying period where the person is requestor + badge in results
This commit is contained in:
parent
f1f13996f9
commit
0d5d4b3f05
@ -213,7 +213,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
private $scopes;
|
private $scopes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodRequested")
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
*/
|
*/
|
||||||
private $requestorPerson;
|
private $requestorPerson;
|
||||||
|
@ -129,4 +129,9 @@ class AccompanyingPeriodParticipation
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isOpen(): bool
|
||||||
|
{
|
||||||
|
return $this->endDate === null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Entity\Country;
|
use Chill\MainBundle\Entity\Country;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
@ -329,6 +329,15 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
*/
|
*/
|
||||||
private $accompanyingPeriodParticipations;
|
private $accompanyingPeriodParticipations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The accompanying period requested by the Person
|
||||||
|
*
|
||||||
|
* @ORM\OneToMany(targetEntity=AccompanyingPeriod::class,
|
||||||
|
* mappedBy="requestorPerson")
|
||||||
|
* @var Collection|AccompanyingPeriod[]
|
||||||
|
*/
|
||||||
|
private Collection $accompanyingPeriodRequested;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A remark over the person
|
* A remark over the person
|
||||||
* @var string
|
* @var string
|
||||||
@ -478,6 +487,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
$this->genderComment = new CommentEmbeddable();
|
$this->genderComment = new CommentEmbeddable();
|
||||||
$this->maritalStatusComment = new CommentEmbeddable();
|
$this->maritalStatusComment = new CommentEmbeddable();
|
||||||
$this->periodLocatedOn = new ArrayCollection();
|
$this->periodLocatedOn = new ArrayCollection();
|
||||||
|
$this->accompanyingPeriodRequested = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -605,6 +615,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get AccompanyingPeriodParticipations Collection
|
* Get AccompanyingPeriodParticipations Collection
|
||||||
|
*
|
||||||
|
* @return AccompanyingPeriodParticipation[]|Collection
|
||||||
*/
|
*/
|
||||||
public function getAccompanyingPeriodParticipations(): Collection
|
public function getAccompanyingPeriodParticipations(): Collection
|
||||||
{
|
{
|
||||||
@ -614,6 +626,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
/**
|
/**
|
||||||
* Return a collection of participation, where the participation
|
* Return a collection of participation, where the participation
|
||||||
* is still opened, not a draft, and the period is still opened
|
* is still opened, not a draft, and the period is still opened
|
||||||
|
*
|
||||||
|
* @return AccompanyingPeriodParticipation[]|Collection
|
||||||
*/
|
*/
|
||||||
public function getOpenedParticipations(): Collection
|
public function getOpenedParticipations(): Collection
|
||||||
{
|
{
|
||||||
@ -1650,6 +1664,84 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return AccompanyingPeriod[]|Collection
|
||||||
|
*/
|
||||||
|
public function getAccompanyingPeriodRequested(): Collection
|
||||||
|
{
|
||||||
|
return $this->accompanyingPeriodRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of all accompanying period where the person is involved:
|
||||||
|
*
|
||||||
|
* * as requestor;
|
||||||
|
* * as participant, only for opened participation;
|
||||||
|
*
|
||||||
|
* @param bool $asParticipantOpen add participation which are still opened
|
||||||
|
* @param bool $asRequestor add accompanying period where the person is requestor
|
||||||
|
* @return AccompanyingPeriod[]|Collection
|
||||||
|
*/
|
||||||
|
public function getAccompanyingPeriodInvolved(
|
||||||
|
bool $asParticipantOpen = true,
|
||||||
|
bool $asRequestor = true
|
||||||
|
): Collection
|
||||||
|
{
|
||||||
|
$result = new ArrayCollection();
|
||||||
|
|
||||||
|
if ($asParticipantOpen) {
|
||||||
|
foreach ($this->getOpenedParticipations()
|
||||||
|
->map(fn (AccompanyingPeriodParticipation $app) =>
|
||||||
|
$app->getAccompanyingPeriod())
|
||||||
|
as $period
|
||||||
|
) {
|
||||||
|
if (!$result->contains($period)) {
|
||||||
|
$result->add($period);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($asRequestor) {
|
||||||
|
foreach ($this->accompanyingPeriodRequested as $period) {
|
||||||
|
if (!$result->contains($period)) {
|
||||||
|
$result->add($period);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handy method to get the AccompanyingPeriodParticipation
|
||||||
|
* matching a given AccompanyingPeriod.
|
||||||
|
*
|
||||||
|
* Used in template, to find the participation when iterating on a list
|
||||||
|
* of period.
|
||||||
|
*
|
||||||
|
* @param \Chill\PersonBundle\Entity\AccompanyingPeriod $period
|
||||||
|
* @return AccompanyingPeriodParticipation
|
||||||
|
*/
|
||||||
|
public function findParticipationForPeriod(AccompanyingPeriod $period): ?AccompanyingPeriodParticipation
|
||||||
|
{
|
||||||
|
$closeCandidates = [];
|
||||||
|
|
||||||
|
foreach ($this->getAccompanyingPeriodParticipations() as $participation) {
|
||||||
|
if ($participation->getAccompanyingPeriod() === $period) {
|
||||||
|
if ($participation->isOpen()) {
|
||||||
|
return $participation;
|
||||||
|
}
|
||||||
|
$closeCandidates[] = $participation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 < count($closeCandidates)) {
|
||||||
|
return $closeCandidates[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCreatedBy(): ?User
|
public function getCreatedBy(): ?User
|
||||||
{
|
{
|
||||||
return $this->createdBy;
|
return $this->createdBy;
|
||||||
|
@ -59,47 +59,51 @@
|
|||||||
'customButtons': { 'after': _self.button_person(person) }
|
'customButtons': { 'after': _self.button_person(person) }
|
||||||
}) }}
|
}) }}
|
||||||
|
|
||||||
{#- 'apps' is for AccompanyingPeriodParticipationS #}
|
{#- 'acps' is for AcCompanyingPeriodS #}
|
||||||
{%- set apps = [] %}
|
{%- set acps = [] %}
|
||||||
{%- for app in person.openedParticipations %}
|
{%- for acp in person.accompanyingPeriodInvolved %}
|
||||||
{%- if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', app.accompanyingPeriod) %}
|
{%- if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', acp) %}
|
||||||
{%- set apps = apps|merge([app]) %}
|
{%- set acps = acps|merge([acp]) %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
{% if apps|length > 0 %}
|
{# add as requestor #}
|
||||||
|
|
||||||
|
{% if acps|length > 0 %}
|
||||||
<div class="item-row">
|
<div class="item-row">
|
||||||
<div class="wrap-list periods-list">
|
<div class="wrap-list periods-list">
|
||||||
{% for app in apps %}
|
{% for acp in acps %}
|
||||||
|
{% set app = person.findParticipationForPeriod(acp) %}
|
||||||
<div class="wl-row separator">
|
<div class="wl-row separator">
|
||||||
<div class="wl-col title">
|
<div class="wl-col title">
|
||||||
|
|
||||||
<div class="date">
|
<div class="date">
|
||||||
{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}
|
{% if acp.requestorPerson == person %}
|
||||||
|
<span class="as-requestor badge bg-info" title="{{ 'Requestor'|trans|e('html_attr') }}">
|
||||||
|
{{ 'Requestor'|trans({'gender': person.gender}) }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if app != null %}
|
||||||
|
{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if app.accompanyingPeriod.user is not null %}
|
{% if acp.user is not null %}
|
||||||
<div class="user">
|
<div 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 }}
|
{{ acp.user|chill_entity_render_box }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="wl-col list">
|
<div class="wl-col list">
|
||||||
|
|
||||||
{% for issue in app.accompanyingPeriod.socialIssues %}
|
{% for issue in acp.socialIssues %}
|
||||||
{{ issue|chill_entity_render_box }}
|
{{ issue|chill_entity_render_box }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{# ^^ display all socialIssues, or slice vv
|
|
||||||
|slice(0,2)
|
|
||||||
{% if app.accompanyingPeriod.socialIssues|length > 2 %}
|
|
||||||
<span class="more">{{ 'and %number% other'|transchoice(app.accompanyingPeriod.socialIssues|length-2) }}</span>
|
|
||||||
{% endif %}
|
|
||||||
#}
|
|
||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<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': acp.id }) }}"
|
||||||
class="btn btn-sm btn-outline-primary" title="{{ 'See accompanying period'|trans }}">
|
class="btn btn-sm btn-outline-primary" title="{{ 'See accompanying period'|trans }}">
|
||||||
<i class="fa fa-random fa-fw"></i>
|
<i class="fa fa-random fa-fw"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -5,6 +5,13 @@ Born the date: >-
|
|||||||
other {Né·e le {birthdate}}
|
other {Né·e le {birthdate}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Requestor: >-
|
||||||
|
{gender, select,
|
||||||
|
man {Demandeur}
|
||||||
|
woman {Demandeuse}
|
||||||
|
other {Demandeur·euse}
|
||||||
|
}
|
||||||
|
|
||||||
household:
|
household:
|
||||||
Household: Ménage
|
Household: Ménage
|
||||||
Household number: Ménage {household_num}
|
Household number: Ménage {household_num}
|
||||||
|
@ -189,7 +189,6 @@ Create an accompanying course: Créer un parcours
|
|||||||
This accompanying course is still a draft: Ce parcours est à l'état brouillon
|
This accompanying course is still a draft: Ce parcours est à l'état brouillon
|
||||||
Associated peoples: Usagers concernés
|
Associated peoples: Usagers concernés
|
||||||
Resources: Interlocuteurs privilégiés
|
Resources: Interlocuteurs privilégiés
|
||||||
Requestor: Demandeur
|
|
||||||
Any requestor to this accompanying course: Aucun demandeur pour ce parcours
|
Any requestor to this accompanying course: Aucun demandeur pour ce parcours
|
||||||
Social actions: Actions d'accompagnement
|
Social actions: Actions d'accompagnement
|
||||||
Social issues: Problématiques sociales
|
Social issues: Problématiques sociales
|
||||||
|
Loading…
x
Reference in New Issue
Block a user