Compare commits

..

8 Commits

Author SHA1 Message Date
cef00005c5 fix add other phonenumber rendering 2021-03-28 23:39:19 +02:00
127803a94c fix behaviour when phone is newly created 2021-03-28 23:38:53 +02:00
2d76294c26 fix label font-weight for nested forms 2021-03-28 23:37:48 +02:00
82f95d2745 fix behaviour when twilio is not configured 2021-03-28 23:37:22 +02:00
2f4f1f2c55 Merge remote-tracking branch 'origin/features/new-phones' into dune 2021-03-28 22:26:10 +02:00
Jean-Francois Monfort
068b269af9 Add other phone number 2021-03-25 17:41:37 +01:00
Jean-Francois Monfort
756ed616b6 Add other phone number 2021-03-25 16:14:23 +01:00
Jean-Francois Monfort
50d686f086 Add other phone number 2021-03-25 15:04:59 +01:00
57 changed files with 573 additions and 2224 deletions

64
.env
View File

@@ -1,64 +0,0 @@
##
## Manually dump .env files in .env.local.php with
## `$ composer symfony:dump-env prod`
##
## Project environment
APP_ENV=dev
## Enable debug
APP_DEBUG=true
## Locale
LOCALE=fr
## Framework secret
APP_SECRET=ThisTokenIsNotSoSecretChangeIt
## Symfony/swiftmailer
MAILER_TRANSPORT=smtp
MAILER_HOST=smtp
MAILER_PORT=1025
MAILER_CRYPT=
MAILER_AUTH=
MAILER_USER=
MAILER_PASSWORD=
MAILER_URL=${MAILER_TRANSPORT}://${MAILER_HOST}:${MAILER_PORT}?encryption=${MAILER_CRYPT}&auth_mode=${MAILER_AUTH}&username=${MAILER_USER}&password=${MAILER_PASSWORD}
## Notifications
NOTIFICATION_HOST=localhost:8001
NOTIFICATION_FROM_EMAIL=admin@chill.social
NOTIFICATION_FROM_NAME=Chill
## Gelf
GELF_HOST=gelf
GELF_PORT=12201
## OVH OpenStack Storage User/Role
OS_USERNAME=
OS_PASSWORD=
OS_TENANT_ID=
OS_REGION_NAME=GRA
OS_AUTH_URL=https://auth.cloud.ovh.net/v2.0/
## OVH OpenStack Storage Container
ASYNC_UPLOAD_TEMP_URL_KEY=
ASYNC_UPLOAD_TEMP_URL_BASE_PATH=
ASYNC_UPLOAD_TEMP_URL_CONTAINER=
## Redis Cache
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}
## Twilio
TWILIO_SID=~
TWILIO_SECRET=~
## DOCKER IMAGES REGISTRY
#IMAGE_PHP=
#IMAGE_NGINX=
## DOCKER IMAGES VERSION
#VERSION=test
VERSION=prod

View File

@@ -1,6 +0,0 @@
# variables for .env environement
# those variables suits for gitlab-ci
# Run tests from root to adapt your own environment
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres?serverVersion=12&charset=utf8

16
.gitignore vendored
View File

@@ -1,19 +1,3 @@
.composer/*
composer.phar
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
/bin/
###< symfony/framework-bundle ###
###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

View File

@@ -1,37 +0,0 @@
---
image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4
# Select what we should cache between builds
cache:
paths:
- tests/app/vendor/
before_script:
# 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;"
# Install and run Composer
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
- php tests/app/bin/console doctrine:migrations:migrate -n
- php tests/app/bin/console doctrine:fixtures:load -n
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
services:
- name: postgres:12
alias: db
- name: redis
alias: redis
# Set any variables we need
variables:
# Configure postgres environment variables (https://hub.docker.com/r/_/postgres/)
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# fetch the chill-app using git submodules
GIT_SUBMODULE_STRATEGY: recursive
# Run our tests
test:
script:
- bin/phpunit --colors=never

3
.gitmodules vendored
View File

@@ -1,6 +1,3 @@
[submodule "_exts/sphinx-php"]
path = _exts/sphinx-php
url = https://github.com/fabpot/sphinx-php.git
[submodule "tests/app"]
path = tests/app
url = https://gitlab.com/Chill-projet/chill-app.git

View File

@@ -19,14 +19,10 @@
"Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle"
}
},
"autoload-dev": {
"psr-4": {
"App\\": "tests/app/src/"
}
},
"require": {
"champs-libres/async-uploader-bundle": "dev-sf4",
"graylog2/gelf-php": "^1.5",
"symfony/flex": "^1.9",
"symfony/form": "4.*",
"symfony/twig-bundle": "^4.4",
"twig/extra-bundle": "^2.12|^3.0",
@@ -70,17 +66,6 @@
"symfony/stopwatch": "^5.1",
"symfony/web-profiler-bundle": "^5.0",
"symfony/var-dumper": "4.*",
"symfony/debug-bundle": "^5.1",
"symfony/phpunit-bridge": "^5.2"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
}
},
"config": {
"vendor-dir": "tests/app/vendor",
"bin-dir": "bin"
"symfony/debug-bundle": "^5.1"
}
}

View File

@@ -14,6 +14,7 @@ As Chill rely on the `symfony <http://symfony.com>`_ framework, reading the fram
.. toctree::
:maxdepth: 2
Install Chill for development <installation.rst>
Instructions to create a new bundle <create-a-new-bundle.rst>
CRUD (Create - Update - Delete) for one entity <crud.rst>
Routing <routing.rst>

View File

@@ -0,0 +1,155 @@
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
.. _installation-for-development :
Installation for development
****************************
Installation for development should allow:
- access to the source code,
- upload the code to our CVS (i.e. `git`_) and
- work with `composer`_.
As Chill is divided into bundles (the Symfony name for 'modules'), each bundle has his own repository.
Installation and big picture
----------------------------
First, you should install Chill as described in the :ref:`basic-installation` section.
Two things must be modified :
First, add the `--prefer-source` argument when you create project.
.. code-block:: bash
composer create-project chill-project/standard path/to/your/directory --stability=dev --prefer-source
Second, when composer ask you the following question : ::
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]?
**You should answer `n` (no).**
Once Chill is installed, all the downloaded bundles will be stored in the `/vendor` directories.
In those directories, you will have access to the git commands.
.. code-block:: bash
$ cd vendor/chill-project/main/
$ git remote -v
composer git://github.com/Chill-project/Standard.git (fetch)
composer git://github.com/Chill-project/Standard.git (push)
origin git://github.com/Chill-project/Standard.git (fetch)
origin git@github.com:Chill-project/Standard.git (push)
Files cleaning after installation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Composer will delete unrequired files, and add some. This is perfectly normal and will appears in your git index.
But you should NOT delete those files.
This is the expected 'git status' result:
.. code-block:: bash
$git status
#(...)
Modifications qui ne seront pas validées :
(utilisez "git add/rm <fichier>..." pour mettre à jour ce qui sera validé)
(utilisez "git checkout -- <fichier>..." pour annuler les modifications dans la copie de travail)
modifié: app/SymfonyRequirements.php
supprimé: app/SymfonyStandard/Composer.php
supprimé: app/SymfonyStandard/RootPackageInstallSubscriber.php
modifié: app/check.php
You can ignore the local changes using the `git update-index --assume-unchanged` command.
.. code-block:: bash
$ git update-index --assume-unchanged app/check.php
$ git update-index --assume-unchanged app/SymfonyRequirements.php
$ git update-index --assume-unchanged app/SymfonyStandard/Composer.php
$ git update-index --assume-unchanged app/SymfonyStandard/RootPackageInstallSuscriber.php
Working with your own fork
^^^^^^^^^^^^^^^^^^^^^^^^^^
Ideally, you will work on a fork of the main github repository.
To ensure that composer will download the code from **your** repository, you will have to adapt the `composer.json` file accordingly, using your own repositories.
For each Chill module that you have forked, add an indexed array into the "repositories" key of the composer.json file
at the root of the chill installation directory if you want to force composer to download from your own forked repositories:
.. code-block:: json
"repositories": [
{
"type": "git",
"url": "git://github.com/your-github-username/ChillMain.git"
},
{
"type": "git",
"url": "git://github.com/your-github-username/Chill-Person.git"
}
]
Then run composer update to load your forked code.
If it does not happen, delete the content of the chill/vendor/chill-project/my_forked_bundle and relaunch composer update and the code will be downloaded from your fork.
.. code-block:: bash
composer update
You may also `use aliases <https://getcomposer.org/doc/articles/aliases.md>`_ to define versions.
.. _editing-code-and-commiting :
Editing the code and commiting
------------------------------
You may edit code in the `vendor/path/to/the/bundle` directory.
Once satisfied with your changes, you should commit as usually :
.. code-block:: bash
$ cd vendor/path/to/bundle
$ git status
Sur la branche master
Votre branche est à jour avec 'origin/master'.
rien à valider, la copie de travail est propre
.. warning
The git command must be run from you vendor bundle's path (`vendor/path/to/bundle`).
Tips
^^^^
The command `composer status` (`see composer documentation <https://getcomposer.org/doc/03-cli.md#status>`_) will give you and idea of which bundle has been edited :
.. code-block:: bash
$ cd ./../../ #back to the root project directory
$ composer status
You have changes in the following dependencies:
/path/to/your/project/install/vendor/chill-project/main
Use --verbose (-v) to see modified files
.. _git: http://git-scm.org
.. _composer: https://getcomposer.org

View File

@@ -30,14 +30,21 @@ Contents of this documentation:
Let's talk together !
======================
You may talk to developers using the matrix room: `https://app.element.io/#/room/#chill-social-admin:matrix.org`_
Subscribe to the dev mailing-list to discuss your project and extend Chill with the feature you need!
- `The dev mailing-list <https://lists.chill.social/listinfo/dev>`_
- `Read the archives of the mailing-list <https://lists.chill.social/pipermail/dev/>`_
Contribute
==========
* `Issue tracker <https://gitlab.com/groups/Chill-project/issues>`_ You may want to dispatch the issue in the multiple projects. If you do not know in which project is located your bug / feature request, use the project Chill-Main.
* `Issue tracker <https://git.framasoft.org/groups/Chill-project/issues>`_ You may want to dispatch the issue in the multiple projects. If you do not know in which project is located your bug / feature request, use the project Chill-Main.
* `The dev mailing-list <https://lists.chill.social/listinfo/dev>`_
Source code is dispatched in multiple bundle, to improve re-usability. Each bundle has dependencies with other chill bundle, but the developer take care that bundles may not be installed if the user do not need it.
User manual
===========
@@ -49,22 +56,22 @@ An user manual exists in French and currently focuses on describing the main con
Available bundles
=================
* Chill-app | https://gitlab.com/Chill-project/Chill-app This is the skeleton of the project. It does contains only few code, but information about configuration of your instance ;
* Chill-bundle: contains the main bundles, the most used in an instance. This means:
* chill-main, the main framework,
* Chill Person, to deal with persons,
* chill custom fields, to add custom fields to some entities,
* chill activity: to add activities to people,
* chill report: to add report to people,
* chill event: to gather people into events,
* chill docs store: to store documents to people, but also entities,
* chill task: to register task with people,
* chill third party: to register third parties,
* chill family members: to register family members
* Chill-standard | https://git.framasoft.org/Chill-project/Chill-Standard This is the skeleton of the project. It does contains only few code, but information about configuration of your instance ;
* Chill-Main : https://git.framasoft.org/Chill-project/Chill-Main : the main, required bundle for all the subsequent chill bundles. It contains the framework to add features (like searching, timeline, ...). It also provides the user managements (authentification and authorization) ;
* Chill-Person : https://git.framasoft.org/Chill-project/Chill-Person This is the bundle which provides the possibility to create and add a person.
* Chill-CustomFields : https://git.framasoft.org/Chill-project/Chill-CustomFields This bundle allows you to create custom fields on other bundles. It provides the framework for this features, and modify the schema according to this. It is required by Chill-Person and Chill-Report.
* Chill-Report: https://git.framasoft.org/Chill-project/Chill-Report This bundle allow to add report about People recorded in your database ;
* Chill-Activity : https://git.framasoft.org/Chill-project/Chill-Activity This bundle allow to add activities about People recorded in your database ;
* Chill-ICPC2 : https://git.framasoft.org/Chill-project/Chill-ICPC2 This bundle provides a custom fields for `ICPC code <https://en.wikipedia.org/wiki/International_Classification_of_Primary_Care>`_ (international classification for primary care)
* Chill-Group: https://git.framasoft.org/Chill-project/Chill-Group This bundle provides a way to create link between accompanyed people
* Chill-Event: https://git.framasoft.org/Chill-project/Chill-Event This bundle provides a way to create event and associate people to event through a "participation"
* Chill-Ldap: https://git.framasoft.org/Chill-project/Chill-Ldap Allow to synchronize the database with a ldap directory.
* Chill-ONEStat : https://framagit.org/Chill-project/Chill-ONEStat Provide statistics for the Belgian one "Centre de vacances" and "Ecoles de devoir".
You will also found the following projects :
* The website https://chill.social : https://gitlab.com/Chill-project/chill.social
* The present documentation : https://git.framasoft.org/Chill-project/chill-documentation
* The website https://chill.social : https://git.framasoft.org/Chill-project/chill.social
And various project to build docker containers with Chill.

View File

@@ -27,13 +27,13 @@ Installation in development mode
1. Get the code
===============
Clone or download the chill-app project and `cd` into the main directory.
Clone or download the chill-standard project and `cd` into the main directory.
.. code-block:: bash
git clone https://gitlab.com/Chill-Projet/chill-app.git
cd chill-app
git clone https://framagit.org/Chill-project/Chill-Standard.git
cd Chill-Standard
As a developer, the code will stay on your computer and will be executed in docker container. To avoid permission problem, the code should be run with the same uid/gid from your current user. This is why we get your current user id with the command ``id -u`` in each following scripts.

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/app/tests/bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
<server name="SHELL_VERBOSITY" value="-1" />
</php>
<testsuites>
<testsuite name="MainBundle">
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
</testsuite>
<testsuite name="PersonBundle">
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
-->
</phpunit>

View File

@@ -14,7 +14,6 @@ use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Role\RoleHierarchy;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Form\Type\ComposedRoleScopeType;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
@@ -44,11 +43,6 @@ class PermissionsGroupController extends AbstractController
*/
private $translator;
/**
* @var ValidatorInterface
*/
private $validator;
/**
* PermissionsGroupController constructor.
*
@@ -56,21 +50,18 @@ class PermissionsGroupController extends AbstractController
* @param RoleProvider $roleProvider
* @param RoleHierarchy $roleHierarchy
* @param TranslatorInterface $translator
* @param ValidatorInterface $validator
*/
public function __construct(
TranslatableStringHelper $translatableStringHelper,
RoleProvider $roleProvider,
RoleHierarchy $roleHierarchy,
TranslatorInterface $translator,
ValidatorInterface $validator
TranslatorInterface $translator
)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->roleProvider = $roleProvider;
$this->roleHierarchy = $roleHierarchy;
$this->translator = $translator;
$this->validator = $validator;
}
/**
@@ -461,7 +452,7 @@ class PermissionsGroupController extends AbstractController
);
$permissionsGroup->addRoleScope($roleScope);
$violations = $this->validator->validate($permissionsGroup);
$violations = $this->get('validator')->validate($permissionsGroup);
if ($violations->count() === 0) {
$em->flush();

View File

@@ -11,7 +11,6 @@ use Chill\MainBundle\Form\UserType;
use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Form\Type\ComposedGroupCenterType;
use Chill\MainBundle\Form\UserPasswordType;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
@@ -29,21 +28,14 @@ class UserController extends AbstractController
*/
private $logger;
/**
* @var ValidatorInterface
*/
private $validator;
/**
* UserController constructor.
*
* @param LoggerInterface $logger
* @param ValidatorInterface $validator
*/
public function __construct(LoggerInterface $logger, ValidatorInterface $validator)
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
$this->validator = $validator;
}
/**
@@ -266,7 +258,7 @@ class UserController extends AbstractController
$form[self::FORM_GROUP_CENTER_COMPOSED]->getData());
$user->addGroupCenter($groupCenter);
if ($this->validator->validate($user)->count() === 0) {
if ($this->get('validator')->validate($user)->count() === 0) {
$em->flush();
$this->addFlash('success', $this->get('translator')->trans('The '
@@ -275,7 +267,7 @@ class UserController extends AbstractController
return $this->redirect($this->generateUrl('admin_user_edit',
array('id' => $uid)));
} else {
foreach($this->validator->validate($user) as $error)
foreach($this->get('validator')->validate($user) as $error)
$this->addFlash('error', $error->getMessage());
}
}
@@ -388,7 +380,7 @@ class UserController extends AbstractController
// logging for prod
$this->logger->info('update password for an user', [
'by' => $this->getUser()->getUsername(),
'by' => $this->getUser()->getUsername(),
'user' => $user->getUsername()
]);

View File

@@ -34,7 +34,7 @@ trait PrepareClientTrait
* @return \Symfony\Component\BrowserKit\Client
* @throws \LogicException
*/
public function getClientAuthenticated(
public function getClient(
$username = 'center a_social',
$password = 'password'
) {

View File

@@ -0,0 +1,13 @@
<?php
namespace Chill\MainBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
public function testIndex()
{
}
}

View File

@@ -45,6 +45,11 @@ class ExportManagerTest extends KernelTestCase
use \Chill\MainBundle\Test\PrepareUserTrait;
use \Chill\MainBundle\Test\PrepareScopeTrait;
/**
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
private $container;
/**
*
@@ -60,6 +65,8 @@ class ExportManagerTest extends KernelTestCase
{
self::bootKernel();
$this->container = self::$kernel->getContainer();
$this->prophet = new \Prophecy\Prophet;
}
@@ -90,7 +97,7 @@ class ExportManagerTest extends KernelTestCase
\Symfony\Component\Security\Core\User\UserInterface $user = null
)
{
$localUser = $user === NULL ? self::$container->get('doctrine.orm.entity_manager')
$localUser = $user === NULL ? $this->container->get('doctrine.orm.entity_manager')
->getRepository('ChillMainBundle:User')
->findOneBy(array('username' => 'center a_social')) :
$user;
@@ -99,10 +106,10 @@ class ExportManagerTest extends KernelTestCase
$tokenStorage->setToken($token);
return new ExportManager(
$logger === NULL ? self::$container->get('logger') : $logger,
$em === NULL ? self::$container->get('doctrine.orm.entity_manager') : $em,
$authorizationChecker === NULL ? self::$container->get('security.authorization_checker') : $authorizationChecker,
$authorizationHelper === NULL ? self::$container->get('chill.main.security.authorization.helper') : $authorizationHelper,
$logger === NULL ? $this->container->get('logger') : $logger,
$em === NULL ? $this->container->get('doctrine.orm.entity_manager') : $em,
$authorizationChecker === NULL ? $this->container->get('security.authorization_checker') : $authorizationChecker,
$authorizationHelper === NULL ? $this->container->get('chill.main.security.authorization.helper') : $authorizationHelper,
$tokenStorage)
;
}
@@ -537,7 +544,7 @@ class ExportManagerTest extends KernelTestCase
$export = $this->prophet->prophesize();
$export->willImplement(ExportInterface::class);
$em = self::$container->get('doctrine.orm.entity_manager');
$em = $this->container->get('doctrine.orm.entity_manager');
$export->initiateQuery(
Argument::is(array('foo')),
Argument::Type('array'),
@@ -620,7 +627,7 @@ class ExportManagerTest extends KernelTestCase
//add formatter interface
$formatter = new \Chill\MainBundle\Export\Formatter\SpreadSheetFormatter(
self::$container->get('translator'), $exportManager);
$this->container->get('translator'), $exportManager);
$exportManager->addFormatter($formatter, 'spreadsheet');
//ob_start();

View File

@@ -1,16 +1,16 @@
services:
Chill\MainBundle\Controller\:
autowire: true
resource: '../../Controller'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\PasswordController:
autowire: true
arguments:
$chillLogger: '@monolog.logger.chill'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\SearchController:
arguments:
$searchProvider: '@chill_main.search_provider'
@@ -24,11 +24,9 @@ services:
$roleProvider: '@chill.main.role_provider'
$roleHierarchy: '@security.role_hierarchy'
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\UserController:
arguments:
$logger: '@Psr\Log\LoggerInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
tags: ['controller.service_arguments']

View File

@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
namespace Chill\Migrations\Main;
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

View File

@@ -3,7 +3,7 @@
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
* 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
@@ -23,7 +23,6 @@
namespace Chill\PersonBundle\Controller;
use Chill\PersonBundle\Privacy\PrivacyEvent;
use Doctrine\DBAL\Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Form\AccompanyingPeriodType;
@@ -33,8 +32,6 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Class AccompanyingPeriodController
@@ -49,54 +46,57 @@ class AccompanyingPeriodController extends AbstractController
protected $eventDispatcher;
/**
* @var ValidatorInterface
*/
protected $validator;
/**
* AccompanyingPeriodController constructor.
* ReportController constructor.
*
* @param EventDispatcherInterface $eventDispatcher
* @param ValidatorInterface $validator
*/
public function __construct(EventDispatcherInterface $eventDispatcher, ValidatorInterface $validator)
public function __construct(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
$this->validator = $validator;
}
public function listAction(int $person_id): Response
{
/**
* @param $person_id
* @return Response
*/
public function listAction($person_id){
$person = $this->_getPerson($person_id);
$event = new PrivacyEvent($person, [
$event = new PrivacyEvent($person, array(
'element_class' => AccompanyingPeriod::class,
'action' => 'list'
]);
));
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
return $this->render('ChillPersonBundle:AccompanyingPeriod:list.html.twig', [
'accompanying_periods' => $person->getAccompanyingPeriodsOrdered(),
'person' => $person
]);
return $this->render('ChillPersonBundle:AccompanyingPeriod:list.html.twig',
array('accompanying_periods' => $person->getAccompanyingPeriodsOrdered(),
'person' => $person));
}
public function createAction(int $person_id, Request $request): Response
/**
* @param $person_id
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function createAction($person_id, Request $request)
{
$person = $this->_getPerson($person_id);
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
'You are not allowed to update this person');
$accompanyingPeriod = new AccompanyingPeriod(new \DateTimeImmutable('now'));
$accompanyingPeriod->setClosingDate(new \DateTimeImmutable('now'));
$accompanyingPeriod->addPerson($person);
//or $person->addAccompanyingPeriod($accompanyingPeriod);
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime());
$accompanyingPeriod->setClosingDate(new \DateTime());
$person->addAccompanyingPeriod(
$accompanyingPeriod);
$form = $this->createForm(
AccompanyingPeriodType::class,
$accompanyingPeriod, [
$accompanyingPeriod,
[
'period_action' => 'create',
'center' => $person->getCenter()
]);
@@ -106,7 +106,7 @@ class AccompanyingPeriodController extends AbstractController
$errors = $this->_validatePerson($person);
$flashBag = $this->get('session')->getFlashBag();
if ($form->isValid(['Default', 'closed'])
if ($form->isValid(array('Default', 'closed'))
&& count($errors) === 0) {
$em = $this->getDoctrine()->getManager();
@@ -116,11 +116,8 @@ class AccompanyingPeriodController extends AbstractController
$this->get('translator')->trans(
'A period has been created.'));
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId()
]));
return $this->redirect($this->generateUrl('chill_person_accompanying_period_list',
array('person_id' => $person->getId())));
} else {
$flashBag->add('error', $this->get('translator')
->trans('Error! Period not created!'));
@@ -131,64 +128,57 @@ class AccompanyingPeriodController extends AbstractController
}
}
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
'form' => $form->createView(),
'person' => $person,
'accompanying_period' => $accompanyingPeriod
]);
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig',
array(
'form' => $form->createView(),
'person' => $person,
'accompanying_period' => $accompanyingPeriod
)
);
}
/**
* @throws Exception
* @param $person_id
* @param $period_id
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response|\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function updateAction(int $person_id, int $period_id, Request $request): Response
{
public function updateAction($person_id, $period_id, Request $request){
$em = $this->getDoctrine()->getManager();
/** @var AccompanyingPeriod $accompanyingPeriod */
$accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($period_id);
$accompanyingPeriod = $em->getRepository('ChillPersonBundle:AccompanyingPeriod')
->find($period_id);
if ($accompanyingPeriod === null) {
throw $this->createNotFoundException("Period with id " . $period_id . " is not found");
return $this->createNotFoundException("Period with id ".$period_id.
" is not found");
}
/** @var Person $person */
$person = $this->_getPerson($person_id);
// CHECK
if (! $accompanyingPeriod->containsPerson($person)) {
throw new Exception("Accompanying period " . $period_id . " does not contain person " . $person_id);
}
$person = $accompanyingPeriod->getPerson();
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
'You are not allowed to update this person');
$form = $this->createForm(AccompanyingPeriodType::class,
$accompanyingPeriod, [
'period_action' => 'update',
'center' => $person->getCenter()
]);
$accompanyingPeriod, array('period_action' => 'update',
'center' => $person->getCenter()));
if ($request->getMethod() === 'POST') {
$form->handleRequest($request);
$errors = $this->_validatePerson($person);
$flashBag = $this->get('session')->getFlashBag();
if ($form->isValid(['Default', 'closed'])
if ($form->isValid(array('Default', 'closed'))
&& count($errors) === 0) {
$em->flush();
$flashBag->add('success',
$this->get('translator')->trans('An accompanying period has been updated.'));
$this->get('translator')->trans(
'An accompanying period has been updated.'));
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId()
]));
return $this->redirect($this->generateUrl('chill_person_accompanying_period_list',
array('person_id' => $person->getId())));
} else {
$flashBag->add('error', $this->get('translator')
->trans('Error when updating the period'));
@@ -198,42 +188,46 @@ class AccompanyingPeriodController extends AbstractController
}
}
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
'form' => $form->createView(),
'person' => $person,
'accompanying_period' => $accompanyingPeriod
]);
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig',
array(
'form' => $form->createView(),
'person' => $person,
'accompanying_period' => $accompanyingPeriod
) );
}
/**
* @param $person_id
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
* @throws \Exception
*/
public function closeAction(int $person_id, Request $request): Response
public function closeAction($person_id, Request $request)
{
$person = $this->_getPerson($person_id);
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, 'You are not allowed to update this person');
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
'You are not allowed to update this person');
if ($person->isOpen() === false) {
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
->trans('Beware period is closed', ['%name%' => $person->__toString()]
));
->trans('Beware period is closed',
array('%name%' => $person->__toString())));
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId()
]));
$this->generateUrl('chill_person_accompanying_period_list', array(
'person_id' => $person->getId()
)));
}
$current = $person->getCurrentAccompanyingPeriod();
$form = $this->createForm(AccompanyingPeriodType::class, $current, [
$form = $this->createForm(AccompanyingPeriodType::class, $current, array(
'period_action' => 'close',
'center' => $person->getCenter()
]);
));
if ($request->getMethod() === 'POST') {
$form->handleRequest($request);
@@ -245,18 +239,16 @@ class AccompanyingPeriodController extends AbstractController
if (count($errors) === 0) {
$this->get('session')->getFlashBag()
->add('success', $this->get('translator')
->trans('An accompanying period has been closed.', [
'%name%' => $person->__toString()
]));
->trans('An accompanying period has been closed.',
array('%name%' => $person->__toString())));
$this->getDoctrine()->getManager()->flush();
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId()
])
);
$this->generateUrl('chill_person_accompanying_period_list', array(
'person_id' => $person->getId()
))
);
} else {
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
@@ -267,7 +259,6 @@ class AccompanyingPeriodController extends AbstractController
->add('info', $error->getMessage());
}
}
} else { //if form is not valid
$this->get('session')->getFlashBag()
->add('error',
@@ -282,34 +273,37 @@ class AccompanyingPeriodController extends AbstractController
}
}
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
'form' => $form->createView(),
'person' => $person,
'accompanying_period' => $current
]);
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig',
array(
'form' => $form->createView(),
'person' => $person,
'accompanying_period' => $current
));
}
private function _validatePerson(Person $person): ConstraintViolationListInterface
{
$errors = $this->validator->validate($person, null,
['Default']);
/**
* @param Person $person
* @return \Symfony\Component\Validator\ConstraintViolationListInterface
*/
private function _validatePerson(Person $person) {
$errors = $this->get('validator')->validate($person, null,
array('Default'));
$errors_accompanying_period = $this->get('validator')->validate($person, null,
array('accompanying_period_consistent'));
// Can be disabled with config
if (false === $this->container->getParameter('chill_person.allow_multiple_simultaneous_accompanying_periods')) {
$errors_accompanying_period = $this->validator->validate($person, null,
['accompanying_period_consistent']);
foreach($errors_accompanying_period as $error ) {
$errors->add($error);
}
foreach($errors_accompanying_period as $error ) {
$errors->add($error);
}
return $errors;
}
public function openAction(int $person_id, Request $request): Response
{
/**
* @param $person_id
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function openAction($person_id, Request $request) {
$person = $this->_getPerson($person_id);
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person,
@@ -320,22 +314,19 @@ class AccompanyingPeriodController extends AbstractController
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
->trans('Error! Period %name% is not closed ; it can be open',
['%name%' => $person->__toString()]
));
array('%name%' => $person->__toString())));
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
'person_id' => $person->getId()
]));
$this->generateUrl('chill_person_accompanying_period_list', array(
'person_id' => $person->getId()
)));
}
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime());
$form = $this->createForm(AccompanyingPeriodType::class,
$accompanyingPeriod, [
'period_action' => 'open',
'center' => $person->getCenter()
]);
$accompanyingPeriod, array('period_action' => 'open',
'center' => $person->getCenter()));
if ($request->getMethod() === 'POST') {
$form->handleRequest($request);
@@ -347,18 +338,16 @@ class AccompanyingPeriodController extends AbstractController
if (count($errors) <= 0) {
$this->get('session')->getFlashBag()
->add('success', $this->get('translator')
->trans('An accompanying period has been opened.',
['%name%' => $person->__toString()]
));
->add('success', $this->get('translator')
->trans('An accompanying period has been opened.',
array('%name%' => $person->__toString())));
$this->getDoctrine()->getManager()->flush();
return $this->redirect(
$this->generateUrl('chill_person_accompanying_period_list', [
$this->generateUrl('chill_person_accompanying_period_list', array(
'person_id' => $person->getId()
]));
)));
} else {
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
@@ -369,25 +358,27 @@ class AccompanyingPeriodController extends AbstractController
->add('info', $error->getMessage());
}
}
} else { // if errors in forms
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
->trans('Period not opened : form is invalid')
);
->add('error', $this->get('translator')
->trans('Period not opened : form is invalid'));
}
}
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig', [
'form' => $form->createView(),
'person' => $person,
'accompanying_period' => $accompanyingPeriod
]);
return $this->render('ChillPersonBundle:AccompanyingPeriod:form.html.twig',
array('form' => $form->createView(),
'person' => $person,
'accompanying_period' => $accompanyingPeriod));
}
public function reOpenAction(int $person_id, int $period_id, Request $request): Response
/**
* @param $person_id
* @param $period_id
* @param Request $request
* @return object|\Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function reOpenAction($person_id, $period_id, Request $request)
{
/** @var Person $person */
$person = $this->_getPerson($person_id);
$criteria = Criteria::create();
@@ -404,7 +395,7 @@ class AccompanyingPeriodController extends AbstractController
$confirm = $request->query->getBoolean('confirm', false);
if ($confirm === true && $period->canBeReOpened($person)) {
if ($confirm === true && $period->canBeReOpened()) {
$period->reOpen();
$this->_validatePerson($person);
@@ -414,16 +405,13 @@ class AccompanyingPeriodController extends AbstractController
$this->addFlash('success', $this->get('translator')->trans(
'The period has been re-opened'));
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person->getId()
]);
} elseif ($confirm === false && $period->canBeReOpened($person)) {
return $this->render('ChillPersonBundle:AccompanyingPeriod:re_open.html.twig', [
return $this->redirectToRoute('chill_person_accompanying_period_list',
array('person_id' => $person->getId()));
} elseif ($confirm === false && $period->canBeReOpened()) {
return $this->render('ChillPersonBundle:AccompanyingPeriod:re_open.html.twig', array(
'period' => $period,
'person' => $person
]);
));
} else {
return (new Response())
->setStatusCode(Response::HTTP_BAD_REQUEST)
@@ -432,10 +420,12 @@ class AccompanyingPeriodController extends AbstractController
}
/**
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*
* @param int $id
* @return Person
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the person is not found
*/
private function _getPerson(int $id) : Person
{
private function _getPerson($id) {
$person = $this->getDoctrine()->getManager()
->getRepository('ChillPersonBundle:Person')->find($id);

View File

@@ -29,7 +29,6 @@ use Chill\MainBundle\Form\Type\AddressType;
use Chill\MainBundle\Entity\Address;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Class PersonAddressController
@@ -41,21 +40,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
*/
class PersonAddressController extends AbstractController
{
/**
* @var ValidatorInterface
*/
protected $validator;
/**
* PersonAddressController constructor.
*
* @param ValidatorInterface $validator
*/
public function __construct(ValidatorInterface $validator)
{
$this->validator = $validator;
}
public function listAction($person_id)
{
$person = $this->getDoctrine()->getManager()
@@ -317,9 +302,9 @@ class PersonAddressController extends AbstractController
*/
private function validatePerson(Person $person)
{
$errors = $this->validator
$errors = $this->get('validator')
->validate($person, null, array('Default'));
$errors_addresses_consistent = $this->validator
$errors_addresses_consistent = $this->get('validator')
->validate($person, null, array('addresses_consistent'));
foreach($errors_addresses_consistent as $error) {

View File

@@ -38,7 +38,6 @@ use Symfony\Component\Translation\TranslatorInterface;
use Chill\MainBundle\Search\SearchProvider;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Class PersonController
@@ -80,11 +79,6 @@ class PersonController extends AbstractController
* @var \Psr\Log\LoggerInterface
*/
private $logger;
/**
* @var ValidatorInterface
*/
private $validator;
public function __construct(
SimilarPersonMatcher $similarPersonMatcher,
@@ -92,8 +86,7 @@ class PersonController extends AbstractController
EventDispatcherInterface $eventDispatcher,
PersonRepository $personRepository,
ConfigPersonAltNamesHelper $configPersonAltNameHelper,
LoggerInterface $logger,
ValidatorInterface $validator
LoggerInterface $logger
) {
$this->similarPersonMatcher = $similarPersonMatcher;
$this->translator = $translator;
@@ -101,7 +94,6 @@ class PersonController extends AbstractController
$this->configPersonAltNameHelper = $configPersonAltNameHelper;
$this->personRepository = $personRepository;
$this->logger = $logger;
$this->validator = $validator;
}
public function getCFGroup()
@@ -274,14 +266,14 @@ class PersonController extends AbstractController
*/
private function _validatePersonAndAccompanyingPeriod(Person $person)
{
$errors = $this->validator
$errors = $this->get('validator')
->validate($person, null, array('creation'));
//validate accompanying periods
$periods = $person->getAccompanyingPeriods();
foreach ($periods as $period) {
$period_errors = $this->validator
$period_errors = $this->get('validator')
->validate($period);
//group errors :

View File

@@ -21,7 +21,6 @@
namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
@@ -196,9 +195,6 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
case 'maritalStatus':
$value = $this->getReference($value);
break;
case 'accompanyingPeriods':
$this->addAccompanyingPeriods($p, $value, $manager);
break;
}
//try to add the data using the setSomething function,
@@ -234,15 +230,15 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
private function getRandomAddress()
{
return (new Address())
->setStreetAddress1($this->faker->streetAddress)
->setStreetAddress2(
rand(0,9) > 5 ? $this->faker->streetAddress : ''
)
->setPostcode($this->getReference(
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
))
->setValidFrom($this->faker->dateTimeBetween('-5 years'))
;
->setStreetAddress1($this->faker->streetAddress)
->setStreetAddress2(
rand(0,9) > 5 ? $this->faker->streetAddress : ''
)
->setPostcode($this->getReference(
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
))
->setValidFrom($this->faker->dateTimeBetween('-5 years'))
;
}
private function getCountry($countryCode)
@@ -255,25 +251,25 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
->findOneByCountryCode($countryCode);
}
private $maritalStatusRef = ['ms_single', 'ms_married', 'ms_widow', 'ms_separat',
private $maritalStatusRef = ['ms_single', 'ms_married', 'ms_widow', 'ms_separat',
'ms_divorce', 'ms_legalco', 'ms_unknown'];
private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert", "Justin", "Brian",
"Compère", "Jean-de-Dieu", "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric",
"Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", "Vursuv", "Youssef" );
private $firstNamesFemale = array("Svedana", "Sevlatina", "Irène", "Marcelle",
"Corentine", "Alfonsine", "Caroline", "Solange", "Gostine", "Fatoumata", "Nicole",
"Groseille", "Chana", "Oxana", "Ivana", "Julie", "Tina", "Adèle" );
private $lastNames = array("Diallo", "Bah", "Gaillot", "Martin");
private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert",
"Compère", "Jean-de-Dieu",
"Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric",
"Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou",
"Vursuv" );
private $firstNamesFemale = array("Svedana", "Sevlatina","Irène", "Marcelle",
"Corentine", "Alfonsine","Caroline","Solange","Gostine", "Fatoumata",
"Groseille", "Chana", "Oxana", "Ivana");
private $lastNames = array("Diallo", "Bah", "Gaillot");
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',
'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", "jau", "tte", 'sir',
'ta', 'mi', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al',
'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su",
"lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu');
private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER);
private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER);
private $years = array();
@@ -283,101 +279,48 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
private $peoples = array(
array(
'LastName' => "Depardieu",
'FirstName' => "Gérard",
'FirstName' => "Depardieu",
'LastName' => "Gérard",
'Birthdate' => "1948-12-27",
'PlaceOfBirth' => "Châteauroux",
'Gender' => Person::MALE_GENDER,
'CountryOfBirth' => 'FR',
'Nationality' => 'RU',
'center' => 'centerA',
'maritalStatus' => 'ms_divorce',
'accompanyingPeriods' => [
[
'from' => '2015-02-01',
'to' => '2015-10-30',
'remark' => 'oops',
],[
'from' => '2017-06-01',
'to' => '2018-03-30',
'remark' => 'argg',
],[
'from' => '2019-01-01',
'to' => '2019-12-31',
'remark' => 'blob',
]
]
'maritalStatus' => 'ms_divorce'
),
array(
//to have a person with same firstname as Gérard Depardieu
'LastName' => "Depardieu",
'FirstName' => "Jean",
array(
//to have a person with same firstname as Gérard Depardieu
'FirstName' => "Depardieu",
'LastName' => "Jean",
'Birthdate' => "1960-10-12",
'CountryOfBirth' => 'FR',
'Nationality' => 'FR',
'center' => 'centerA',
'maritalStatus' => 'ms_divorce'
),
array(
//to have a person with same birthdate of Gérard Depardieu
'LastName' => 'Van Snick',
'FirstName' => 'Bart',
'Birthdate' => '1948-12-27',
'center' => 'centerA',
'maritalStatus' => 'ms_legalco'
),
array(
//to have a woman with Depardieu as FirstName
'LastName' => 'Depardieu',
'FirstName' => 'Charline',
'Gender' => Person::FEMALE_GENDER,
'center' => 'centerA',
'maritalStatus' => 'ms_legalco'
),
array(
//to have a special character in lastName
'LastName' => 'Manço',
'FirstName' => 'Étienne',
'center' => 'centerA',
'maritalStatus' => 'ms_unknown'
),
array(
//to have true duplicate person
'LastName' => "Depardieu",
'FirstName' => "Jean",
'Birthdate' => "1960-10-12",
'CountryOfBirth' => 'FR',
'Nationality' => 'FR',
'center' => 'centerA',
'maritalStatus' => 'ms_divorce'
),
array(
//to have false duplicate person
'LastName' => "Depardieu",
'FirstName' => "Jeanne",
'Birthdate' => "1966-11-13",
'CountryOfBirth' => 'FR',
'Nationality' => 'FR',
'center' => 'centerA',
'maritalStatus' => 'ms_legalco'
),
array(
//to have a person with same birthdate of Gérard Depardieu
'FirstName' => 'Van Snick',
'LastName' => 'Bart',
'Birthdate' => '1948-12-27',
'center' => 'centerA',
'maritalStatus' => 'ms_legalco'
),
array(
//to have a woman with Depardieu as FirstName
'FirstName' => 'Depardieu',
'LastName' => 'Charline',
'Gender' => Person::FEMALE_GENDER,
'center' => 'centerA',
'maritalStatus' => 'ms_legalco'
),
array(
//to have a special character in lastName
'FirstName' => 'Manço',
'LastName' => 'Étienne',
'center' => 'centerA',
'maritalStatus' => 'ms_unknown'
)
);
private function addAccompanyingPeriods(Person $person, array $periods, ObjectManager $manager)
{
foreach ($periods as $period) {
echo "adding new past Accompanying Period..\n";
/** @var AccompanyingPeriod $accompanyingPeriod */
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime($period['from']));
$accompanyingPeriod
->setClosingDate(new \DateTime($period['to']))
->setRemark($period['remark'])
;
$person->addAccompanyingPeriod($accompanyingPeriod);
}
}
}

View File

@@ -50,36 +50,24 @@ class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface
case 'social':
case 'direction':
printf("Adding CHILL_PERSON_UPDATE & CHILL_PERSON_CREATE to %s permission group \n", $permissionsGroup->getName());
$roleScopeUpdate = (new RoleScope())
->setRole('CHILL_PERSON_UPDATE')
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeUpdate);
$roleScopeCreate = (new RoleScope())
->setRole('CHILL_PERSON_CREATE')
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeCreate);
$roleScopeDuplicate = (new RoleScope())
->setRole('CHILL_PERSON_DUPLICATE')
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeDuplicate);
$roleScopeList = (new RoleScope())
->setRole(PersonVoter::LISTS)
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeList);
$roleScopeStats = (new RoleScope())
->setRole(PersonVoter::STATS)
->setScope(null);
$permissionsGroup->addRoleScope($roleScopeStats);
$manager->persist($roleScopeUpdate);
$manager->persist($roleScopeCreate);
$manager->persist($roleScopeDuplicate);
break;
case 'administrative':
printf("Adding CHILL_PERSON_SEE to %s permission group \n", $permissionsGroup->getName());

View File

@@ -56,9 +56,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
$this->handlePersonFieldsParameters($container, $config['person_fields']);
$this->handleAccompanyingPeriodsFieldsParameters($container, $config['accompanying_periods_fields']);
$container->setParameter('chill_person.allow_multiple_simultaneous_accompanying_periods',
$config['allow_multiple_simultaneous_accompanying_periods']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
$loader->load('services.yaml');
@@ -143,7 +140,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
}
$container->prependExtensionConfig('chill_custom_fields',
array('customizables_entities' =>
array('customizables_entities' =>
array(
array('class' => 'Chill\PersonBundle\Entity\Person', 'name' => 'PersonEntity')
)
@@ -155,7 +152,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
* @param ContainerBuilder $container
* @throws MissingBundleException
*/
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container)
{
$this->prependRoleHierarchy($container);
$this->prependHomepageWidget($container);
@@ -192,7 +189,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
/**
* Add a widget "add a person" on the homepage, automatically
*
*
* @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container
*/
protected function prependHomepageWidget(containerBuilder $container)
@@ -211,7 +208,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
/**
* Add role hierarchy.
*
*
* @param ContainerBuilder $container
*/
protected function prependRoleHierarchy(ContainerBuilder $container)
@@ -220,7 +217,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
'role_hierarchy' => array(
'CHILL_PERSON_UPDATE' => array('CHILL_PERSON_SEE'),
'CHILL_PERSON_CREATE' => array('CHILL_PERSON_SEE'),
PersonVoter::LISTS => [ ChillExportVoter::EXPORT ],
PersonVoter::LISTS => [ ChillExportVoter::EXPORT ],
PersonVoter::STATS => [ ChillExportVoter::EXPORT ]
)
));
@@ -228,7 +225,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
/**
* Add DQL function linked with person
*
*
* @param ContainerBuilder $container
*/
protected function prependDoctrineDQL(ContainerBuilder $container)

View File

@@ -104,21 +104,8 @@ class Configuration implements ConfigurationInterface
->canBeDisabled()
->children()
->append($this->addFieldNode('user'))
->append($this->addFieldNode('createdBy'))
->append($this->addFieldNode('step'))
->append($this->addFieldNode('origin'))
->append($this->addFieldNode('intensity'))
->append($this->addFieldNode('scopes'))
->append($this->addFieldNode('requestor'))
->append($this->addFieldNode('anonymous'))
->append($this->addFieldNode('emergency'))
->append($this->addFieldNode('confidential'))
->end() //children for 'accompanying_person_fields', parent = array 'person_fields'
->end() // paccompanying_person_fields, parent = children of root
->booleanNode('allow_multiple_simultaneous_accompanying_periods')
->info('Can we have more than one simultaneous accompanying period in the same time. Default false.')
->defaultValue(false)
->end()
->end() // children of 'root', parent = root
;

View File

@@ -3,7 +3,7 @@
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
* 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
@@ -22,58 +22,18 @@
namespace Chill\PersonBundle\Entity;
use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Chill\MainBundle\Entity\User;
/**
* AccompanyingPeriod Class
* AccompanyingPeriod
*
* @ORM\Entity(repositoryClass="Chill\PersonBundle\Repository\AccompanyingPeriodRepository")
* @ORM\Entity()
* @ORM\Table(name="chill_person_accompanying_period")
*/
class AccompanyingPeriod
{
/**
* Mark an accompanying period as "occasional"
*
* used in INTENSITY
*/
public const INTENSITY_OCCASIONAL = 'occasional';
/**
* Mark an accompanying period as "regular"
*
* used in INTENSITY
*/
public const INTENSITY_REGULAR = 'regular';
public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR];
/**
* Mark an accompanying period as "draft".
*
* This means that the accompanying period is not yet
* confirmed by the creator
*/
public const STEP_DRAFT = 'DRAFT';
/**
* Mark an accompanying period as "confirmed".
*
* This means that the accompanying period **is**
* confirmed by the creator
*/
public const STEP_CONFIRMED = 'CONFIRMED';
/**
* @var integer
*
@@ -103,24 +63,16 @@ class AccompanyingPeriod
* @ORM\Column(type="text")
*/
private $remark = '';
/**
* @var Collection
* @var Person
*
* @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Comment",
* mappedBy="accompanyingPeriod"
* )
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\Person",
* inversedBy="accompanyingPeriods",
* cascade={"refresh"})
*/
private $comments;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
* mappedBy="accompanyingPeriod",
* cascade={"persist", "remove", "merge", "detach"})
*/
private $participations;
private $person;
/**
* @var AccompanyingPeriod\ClosingMotive
@@ -132,88 +84,14 @@ class AccompanyingPeriod
private $closingMotive = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* The user making the accompanying
* @var User
*
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
* @ORM\JoinColumn(nullable=true)
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=true)
*/
private $createdBy;
/**
* @var string
* @ORM\Column(type="string", length=32, nullable=true)
*/
private $step = self::STEP_DRAFT;
/**
* @ORM\ManyToOne(targetEntity=Origin::class)
* @ORM\JoinColumn(nullable=true)
*/
private $origin;
/**
* @var string
* @ORM\Column(type="string", nullable=true)
*/
private $intensity;
/**
* @var Collection
* @ORM\ManyToMany(
* targetEntity=Scope::class,
* cascade={}
* )
* @ORM\JoinTable(
* name="accompanying_periods_scopes",
* joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
* )
*/
private $scopes;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=true)
*/
private $requestorPerson;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
* @ORM\JoinColumn(nullable=true)
*/
private $requestorThirdParty;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
private $requestorAnonymous = false;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
private $emergency = false;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
private $confidential = false;
/**
* @var Collection
*
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
* mappedBy="accompanyingPeriod"
* )
*/
private $resources;
/**
* AccompanyingPeriod constructor.
@@ -223,14 +101,12 @@ class AccompanyingPeriod
*/
public function __construct(\DateTime $dateOpening) {
$this->setOpeningDate($dateOpening);
$this->participations = new ArrayCollection();
$this->scopes = new ArrayCollection();
}
/**
* Get id
*
* @return integer
* @return integer
*/
public function getId()
{
@@ -253,7 +129,7 @@ class AccompanyingPeriod
/**
* Get openingDate
*
* @return \DateTime
* @return \DateTime
*/
public function getOpeningDate()
{
@@ -262,12 +138,12 @@ class AccompanyingPeriod
/**
* Set closingDate
*
*
* For closing a Person file, you should use Person::setClosed instead.
*
* @param \DateTime $dateClosing
* @return AccompanyingPeriod
*
*
*/
public function setClosingDate($closingDate)
{
@@ -279,7 +155,7 @@ class AccompanyingPeriod
/**
* Get closingDate
*
* @return \DateTime
* @return \DateTime
*/
public function getClosingDate()
{
@@ -289,20 +165,26 @@ class AccompanyingPeriod
/**
* @return boolean
*/
public function isOpen(): bool
public function isOpen(): bool
{
if ($this->getOpeningDate() > new \DateTimeImmutable('now')) {
if ($this->getOpeningDate() > new \DateTime('now')) {
return false;
}
if ($this->getClosingDate() === null) {
return true;
} else {
return false;
}
return false;
}
public function setRemark(string $remark): self
/**
* Set remark
*
* @param string $remark
* @return AccompanyingPeriod
*/
public function setRemark($remark)
{
if ($remark === null) {
$remark = '';
@@ -312,123 +194,83 @@ class AccompanyingPeriod
return $this;
}
public function getRemark(): string
/**
* Get remark
*
* @return string
*/
public function getRemark()
{
return $this->remark;
}
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
$this->comments[] = $comment;
return $this;
}
public function removeComment(Comment $comment): void
{
$this->comments->removeElement($comment);
}
/**
* Get Participations Collection
*/
public function getParticipations(): Collection
{
return $this->participations;
}
/**
* This private function scan Participations Collection,
* searching for a given Person
*/
private function participationsContainsPerson(Person $person): ?AccompanyingPeriodParticipation
{
foreach ($this->participations as $participation) {
/** @var AccompanyingPeriodParticipation $participation */
if ($person === $participation->getPerson()) {
return $participation;
}}
return null;
}
/**
* This public function is the same but return only true or false
* Set person.
*
* For consistency, you should use Person::addAccompanyingPeriod instead.
*
* @param Person $person
* @return AccompanyingPeriod
* @see Person::addAccompanyingPeriod
*/
public function containsPerson(Person $person): bool
public function setPerson(Person $person = null)
{
return ($this->participationsContainsPerson($person) === null) ? false : true;
}
/**
* Add Person
*/
public function addPerson(Person $person = null): self
{
$participation = new AccompanyingPeriodParticipation($this, $person);
$this->participations[] = $participation;
$this->person = $person;
return $this;
}
/**
* Remove Person
* Get person
*
* @return Person
*/
public function removePerson(Person $person): void
public function getPerson()
{
$participation = $this->participationsContainsPerson($person);
if (! null === $participation) {
$participation->setEndDate(new \DateTimeImmutable('now'));
$this->participations->removeElement($participation);
}
return $this->person;
}
public function getClosingMotive(): ?ClosingMotive
/**
* @return AccompanyingPeriod\ClosingMotive
*/
public function getClosingMotive()
{
return $this->closingMotive;
}
public function setClosingMotive(ClosingMotive $closingMotive = null): self
/**
* @param AccompanyingPeriod\ClosingMotive|null $closingMotive
* @return $this
*/
public function setClosingMotive(AccompanyingPeriod\ClosingMotive $closingMotive = null)
{
$this->closingMotive = $closingMotive;
return $this;
}
/**
* If the period can be reopened.
*
* This function test if the period is closed and if the period is the last
* for the given person
*
* This function test if the period is closed and if the period is the last
* for the associated person
*
* @return boolean
*/
public function canBeReOpened(Person $person): bool
public function canBeReOpened()
{
if ($this->isOpen() === true) {
return false;
}
$participation = $this->participationsContainsPerson($person);
if (!null === $participation)
{
$person = $participation->getPerson();
$periods = $person->getAccompanyingPeriodsOrdered();
return end($periods) === $this;
}
$periods = $this->getPerson()->getAccompanyingPeriodsOrdered();
return false;
return end($periods) === $this;
}
/**
*/
public function reOpen(): void
public function reOpen()
{
$this->setClosingDate(null);
$this->setClosingMotive(null);
@@ -452,7 +294,7 @@ class AccompanyingPeriod
/**
* Returns true if the closing date is after the opening date.
*
*
* @return boolean
*/
public function isClosingAfterOpening()
@@ -466,165 +308,23 @@ class AccompanyingPeriod
}
}
/**
* @return User|null
*/
function getUser(): ?User
{
return $this->user;
}
/**
* @param User $user
* @return AccompanyingPeriod
*/
function setUser(User $user): self
{
$this->user = $user;
return $this;
}
public function getOrigin(): Origin
{
return $this->origin;
}
public function setOrigin(Origin $origin): self
{
$this->origin = $origin;
return $this;
}
public function getRequestorPerson(): ?Person
{
return $this->requestorPerson;
}
public function setRequestorPerson(Person $requestorPerson): self
{
$this->requestorPerson = ($this->requestorThirdParty === null) ? $requestorPerson : null;
return $this;
}
public function getRequestorThirdParty(): ?ThirdParty
{
return $this->requestorThirdParty;
}
public function setRequestorThirdParty(ThirdParty $requestorThirdParty): self
{
$this->requestorThirdParty = ($this->requestorPerson === null) ? $requestorThirdParty : null;
return $this;
}
/**
* @return Person|ThirdParty
*/
public function getRequestor()
{
return $this->requestorPerson ?? $this->requestorThirdParty;
}
public function isRequestorAnonymous(): bool
{
return $this->requestorAnonymous;
}
public function setRequestorAnonymous(bool $requestorAnonymous): self
{
$this->requestorAnonymous = $requestorAnonymous;
return $this;
}
public function isEmergency(): bool
{
return $this->emergency;
}
public function setEmergency(bool $emergency): self
{
$this->emergency = $emergency;
return $this;
}
public function isConfidential(): bool
{
return $this->confidential;
}
public function setConfidential(bool $confidential): self
{
$this->confidential = $confidential;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getStep(): string
{
return $this->step;
}
public function setStep(string $step): self
{
$this->step = $step;
return $this;
}
public function getIntensity(): string
{
return $this->intensity;
}
public function setIntensity(string $intensity): self
{
$this->intensity = $intensity;
return $this;
}
public function getScopes(): Collection
{
return $this->scopes;
}
public function addScope(Scope $scope): self
{
$this->scopes[] = $scope;
return $this;
}
public function removeScope(Scope $scope): void
{
$this->scopes->removeElement($scope);
}
public function getResources(): Collection
{
return $this->resources;
}
public function addResource(Resource $resource): self
{
$this->resources[] = $resource;
return $this;
}
public function removeResource(Resource $resource): void
{
$this->resources->removeElement($resource);
}
}

View File

@@ -1,21 +1,19 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
*
*
* Copyright (C) 2014-2020, 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
* 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.
*
* 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/>.
*/
@@ -30,8 +28,8 @@ use Doctrine\Common\Collections\ArrayCollection;
* ClosingMotive give an explanation why we closed the Accompanying period
*
* @ORM\Entity(
* repositoryClass="Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository")
* @ORM\Table(name="chill_person_accompanying_period_closingmotive")
* repositoryClass="Chill\PersonBundle\Repository\ClosingMotiveRepository")
* @ORM\Table(name="chill_person_closingmotive")
*/
class ClosingMotive
{
@@ -47,7 +45,7 @@ class ClosingMotive
/**
* @var array
*
* @ORM\Column(type="json")
* @ORM\Column(type="json_array")
*/
private $name;

View File

@@ -1,154 +0,0 @@
<?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\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriod\CommentRepository;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CommentRepository::class)
* @ORM\Table(name="chill_person_accompanying_period_comment")
*/
class Comment
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $accompanyingPeriod;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private $creator;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private $updatedBy;
/**
* @ORM\Column(type="text")
*/
private $content;
public function getId(): ?int
{
return $this->id;
}
public function getAccompanyingPeriod(): ?AccompanyingPeriod
{
return $this->accompanyingPeriod;
}
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
{
$this->accompanyingPeriod = $accompanyingPeriod;
return $this;
}
public function getCreator(): ?User
{
return $this->creator;
}
public function setCreator(?User $creator): self
{
$this->creator = $creator;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
}

View File

@@ -1,79 +0,0 @@
<?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\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\OriginRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=OriginRepository::class)
* @ORM\Table(name="chill_person_accompanying_period_origin")
*/
class Origin
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="json")
*/
private $label;
/**
* @ORM\Column(type="date_immutable", nullable=true)
*/
private $noActiveAfter;
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getNoActiveAfter(): ?\DateTimeImmutable
{
return $this->noActiveAfter;
}
public function setNoActiveAfter(?\DateTimeImmutable $noActiveAfter): self
{
$this->noActiveAfter = $noActiveAfter;
return $this;
}
}

