diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminEvaluationController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminEvaluationController.php new file mode 100644 index 000000000..134cedc74 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminEvaluationController.php @@ -0,0 +1,33 @@ + + * + * 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 . + */ + +namespace Chill\PersonBundle\Controller\SocialWork; + +use Chill\MainBundle\CRUD\Controller\CRUDController; + +/** + * Class AdminSocialIssueController + * Controller for social issues + * + * @package Chill\PersonBundle\Controller + */ +class AdminEvaluationController extends CRUDController +{ +} diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminGoalController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminGoalController.php new file mode 100644 index 000000000..18e1c9f3b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminGoalController.php @@ -0,0 +1,33 @@ + + * + * 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 . + */ + +namespace Chill\PersonBundle\Controller\SocialWork; + +use Chill\MainBundle\CRUD\Controller\CRUDController; + +/** + * Class AdminSocialIssueController + * Controller for social issues + * + * @package Chill\PersonBundle\Controller + */ +class AdminGoalController extends CRUDController +{ +} diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminResultController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminResultController.php new file mode 100644 index 000000000..80d552282 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminResultController.php @@ -0,0 +1,33 @@ + + * + * 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 . + */ + +namespace Chill\PersonBundle\Controller\SocialWork; + +use Chill\MainBundle\CRUD\Controller\CRUDController; + +/** + * Class AdminSocialIssueController + * Controller for social issues + * + * @package Chill\PersonBundle\Controller + */ +class AdminResultController extends CRUDController +{ +} diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminSocialActionController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminSocialActionController.php new file mode 100644 index 000000000..695ec75a1 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminSocialActionController.php @@ -0,0 +1,33 @@ + + * + * 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 . + */ + +namespace Chill\PersonBundle\Controller\SocialWork; + +use Chill\MainBundle\CRUD\Controller\CRUDController; + +/** + * Class AdminSocialIssueController + * Controller for social issues + * + * @package Chill\PersonBundle\Controller + */ +class AdminSocialActionController extends CRUDController +{ +} diff --git a/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminSocialIssueController.php b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminSocialIssueController.php new file mode 100644 index 000000000..35b0df4a2 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/SocialWork/AdminSocialIssueController.php @@ -0,0 +1,33 @@ + + * + * 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 . + */ + +namespace Chill\PersonBundle\Controller\SocialWork; + +use Chill\MainBundle\CRUD\Controller\CRUDController; + +/** + * Class AdminSocialIssueController + * Controller for social issues + * + * @package Chill\PersonBundle\Controller + */ +class AdminSocialIssueController extends CRUDController +{ +} diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index c9ad36319..9cc026909 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -345,6 +345,111 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ] ] ], + [ + 'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class, + 'name' => 'social_issue', + 'base_path' => '/admin/social-work/social-issue', + 'form_class' => \Chill\PersonBundle\Form\SocialWork\SocialIssueType::class, + 'controller' => \Chill\PersonBundle\Controller\SocialWork\AdminSocialIssueController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/SocialIssue/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/edit.html.twig', + ] + ] + ], + [ + 'class' => \Chill\PersonBundle\Entity\SocialWork\SocialAction::class, + 'name' => 'social_action', + 'base_path' => '/admin/social-work/social-action', + 'form_class' => \Chill\PersonBundle\Form\SocialWork\SocialActionType::class, + 'controller' => \Chill\PersonBundle\Controller\SocialWork\AdminSocialActionController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/SocialAction/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/edit.html.twig', + ] + ] + ], + [ + 'class' => \Chill\PersonBundle\Entity\SocialWork\Goal::class, + 'name' => 'social_goal', + 'base_path' => '/admin/social-work/goal', + 'form_class' => \Chill\PersonBundle\Form\SocialWork\GoalType::class, + 'controller' => \Chill\PersonBundle\Controller\SocialWork\AdminGoalController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/Goal/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/edit.html.twig', + ] + ] + ], + [ + 'class' => \Chill\PersonBundle\Entity\SocialWork\Result::class, + 'name' => 'social_result', + 'base_path' => '/admin/social-work/result', + 'form_class' => \Chill\PersonBundle\Form\SocialWork\ResultType::class, + 'controller' => \Chill\PersonBundle\Controller\SocialWork\AdminResultController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/Result/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/edit.html.twig', + ] + ] + ], + [ + 'class' => \Chill\PersonBundle\Entity\SocialWork\Evaluation::class, + 'name' => 'social_evaluation', + 'base_path' => '/admin/social-work/evaluation', + 'form_class' => \Chill\PersonBundle\Form\SocialWork\EvaluationType::class, + 'controller' => \Chill\PersonBundle\Controller\SocialWork\AdminEvaluationController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/Evaluation/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/SocialWork/edit.html.twig', + ] + ] + ], ], 'apis' => [ [ diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php index f59fc567e..edf94bd67 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/Household.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/Household.php @@ -99,6 +99,22 @@ class Household return $this; } + /** + * Force an address starting at the current day + * on the Household. + * + * This will force the startDate's address on today. + * + * Used on household creation. + * + * @Serializer\Groups({"create"}) + */ + public function setForceAddress(Address $address) + { + $address->setValidFrom(new \DateTime('today')); + $this->addAddress($address); + } + /** * @param Address $address */ @@ -128,7 +144,7 @@ class Household $at = $at === null ? new \DateTime('today') : $at; $addrs = $this->getAddresses()->filter(function (Address $a) use ($at) { - return $a->getValidFrom() < $at && ( + return $a->getValidFrom() <= $at && ( NULL === $a->getValidTo() || $at < $a->getValidTo() ); }); diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/EvaluationType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/EvaluationType.php new file mode 100644 index 000000000..b45cd327e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/EvaluationType.php @@ -0,0 +1,71 @@ + + * + * 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 . + */ +namespace Chill\PersonBundle\Form\SocialWork; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\PersonBundle\Entity\SocialWork\Evaluation; + +/** + * Class EvaluationType + * + * @package Chill\PersonBundle\Form + */ +class EvaluationType extends AbstractType +{ + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) { + $this->translatableStringHelper = $translatableStringHelper; + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('title', TranslatableStringFormType::class, [ + 'label' => 'Nom', + ]) + ->add('delay') + + ->add('notificationDelay'); + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', Evaluation::class) + ; + } +} diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php new file mode 100644 index 000000000..c86a7d6b9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php @@ -0,0 +1,85 @@ + + * + * 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 . + */ +namespace Chill\PersonBundle\Form\SocialWork; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\PersonBundle\Entity\SocialWork\Goal; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; + +/** + * Class GoalType + * + * @package Chill\PersonBundle\Form + */ +class GoalType extends AbstractType +{ + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) { + $this->translatableStringHelper = $translatableStringHelper; + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('title', TranslatableStringFormType::class, [ + 'label' => 'Nom' + ]) + + ->add('socialActions', EntityType::class, [ + 'class' => SocialAction::class, + 'required' => false, + 'multiple' => true, + 'choice_label' => function (SocialAction $issue) { + return $this->translatableStringHelper->localize($issue->getTitle()); + } + ]) + + ->add('desactivationDate', DateType::class, [ + 'attr' => array('class' => 'datepicker'), + 'widget'=> 'single_text', + 'format' => 'dd-MM-yyyy', + 'required' => false, + ]); +} + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', Goal::class) + ; + } +} diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/ResultType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/ResultType.php new file mode 100644 index 000000000..ee2cefe48 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/ResultType.php @@ -0,0 +1,76 @@ + + * + * 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 . + */ +namespace Chill\PersonBundle\Form\SocialWork; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\PersonBundle\Entity\SocialWork\Result; + +/** + * Class ResultType + * + * @package Chill\PersonBundle\Form + */ +class ResultType extends AbstractType +{ + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) { + $this->translatableStringHelper = $translatableStringHelper; + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('title', TranslatableStringFormType::class, [ + 'label' => 'Nom' + ]) + ->add('accompanyingPeriodWorks') + ->add('accompanyingPeriodWorkGoals') + ->add('desactivationDate', DateType::class, [ + 'attr' => array('class' => 'datepicker'), + 'widget'=> 'single_text', + 'format' => 'dd-MM-yyyy', + 'required' => false, + ]); +} + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', Result::class) + ; + } +} diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php new file mode 100644 index 000000000..7613bc2c7 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialActionType.php @@ -0,0 +1,90 @@ + + * + * 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 . + */ +namespace Chill\PersonBundle\Form\SocialWork; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; + + +/** + * Class SocialActionType + * + * @package Chill\PersonBundle\Form + */ +class SocialActionType extends AbstractType +{ + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) { + $this->translatableStringHelper = $translatableStringHelper; + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('title', TranslatableStringFormType::class, [ + 'label' => 'Nom' + ]) + ->add('issue', EntityType::class, [ + 'class' => SocialIssue::class, + 'choice_label' => function (SocialIssue $issue) { + return $this->translatableStringHelper->localize($issue->getTitle()); + } + ]) + ->add('parent', EntityType::class, [ + 'class' => SocialAction::class, + 'required' => false, + 'choice_label' => function (SocialAction $issue) { + return $this->translatableStringHelper->localize($issue->getTitle()); + } + ]) + ->add('defaultNotificationDelay') + ->add('desactivationDate', DateType::class, [ + 'attr' => array('class' => 'datepicker'), + 'widget'=> 'single_text', + 'format' => 'dd-MM-yyyy', + 'required' => false, + ]); +} + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', SocialIssue::class) + ; + } +} diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php new file mode 100644 index 000000000..1f21defd9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/SocialIssueType.php @@ -0,0 +1,83 @@ + + * + * 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 . + */ +namespace Chill\PersonBundle\Form\SocialWork; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Symfony\Component\Form\Extension\Core\Type\DateType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; + +/** + * Class SocialIssueType + * + * @package Chill\PersonBundle\Form + */ +class SocialIssueType extends AbstractType +{ + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) { + $this->translatableStringHelper = $translatableStringHelper; + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('title', TranslatableStringFormType::class, [ + 'label' => 'Nom' + ]) + + ->add('parent', EntityType::class, [ + 'class' => SocialIssue::class, + 'required' => false, + 'choice_label' => function (SocialIssue $issue) { + return $this->translatableStringHelper->localize($issue->getTitle()); + } + ]) + + ->add('desactivationDate', DateType::class, [ + 'attr' => ['class' => 'datepicker'], + 'widget'=> 'single_text', + 'format' => 'dd-MM-yyyy', + 'required' => false, + ]); +} + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', SocialIssue::class) + ; + } +} diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php index d99ab590e..6686b55b7 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php @@ -18,11 +18,13 @@ namespace Chill\PersonBundle\Repository; + use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; + final class PersonRepository { private EntityRepository $repository; @@ -113,11 +115,20 @@ final class PersonRepository $qb->setParameter('phonenumber', '%'.$phonenumber.'%'); } + + /** + * @param $phonenumber + * @return string + */ protected function parsePhoneNumber(string $phonenumber): string { return \str_replace(' ', '', $phonenumber); } + /** + * @param QueryBuilder $qb + * @param array $centers + */ protected function addByCenters(QueryBuilder $qb, array $centers): void { if (count($centers) > 0) { diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index b0324ba33..51ced6976 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -1,6 +1,25 @@ , + * + * 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 . + */ namespace Chill\PersonBundle\Repository\SocialWork; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/< b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/< new file mode 100644 index 000000000..f2917b463 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/< @@ -0,0 +1,374 @@ +import { createStore } from 'vuex'; +import { householdMove, fetchHouseholdSuggestionByAccompanyingPeriod, fetchAddressSuggestionByPerson} from './../api.js'; +import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js'; + +const debug = process.env.NODE_ENV !== 'production'; + +const concerned = window.household_members_editor_data.persons.map(p => { + return { + person: p, + position: null, + allowRemove: false, + holder: false, + comment: "", + }; +}); + +console.log('expand suggestions', window.household_members_editor_expand_suggestions === 1); + +const store = createStore({ + strict: debug, + state: { + concerned, + household: window.household_members_editor_data.household, + positions: window.household_members_editor_data.positions.sort((a, b) => { + if (a.ordering < b.ordering) { + return -1; + } + if (a.ordering > b.ordering) { + return 1; + } + return 0; + }), + startDate: new Date(), + allowHouseholdCreate: window.household_members_editor_data.allowHouseholdCreate, + allowHouseholdSearch: window.household_members_editor_data.allowHouseholdSearch, + allowLeaveWithoutHousehold: window.household_members_editor_data.allowLeaveWithoutHousehold, + forceLeaveWithoutHousehold: false, + householdSuggestionByAccompanyingPeriod: [], + showHouseholdSuggestion: window.household_members_editor_expand_suggestions === 1, + addressesSuggestion: [], + warnings: [], + errors: [] + }, + getters: { + isHouseholdNew(state) { + if (state.household === null) { + return false; + } + return !Number.isInteger(state.household.id); + }, + hasHousehold(state) { + return state.household !== null; + }, + hasHouseholdOrLeave(state) { + return state.household !== null || state.forceLeaveWithoutHousehold; + }, + hasHouseholdSuggestion(state, getters) { + return getters.filterHouseholdSuggestionByAccompanyingPeriod.length > 0; + }, + countHouseholdSuggestion(state, getters) { + return getters.filterHouseholdSuggestionByAccompanyingPeriod.length; + }, + filterHouseholdSuggestionByAccompanyingPeriod(state) { + if (state.household === null) { + return state.householdSuggestionByAccompanyingPeriod; + } + + return state.householdSuggestionByAccompanyingPeriod + .filter(h => h.id !== state.household.id) + ; + }, + hasPersonsWellPositionnated(state, getters) { + return getters.needsPositionning === false + || (getters.persons.length > 0 && getters.concUnpositionned.length === 0); + }, + persons(state) { + return state.concerned.map(conc => conc.person); + }, + concUnpositionned(state) { + return state.concerned + .filter(conc => conc.position === null) + ; + }, + positions(state) { + return state.positions; + }, + personByPosition: (state) => (position_id) => { + return state.concerned + .filter(conc => + conc.position !== null ? conc.position.id === position_id : false + ) + .map(conc => conc.person) + ; + }, + concByPosition: (state) => (position_id) => { + return state.concerned + .filter(conc => + conc.position !== null ? conc.position.id === position_id : false + ) + ; + }, + concByPersonId: (state) => (person_id) => { + return state.concerned + .find(conc => conc.person.id === person_id) + ; + }, + needsPositionning(state) { + return state.forceLeaveWithoutHousehold === false; + }, + buildPayload: (state) => { + let + conc, + payload_conc, + payload = { + concerned: [], + destination: null + } + ; + + if (state.forceLeaveWithoutHousehold === false) { + payload.destination = { + id: state.household.id, + type: state.household.type + }; + } + + for (let i in state.concerned) { + conc = state.concerned[i]; + payload_conc = { + person: { + id: conc.person.id, + type: conc.person.type + }, + start_date: { + datetime: datetimeToISO(state.startDate) + } + }; + + if (state.forceLeaveWithoutHousehold === false) { + payload_conc.position = { + id: conc.position.id, + type: conc.position.type + }; + payload_conc.holder = conc.holder; + payload_conc.comment = conc.comment; + } + + payload.concerned.push(payload_conc); + } + + return payload; + }, + }, + mutations: { + addConcerned(state, person) { + let persons = state.concerned.map(conc => conc.person.id); + if (!persons.includes(person.id)) { + state.concerned.push({ + person, + position: null, + allowRemove: true, + holder: false, + comment: "", + }); + } else { + console.err("person already included"); + } + }, + markPosition(state, { person_id, position_id}) { + let + position = state.positions.find(pos => pos.id === position_id), + conc = state.concerned.find(c => c.person.id === person_id); + conc.position = position; + }, + setComment(state, {conc, comment}) { + conc.comment = comment; + }, + toggleHolder(state, conc) { + conc.holder = !conc.holder; + }, + removePosition(state, conc) { + conc.holder = false; + conc.position = null; + }, + removeConcerned(state, conc) { + state.concerned = state.concerned.filter(c => + c.person.id !== conc.person.id + ) + }, + createHousehold(state) { + state.household = { type: 'household', members: [], current_address: null, + current_members_id: [] }; + state.forceLeaveWithoutHousehold = false; + }, + removeHousehold(state) { + state.household = null; + state.forceLeaveWithoutHousehold = false; + }, + setHouseholdAddress(state, address) { + if (null === state.household) { + console.error("no household"); + throw new Error("No household"); + } + + state.household.current_address = address; + state.household.force_new_address = address; + }, + forceLeaveWithoutHousehold(state) { + state.household = null; + state.forceLeaveWithoutHousehold = true; + }, + selectHousehold(state, household) { + state.household = household; + state.forceLeaveWithoutHousehold = false; + }, + setHouseholdSuggestionByAccompanyingPeriod(state, households) { + let existingIds = state.householdSuggestionByAccompanyingPeriod + .map(h => h.id); + for (let i in households) { + if (!existingIds.includes(households[i].id)) { + state.householdSuggestionByAccompanyingPeriod.push(households[i]); + } + } + }, + setStartDate(state, dateI) { + state.startDate = dateI; + }, + toggleHouseholdSuggestion(state) { + state.showHouseholdSuggestion = !state.showHouseholdSuggestion; + }, + setWarnings(state, warnings) { + state.warnings = warnings; + // reset errors, which should come from servers + state.errors.splice(0, state.errors.length); + }, + setErrors(state, errors) { + state.errors = errors; + }, + addAddressesSuggestion(state, addresses) { + let existingIds = state.addressesSuggestion + .map(a => a.id); + + for (let i in addresses) { + if (!existingIds.includes(addresses[i].id)) { + state.addressesSuggestion.push(addresses[i]); + } + } + } + }, + actions: { + addConcerned({ commit, dispatch }, person) { + commit('addConcerned', person); + dispatch('computeWarnings'); + dispatch('fetchAddressSuggestions'); + }, + markPosition({ commit, state, dispatch }, { person_id, position_id }) { + commit('markPosition', { person_id, position_id }); + dispatch('computeWarnings'); + }, + toggleHolder({ commit, dispatch }, conc) { + commit('toggleHolder', conc); + dispatch('computeWarnings'); + }, + removePosition({ commit, dispatch }, conc) { + commit('removePosition', conc); + dispatch('computeWarnings'); + }, + removeConcerned({ commit, dispatch }, conc) { + commit('removeConcerned', conc); + dispatch('computeWarnings'); + dispatch('fetchAddressSuggestions'); + }, + removeHousehold({ commit, dispatch }) { + commit('removeHousehold'); + dispatch('computeWarnings'); + }, + createHousehold({ commit, dispatch }) { + commit('createHousehold'); + dispatch('computeWarnings'); + }, + forceLeaveWithoutHousehold({ commit, dispatch }) { + commit('forceLeaveWithoutHousehold'); + dispatch('computeWarnings'); + }, + selectHousehold({ commit }, h) { + commit('selectHousehold', h); + dispatch('computeWarnings'); + }, + setStartDate({ commit, dispatch }, date) { + commit('setStartDate', date); + dispatch('computeWarnings'); + }, + setComment({ commit }, payload) { + commit('setComment', payload); + }, + fetchHouseholdSuggestionForConcerned({ commit, state }, person) { + fetchHouseholdSuggestionByAccompanyingPeriod(person.id) + .then(households => { + commit('setHouseholdSuggestionByAccompanyingPeriod', households); + }); + }, + fetchAddressSuggestions({ commit, state }) { + for (let i in state.concerned) { + fetchAddressSuggestionByPerson(state.concerned[i].person.id) + .then(addresses => { + commit('addAddressesSuggestion', addresses); + }) + .catch(e => { + console.log(e); + }); + } + }, + computeWarnings({ commit, state, getters }) { + let warnings = [], + payload; + + if (!getters.hasHousehold && !state.forceLeaveWithoutHousehold) { + warnings.push({ m: 'household_members_editor.add_destination', a: {} }); + } + + if (state.concerned.length === 0) { + warnings.push({ m: 'household_members_editor.add_at_least_onePerson', a: {} }); + } + + if (getters.concUnpositionned.length > 0 + && !state.forceLeaveWithoutHousehold) { + warnings.push({ m: 'household_members_editor.give_a_position_to_every_person', a: {} }) + } + + commit('setWarnings', warnings); + }, + confirm({ getters, state, commit }) { + let payload = getters.buildPayload, + errors = [], + person_id, + household_id, + error + ; + + householdMove(payload).then(household => { + if (household === null) { + person_id = getters.persons[0].id; + window.location.replace(`/fr/person/${person_id}/general`); + } else { + if (household.type === 'household') { + household_id = household.id; + // nothing to do anymore here, bye-bye ! + window.location.replace(`/fr/person/household/${household_id}/summary`); + } else { + // we assume the answer was 422... + error = household; + for (let i in error.violations) { + let e = error.violations[i]; + errors.push(e.title); + } + + commit('setErrors', errors); + } + } + }); + }, + } +}); + +store.dispatch('computeWarnings'); +store.dispatch('fetchAddressSuggestions'); + +if (concerned.length > 0) { + concerned.forEach(c => { + store.dispatch('fetchHouseholdSuggestionForConcerned', c.person); + }); +} + +export { store }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/api.js index e54bd9b15..7a91ec912 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/api.js @@ -37,7 +37,20 @@ const fetchHouseholdSuggestionByAccompanyingPeriod = (personId) => { ; }; +const fetchAddressSuggestionByPerson = (personId) => { + const url = `/api/1.0/person/address/suggest/by-person/${personId}.json`; + return window.fetch(url) + .then(response => { + if (response.ok) { + return response.json(); + } + + throw Error({m: 'Error while fetch address suggestion', status: response.status}); + }); +} + export { householdMove, fetchHouseholdSuggestionByAccompanyingPeriod, + fetchAddressSuggestionByPerson, }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue index 4c4929581..fa3dd64b6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue @@ -5,6 +5,38 @@ + + + À quelle adresse habite ce ménage ? + + + + + + Le ménage habite cette adresse + + + + + + + + Créer une adresse + + + + + + + + + + Supprimer cette adresse + + + + + {{ $t('household_members_editor.household.will_leave_any_household') }} @@ -23,7 +55,7 @@ countHouseholdSuggestion) }} - + {{ $t('household_members_editor.household.leave_without_household') }} + + + {{ $t('household_members_editor.household.change') }} + + - + {{ $t('household_members_editor.household_for_participants_accompanying_period') }}: h.id !== state.household.id) ; }, + filterAddressesSuggestion(state) { + if (state.household === null) { + return state.addressesSuggestion; + } + + if (state.household.current_address === null) { + return state.addressesSuggestion; + } + + return state.addressesSuggestion + .filter(a => a.address_id !== state.household.current_address.address_id); + }, hasPersonsWellPositionnated(state, getters) { return getters.needsPositionning === false || (getters.persons.length > 0 && getters.concUnpositionned.length === 0); @@ -106,7 +125,7 @@ const store = createStore({ needsPositionning(state) { return state.forceLeaveWithoutHousehold === false; }, - buildPayload: (state) => { + buildPayload: (state, getters) => { let conc, payload_conc, @@ -119,8 +138,13 @@ const store = createStore({ if (state.forceLeaveWithoutHousehold === false) { payload.destination = { id: state.household.id, - type: state.household.type + type: state.household.type, }; + + if (getters.isHouseholdNew && state.household.current_address !== null) { + console.log(state.household); + payload.destination.forceAddress = { id: state.household.current_address.address_id }; + } } for (let i in state.concerned) { @@ -187,9 +211,29 @@ const store = createStore({ ) }, createHousehold(state) { - state.household = { type: 'household', members: [], current_address: null } + state.household = { type: 'household', members: [], current_address: null, current_members_id: [] } state.forceLeaveWithoutHousehold = false; }, + removeHousehold(state) { + state.household = null; + state.forceLeaveWithoutHousehold = false; + }, + setHouseholdAddress(state, address) { + if (null === state.household) { + console.error("no household"); + throw new Error("No household"); + } + + state.household.current_address = address; + }, + removeHouseholdAddress(state, address) { + if (null === state.household) { + console.error("no household"); + throw new Error("No household"); + } + + state.household.current_address = null; + }, forceLeaveWithoutHousehold(state) { state.household = null; state.forceLeaveWithoutHousehold = true; @@ -221,11 +265,22 @@ const store = createStore({ setErrors(state, errors) { state.errors = errors; }, + addAddressesSuggestion(state, addresses) { + let existingIds = state.addressesSuggestion + .map(a => a.address_id); + + for (let i in addresses) { + if (!existingIds.includes(addresses[i].address_id)) { + state.addressesSuggestion.push(addresses[i]); + } + } + } }, actions: { addConcerned({ commit, dispatch }, person) { commit('addConcerned', person); dispatch('computeWarnings'); + dispatch('fetchAddressSuggestions'); }, markPosition({ commit, state, dispatch }, { person_id, position_id }) { commit('markPosition', { person_id, position_id }); @@ -242,6 +297,11 @@ const store = createStore({ removeConcerned({ commit, dispatch }, conc) { commit('removeConcerned', conc); dispatch('computeWarnings'); + dispatch('fetchAddressSuggestions'); + }, + removeHousehold({ commit, dispatch }) { + commit('removeHousehold'); + dispatch('computeWarnings'); }, createHousehold({ commit, dispatch }) { commit('createHousehold'); @@ -268,6 +328,17 @@ const store = createStore({ commit('setHouseholdSuggestionByAccompanyingPeriod', households); }); }, + fetchAddressSuggestions({ commit, state }) { + for (let i in state.concerned) { + fetchAddressSuggestionByPerson(state.concerned[i].person.id) + .then(addresses => { + commit('addAddressesSuggestion', addresses); + }) + .catch(e => { + console.log(e); + }); + } + }, computeWarnings({ commit, state, getters }) { let warnings = [], payload; @@ -321,6 +392,7 @@ const store = createStore({ }); store.dispatch('computeWarnings'); +store.dispatch('fetchAddressSuggestions'); if (concerned.length > 0) { concerned.forEach(c => { diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig new file mode 100644 index 000000000..301a3a9cf --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_warning_address.html.twig @@ -0,0 +1,7 @@ + + + + {{ 'This course is located at a temporarily address. You should locate this course to an user'|trans }} + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig index ea2fcd710..1910b7497 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig @@ -45,8 +45,13 @@ {% endif %} {% endfor %} - {% if withoutHousehold|length > 0 %} - {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %} + {% if 'DRAFT' != accompanyingCourse.step %} + {% if withoutHousehold|length > 0 %} + {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %} + {% endif %} + {% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %} + {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' with {} %} + {% endif %} {% endif %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Evaluation/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Evaluation/index.html.twig new file mode 100644 index 000000000..186b2f3ec --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Evaluation/index.html.twig @@ -0,0 +1,27 @@ +{% extends '@ChillPerson/Admin/layout.html.twig' %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Id'|trans }} + {{ 'Title'|trans }} + + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.title|localize_translatable_string }} + + + + + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig new file mode 100644 index 000000000..aa7c239ba --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Goal/index.html.twig @@ -0,0 +1,27 @@ +{% extends '@ChillPerson/Admin/layout.html.twig' %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Id'|trans }} + {{ 'Title'|trans }} + + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.title|localize_translatable_string }} + + + + + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Result/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Result/index.html.twig new file mode 100644 index 000000000..f1081aebe --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/Result/index.html.twig @@ -0,0 +1,27 @@ +{% extends '@ChillPerson/Admin/layout.html.twig' %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Id'|trans }} + {{ 'Title'|trans }} + + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.title|localize_translatable_string }} + + + + + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig new file mode 100644 index 000000000..4c1d5a59d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialAction/index.html.twig @@ -0,0 +1,27 @@ +{% extends '@ChillPerson/Admin/layout.html.twig' %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Id'|trans }} + {{ 'Title'|trans }} + + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.title|localize_translatable_string }} + + + + + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig new file mode 100644 index 000000000..44627852e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/SocialIssue/index.html.twig @@ -0,0 +1,27 @@ +{% extends '@ChillPerson/Admin/layout.html.twig' %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Id'|trans }} + {{ 'Title'|trans }} + + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.title|localize_translatable_string }} + + + + + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/edit.html.twig new file mode 100644 index 000000000..0ae8754fe --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/edit.html.twig @@ -0,0 +1,12 @@ +{% extends '@ChillPerson/Admin/layout.html.twig' %} + +{% block title %} +{% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} +{% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/new.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/new.html.twig new file mode 100644 index 000000000..cc6021021 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/SocialWork/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillPerson/Admin/layout.html.twig' %} + +{% block title %} +{% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} +{% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} +{% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php index 57745e276..b2c21c048 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/MembersEditorNormalizer.php @@ -77,8 +77,11 @@ class MembersEditorNormalizer implements DenormalizerInterface, DenormalizerAwar protected function denormalizeMove($data, string $type, string $format, array $context = []) { + $householdContext = $context; + $householdContext['groups'][] = 'create'; + $household = $this->denormalizer->denormalize($data['destination'], Household::class, - $format, $context); + $format, $householdContext); if (NULL === $household) { throw new Exception\InvalidArgumentException("household could not be denormalized. Impossible to process"); diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml index 0684a352c..ad4f6109c 100644 --- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml @@ -1169,14 +1169,32 @@ paths: id: 0 type: person position: - type: position + type: household_position id: 1 start_date: - datetime: 2021-06-01T00:00:00+02:00 + datetime: "2021-06-01T00:00:00+02:00" comment: "This is my comment for moving" holder: false destination: type: household + Moving person to a new household and set an address to this household: + value: + concerned: + - + person: + id: 0 + type: person + position: + type: household_position + id: 1 + start_date: + datetime: "2021-06-01T00:00:00+02:00" + comment: "This is my comment for moving" + holder: false + destination: + type: household + forceAddress: + id: 0 Moving person to an existing household: value: concerned: @@ -1185,7 +1203,7 @@ paths: id: 0 type: person position: - type: position + type: household_position id: 1 start_date: datetime: 2021-06-01T00:00:00+02:00 diff --git a/src/Bundle/ChillPersonBundle/config/routes.yaml b/src/Bundle/ChillPersonBundle/config/routes.yaml index cd0de3ea3..bbcb7c39b 100644 --- a/src/Bundle/ChillPersonBundle/config/routes.yaml +++ b/src/Bundle/ChillPersonBundle/config/routes.yaml @@ -136,6 +136,54 @@ chill_person_maritalstatus_admin: order: 120 label: 'person_admin.marital status' +chill_person_socialissue_admin: + path: /{_locale}/admin/social-work/social-issue + controller: cscrud_social_issue_controller:index + options: + menus: + admin_person: + order: 150 + label: 'person_admin.social_issue' + +chill_person_socialaction_admin: + path: /{_locale}/admin/social-work/social-action + controller: cscrud_social_action_controller:index + options: + menus: + admin_person: + order: 160 + label: 'person_admin.social_action' + + +chill_person_social_evaluation_admin: + path: /{_locale}/admin/social-work/evaluation + controller: cscrud_social_evaluation_controller:index + options: + menus: + admin_person: + order: 170 + label: 'person_admin.social_evaluation' + +chill_person_social_goal_admin: + path: /{_locale}/admin/social-work/goal + controller: cscrud_social_goal_controller:index + options: + menus: + admin_person: + order: 180 + label: 'person_admin.social_goal' + +chill_person_social_result_admin: + path: /{_locale}/admin/social-work/result + controller: cscrud_social_result_controller:index + options: + menus: + admin_person: + order: 190 + label: 'person_admin.social_result' + + + chill_person_controllers: resource: "@ChillPersonBundle/Controller" type: annotation diff --git a/src/Bundle/ChillPersonBundle/config/services/form.yaml b/src/Bundle/ChillPersonBundle/config/services/form.yaml index aa6f36b28..b61de615d 100644 --- a/src/Bundle/ChillPersonBundle/config/services/form.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/form.yaml @@ -32,7 +32,7 @@ services: chill.person.form.type.pick_person: class: Chill\PersonBundle\Form\Type\PickPersonType arguments: - - "@chill.person.repository.person" + - '@Chill\PersonBundle\Repository\PersonRepository' - "@security.token_storage" - "@chill.main.security.authorization.helper" - '@Symfony\Component\Routing\Generator\UrlGeneratorInterface' @@ -53,3 +53,35 @@ services: $em: '@Doctrine\ORM\EntityManagerInterface' tags: - { name: form.type } + + Chill\PersonBundle\Form\SocialWork\SocialIssueType: + arguments: + $translatableStringHelper: '@chill.main.helper.translatable_string' + tags: + - { name: form.type } + + Chill\PersonBundle\Form\SocialWork\SocialActionType: + arguments: + $translatableStringHelper: '@chill.main.helper.translatable_string' + tags: + - { name: form.type } + + Chill\PersonBundle\Form\SocialWork\EvaluationType: + arguments: + $translatableStringHelper: '@chill.main.helper.translatable_string' + tags: + - { name: form.type } + + + Chill\PersonBundle\Form\SocialWork\GoalType: + arguments: + $translatableStringHelper: '@chill.main.helper.translatable_string' + tags: + - { name: form.type } + + + Chill\PersonBundle\Form\SocialWork\ResultType: + arguments: + $translatableStringHelper: '@chill.main.helper.translatable_string' + tags: + - { name: form.type } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index d8cd87626..4cf171f2b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -307,6 +307,31 @@ crud: add_new: Ajouter un nouveau title_new: Nouvel état civil title_edit: Modifier l'état civil + social_issue: + index: + title: Liste des problématiques sociales + add_new: Ajouter une nouvelle problématique sociale + title_new: Nouvelle problématique sociale + title_edit: Modifier la problématique sociale + social_action: + index: + title: Liste des actions d'accompagnements + add_new: Ajouter une nouvelle action d'accompagnements + title_new: Nouvelle action d'accompagnements + title_edit: Modifier l'action d'accompagnements + social_goal: + index: + title: Liste des objectifs d'action d'accompagnements + add_new: Ajouter un nouvel objectif d'action d'accompagnements + title_new: Nouvel objectif + title_edit: Modifier l'objectif + social_result: + index: + title: Liste des résultats d'action d'accompagnements + add_new: Ajouter un nouveau résultat d'action d'accompagnements + title_new: Nouveau résultat + title_edit: Modifier le résultat + # specific to closing motive closing_motive: @@ -325,6 +350,11 @@ person_admin: marital status list: Liste des états civils marital status explanation: > Configurer la liste des états civils. + social_issue: Problématiques sociales + social_action: Actions d'accompagnement + social_goal: Buts + social_result: Résultats + social_evaluation: Évaluations # specific to accompanying period accompanying_period:
{{ $t('household_members_editor.household_for_participants_accompanying_period') }}: