Compare commits

...

70 Commits

Author SHA1 Message Date
1e996ce230 onTheFly with hardcoded data. needs to be changed when endpoint is created 2021-08-27 17:26:59 +02:00
4ee67869bd style fixes requestor + multiline option for thirdpartyrenderbox 2021-08-20 17:53:48 +02:00
8bcd69c5ec requestor styling fixed + button added. problem with removing requestor though... 2021-08-20 16:55:41 +02:00
badf632a8a #134 fixes address multiline 2021-08-20 16:55:04 +02:00
7363092d51 #134 fixes show button for thirdparty 2021-08-20 16:52:35 +02:00
698514ef12 #192 custom-zone added + no_data message 2021-08-20 14:47:33 +02:00
55c34c2583 #134 fix dynamic URL to go to person or thirdparty file 2021-08-20 11:06:11 +02:00
3e27589cca #134 hLevel fixed 2021-08-20 10:37:46 +02:00
52469d995a onTheFly modal, edit button changed to show person file 2021-08-19 21:07:37 +02:00
b4234ddc58 class made dynamic with correct hLevel option 2021-08-19 21:06:30 +02:00
bb471fd4af AccompanyingCourse: fix errors with renderbox into Resources 2021-08-19 19:41:16 +02:00
fdd08905a8 init new twig block_post_menu 2021-08-19 19:40:32 +02:00
755812ae3c fix buttonLocation deleted from last merge 2021-08-19 17:16:52 +02:00
3602b0d097 requestor import fix alias 2021-08-19 16:50:08 +02:00
5dc92ed5bd Merge branch 'ameliorations_composants_vue' of gitlab.com:Chill-Projet/chill-bundles into ameliorations_composants_vue 2021-08-19 16:21:11 +02:00
d61dbaed91 move vue thirdparty components in ChillThirdPartyBundle assets 2021-08-19 16:01:23 +02:00
9ac72a21d1 adding alias ChillThirdPartyAssets 2021-08-19 15:45:29 +02:00
fd8f4a98c0 vue Address: fix ShowAddress multiline option 2021-08-19 15:41:54 +02:00
2394895ccb Merge branch 'ameliorations_composants_vue' of gitlab.com:Chill-Projet/chill-bundles into ameliorations_composants_vue 2021-08-19 15:07:43 +02:00
6ca35d5a18 requestor adapted to use PersonRenderBox or ThirdPartyRenderBox 2021-08-19 14:47:41 +02:00
6253927e2e Merge branch 'ameliorations_composants_vue' into improve_ux 2021-08-19 14:31:20 +02:00
0f87d77896 Merge branch 102_activites_annexes into 'improve_ux' 2021-08-19 14:08:23 +02:00
8b50e5bd62 comment TODO 2021-08-19 12:41:38 +02:00
f490fdd37c batch remove 'Bravo' 2021-08-19 12:41:38 +02:00
7ffdf4cb1f render_box person and thirdparty: fix bug customOptions with 'replace' 2021-08-19 12:41:38 +02:00
801e897a38 Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles 2021-08-19 12:40:05 +02:00
21db8674e7 thirdparty: replace macro address by render_box 2021-08-19 12:38:07 +02:00
de7322464b deathdate fix in personrenderbox, in case there is a deathdate 2021-08-19 12:32:26 +02:00
90cfcd0569 ThirdPartyRenderBox created and old view replaced 2021-08-19 12:31:38 +02:00
4a0ffd2cba flex-table taken out of for-loop 2021-08-19 12:29:08 +02:00
3e9d96368d style added to create space between streetname and city + margin of flex-table fixed 2021-08-19 12:26:00 +02:00
227d627ad5 Merge branch 110_extend_thirdparty into 'master' 2021-08-19 12:19:00 +02:00
c7a2bbfc1d remove dump debug 2021-08-19 12:17:16 +02:00
1aa77bd1c4 AccompanyingCourse: uniformity of styles 2021-08-18 22:36:02 +02:00
39e8af48b4 #198 issue fixes: mostly template fixes and translations 2021-08-18 22:31:43 +02:00
9a1f56a820 [Aside activity] Temporarily remove the link to aside activities 2021-08-18 21:23:04 +02:00
d652771af0 CourseLocation: fix errors 2021-08-18 20:10:43 +02:00
9d655d92f2 CourseLocation: add message if no address 2021-08-18 17:45:37 +02:00
9e51717984 Merge branch accourse_confirmation into 'master' 2021-08-18 17:23:27 +02:00
a6b360c193 setup of ThirdPartyRenderBox 2021-08-18 17:20:57 +02:00
42b9e25403 some todo's added in comment + most href's made dynamic 2021-08-18 17:20:17 +02:00
403922c631 AccompanyingCourse, change blocs order (location in second position) 2021-08-18 17:10:37 +02:00
53fe90adc3 AccompanyingCourse: check if conditions of confirmation are met, or display alert 2021-08-18 16:54:22 +02:00
41fe95c80f fix display styles bugs 2021-08-18 16:54:22 +02:00
28435940f1 AccompanyingCourse api errorMsg 2021-08-18 16:53:06 +02:00
34e1a9b748 address added to personrenderbox w/ ShowAddress. Adapted to include a multiline option 2021-08-18 16:22:38 +02:00
097ad3a364 fix return type of class 2021-08-18 09:56:48 +02:00
816d860f4a Merge branch 'fixtures/fix-loading-people' into 'master'
Fixtures/fix loading people

See merge request Chill-Projet/chill-bundles!124
2021-08-17 20:01:29 +00:00
c7cc2c7596 Fixtures/fix loading people 2021-08-17 20:01:29 +00:00
6ad8a73fc0 Merge branch 'master' into 110_extend_thirdparty 2021-08-17 20:47:58 +02:00
eac4c48d8f deathdate added if not null 2021-08-17 16:30:26 +02:00
7af85bc401 AddressRenderBox created and added to PersonRenderBox, still some styling issue with address. Render options not done yet 2021-08-17 16:14:08 +02:00
1a6c0529cc date formatting using dateToISO function, still fix with translations. + record-actions inserted via <slot> 2021-08-17 14:05:48 +02:00
77fe497994 altNames displayed dynamically 2021-08-14 12:01:44 +02:00
b89a66b20c dynamic properties displayed 2021-08-13 18:31:15 +02:00
438134690f styling fixed with proper class cascade 2021-08-13 14:57:56 +02:00
166144e57e first conditionalities added analog to twig template 2021-08-13 13:15:08 +02:00
6bb5440220 injecting person data into renderbox, no styling yet 2021-08-12 16:23:58 +02:00
c48586cd0e renaming of PersonItem into ParticipationItem 2021-08-12 15:55:35 +02:00
21fd69488f start of PersonRenderBox in vue 2021-08-12 15:21:33 +02:00
4eef8492b1 Merge branch 'master' into 110_extend_thirdparty 2021-07-30 22:56:41 +02:00
5d1d6c83a9 Merge branch 'bootstrap5' into 110_extend_thirdparty 2021-07-23 17:09:45 +02:00
a559589883 add isLeaf condition on ThirdParty form Type 2021-07-22 16:34:07 +02:00
587da94645 adapt Thirdparty form and templates 2021-07-20 15:34:28 +02:00
3f9e215ea5 adding fixtures for new thirdparty fields (choice lists) 2021-07-19 17:18:36 +02:00
732390f704 add new fields in thirdparty entity 2021-07-19 16:11:25 +02:00
25b00296ca adapt thirdparty templates 2021-07-16 17:01:32 +02:00
1e626d573f Merge branch 'bootstrap5' into 110_extend_thirdparty 2021-07-16 13:29:01 +02:00
3ee676600e adding twig extensions to select how many items per page
* twig anchor: {{ chill_items_per_page(pagination) }}
* select field changed with javascript event listener
2021-07-16 13:23:10 +02:00
d2c631ae20 prepare thirdparty index template 2021-07-16 11:07:52 +02:00
84 changed files with 3000 additions and 1106 deletions

View File

@@ -5,11 +5,13 @@ image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
cache: cache:
paths: paths:
- tests/app/vendor/ - tests/app/vendor/
- .composer
before_script: before_script:
# add extensions to postgres # add extensions to postgres
- PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;" - PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;"
# Install and run Composer # Install and run Composer
- mkdir -p $COMPOSER_HOME
- curl -sS https://getcomposer.org/installer | php - curl -sS https://getcomposer.org/installer | php
- php -d memory_limit=2G composer.phar install - php -d memory_limit=2G composer.phar install
- php tests/app/bin/console doctrine:migrations:migrate -n - php tests/app/bin/console doctrine:migrations:migrate -n
@@ -34,6 +36,10 @@ variables:
REDIS_HOST: redis REDIS_HOST: redis
REDIS_PORT: 6379 REDIS_PORT: 6379
REDIS_URL: redis://redis:6379 REDIS_URL: redis://redis:6379
# change vendor dir to make the app install into tests/apps
COMPOSER_VENDOR_DIR: tests/app/vendor
# cache some composer data
COMPOSER_HOME: .composer
# Run our tests # Run our tests

View File

@@ -54,7 +54,7 @@
{{ form_row(edit_form.date) }} {{ form_row(edit_form.date) }}
{% endif %} {% endif %}
.. location {# TODO .. location #}
{%- if edit_form.durationTime is defined -%} {%- if edit_form.durationTime is defined -%}
{{ form_row(edit_form.durationTime) }} {{ form_row(edit_form.durationTime) }}
@@ -65,7 +65,7 @@
{% endif %} {% endif %}
{%- if edit_form.comment is defined -%} {%- if edit_form.comment is defined -%}
.. public and private {# TODO .. public and private #}
{{ form_row(edit_form.comment) }} {{ form_row(edit_form.comment) }}
{% endif %} {% endif %}
@@ -77,7 +77,7 @@
{{ form_row(edit_form.attendee) }} {{ form_row(edit_form.attendee) }}
{% endif %} {% endif %}
.. status {# TODO .. status #}
{% set person_id = null %} {% set person_id = null %}
{% if entity.person %} {% if entity.person %}

View File

@@ -55,7 +55,7 @@
{{ form_row(form.date) }} {{ form_row(form.date) }}
{% endif %} {% endif %}
.. location {# TODO .. location #}
{%- if form.durationTime is defined -%} {%- if form.durationTime is defined -%}
{{ form_row(form.durationTime) }} {{ form_row(form.durationTime) }}
@@ -66,7 +66,7 @@
{% endif %} {% endif %}
{%- if form.comment is defined -%} {%- if form.comment is defined -%}
.. public and private {# TODO .. public and private #}
{{ form_row(form.comment) }} {{ form_row(form.comment) }}
{% endif %} {% endif %}
@@ -78,13 +78,13 @@
{{ form_row(form.attendee) }} {{ form_row(form.attendee) }}
{% endif %} {% endif %}
.. status {# TODO .. status #}
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">
<li class="cancel"> <li class="cancel">
<a <a
class="btn btn-cancel" class="btn btn-cancel"
{%- if context == 'person' -%} {%- if context == 'person' -%}
href="{{ chill_return_path_or('chill_activity_activity_list', { 'person_id': person.id } )}}" href="{{ chill_return_path_or('chill_activity_activity_list', { 'person_id': person.id } )}}"
{%- else -%} {%- else -%}
href="{{ chill_return_path_or('chill_activity_activity_list', { 'accompanying_period_id': accompanyingCourse.id } )}}" href="{{ chill_return_path_or('chill_activity_activity_list', { 'accompanying_period_id': accompanyingCourse.id } )}}"

View File

@@ -81,9 +81,9 @@ activity:
'%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"' '%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"'
#controller #controller
'Success : activity created!': Bravo ! L'activité a été créée. 'Success : activity created!': L'activité a été créée.
'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'activité n'a pas été créée. 'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'activité n'a pas été créée.
'Success : activity updated!': Bravo ! L'activité a été mise à jour. 'Success : activity updated!': L'activité a été mise à jour.
'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'activité n'a pas été mise à jour. 'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'activité n'a pas été mise à jour.
# ROLES # ROLES

View File

@@ -17,15 +17,19 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Security;
final class AsideActivityFormType extends AbstractType final class AsideActivityFormType extends AbstractType
{ {
protected array $timeChoices; protected array $timeChoices;
private TranslatableStringHelper $translatableStringHelper; private TranslatableStringHelper $translatableStringHelper;
private TokenStorageInterface $storage;
public function __construct (TranslatableStringHelper $translatableStringHelper, array $timeChoices){ public function __construct (TranslatableStringHelper $translatableStringHelper, array $timeChoices, TokenStorageInterface $storage){
$this->timeChoices = $timeChoices; $this->timeChoices = $timeChoices;
$this->translatableStringHelper = $translatableStringHelper; $this->translatableStringHelper = $translatableStringHelper;
$this->storage = $storage;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
@@ -48,7 +52,8 @@ final class AsideActivityFormType extends AbstractType
'label' => 'Agent', 'label' => 'Agent',
'required' => true, 'required' => true,
'class' => User::class, 'class' => User::class,
//translate 'data' => $this->storage->getToken()->getUser(),
'attr' => array('class' => 'select2 '),
'placeholder' => 'Choose the agent for whom this activity is created', 'placeholder' => 'Choose the agent for whom this activity is created',
'choice_label' => 'username' 'choice_label' => 'username'
]) ])

View File

@@ -1,12 +1,14 @@
{% extends "@ChillMain/layout.html.twig" %} {% extends "@ChillMain/layout.html.twig" %}
{% block title %}{{ 'Aside activity list' |trans }}{% endblock title %}
{% block content %} {% block content %}
<div class="col-md-10 col-xxl asideactivity-list"> <div class="col-md-10 col-xxl asideactivity-list">
<h2>{{ 'My aside activities' |trans }}</h2> <h2>{{ 'My aside activities' |trans }}</h2>
{% if entities|length == 0 %} {% if entities|length == 0 %}
<p class="chill-no-data-statement"> <p class="chill-no-data-statement">
{{ "There isn't any activities."|trans }} {{ "There aren't any aside activities."|trans }}
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create button-small"></a> <a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create button-small"></a>
</p> </p>
{% else %} {% else %}
@@ -30,13 +32,13 @@
{% if entity.date %} {% if entity.date %}
<p>{{ entity.date|format_date('long') }}</p> <p>{{ entity.date|format_date('long') }}</p>
{% endif %} {% endif %}
{#
<div class="duration"> <div class="duration">
<p> <p>
<i class="fa fa-fw fa-hourglass-end"></i> <i class="fa fa-fw fa-hourglass-end"></i>
{{ entity.duration|date('H:i') }} {{ entity.duration|date('H:i') }}
</p> </p>
</div> #} </div>
</div> </div>
<div class="item-col"> <div class="item-col">
@@ -66,9 +68,9 @@
<div class="item-col"> <div class="item-col">
<ul class="list-content"> <ul class="list-content">
<ul class="record_actions"> <ul class="record_actions">
<li> {# <li>
<a href="{{ path('chill_crud_aside_activity_view', { 'id': entity.id} ) }}" class="btn btn-show "></a> <a href="{{ path('chill_crud_aside_activity_view', { 'id': entity.id} ) }}" class="btn btn-show "></a>
</li> </li> #}
{# TOOD {# TOOD
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %} {% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
#} #}
@@ -91,18 +93,15 @@
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div>
<ul class="record_actions">
<li>
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create">
{{ 'Add a new aside activity' | trans }}
</a>
</li>
</ul>
</div> </div>
{% endif %} {% endif %}
{% endblock %}
{# TODO set this condition in configuration #}
<ul class="record_actions">
<li>
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create">
{{ 'Add a new activity' | trans }}
</a>
</li>
</ul>
</div>
{% endblock %}

View File

@@ -36,8 +36,8 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a href="{{ path('chill_crud_activity_type_new') }}" class="btn btn-create"> <a href="{{ path('chill_crud_aside_activity_category_new') }}" class="btn btn-create">
{{ 'Create a new activity type'|trans }} {{ 'Create a new aside activity type'|trans }}
</a> </a>
</li> </li>
</ul> </ul>

View File

@@ -5,5 +5,6 @@ services:
arguments: arguments:
- "@chill.main.helper.translatable_string" - "@chill.main.helper.translatable_string"
- "%chill_activity.form.time_duration%" - "%chill_activity.form.time_duration%"
- "@security.token_storage"
tags: tags:
- { name: form.type, alias: chill_asideactivitybundle_asideactivity } - { name: form.type, alias: chill_asideactivitybundle_asideactivity }

View File

@@ -8,7 +8,7 @@ user_username: nom de l'utilisateur
Remark: Commentaire Remark: Commentaire
No comments: Aucun commentaire No comments: Aucun commentaire
Add a new aside activity: Ajouter une nouvelle activité annexe Add a new aside activity: Ajouter une nouvelle activité annexe
Aside activity list: Liste des activités annexes Aside activity list: Activités annexes
present: présent present: présent
not present: absent not present: absent
Delete: Supprimer Delete: Supprimer
@@ -32,7 +32,7 @@ location: Lieu
crud: crud:
aside_activity: aside_activity:
title_view: Détail de l'activité annexe title_view: Détail de l'activité annexe
title_new: Nouveau activité annexe title_new: Nouvelle activité annexe
title_edit: Edition d'une activité annexe title_edit: Edition d'une activité annexe
title_delete: Supprimation d'une activité annexe title_delete: Supprimation d'une activité annexe
button_delete: Supprimer button_delete: Supprimer
@@ -43,14 +43,20 @@ crud:
#forms #forms
Activity creation: Nouvelle activité annexe Activity creation: Nouvelle activité annexe
Create a new aside activity type: Nouvelle categorie d'activité annexe
Create: Créer Create: Créer
Back to the list: Retour à la liste Back to the list: Retour à la liste
Save activity: Sauver l'activité Save activity: Sauver l'activité
Reset form: Remise à zéro du formulaire Reset form: Remise à zéro du formulaire
Choose the agent for whom this activity is created: Choissisez l'agent pour qui l'activitée est creeé. Choose the agent for whom this activity is created: Choissisez l'utilisateur pour qui l'activité est creéé.
Choose the activity category: Choissisez le type d'activité Choose the activity category: Choissisez le type d'activité
Choose the duration: Choisir la durée Choose the duration: Choisir la durée
Choose a category: Choisir un categorie Choose a category: Choisir un categorie
Is active: Actif
Agent: Utilisateur
date: Date
Duration: Durée
Note: Note
5 minutes: 5 minutes 5 minutes: 5 minutes
10 minutes: 10 minutes 10 minutes: 10 minutes
15 minutes: 15 minutes 15 minutes: 15 minutes

View File

@@ -15,6 +15,7 @@ trait LoadAbstractNotificationsTrait
{ {
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
return;
foreach ($this->notifs as $notif) { foreach ($this->notifs as $notif) {
$entityId = $this->getReference($notif['entityRef'])->getId(); $entityId = $this->getReference($notif['entityRef'])->getId();

View File

@@ -0,0 +1,67 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2021, 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/>.
*/
namespace Chill\MainBundle\Pagination;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
/**
* add twig function to render pagination
*
* @author Mathieu Jaumotte <mathieu.jaumotte@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
*/
class ChillItemsPerPageTwig extends AbstractExtension
{
public function getName()
{
return 'chill_items_per_page';
}
public function getFunctions()
{
return array(
new TwigFunction(
'chill_items_per_page',
array($this, 'paginationRender'),
array(
'needs_environment' => true,
'is_safe' => ['html']
)
)
);
}
public function paginationRender(
Environment $env,
PaginatorInterface $paginator,
$template = '@ChillMain/Pagination/items_per_page.html.twig'
) {
return $env->render($template, array(
'paginator' => $paginator,
'current' => $paginator->getItemsPerPage()
));
}
}

View File

@@ -61,7 +61,7 @@ class PaginatorFactory
public function __construct( public function __construct(
RequestStack $requestStack, RequestStack $requestStack,
RouterInterface $router, RouterInterface $router,
$itemPerPage = 50 $itemPerPage = 20
) { ) {
$this->itemPerPage = $itemPerPage; $this->itemPerPage = $itemPerPage;
$this->requestStack = $requestStack; $this->requestStack = $requestStack;

View File

@@ -111,3 +111,8 @@ $chill-theme-buttons: (
} }
} }
} }
// fix min-width on small pictos buttons
.btn-sm, .btn-group-sm > .btn {
min-width: 36px;
}

View File

@@ -51,6 +51,7 @@ div.flex-bloc {
flex-grow: 0; flex-shrink: 1; flex-basis: auto; flex-grow: 0; flex-shrink: 1; flex-basis: auto;
flex-direction: column; flex-direction: column;
margin: 0; margin: 0;
hyphens: auto;
div.item-row { div.item-row {
flex-grow: 1; flex-shrink: 1; flex-basis: auto; flex-grow: 1; flex-shrink: 1; flex-basis: auto;

View File

@@ -1,9 +1,10 @@
<template> <template>
<div class="chill-entity entity-address my-3"> <component :is="component" class="chill-entity entity-address my-3">
<div class="address multiline">
<component :is="component" class="address" :class="multiline">
<p v-if="address.text" <p v-if="address.text"
class="street"> class="street">
{{ address.text }} {{ address.text }},
</p> </p>
<p v-if="address.postcode" <p v-if="address.postcode"
class="postcode"> class="postcode">
@@ -13,8 +14,9 @@
class="country"> class="country">
{{ address.country.name.fr }} {{ address.country.name.fr }}
</p> </p>
</div> </component>
<div>
<div v-if="isMultiline">
<div v-if="address.floor"> <div v-if="address.floor">
<span class="floor"> <span class="floor">
<b>{{ $t('floor') }}</b>: {{ address.floor }} <b>{{ $t('floor') }}</b>: {{ address.floor }}
@@ -35,28 +37,76 @@
<b>{{ $t('flat') }}</b>: {{ address.flat }} <b>{{ $t('flat') }}</b>: {{ address.flat }}
</span> </span>
</div> </div>
<div v-if="address.buildingName"> <div>
<span class="buildingName"> <div v-if="address.floor">
<b>{{ $t('buildingName') }}</b>: {{ address.buildingName }} <span class="floor">
</span> <b>{{ $t('floor') }}</b>: {{ address.floor }}
</div> </span>
<div v-if="address.extra"> </div>
<span class="extra"> <div v-if="address.corridor">
<b>{{ $t('extra') }}</b>: {{ address.extra }} <span class="corridor">
</span> <b>{{ $t('corridor') }}</b>: {{ address.corridor }}
</div> </span>
<div v-if="address.distribution"> </div>
<span class="distribution"> <div v-if="address.steps">
<b>{{ $t('distribution') }}</b>: {{ address.distribution }} <span class="steps">
</span> <b>{{ $t('steps') }}</b>: {{ address.steps }}
</span>
</div>
<div v-if="address.flat">
<span class="flat">
<b>{{ $t('flat') }}</b>: {{ address.flat }}
</span>
</div>
<div v-if="address.buildingName">
<span class="buildingName">
<b>{{ $t('buildingName') }}</b>: {{ address.buildingName }}
</span>
</div>
<div v-if="address.extra">
<span class="extra">
<b>{{ $t('extra') }}</b>: {{ address.extra }}
</span>
</div>
<div v-if="address.distribution">
<span class="distribution">
<b>{{ $t('distribution') }}</b>: {{ address.distribution }}
</span>
</div>
</div> </div>
</div> </div>
</div>
</component>
</template> </template>
<script> <script>
export default { export default {
name: "ShowAddress", name: 'ShowAddress',
props: ['address'] props: {
} address: {
type: Object
},
isMultiline: {
default: true,
type: Boolean
}
},
computed: {
component(){
return this.isMultiline == true ? "div" : "span";
},
multiline(){
return this.isMultiline == true ? "multiline" : "";
}
}
};
</script> </script>
<style lang="scss" scoped>
p {
&:after {
content: " ";
margin-right: 0.3em;
}
}
</style>

View File

@@ -43,8 +43,9 @@
<template v-slot:footer> <template v-slot:footer>
<button v-if="action === 'show'" <button v-if="action === 'show'"
@click="changeActionTo('edit')" @click="goToLocation(id, type)"
class="btn btn-update"> :title="$t(titleMessage)"
class="btn btn-show">{{ $t(buttonMessage) }}
</button> </button>
<button v-else <button v-else
class="btn btn-save" class="btn btn-save"
@@ -60,9 +61,9 @@
<script> <script>
import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue'; import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
import OnTheFlyThirdparty from './OnTheFly/ThirdParty.vue';
import OnTheFlyCreate from './OnTheFly/Create.vue'; import OnTheFlyCreate from './OnTheFly/Create.vue';
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue';
export default { export default {
name: 'OnTheFly', name: 'OnTheFly',
@@ -115,6 +116,22 @@ export default {
case 'create': case 'create':
return 'onthefly.create.title'; return 'onthefly.create.title';
} }
},
titleMessage() {
switch (this.type){
case 'person':
return 'action.redirect.' + this.type;
case 'thirdparty':
return 'action.redirect.' + this.type;
}
},
buttonMessage(){
switch (this.type){
case 'person':
return 'onthefly.show.file_' + this.type;
case 'thirdparty':
return 'onthefly.show.file_' + this.type;
}
} }
}, },
methods: { methods: {
@@ -139,6 +156,13 @@ export default {
this.$refs.castNew.castByType(); this.$refs.castNew.castByType();
} }
this.modal.showModal = false; this.modal.showModal = false;
},
goToLocation(id, type){
if(type == 'person'){
window.location = `../../person/${id}/general`
} else if(type == 'thirdparty') {
window.location = `../../thirdparty/thirdparty/${id}/show`
}
} }
} }
} }
@@ -148,4 +172,5 @@ export default {
a { a {
cursor: pointer; cursor: pointer;
} }
</style> </style>

View File

@@ -35,7 +35,7 @@
<script> <script>
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue'; import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
import OnTheFlyThirdparty from './ThirdParty.vue'; // TODO move in ChillThirdpartyAssets import OnTheFlyThirdparty from 'ChillThirdPartyAssets/vuejs/_components/OnTheFly/ThirdParty.vue';
export default { export default {
name: "OnTheFlyCreate", name: "OnTheFlyCreate",

View File

@@ -1,23 +0,0 @@
<template>
<div v-if="action === 'show'">
show
thirdparty
{{ id }}
</div>
<div v-else-if="action === 'edit' || action === 'create'">
{{ action }}
thirdparty
{{ id }}
</div>
</template>
<script>
export default {
name: "OnTheFlyThirdParty",
props: ['id', 'type', 'action']
}
// TODO move in ChillThirdpartyAssets
</script>
<style lang="css" scoped>
</style>

View File

@@ -41,7 +41,11 @@ const messages = {
close: "Fermer", close: "Fermer",
back: "Retour", back: "Retour",
check_all: "cocher tout", check_all: "cocher tout",
reset: "réinitialiser" reset: "réinitialiser",
redirect: {
person: "Quitter la page et ouvrir le dossier",
thirdparty: "Quitter la page et voir le tiers",
}
}, },
nav: { nav: {
next: "Suivant", next: "Suivant",
@@ -52,7 +56,9 @@ const messages = {
onthefly: { onthefly: {
show: { show: {
person: "Détails de l'usager", person: "Détails de l'usager",
thirdparty: "Détails du tiers" thirdparty: "Détails du tiers",
file_person: "Ouvrir le dossier",
file_thirdparty: "Voir le Tiers",
}, },
edit: { edit: {
person: "Modifier un usager", person: "Modifier un usager",
@@ -65,6 +71,18 @@ const messages = {
thirdparty: "un nouveau tiers professionnel" thirdparty: "un nouveau tiers professionnel"
}, },
}, },
renderbox: {
person: "Person",
birthday: {
man: "Né le",
woman: "Née le"
} ,
no_data: "Aucune information renseignée",
type: {
thirdparty: "Tiers",
person: "Usager"
}
}
} }
}; };

View File

@@ -0,0 +1,20 @@
<select class="form-select" aria-label="items Per Page" id="itemsPerPage">
<option value="10">10 {{ 'results'|trans }}</option>
<option value="20">20 {{ 'results'|trans }}</option>
<option value="50">50 {{ 'results'|trans }}</option>
<option value="100">100 {{ 'results'|trans }}</option>
</select>
<script>
let select = document.querySelector("select#itemsPerPage");
window.addEventListener('load', () =>
select.value = {{ current }}
);
select.addEventListener('change', () => {
let url = new URL(window.location.href);
let params = url.searchParams;
params.set('page', '1');
params.set('item_per_page', select.value);
url.search = params.toString();
window.location.href = url.toString();
});
</script>

View File

@@ -15,3 +15,8 @@ services:
class: Chill\MainBundle\Pagination\ChillPaginationTwig class: Chill\MainBundle\Pagination\ChillPaginationTwig
tags: tags:
- { name: twig.extension } - { name: twig.extension }
chill_main.paginator.items_per_page.twig_extensions:
class: Chill\MainBundle\Pagination\ChillItemsPerPageTwig
tags:
- { name: twig.extension }

View File

@@ -85,6 +85,7 @@ Search %pattern%: Recherche de "%pattern%"
Results %start%-%end% of %total%: Résultats %start%-%end% sur %total% Results %start%-%end% of %total%: Résultats %start%-%end% sur %total%
See all results: Voir tous les résultats See all results: Voir tous les résultats
Advanced search: Recherche avancée Advanced search: Recherche avancée
results: résultats
# timeline # timeline
Global timeline: Historique global Global timeline: Historique global

View File

@@ -1,88 +0,0 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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/>.
*/
namespace Chill\PersonBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
/**
* Description of LoadAccompanyingPeriod
*
* @author Champs-Libres Coop
*/
class LoadAccompanyingPeriod extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
public const ACCOMPANYING_PERIOD = 'parcours 1';
public function getOrder()
{
return 10004;
}
public static $references = array();
public function load(ObjectManager $manager)
{
$centerA = $this->getReference('centerA');
$centerAId = $centerA->getId();
$personIds = $this->container->get('doctrine.orm.entity_manager')
->createQueryBuilder()
->select('p.id')
->from('ChillPersonBundle:Person', 'p')
->where('p.center = :centerAId')
->orderBy('p.id', 'ASC')
->setParameter('centerAId', $centerAId)
->getQuery()
->getScalarResult();
$openingDate = new \DateTime('2020-04-01');
$person1 = $manager->getRepository(Person::class)->find($personIds[0]);
$person2 = $manager->getRepository(Person::class)->find($personIds[1]);
$socialScope = $this->getReference('scope_social');
$a = new AccompanyingPeriod($openingDate);
$a->addPerson($person1);
$a->addPerson($person2);
$a->addScope($socialScope);
$a->setStep(AccompanyingPeriod::STEP_CONFIRMED);
$manager->persist($a);
$this->addReference(self::ACCOMPANYING_PERIOD, $a);
echo "Adding one AccompanyingPeriod\n";
$manager->flush();
}
}

View File

@@ -6,7 +6,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\DataFixtures\ORM\LoadAbstractNotificationsTrait; use Chill\MainBundle\DataFixtures\ORM\LoadAbstractNotificationsTrait;
use Chill\PersonBundle\DataFixtures\ORM\LoadAccompanyingPeriod;
/** /**
* Load notififications into database * Load notififications into database
@@ -19,7 +18,7 @@ class LoadAccompanyingPeriodNotifications extends AbstractFixture implements Dep
[ [
'message' => 'Hello !', 'message' => 'Hello !',
'entityClass' => AccompanyingPeriod::class, 'entityClass' => AccompanyingPeriod::class,
'entityRef' => LoadAccompanyingPeriod::ACCOMPANYING_PERIOD, 'entityRef' => null,
'sender' => 'center a_social', 'sender' => 'center a_social',
'addressees' => [ 'addressees' => [
'center a_social', 'center a_social',
@@ -30,10 +29,15 @@ class LoadAccompanyingPeriodNotifications extends AbstractFixture implements Dep
] ]
]; ];
protected function getEntityRef()
{
return null;
}
public function getDependencies() public function getDependencies()
{ {
return [ return [
LoadAccompanyingPeriod::class, LoadPeople::class,
]; ];
} }
} }

View File

@@ -33,7 +33,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
// generate two times the participation. This will lead to // generate two times the participation. This will lead to
// some movement in participation (same people in two differents // some movement in participation (same people in two differents
// households) // households)
@@ -110,7 +110,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
$i = 0; $i = 0;
while ($i < $nb) { while ($i < $nb) {
$address = $this->createAddress(); $address = $this->createAddress();
$address->setValidFrom(\DateTime::createFromImmutable($date)); $address->setValidFrom(\DateTime::createFromImmutable($date));
if (\random_int(0, 20) < 1) { if (\random_int(0, 20) < 1) {
$date = $date->add(new \DateInterval('P'.\random_int(8, 52).'W')); $date = $date->add(new \DateInterval('P'.\random_int(8, 52).'W'));
@@ -157,6 +157,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
->setParameter('center', 'Center A') ->setParameter('center', 'Center A')
->getScalarResult() ->getScalarResult()
; ;
\shuffle($this->personIds); \shuffle($this->personIds);
} }

View File

@@ -21,9 +21,15 @@
namespace Chill\PersonBundle\DataFixtures\ORM; namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Country;
use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\PostalCode;
use Chill\MainBundle\Repository\CenterRepository;
use Chill\MainBundle\Repository\CountryRepository;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\MaritalStatus;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Repository\MaritalStatusRepository;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@@ -31,6 +37,7 @@ use Doctrine\Persistence\ObjectManager;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Faker\Factory; use Faker\Factory;
use Faker\Generator; use Faker\Generator;
use Nelmio\Alice\Faker\GeneratorFactory;
use Nelmio\Alice\Loader\NativeLoader; use Nelmio\Alice\Loader\NativeLoader;
use Nelmio\Alice\ObjectSet; use Nelmio\Alice\ObjectSet;
use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface;
@@ -44,8 +51,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
/** /**
* Load people into database * Load people into database
* *
* @author Julien Fastré <julien arobase fastre point info>
* @author Marc Ducobu <marc@champs-libres.coop>
*/ */
class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{ {
@@ -57,35 +62,50 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
protected SocialIssueRepository $socialIssueRepository; protected SocialIssueRepository $socialIssueRepository;
protected array $cacheSocialIssues = array(); protected CountryRepository $countryRepository;
public function __construct(Registry $workflowRegistry, SocialIssueRepository $socialIssueRepository) protected NativeLoader $loader;
{
/**
* @var array|SocialIssue[]
*/
protected array $cacheSocialIssues = [];
/**
* @var array|Country[]
*/
protected array $cacheCountries = [];
/**
* @var array|Center[]
*/
protected array $cacheCenters = [];
protected CenterRepository $centerRepository;
/**
* @var array|MaritalStatus[]
*/
protected array $cacheMaritalStatuses = [];
protected MaritalStatusRepository $maritalStatusRepository;
public function __construct(
Registry $workflowRegistry,
SocialIssueRepository $socialIssueRepository,
CenterRepository $centerRepository,
CountryRepository $countryRepository,
MaritalStatusRepository $maritalStatusRepository
) {
$this->faker = Factory::create('fr_FR'); $this->faker = Factory::create('fr_FR');
$this->faker->addProvider($this);
$this->workflowRegistry = $workflowRegistry; $this->workflowRegistry = $workflowRegistry;
$this->socialIssueRepository = $socialIssueRepository; $this->socialIssueRepository = $socialIssueRepository;
} $this->centerRepository = $centerRepository;
$this->countryRepository = $countryRepository;
$this->maritalStatusRepository = $maritalStatusRepository;
$this->loader = new NativeLoader($this->faker);
public function prepare()
{
//prepare days, month, years
$y = 1950;
do {
$this->years[] = $y;
$y = $y +1;
} while ($y >= 1990);
$m = 1;
do {
$this->month[] = $m;
$m = $m +1;
} while ($m >= 12);
$d = 1;
do {
$this->day[] = $d;
$d = $d + 1;
} while ($d <= 28);
} }
public function getOrder() public function getOrder()
@@ -95,8 +115,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
$this->loadRandPeople($manager);
$this->loadExpectedPeople($manager); $this->loadExpectedPeople($manager);
$this->loadRandPeople($manager);
$manager->flush(); $manager->flush();
} }
@@ -105,117 +125,102 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
{ {
echo "loading expected people...\n"; echo "loading expected people...\n";
foreach ($this->peoples as $person) {
$this->addAPerson($this->fillWithDefault($person), $manager); foreach ($this->peoples as $personDef) {
$person = $this->createExpectedPerson($personDef);
$this->addAPerson($person, $manager);
} }
} }
public function loadRandPeople(ObjectManager $manager) protected function loadRandPeople(ObjectManager $manager)
{ {
echo "loading rand people...\n"; echo "loading rand people...\n";
$persons = $this->createRandPerson()->getObjects();
$this->prepare(); foreach ($persons as $person) {
$this->addAPerson($person, $manager);
$chooseLastNameOrTri = array('tri', 'tri', 'name', 'tri'); }
$i = 0;
do {
$i++;
$sex = $this->genders[array_rand($this->genders)];
if ($chooseLastNameOrTri[array_rand($chooseLastNameOrTri)] === 'tri' ) {
$length = rand(2, 3);
$lastName = '';
for ($j = 0; $j <= $length; $j++) {
$lastName .= $this->lastNamesTrigrams[array_rand($this->lastNamesTrigrams)];
}
$lastName = ucfirst($lastName);
} else {
$lastName = $this->lastNames[array_rand($this->lastNames)];
}
if ($sex === Person::MALE_GENDER) {
$firstName = $this->firstNamesMale[array_rand($this->firstNamesMale)];
} else {
$firstName = $this->firstNamesFemale[array_rand($this->firstNamesFemale)];
}
// add an address on 80% of the created people
if (rand(0,100) < 80) {
$address = $this->getRandomAddress();
// on 30% of those person, add multiple addresses
if (rand(0,10) < 4) {
$address = array(
$address,
$this->getRandomAddress()
);
}
} else {
$address = null;
}
$person = array(
'FirstName' => $firstName,
'LastName' => $lastName,
'Gender' => $sex,
'Nationality' => (rand(0,100) > 50) ? NULL: 'BE',
'center' => (rand(0,1) == 0) ? 'centerA': 'centerB',
'Address' => $address,
'maritalStatus' => $this->maritalStatusRef[array_rand($this->maritalStatusRef)]
);
$this->addAPerson($this->fillWithDefault($person), $manager);
} while ($i <= 100);
} }
/** private function createRandPerson(): ObjectSet
* fill a person array with default value
*
* @param string[] $specific
*/
private function fillWithDefault(array $specific)
{ {
return array_merge(array( return $this->loader->loadData([
'Birthdate' => "1960-10-12", Person::class => [
'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", 'persons{1..300}' => [
'Gender' => Person::MALE_GENDER, 'firstName' => '<firstname()>',
'Email' => "roger@yopmail.com", 'lastName' => '<lastname()>',
'CountryOfBirth' => 'BE', 'gender' => '<getRandomGender()>',
'Nationality' => 'BE', 'nationality' => '<getRandomCountry()>',
'CFData' => array(), 'center' => '<getRandomCenter()>',
'Address' => null 'maritalStatus' => '<getRandomMaritalStatus()>',
), $specific); 'birthdate' => '<dateTimeBetween("-75 years", "-1 tears")>',
'placeOfBirth' => '<city()>',
'email' => '<freeEmail()>',
'countryOfBirth' => '<getRandomCountry(80)>',
]
]
]);
} }
private function getRandomSocialIssue(): SocialIssue private function createExpectedPerson($default): Person
{ {
if (0 === count($this->cacheSocialIssues)) { $person = $this->loader->loadData([
$this->cacheSocialIssues = $this->socialIssueRepository->findAll(); Person::class => [
"person" => [
'firstName' => $default['firstName'] ?? '<firstname()>',
'lastName' => $default['lastName'] ?? '<lastname()>',
'gender' => '<getRandomGender()>',
'nationality' => '<getRandomCountry()>',
'center' => '<getRandomCenter()>',
'maritalStatus' => '<getRandomMaritalStatus()>',
'birthdate' => '<dateTimeBetween("-75 years", "-1 tears")>',
'placeOfBirth' => '<city()>',
'email' => '<freeEmail()>',
'countryOfBirth' => '<getRandomCountry(80)>',
],
]
])->getObjects()['person'];
// force some values
foreach ($default as $key => $value) {
switch ($key) {
case 'birthdate':
$person->setBirthdate(new \DateTime($value));
break;
case 'center':
$person->setCenter($this->centerRepository
->findOneBy(['name' => $value]));
break;
case 'countryOfBirth':
case 'nationality':
$country = $this->countryRepository
->findOneBy(['countryCode' => $value]);
$person->{'set'.\ucfirst($key)}($country);
break;
case 'maritalStatus':
$person->setMaritalStatus($this->maritalStatusRepository
->find($value));
break;
}
} }
return $this->cacheSocialIssues[\array_rand($this->cacheSocialIssues)]; return $person;
} }
/** /**
* create a new person from array data * create a new person from array data
* *
* @param array $person
* @param ObjectManager $manager
* @throws \Exception * @throws \Exception
*/ */
private function addAPerson(array $person, ObjectManager $manager) private function addAPerson(Person $person, ObjectManager $manager)
{ {
$p = new Person();
$accompanyingPeriod = new AccompanyingPeriod( $accompanyingPeriod = new AccompanyingPeriod(
(new \DateTime()) (new \DateTime())
->sub( ->sub(
new \DateInterval('P' . \random_int(0, 180) . 'D') new \DateInterval('P' . \random_int(0, 180) . 'D')
) )
); );
$p->addAccompanyingPeriod($accompanyingPeriod); $person->addAccompanyingPeriod($accompanyingPeriod);
$accompanyingPeriod->addSocialIssue($this->getRandomSocialIssue()); $accompanyingPeriod->addSocialIssue($this->getRandomSocialIssue());
if (\random_int(0, 10) > 3) { if (\random_int(0, 10) > 3) {
@@ -225,53 +230,13 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
$workflow->apply($accompanyingPeriod, 'confirm'); $workflow->apply($accompanyingPeriod, 'confirm');
} }
foreach ($person as $key => $value) { $manager->persist($person);
switch ($key) { echo "add person'".$person->__toString()."'\n";
case 'CountryOfBirth':
case 'Nationality':
$value = $this->getCountry($value);
break;
case 'Birthdate':
$value = new \DateTime($value);
break;
case 'center':
case 'maritalStatus':
$value = $this->getReference($value);
break;
case 'accompanyingPeriods':
$this->addAccompanyingPeriods($p, $value, $manager);
break;
}
//try to add the data using the setSomething function,
// if not possible, fallback to addSomething function
if (method_exists($p, 'set'.$key)) {
call_user_func(array($p, 'set'.$key), $value);
} elseif (method_exists($p, 'add'.$key)) {
// if we have a "addSomething", we may have multiple items to add
// so, we set the value in an array if it is not an array, and
// will call the function addSomething multiple times
if (!is_array($value)) {
$value = array($value);
}
foreach($value as $v) {
if ($v !== NULL) {
call_user_func(array($p, 'add'.$key), $v);
}
}
}
}
$manager->persist($p);
echo "add person'".$p->__toString()."'\n";
} }
private function createAddress(): Address private function createAddress(): Address
{ {
$loader = new NativeLoader(); $objectSet = $this->loader->loadData([
$objectSet = $loader->loadData([
Address::class => [ Address::class => [
'address' => [ 'address' => [
'street' => '<fr_FR:streetName()>', 'street' => '<fr_FR:streetName()>',
@@ -285,6 +250,17 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
return $objectSet->getObjects()['address']; return $objectSet->getObjects()['address'];
} }
private function getRandomSocialIssue(): SocialIssue
{
if (0 === count($this->cacheSocialIssues)) {
$this->cacheSocialIssues = $this->socialIssueRepository->findAll();
}
return $this->cacheSocialIssues[\array_rand($this->cacheSocialIssues)];
}
private function getPostalCode(): PostalCode private function getPostalCode(): PostalCode
{ {
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)]; $ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)];
@@ -306,7 +282,6 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
return Point::fromLonLat($lon, $lat); return Point::fromLonLat($lon, $lat);
} }
/** /**
* Create a random address * Create a random address
* *
@@ -329,53 +304,77 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
; ;
} }
private function getCountry($countryCode) /**
* @internal This method is public and called by faker as a custom generator
* @return Center
*/
public function getRandomCenter(): Center
{ {
if ($countryCode === NULL) { if (0 === count($this->cacheCenters)) {
return NULL; $this->cacheCenters = $this->centerRepository->findAll();
} }
return $this->container->get('doctrine.orm.entity_manager')
->getRepository('ChillMainBundle:Country') return $this->cacheCenters[\array_rand($this->cacheCenters)];
->findOneByCountryCode($countryCode);
} }
private $maritalStatusRef = ['ms_single', 'ms_married', 'ms_widow', 'ms_separat', /**
'ms_divorce', 'ms_legalco', 'ms_unknown']; * @internal This method is public and called by faker as a custom generator
* @param int $nullPercentage
* @return Country|null
* @throws \Exception
*/
public function getRandomCountry(int $nullPercentage = 20): ?Country
{
if (0 === count($this->cacheCountries)) {
$this->cacheCountries = $this->countryRepository->findAll();
}
private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert", "Justin", "Brian", if ($nullPercentage < \random_int(0, 100)) {
"Compère", "Jean-de-Dieu", "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric", return NULL;
"Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", "Vursuv", "Youssef" ); }
private $firstNamesFemale = array("Svedana", "Sevlatina", "Irène", "Marcelle", return $this->cacheCountries [\array_rand($this->cacheCountries)];
"Corentine", "Alfonsine", "Caroline", "Solange", "Gostine", "Fatoumata", "Nicole", }
"Groseille", "Chana", "Oxana", "Ivana", "Julie", "Tina", "Adèle" );
private $lastNames = array("Diallo", "Bah", "Gaillot", "Martin"); /**
* @internal This method is public and called by faker as a custom generator
* @return string
*/
public function getRandomGender(): string
{
return $this->genders[array_rand($this->genders)];
}
private $lastNamesTrigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den', /**
'ta', 'mi', 'net', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al', * @internal This method is public and called by faker as a custom generator
'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", "jau", "tte", 'sir', * @param int $nullPercentage
"lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu'); * @return MaritalStatus|null
* @throws \Exception
*/
public function getRandomMaritalStatus(int $nullPercentage = 50): ?MaritalStatus
{
if (0 === count($this->cacheMaritalStatuses)) {
$this->cacheMaritalStatuses = $this->maritalStatusRepository->findAll();
}
private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER); if ($nullPercentage < \random_int(0, 100)) {
return NULL;
}
private $years = array(); return $this->cacheMaritalStatuses[array_rand($this->cacheMaritalStatuses)];
}
private $month = array(); private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER, Person::BOTH_GENDER);
private $day = array();
private $peoples = array( private $peoples = array(
array( array(
'LastName' => "Depardieu", 'lastName' => "Depardieu",
'FirstName' => "Gérard", 'firstName' => "Gérard",
'Birthdate' => "1948-12-27", 'birthdate' => "1948-12-27",
'PlaceOfBirth' => "Châteauroux", 'placeOfBirth' => "Châteauroux",
'Gender' => Person::MALE_GENDER, 'nationality' => 'RU',
'CountryOfBirth' => 'FR', 'gender' => Person::MALE_GENDER,
'Nationality' => 'RU', 'center' => 'Center A',
'center' => 'centerA',
'maritalStatus' => 'ms_divorce',
'accompanyingPeriods' => [ 'accompanyingPeriods' => [
[ [
'from' => '2015-02-01', 'from' => '2015-02-01',
@@ -394,67 +393,123 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
), ),
array( array(
//to have a person with same firstname as Gérard Depardieu //to have a person with same firstname as Gérard Depardieu
'LastName' => "Depardieu", 'lastName' => "Depardieu",
'FirstName' => "Jean", 'firstName' => "Jean",
'Birthdate' => "1960-10-12", 'birthdate' => "1960-10-12",
'CountryOfBirth' => 'FR', 'countryOfBirth' => 'FR',
'Nationality' => 'FR', 'nationality' => 'FR',
'center' => 'centerA', 'center' => 'Center A',
'maritalStatus' => 'ms_divorce' 'maritalStatus' => 'ms_divorce'
), ),
array( array(
//to have a person with same birthdate of Gérard Depardieu //to have a person with same birthdate of Gérard Depardieu
'LastName' => 'Van Snick', 'lastName' => 'Van Snick',
'FirstName' => 'Bart', 'firstName' => 'Bart',
'Birthdate' => '1948-12-27', 'birthdate' => '1948-12-27',
'center' => 'centerA', 'center' => 'Center A',
'maritalStatus' => 'ms_legalco' 'maritalStatus' => 'ms_legalco'
), ),
array( array(
//to have a woman with Depardieu as FirstName //to have a woman with Depardieu as FirstName
'LastName' => 'Depardieu', 'lastName' => 'Depardieu',
'FirstName' => 'Charline', 'firstName' => 'Charline',
'Gender' => Person::FEMALE_GENDER, 'gender' => Person::FEMALE_GENDER,
'center' => 'centerA', 'center' => 'Center A',
'maritalStatus' => 'ms_legalco' 'maritalStatus' => 'ms_legalco'
), ),
array( array(
//to have a special character in lastName //to have a special character in lastName
'LastName' => 'Manço', 'lastName' => 'Manço',
'FirstName' => 'Étienne', 'firstName' => 'Étienne',
'center' => 'centerA', 'center' => 'Center A',
'maritalStatus' => 'ms_unknown' 'maritalStatus' => 'ms_unknown'
), ),
array( array(
//to have true duplicate person //to have true duplicate person
'LastName' => "Depardieu", 'lastName' => "Depardieu",
'FirstName' => "Jean", 'firstName' => "Jean",
'Birthdate' => "1960-10-12", 'birthdate' => "1960-10-12",
'CountryOfBirth' => 'FR', 'countryOfBirth' => 'FR',
'Nationality' => 'FR', 'nationality' => 'FR',
'center' => 'centerA', 'center' => 'Center A',
'maritalStatus' => 'ms_divorce' 'maritalStatus' => 'ms_divorce'
), ),
array( array(
//to have false duplicate person //to have false duplicate person
'LastName' => "Depardieu", 'lastName' => "Depardieu",
'FirstName' => "Jeanne", 'firstName' => "Jeanne",
'Birthdate' => "1966-11-13", 'birthdate' => "1966-11-13",
'CountryOfBirth' => 'FR', 'countryOfBirth' => 'FR',
'Nationality' => 'FR', 'nationality' => 'FR',
'center' => 'centerA', 'center' => 'Center A',
'maritalStatus' => 'ms_legalco' 'maritalStatus' => 'ms_legalco'
), ),
[
'lastName' => 'Diallo',
'firstName' => "Fatoumata Binta"
],
[
'lastName' => 'Diallo',
'firstName' => 'Abdoulaye',
],
[
'lastName' => 'Diallo',
'firstName' => 'Diakite',
],
[
'lastName' => 'Diallo',
'firstName' => 'Mohamed',
],
[
'lastName' => 'Diallo',
'firstName' => 'Fatou',
],
[
'lastName' => 'Diallo',
'firstName' => 'Fanta',
],
[
'lastName' => 'Bah',
'firstName' => "Fatoumata Binta"
],
[
'lastName' => 'Bah',
'firstName' => 'Abdoulaye',
],
[
'lastName' => 'Bah',
'firstName' => 'Diakite',
],
[
'lastName' => 'Bah',
'firstName' => 'Mohamed',
],
[
'lastName' => 'Bah',
'firstName' => 'Fatou',
],
[
'lastName' => 'Bah',
'firstName' => 'Fanta',
],
[
'lastName' => 'Bah',
'firstName' => 'Gaston',
],
[
'lastName' => 'Gaillot',
'firstName' => 'Adèle',
],
); );
/*
private function addAccompanyingPeriods(Person $person, array $periods, ObjectManager $manager) private function addAccompanyingPeriods(Person $person, array $periods, ObjectManager $manager)
{ {
foreach ($periods as $period) { foreach ($periods as $period) {
echo "adding new past Accompanying Period..\n"; echo "adding new past Accompanying Period..\n";
/** @var AccompanyingPeriod $accompanyingPeriod */ /** @var AccompanyingPeriod $accompanyingPeriod
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime($period['from'])); $accompanyingPeriod = new AccompanyingPeriod(new \DateTime($period['from']));
$accompanyingPeriod $accompanyingPeriod
->setClosingDate(new \DateTime($period['to'])) ->setClosingDate(new \DateTime($period['to']))
@@ -464,4 +519,5 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
$person->addAccompanyingPeriod($accompanyingPeriod); $person->addAccompanyingPeriod($accompanyingPeriod);
} }
} }
*/
} }

View File

@@ -167,7 +167,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
/** /**
* @return DateTimeImmutable|null * @return DateTimeImmutable|null
*/ */
public function getUpdatedAt(): ?DateTimeInterface public function getUpdatedAt(): ?\DateTimeInterface
{ {
return $this->updatedAt; return $this->updatedAt;
} }

View File

@@ -0,0 +1,43 @@
<?php
namespace Chill\PersonBundle\Repository;
use Chill\PersonBundle\Entity\MaritalStatus;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
use UnexpectedValueException;
class MaritalStatusRepository implements ObjectRepository
{
private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{
$this->repository = $entityManager->getRepository(MaritalStatus::class);
}
public function find($id): ?MaritalStatus
{
return $this->repository->find($id);
}
public function findAll(): array
{
return $this->repository->findAll();
}
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria): ?MaritalStatus
{
return $this->findOneBy($criteria);
}
public function getClassName(): string
{
return MaritalStatus::class;
}
}

View File

@@ -6,15 +6,21 @@
<h1 v-else>{{ $t('course.title.active') }}</h1> <h1 v-else>{{ $t('course.title.active') }}</h1>
<persons-associated></persons-associated> <persons-associated></persons-associated>
<course-location></course-location>
<origin-demand></origin-demand> <origin-demand></origin-demand>
<requestor></requestor> <requestor></requestor>
<social-issue></social-issue> <social-issue></social-issue>
<course-location></course-location>
<referrer></referrer> <referrer></referrer>
<resources></resources> <resources></resources>
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment> <comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm> <confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
<div v-for="error in errorMsg" class="vue-component errors alert alert-danger">
<p>
<span>{{ error.sta }} {{ error.txt }}</span><br>
<span>{{ $t(error.msg) }}</span>
</p>
</div>
</template> </template>
<script> <script>
@@ -48,7 +54,8 @@ export default {
}, },
computed: mapState([ computed: mapState([
'accompanyingCourse', 'accompanyingCourse',
'addressContext' 'addressContext',
'errorMsg'
]) ])
}; };
</script> </script>
@@ -86,8 +93,27 @@ export default {
} }
& > div { & > div {
margin: 1em 3em 0; margin: 1em 3em 0;
&.flex-table {
margin: 1em 0 0;
}
} }
table {
div.flex-table {
div.item-row {
div.item-col:first-child {
flex-basis: 33%;
}
}
}
&.errors {
//display: flex;
//position: sticky;
//bottom: 0.3em;
//z-index: 1000;
margin: 1em 0;
padding: 1em;
border-radius: 0;
} }
} }
} }

View File

@@ -9,7 +9,7 @@ const getAccompanyingCourse = (id) => {
return fetch(url) return fetch(url)
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while retriving AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -32,7 +32,8 @@ const patchAccompanyingCourse = (id, body) => {
}) })
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); console.log(response);
throw { msg: 'Error while updating AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -47,7 +48,7 @@ const confirmAccompanyingCourse = (id) => {
}) })
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while confirming AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -59,7 +60,7 @@ const getSocialIssues = () => {
return fetch(url) return fetch(url)
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while retriving Social Issues.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -83,7 +84,7 @@ const postParticipation = (id, payload, method) => {
}) })
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while sending AccompanyingPeriod Course participation.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -109,7 +110,7 @@ const postRequestor = (id, payload, method) => {
}) })
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while sending AccompanyingPeriod Course requestor', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -142,7 +143,7 @@ const postResource = (id, payload, method) => {
}) })
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while sending AccompanyingPeriod Course resource.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -161,7 +162,7 @@ const postSocialIssue = (id, body, method) => {
}) })
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while updating SocialIssue.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -170,7 +171,7 @@ const getUsers = () => {
return fetch(url) return fetch(url)
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while retriving users.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -179,7 +180,7 @@ const whoami = () => {
return fetch(url) return fetch(url)
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while getting whoami.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
}; };
@@ -188,7 +189,7 @@ const getListOrigins = () => {
return fetch(url) return fetch(url)
.then(response => { .then(response => {
if (response.ok) { return response.json(); } if (response.ok) { return response.json(); }
throw Error('Error with request resource response'); throw { msg: 'Error while retriving origin\'s list.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body };
}); });
} }

View File

@@ -60,7 +60,7 @@ export default {
personId: this.person.id personId: this.person.id
}; };
this.$store.dispatch('updateLocation', payload); this.$store.dispatch('updateLocation', payload);
window.location.assign('#section-50'); window.location.assign('#section-20');
this.modal.showModal = false; this.modal.showModal = false;
} }
} }

View File

@@ -27,17 +27,19 @@
]) }} ]) }}
</div> </div>
<ul class="record_actions"> <div>
<li> <ul class="record_actions">
<button type="submit" class="btn btn-save">{{ $t('action.save') }}</button> <li>
</li> <button type="submit" class="btn btn-save">{{ $t('action.save') }}</button>
<li v-if="initialComment !== null"> </li>
<a class="btn btn-delete" <li v-if="initialComment !== null">
@click="removeComment"> <a class="btn btn-delete"
{{ $t('action.delete') }} @click="removeComment">
</a> {{ $t('action.delete') }}
</li> </a>
</ul> </li>
</ul>
</div>
</form> </form>
</div> </div>

View File

