mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-11 09:14:59 +00:00
Compare commits
15 Commits
167-build-
...
2.15.1
Author | SHA1 | Date | |
---|---|---|---|
60ede58af0 | |||
afb79141f0 | |||
4d72933edb | |||
0da12cdc2e | |||
d1ce99e6d3 | |||
|
0ad27328c9 | ||
91e6b035bd
|
|||
2adb6105eb | |||
33d187f329 | |||
f02873c6e0
|
|||
8cc93a8b07
|
|||
f7184ca7bb
|
|||
f0605c6b08
|
|||
54606403b4
|
|||
47d829d72d
|
@@ -1,5 +0,0 @@
|
|||||||
kind: Feature
|
|
||||||
body: Add export "number of household associate with an exchange"
|
|
||||||
time: 2023-12-04T16:29:23.341485328+01:00
|
|
||||||
custom:
|
|
||||||
Issue: "191"
|
|
@@ -1,5 +0,0 @@
|
|||||||
kind: Feature
|
|
||||||
body: 'Export: add dates on the filter "filter course by activity type"'
|
|
||||||
time: 2023-12-04T18:11:56.906524311+01:00
|
|
||||||
custom:
|
|
||||||
Issue: "235"
|
|
@@ -1,5 +0,0 @@
|
|||||||
kind: Fixed
|
|
||||||
body: Fix error when posting an empty comment on an accompanying period.
|
|
||||||
time: 2023-11-29T11:34:58.986983057+01:00
|
|
||||||
custom:
|
|
||||||
Issue: "214"
|
|
@@ -1,5 +0,0 @@
|
|||||||
kind: Fixed
|
|
||||||
body: Fix "filter evaluation by evaluation type" (and add select2 to the list of evaluation types to pick)
|
|
||||||
time: 2023-12-01T09:45:10.744382859+01:00
|
|
||||||
custom:
|
|
||||||
Issue: "233"
|
|
@@ -1,6 +0,0 @@
|
|||||||
kind: Fixed
|
|
||||||
body: |
|
|
||||||
Fix "filter aside activity by date"
|
|
||||||
time: 2023-12-04T17:17:16.553597209+01:00
|
|
||||||
custom:
|
|
||||||
Issue: "234"
|
|
11
.changes/v2.15.0.md
Normal file
11
.changes/v2.15.0.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
## v2.15.0 - 2023-12-11
|
||||||
|
### Feature
|
||||||
|
* ([#191](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/191)) Add export "number of household associate with an exchange"
|
||||||
|
* ([#235](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/235)) Export: add dates on the filter "filter course by activity type"
|
||||||
|
### Fixed
|
||||||
|
* ([#214](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/214)) Fix error when posting an empty comment on an accompanying period.
|
||||||
|
* ([#233](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/233)) Fix "filter evaluation by evaluation type" (and add select2 to the list of evaluation types to pick)
|
||||||
|
* ([#234](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/234)) Fix "filter aside activity by date"
|
||||||
|
|
||||||
|
* ([#228](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/228)) Fix export of activity for people created before the introduction of the createdAt column on person (during v1)
|
||||||
|
* ([#246](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/246)) Do not show activities, evaluations and social work when associated to a confidential accompanying period, except for the users which are allowed to see them
|
5
.changes/v2.15.1.md
Normal file
5
.changes/v2.15.1.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
## v2.15.1 - 2023-12-20
|
||||||
|
### Fixed
|
||||||
|
* Fix the household export query to exclude accompanying periods that are in draft state.
|
||||||
|
### DX
|
||||||
|
* ([#167](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/167)) Fixed readthedocs compilation by updating readthedocs config file and requirements for Sphinx
|
@@ -1,10 +1,14 @@
|
|||||||
---
|
---
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
|
build:
|
||||||
|
os: ubuntu-22.04
|
||||||
|
tools:
|
||||||
|
python: "3.7"
|
||||||
|
|
||||||
sphinx:
|
sphinx:
|
||||||
configuration: docs/source/conf.py
|
configuration: docs/source/conf.py
|
||||||
|
|
||||||
python:
|
python:
|
||||||
version: 3.7
|
|
||||||
install:
|
install:
|
||||||
- requirements: docs/requirements.txt
|
- requirements: docs/requirements.txt
|
24
CHANGELOG.md
24
CHANGELOG.md
@@ -6,6 +6,30 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
|||||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||||
|
|
||||||
|
|
||||||
|
## v2.15.1 - 2023-12-20
|
||||||
|
### Fixed
|
||||||
|
* Fix the household export query to exclude accompanying periods that are in draft state.
|
||||||
|
### DX
|
||||||
|
* ([#167](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/167)) Fixed readthedocs compilation by updating readthedocs config file and requirements for Sphinx
|
||||||
|
|
||||||
|
## v2.15.0 - 2023-12-11
|
||||||
|
### Feature
|
||||||
|
* ([#191](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/191)) Add export "number of household associate with an exchange"
|
||||||
|
* ([#235](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/235)) Export: add dates on the filter "filter course by activity type"
|
||||||
|
### Fixed
|
||||||
|
* ([#214](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/214)) Fix error when posting an empty comment on an accompanying period.
|
||||||
|
* ([#233](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/233)) Fix "filter evaluation by evaluation type" (and add select2 to the list of evaluation types to pick)
|
||||||
|
* ([#234](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/234)) Fix "filter aside activity by date"
|
||||||
|
|
||||||
|
* ([#228](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/228)) Fix export of activity for people created before the introduction of the createdAt column on person (during v1)
|
||||||
|
* ([#246](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/246)) Do not show activities, evaluations and social work when associated to a confidential accompanying period, except for the users which are allowed to see them
|
||||||
|
|
||||||
|
## v2.14.1 - 2023-11-29
|
||||||
|
### Fixed
|
||||||
|
* Export: fix list person with custom fields
|
||||||
|
* ([#100](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/100)) Add a paginator to budget elements (resource and charge types) in the admin
|
||||||
|
* Fix error in ListEvaluation when "handling agents" are alone
|
||||||
|
|
||||||
## v2.14.0 - 2023-11-24
|
## v2.14.0 - 2023-11-24
|
||||||
### Feature
|
### Feature
|
||||||
* ([#161](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/161)) Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order
|
* ([#161](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/161)) Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order
|
||||||
|
@@ -27,7 +27,7 @@ To compile this documentation :
|
|||||||
Contribute
|
Contribute
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Issue tracker : https://git.framasoft.org/groups/Chill-project/issues
|
Issue tracker : https://gitlab.com/Chill-Projet/chill-bundles/-/issues
|
||||||
|
|
||||||
Licence
|
Licence
|
||||||
=======
|
=======
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
docutils==0.13.1
|
docutils==0.13.1
|
||||||
Pygments==2.2.0
|
Pygments==2.2.0
|
||||||
sphinx==1.8.5
|
sphinx==1.8.5
|
||||||
|
Jinja2<3.1
|
||||||
git+https://github.com/fabpot/sphinx-php.git@v2.0.2#egg_name=sphinx-php
|
git+https://github.com/fabpot/sphinx-php.git@v2.0.2#egg_name=sphinx-php
|
||||||
jsx-lexer===0.0.8
|
jsx-lexer===0.0.8
|
||||||
sphinx_rtd_theme==0.5.0
|
sphinx_rtd_theme==0.5.0
|
||||||
|
@@ -49,7 +49,7 @@ Clone or download the chill-skeleton project and `cd` into the main directory.
|
|||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
git clone https://gitlab.com/Chill-Projet/chill-skeleton-basic.git
|
git clone https://gitlab.com/Chill-Projet/chill-skeleton-basic.git
|
||||||
cd chill-app
|
cd chill-skeleton-basic
|
||||||
|
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
@@ -20,23 +20,18 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
|
|||||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||||
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
|
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
|
||||||
use Chill\MainBundle\Export\ListInterface;
|
use Chill\MainBundle\Export\ListInterface;
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class ListActivity implements ListInterface, GroupedExportInterface
|
final readonly class ListActivity implements ListInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
private readonly bool $filterStatsByCenters;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly ListActivityHelper $helper,
|
private ListActivityHelper $helper,
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
|
private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
|
||||||
ParameterBagInterface $parameterBag,
|
private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
|
||||||
) {
|
) {}
|
||||||
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
@@ -119,19 +114,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
->leftJoin('acppart.person', 'person')
|
->leftJoin('acppart.person', 'person')
|
||||||
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL');
|
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL');
|
||||||
|
|
||||||
if ($this->filterStatsByCenters) {
|
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
|
||||||
$qb
|
|
||||||
->andWhere(
|
|
||||||
$qb->expr()->exists(
|
|
||||||
'SELECT 1
|
|
||||||
FROM '.PersonCenterHistory::class.' acl_count_person_history
|
|
||||||
WHERE acl_count_person_history.person = person
|
|
||||||
AND acl_count_person_history.center IN (:authorized_centers)
|
|
||||||
'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setParameter('authorized_centers', $centers);
|
|
||||||
}
|
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
// some grouping are necessary
|
// some grouping are necessary
|
||||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Export\GroupedExportInterface;
|
|||||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
@@ -121,7 +122,9 @@ class CountHouseholdInPeriod implements ExportInterface, GroupedExportInterface
|
|||||||
->join('acppart.accompanyingPeriod', 'acp')
|
->join('acppart.accompanyingPeriod', 'acp')
|
||||||
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
|
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
|
||||||
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
|
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
|
||||||
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
|
->andWhere('acp.step != :count_acp_step')
|
||||||
|
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']))
|
||||||
|
->setParameter('count_acp_step', AccompanyingPeriod::STEP_DRAFT);
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->select('COUNT(DISTINCT household.id) AS household_export_result')
|
->select('COUNT(DISTINCT household.id) AS household_export_result')
|
||||||
|
@@ -19,28 +19,22 @@ use Chill\MainBundle\Form\Type\PickRollingDateType;
|
|||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Doctrine\ORM\AbstractQuery;
|
use Doctrine\ORM\AbstractQuery;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
private bool $filterStatsByCenters;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private RollingDateConverterInterface $rollingDateConverter,
|
private RollingDateConverterInterface $rollingDateConverter,
|
||||||
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
|
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
|
||||||
ParameterBagInterface $parameterBag,
|
private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
|
||||||
) {
|
) {}
|
||||||
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
@@ -101,8 +95,6 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
|
||||||
|
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
@@ -110,18 +102,7 @@ final readonly class ListAccompanyingPeriod implements ListInterface, GroupedExp
|
|||||||
->andWhere('acp.step != :list_acp_step')
|
->andWhere('acp.step != :list_acp_step')
|
||||||
->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT);
|
->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT);
|
||||||
|
|
||||||
if ($this->filterStatsByCenters) {
|
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
|
||||||
$qb
|
|
||||||
->andWhere(
|
|
||||||
$qb->expr()->exists(
|
|
||||||
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
|
|
||||||
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
|
||||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
|
||||||
'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setParameter('authorized_centers', $centers);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
|
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
|
||||||
|
|
||||||
|
@@ -28,11 +28,11 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
@@ -44,10 +44,9 @@ use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
|||||||
use Doctrine\ORM\AbstractQuery;
|
use Doctrine\ORM\AbstractQuery;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
private const FIELDS = [
|
private const FIELDS = [
|
||||||
'id',
|
'id',
|
||||||
@@ -79,8 +78,6 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
|
|||||||
'updatedBy',
|
'updatedBy',
|
||||||
];
|
];
|
||||||
|
|
||||||
private readonly bool $filterStatsByCenters;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
private readonly DateTimeHelper $dateTimeHelper,
|
private readonly DateTimeHelper $dateTimeHelper,
|
||||||
@@ -94,10 +91,8 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
|
|||||||
private readonly RollingDateConverterInterface $rollingDateConverter,
|
private readonly RollingDateConverterInterface $rollingDateConverter,
|
||||||
private readonly AggregateStringHelper $aggregateStringHelper,
|
private readonly AggregateStringHelper $aggregateStringHelper,
|
||||||
private readonly SocialActionRepository $socialActionRepository,
|
private readonly SocialActionRepository $socialActionRepository,
|
||||||
ParameterBagInterface $parameterBag,
|
private readonly FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
|
||||||
) {
|
) {}
|
||||||
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
@@ -223,17 +218,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
|
|||||||
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
|
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
|
||||||
->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate));
|
->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate));
|
||||||
|
|
||||||
if ($this->filterStatsByCenters) {
|
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
|
||||||
$qb
|
|
||||||
->andWhere(
|
|
||||||
$qb->expr()->exists(
|
|
||||||
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
|
|
||||||
AND acl_count_person_history.center IN (:authorized_centers)
|
|
||||||
'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setParameter('authorized_centers', $centers);
|
|
||||||
}
|
|
||||||
|
|
||||||
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
||||||
|
|
||||||
|
@@ -28,11 +28,11 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
use Chill\PersonBundle\Entity\SocialWork\Goal;
|
||||||
use Chill\PersonBundle\Entity\SocialWork\Result;
|
use Chill\PersonBundle\Entity\SocialWork\Result;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
@@ -44,10 +44,9 @@ use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
|||||||
use Doctrine\ORM\AbstractQuery;
|
use Doctrine\ORM\AbstractQuery;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface, GroupedExportInterface
|
final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
private const FIELDS = [
|
private const FIELDS = [
|
||||||
'id',
|
'id',
|
||||||
@@ -79,8 +78,6 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
|
|||||||
'updatedBy',
|
'updatedBy',
|
||||||
];
|
];
|
||||||
|
|
||||||
private readonly bool $filterStatsByCenters;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
private readonly DateTimeHelper $dateTimeHelper,
|
private readonly DateTimeHelper $dateTimeHelper,
|
||||||
@@ -94,10 +91,8 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
|
|||||||
private readonly RollingDateConverterInterface $rollingDateConverter,
|
private readonly RollingDateConverterInterface $rollingDateConverter,
|
||||||
private readonly AggregateStringHelper $aggregateStringHelper,
|
private readonly AggregateStringHelper $aggregateStringHelper,
|
||||||
private readonly SocialActionRepository $socialActionRepository,
|
private readonly SocialActionRepository $socialActionRepository,
|
||||||
ParameterBagInterface $parameterBag,
|
private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
|
||||||
) {
|
) {}
|
||||||
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
@@ -218,17 +213,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
|
|||||||
->join('acpw.persons', 'person')
|
->join('acpw.persons', 'person')
|
||||||
;
|
;
|
||||||
|
|
||||||
if ($this->filterStatsByCenters) {
|
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
|
||||||
$qb
|
|
||||||
->andWhere(
|
|
||||||
$qb->expr()->exists(
|
|
||||||
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
|
|
||||||
AND acl_count_person_history.center IN (:authorized_centers)
|
|
||||||
'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setParameter('authorized_centers', $centers);
|
|
||||||
}
|
|
||||||
|
|
||||||
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
||||||
|
|
||||||
|
@@ -26,8 +26,8 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
@@ -37,10 +37,9 @@ use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
|||||||
use Doctrine\ORM\AbstractQuery;
|
use Doctrine\ORM\AbstractQuery;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class ListEvaluation implements ListInterface, GroupedExportInterface
|
final readonly class ListEvaluation implements ListInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
private const FIELDS = [
|
private const FIELDS = [
|
||||||
'id',
|
'id',
|
||||||
@@ -69,8 +68,6 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
|
|||||||
'updatedBy',
|
'updatedBy',
|
||||||
];
|
];
|
||||||
|
|
||||||
private readonly bool $filterStatsByCenters;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
private readonly SocialIssueRender $socialIssueRender,
|
private readonly SocialIssueRender $socialIssueRender,
|
||||||
@@ -83,10 +80,8 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
|
|||||||
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
|
private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
|
||||||
private readonly AggregateStringHelper $aggregateStringHelper,
|
private readonly AggregateStringHelper $aggregateStringHelper,
|
||||||
private readonly RollingDateConverterInterface $rollingDateConverter,
|
private readonly RollingDateConverterInterface $rollingDateConverter,
|
||||||
ParameterBagInterface $parameterBag,
|
private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
|
||||||
) {
|
) {}
|
||||||
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
@@ -211,17 +206,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
|
|||||||
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
|
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
|
||||||
->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate));
|
->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate));
|
||||||
|
|
||||||
if ($this->filterStatsByCenters) {
|
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
|
||||||
$qb
|
|
||||||
->andWhere(
|
|
||||||
$qb->expr()->exists(
|
|
||||||
'SELECT 1 FROM '.PersonCenterHistory::class.' acl_count_person_history WHERE acl_count_person_history.person = person
|
|
||||||
AND acl_count_person_history.center IN (:authorized_centers)
|
|
||||||
'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
->setParameter('authorized_centers', $centers);
|
|
||||||
}
|
|
||||||
|
|
||||||
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ use Chill\MainBundle\Export\ListInterface;
|
|||||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdComposition;
|
use Chill\PersonBundle\Entity\Household\HouseholdComposition;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
@@ -144,7 +145,9 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
|
|||||||
->join('acppart.accompanyingPeriod', 'acp')
|
->join('acppart.accompanyingPeriod', 'acp')
|
||||||
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
|
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
|
||||||
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
|
->andWhere('hmember.startDate <= :count_household_at_date AND (hmember.endDate IS NULL OR hmember.endDate > :count_household_at_date)')
|
||||||
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']));
|
->andWhere('acp.step != :list_acp_step')
|
||||||
|
->setParameter('count_household_at_date', $this->rollingDateConverter->convert($data['calc_date']))
|
||||||
|
->setParameter('list_acp_step', AccompanyingPeriod::STEP_DRAFT);
|
||||||
|
|
||||||
if ($this->filterStatsByCenters) {
|
if ($this->filterStatsByCenters) {
|
||||||
$qb
|
$qb
|
||||||
|
@@ -20,15 +20,14 @@ use Chill\MainBundle\Service\RollingDate\RollingDate;
|
|||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
||||||
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
|
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Doctrine\ORM\AbstractQuery;
|
use Doctrine\ORM\AbstractQuery;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,17 +35,13 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
*/
|
*/
|
||||||
final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface
|
final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
private bool $filterStatsByCenters;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private ListPersonHelper $listPersonHelper,
|
private ListPersonHelper $listPersonHelper,
|
||||||
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
|
private ListAccompanyingPeriodHelper $listAccompanyingPeriodHelper,
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private RollingDateConverterInterface $rollingDateConverter,
|
private RollingDateConverterInterface $rollingDateConverter,
|
||||||
ParameterBagInterface $parameterBag,
|
private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
|
||||||
) {
|
) {}
|
||||||
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
@@ -122,14 +117,7 @@ final readonly class ListPersonWithAccompanyingPeriodDetails implements ListInte
|
|||||||
->join('acppart.accompanyingPeriod', 'acp')
|
->join('acppart.accompanyingPeriod', 'acp')
|
||||||
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"));
|
->andWhere($qb->expr()->neq('acp.step', "'".AccompanyingPeriod::STEP_DRAFT."'"));
|
||||||
|
|
||||||
if ($this->filterStatsByCenters) {
|
$this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
|
||||||
$qb
|
|
||||||
->andWhere(
|
|
||||||
$qb->expr()->exists(
|
|
||||||
'SELECT 1 FROM '.PersonCenterHistory::class.' pch WHERE pch.person = person.id AND pch.center IN (:authorized_centers)'
|
|
||||||
)
|
|
||||||
)->setParameter('authorized_centers', $centers);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date']));
|
$this->listPersonHelper->addSelect($qb, ListPersonHelper::FIELDS, $this->rollingDateConverter->convert($data['address_date']));
|
||||||
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date']));
|
$this->listAccompanyingPeriodHelper->addSelectClauses($qb, $this->rollingDateConverter->convert($data['address_date']));
|
||||||
|
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Helper;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||||
|
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter accompanying period list and related, removing confidential ones
|
||||||
|
* based on ACL rules.
|
||||||
|
*/
|
||||||
|
final readonly class FilterListAccompanyingPeriodHelper implements FilterListAccompanyingPeriodHelperInterface
|
||||||
|
{
|
||||||
|
private bool $filterStatsByCenters;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private Security $security,
|
||||||
|
private CenterRepositoryInterface $centerRepository,
|
||||||
|
private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser,
|
||||||
|
ParameterBagInterface $parameterBag,
|
||||||
|
) {
|
||||||
|
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFilterAccompanyingPeriods(QueryBuilder &$qb, array $requiredModifiers, array $acl, array $data = []): void
|
||||||
|
{
|
||||||
|
$centers = match ($this->filterStatsByCenters) {
|
||||||
|
true => array_map(static fn ($el) => $el['center'], $acl),
|
||||||
|
false => $this->centerRepository->findAll(),
|
||||||
|
};
|
||||||
|
|
||||||
|
$user = $this->security->getUser();
|
||||||
|
|
||||||
|
if (!$user instanceof User) {
|
||||||
|
throw new \RuntimeException('only a regular user can run this export');
|
||||||
|
}
|
||||||
|
|
||||||
|
// add filtering on confidential accompanying period. The confidential is applyed on the current status of
|
||||||
|
// the accompanying period (we do not use the 'calc_date' here
|
||||||
|
$aclConditionsOrX = $qb->expr()->orX(
|
||||||
|
// either the current user is the refferer for the course
|
||||||
|
'acp.user = :list_acp_current_user',
|
||||||
|
);
|
||||||
|
$qb->setParameter('list_acp_current_user', $user);
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($centers as $center) {
|
||||||
|
$scopes = $this->authorizationHelperForCurrentUser->getReachableScopes(AccompanyingPeriodVoter::SEE_DETAILS, $center);
|
||||||
|
$scopesConfidential =
|
||||||
|
$this->authorizationHelperForCurrentUser->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center);
|
||||||
|
$orScopes = $qb->expr()->orX();
|
||||||
|
|
||||||
|
foreach ($scopes as $scope) {
|
||||||
|
$scopeCondition = match (in_array($scope, $scopesConfidential, true)) {
|
||||||
|
true => ":scope_{$i} MEMBER OF acp.scopes",
|
||||||
|
false => $qb->expr()->andX(
|
||||||
|
'acp.confidential = FALSE',
|
||||||
|
":scope_{$i} MEMBER OF acp.scopes",
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
$orScopes->add($scopeCondition);
|
||||||
|
$qb->setParameter("scope_{$i}", $scope);
|
||||||
|
++$i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->filterStatsByCenters) {
|
||||||
|
$andX = $qb->expr()->andX(
|
||||||
|
$qb->expr()->exists(
|
||||||
|
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class." acl_count_part_{$i}
|
||||||
|
JOIN ".PersonCenterHistory::class." acl_count_person_history_{$i} WITH IDENTITY(acl_count_person_history_{$i}.person) = IDENTITY(acl_count_part_{$i}.person)
|
||||||
|
WHERE acl_count_part_{$i}.accompanyingPeriod = acp.id AND acl_count_person_history_{$i}.center IN (:authorized_center_{$i})
|
||||||
|
AND acl_count_person_history_{$i}.startDate <= CURRENT_DATE() AND (acl_count_person_history_{$i}.endDate IS NULL or acl_count_person_history_{$i}.endDate > CURRENT_DATE())
|
||||||
|
"
|
||||||
|
),
|
||||||
|
$orScopes,
|
||||||
|
);
|
||||||
|
$qb->setParameter('authorized_center_'.$i, $center);
|
||||||
|
$aclConditionsOrX->add($andX);
|
||||||
|
} else {
|
||||||
|
$aclConditionsOrX->add($orScopes);
|
||||||
|
}
|
||||||
|
|
||||||
|
++$i;
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->andWhere($aclConditionsOrX);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Helper;
|
||||||
|
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter accompanying period list and related, removing confidential ones
|
||||||
|
* based on ACL rules.
|
||||||
|
*/
|
||||||
|
interface FilterListAccompanyingPeriodHelperInterface
|
||||||
|
{
|
||||||
|
public function addFilterAccompanyingPeriods(QueryBuilder &$qb, array $requiredModifiers, array $acl, array $data = []): void;
|
||||||
|
}
|
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Tests\Controller;
|
|||||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Relationships\Relation;
|
use Chill\PersonBundle\Entity\Relationships\Relation;
|
||||||
|
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -43,31 +44,34 @@ final class RelationshipApiControllerTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
$em = self::$container->get(EntityManagerInterface::class);
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
$countPersons = $em->createQueryBuilder()
|
$personIdHavingRelation = $em->createQueryBuilder()
|
||||||
->select('count(p)')
|
->select('p.id')
|
||||||
->from(Person::class, 'p')
|
|
||||||
->join('p.centerCurrent', 'center_current')
|
|
||||||
->join('center_current.center', 'c')
|
|
||||||
->where('c.name LIKE :name')
|
|
||||||
->setParameter('name', 'Center A')
|
|
||||||
->getQuery()
|
|
||||||
->getSingleScalarResult();
|
|
||||||
$person = $em->createQueryBuilder()
|
|
||||||
->select('p')
|
|
||||||
->from(Person::class, 'p')
|
->from(Person::class, 'p')
|
||||||
->join('p.centerCurrent', 'center_current')
|
->join('p.centerCurrent', 'center_current')
|
||||||
->join('center_current.center', 'c')
|
->join('center_current.center', 'c')
|
||||||
->where('c.name LIKE :name')
|
->where('c.name LIKE :name')
|
||||||
|
->andWhere('EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
|
||||||
->setParameter('name', 'Center A')
|
->setParameter('name', 'Center A')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->setMaxResults(1)
|
->setMaxResults(1)
|
||||||
->setFirstResult(\random_int(0, $countPersons - 1))
|
->getSingleScalarResult();
|
||||||
->getSingleResult();
|
|
||||||
|
$personIdWithoutRelation = $em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p')
|
||||||
|
->join('p.centerCurrent', 'center_current')
|
||||||
|
->join('center_current.center', 'c')
|
||||||
|
->where('c.name LIKE :name')
|
||||||
|
->andWhere('NOT EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
|
||||||
|
->setParameter('name', 'Center A')
|
||||||
|
->getQuery()
|
||||||
|
->setMaxResults(1)
|
||||||
|
->getSingleScalarResult();
|
||||||
|
|
||||||
self::ensureKernelShutdown();
|
self::ensureKernelShutdown();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[$person->getId()],
|
[$personIdHavingRelation, $personIdWithoutRelation],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,39 +79,29 @@ final class RelationshipApiControllerTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
$em = self::$container->get(EntityManagerInterface::class);
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
$countPersons = $em->createQueryBuilder()
|
$personIdWithoutRelations = $em->createQueryBuilder()
|
||||||
->select('count(DISTINCT p)')
|
->select('p.id')
|
||||||
->from(Person::class, 'p')
|
|
||||||
->join('p.centerCurrent', 'center_current')
|
|
||||||
->join('center_current.center', 'c')
|
|
||||||
->where('c.name LIKE :name')
|
|
||||||
->setParameter('name', 'Center A')
|
|
||||||
->getQuery()
|
|
||||||
->getSingleScalarResult();
|
|
||||||
|
|
||||||
$persons = $em->createQueryBuilder()
|
|
||||||
->select('p')
|
|
||||||
->from(Person::class, 'p')
|
->from(Person::class, 'p')
|
||||||
->join('p.centerCurrent', 'center_current')
|
->join('p.centerCurrent', 'center_current')
|
||||||
->join('center_current.center', 'c')
|
->join('center_current.center', 'c')
|
||||||
->where('c.name LIKE :name')
|
->where('c.name LIKE :name')
|
||||||
|
->andWhere('NOT EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
|
||||||
->setParameter('name', 'Center A')
|
->setParameter('name', 'Center A')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->setMaxResults(2)
|
->setMaxResults(2)
|
||||||
->setFirstResult(\random_int(0, $countPersons - 1))
|
|
||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
self::ensureKernelShutdown();
|
self::ensureKernelShutdown();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
[$persons[0]->getId(), $persons[1]->getId(), $this->getRandomRelation($em)->getId(), true],
|
[$personIdWithoutRelations[0]['id'], $personIdWithoutRelations[1]['id'], $this->getRandomRelation($em)->getId(), true],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider personProvider
|
* @dataProvider personProvider
|
||||||
*/
|
*/
|
||||||
public function testGetRelationshipByPerson(mixed $personId)
|
public function testGetRelationshipByPerson(int $personId)
|
||||||
{
|
{
|
||||||
self::ensureKernelShutdown();
|
self::ensureKernelShutdown();
|
||||||
$client = $this->getClientAuthenticated();
|
$client = $this->getClientAuthenticated();
|
||||||
|
@@ -11,14 +11,23 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Tests\Export\Export;
|
namespace Chill\PersonBundle\Tests\Export\Export;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriod;
|
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelper;
|
||||||
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Prophecy\Argument;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -27,6 +36,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
class ListAccompanyingPeriodTest extends AbstractExportTest
|
class ListAccompanyingPeriodTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
private readonly ListAccompanyingPeriod $listAccompanyingPeriod;
|
private readonly ListAccompanyingPeriod $listAccompanyingPeriod;
|
||||||
|
|
||||||
private readonly CenterRepositoryInterface $centerRepository;
|
private readonly CenterRepositoryInterface $centerRepository;
|
||||||
@@ -39,12 +50,54 @@ class ListAccompanyingPeriodTest extends AbstractExportTest
|
|||||||
|
|
||||||
public function getExport()
|
public function getExport()
|
||||||
{
|
{
|
||||||
|
/** @var EntityManagerInterface::class $em */
|
||||||
$em = self::$container->get(EntityManagerInterface::class);
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
||||||
$listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class);
|
$listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class);
|
||||||
|
$centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
||||||
|
$scopeRepository = self::$container->get(ScopeRepositoryInterface::class);
|
||||||
|
|
||||||
yield new ListAccompanyingPeriod($em, $rollingDateConverter, $listAccompanyingPeriodHelper, $this->getParameters(true));
|
// mock security
|
||||||
yield new ListAccompanyingPeriod($em, $rollingDateConverter, $listAccompanyingPeriodHelper, $this->getParameters(false));
|
$user = $em->createQuery('SELECT u FROM '.User::class.' u')
|
||||||
|
->setMaxResults(1)->getSingleResult();
|
||||||
|
if (null === $user) {
|
||||||
|
throw new \RuntimeException('no user found');
|
||||||
|
}
|
||||||
|
$security = $this->prophesize(Security::class);
|
||||||
|
$security->getUser()->willReturn($user);
|
||||||
|
|
||||||
|
// mock authorization helper
|
||||||
|
$scopes = $scopeRepository->findAll();
|
||||||
|
$scopesConfidentials = [] !== $scopes ? [$scopes[0]] : [];
|
||||||
|
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
|
||||||
|
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_DETAILS, Argument::type(Center::class))
|
||||||
|
->willReturn($scopes);
|
||||||
|
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::type(Center::class))
|
||||||
|
->willReturn($scopesConfidentials);
|
||||||
|
|
||||||
|
yield new ListAccompanyingPeriod(
|
||||||
|
$em,
|
||||||
|
$rollingDateConverter,
|
||||||
|
$listAccompanyingPeriodHelper,
|
||||||
|
new FilterListAccompanyingPeriodHelper(
|
||||||
|
$security->reveal(),
|
||||||
|
$centerRepository,
|
||||||
|
$authorizationHelper->reveal(),
|
||||||
|
$this->getParameters(true)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
yield new ListAccompanyingPeriod(
|
||||||
|
$em,
|
||||||
|
$rollingDateConverter,
|
||||||
|
$listAccompanyingPeriodHelper,
|
||||||
|
new FilterListAccompanyingPeriodHelper(
|
||||||
|
$security->reveal(),
|
||||||
|
$centerRepository,
|
||||||
|
$authorizationHelper->reveal(),
|
||||||
|
$this->getParameters(false)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormData()
|
public function getFormData()
|
||||||
|
@@ -20,6 +20,7 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
|||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod;
|
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
@@ -27,6 +28,7 @@ use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
|||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -35,6 +37,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends AbstractExportTest
|
class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -55,6 +59,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends
|
|||||||
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
||||||
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
|
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
|
||||||
$socialActionRepository = self::$container->get(SocialActionRepository::class);
|
$socialActionRepository = self::$container->get(SocialActionRepository::class);
|
||||||
|
$filterListAccompanyingPeriodHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
|
||||||
|
|
||||||
yield new ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod(
|
yield new ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod(
|
||||||
$entityManager,
|
$entityManager,
|
||||||
@@ -69,23 +74,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriodTest extends
|
|||||||
$rollingDateConverter,
|
$rollingDateConverter,
|
||||||
$aggregateStringHelper,
|
$aggregateStringHelper,
|
||||||
$socialActionRepository,
|
$socialActionRepository,
|
||||||
$this->getParameters(true),
|
$filterListAccompanyingPeriodHelper->reveal(),
|
||||||
);
|
|
||||||
|
|
||||||
yield new ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod(
|
|
||||||
$entityManager,
|
|
||||||
$dateTimeHelper,
|
|
||||||
$userHelper,
|
|
||||||
$personHelper,
|
|
||||||
$thirdPartyHelper,
|
|
||||||
$translatableStringExportLabelHelper,
|
|
||||||
$socialIssueRender,
|
|
||||||
$socialIssueRepository,
|
|
||||||
$socialActionRender,
|
|
||||||
$rollingDateConverter,
|
|
||||||
$aggregateStringHelper,
|
|
||||||
$socialActionRepository,
|
|
||||||
$this->getParameters(false),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
|||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnWork;
|
use Chill\PersonBundle\Export\Export\ListAccompanyingPeriodWorkAssociatePersonOnWork;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
@@ -27,6 +28,7 @@ use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
|||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -35,6 +37,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExportTest
|
class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -55,6 +59,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExport
|
|||||||
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
||||||
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
|
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
|
||||||
$socialActionRepository = self::$container->get(SocialActionRepository::class);
|
$socialActionRepository = self::$container->get(SocialActionRepository::class);
|
||||||
|
$filterHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
|
||||||
|
|
||||||
yield new ListAccompanyingPeriodWorkAssociatePersonOnWork(
|
yield new ListAccompanyingPeriodWorkAssociatePersonOnWork(
|
||||||
$entityManager,
|
$entityManager,
|
||||||
@@ -69,23 +74,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWorkTest extends AbstractExport
|
|||||||
$rollingDateConverter,
|
$rollingDateConverter,
|
||||||
$aggregateStringHelper,
|
$aggregateStringHelper,
|
||||||
$socialActionRepository,
|
$socialActionRepository,
|
||||||
$this->getParameters(true),
|
$filterHelper->reveal(),
|
||||||
);
|
|
||||||
|
|
||||||
yield new ListAccompanyingPeriodWorkAssociatePersonOnWork(
|
|
||||||
$entityManager,
|
|
||||||
$dateTimeHelper,
|
|
||||||
$userHelper,
|
|
||||||
$personHelper,
|
|
||||||
$thirdPartyHelper,
|
|
||||||
$translatableStringExportLabelHelper,
|
|
||||||
$socialIssueRender,
|
|
||||||
$socialIssueRepository,
|
|
||||||
$socialActionRender,
|
|
||||||
$rollingDateConverter,
|
|
||||||
$aggregateStringHelper,
|
|
||||||
$socialActionRepository,
|
|
||||||
$this->getParameters(false),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Tests\Export\Export;
|
namespace Chill\PersonBundle\Tests\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
|
||||||
use Chill\MainBundle\Export\Helper\AggregateStringHelper;
|
use Chill\MainBundle\Export\Helper\AggregateStringHelper;
|
||||||
use Chill\MainBundle\Export\Helper\DateTimeHelper;
|
use Chill\MainBundle\Export\Helper\DateTimeHelper;
|
||||||
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
|
use Chill\MainBundle\Export\Helper\TranslatableStringExportLabelHelper;
|
||||||
@@ -22,13 +21,14 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
|||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Export\Export\ListEvaluation;
|
use Chill\PersonBundle\Export\Export\ListEvaluation;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Doctrine\ORM\AbstractQuery;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -37,7 +37,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
class ListEvaluationTest extends AbstractExportTest
|
class ListEvaluationTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
private ListEvaluation $listEvaluation;
|
use ProphecyTrait;
|
||||||
|
|
||||||
private CenterRepositoryInterface $centerRepository;
|
private CenterRepositoryInterface $centerRepository;
|
||||||
|
|
||||||
@@ -46,7 +46,6 @@ class ListEvaluationTest extends AbstractExportTest
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
|
|
||||||
$this->listEvaluation = self::$container->get(ListEvaluation::class);
|
|
||||||
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +62,7 @@ class ListEvaluationTest extends AbstractExportTest
|
|||||||
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
||||||
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
|
$aggregateStringHelper = self::$container->get(AggregateStringHelper::class);
|
||||||
$socialActionRepository = self::$container->get(SocialActionRepository::class);
|
$socialActionRepository = self::$container->get(SocialActionRepository::class);
|
||||||
|
$filterListHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
|
||||||
|
|
||||||
yield new ListEvaluation(
|
yield new ListEvaluation(
|
||||||
$entityManager,
|
$entityManager,
|
||||||
@@ -76,22 +76,7 @@ class ListEvaluationTest extends AbstractExportTest
|
|||||||
$translatableStringExportLabelHelper,
|
$translatableStringExportLabelHelper,
|
||||||
$aggregateStringHelper,
|
$aggregateStringHelper,
|
||||||
$rollingDateConverter,
|
$rollingDateConverter,
|
||||||
$this->getParameters(true),
|
$filterListHelper->reveal(),
|
||||||
);
|
|
||||||
|
|
||||||
yield new ListEvaluation(
|
|
||||||
$entityManager,
|
|
||||||
$socialIssueRender,
|
|
||||||
$socialIssueRepository,
|
|
||||||
$socialActionRender,
|
|
||||||
$socialActionRepository,
|
|
||||||
$userHelper,
|
|
||||||
$personHelper,
|
|
||||||
$dateTimeHelper,
|
|
||||||
$translatableStringExportLabelHelper,
|
|
||||||
$aggregateStringHelper,
|
|
||||||
$rollingDateConverter,
|
|
||||||
$this->getParameters(false),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,14 +89,4 @@ class ListEvaluationTest extends AbstractExportTest
|
|||||||
{
|
{
|
||||||
return [[Declarations::ACP_TYPE]];
|
return [[Declarations::ACP_TYPE]];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testQuery(): void
|
|
||||||
{
|
|
||||||
$centers = $this->centerRepository->findAll();
|
|
||||||
|
|
||||||
$query = $this->listEvaluation->initiateQuery([], array_map(fn (Center $c) => ['center' => $c], $centers), ['calc_date' => new RollingDate(RollingDate::T_TODAY)]);
|
|
||||||
$query->setMaxResults(1);
|
|
||||||
|
|
||||||
self::assertIsArray($query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -16,9 +16,11 @@ use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
|||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriodDetails;
|
use Chill\PersonBundle\Export\Export\ListPersonWithAccompanyingPeriodDetails;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
use Chill\PersonBundle\Export\Helper\ListAccompanyingPeriodHelper;
|
||||||
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
|
use Chill\PersonBundle\Export\Helper\ListPersonHelper;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@@ -27,6 +29,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
class ListPersonWithAccompanyingPeriodDetailsTest extends AbstractExportTest
|
class ListPersonWithAccompanyingPeriodDetailsTest extends AbstractExportTest
|
||||||
{
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -39,21 +43,14 @@ class ListPersonWithAccompanyingPeriodDetailsTest extends AbstractExportTest
|
|||||||
$listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class);
|
$listAccompanyingPeriodHelper = self::$container->get(ListAccompanyingPeriodHelper::class);
|
||||||
$entityManager = self::$container->get(EntityManagerInterface::class);
|
$entityManager = self::$container->get(EntityManagerInterface::class);
|
||||||
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
$rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
||||||
|
$filterHelper = $this->prophesize(FilterListAccompanyingPeriodHelperInterface::class);
|
||||||
|
|
||||||
yield new ListPersonWithAccompanyingPeriodDetails(
|
yield new ListPersonWithAccompanyingPeriodDetails(
|
||||||
$listPersonHelper,
|
$listPersonHelper,
|
||||||
$listAccompanyingPeriodHelper,
|
$listAccompanyingPeriodHelper,
|
||||||
$entityManager,
|
$entityManager,
|
||||||
$rollingDateConverter,
|
$rollingDateConverter,
|
||||||
$this->getParameters(true),
|
$filterHelper->reveal()
|
||||||
);
|
|
||||||
|
|
||||||
yield new ListPersonWithAccompanyingPeriodDetails(
|
|
||||||
$listPersonHelper,
|
|
||||||
$listAccompanyingPeriodHelper,
|
|
||||||
$entityManager,
|
|
||||||
$rollingDateConverter,
|
|
||||||
$this->getParameters(false),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Helper;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Export\Helper\FilterListAccompanyingPeriodHelper;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Prophecy\Argument;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class FilterListAccompanyingPeriodHelperTest extends KernelTestCase
|
||||||
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
|
private CenterRepositoryInterface $centerRepository;
|
||||||
|
private ScopeRepositoryInterface $scopeRepository;
|
||||||
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
|
||||||
|
$this->scopeRepository = self::$container->get(ScopeRepositoryInterface::class);
|
||||||
|
$this->entityManager = self::$container->get(EntityManagerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataProviderTestAddFilterAccompanyingPeriod
|
||||||
|
*/
|
||||||
|
public function testAddFilterAccompanyingPeriod(QueryBuilder $qb, ParameterBagInterface $parameterBag): void
|
||||||
|
{
|
||||||
|
// mock security
|
||||||
|
$user = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u')
|
||||||
|
->setMaxResults(1)->getSingleResult();
|
||||||
|
if (null === $user) {
|
||||||
|
throw new \RuntimeException('no user found');
|
||||||
|
}
|
||||||
|
$security = $this->prophesize(Security::class);
|
||||||
|
$security->getUser()->willReturn($user);
|
||||||
|
|
||||||
|
// mock authorization helper
|
||||||
|
$scopes = $this->scopeRepository->findAll();
|
||||||
|
$scopesConfidentials = [] !== $scopes ? [$scopes[0]] : [];
|
||||||
|
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
|
||||||
|
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_DETAILS, Argument::type(Center::class))
|
||||||
|
->willReturn($scopes);
|
||||||
|
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::type(Center::class))
|
||||||
|
->willReturn($scopesConfidentials);
|
||||||
|
|
||||||
|
$filter = new FilterListAccompanyingPeriodHelper(
|
||||||
|
$security->reveal(),
|
||||||
|
$this->centerRepository,
|
||||||
|
$authorizationHelper->reveal(),
|
||||||
|
$parameterBag
|
||||||
|
);
|
||||||
|
|
||||||
|
$filter->addFilterAccompanyingPeriods($qb, [], $this->getACL(), []);
|
||||||
|
|
||||||
|
$qb->setMaxResults(1);
|
||||||
|
$result = $qb->getQuery()->getResult();
|
||||||
|
|
||||||
|
self::assertIsArray($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataProviderTestAddFilterAccompanyingPeriod(): iterable
|
||||||
|
{
|
||||||
|
self::setUp();
|
||||||
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->select('acp.id')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp');
|
||||||
|
|
||||||
|
yield [
|
||||||
|
$qb,
|
||||||
|
new ParameterBag(['chill_main' => ['acl' => ['filter_stats_by_center' => true]]]),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
$qb,
|
||||||
|
new ParameterBag(['chill_main' => ['acl' => ['filter_stats_by_center' => false]]]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{center: Center, circles: list<Scope>}> the ACL, structured as an array
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException when no center or circle is found
|
||||||
|
*/
|
||||||
|
private function getACL(): array
|
||||||
|
{
|
||||||
|
$centers = $this->centerRepository->findAll();
|
||||||
|
$circles = $this->scopeRepository->findAll();
|
||||||
|
|
||||||
|
if (0 === \count($centers)) {
|
||||||
|
throw new \RuntimeException('No center found. Did you forget to run `doctrine:fixtures:load` command before ?');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 === \count($circles)) {
|
||||||
|
throw new \RuntimeException('No circle found. Did you forget to run `doctrine:fixtures:load` command before ?');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [[
|
||||||
|
'center' => $centers[0],
|
||||||
|
'circles' => [
|
||||||
|
$circles,
|
||||||
|
], ]];
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Person;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix lines in chill_person_person_center_history for people created before the introduction of the createdAt column.
|
||||||
|
*
|
||||||
|
* This class represents a migration for fixing lines in the 'chill_person_person_center_history' table.
|
||||||
|
*
|
||||||
|
* It updates the 'startdate' column for people created before the introduction
|
||||||
|
* of the 'createdAt' column, and set it at the first activity date. This migration is irreversible.
|
||||||
|
*/
|
||||||
|
final class Version20231207221700 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Fix lines in chill_person_person_center_history for people created before the introduction of the createdAt column';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('WITH first_history_line AS (SELECT *
|
||||||
|
FROM (SELECT id,
|
||||||
|
person_id,
|
||||||
|
startdate,
|
||||||
|
rank() OVER (PARTITION BY person_id ORDER BY startdate ASC, id ASC) AS r
|
||||||
|
FROM chill_person_person_center_history) AS sk
|
||||||
|
WHERE sk.r = 1),
|
||||||
|
first_activity AS (SELECT *
|
||||||
|
FROM (SELECT id, date, person_id, rank() OVER (PARTITION BY person_id ORDER BY date ASC, id ASC) AS r
|
||||||
|
FROM activity
|
||||||
|
WHERE person_id IS NOT NULL) sq
|
||||||
|
WHERE sq.r = 1)
|
||||||
|
UPDATE chill_person_person_center_history cppch SET startdate=first_activity.date
|
||||||
|
FROM first_history_line, first_activity
|
||||||
|
WHERE
|
||||||
|
first_history_line.id = cppch.id
|
||||||
|
AND first_activity.person_id = cppch.person_id
|
||||||
|
AND first_activity.date < first_history_line.startDate');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->throwIrreversibleMigrationException();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user