View File

@@ -1,132 +0,0 @@
<?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\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriod\ResourceRepository;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ResourceRepository::class)
* @ORM\Table(name="chill_person_accompanying_period_resource")
*/
class Resource
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* inversedBy="resources"
* )
* @ORM\JoinColumn(nullable=false)
*/
private $accompanyingPeriod;
/**
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
* @ORM\JoinColumn(nullable=true)
*/
private $thirdParty;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=true)
*/
private $person;
/**
* @ORM\ManyToOne(targetEntity=Comment::class)
* @ORM\JoinColumn(nullable=true)
*/
private $comment;
public function getId(): ?int
{
return $this->id;
}
public function getAccompanyingPeriod(): ?AccompanyingPeriod
{
return $this->accompanyingPeriod;
}
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
{
$this->accompanyingPeriod = $accompanyingPeriod;
return $this;
}
public function getThirdParty(): ?ThirdParty
{
return $this->thirdParty;
}
public function setThirdParty(?ThirdParty $thirdParty): self
{
$this->thirdParty = $thirdParty;
return $this;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function setPerson(?Person $person): self
{
$this->person = $person;
return $this;
}
public function getComment(): ?Comment
{
return $this->comment;
}
public function setComment(?Comment $comment): self
{
$this->comment = $comment;
return $this;
}
/**
* @return Person|ThirdParty
*/
public function getResource()
{
return $this->person ?? $this->thirdParty;
}
}