@@ -3,24 +3,43 @@
<h2><a name="section-90"></a> <h2><a name="section-90"></a>
{{ $t('confirm.title') }} {{ $t('confirm.title') }}
</h2> </h2>
<div> <div>
<p> <p v-html="$t('confirm.text_draft', [$t('course.step.draft')])"></p>
{{ $t('confirm.text_draft') }}
<span class="badge bg-secondary">{{ $t('course.step.draft') }}</span> <div v-if="!isValidToBeConfirmed">
</p> <div class="alert alert-warning">
<p> {{ $t('confirm.alert_validation') }}
{{ $t('confirm.text_active') }} <ul class="mt-2">
<span class="badge bg-primary">{{ $t('course.step.active') }}</span> <li v-for="k in validationKeys">
</p> {{ $t(notValidMessages[k].msg) }}
<a :href="notValidMessages[k].anchor">
<i class="fa fa-level-up fa-fw"></i>
</a>
</li>
</ul>
</div>
<ul class="record_actions">
<li>
<button class="btn btn-save" disabled>
{{ $t('confirm.ok') }}
</button>
</li>
</ul>
</div>
<div v-else>
<p v-html="$t('confirm.text_active', [$t('course.step.active')])"></p>
<ul class="record_actions">
<li>
<button
class="btn btn-save"
@click="modal.showModal = true">
{{ $t('confirm.ok') }}
</button>
</li>
</ul>
</div>
<ul class="record_actions">
<li>
<button class="btn btn-save" @click="modal.showModal = true">
{{ $t('confirm.ok') }}
</button>
</li>
</ul>
</div> </div>
<teleport to="body"> <teleport to="body">
@@ -43,6 +62,7 @@
</template> </template>
<script> <script>
import {mapGetters, mapState} from "vuex";
import Modal from 'ChillMainAssets/vuejs/_components/Modal'; import Modal from 'ChillMainAssets/vuejs/_components/Modal';
export default { export default {
@@ -55,13 +75,34 @@ export default {
modal: { modal: {
showModal: false, showModal: false,
modalDialogClass: "modal-dialog-centered modal-md" modalDialogClass: "modal-dialog-centered modal-md"
},
notValidMessages: {
participation: {
msg: 'confirm.participation_not_valid',
anchor: '#section-10'
},
location: {
msg: 'confirm.location_not_valid',
anchor: '#section-20' //
},
socialIssue: {
msg: 'confirm.socialIssue_not_valid',
anchor: '#section-50'
}
} }
} }
}, },
computed: { computed: {
accompanyingCourse() { ...mapState([
return this.$store.state.accompanyingCourse 'accompanyingCourse'
} ]),
...mapGetters([
'isParticipationValid',
'isSocialIssueValid',
'isLocationValid',
'validationKeys',
'isValidToBeConfirmed'
])
}, },
methods: { methods: {
confirmCourse() { confirmCourse() {
@@ -72,9 +113,3 @@ export default {
} }
} }
</script> </script>
<style lang="scss" scoped>
div.vue-component > div {
//margin: 1em;
}
</style>

View File

@@ -1,28 +1,36 @@
<template> <template>
<div class="vue-component"> <div class="vue-component">
<h2><a name="section-50"></a> <h2><a name="section-20"></a>
{{ $t('courselocation.title') }} {{ $t('courselocation.title') }}
</h2> </h2>
<div class="my-4">
<!-- {# include vue_address component #} --> <!-- {# include vue_address component #} -->
<div v-for="error in displayErrors" class="alert alert-danger my-2"> <div v-for="error in displayErrors" class="alert alert-danger my-2">
{{ error }} {{ error }}
</div> </div>
<show-address <div v-if="hasNoLocation">
v-if="accompanyingCourse.location" <label class="chill-no-data-statement">
:address="accompanyingCourse.location"> {{ $t('courselocation.no_address') }}
</show-address> </label>
</div>
<div v-if="isPersonLocation" class="alert alert-success"> <div v-if="isPersonLocation">
<label class="col-form-label">
{{ $t('courselocation.person_locator', [ accompanyingCourse.personLocation.text ]) }} {{ $t('courselocation.person_locator', [ accompanyingCourse.personLocation.text ]) }}
</div> </label>
</div>
<div v-if="isTemporaryAddress" class="alert alert-warning"> <show-address
<p>{{ $t('courselocation.temporary_address_must_be_changed') }}</p> v-if="accompanyingCourse.location"
</div> :address="accompanyingCourse.location">
</show-address>
<div v-if="isTemporaryAddress" class="alert alert-warning">
<p>{{ $t('courselocation.temporary_address_must_be_changed') }}</p>
</div>
<div>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<add-address <add-address
@@ -43,8 +51,8 @@
</button> </button>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</template> </template>
@@ -96,6 +104,9 @@ export default {
isPersonLocation() { isPersonLocation() {
return this.accompanyingCourse.locationStatus === 'person'; return this.accompanyingCourse.locationStatus === 'person';
}, },
hasNoLocation() {
return this.accompanyingCourse.locationStatus === 'none';
},
isContextEdit() { isContextEdit() {
return this.context.edit; return this.context.edit;
} }

View File

@@ -1,8 +1,8 @@
<template> <template>
<div class="vue-component"> <div class="vue-component">
<h2><a name="section-20"></a>{{ $t('origin.title') }}</h2> <h2><a name="section-30"></a>{{ $t('origin.title') }}</h2>
<div class="my-4"> <div class="mb-4">
<label for="selectOrigin"> <label for="selectOrigin">
{{ $t('origin.label') }} {{ $t('origin.label') }}
</label> </label>

View File

@@ -2,29 +2,22 @@
<div class="vue-component"> <div class="vue-component">
<h2><a name="section-10"></a>{{ $t('persons_associated.title')}}</h2> <h2><a name="section-10"></a>{{ $t('persons_associated.title')}}</h2>
<div> <div v-if="participations.length > 0">
<label class="col-form-label">{{ $tc('persons_associated.counter', counter) }}</label> <label class="col-form-label">{{ $tc('persons_associated.counter', counter) }}</label>
</div> </div>
<div v-else>
<label class="chill-no-data-statement">{{ $tc('persons_associated.counter', counter) }}</label>
</div>
<table class="table table-bordered table-striped border-dark align-middle" v-if="participations.length > 0"> <div class="flex-table mb-3">
<thead> <participation-item
<tr> v-for="participation in participations"
<th class="chill-orange">{{ $t('persons_associated.name') }}</th> v-bind:participation="participation"
<th class="chill-orange">{{ $t('persons_associated.startdate') }}</th> v-bind:key="participation.id"
<th class="chill-orange">{{ $t('persons_associated.enddate') }}</th> @remove="removeParticipation"
<th class="chill-orange">{{ $t('action.actions') }}</th> @close="closeParticipation">
</tr> </participation-item>
</thead> </div>
<tbody>
<person-item
v-for="participation in participations"
v-bind:participation="participation"
v-bind:key="participation.id"
@remove="removeParticipation"
@close="closeParticipation">
</person-item>
</tbody>
</table>
<div> <div>
<add-persons <add-persons
@@ -42,13 +35,13 @@
<script> <script>
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import PersonItem from "./PersonsAssociated/PersonItem.vue" import ParticipationItem from "./PersonsAssociated/ParticipationItem.vue"
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue' import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'
export default { export default {
name: 'PersonsAssociated', name: 'PersonsAssociated',
components: { components: {
PersonItem, ParticipationItem,
AddPersons AddPersons
}, },
data() { data() {

View File

@@ -0,0 +1,111 @@
<template>
<person-render-box
:options="{
addInfo : true,
addId : false,
addEntity: false,
addLink: false,
addAltNames: true,
addAge : false,
hLevel : 3,
}"
:person="participation.person">
<template v-slot:record-actions>
<ul class="record_actions">
<button-location
v-if="hasCurrentHouseholdAddress"
v-bind:person="participation.person">
</button-location>
<li>
<on-the-fly
v-bind:type="participation.person.type"
v-bind:id="participation.person.id"
action="show">
</on-the-fly>
</li>
<li>
<on-the-fly
v-bind:type="participation.person.type"
v-bind:id="participation.person.id"
action="edit">
</on-the-fly>
</li>
<!-- <li>
<button class="btn btn-delete"
:title="$t('action.delete')"
@click.prevent="$emit('remove', participation)">
</button>
</li> -->
<li>
<button v-if="!participation.endDate"
class="btn btn-sm btn-remove"
v-bind:title="$t('action.remove')"
@click.prevent="$emit('close', participation)">
</button>
<button v-else
class="btn btn-sm btn-remove disabled"></button>
</li>
</ul>
</template>
</person-render-box>
</template>
<script>
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
import ButtonLocation from '../ButtonLocation.vue';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
export default {
name: 'ParticipationItem',
components: {
OnTheFly,
ButtonLocation,
PersonRenderBox
},
props: ['participation'],
emits: ['remove', 'close'],
data() {
return {
PersonRenderBox: {
participation: 'participation',
options: {
addInfo: false,
addId: true,
addAge: false,
hLevel: 1
}
}
}
},
computed: {
hasCurrentHouseholdAddress() {
if ( !this.participation.endDate
&& this.participation.person.current_household_address !== null ) {
return true;
}
return false;
}
}
}
/*
* dates of participation
*
* :title="$t('persons_associated.date_start_to_end', {
* start: $d(participation.startDate.datetime, 'short'),
* end: $d(participation.endDate.datetime, 'short')
* })"
*
* <tr>
* <td><span v-if="participation.startDate">
* {{ $d(participation.startDate.datetime, 'short') }}</span>
* </td>
* <td><span v-if="participation.endDate">
* {{ $d(participation.endDate.datetime, 'short') }}</span>
* </td>
* </tr>
*
*/
</script>

View File

@@ -1,74 +0,0 @@
<template>
<tr>
<td>
{{ participation.person.firstName }}
{{ participation.person.lastName }}
</td>
<td><span v-if="participation.startDate">
{{ $d(participation.startDate.datetime, 'short') }}</span>
</td>
<td><span v-if="participation.endDate">
{{ $d(participation.endDate.datetime, 'short') }}</span>
</td>
<td>
<ul class="record_actions">
<button-location
v-if="hasCurrentHouseholdAddress"
v-bind:person="participation.person">
</button-location>
<li>
<on-the-fly
v-bind:type="participation.person.type"
v-bind:id="participation.person.id"
action="show">
</on-the-fly>
</li>
<li>
<on-the-fly
v-bind:type="participation.person.type"
v-bind:id="participation.person.id"
action="edit">
</on-the-fly>
</li>
<!--li>
<button class="btn btn-delete"
:title="$t('action.delete')"
@click.prevent="$emit('remove', participation)">
</button>
</li-->
<li>
<button v-if="!participation.endDate"
class="btn btn-sm btn-remove"
v-bind:title="$t('action.remove')"
@click.prevent="$emit('close', participation)">
</button>
<button v-else class="btn btn-sm btn-remove" disabled></button>
</li>
</ul>
</td>
</tr>
</template>
<script>
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
import ButtonLocation from '../ButtonLocation.vue';
export default {
name: 'PersonItem',
components: {
OnTheFly,
ButtonLocation
},
props: ['participation'],
emits: ['remove', 'close'],
computed: {
hasCurrentHouseholdAddress() {
if ( !this.participation.endDate
&& this.participation.person.current_household_address !== null ) {
return true;
}
return false;
}
}
}
</script>

View File

@@ -2,7 +2,7 @@
<div class="vue-component"> <div class="vue-component">
<h2><a name="section-60"></a>{{ $t('referrer.title') }}</h2> <h2><a name="section-60"></a>{{ $t('referrer.title') }}</h2>
<div class="my-4"> <div>
<label class="col-form-label" for="selectReferrer"> <label class="col-form-label" for="selectReferrer">
{{ $t('referrer.label') }} {{ $t('referrer.label') }}
</label> </label>
@@ -18,7 +18,9 @@
v-bind:options="options" v-bind:options="options"
@select="updateReferrer"> @select="updateReferrer">
</VueMultiselect> </VueMultiselect>
</div>
<div>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<button <button
@@ -30,8 +32,8 @@
</button> </button>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
</template> </template>

View File

@@ -1,17 +1,58 @@
<template> <template>
<div class="vue-component"> <div class="vue-component">
<!-- {{ accompanyingCourse.requestor }} -->
<h2><a name="section-30"></a>{{ $t('requestor.title') }}</h2> <h2><a name="section-40"></a>{{ $t('requestor.title') }}</h2>
<div v-if="accompanyingCourse.requestor" class="flex-table"> <div v-if="accompanyingCourse.requestor" class="flex-table">
<label> <label>
<input type="checkbox" v-model="isAnonymous" class="me-2" /><!-- :value="value" --> <input type="checkbox" v-model="isAnonymous" class="me-2" />
{{ $t('requestor.is_anonymous') }} {{ $t('requestor.is_anonymous') }}
</label> </label>
<third-party-render-box v-if="accompanyingCourse.requestor.type == 'thirdparty'"
:thirdparty="accompanyingCourse.requestor"
:options="{
addLink: false,
addId: false,
addEntity: true,
addInfo: true,
hLevel: 3,
isMultiline: true
}"
>
<template v-slot:record-actions>
<ul class="record_actions">
<button-location v-if="hasCurrentHouseholdAddress" :thirdparty="accompanyingCourse.requestor"></button-location>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit"></on-the-fly></li>
</ul>
</template>
</third-party-render-box>
<div class="item-bloc"> <person-render-box v-else-if="accompanyingCourse.requestor.type == 'person'"
<h4> :person="accompanyingCourse.requestor"
:options="{
addLink: false,
addId: false,
addAltNames: false,
addEntity: true,
addInfo: true,
hLevel: 3,
isMultiline: true
}"
>
<template v-slot:record-actions>
<ul class="record_actions">
<button-location v-if="hasCurrentHouseholdAddress" :person="accompanyingCourse.requestor"></button-location>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="accompanyingCourse.requestor.type" :id="accompanyingCourse.requestor.id" action="edit"></on-the-fly></li>
</ul>
</template>
</person-render-box>
<!-- <h4>
<span class="badge rounded-pill bg-secondary">{{ accompanyingCourse.requestor.type }}</span> <span class="badge rounded-pill bg-secondary">{{ accompanyingCourse.requestor.type }}</span>
{{ accompanyingCourse.requestor.text }} {{ accompanyingCourse.requestor.text }}
</h4> </h4>
@@ -54,8 +95,8 @@
action="edit"> action="edit">
</on-the-fly> </on-the-fly>
</li> </li>
</ul> </ul> -->
</div>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<button class="btn btn-remove" <button class="btn btn-remove"
@@ -67,7 +108,7 @@
</ul> </ul>
</div> </div>
<div v-else> <div v-else>
<label>{{ $t('requestor.counter') }}</label> <label class="chill-no-data-statement">{{ $t('requestor.counter') }}</label>
</div> </div>
<div> <div>
@@ -87,12 +128,16 @@
<script> <script>
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue'; import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue'; import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
import PersonRenderBox from '../../_components/Entity/PersonRenderBox.vue';
import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue';
export default { export default {
name: 'Requestor', name: 'Requestor',
components: { components: {
AddPersons, AddPersons,
OnTheFly OnTheFly,
PersonRenderBox,
ThirdPartyRenderBox,
}, },
data() { data() {
return { return {

View File

@@ -3,28 +3,21 @@
<h2><a name="section-70"></a>{{ $t('resources.title')}}</h2> <h2><a name="section-70"></a>{{ $t('resources.title')}}</h2>
<div> <div v-if="resources.length > 0">
<label class="col-form-label">{{ $tc('resources.counter', counter) }}</label> <label class="col-form-label">{{ $tc('resources.counter', counter) }}</label>
</div> </div>
<div v-else>
<label class="chill-no-data-statement">{{ $tc('resources.counter', counter) }}</label>
</div>
<table class="table table-bordered table-striped border-dark align-middle" v-if="resources.length > 0"> <div class="flex-table mb-3">
<thead> <resource-item
<tr> v-for="resource in resources"
<th class="chill-orange">{{ $t('resources.text') }}</th> v-bind:resource="resource"
<th class="chill-orange">{{ $t('resources.description') }}</th> v-bind:key="resource.id"
<th class="chill-orange">{{ $t('action.actions') }}</th> @remove="removeResource">
</tr> </resource-item>
</thead> </div>
<tbody>
<resource-item
v-for="resource in resources"
v-bind:resource="resource"
v-bind:key="resource.id"
@remove="removeResource">
</resource-item>
</tbody>
</table>
<div> <div>
<add-persons <add-persons
buttonTitle="resources.add_resources" buttonTitle="resources.add_resources"

View File

@@ -1,71 +1,54 @@
<template> <template>
<tr> <person-render-box
v-if="resource.resource.type === 'person'"
:person="resource.resource"
:options="{ addInfo : true, addId : false, addEntity: true, addLink: false, addAltNames: true, addAge : false, hLevel : 3 }"
>
<template v-slot:record-actions>
<ul class="record_actions">
<button-location v-if="hasCurrentHouseholdAddress" :person="resource.resource"></button-location>
<li><on-the-fly :type="resource.resource.type" :id="resource.resource.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="resource.resource.type" :id="resource.resource.id" action="edit"></on-the-fly></li>
<li><button class="btn btn-sm btn-remove" :title="$t('action.remove')" @click.prevent="$emit('remove', resource)"></button></li>
</ul>
</template>
<td> </person-render-box>
<span class="badge rounded-pill bg-secondary" <third-party-render-box
v-bind:title="resource.resource.id"> v-if="resource.resource.type === 'thirdparty'"
<span v-if="resource.resource.type === 'person'" >{{ $t('item.type_person') }}</span> :thirdparty="resource.resource"
<span v-if="resource.resource.type === 'thirdparty'" >{{ $t('item.type_thirdparty') }}</span> :options="{ addLink : false, addId : false, addEntity: true, addInfo: true, hLevel: 3 }"
</span> >
{{ resource.resource.text }} <template v-slot:record-actions>
</td> <ul class="record_actions">
<li><on-the-fly :type="resource.resource.type" :id="resource.resource.id" action="show"></on-the-fly></li>
<li><on-the-fly :type="resource.resource.type" :id="resource.resource.id" action="edit"></on-the-fly></li>
<li><button class="btn btn-sm btn-remove" :title="$t('action.remove')" @click.prevent="$emit('remove', resource)"></button></li>
</ul>
</template>
<td v-if="resource.resource.type === 'person'"> </third-party-render-box>
{{ $tc('person.born') }}{{ $d(resource.resource.birthdate.datetime, 'short') }}
</td>
<td v-else-if="resource.resource.type === 'thirdparty'">
{{ resource.resource.address.text }}<br>
{{ resource.resource.address.postcode.name }}
</td>
<td>
<ul class="record_actions">
<button-location
v-if="hasCurrentHouseholdAddress"
v-bind:person="resource.resource">
</button-location>
<li>
<on-the-fly
v-bind:type="resource.resource.type"
v-bind:id="resource.resource.id"
action="show">
</on-the-fly>
</li>
<li>
<on-the-fly
v-bind:type="resource.resource.type"
v-bind:id="resource.resource.id"
action="edit">
</on-the-fly>
</li>
<li>
<button
class="btn btn-sm btn-remove"
v-bind:title="$t('action.remove')"
@click.prevent="$emit('remove', resource)">
</button>
</li>
</ul>
</td>
</tr>
</template> </template>
<script> <script>
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue'; import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
import ButtonLocation from '../ButtonLocation.vue'; import ButtonLocation from '../ButtonLocation.vue';
import PersonRenderBox from 'ChillPersonAssets/vuejs/_components/Entity/PersonRenderBox.vue';
import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue';
export default { export default {
name: 'ResourceItem', name: 'ResourceItem',
components: { components: {
OnTheFly, OnTheFly,
ButtonLocation ButtonLocation,
PersonRenderBox,
ThirdPartyRenderBox
}, },
props: ['resource'], props: ['resource'],
emits: ['remove'], emits: ['remove'],
computed: { computed: {
hasCurrentHouseholdAddress() { hasCurrentHouseholdAddress() {
if ( !this.resource.resource.type === 'person' if ( this.resource.resource.current_household_address !== null ) {
&& this.resource.resource.current_household_address !== null ) {
return true; return true;
} }
return false; return false;

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="vue-component"> <div class="vue-component">
<h2><a name="section-40"></a>{{ $t('social_issue.title') }}</h2> <h2><a name="section-50"></a>{{ $t('social_issue.title') }}</h2>
<div class="my-4"> <div class="my-4">
<!--label for="field">{{ $t('social_issue.label') }}</label <!--label for="field">{{ $t('social_issue.label') }}</label

View File

@@ -0,0 +1,14 @@
{
"name": "vendor_name/AccompanyingCourse",
"description": "description",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "mat",
"email": "email@example.com"
}
],
"require": {
}
}

View File

@@ -34,13 +34,14 @@ const appMessages = {
}, },
persons_associated: { persons_associated: {
title: "Usagers concernés", title: "Usagers concernés",
counter: "Il n'y a pas encore d'usager | 1 usager | {count} usagers", counter: "Il n'y a pas encore d'usagers | 1 usager | {count} usagers",
firstname: "Prénom", firstname: "Prénom",
lastname: "Nom", lastname: "Nom",
name: "Nom", name: "Nom",
startdate: "Date d'entrée", startdate: "Date d'entrée",
enddate: "Date de sortie", enddate: "Date de sortie",
add_persons: "Ajouter des usagers", add_persons: "Ajouter des usagers",
date_start_to_end: "Participation du {start} au {end}",
}, },
requestor: { requestor: {
title: "Demandeur", title: "Demandeur",
@@ -70,11 +71,12 @@ const appMessages = {
edit_temporary_address: "Modifier l'adresse temporaire", edit_temporary_address: "Modifier l'adresse temporaire",
assign_course_address: "Désigner comme l'adresse du parcours", assign_course_address: "Désigner comme l'adresse du parcours",
remove_button: "Enlever l'adresse", remove_button: "Enlever l'adresse",
temporary_address_must_be_changed: "Cette addresse est temporaire et doit être remplacée par celle d'un usager de référence.", temporary_address_must_be_changed: "Cette addresse est temporaire et devrait être remplacée par celle d'un usager de référence.",
sure: "Êtes-vous sûr ?", sure: "Êtes-vous sûr ?",
sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?", sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?",
ok: "Désigner comme adresse du parcours", ok: "Désigner comme adresse du parcours",
person_locator: "Parcours localisé auprès de {0}", person_locator: "Parcours localisé auprès de {0}",
no_address: "Il n'y a pas d'adresse associée au parcours"
}, },
referrer: { referrer: {
title: "Référent du parcours", title: "Référent du parcours",
@@ -97,13 +99,28 @@ const appMessages = {
}, },
confirm: { confirm: {
title: "Confirmation", title: "Confirmation",
text_draft: "Le parcours est actuellement à l'état de ", text_draft: "Le parcours est actuellement à l'état de <b>{0}</b>.",
text_active: "En validant cette étape, vous lui donnez le statut ", text_active: "En validant cette étape, vous lui donnez le statut <b>{0}</b>.",
alert_validation: "Certaines conditions ne sont pas remplies pour pouvoir confirmer le parcours :",
participation_not_valid: "sélectionnez au minimum 1 usager",
socialIssue_not_valid: "sélectionnez au minimum une problématique sociale",
location_not_valid: "indiquez au minimum une localisation temporaire du parcours",
sure: "Êtes-vous sûr ?", sure: "Êtes-vous sûr ?",
sure_description: "Une fois le changement confirmé, il n'est plus possible de le remettre à l'état de brouillon !", sure_description: "Une fois le changement confirmé, il ne sera plus possible de le remettre à l'état de brouillon !",
ok: "Confirmer le parcours" ok: "Confirmer le parcours"
}, },
// catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",
'Error while retriving AccompanyingPeriod Course.': "Erreur du serveur lors du chargement du parcours d'accompagnement.",
'Error while confirming AccompanyingPeriod Course.': "Erreur du serveur lors de la confirmation du parcours d'accompagnement.",
'Error while retriving Social Issues.': "Erreur du serveur lors du chargement des problématique sociales.",
'Error while sending AccompanyingPeriod Course participation.': "Erreur du serveur lors de l'envoi des infos d'un usager.",
'Error while sending AccompanyingPeriod Course requestor': "Erreur du serveur lors de l'envoi des infos du demandeur.",
'Error while sending AccompanyingPeriod Course resource.': "Erreur du serveur lors de l'envoi des infos d'un interlocuteur privilégié.",
'Error while updating SocialIssue.': "Erreur du serveur lors de la mise à jour d'une problématique sociale.",
'Error while retriving users.': "Erreur du serveur lors du chargement de la liste des travailleurs.",
'Error while getting whoami.': "Erreur du serveur lors de la requête 'qui suis-je ?'",
'Error while retriving origin\'s list.': "Erreur du serveur lors du chargement de la liste des origines de la demande.",
} }
}; };

View File

@@ -25,9 +25,33 @@ let initPromise = getAccompanyingCourse(id)
errorMsg: [] errorMsg: []
}, },
getters: { getters: {
isParticipationValid(state) {
return state.accompanyingCourse.participations.length > 0;
},
isSocialIssueValid(state) {
return state.accompanyingCourse.socialIssues.length > 0;
},
isLocationValid(state) {
return state.accompanyingCourse.location !== null;
},
validationKeys(state, getters) {
let keys = [];
if (!getters.isParticipationValid) { keys.push('participation'); }
if (!getters.isLocationValid) { keys.push('location'); }
if (!getters.isSocialIssueValid) { keys.push('socialIssue'); }
//console.log('getter keys', keys);
return keys;
},
isValidToBeConfirmed(state, getters) {
if (getters.validationKeys.length === 0) {
return true;
}
return false;
}
}, },
mutations: { mutations: {
catchError(state, error) { catchError(state, error) {
console.log('### mutation: a new error have been catched and pushed in store !', error);
state.errorMsg.push(error); state.errorMsg.push(error);
}, },
removeParticipation(state, participation) { removeParticipation(state, participation) {

View File

@@ -0,0 +1,48 @@
// CURRENTLY NOT IN USE
<template>
<li v-if="address" class="chill-entity entity-address">
<i v-if="options.with_picto == true" class="fa fa-fw fa-map-marker"></i>
<span v-if="options.render == 'list' || options.render == 'list'" :class="'address ' + {'multiline' : options.multiline === true}">
<!-- if address.street is not empty -->
<p v-if="address.street" class="street">{{ address.street }}
<!-- if address.streetNumber is not empty -->
<span v-if="address.streetNumber" class="streetnumber">{{ address.streetNumber }}</span>
</p>
<!-- if options['extended_infos'] -->
<div v-if="options.extended_infos == true">
<span v-if="address.floor" class="floor">{{ address.floor }}</span>
<span v-if="address.corridor" class="corridor">{{ address.corridor }}</span>
<span v-if="address.steps" class="steps">{{ address.steps }}</span>
<span v-if="address.buildingName" class="buildingName">{{ address.buildingName }}</span>
<span v-if="address.flat" class="flat">{{ address.flat }}</span>
<span v-if="address.distribution" class="distribution">{{ address.distribution }}</span>
<span v-if="address.extra" class="extra">{{ address.extra }}</span>
</div>
<!-- if address.postCode is not empty -->
<div v-if="address.postCode">
<p class="postcode">
<span class="code">{{ address.postCode.code }}</span>
<span class="name">{{ address.postCode.name }}</span>
</p>
<p class="country">{{ address.postCode.country.name }}</p>
</div>
</span>
</li>
</template>
<script>
export default{
name: "AddressRenderBox",
props: ['address', 'options']
}
</script>

View File

@@ -0,0 +1,158 @@
<template>
<div class="item-bloc">
<section class="chill-entity entity-person">
<div class="item-row entity-bloc">
<div class="item-col">
<div class="entity-label">
<div :class="'denomination h' + options.hLevel">
<a v-if="this.options.addLink == true" href="#">
<span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span>
<span v-if="person.altNames && options.addAltNames == true" class="altnames">
<span :class="'altname altname-' + altNameKey">{{ altNameLabel }}</span>
</span>
</a>
<span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span>
<span v-if="person.altNames && options.addAltNames == true" class="altnames">
<span :class="'altname altname-' + altNameKey">{{ altNameLabel }}</span>
</span>
<span v-if="options.addId == true" class="id-number" :title="'n° ' + person.id">{{ person.id }}</span>
<span v-if="options.addEntity == true" class="badge rounded-pill bg-secondary">{{ $t('renderbox.person') }}</span>
</div>
<p v-if="this.options.addInfo == true" class="moreinfo">
<i :class="'fa fa-fw ' + getGenderIcon" title="{{ getGender }}"></i>
<time v-if="person.birthdate" datetime="{{ person.birthdate }}" title="{{ birthdate }}">
{{ $t(getGender) + ' ' + $d(birthdate, 'text') }}
</time>
<time v-else-if="person.deathdate" datetime="{{ person.deathdate }}" title="{{ person.deathdate }}">
{{ birthdate }} - {{ deathdate }}
</time>
<!-- <span class="age">{{ person.age }}</span> -->
</p>
</div>
</div>
<div class="item-col separator">
<ul class="list-content fa-ul">
<li v-if="person.current_household_address">
<i class="fa fa-li fa-map-marker"></i>
<show-address :address="person.current_household_address" :isMultiline="isMultiline"></show-address>
</li>
<li v-else-if="options.addNoData">
<i class="fa fa-li fa-map-marker"></i>
<p class="chill-no-data-statement">{{ $t('renderbox.no_data') }}</p>
</li>
<li v-if="person.mobilenumber">
<i class="fa fa-li fa-mobile"></i>
<a :href="'tel: ' + person.mobilenumber">{{ person.mobilenumber }}</a>
</li>
<li v-else-if="options.addNoData">
<i class="fa fa-li fa-mobile"></i>
<p class="chill-no-data-statement">{{ $t('renderbox.no_data') }}</p>
</li>
<li v-if="person.phonenumber">
<i class="fa fa-li fa-phone"></i>
<a :href="'tel: ' + person.phonenumber">{{ person.phonenumber }}</a>
</li>
<li v-else-if="options.addNoData">
<i class="fa fa-li fa-phone"></i>
<p class="chill-no-data-statement">{{ $t('renderbox.no_data') }}</p>
</li>
<li v-if="person.center && options.addCenter">
<i class="fa fa-li fa-long-arrow-right"></i>
{{ person.center.name }}
</li>
<li v-else-if="options.addNoData">
<i class="fa fa-li fa-long-arrow-right"></i>
<p class="chill-no-data-statement">{{ $t('renderbox.no_data') }}</p>
</li>
<slot name="custom-zone"></slot>
</ul>
<slot name="record-actions"></slot>
</div>
</div>
</section>
</div>
</template>
<script>
import {dateToISO} from 'ChillMainAssets/chill/js/date.js';
import ShowAddress from 'ChillMainAssets/vuejs/Address/components/ShowAddress.vue';
export default {
name: "PersonRenderBox",
components: {
ShowAddress
},
props: ['person', 'options'],
computed: {
getGender: function() {
return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
},
isMultiline: function() {
if(this.options.isMultiline){
return this.options.isMultiline
} else {
return false
}
},
getGenderIcon: function() {
return this.person.gender == 'woman' ? 'fa-venus' : this.person.gender == 'man' ? 'fa-mars' : 'fa-neuter';
},
birthdate: function(){
var date = new Date(this.person.birthdate.datetime);
return dateToISO(date);
},
deathdate: function(){
var date = new Date(this.person.deathdate.datetime);
return dateToISO(date);
},
altNameLabel: function(){
for(let i = 0; i < this.person.altNames.length; i++){
return this.person.altNames[i].label
}
},
altNameKey: function(){
for(let i = 0; i < this.person.altNames.length; i++){
return this.person.altNames[i].key
}
},
}
}
</script>
<style lang='scss'>
.lastname:before{
content: " "
}
div.item-col:first-child{
width: 33%;
}
div.flex-table {
div.item-bloc {
div.item-row {
div.item-col:last-child {
justify-content: flex-start;
}
}
}
}
</style>

View File

@@ -1,57 +1,23 @@
<template> <template>
<div v-if="action === 'show'"> <div v-if="action === 'show'">
<div class="flex-table"> <div class="flex-table">
<div class="item-bloc"> <person-render-box
<div class="item-row"> :person="person"
<div class="item-col"> :options="{
<h3 :title="person.id">{{ person.text }}</h3> addInfo: true,
<p> addEntity: false,
<i class="fa fa-fw" addAltNames: true,
:class="genderClass"> addId: true,
<!-- addLink: false,
:title="$t(genderTranslation)" hLevel: 3,
--> addCenter: true,
</i> addNoData: true,
<span v-if="person.birthdate"> isMultiline: true
{{ $t('person.born', { e: feminized }) }} }"
{{ $d(person.birthdate.datetime, 'short') }} ></person-render-box>
</span>
</p>
</div>
<div class="item-col">
<dl class="list-content">
<dt>{{ $t('person.firstname') }}</dt>
<dd>{{ person.firstName }}</dd>
<dt>{{ $t('person.lastname') }}</dt>
<dd>{{ person.lastName }}</dd>
<dt>{{ $t('person.altnames') }}</dt>
<dd>{{ person.altNames }}</dd>
<span v-if="person.center">
<dt>{{ $t('person.center_name') }}</dt>
<dd :title="person.center.id">{{ person.center.name }}</dd>
</span>
<dt>{{ $t('person.phonenumber') }}</dt>
<dd>{{ person.phonenumber }}</dd>
<dt>{{ $t('person.mobilenumber') }}</dt>
<dd>{{ person.mobilenumber }}</dd>
<dt>{{ $t('person.gender.title') }}</dt>
<!--
<dd>{{ $t(genderTranslation) }}</dd>
-->
</dl>
</div>
</div>
</div>
</div> </div>
</div> </div>
<div v-else-if="action === 'edit' || action === 'create'"> <div v-else-if="action === 'edit' || action === 'create'">
<div class="form-floating mb-3"> <div class="form-floating mb-3">
@@ -109,10 +75,14 @@
<script> <script>
import { getPerson, postPerson } from '../../_api/OnTheFly'; import { getPerson, postPerson } from '../../_api/OnTheFly';
import PersonRenderBox from '../Entity/PersonRenderBox.vue';
export default { export default {
name: "OnTheFlyPerson", name: "OnTheFlyPerson",
props: ['id', 'type', 'action'], props: ['id', 'type', 'action'],
components: {
PersonRenderBox
},
data() { data() {
return { return {
person: { person: {
@@ -204,10 +174,6 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
ul {
li::marker {
}
}
div.flex-table { div.flex-table {
div.item-bloc { div.item-bloc {
div.item-row { div.item-row {

View File

@@ -137,13 +137,14 @@
{{ options['customButtons']['before'] }} {{ options['customButtons']['before'] }}
{% endif %} {% endif %}
{%- if options['customButtons']['replace'] is not defined and is_granted('CHILL_PERSON_SEE', person) -%} {%- if options['customButtons']['replace'] is defined -%}
{{ options['customButtons']['replace'] }}
{%- elseif is_granted('CHILL_PERSON_SEE', person) -%}
<li> <li>
<a class="btn btn-sm btn-show" target="_blank" title="{{ 'Show person'|trans }}" <a class="btn btn-sm btn-show" target="_blank" title="{{ 'Show person'|trans }}"
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a> href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
</li> </li>
{%- else -%} {%- else -%}
{{ options['customButtons']['replace'] }}
{%- endif -%} {%- endif -%}
{% if options['customButtons']['after'] is defined %} {% if options['customButtons']['after'] is defined %}

View File

@@ -36,8 +36,11 @@
'args' : {'person_id': person.id, 'person': person }, 'args' : {'person_id': person.id, 'person': person },
'activeRouteKey': activeRouteKey 'activeRouteKey': activeRouteKey
}) }} }) }}
<div class="block-post-menu"> {% block block_post_menu %}
{{ chill_delegated_block('person_post_vertical_menu', { 'person': person } ) }} <div class="block-post-menu">
</div> {{ chill_delegated_block('person_post_vertical_menu', { 'person': person } ) }}
</div>
{% endblock %}
{% endblock %} {% endblock %}

View File

@@ -3,7 +3,7 @@
/* /*
* Chill is a software for social workers * Chill is a software for social workers
* *
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop> * <http://www.champs-libres.coop>, <info@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
@@ -42,7 +42,7 @@ class PersonControllerCreateTest extends WebTestCase
const BIRTHDATE_INPUT = "chill_personbundle_person_creation[birthdate]"; const BIRTHDATE_INPUT = "chill_personbundle_person_creation[birthdate]";
const CREATEDATE_INPUT = "chill_personbundle_person_creation[creation_date]"; const CREATEDATE_INPUT = "chill_personbundle_person_creation[creation_date]";
const CENTER_INPUT = "chill_personbundle_person_creation[center]"; const CENTER_INPUT = "chill_personbundle_person_creation[center]";
const LONG_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq."; const LONG_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosq.";
public function setUp(): void public function setUp(): void
@@ -51,7 +51,7 @@ class PersonControllerCreateTest extends WebTestCase
} }
/** /**
* *
* @param Form $creationForm * @param Form $creationForm
*/ */
private function fillAValidCreationForm( private function fillAValidCreationForm(
@@ -64,26 +64,26 @@ class PersonControllerCreateTest extends WebTestCase
$creationForm->get(self::GENDER_INPUT)->select("man"); $creationForm->get(self::GENDER_INPUT)->select("man");
$date = new \DateTime('1947-02-01'); $date = new \DateTime('1947-02-01');
$creationForm->get(self::BIRTHDATE_INPUT)->setValue($date->format('d-m-Y')); $creationForm->get(self::BIRTHDATE_INPUT)->setValue($date->format('d-m-Y'));
return $creationForm; return $creationForm;
} }
/** /**
* Test the "add a person" page : test that required elements are present * Test the "add a person" page : test that required elements are present
* *
* see https://redmine.champs-libres.coop/projects/chillperson/wiki/Test_plan_for_page_%22add_a_person%22 * see https://redmine.champs-libres.coop/projects/chillperson/wiki/Test_plan_for_page_%22add_a_person%22
*/ */
public function testAddAPersonPage() public function testAddAPersonPage()
{ {
$client = $this->client; $client = $this->client;
$crawler = $client->request('GET', '/fr/person/new'); $crawler = $client->request('GET', '/fr/person/new');
$this->assertTrue($client->getResponse()->isSuccessful(), $this->assertTrue($client->getResponse()->isSuccessful(),
"The page is accessible at the URL /{_locale}/person/new"); "The page is accessible at the URL /{_locale}/person/new");
$form = $crawler->selectButton("Ajouter la personne")->form(); $form = $crawler->selectButton("Ajouter la personne")->form();
$this->assertInstanceOf('Symfony\Component\DomCrawler\Form', $form, $this->assertInstanceOf('Symfony\Component\DomCrawler\Form', $form,
'The page contains a butto '); 'The page contains a butto ');
$this->assertTrue($form->has(self::FIRSTNAME_INPUT), $this->assertTrue($form->has(self::FIRSTNAME_INPUT),
'The page contains a "firstname" input'); 'The page contains a "firstname" input');
@@ -91,27 +91,27 @@ class PersonControllerCreateTest extends WebTestCase
'The page contains a "lastname" input'); 'The page contains a "lastname" input');
$this->assertTrue($form->has(self::GENDER_INPUT), $this->assertTrue($form->has(self::GENDER_INPUT),
'The page contains a "gender" input'); 'The page contains a "gender" input');
$this->assertTrue($form->has(self::BIRTHDATE_INPUT), $this->assertTrue($form->has(self::BIRTHDATE_INPUT),
'The page has a "date of birth" input'); 'The page has a "date of birth" input');
$genderType = $form->get(self::GENDER_INPUT); $genderType = $form->get(self::GENDER_INPUT);
$this->assertEquals('radio', $genderType->getType(), $this->assertEquals('radio', $genderType->getType(),
'The gender input has radio buttons'); 'The gender input has radio buttons');
$this->assertEquals(3, count($genderType->availableOptionValues()), $this->assertEquals(3, count($genderType->availableOptionValues()),
'The gender input has three options: man, women and undefined'); 'The gender input has three options: man, women and undefined');
$this->assertTrue(in_array('man', $genderType->availableOptionValues()), $this->assertTrue(in_array('man', $genderType->availableOptionValues()),
'gender has "homme" option'); 'gender has "homme" option');
$this->assertTrue(in_array('woman', $genderType->availableOptionValues()), $this->assertTrue(in_array('woman', $genderType->availableOptionValues()),
'gender has "femme" option'); 'gender has "femme" option');
$this->assertFalse($genderType->hasValue(), 'The gender input is not checked'); $this->assertFalse($genderType->hasValue(), 'The gender input is not checked');
return $form; return $form;
} }
/** /**
* Test the creation of a valid person. * Test the creation of a valid person.
* *
* @param Form $form * @param Form $form
* @return string The id of the created person * @return string The id of the created person
* @depends testAddAPersonPage * @depends testAddAPersonPage
@@ -125,9 +125,9 @@ class PersonControllerCreateTest extends WebTestCase
$this->assertTrue((bool)$client->getResponse()->isRedirect(), $this->assertTrue((bool)$client->getResponse()->isRedirect(),
"a valid form redirect to url /{_locale}/person/{personId}/general/edit"); "a valid form redirect to url /{_locale}/person/{personId}/general/edit");
$client->followRedirect(); $client->followRedirect();
// visualize regexp here : http://jex.im/regulex/#!embed=false&flags=&re=%2Ffr%2Fperson%2F[1-9][0-9]*%2Fgeneral%2Fedit%24 // visualize regexp here : http://jex.im/regulex/#!embed=false&flags=&re=%2Ffr%2Fperson%2F[1-9][0-9]*%2Fgeneral%2Fedit%24
$this->assertRegExp('|/fr/person/[1-9][0-9]*/general/edit$|', $this->assertRegExp('|/fr/person/[1-9][0-9]*/general/edit$|',
$client->getHistory()->current()->getUri(), $client->getHistory()->current()->getUri(),
"a valid form redirect to url /{_locale}/person/{personId}/general/edit"); "a valid form redirect to url /{_locale}/person/{personId}/general/edit");
@@ -149,11 +149,11 @@ class PersonControllerCreateTest extends WebTestCase
$client = $this->client; $client = $this->client;
$client->request('GET', '/fr/person/'.$personId.'/general'); $client->request('GET', '/fr/person/'.$personId.'/general');
$this->assertTrue($client->getResponse()->isSuccessful(), $this->assertTrue($client->getResponse()->isSuccessful(),
"The person view page is accessible at the URL" "The person view page is accessible at the URL"
. "/{_locale}/person/{personID}/general"); . "/{_locale}/person/{personID}/general");
} }
/** /**
* test adding a person with a user with multi center * test adding a person with a user with multi center
* is valid * is valid
@@ -161,70 +161,71 @@ class PersonControllerCreateTest extends WebTestCase
public function testValidFormWithMultiCenterUser() public function testValidFormWithMultiCenterUser()
{ {
$client = $this->getClientAuthenticated('multi_center'); $client = $this->getClientAuthenticated('multi_center');
$crawler = $client->request('GET', '/fr/person/new'); $crawler = $client->request('GET', '/fr/person/new');
$this->assertTrue($client->getResponse()->isSuccessful(), $this->assertTrue($client->getResponse()->isSuccessful(),
"The page is accessible at the URL /{_locale}/person/new"); "The page is accessible at the URL /{_locale}/person/new");
$form = $crawler->selectButton("Ajouter la personne")->form(); $form = $crawler->selectButton("Ajouter la personne")->form();
$this->fillAValidCreationForm($form, 'roger', 'rabbit'); // create a very long name to avoid collision
$this->fillAValidCreationForm($form, 'Carmela Girdana Assuntamente Castalle', 'rabbit');
$this->assertTrue($form->has(self::CENTER_INPUT), $this->assertTrue($form->has(self::CENTER_INPUT),
'The page contains a "center" input'); 'The page contains a "center" input');
$centerInput = $form->get(self::CENTER_INPUT); $centerInput = $form->get(self::CENTER_INPUT);
$availableValues = $centerInput->availableOptionValues(); $availableValues = $centerInput->availableOptionValues();
$lastCenterInputValue = end($availableValues); $lastCenterInputValue = end($availableValues);
$centerInput->setValue($lastCenterInputValue); $centerInput->setValue($lastCenterInputValue);
$client->submit($form); $client->submit($form);
$this->assertTrue($client->getResponse()->isRedirect(), $this->assertTrue($client->getResponse()->isRedirect(),
"a valid form redirect to url /{_locale}/person/{personId}/general/edit"); "a valid form redirect to url /{_locale}/person/{personId}/general/edit");
$client->followRedirect(); $client->followRedirect();
$this->assertRegExp('|/fr/person/[1-9][0-9]*/general/edit$|', $this->assertRegExp('|/fr/person/[1-9][0-9]*/general/edit$|',
$client->getHistory()->current()->getUri(), $client->getHistory()->current()->getUri(),
"a valid form redirect to url /{_locale}/person/{personId}/general/edit"); "a valid form redirect to url /{_locale}/person/{personId}/general/edit");
} }
public function testReviewExistingDetectionInversedLastNameWithFirstName() public function testReviewExistingDetectionInversedLastNameWithFirstName()
{ {
$client = $this->client; $client = $this->client;
$crawler = $client->request('GET', '/fr/person/new'); $crawler = $client->request('GET', '/fr/person/new');
//test the page is loaded before continuing //test the page is loaded before continuing
$this->assertTrue($client->getResponse()->isSuccessful()); $this->assertTrue($client->getResponse()->isSuccessful());
$form = $crawler->selectButton("Ajouter la personne")->form(); $form = $crawler->selectButton("Ajouter la personne")->form();
$form = $this->fillAValidCreationForm($form, 'Charline', 'dd'); $form = $this->fillAValidCreationForm($form, 'Charline', 'dd');
$client->submit($form); $client->submit($form);
$this->assertContains('Depardieu', $client->getCrawler()->text(), $this->assertContains('Depardieu', $client->getCrawler()->text(),
"check that the page has detected the lastname of a person existing in database"); "check that the page has detected the lastname of a person existing in database");
//inversion //inversion
$form = $crawler->selectButton("Ajouter la personne")->form(); $form = $crawler->selectButton("Ajouter la personne")->form();
$form = $this->fillAValidCreationForm($form, 'dd', 'Charline'); $form = $this->fillAValidCreationForm($form, 'dd', 'Charline');
$client->submit($form); $client->submit($form);
$this->assertContains('Depardieu', $client->getCrawler()->text(), $this->assertContains('Depardieu', $client->getCrawler()->text(),
"check that the page has detected the lastname of a person existing in database"); "check that the page has detected the lastname of a person existing in database");
} }
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
static::bootKernel(); static::bootKernel();
$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager'); $em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
//remove two people created during test //remove two people created during test
$jesus = $em->getRepository('ChillPersonBundle:Person') $jesus = $em->getRepository('ChillPersonBundle:Person')
->findOneBy(array('firstName' => 'God')); ->findOneBy(array('firstName' => 'God'));
if ($jesus !== NULL) { if ($jesus !== NULL) {
$em->remove($jesus); $em->remove($jesus);
} }
$jesus2 = $em->getRepository('ChillPersonBundle:Person') $jesus2 = $em->getRepository('ChillPersonBundle:Person')
->findOneBy(array('firstName' => 'roger')); ->findOneBy(array('firstName' => 'roger'));
if ($jesus2 !== NULL) { if ($jesus2 !== NULL) {

View File

@@ -33,165 +33,165 @@ class PersonSearchTest extends WebTestCase
public function testExpected() public function testExpected()
{ {
$client = $this->getAuthenticatedClient(); $client = $this->getAuthenticatedClient();
$crawler = $client->request('GET', '/fr/search', array( $crawler = $client->request('GET', '/fr/search', array(
'q' => '@person Depardieu' 'q' => '@person Depardieu'
)); ));
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testExpectedNamed() public function testExpectedNamed()
{ {
$client = $this->getAuthenticatedClient(); $client = $this->getAuthenticatedClient();
$crawler = $client->request('GET', '/fr/search', array( $crawler = $client->request('GET', '/fr/search', array(
'q' => '@person Depardieu', 'name' => 'person_regular' 'q' => '@person Depardieu', 'name' => 'person_regular'
)); ));
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByLastName() public function testSearchByLastName()
{ {
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu'); $crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNameLower() public function testSearchByFirstNameLower()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:Gérard'); $crawler = $this->generateCrawlerForSearch('@person firstname:Gérard');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNamePartim() public function testSearchByFirstNamePartim()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:Ger'); $crawler = $this->generateCrawlerForSearch('@person firstname:Ger');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testLastNameAccentued() public function testLastNameAccentued()
{ {
$crawlerSpecial = $this->generateCrawlerForSearch('@person lastname:manço'); $crawlerSpecial = $this->generateCrawlerForSearch('@person lastname:manço');
$this->assertRegExp('/Manço/', $crawlerSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Manço/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person lastname:manco'); $crawlerNoSpecial = $this->generateCrawlerForSearch('@person lastname:manco');
$this->assertRegExp('/Manço/', $crawlerNoSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Manço/', $crawlerNoSpecial->filter('.list-with-period')->text());
} }
public function testSearchByFirstName() public function testSearchByFirstName()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:Jean'); $crawler = $this->generateCrawlerForSearch('@person firstname:Jean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNameLower2() public function testSearchByFirstNameLower2()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:jean'); $crawler = $this->generateCrawlerForSearch('@person firstname:jean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNamePartim2() public function testSearchByFirstNamePartim2()
{ {
$crawler = $this->generateCrawlerForSearch('@person firstname:ean'); $crawler = $this->generateCrawlerForSearch('@person firstname:ean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchByFirstNameAccented() public function testSearchByFirstNameAccented()
{ {
$crawlerSpecial = $this->generateCrawlerForSearch('@person firstname:Gérard'); $crawlerSpecial = $this->generateCrawlerForSearch('@person firstname:Gérard');
$this->assertRegExp('/Gérard/', $crawlerSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Gérard/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person firstname:Gerard'); $crawlerNoSpecial = $this->generateCrawlerForSearch('@person firstname:Gerard');
$this->assertRegExp('/Gérard/', $crawlerNoSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Gérard/', $crawlerNoSpecial->filter('.list-with-period')->text());
} }
public function testSearchCombineLastnameAndNationality() public function testSearchCombineLastnameAndNationality()
{ {
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu nationality:RU'); $crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu nationality:RU');
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
//if this is a AND clause, Jean Depardieu should not appears //if this is a AND clause, Jean Depardieu should not appears
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text(), $this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text(),
"assert clause firstname and nationality are AND"); "assert clause firstname and nationality are AND");
} }
public function testSearchCombineLastnameAndFirstName() public function testSearchCombineLastnameAndFirstName()
{ {
$crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu firstname:Jean'); $crawler = $this->generateCrawlerForSearch('@person lastname:Depardieu firstname:Jean');
$this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
//if this is a AND clause, Jean Depardieu should not appears //if this is a AND clause, Jean Depardieu should not appears
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text(), $this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text(),
"assert clause firstname and nationality are AND"); "assert clause firstname and nationality are AND");
} }
public function testSearchBirthdate() public function testSearchBirthdate()
{ {
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27'); $crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27');
$this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchCombineBirthdateAndLastName() public function testSearchCombineBirthdateAndLastName()
{ {
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 lastname:(Van Snick)'); $crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 lastname:(Van Snick)');
$this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Bart/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text()); $this->assertNotRegExp('/Depardieu/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchCombineGenderAndLastName() public function testSearchCombineGenderAndLastName()
{ {
$crawler = $this->generateCrawlerForSearch('@person gender:woman lastname:(Depardieu)'); $crawler = $this->generateCrawlerForSearch('@person gender:woman lastname:(Depardieu)');
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text()); $this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
} }
public function testSearchMultipleTrigramUseAndClauseInDefault() public function testSearchMultipleTrigramUseAndClauseInDefault()
{ {
$crawler = $this->generateCrawlerForSearch('@person cha dep'); $crawler = $this->generateCrawlerForSearch('@person cha dep');
$this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text()); $this->assertRegExp('/Charline/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text()); $this->assertNotRegExp('/Gérard/', $crawler->filter('.list-with-period')->text());
$this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text()); $this->assertNotRegExp('/Jean/', $crawler->filter('.list-with-period')->text());
} }
public function testDefaultAccented() public function testDefaultAccented()
{ {
$crawlerSpecial = $this->generateCrawlerForSearch('@person manço'); $crawlerSpecial = $this->generateCrawlerForSearch('@person manço');
$this->assertRegExp('/Manço/', $crawlerSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Manço/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person manco'); $crawlerNoSpecial = $this->generateCrawlerForSearch('@person manco');
$this->assertRegExp('/Manço/', $crawlerNoSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Manço/', $crawlerNoSpecial->filter('.list-with-period')->text());
$crawlerSpecial = $this->generateCrawlerForSearch('@person Étienne'); $crawlerSpecial = $this->generateCrawlerForSearch('@person Étienne');
$this->assertRegExp('/Étienne/', $crawlerSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Étienne/', $crawlerSpecial->filter('.list-with-period')->text());
$crawlerNoSpecial = $this->generateCrawlerForSearch('@person etienne'); $crawlerNoSpecial = $this->generateCrawlerForSearch('@person etienne');
$this->assertRegExp('/Étienne/', $crawlerNoSpecial->filter('.list-with-period')->text()); $this->assertRegExp('/Étienne/', $crawlerNoSpecial->filter('.list-with-period')->text());
} }
/** /**
* test that person which a user cannot see are not displayed in results * test that person which a user cannot see are not displayed in results
*/ */
@@ -199,30 +199,29 @@ class PersonSearchTest extends WebTestCase
{ {
$crawlerCanSee = $this->generateCrawlerForSearch('Gérard', 'center a_social'); $crawlerCanSee = $this->generateCrawlerForSearch('Gérard', 'center a_social');
$crawlerCannotSee = $this->generateCrawlerForSearch('Gérard', 'center b_social'); $crawlerCannotSee = $this->generateCrawlerForSearch('Gérard', 'center b_social');
$this->assertRegExp('/Gérard/', $crawlerCanSee->text(), $this->assertRegExp('/Depardieu/', $crawlerCanSee->text(),
'center a_social may see "Gérard" in center a'); 'center a_social may see "Depardieu" in center a');
$this->assertRegExp('/Aucune personne ne correspond aux termes de recherche/', $this->assertNotRegExp('/Depardieu/', $crawlerCannotSee->text(),
$crawlerCannotSee->text(), 'center b_social may see "Depardieu" in center b');
'center b_social may not see any "Gérard" associated to center b');
} }
private function generateCrawlerForSearch($pattern, $username = 'center a_social') private function generateCrawlerForSearch($pattern, $username = 'center a_social')
{ {
$client = $this->getAuthenticatedClient($username); $client = $this->getAuthenticatedClient($username);
$crawler = $client->request('GET', '/fr/search', array( $crawler = $client->request('GET', '/fr/search', array(
'q' => $pattern, 'q' => $pattern,
)); ));
$this->assertTrue($client->getResponse()->isSuccessful()); $this->assertTrue($client->getResponse()->isSuccessful());
return $crawler; return $crawler;
} }
/** /**
* *
* @return \Symfony\Component\BrowserKit\Client * @return \Symfony\Component\BrowserKit\Client
*/ */
private function getAuthenticatedClient($username = 'center a_social') private function getAuthenticatedClient($username = 'center a_social')

View File

@@ -27,7 +27,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Chill\MainBundle\Test\PrepareClientTrait; use Chill\MainBundle\Test\PrepareClientTrait;
/** /**
* This class tests entries are shown for closing and opening * This class tests entries are shown for closing and opening
* periods in timeline. * periods in timeline.
* *
* @author Julien Fastré <julien.fastre@champs-libres.coop> * @author Julien Fastré <julien.fastre@champs-libres.coop>
@@ -40,22 +40,19 @@ class TimelineAccompanyingPeriodTest extends WebTestCase
/** /**
* @dataProvider provideDataPersonWithAccompanyingPeriod * @dataProvider provideDataPersonWithAccompanyingPeriod
*/ */
public function testEntriesAreShown($personId) public function testEntriesAreShown($personId)
{ {
$client = $this->getClientAuthenticated(); $client = $this->getClientAuthenticated();
$crawler = $client->request('GET', "/en/person/{$personId}/timeline"); $crawler = $client->request('GET', "/en/person/{$personId}/timeline");
$this->assertTrue($client->getResponse()->isSuccessful(), $this->assertTrue($client->getResponse()->isSuccessful(),
"the timeline page loads sucessfully"); "the timeline page loads sucessfully");
$this->assertGreaterThan(0, $crawler->filter('.timeline div')->count(), $this->assertGreaterThan(0, $crawler->filter('.timeline div')->count(),
"the timeline page contains multiple div inside a .timeline element"); "the timeline page contains multiple div inside a .timeline element");
$this->assertContains(" Une période d'accompagnement est ouverte", $this->assertContains("est ouvert",
$crawler->filter('.timeline')->text(), $crawler->filter('.timeline')->text(),
"the text 'une période d'accompagnement a été ouverte' is present"); "the text 'est ouvert' is present");
$this->assertContains("Une periode d'accompagnement se clôture",
$crawler->Filter('.timeline')->text(),
"the text 'Une période d'accompagnement a été fermée' is present");
} }
public function provideDataPersonWithAccompanyingPeriod() public function provideDataPersonWithAccompanyingPeriod()
@@ -71,8 +68,7 @@ class TimelineAccompanyingPeriodTest extends WebTestCase
->join('part.accompanyingPeriod', 'period') ->join('part.accompanyingPeriod', 'period')
->join('p.center', 'center') ->join('p.center', 'center')
->select('p.id') ->select('p.id')
->where($qb->expr()->isNotNull('period.closingDate')) ->where($qb->expr()->eq('center.name', ':center'))
->andWhere($qb->expr()->eq('center.name', ':center'))
->setParameter('center', 'Center A') ->setParameter('center', 'Center A')
->setMaxResults(1000) ->setMaxResults(1000)
->getQuery() ->getQuery()
@@ -86,5 +82,5 @@ class TimelineAccompanyingPeriodTest extends WebTestCase
yield [ \array_pop($personIds)['id'] ]; yield [ \array_pop($personIds)['id'] ];
} }
} }

View File

@@ -46,7 +46,7 @@ Married: Marié(e)
Return: Retour Return: Retour
Submit: Submit Submit: Submit
Reset: 'Remise à zéro' Reset: 'Remise à zéro'
'The person data has been updated': 'Bravo ! Les données ont été mises à jour.' 'The person data has been updated': 'Les données ont été mises à jour.'
'{1} The person field %field% is incorrect. Please check. | ]1, Inf] Several person fields are incorrect. Please check.': '{1} Le champs %field% est incorrect. Veuillez le corriger. | ]1, Inf] Plusieurs champs sont incorrects. Veuillez les vérifier.' '{1} The person field %field% is incorrect. Please check. | ]1, Inf] Several person fields are incorrect. Please check.': '{1} Le champs %field% est incorrect. Veuillez le corriger. | ]1, Inf] Plusieurs champs sont incorrects. Veuillez les vérifier.'
'Add a person': 'Ajout d''une personne' 'Add a person': 'Ajout d''une personne'
'Person Menu': 'Menu personne' 'Person Menu': 'Menu personne'

View File

@@ -125,7 +125,7 @@ Show person: Voir le dossier de la personne
Return: Retour Return: Retour
Submit: Envoi Submit: Envoi
Reset: 'Remise à zéro' Reset: 'Remise à zéro'
'The person data has been updated': 'Bravo ! Les données ont été mises à jour.' 'The person data has been updated': 'Les données ont été mises à jour.'
'The person data provided are not valid': 'Les données introduites ne sont pas valides' 'The person data provided are not valid': 'Les données introduites ne sont pas valides'
'{1} The person field %field% is incorrect. Please check. | ]1, Inf] Several person fields are incorrect. Please check.': '{1} Le champs %field% est incorrect. Veuillez le corriger. | ]1, Inf] Plusieurs champs sont incorrects. Veuillez les vérifier.' '{1} The person field %field% is incorrect. Please check. | ]1, Inf] Several person fields are incorrect. Please check.': '{1} Le champs %field% est incorrect. Veuillez le corriger. | ]1, Inf] Plusieurs champs sont incorrects. Veuillez les vérifier.'
'Add a person': 'Ajout d''une personne' 'Add a person': 'Ajout d''une personne'

View File

@@ -28,36 +28,36 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Chill\TaskBundle\Security\Authorization\TaskVoter; use Chill\TaskBundle\Security\Authorization\TaskVoter;
/** /**
* *
* *
* @author Julien Fastré <julien.fastre@champs-libres.coop> * @author Julien Fastré <julien.fastre@champs-libres.coop>
*/ */
class UserMenuBuilder implements LocalMenuBuilderInterface class UserMenuBuilder implements LocalMenuBuilderInterface
{ {
/** /**
* *
* @var CountNotificationTask * @var CountNotificationTask
*/ */
public $counter; public $counter;
/* /*
* @var TokenStorageInterface * @var TokenStorageInterface
*/ */
public $tokenStorage; public $tokenStorage;
/** /**
* *
* @var TranslatorInterface * @var TranslatorInterface
*/ */
public $translator; public $translator;
/** /**
* *
* @var AuthorizationCheckerInterface * @var AuthorizationCheckerInterface
*/ */
public $authorizationChecker; public $authorizationChecker;
public function __construct( public function __construct(
CountNotificationTask $counter, CountNotificationTask $counter,
TokenStorageInterface $tokenStorage, TokenStorageInterface $tokenStorage,
@@ -69,44 +69,44 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
$this->translator = $translator; $this->translator = $translator;
$this->authorizationChecker = $authorizationChecker; $this->authorizationChecker = $authorizationChecker;
} }
public static function getMenuIds(): array public static function getMenuIds(): array
{ {
return [ 'user' ]; return [ 'user' ];
} }
public function buildMenu($menuId, MenuItem $menu, array $parameters) public function buildMenu($menuId, MenuItem $menu, array $parameters)
{ {
if (FALSE === $this->authorizationChecker->isGranted(TaskVoter::SHOW)) { if (FALSE === $this->authorizationChecker->isGranted(TaskVoter::SHOW)) {
return; return;
} }
$user = $this->tokenStorage->getToken()->getUser(); $user = $this->tokenStorage->getToken()->getUser();
$ended = $this->counter->countNotificationEnded($user); $ended = $this->counter->countNotificationEnded($user);
$warning = $this->counter->countNotificationWarning($user); $warning = $this->counter->countNotificationWarning($user);
if ($ended > 0) { if ($ended > 0) {
$this->addItemInMenu( $this->addItemInMenu(
$menu, $menu,
$user, $user,
'%number% tasks over deadline', '%number% tasks over deadline',
'My tasks over deadline', 'My tasks over deadline',
SingleTaskRepository::DATE_STATUS_ENDED, SingleTaskRepository::DATE_STATUS_ENDED,
$ended, $ended,
-15); -15);
} }
if ($warning > 0) { if ($warning > 0) {
$this->addItemInMenu( $this->addItemInMenu(
$menu, $menu,
$user, $user,
'%number% tasks near deadline', '%number% tasks near deadline',
'My tasks near deadline', 'My tasks near deadline',
SingleTaskRepository::DATE_STATUS_WARNING, SingleTaskRepository::DATE_STATUS_WARNING,
$warning, $warning,
-14); -14);
} }
$menu->addChild("My tasks", [ $menu->addChild("My tasks", [
'route' => 'chill_task_single_my_tasks' 'route' => 'chill_task_single_my_tasks'
]) ])
@@ -115,6 +115,7 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
'icon' => 'tasks' 'icon' => 'tasks'
]); ]);
/*
$menu->addChild("My aside activities", [ $menu->addChild("My aside activities", [
'route' => 'chill_crud_aside_activity_index' 'route' => 'chill_crud_aside_activity_index'
]) ])
@@ -122,13 +123,14 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
'order' => -10, 'order' => -10,
'icon' => 'tasks' 'icon' => 'tasks'
]); ]);
*/
} }
protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order) protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order)
{ {
if ($number > 0) { if ($number > 0) {
$menu->addChild( $menu->addChild(
$this->translator->transChoice($message, $number), $this->translator->transChoice($message, $number),
[ [
'route' => 'chill_task_singletask_list', 'route' => 'chill_task_singletask_list',
'routeParameters' => [ 'routeParameters' => [

View File

@@ -70,8 +70,6 @@ class ThirdPartyController extends Controller
$nbThirdParties = $repository->countByMemberOfCenters($centers); $nbThirdParties = $repository->countByMemberOfCenters($centers);
$pagination = $this->paginatorFactory->create($nbThirdParties); $pagination = $this->paginatorFactory->create($nbThirdParties);
$pagination->setItemsPerPage(20);
$thirdParties = $repository->findByMemberOfCenters( $thirdParties = $repository->findByMemberOfCenters(
$centers, $centers,
$pagination->getCurrentPage()->getFirstItemNumber(), $pagination->getCurrentPage()->getFirstItemNumber(),

View File

@@ -0,0 +1,46 @@
<?php
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Persistence\ObjectManager;
/**
* Class LoadThirdPartyCategory
* @package Chill\ThirdPartyBundle\DataFixtures\ORM
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
class LoadThirdPartyCategory extends Fixture implements FixtureGroupInterface
{
public static function getGroups(): array
{
return ['thirdparty_categories'];
}
public function load(ObjectManager $manager)
{
$categories = [
['name' => ['fr' => "maison médicale" ]],
['name' => ['fr' => "hôpital" ]],
['name' => ['fr' => "médecin généraliste" ]],
['name' => ['fr' => "pharmacien" ]],
['name' => ['fr' => "assistance aux personnes âgées" ]],
['name' => ['fr' => "assistante maternelle" ]],
['name' => ['fr' => "assistant social" ]],
['name' => ['fr' => "éducateur spécialisé" ]],
['name' => ['fr' => "infirmier.ère" ]],
];
foreach ( $categories as $val) {
print "Creating thirdparty category : " . $val['name']['fr'] . "\n";
$category = (new ThirdPartyCategory())
->setName($val['name'])
->setActive(true);
$manager->persist($category);
}
$manager->flush();
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCivility;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Persistence\ObjectManager;
/**
* Class LoadThirdPartyCivility
* @package Chill\ThirdPartyBundle\DataFixtures\ORM
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
class LoadThirdPartyCivility extends Fixture implements FixtureGroupInterface
{
public static function getGroups(): array
{
return ['thirdparty_civilities'];
}
public function load(ObjectManager $manager): void
{
$civilities = [
['name' => ['fr' => "Monsieur" ]],
['name' => ['fr' => "Madame" ]],
['name' => ['fr' => "Docteur" ]],
['name' => ['fr' => "Professeur" ]],
['name' => ['fr' => "Madame la Directrice" ]],
['name' => ['fr' => "Monsieur le Directeur" ]],
['name' => ['fr' => "Madame la Maire" ]],
['name' => ['fr' => "Monsieur le Maire" ]],
['name' => ['fr' => "Maître" ]],
];
foreach ( $civilities as $val) {
print "Creating thirdparty civility : " . $val['name']['fr'] . "\n";
$civility = (new ThirdPartyCivility())
->setName($val['name'])
->setActive(true);
$manager->persist($civility);
}
$manager->flush();
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Persistence\ObjectManager;
/**
* Class LoadThirdPartyProfession
* @package Chill\ThirdPartyBundle\DataFixtures\ORM
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
class LoadThirdPartyProfession extends Fixture implements FixtureGroupInterface
{
public static function getGroups(): array
{
return ['thirdparty_professions'];
}
public function load(ObjectManager $manager)
{
$professions = [
['name' => ['fr' => "Directeur" ]],
['name' => ['fr' => "Docteur" ]],
['name' => ['fr' => "Médecin" ]],
['name' => ['fr' => "Opérateur" ]],
['name' => ['fr' => "Personnel administratif" ]],
['name' => ['fr' => "Président" ]],
['name' => ['fr' => "Responsable infirmier.ère" ]],
];
foreach ( $professions as $val) {
print "Creating thirdparty professions : " . $val['name']['fr'] . "\n";
$profession = (new ThirdPartyProfession())
->setName($val['name'])
->setActive(true);
$manager->persist($profession);
}
$manager->flush();
}
}

View File

@@ -22,6 +22,7 @@
namespace Chill\ThirdPartyBundle\Entity; namespace Chill\ThirdPartyBundle\Entity;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
@@ -41,13 +42,13 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
* @ORM\Entity(repositoryClass="Chill\ThirdPartyBundle\Repository\ThirdPartyRepository") * @ORM\Entity(repositoryClass="Chill\ThirdPartyBundle\Repository\ThirdPartyRepository")
* @DiscriminatorMap(typeProperty="type", mapping={ * @DiscriminatorMap(typeProperty="type", mapping={
* "thirdparty"=ThirdParty::class * "thirdparty"=ThirdParty::class
*}) * })
* @ORM\HasLifecycleCallbacks()
*/ */
class ThirdParty class ThirdParty
{ {
/** /**
* @var int * @var int
*
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
@@ -56,15 +57,73 @@ class ThirdParty
/** /**
* @var string * @var string
*
* @ORM\Column(name="name", type="string", length=255) * @ORM\Column(name="name", type="string", length=255)
* @Assert\Length(min="2") * @Assert\Length(min="2")
*/ */
private $name; private $name;
/**
* [fr] Raison sociale
* @var string
* @ORM\Column(name="name_company", type="string", length=255, nullable=true)
* @Assert\Length(min="3")
*/
private $nameCompany;
/**
* [fr] Sigle
* @var string
* @ORM\Column(name="acronym", type="string", length=64, nullable=true)
* @Assert\Length(min="2")
*/
private $acronym;
/**
* @var ThirdPartyCategory
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyCategory")
* @ORM\JoinTable(name="chill_3party.thirdparty_category",
* joinColumns={@ORM\JoinColumn(name="thirdparty_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")})
*/
private $categories;
/**
* @var array|null
* @ORM\Column(name="types", type="json", nullable=true)
* @Assert\Count(min=1)
*/
private $type;
/**
* Contact Persons: One Institutional ThirdParty has Many Contact Persons
* @ORM\OneToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", mappedBy="parent")
*/
private Collection $children;
/**
* Institutional ThirdParty: Many Contact Persons have One Institutional ThirdParty
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
*/
private ?ThirdParty $parent;
/**
* @var ThirdPartyCivility
* @ORM\OneToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyCivility")
* @ORM\JoinColumn(name="civility", referencedColumnName="id", nullable=true)
*/
private $civility;
/**
* [fr] Qualité
* @var ThirdPartyProfession
* @ORM\OneToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
* @ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
*/
private $profession;
/** /**
* @var string|null * @var string|null
*
* @ORM\Column(name="telephone", type="string", length=64, nullable=true) * @ORM\Column(name="telephone", type="string", length=64, nullable=true)
* @Assert\Regex("/^([\+{1}])([0-9\s*]{4,20})$/", * @Assert\Regex("/^([\+{1}])([0-9\s*]{4,20})$/",
* message="Invalid phone number: it should begin with the international prefix starting with ""+"", hold only digits and be smaller than 20 characters. Ex: +33123456789" * message="Invalid phone number: it should begin with the international prefix starting with ""+"", hold only digits and be smaller than 20 characters. Ex: +33123456789"
@@ -74,41 +133,11 @@ class ThirdParty
/** /**
* @var string|null * @var string|null
*
* @ORM\Column(name="email", type="string", length=255, nullable=true) * @ORM\Column(name="email", type="string", length=255, nullable=true)
* @Assert\Email(checkMX=false) * @Assert\Email(checkMX=false)
*/ */
private $email; private $email;
/**
* @var string|null
*
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* @var array|null
*
* @ORM\Column(name="types", type="json", nullable=true)
* @Assert\Count(min=1)
*/
private $type;
/**
* @var boolean
* @ORM\Column(name="active", type="boolean", options={"defaut": true})
*/
private $active = true;
/**
* @var Collection instances of Center
* @ORM\ManyToMany(targetEntity="\Chill\MainBundle\Entity\Center")
* @ORM\JoinTable(name="chill_3party.party_center")
* @Assert\Count(min=1)
*/
private $centers;
/** /**
* @var Address|null * @var Address|null
* @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address", * @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address",
@@ -117,12 +146,69 @@ class ThirdParty
*/ */
private $address; private $address;
/**
* @var boolean
* @ORM\Column(name="active", type="boolean", options={"defaut": true})
*/
private $active = true;
/**
* @var string|null
* @ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* @var Collection
* @ORM\ManyToMany(targetEntity="\Chill\MainBundle\Entity\Center")
* @ORM\JoinTable(name="chill_3party.party_center")
* @Assert\Count(min=1)
*/
private $centers;
/**
* @ORM\Column(name="created_at", type="datetime_immutable", nullable=false)
*/
private \DateTimeImmutable $createdAt;
/**
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private ?\DateTime $updatedAt;
/**
* @var User
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @ORM\JoinColumn(name="updated_by", referencedColumnName="id")
*/
private $updatedBy;
/**
* @ORM\PrePersist()
*/
public function prePersist()
{
$this->createdAt = new \DateTimeImmutable();
}
/**
* @ORM\PreUpdate()
*/
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
/** /**
* ThirdParty constructor. * ThirdParty constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->centers = new ArrayCollection(); $this->centers = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->children = new ArrayCollection();
} }
/** /**
@@ -342,4 +428,212 @@ class ThirdParty
{ {
return $this->getName(); return $this->getName();
} }
/**
* @return string|null
*/
public function getNameCompany(): ?string
{
return $this->nameCompany;
}
/**
* @param string $nameCompany
* @return ThirdParty
*/
public function setNameCompany(string $nameCompany): ThirdParty
{
$this->nameCompany = $nameCompany;
return $this;
}
/**
* @return string
*/
public function getAcronym(): ?string
{
return $this->acronym;
}
/**
* @param string $acronym
* @return $this
*/
public function setAcronym(string $acronym): ThirdParty
{
$this->acronym = $acronym;
return $this;
}
/**
* @return Collection
*/
public function getCategories(): Collection
{
return $this->categories;
}
/**
* @param ThirdPartyCategory $category
* @return $this
*/
public function addCategory(ThirdPartyCategory $category): self
{
$this->categories[] = $category;
return $this;
}
/**
* @param ThirdPartyCategory $category
* @return $this
*/
public function removeCategory(ThirdPartyCategory $category): self
{
$this->categories->removeElement($category);
return $this;
}
public function isLeaf(): bool
{
return $this->children->count() !== 0;
}
/**
* @return Collection
*/
public function getChildren(): Collection
{
return $this->children;
}
/**
* @param ThirdParty $child
* @return $this
*/
public function addChild(ThirdParty $child): self
{
$this->children[] = $child;
return $this;
}
/**
* @param ThirdParty $child
* @return $this
*/
public function removeChild(ThirdParty $child): self
{
$this->categories->removeElement($child);
return $this;
}
/**
* @return ThirdParty|null
*/
public function getParent(): ?ThirdParty
{
return $this->parent;
}
/**
* @param ThirdParty|null $parent
* @return $this
*/
public function setParent(?ThirdParty $parent): ThirdParty
{
$this->parent = $parent;
return $this;
}
/**
* @return ThirdPartyCivility|null
*/
public function getCivility(): ?ThirdPartyCivility
{
return $this->civility;
}
/**
* @param ThirdPartyCivility $civility
* @return $this
*/
public function setCivility(ThirdPartyCivility $civility): ThirdParty
{
$this->civility = $civility;
return $this;
}
/**
* @return ThirdPartyProfession
*/
public function getProfession(): ?ThirdPartyProfession
{
return $this->profession;
}
/**
* @param ThirdPartyProfession $profession
* @return $this
*/
public function setProfession(ThirdPartyProfession $profession): ThirdParty
{
$this->profession = $profession;
return $this;
}
/**
* @return \DateTimeImmutable
*/
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;
}
/**
* @param \DateTimeImmutable $createdAt
* @return $this
*/
public function setCreatedAt(\DateTimeImmutable $createdAt): ThirdParty
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return \DateTime|null
*/
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
/**
* @param \DateTime $updatedAt
* @return $this
*/
public function setUpdatedAt(\DateTime $updatedAt): ThirdParty
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return User|null
*/
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
/**
* @param User $updatedBy
* @return $this
*/
public function setUpdatedBy(User $updatedBy): ThirdParty
{
$this->updatedBy = $updatedBy;
return $this;
}
} }

View File

@@ -0,0 +1,79 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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/>.
*/
namespace Chill\ThirdPartyBundle\Entity;
use Chill\ThirdPartyBundle\Repository\ThirdPartyCategoryRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_3party.party_category")
* @ORM\Entity(repositoryClass=ThirdPartyCategoryRepository::class)
*/
class ThirdPartyCategory
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="json")
*/
private $name = [];
/**
* @ORM\Column(type="boolean")
*/
private $active = true;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?array
{
return $this->name;
}
public function setName(array $name): self
{
$this->name = $name;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
}

View File

@@ -0,0 +1,79 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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/>.
*/
namespace Chill\ThirdPartyBundle\Entity;
use Chill\ThirdPartyBundle\Repository\ThirdPartyCivilityRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_3party.party_civility")
* @ORM\Entity(repositoryClass=ThirdPartyCivilityRepository::class)
*/
class ThirdPartyCivility
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="json")
*/
private $name = [];
/**
* @ORM\Column(type="boolean")
*/
private $active = true;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?array
{
return $this->name;
}
public function setName(array $name): self
{
$this->name = $name;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
}

View File

@@ -0,0 +1,79 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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/>.
*/
namespace Chill\ThirdPartyBundle\Entity;
use Chill\ThirdPartyBundle\Repository\ThirdPartyProfessionRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_3party.party_profession")
* @ORM\Entity(repositoryClass=ThirdPartyProfessionRepository::class)
*/
class ThirdPartyProfession
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="json")
*/
private $name = [];
/**
* @ORM\Column(type="boolean")
*/
private $active = true;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?array
{
return $this->name;
}
public function setName(array $name): self
{
$this->name = $name;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
}

View File

@@ -2,6 +2,13 @@
namespace Chill\ThirdPartyBundle\Form; namespace Chill\ThirdPartyBundle\Form;
use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCivility;
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -20,34 +27,26 @@ use Chill\MainBundle\Form\Type\AddressType;
class ThirdPartyType extends AbstractType class ThirdPartyType extends AbstractType
{ {
/** protected AuthorizationHelper $authorizationHelper;
*
* @var AuthorizationHelper protected TokenStorageInterface $tokenStorage;
*/
protected $authorizationHelper; protected ThirdPartyTypeManager $typesManager;
/** protected TranslatableStringHelper $translatableStringHelper;
*
* @var TokenStorageInterface
*/
protected $tokenStorage;
/**
*
* @var ThirdPartyTypeManager
*/
protected $typesManager;
public function __construct( public function __construct(
AuthorizationHelper $authorizationHelper, AuthorizationHelper $authorizationHelper,
TokenStorageInterface $tokenStorage, TokenStorageInterface $tokenStorage,
ThirdPartyTypeManager $typesManager ThirdPartyTypeManager $typesManager,
TranslatableStringHelper $translatableStringHelper
) { ) {
$this->authorizationHelper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
$this->typesManager = $typesManager; $this->typesManager = $typesManager;
$this->translatableStringHelper = $translatableStringHelper;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@@ -57,11 +56,31 @@ class ThirdPartyType extends AbstractType
foreach ($this->typesManager->getProviders() as $key => $provider) { foreach ($this->typesManager->getProviders() as $key => $provider) {
$types['chill_3party.key_label.'.$key] = $key; $types['chill_3party.key_label.'.$key] = $key;
} }
$builder $builder
->add('name', TextType::class, [ ->add('name', TextType::class, [
'required' => true 'required' => true
]) ])
->add('categories', EntityType::class, [
'label' => 'thirdparty.Categories',
'class' => ThirdPartyCategory::class,
'choice_label' => function (ThirdPartyCategory $category): string {
return $this->translatableStringHelper->localize($category->getName());
},
'query_builder' => function (EntityRepository $er): QueryBuilder {
return $er->createQueryBuilder('c')
->where('c.active = true');
},
'required' => true,
'multiple' => true,
'attr' => ['class' => 'select2']
])
->add('type', ChoiceType::class, [
'choices' => $types,
'expanded' => true,
'multiple' => true,
'label' => 'thirdparty.Type'
])
->add('telephone', TextType::class, [ ->add('telephone', TextType::class, [
'label' => 'Phonenumber', 'label' => 'Phonenumber',
'required' => false 'required' => false
@@ -69,16 +88,13 @@ class ThirdPartyType extends AbstractType
->add('email', EmailType::class, [ ->add('email', EmailType::class, [
'required' => false 'required' => false
]) ])
->add('comment', TextareaType::class, [ ->add('address', AddressType::class, [
'has_valid_from' => false,
'null_if_empty' => true,
'required' => false 'required' => false
]) ])
->add('type', ChoiceType::class, [
'choices' => $types,
'expanded' => true,
'multiple' => true,
'label' => 'thirdparty.Type'
])
->add('active', ChoiceType::class, [ ->add('active', ChoiceType::class, [
'label' => 'thirdparty.Status',
'choices' => [ 'choices' => [
'Active, shown to users' => true, 'Active, shown to users' => true,
'Inactive, not shown to users' => false 'Inactive, not shown to users' => false
@@ -86,22 +102,65 @@ class ThirdPartyType extends AbstractType
'expanded' => true, 'expanded' => true,
'multiple' => false 'multiple' => false
]) ])
->add('comment', ChillTextareaType::class, [
'required' => false
])
->add('centers', EntityType::class, [ ->add('centers', EntityType::class, [
'choices' => $this->getReachableCenters($options), 'choices' => $this->getReachableCenters($options),
'class' => \Chill\MainBundle\Entity\Center::class, 'class' => \Chill\MainBundle\Entity\Center::class,
'multiple' => true, 'multiple' => true,
'expanded' => true 'attr' => ['class' => 'select2']
])
->add('address', AddressType::class, [
'has_valid_from' => false,
'null_if_empty' => true,
'required' => false
]) ])
;
// Contact Person ThirdParty (child)
if ($options['data']->isLeaf()) {
$builder
->add('civility', EntityType::class, [
'label' => 'thirdparty.Civility',
'class' => ThirdPartyCivility::class,
'choice_label' => function (ThirdPartyCivility $civility): string {
return $this->translatableStringHelper->localize($civility->getName());
},
'query_builder' => function (EntityRepository $er): QueryBuilder {
return $er->createQueryBuilder('c')
->where('c.active = true');
},
'placeholder' => 'thirdparty.choose civility',
'required' => true
])
->add('profession', EntityType::class, [
'label' => 'thirdparty.Profession',
'class' => ThirdPartyProfession::class,
'choice_label' => function (ThirdPartyProfession $profession): string {
return $this->translatableStringHelper->localize($profession->getName());
},
'query_builder' => function (EntityRepository $er): QueryBuilder {
return $er->createQueryBuilder('p')
->where('p.active = true');
},
'placeholder' => 'thirdparty.choose profession',
'required' => false
])
; ;
// Institutional ThirdParty (parent)
} else {
$builder
->add('nameCompany', TextType::class, [
'label' => 'thirdparty.NameCompany',
'required' => false
])
->add('acronym', TextType::class, [
'label' => 'thirdparty.Acronym',
'required' => false
])
;
}
} }
/** /**
* *
* @param array $options * @param array $options
* @return \Chill\MainBundle\Entity\Center[] * @return \Chill\MainBundle\Entity\Center[]
*/ */
@@ -113,11 +172,11 @@ class ThirdPartyType extends AbstractType
case 'update': $role = new Role(ThirdPartyVoter::UPDATE); case 'update': $role = new Role(ThirdPartyVoter::UPDATE);
break; break;
} }
return $this->authorizationHelper->getReachableCenters( return $this->authorizationHelper->getReachableCenters(
$this->tokenStorage->getToken()->getUser(), $role); $this->tokenStorage->getToken()->getUser(), $role);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@@ -126,7 +185,7 @@ class ThirdPartyType extends AbstractType
$resolver->setDefaults(array( $resolver->setDefaults(array(
'data_class' => 'Chill\ThirdPartyBundle\Entity\ThirdParty' 'data_class' => 'Chill\ThirdPartyBundle\Entity\ThirdParty'
)); ));
$resolver->setRequired('usage') $resolver->setRequired('usage')
->setAllowedValues('usage', ['create', 'update']) ->setAllowedValues('usage', ['create', 'update'])
; ;

View File

@@ -0,0 +1,42 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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/>.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method ThirdPartyCategory|null find($id, $lockMode = null, $lockVersion = null)
* @method ThirdPartyCategory|null findOneBy(array $criteria, array $orderBy = null)
* @method ThirdPartyCategory[] findAll()
* @method ThirdPartyCategory[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ThirdPartyCategoryRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ThirdPartyCategory::class);
}
}

View File

@@ -0,0 +1,42 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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/>.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCivility;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method ThirdPartyCivility|null find($id, $lockMode = null, $lockVersion = null)
* @method ThirdPartyCivility|null findOneBy(array $criteria, array $orderBy = null)
* @method ThirdPartyCivility[] findAll()
* @method ThirdPartyCivility[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ThirdPartyCivilityRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ThirdPartyCivility::class);
}
}

View File

@@ -0,0 +1,42 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@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/>.
*/
namespace Chill\ThirdPartyBundle\Repository;
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method ThirdPartyProfession|null find($id, $lockMode = null, $lockVersion = null)
* @method ThirdPartyProfession|null findOneBy(array $criteria, array $orderBy = null)
* @method ThirdPartyProfession[] findAll()
* @method ThirdPartyProfession[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ThirdPartyProfessionRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ThirdPartyProfession::class);
}
}

View File

@@ -1,3 +1,13 @@
///
div.thirdparty-list {
label.counter {
float: right;
span {
font-weight: bold;
}
}
}
/// render_box /// render_box
section.chill-entity { section.chill-entity {
.entity-thirdparty { .entity-thirdparty {

View File

@@ -0,0 +1,103 @@
<template>
<div class="item-bloc col">
<section class="chill-entity entity-thirdparty">
<div class="item-row entity-bloc">
<div class="item-col">
<div class="entity-label">
<div :class="'denomination h' + options.hLevel">
<a v-if="this.options.addLink == true" href="#">
<span class="name">{{ thirdparty.text }}</span>
</a>
<span class="name">{{ thirdparty.text }}</span>
<span v-if="options.addId == true" class="id-number" :title="'n° ' + thirdparty.id">{{ thirdparty.id }}</span>
<span v-if="options.addEntity == true && thirdparty.type == 'thirdparty'" class="badge rounded-pill bg-secondary">{{ $t('renderbox.type.thirdparty') }}</span>
</div>
<p v-if="this.options.addInfo == true" class="moreinfo">
<i v-if="thirdparty.birthdate" :class="'fa fa-fw ' + getGenderIcon" title="{{ getGender }}"></i>
<time v-if="thirdparty.birthdate" datetime="{{ thirdparty.birthdate.datetime }}" title="{{ birthdate }}">
{{ $t(getGender) + ' ' + $d(birthdate, 'short') }}
</time>
<time v-else-if="thirdparty.deathdate" datetime="{{ thirdparty.deathdate.datetime }}" title="{{ thirdparty.deathdate }}">
{{ birthdate }} - {{ deathdate }}
</time>
<span class="age">{{ thirdparty.age }}</span>
</p>
</div>
</div>
<div class="item-col separator">
<ul class="list-content fa-ul">
<li v-if="thirdparty.address">
<i class="fa fa-li fa-map-marker"></i>
<show-address :address="thirdparty.address" :isMultiline="isMultiline"></show-address>
</li>
<li v-if="thirdparty.telephone">
<i class="fa fa-li fa-mobile"></i>
<a :href="'tel: ' + thirdparty.telephone">{{ thirdparty.telephone }}</a>
</li>
<li v-if="thirdparty.email">
<i class="fa fa-li fa-envelope-o"></i>
<a :href="'mailto: ' + thirdparty.email">{{ thirdparty.email }}</a>
</li>
</ul>
<slot name="record-actions"></slot>
</div>
</div>
</section>
</div>
</template>
<script>
import ShowAddress from 'ChillMainAssets/vuejs/Address/components/ShowAddress.vue';
import {dateToISO} from 'ChillMainAssets/chill/js/date.js';
export default {
name: "ThirdPartyRenderBox",
components: {
ShowAddress
},
props: ['thirdparty', 'options'],
computed: {
isMultiline: function() {
if(this.options.isMultiline){
return this.options.isMultiline
} else {
return false
}
},
getGender: function() {
return this.thirdparty.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man';
},
getGenderIcon: function() {
return this.thirdparty.gender == 'woman' ? 'fa-venus' : this.thirdparty.gender == 'man' ? 'fa-mars' : 'fa-neuter';
},
birthdate: function(){
var date = new Date(this.thirdparty.birthdate.datetime);
return dateToISO(date);
},
deathdate: function(){
var date = new Date(this.thirdparty.deathdate.datetime);
return dateToISO(date);
},
}
}
</script>
<style lang="scss">
.name{
&:before{
content: " "
}
}
</style>

View File

@@ -0,0 +1,80 @@
<template>
<!-- !!!! DATA still hardcoded until endpoint is fixed -->
<div v-if="action === 'show'">
<div class="flex-table">
<third-party-render-box
:thirdparty="thirdparty"
:options="{
addInfo: true,
addEntity: false,
addAltNames: true,
addId: true,
addLink: false,
hLevel: 3,
addCenter: true,
addNoData: true,
isMultiline: true
}"
></third-party-render-box>
</div>
</div>
<div v-else-if="action === 'edit' || action === 'create'">
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="firstname" v-model="thirdparty.firstName" v-bind:placeholder="$t('thirdparty.firstname')" />
<label for="firstname">{{ $t('thirdparty.firstname') }}</label>
</div>
<div class="form-floating mb-3">
<input class="form-control form-control-lg" id="lastname" v-model="thirdparty.lastName" v-bind:placeholder="$t('thirdparty.lastname')" />
<label for="lastname">{{ $t('thirdparty.lastname') }}</label>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="email"><i class="fa fa-fw fa-envelope"></i></span>
<input class="form-control form-control-lg"
v-model="thirdparty.email"
v-bind:placeholder="$t('thirdparty.email')"
v-bind:aria-label="$t('thirdparty.email')"
aria-describedby="email" />
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="phonenumber"><i class="fa fa-fw fa-phone"></i></span>
<input class="form-control form-control-lg"
v-model="thirdparty.telephone"
v-bind:placeholder="$t('thirdparty.phonenumber')"
v-bind:aria-label="$t('thirdparty.phonenumber')"
aria-describedby="phonenumber" />
</div>
</div>
</template>
<script>
import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue'
export default {
name: "OnTheFlyThirdParty",
props: ['id', 'type', 'action'],
components: {
ThirdPartyRenderBox,
},
data: function() {
return {
thirdparty: {
text : "Bart Maes",
firstName : "Bart",
lastName : "Maes",
email : "bartmaes@gmail.com",
telephone : "0475 94 66 15",
}
}
}
}
// TODO move in ChillThirdpartyAssets
</script>
<style lang="css" scoped>
</style>

View File

@@ -94,13 +94,12 @@
{% if options['customButtons']['replace'] is defined %} {% if options['customButtons']['replace'] is defined %}
{{ options['customButtons']['replace'] }} {{ options['customButtons']['replace'] }}
{% elseif is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) %} {% elseif is_granted('CHILL_3PARTY_3PARTY_SHOW', thirdparty) %}
<li> <li>
<a class="btn btn-sm btn-show" target="_blank" title="{{ 'Show thirdparty'|trans }}" <a class="btn btn-sm btn-show" target="_blank" title="{{ 'Show thirdparty'|trans }}"
href="{{ path('chill_3party_3party_show', { thirdparty_id: thirdparty.id }) }}"></a> href="{{ path('chill_3party_3party_show', { thirdparty_id: thirdparty.id }) }}"></a>
</li> </li>
{% else %} {% else %}
{# rien faire ? j'ai eu un bug car options['customButtons'] était vide (marc) #}
{% endif %} {% endif %}
{% if options['customButtons']['after'] is defined %} {% if options['customButtons']['after'] is defined %}

View File

@@ -3,64 +3,107 @@
{% block title 'List of third parties'|trans %} {% block title 'List of third parties'|trans %}
{% block content %} {% block content %}
<div class="col-10 centered"> <div class="thirdparty-list my-5">
<h1>{{ 'List of third parties'|trans }}</h1> <div class="row justify-content-center">
<div class="col-md-10 col-xxl">
{% if third_parties|length == 0 %}
<p class="chill-no-data-statement">{{ 'No third parties'|trans }}</p>
{% else %}
<table>
<thead>
<tr>
<th style="width: 35px;"></th>
<th>{{ 'Name'|trans }}</th>
<th>{{ 'Category'|trans }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for tp in third_parties %}
<tr>
<th>{{ (tp.active ? '<i class="fa fa-check chill-green">' : '<i class="fa fa-times chill-red">')|raw }}</th>
<td>{{ tp.name }}</td>
{% set types = [] %}
{% for t in tp.type %}
{% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %}
{% endfor %}
<td>{{ types|join(', ') }}</td>
<td>
<ul class="record_actions">
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_update', { 'thirdparty_id': tp.id }) }}" class="btn btn-update"></a>
</li>
{% endif %}
{% if is_granted('CHILL_3PARTY_3PARTY_SHOW', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_show', { 'thirdparty_id': tp.id }) }}" class="btn btn-show"></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if third_parties|length < pagination.getTotalItems %} <h1>{{ 'List of third parties'|trans }}</h1>
{{ chill_pagination(pagination) }}
{% endif %}
{% endif %} {% if third_parties|length == 0 %}
<p class="chill-no-data-statement">{{ 'No third parties'|trans }}</p>
{% else %}
{% if is_granted('CHILL_3PARTY_3PARTY_CREATE') %} <nav class="filter-actions border border-secondary my-4 p-3">
<ul class="record_actions"> <i>outils de filtrage</i>
<li> </nav>
<a href="{{ chill_path_add_return_path('chill_3party_3party_new') }}" class="btn btn-create">
{{ "New third party"|trans }} </div>
</a> </div>
{% endif %} <div class="row justify-content-center">
<div class="col-md-10 col-xxl">
<label class="counter">
<span>{{ pagination.totalItems }}</span> {{ 'third parties'|trans }}
</label>
<table class="table table-striped table-hover align-middle">
<thead>
<tr>
<th class="chill-pink" style="width: 35px;"></th>
<th class="chill-pink">{{ 'Name'|trans }}
<i class="fa fa-fw fa-sort"></i>
</th>
<th class="chill-pink">{{ 'Category'|trans }}
<i class="fa fa-fw fa-sort"></i>
</th>
<th class="chill-pink">{{ 'Address'|trans }}
<i class="fa fa-fw fa-sort"></i>
</th>
<th class="chill-pink">{{ 'thirdparty.UpdatedAt.short'|trans }}
<i class="fa fa-fw fa-sort"></i>
</th>
<th class="chill-pink"></th>
</tr>
</thead>
<tbody>
{% for tp in third_parties %}
<tr>
<th>{{ (tp.active ? '<i class="fa fa-check chill-green">' : '<i class="fa fa-times chill-red">')|raw }}</th>
<td>{{ tp.name }}</td>
{% set types = [] %}
{% for t in tp.type %}
{% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %}
{% endfor %}
<td>{{ types|join(', ') }}</td>
<td>
{{ tp.address|chill_entity_render_box({'multiline': false, 'with_valid_from': false}) }}
</td>
<td>
{% if tp.updatedAt != null %}
{{ tp.updatedAt|format_date('short') }}
{% else %}
{{ tp.createdAt|format_date('short') }}
{% endif %}
</td>
<td>
<ul class="record_actions">
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_update', { 'thirdparty_id': tp.id }) }}" class="btn btn-update"></a>
</li>
{% endif %}
{% if is_granted('CHILL_3PARTY_3PARTY_SHOW', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_show', { 'thirdparty_id': tp.id }) }}" class="btn btn-show"></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if third_parties|length < pagination.getTotalItems %}
{{ chill_pagination(pagination, 'long') }}
{% endif %}
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
{{ chill_items_per_page(pagination) }}
</li>
{% if is_granted('CHILL_3PARTY_3PARTY_CREATE') %}
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_new') }}" class="btn btn-create">
{{ "New third party"|trans }}
</a>
</li>
{% endif %}
</ul>
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -3,32 +3,58 @@
{% block title 'Create third party'|trans %} {% block title 'Create third party'|trans %}
{% block content %} {% block content %}
<div class="col-10 centered"> <div class="thirdparty-new my-5">
<h1>{{ 'Create third party'|trans }}</h1> <div class="row justify-content-center">
<div class="col-md-10 col-xxl">
{{ form_start(form) }} <h1>{{ 'Create third party'|trans }}</h1>
{{ form_row(form.name) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.active) }}
{{ form_row(form.centers) }}
{{ form_row(form.comment) }}
{{ form_start(form) }}
<ul class="record_actions"> {% if form.civility is defined %}
<li class="cancel"> {{ form_row(form.civility) }}
<a href="{{ chill_return_path_or('chill_3party_3party_index') }}" class="btn btn-cancel"> {% endif %}
{{ 'Back to the list'|trans }}
</a> {{ form_row(form.name) }}
</li>
<li> {% if form.nameCompany is defined %}
{{ form_widget(form.submit, {'label': 'Create', 'attr': {'class': 'btn btn-new' }}) }} {{ form_row(form.nameCompany) }}
</li> {{ form_row(form.acronym) }}
</ul> {% endif %}
{{ form_end(form) }} {% if form.profession is defined %}
{{ form_row(form.profession) }}
{% endif %}
{{ form_row(form.categories) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.comment) }}
{{ form_row(form.centers) }}
{{ form_row(form.active) }}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_3party_3party_index') }}" class="btn btn-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
</li>
<li>
{{ form_widget(form.submit, {'label': 'Create', 'attr': {'class': 'btn btn-new' }}) }}
</li>
</ul>
{{ form_end(form) }}
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -5,61 +5,118 @@
{% block title title_ %} {% block title title_ %}
{% block content %} {% block content %}
<div class="col-10 centered"> <div class="thirdparty-show my-5">
<h1> <div class="row justify-content-center">
{{ title_ }} <div class="col-md-10 col-xxl">
<span class="chill__box {{ thirdParty.active ? 'green' : 'red' }}">{{ (thirdParty.active ? 'Active, shown to users' : 'Inactive, not shown to users')|trans }}</span>
</h1> <h1>
{{ title_ }}
<dl class="chill_view_data"> <span class="badge bg-{{ thirdParty.active ? 'success' : 'danger' }}"
<dt>{{ 'Name'|trans }}</dt> title="{{ (thirdParty.active ? 'shown to users' : 'not shown to users')|trans }}">
<dd>{{ thirdParty.name }}</dd> {{ (thirdParty.active ? 'Active' : 'Inactive')|trans }}
</span>
<dt>{{ 'Type'|trans }}</dt> </h1>
{% set types = [] %}
{% for t in thirdParty.type %}
{% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %} <dl class="chill_view_data">
{% endfor %}
<dd>{{ types|join(', ') }}</dd> <dt>{{ 'Name'|trans }}</dt>
<dd>
<dt>{{ 'Centers'|trans }}</dt> {% if thirdParty.isLeaf == true %}{{ thirdParty.civility }}{% endif %}
<dd>{{ 'The party is visible in those centers'|trans }}&nbsp;: {{ thirdParty.centers|join(', ') }}</dd> {{ thirdParty.name }}
</dd>
<dt>{{ 'Phonenumber'|trans }}</dt>
<dd>{{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }}</dd> {% if thirdParty.isLeaf == false %}
<dt>{{ 'thirdparty.NameCompany'|trans }}</dt>
<dt>{{ 'email'|trans }}<dt> <dd>
<dd>{{ thirdParty.email|chill_print_or_message("thirdparty.No_email") }}</dd> {% if thirdParty.nameCompany == null %}
<span class="chill-no-data-statement">{{ 'No nameCompany given'|trans }}</span>
<dt>{{ 'Address'|trans }}</dt> {% else %}
<dd> {{ thirdParty.nameCompany }}
{% if thirdParty.address == null %} {% endif %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span> </dd>
{% else %}
{{ thirdParty.address|chill_entity_render_box({'with_valid_from': false }) }} <dt>{{ 'thirdparty.Acronym'|trans }}</dt>
{% endif %} <dd>
</dd> {% if thirdParty.acronym == null %}
<span class="chill-no-data-statement">{{ 'No acronym given'|trans }}</span>
<dt>{{ 'Comment'|trans }}</dt> {% else %}
<dd>{{ thirdParty.comment|chill_print_or_message("thirdparty.No_comment") }}</dd> {{ thirdParty.acronym }}
{% endif %}
</dl> </dd>
{% endif %}
<ul class="record_actions">
<li class="cancel"> <dt>{{ 'Type'|trans }}</dt>
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_3party_3party_index') }}"> {% set types = [] %}
{{ 'Cancel'|trans }} {% for t in thirdParty.type %}
</a> {% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %}
</li> {% endfor %}
<dd>
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', thirdParty) %} {{ types|join(', ') }}
<li> </dd>
<a class="btn btn-update" href="{{ chill_path_forward_return_path('chill_3party_3party_update', { 'thirdparty_id': thirdParty.id }) }}">
{{ 'Update'|trans }} <dt>{{ 'Phonenumber'|trans }}</dt>
</a> <dd>
</li> {% if thirdParty.telephone == null %}
{% endif %} <span class="chill-no-data-statement">{{ 'No phone given'|trans }}</span>
</ul> {% else %}
<a href="{{ 'tel:' ~ thirdParty.telephone }}">
{{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }}
</a>
{% endif %}
</dd>
<dt>{{ 'email'|trans }}<dt>
<dd>
{% if thirdParty.email == null %}
<span class="chill-no-data-statement">{{ 'No email given'|trans }}</span>
{% else %}
<a href="{{ 'mailto:' ~ thirdParty.email }}">
{{ thirdParty.email|chill_print_or_message("thirdparty.No_email") }}
</a>
{% endif %}
</dd>
<dt>{{ 'Address'|trans }}</dt>
<dd>
{% if thirdParty.address == null %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
{{ thirdParty.address|chill_entity_render_box({'with_valid_from': false }) }}
{% endif %}
</dd>
<dt>{{ 'Comment'|trans }}</dt>
<dd>
{% if thirdParty.comment is not empty %}
<blockquote class="chill-user-quote">
{{ thirdParty.comment|chill_markdown_to_html }}
</blockquote>
{% endif %}
</dd>
<dt>{{ 'Centers'|trans }}</dt>
<dd>{{ 'The party is visible in those centers'|trans }}&nbsp;: {{ thirdParty.centers|join(', ') }}</dd>
</dl>
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_3party_3party_index') }}">
{{ 'Cancel'|trans }}
</a>
</li>
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', thirdParty) %}
<li>
<a class="btn btn-update" href="{{ chill_path_forward_return_path('chill_3party_3party_update', { 'thirdparty_id': thirdParty.id }) }}">
{{ 'Update'|trans }}
</a>
</li>
{% endif %}
</ul>
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -3,35 +3,75 @@
{% block title 'Update third party %name%'|trans({ '%name%': thirdParty.name }) %} {% block title 'Update third party %name%'|trans({ '%name%': thirdParty.name }) %}
{% block content %} {% block content %}
<div class="col-10 centered"> <div class="thirdparty-edit my-5">
<h1> <div class="row justify-content-center">
{{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }} <div class="col-md-10 col-xxl">
<span class="chill__box {{ thirdParty.active ? 'green' : 'red' }}">{{ (thirdParty.active ? 'Active, shown to users' : 'Inactive, not shown to users')|trans }}</span>
</h1> <h1>
{{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }}
<span class="badge bg-{{ thirdParty.active ? 'success' : 'danger' }}"
title="{{ (thirdParty.active ? 'shown to users' : 'not shown to users')|trans }}">
{{ (thirdParty.active ? 'Active' : 'Inactive')|trans }}
</span>
</h1>
{{ form_start(form) }} <div class="date-by">
{{ form_row(form.name) }} {% if thirdParty.updatedAt != null %}
{{ form_row(form.type) }} {{ 'thirdparty.UpdatedAt.short'|trans ~ thirdParty.updatedAt|format_date('short') }}
{{ form_row(form.telephone) }} {% else %}
{{ form_row(form.email) }} {{ 'thirdparty.CreatedAt.short'|trans ~ thirdParty.createdAt|format_date('short') }}
{{ form_row(form.address) }} {% endif %}
{% if thirdParty.updatedBy != null %}
{{ form_row(form.active) }} {{ 'thirdparty.UpdateBy.short'|trans ~ thirdParty.updatedBy.usernameCanonical }}
{{ form_row(form.centers) }} {% endif %}
{{ form_row(form.comment) }} </div>
{{ form_start(form) }}
<ul class="record_actions"> {% if form.civility is defined %}
<li class="cancel"> {{ form_row(form.civility) }}
<a class="btn btn-cancel" href="{{ chill_path_forward_return_path('chill_3party_3party_index') }}"> {% endif %}
{{ 'Back to the list'|trans }}
</a> {{ form_row(form.name) }}
<li>
{{ form_row(form.submit, {'label': 'Update', 'attr': {'class': 'btn btn-update' }}) }} {% if form.nameCompany is defined %}
</li> {{ form_row(form.nameCompany) }}
</ul> {{ form_row(form.acronym) }}
{% endif %}
{{ form_end(form) }}
{% if form.profession is defined %}
{{ form_row(form.profession) }}
{% endif %}
{{ form_row(form.categories) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.comment) }}
{{ form_row(form.centers) }}
{{ form_row(form.active) }}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a class="btn btn-cancel" href="{{ chill_path_forward_return_path('chill_3party_3party_index') }}">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
</li>
<li>
{{ form_widget(form.submit, {'label': 'Update', 'attr': {'class': 'btn btn-update' }}) }}
</li>
</ul>
{{ form_end(form) }}
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -1,4 +1,9 @@
module.exports = function(encore, entries) module.exports = function(encore, entries)
{ {
entries.push(__dirname + '/Resources/public/chill/index.js'); entries.push(__dirname + '/Resources/public/chill/index.js');
// Aliases are used when webpack is trying to resolve modules path
encore.addAliases({
ChillThirdPartyAssets: __dirname + '/Resources/public'
});
}; };

View File

@@ -2,4 +2,16 @@
services: services:
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdParty: Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdParty:
tags: tags:
- { 'name': doctrine.fixture.orm } - { 'name': doctrine.fixture.orm }
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdPartyCivility:
tags:
- { 'name': doctrine.fixture.orm }
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdPartyCategory:
tags:
- { 'name': doctrine.fixture.orm }
Chill\ThirdPartyBundle\DataFixtures\ORM\LoadThirdPartyProfession:
tags:
- { 'name': doctrine.fixture.orm }

View File

@@ -4,9 +4,10 @@ services:
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
$typesManager: '@Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager' $typesManager: '@Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager'
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
tags: tags:
- { name: form.type } - { name: form.type }
Chill\ThirdPartyBundle\Form\Type\PickThirdPartyType: Chill\ThirdPartyBundle\Form\Type\PickThirdPartyType:
arguments: arguments:
$em: '@Doctrine\ORM\EntityManagerInterface' $em: '@Doctrine\ORM\EntityManagerInterface'
@@ -14,4 +15,4 @@ services:
$translator: '@Symfony\Component\Translation\TranslatorInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface'
$typesManager: '@Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager' $typesManager: '@Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager'
tags: tags:
- { name: form.type } - { name: form.type }

View File

@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\ThirdParty;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add new fields to ThirdParty Entity
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
final class Version20210719105918 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add new fields to ThirdParty Entity + new join tables';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE SEQUENCE chill_3party.party_category_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE chill_3party.party_civility_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE chill_3party.party_profession_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_3party.party_category (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE chill_3party.party_civility (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE chill_3party.party_profession (id INT NOT NULL, name JSON NOT NULL, active BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE chill_3party.thirdparty_category (thirdparty_id INT NOT NULL, category_id INT NOT NULL, PRIMARY KEY(thirdparty_id, category_id))');
$this->addSql('CREATE INDEX IDX_70495637C7D3A8E6 ON chill_3party.thirdparty_category (thirdparty_id)');
$this->addSql('CREATE INDEX IDX_7049563712469DE2 ON chill_3party.thirdparty_category (category_id)');
$this->addSql('ALTER TABLE chill_3party.thirdparty_category ADD CONSTRAINT FK_70495637C7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_3party.thirdparty_category ADD CONSTRAINT FK_7049563712469DE2 FOREIGN KEY (category_id) REFERENCES chill_3party.party_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_3party.third_party ADD parent_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD civility INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD profession INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD updated_by INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD name_company VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD acronym VARCHAR(64) DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT \'2015-01-01\' NOT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD CONSTRAINT FK_D952467B727ACA70 FOREIGN KEY (parent_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_3party.third_party ADD CONSTRAINT FK_D952467B384D4799 FOREIGN KEY (civility) REFERENCES chill_3party.party_civility (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_3party.third_party ADD CONSTRAINT FK_D952467BBA930D69 FOREIGN KEY (profession) REFERENCES chill_3party.party_profession (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_3party.third_party ADD CONSTRAINT FK_D952467B16FE72E1 FOREIGN KEY (updated_by) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_D952467B727ACA70 ON chill_3party.third_party (parent_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_D952467B384D4799 ON chill_3party.third_party (civility)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_D952467BBA930D69 ON chill_3party.third_party (profession)');
$this->addSql('CREATE INDEX IDX_D952467B16FE72E1 ON chill_3party.third_party (updated_by)');
$this->addSql('ALTER INDEX chill_3party.idx_c65d4397c7d3a8e6 RENAME TO IDX_14DC4475C7D3A8E6');
$this->addSql('ALTER INDEX chill_3party.idx_c65d43975932f377 RENAME TO IDX_14DC44755932F377');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_3party.thirdparty_category DROP CONSTRAINT FK_7049563712469DE2');
$this->addSql('ALTER TABLE chill_3party.third_party DROP CONSTRAINT FK_D952467B384D4799');
$this->addSql('ALTER TABLE chill_3party.third_party DROP CONSTRAINT FK_D952467BBA930D69');
$this->addSql('DROP SEQUENCE chill_3party.party_category_id_seq CASCADE');
$this->addSql('DROP SEQUENCE chill_3party.party_civility_id_seq CASCADE');
$this->addSql('DROP SEQUENCE chill_3party.party_profession_id_seq CASCADE');
$this->addSql('DROP TABLE chill_3party.party_category');
$this->addSql('DROP TABLE chill_3party.party_civility');
$this->addSql('DROP TABLE chill_3party.party_profession');
$this->addSql('DROP TABLE chill_3party.thirdparty_category');
$this->addSql('ALTER INDEX chill_3party.idx_14dc44755932f377 RENAME TO idx_c65d43975932f377');
$this->addSql('ALTER INDEX chill_3party.idx_14dc4475c7d3a8e6 RENAME TO idx_c65d4397c7d3a8e6');
$this->addSql('ALTER TABLE chill_3party.third_party DROP CONSTRAINT FK_D952467B727ACA70');
$this->addSql('ALTER TABLE chill_3party.third_party DROP CONSTRAINT FK_D952467B16FE72E1');
$this->addSql('ALTER TABLE chill_3party.third_party DROP parent_id');
$this->addSql('ALTER TABLE chill_3party.third_party DROP civility');
$this->addSql('ALTER TABLE chill_3party.third_party DROP profession');
$this->addSql('ALTER TABLE chill_3party.third_party DROP updated_by');
$this->addSql('ALTER TABLE chill_3party.third_party DROP name_company');
$this->addSql('ALTER TABLE chill_3party.third_party DROP acronym');
$this->addSql('ALTER TABLE chill_3party.third_party DROP created_at');
$this->addSql('ALTER TABLE chill_3party.third_party DROP updated_at');
}
}

View File

@@ -1,5 +1,6 @@
Third party: Tiers Third party: Tiers
Third parties: Tiers Third parties: Tiers
third parties: tiers
name: Nom name: Nom
telephone: Téléphone telephone: Téléphone
adress: Adresse adress: Adresse
@@ -11,17 +12,45 @@ thirdparty.No_phonenumber: Aucun numéro de téléphone
thirdparty.No_email: Aucun email thirdparty.No_email: Aucun email
thirdparty.No_comment: Aucun commentaire thirdparty.No_comment: Aucun commentaire
New third party: Nouveau tiers thirdparty.NameCompany: Raison sociale
thirdparty.Acronym: Sigle
thirdparty.Categories: Catégories
thirdparty.Child: Personne de contact
thirdparty.Children: Personnes de contact
thirdparty.Parent: Tiers institutionnel
thirdparty.Parents: Tiers institutionnels
thirdparty.Civility: Civilité
thirdparty.choose civility: --
thirdparty.Profession: Qualité
thirdparty.choose profession: --
thirdparty.CreatedAt.short: 'Créé le '
thirdparty.UpdatedAt.short: 'Modifié le '
thirdparty.UpdateBy.short: ' par '
thirdparty.CreatedAt.long: Date de création
thirdparty.UpdatedAt.long: Date de la dernière modification
thirdparty.UpdateBy.long: Utilisateur qui a effectué la dernière modification
New third party: Ajouter un nouveau tiers
Show third party %name%: Tiers "%name%" Show third party %name%: Tiers "%name%"
Create third party: Créer un tiers Create third party: Créer un tiers
Update third party %name%: Mettre à jour "%name%" Update third party %name%: Mettre à jour "%name%"
List of third parties: Liste des tiers List of third parties: Liste des tiers
Third party updated: Le tiers a été mis à jour Third party updated: Le tiers a été mis à jour
Third party created: Le tiers a été créé Third party created: Le tiers a été créé
Active, shown to users: Actif, visible par les utilisateurs thirdparty.Status: Statut
Inactive, not shown to users: Inactif, invisible par les utilisateurs Active, shown to users: Actif, visible pour les utilisateurs
Active: Actif
shown to users: visible pour les utilisateurs
Inactive, not shown to users: Inactif, invisible pour les utilisateurs
Inactive: Inactif
not shown to users: invisible pour les utilisateurs
Show thirdparty: Voir le tiers Show thirdparty: Voir le tiers
No nameCompany given: Aucune raison sociale renseignée
No acronym given: Aucun sigle renseigné
No phone given: Aucun téléphone renseigné
No email given: Aucune adresse courriel renseignée
The party is visible in those centers: Le tiers est visible dans ces centres The party is visible in those centers: Le tiers est visible dans ces centres
No third parties: Aucun tiers No third parties: Aucun tiers