View File

@@ -1,124 +0,0 @@
<?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\PersonBundle\Entity;
use Chill\PersonBundle\Repository\AccompanyingPeriodParticipationRepository;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\Mapping as ORM;
/**
* AccompanyingPeriodParticipation Class
*
* @package Chill\PersonBundle\Entity
* @ORM\Entity(repositoryClass=AccompanyingPeriodParticipationRepository::class)
* @ORM\Table(name="chill_person_accompanying_period_participation")
*/
class AccompanyingPeriodParticipation
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations")
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
*/
private $person;
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
*/
private $accompanyingPeriod;
/**
* @ORM\Column(type="date", nullable=false)
*/
private $startDate;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $endDate = null;
public function __construct(AccompanyingPeriod $accompanyingPeriod, Person $person)
{
$this->startDate = new \DateTimeImmutable('now');
$this->accompanyingPeriod = $accompanyingPeriod;
$this->person = $person;
}
public function getId(): ?int
{
return $this->id;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function setPerson(?Person $person): self
{
$this->person = $person;
return $this;
}
public function getAccompanyingPeriod(): ?AccompanyingPeriod
{
return $this->accompanyingPeriod;
}
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
{
$this->accompanyingPeriod = $accompanyingPeriod;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
/*
* public function setStartDate(\DateTimeInterface $startDate): self { $this->startDate = $startDate; return $this; }
*/
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(?\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
}

View File

@@ -42,6 +42,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
* name="person_names",
* columns={"firstName", "lastName"}
* )})
* sf4 check index name
* @ORM\HasLifecycleCallbacks()
*/
class Person implements HasCenterInterface
@@ -215,13 +216,14 @@ class Person implements HasCenterInterface
/**
* The person's accompanying periods (when the person was accompanied by the center)
* @var Collection
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* mappedBy="person",
* cascade={"persist", "remove", "merge", "detach"})
*/
private $accompanyingPeriodParticipations;
private $accompanyingPeriods; //TO-CHANGE in accompanyingHistory
/**
* A remark over the person
@@ -273,7 +275,7 @@ class Person implements HasCenterInterface
*/
public function __construct(\DateTime $opening = null)
{
$this->accompanyingPeriodParticipations = new ArrayCollection();
$this->accompanyingPeriods = new ArrayCollection();
$this->spokenLanguages = new ArrayCollection();
$this->addresses = new ArrayCollection();
$this->altNames = new ArrayCollection();
@@ -285,54 +287,23 @@ class Person implements HasCenterInterface
$this->open(new AccompanyingPeriod($opening));
}
/**
* This private function scan accompanyingPeriodParticipations Collection,
* searching for a given AccompanyingPeriod
* @param AccompanyingPeriod $accompanyingPeriod
* @uses AccompanyingPeriod::setPerson
*/
private function participationsContainAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): ?AccompanyingPeriodParticipation
public function addAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod)
{
foreach ($this->accompanyingPeriodParticipations as $participation) {
/** @var AccompanyingPeriodParticipation $participation */
if ($accompanyingPeriod === $participation->getAccompanyingPeriod()) {
return $participation;
}}
return null;
}
/**
* This public function is the same but return only true or false
*/
public function containsAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool
{
return ($this->participationsContainAccompanyingPeriod($accompanyingPeriod)) ? false : true;
}
/**
* Add AccompanyingPeriodParticipation
*
* @uses AccompanyingPeriod::addPerson
*/
public function addAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): self
{
$participation = new AccompanyingPeriodParticipation($accompanyingPeriod, $this);
$this->accompanyingPeriodParticipations->add($participation);
return $this;
$accompanyingPeriod->setPerson($this);
$this->accompanyingPeriods->add($accompanyingPeriod);
}
/**
* Remove AccompanyingPeriod
* @param AccompanyingPeriod $accompanyingPeriod
*/
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod)
{
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
if (! null === $participation) {
$participation->setEndDate(\DateTimeImmutable::class);
$this->accompanyingPeriodParticipations->removeElement($participation);
}
$this->accompanyingPeriods->remove($accompanyingPeriod);
}
/**
@@ -344,8 +315,10 @@ class Person implements HasCenterInterface
* For closing a file, @see this::close
*
* To check if the Person and its accompanying period is consistent, use validation.
*
* @param AccompanyingPeriod $accompanyingPeriod
*/
public function open(AccompanyingPeriod $accompanyingPeriod) : void
public function open(AccompanyingPeriod $accompanyingPeriod)
{
$this->proxyAccompanyingPeriodOpenState = true;
$this->addAccompanyingPeriod($accompanyingPeriod);
@@ -359,26 +332,28 @@ class Person implements HasCenterInterface
*
* To check if the Person and its accompanying period are consistent, use validation.
*
* @param accompanyingPeriod
* @throws \Exception if two lines of the accompanying period are open.
*/
public function close(AccompanyingPeriod $accompanyingPeriod = null) : void
public function close(AccompanyingPeriod $accompanyingPeriod = null)
{
$this->proxyAccompanyingPeriodOpenState = false;
}
/**
* Return the opened accompanying period.
*
* @return AccompanyingPeriod
*/
public function getOpenedAccompanyingPeriod() : AccompanyingPeriod
public function getOpenedAccompanyingPeriod()
{
if ($this->isOpen() === false) {
return null;
}
foreach ($this->accompanyingPeriodParticipations as $participation) {
/** @var AccompanyingPeriodParticipation $participation */
if ($participation->getAccompanyingPeriod()->isOpen()) {
return $participation->getAccompanyingPeriod();
foreach ($this->accompanyingPeriods as $period) {
if ($period->isOpen()) {
return $period;
}
}
}
@@ -386,41 +361,31 @@ class Person implements HasCenterInterface
/**
* Returns the opened accompanying period.
*
* @return AccompanyingPeriod
* @deprecated since 1.1 use `getOpenedAccompanyingPeriod instead
*/
public function getCurrentAccompanyingPeriod() : AccompanyingPeriod
public function getCurrentAccompanyingPeriod()
{
return $this->getOpenedAccompanyingPeriod();
}
/**
* Get AccompanyingPeriods array
* @return ArrayCollection
*/
public function getAccompanyingPeriods(): array
public function getAccompanyingPeriods()
{
$accompanyingPeriods = [];
foreach ($this->accompanyingPeriodParticipations as $participation)
{
/** @var AccompanyingPeriodParticipation $participation */
$accompanyingPeriods[] = $participation->getAccompanyingPeriod();
}
return $accompanyingPeriods;
}
/**
* Get AccompanyingPeriodParticipations Collection
*/
public function getAccompanyingPeriodParticipations(): Collection
{
return $this->accompanyingPeriodParticipations;
return $this->accompanyingPeriods;
}
/**
* Get the accompanying periods of a give person with the chronological order.
* Get the accompanying periods of a give person with the
* chronological order.
*
* @return AccompanyingPeriod[]
*/
public function getAccompanyingPeriodsOrdered(): array
public function getAccompanyingPeriodsOrdered()
{
$periods = $this->getAccompanyingPeriods();
$periods = $this->getAccompanyingPeriods()->toArray();
//order by date :
usort($periods, function($a, $b) {
@@ -453,9 +418,11 @@ class Person implements HasCenterInterface
}
/**
* Check if the person is opened
* check if the person is opened
*
* @return boolean
*/
public function isOpen() : bool
public function isOpen()
{
foreach ($this->getAccompanyingPeriods() as $period) {
if ($period->isOpen()) {
@@ -1142,15 +1109,4 @@ class Person implements HasCenterInterface
return true;
}
public function getFullnameCanonical() : string
{
return $this->fullnameCanonical;
}
public function setFullnameCanonical($fullnameCanonical) : Person
{
$this->fullnameCanonical = $fullnameCanonical;
return $this;
}
}

View File

@@ -11,7 +11,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
use Symfony\Component\OptionsResolver\Options;
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository;
use Chill\PersonBundle\Repository\ClosingMotiveRepository;
/**
* Class ClosingMotivePickerType

View File

@@ -1,42 +0,0 @@
<?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\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Comment|null find($id, $lockMode = null, $lockVersion = null)
* @method Comment|null findOneBy(array $criteria, array $orderBy = null)
* @method Comment[] findAll()
* @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CommentRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Comment::class);
}
}

View File

@@ -1,42 +0,0 @@
<?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\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Origin|null find($id, $lockMode = null, $lockVersion = null)
* @method Origin|null findOneBy(array $criteria, array $orderBy = null)
* @method Origin[] findAll()
* @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class OriginRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Origin::class);
}
}

View File

@@ -1,42 +0,0 @@
<?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\PersonBundle\Repository\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Resource|null find($id, $lockMode = null, $lockVersion = null)
* @method Resource|null findOneBy(array $criteria, array $orderBy = null)
* @method Resource[] findAll()
* @method Resource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ResourceRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Resource::class);
}
}

View File

@@ -1,42 +0,0 @@
<?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\PersonBundle\Repository;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null)
* @method AccompanyingPeriodParticipation|null findOneBy(array $criteria, array $orderBy = null)
* @method AccompanyingPeriodParticipation[] findAll()
* @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class AccompanyingPeriodParticipationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, AccompanyingPeriodParticipation::class);
}
}

View File

@@ -1,42 +0,0 @@
<?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\PersonBundle\Repository;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method AccompanyingPeriod|null find($id, $lockMode = null, $lockVersion = null)
* @method AccompanyingPeriod|null findOneBy(array $criteria, array $orderBy = null)
* @method AccompanyingPeriod[] findAll()
* @method AccompanyingPeriod[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class AccompanyingPeriodRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, AccompanyingPeriod::class);
}
}

View File

@@ -1,15 +1,11 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
* Copyright (C) 2020 Champs-Libres <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.
* 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
@@ -19,8 +15,7 @@
* 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\Repository\AccompanyingPeriod;
namespace Chill\PersonBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
@@ -44,13 +39,13 @@ class ClosingMotiveRepository extends EntityRepository
$rsm->addRootEntityFromClassMetadata($this->getClassName(), 'cm');
$sql = "SELECT ".(string) $rsm."
FROM chill_person_accompanying_period_closingmotive AS cm
FROM chill_person_closingmotive AS cm
WHERE
active IS TRUE ";
if ($onlyLeaf) {
$sql .= "AND cm.id NOT IN (
SELECT DISTINCT parent_id FROM chill_person_accompanying_period_closingmotive WHERE parent_id IS NOT NULL
SELECT DISTINCT parent_id FROM chill_person_closingmotive WHERE parent_id IS NOT NULL
)";
}

View File

@@ -5,9 +5,6 @@
{% block title %}{{ 'Person accompanying period - %name%'|trans({ '%name%' : person.__toString}) }}{% endblock title %}
{% block personcontent %}
<h1>{{ 'Accompanying period list'|trans }}</h1>
<table class="rounded">
<thead>
<tr>
@@ -71,7 +68,7 @@
</a>
</li>
{% endif %}
{% if accompanying_period.canBeReOpened(person) == true %}
{% if accompanying_period.canBeReOpened == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_re_open', {'person_id' : person.id, 'period_id' : accompanying_period.id } ) }}" class="sc-button bt-create change-icon has-hidden">
<i class="fa fa-unlock" aria-hidden="true"></i><span class="show-on-hover">{{'Re-open accompanying period'|trans }}</span>

View File

@@ -7,7 +7,6 @@ services:
$personRepository: '@Chill\PersonBundle\Repository\PersonRepository'
$configPersonAltNameHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
$logger: '@Psr\Log\LoggerInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\TimelinePersonController:
@@ -20,12 +19,6 @@ services:
Chill\PersonBundle\Controller\AccompanyingPeriodController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\PersonAddressController:
arguments:
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AdminController: ~

View File

@@ -19,7 +19,7 @@ services:
arguments:
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
$chillEntityRenderExtension: '@Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension'
$closingMotiveRepository: '@Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository'
$closingMotiveRepository: '@Chill\PersonBundle\Repository\ClosingMotiveRepository'
tags:
- { name: form.type, alias: closing_motive }

View File

@@ -6,15 +6,9 @@ services:
arguments:
- 'Chill\PersonBundle\Entity\Person'
Chill\PersonBundle\Repository\PersonRepository: '@chill.person.repository.person'
Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository:
class: Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository
Chill\PersonBundle\Repository\ClosingMotiveRepository:
class: Chill\PersonBundle\Repository\ClosingMotiveRepository
factory: ['@doctrine.orm.entity_manager', getRepository]
arguments:
- 'Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive'
Chill\PersonBundle\Repository\AccompanyingPeriodRepository:
class: Chill\PersonBundle\Repository\AccompanyingPeriodRepository
tags: [ doctrine.repository_service ]
arguments:
- '@Doctrine\Persistence\ManagerRegistry'

View File

@@ -27,9 +27,9 @@ Chill\PersonBundle\Entity\Person:
gender:
- NotNull:
groups: [general, creation]
#accompanyingPeriods:
# - Valid:
# traverse: true
accompanyingPeriods:
- Valid:
traverse: true
email:
- Email:
groups: [general, creation]

View File

@@ -1,70 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Change model relation between Person and AccompagnyingPeriod
* Migrate datas into new join table
*
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
final class Version20210326113045 extends AbstractMigration
{
private $datas = [];
public function getDescription() : string
{
return 'Change model relation between Person and AccompagnyingPeriod, without losing datas when going up';
}
/**
* In these direction, there is no loss.
*/
public function up(Schema $schema) : void
{
// create join table
$this->addSql('CREATE TABLE persons_accompanying_periods (person_id INT NOT NULL, accompanyingperiod_id INT NOT NULL, PRIMARY KEY(person_id, accompanyingperiod_id))');
$this->addSql('CREATE INDEX IDX_49A3871F217BBB47 ON persons_accompanying_periods (person_id)');
$this->addSql('CREATE INDEX IDX_49A3871F550B0C53 ON persons_accompanying_periods (accompanyingperiod_id)');
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT FK_49A3871F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT FK_49A3871F550B0C53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
// insert datas in new join table
$this->addSql('INSERT INTO persons_accompanying_periods (person_id, accompanyingperiod_id) '
. 'SELECT person_id, id as accompagnying_period_id FROM chill_person_accompanying_period WHERE person_id IS NOT NULL');
// drop column
$this->addSql('DROP INDEX idx_64a4a621217bbb47');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT fk_64a4a621217bbb47');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP person_id');
}
/**
* The distinct clause makes that for each group of duplicates, it keeps only the first row in the returned result set.
* Then we have only few lost datas. Lost datas: when many persons for one AccompanyingPeriod (keep only first person)
*/
public function down(Schema $schema) : void
{
// add column
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD person_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT fk_64a4a621217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX idx_64a4a621217bbb47 ON chill_person_accompanying_period (person_id)');
// insert datas in existing table
$this->addSql('UPDATE chill_person_accompanying_period AS ap '
. 'SET person_id = jt.person_id '
. 'FROM ( '
. 'SELECT DISTINCT ON (accompanyingperiod_id) accompanyingperiod_id AS id, person_id FROM persons_accompanying_periods '
. 'ORDER BY id, person_id ASC '
. ') AS jt '
. 'WHERE ap.id = jt.id');
// drop join table
$this->addSql('DROP TABLE persons_accompanying_periods');
}
}

View File

@@ -1,45 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add AccompanyingPeriod Origin table
*
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
final class Version20210329090904 extends AbstractMigration
{
public function getDescription() : string
{
return 'Add AccompanyingPeriod Origin table';
}
public function up(Schema $schema) : void
{
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_origin_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_person_accompanying_period_origin (id INT NOT NULL, label VARCHAR(255) NOT NULL, noActiveAfter DATE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_origin.noActiveAfter IS \'(DC2Type:date_immutable)\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD origin_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86856A273CC FOREIGN KEY (origin_id) REFERENCES chill_person_accompanying_period_origin (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_E260A86856A273CC ON chill_person_accompanying_period (origin_id)');
}
public function down(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86856A273CC');
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_origin_id_seq CASCADE');
$this->addSql('DROP TABLE chill_person_accompanying_period_origin');
$this->addSql('DROP INDEX IDX_E260A86856A273CC');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP origin_id');
}
}

View File

@@ -1,60 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add AccompanyingPeriod Comment and Resource tables
*
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
final class Version20210329113152 extends AbstractMigration
{
public function getDescription() : string
{
return 'Add AccompanyingPeriod Comment and Resource tables';
}
public function up(Schema $schema) : void
{
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_comment_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_person_accompanying_period_comment (id INT NOT NULL, creator_id INT NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, content TEXT NOT NULL, accompanyingPeriod_id INT NOT NULL, updatedBy_id INT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_CD960EF3D7FA8EF0 ON chill_person_accompanying_period_comment (accompanyingPeriod_id)');
$this->addSql('CREATE INDEX IDX_CD960EF361220EA6 ON chill_person_accompanying_period_comment (creator_id)');
$this->addSql('CREATE INDEX IDX_CD960EF365FF1AEC ON chill_person_accompanying_period_comment (updatedBy_id)');
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF3D7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF361220EA6 FOREIGN KEY (creator_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_comment ADD CONSTRAINT FK_CD960EF365FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_resource_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_person_accompanying_period_resource (id INT NOT NULL, person_id INT DEFAULT NULL, comment_id INT DEFAULT NULL, accompanyingPeriod_id INT NOT NULL, thirdParty_id INT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_DC78989FD7FA8EF0 ON chill_person_accompanying_period_resource (accompanyingPeriod_id)');
$this->addSql('CREATE INDEX IDX_DC78989F3EA5CAB0 ON chill_person_accompanying_period_resource (thirdParty_id)');
$this->addSql('CREATE INDEX IDX_DC78989F217BBB47 ON chill_person_accompanying_period_resource (person_id)');
$this->addSql('CREATE INDEX IDX_DC78989FF8697D13 ON chill_person_accompanying_period_resource (comment_id)');
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989FD7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989F3EA5CAB0 FOREIGN KEY (thirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_resource ADD CONSTRAINT FK_DC78989FF8697D13 FOREIGN KEY (comment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema) : void
{
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_resource_id_seq CASCADE');
$this->addSql('DROP TABLE chill_person_accompanying_period_resource');
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_comment_id_seq CASCADE');
$this->addSql('DROP TABLE chill_person_accompanying_period_comment');
}
}

View File

@@ -1,74 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Complete accompanying period table
*
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
final class Version20210329144338 extends AbstractMigration
{
public function getDescription() : string
{
return 'Complete AccompanyingPeriod table';
}
public function up(Schema $schema) : void
{
$this->addSql('CREATE TABLE accompanying_periods_scopes (accompanying_period_id INT NOT NULL, scope_id INT NOT NULL, PRIMARY KEY(accompanying_period_id, scope_id))');
$this->addSql('CREATE INDEX IDX_87C4EAB032A7A428 ON accompanying_periods_scopes (accompanying_period_id)');
$this->addSql('CREATE INDEX IDX_87C4EAB0682B5931 ON accompanying_periods_scopes (scope_id)');
$this->addSql('ALTER TABLE accompanying_periods_scopes ADD CONSTRAINT FK_87C4EAB032A7A428 FOREIGN KEY (accompanying_period_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE accompanying_periods_scopes ADD CONSTRAINT FK_87C4EAB0682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD step VARCHAR(32) DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD intensity VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD createdBy_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorPerson_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorThirdParty_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD requestorAnonymous BOOLEAN NOT NULL DEFAULT \'false\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD emergency BOOLEAN NOT NULL DEFAULT \'false\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD confidential BOOLEAN NOT NULL DEFAULT \'false\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A8683174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A86834269C3F FOREIGN KEY (requestorPerson_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A868CFE4D554 FOREIGN KEY (requestorThirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_E260A8683174800F ON chill_person_accompanying_period (createdBy_id)');
$this->addSql('CREATE INDEX IDX_E260A86834269C3F ON chill_person_accompanying_period (requestorPerson_id)');
$this->addSql('CREATE INDEX IDX_E260A868CFE4D554 ON chill_person_accompanying_period (requestorThirdParty_id)');
}
public function down(Schema $schema) : void
{
$this->addSql('DROP TABLE accompanying_periods_scopes');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A8683174800F');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A86834269C3F');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A868CFE4D554');
$this->addSql('DROP INDEX IDX_E260A8683174800F');
$this->addSql('DROP INDEX IDX_E260A86834269C3F');
$this->addSql('DROP INDEX IDX_E260A868CFE4D554');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP step');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP intensity');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP createdBy_id');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP requestorPerson_id');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP requestorThirdParty_id');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP requestorAnonymous');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP emergency');
$this->addSql('ALTER TABLE chill_person_accompanying_period DROP confidential');
}
}

View File

@@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Rename table closinmotive
*
* @author Mathieu Jaumotte mathieu.jaumotte@champs-libres.coop
*/
final class Version20210330164922 extends AbstractMigration
{
public function getDescription() : string
{
return 'Rename table closinmotive';
}
public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_closingmotive RENAME TO chill_person_accompanying_period_closingmotive');
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive RENAME CONSTRAINT fk_92351ece727aca70 TO FK_72D110E8727ACA70');
$this->addSql('ALTER TABLE chill_person_accompanying_period RENAME CONSTRAINT fk_64a4a621504cb38d TO FK_E260A868504CB38D');
}
public function down(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive RENAME TO chill_person_closingmotive');
$this->addSql('ALTER TABLE chill_person_closingmotive RENAME CONSTRAINT FK_72D110E8727ACA70 TO fk_92351ece727aca70');
$this->addSql('ALTER TABLE chill_person_accompanying_period RENAME CONSTRAINT FK_E260A868504CB38D TO fk_64a4a621504cb38d');
}
}

View File

@@ -1,67 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Transform join table between Person and AccompanyingPeriod in Doctrine entity
*/
final class Version20210331084527 extends AbstractMigration
{
public function getDescription() : string
{
return 'Transform join table between Person and AccompanyingPeriod in Doctrine entity';
}
public function up(Schema $schema) : void
{
// 1
$this->addSql('ALTER TABLE persons_accompanying_periods DROP CONSTRAINT persons_accompanying_periods_pkey');
$this->addSql('ALTER TABLE persons_accompanying_periods RENAME TO chill_person_accompanying_period_participation');
// 2
// SERIAL automatically create sequence with NEXTVAL()
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD COLUMN id SERIAL NOT NULL PRIMARY KEY');
// drop NEXTVAL() in column definition
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ALTER id DROP DEFAULT');
// 3
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD startDate DATE NOT NULL DEFAULT \'1970-01-01\'');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD endDate DATE DEFAULT NULL');
// 4
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT fk_49a3871f217bbb47');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT fk_49a3871f550b0c53');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT FK_A59DF89F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT FK_A59DF89F550B0C53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER INDEX idx_49a3871f217bbb47 RENAME TO IDX_A59DF89F217BBB47');
$this->addSql('ALTER INDEX idx_49a3871f550b0c53 RENAME TO IDX_A59DF89F550B0C53');
}
public function down(Schema $schema) : void
{
// 4
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT FK_A59DF89F217BBB47');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP CONSTRAINT FK_A59DF89F550B0C53');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT fk_49a3871f217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation ADD CONSTRAINT fk_49a3871f550b0c53 FOREIGN KEY (accompanyingperiod_id) REFERENCES chill_person_accompanying_period (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER INDEX idx_a59df89f550b0c53 RENAME TO idx_49a3871f550b0c53');
$this->addSql('ALTER INDEX idx_a59df89f217bbb47 RENAME TO idx_49a3871f217bbb47');
// 3
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP startDate');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP endDate');
// 2
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_participation_id_seq CASCADE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation DROP id');
// 1
$this->addSql('ALTER TABLE chill_person_accompanying_period_participation RENAME TO persons_accompanying_periods');
$this->addSql('ALTER TABLE persons_accompanying_periods ADD CONSTRAINT persons_accompanying_periods_pkey PRIMARY KEY (person_id, accompanyingperiod_id)');
}
}

View File

@@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Rename sequence "closing motive"
*/
final class Version20210419105054 extends AbstractMigration
{
public function getDescription() : string
{
return 'rename sequence "closing motive"';
}
public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_closingmotive_id_seq RENAME TO '
. 'chill_person_accompanying_period_closingmotive_id_seq');
}
public function down(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive_id_seq '
. 'RENAME TO chill_person_closingmotive_id_seq');
}
}

View File

@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* set label for origin as json
*/
final class Version20210419105940 extends AbstractMigration
{
public function getDescription() : string
{
return 'set label for origin as json';
}
public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label TYPE JSON USING json_build_object(\'fr\', label)::jsonb');
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label DROP DEFAULT');
}
public function down(Schema $schema) : void
{
// this will keep the '"' at first and last character, but is acceptable
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label TYPE VARCHAR(255) USING label->\'fr\'::text');
$this->addSql('ALTER TABLE chill_person_accompanying_period_origin '
. 'ALTER label DROP DEFAULT');
}
}

View File

@@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* fix deprecated json array
*/
final class Version20210419112619 extends AbstractMigration
{
public function getDescription() : string
{
return 'fix deprecated json_array';
}
public function up(Schema $schema) : void
{
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS NULL');
}
public function down(Schema $schema) : void
{
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_closingmotive.name IS \'(DC2Type:json_array)\'');
}
}

View File

@@ -285,10 +285,7 @@ person_admin:
marital status explanation: >
Configurer la liste des états civils.
# specific to accompanying period
accompanying_period:
dates: Période
dates_from_%opening_date%: Ouvert depuis le %opening_date%
dates_from_%opening_date%_to_%closing_date%: Ouvert du %opening_date% au %closing_date%
occasional: ponctuel
regular: régulier

View File

@@ -10,7 +10,7 @@
'Opening date can not be null': 'La date d''ouverure ne peut être nulle'
'Closing date is not valid': 'La date de fermeture n''est pas valide'
'Closing date can not be null': 'La date de fermeture ne peut être nulle'
The date of closing is before the date of opening: La période de fermeture est avant la période d'ouverture
The date of closing is before the date of opening: La période de fermeture est après la période d'ouverture
The birthdate must be before %date%: La date de naissance doit être avant le %date%
'Invalid phone number: it should begin with the international prefix starting with "+", hold only digits and be smaller than 20 characters. Ex: +33123456789': 'Numéro de téléphone invalide: il doit commencer par le préfixe international précédé de "+", ne comporter que des chiffres et faire moins de 20 caractères. Ex: +31623456789'
'Invalid phone number: it should begin with the international prefix starting with "+", hold only digits and be smaller than 20 characters. Ex: +33623456789': 'Numéro de téléphone invalide: il doit commencer par le préfixe international précédé de "+", ne comporter que des chiffres et faire moins de 20 caractères. Ex: +33623456789'

View File

@@ -89,7 +89,7 @@ class LoadReports extends AbstractFixture implements OrderedFixtureInterface, Co
{
$charline = $this->container->get('doctrine.orm.entity_manager')
->getRepository('ChillPersonBundle:Person')
->findOneBy(array('firstName' => 'Charline', 'lastName' => 'Depardieu'))
->findOneBy(array('lastName' => 'Charline'))
;
$report = (new Report())

Submodule tests/app deleted from 88bd6e9ea0