Compare commits

...

173 Commits

Author SHA1 Message Date
3fb04594eb add changie [ci-skip] 2023-12-12 15:55:14 +01:00
1065706e60 Re-configure test app 2023-12-12 15:55:14 +01:00
f131572344 Remove references to old async upload bundle 2023-12-12 15:55:14 +01:00
45e1ce034a Add ConfigureOpenstackObjectStorageCommand to ChillDocStoreBundle
Added new command file "ConfigureOpenstackObjectStorageCommand.php" under ChillDocStoreBundle that helps in setting up OpenStack container for document storage. Along with the command, added corresponding test file "ConfigureOpenstackObjectStorageCommandTest.php" to ensure the functionality is working as expected.
2023-12-12 15:55:14 +01:00
82ca321715 Add exceptions for async file handling failures
Introduced two new exceptions, `BadCallToRemoteServer` and `TempUrlRemoteServerException`, to improve error handling in asynchronous file operations. These exceptions are thrown when there are issues with the remote server during an async file operation such as HTTP status codes >= 400 and if the server is unreachable.
2023-12-12 15:55:13 +01:00
28d09a8206 Add form and types to handle async files 2023-12-12 15:55:13 +01:00
1195767eb3 Add Twig AsyncUploadExtension and its associated test
Created AsyncUploadExtension under Chill\DocStoreBundle\AsyncUpload\Templating to provide Twig filter functions for generating URLs for asynchronous file uploads. To ensure correctness, AsyncUploadExtensionTest was implemented in Bundle\ChillDocStoreBundle\Tests\AsyncUpload\Templating. Service definitions were also updated in services.yaml.
2023-12-12 15:55:13 +01:00
4fd5a37df3 Add serializer groups to SignedUrl and SignedUrlPost classes, include tests
Serializer groups have been added to the SignedUrl and SignedUrlPost classes to ensure correct serialization. Two new test files were also included: SignedUrlNormalizerTest and SignedUrlPostNormalizerTest which test the normalization of instances of the classes.
2023-12-12 15:55:13 +01:00
450e7c348b Fix and clean DI configuration for chill_doc_store for usage with AsyncUpload 2023-12-12 15:55:12 +01:00
a70572266f Refactor TempUrlOpenstackGenerator to use parameter bag and Bundle configuration
The TempUrlOpenstackGenerator now uses a ParameterBag for configuration instead of individual parameters. This simplifies the handling of configuration values and makes the code more maintainable. The parameter configuration has also been included in the chill_doc_store configuration array for a unified approach.
2023-12-12 15:55:12 +01:00
d688022825 Add Controller to get asyncUpload signatures
Added new files for handling asynchronous file uploads in ChillDocStoreBundle. The new files include a controller for generating temporary URLs (AsyncUploadController.php), a security authorization file (AsyncUploadVoter.php), and a corresponding test file (AsyncUploadControllerTest.php). These implementations permit asynchronous uploads via POST, GET, and HEAD methods while maintaining security protocols.
2023-12-12 11:36:14 +01:00
264fff5c36 Implement asynchronous upload feature in Openstack Object Store
Those features were previously stored in champs-libres/async-upload-bundle

This commit introduces several new classes within the ChillDocStore bundle for handling asynchronous uploads onto an Openstack Object Store. Specifically, the TempUrlOpenstackGenerator, SignedUrl, TempUrlGeneratorInterface, TempUrlGenerateEvent, and TempUrlGeneratorException classes have been created.

This implementation will allow for generating "temporary URLs", which assist in securely and temporarily uploading resources to the OpenStack Object Store. This feature enables the handling of file uploads in a more scalable and efficient manner in high-volume environments.

Additionally, corresponding unit tests have also been added to ensure the accuracy of this new feature.
2023-12-12 11:36:14 +01:00
91e6b035bd release 2.15.0 2023-12-11 17:23:47 +01:00
2adb6105eb Merge branch '246-do-not-show-confidential-in-list' into 'master'
Filter confidential courses from list of accompanying periods and related

Closes #246

See merge request Chill-Projet/chill-bundles!633
2023-12-11 16:22:38 +00:00
33d187f329 Merge branch '228-fix-export-activity-from-v1' into 'master'
Fix export for people created before 'createdAt' column introduction

Closes #228

See merge request Chill-Projet/chill-bundles!634
2023-12-11 16:22:12 +00:00
8cc93a8b07 add changie [ci-skip] 2023-12-07 23:25:38 +01:00
f7184ca7bb Fix export for people created before 'createdAt' column introduction
This commit introduces a migration to fix the export for individuals who were created before the introduction of the 'createdAt' column. The 'startdate' column is now updated to match the individual's first activity date. This migration is irreversible. It's been added as a response to Issue #228
2023-12-07 23:22:48 +01:00
dab80a84d8 Merge branch '235-add-date-filter-course-by-activity' into 'master'
Add dates in the filter "filter course by activity type"

Closes #235

See merge request Chill-Projet/chill-bundles!632
2023-12-07 15:25:09 +00:00
68e00dc42f Merge branch '234-fix-date-validation-aside-activity-filter-by-date' into 'master'
Fix "filter aside activity by date"

Closes #234

See merge request Chill-Projet/chill-bundles!631
2023-12-07 15:24:16 +00:00
5fae49821f Merge branch '191-export-number-of-household-by-activities' into 'master'
Export: add export "number of household associated with an activity"

Closes #191

See merge request Chill-Projet/chill-bundles!629
2023-12-07 15:23:43 +00:00
0e599a99a7 Merge branch '233-fix-filter-by-evaluation-type' into 'master'
Fix filter evaluation by evaluation type

Closes #233

See merge request Chill-Projet/chill-bundles!628
2023-12-07 15:23:24 +00:00
f0605c6b08 Use dedicated FilterListAccompanyingPeriodHelper to filter confidential course in different lists 2023-12-07 16:18:37 +01:00
54606403b4 Refactor confidential filtering on list to let it usable by other lists 2023-12-07 15:13:54 +01:00
47d829d72d Filter confidential courses from list of accompanying periods 2023-12-06 22:46:50 +01:00
fa3b305ab9 Merge branch 'issue214_fix_error_empty_comment' into 'master'
Notification: avoid the comment's content to be null

Closes #214

See merge request Chill-Projet/chill-bundles!623
2023-12-05 16:26:06 +00:00
b26b7a2706 Notification: avoid the comment's content to be null 2023-12-05 16:26:06 +00:00
fe54e51362 Add dates in the filter "filter course by activity type" 2023-12-04 18:17:00 +01:00
179e3e92ed Fix "filter aside activity by date" 2023-12-04 17:30:40 +01:00
c00c6066a9 Merge branch 'fix-rector-issues-20231204' into 'master'
Fix issues with new version of rector

See merge request Chill-Projet/chill-bundles!630
2023-12-04 16:11:38 +00:00
f424c5464f Fix issues with new version of rector 2023-12-04 16:46:48 +01:00
b17b2a8cfb Export: add export "number of household associated with an activity" 2023-12-04 16:39:01 +01:00
00de657cae Fix filter evaluation by evaluation type 2023-12-01 09:46:02 +01:00
673518e0eb Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles 2023-11-30 12:15:47 +01:00
4700a0fef7 update URL for postal code FR import 2023-11-30 12:15:22 +01:00
f4d258882f Release 2.14.1 2023-11-29 22:23:42 +01:00
fffc4a9c33 Fix error on listEvaluation
- force default calcDate
- Export / UserHelper: handle case when a single user is given, when we expect more than one user
2023-11-29 22:22:06 +01:00
a344f36592 Merge branch 'issue100_add_paginator_budget_admin' into 'master'
add paginator to budget admin pages

See merge request Chill-Projet/chill-bundles!624
2023-11-29 20:21:42 +00:00
eef93b8a0d add changie 2023-11-29 11:33:26 +01:00
75b78d3c99 add paginator to budget admin pages 2023-11-28 17:27:26 +01:00
3d4c439be4 Merge branch 'fix-list-person-custom-field' into 'master'
Fix "PersonList" with custom fields

See merge request Chill-Projet/chill-bundles!622
2023-11-28 11:03:26 +00:00
4727a57825 Export: ListPerson: avoid json_decoding the string '_header' 2023-11-27 21:02:39 +01:00
5f441eb5ac Fix path to csv template 2023-11-27 21:01:01 +01:00
2e4e5ee79a Release v2.14.0 2023-11-24 12:39:13 +01:00
1467c708f2 Merge branch '222-fix-custom-fields' into 'master'
Fix errors in custom field rendering and administration

See merge request Chill-Projet/chill-bundles!620
2023-11-24 11:38:07 +00:00
170bb9586d Fix errors in custom field rendering and administration 2023-11-24 12:30:18 +01:00
c704ffa379 Merge branch '161-fix-ordering-filter-social-action-type' into 'master'
Export: Fix vue app in "filter action by type, goals and result"

Closes #219, #141, and #161

See merge request Chill-Projet/chill-bundles!616
2023-11-23 15:50:57 +00:00
947b7b90e2 Fix SocialWorkTypeFilter: allow null value in date, and avoid vuejs module ExportFormActionGoal to override the export form content 2023-11-23 16:02:55 +01:00
992f7761bb Fix cs 2023-11-21 15:17:02 +01:00
35170e1f7c release 2.13.0 2023-11-21 14:14:11 +01:00
7132dfa3f6 Merge branch '211-errors-exports' into 'master'
Resolve multiple errors in filters and aggregators

Closes #213 and #211

See merge request Chill-Projet/chill-bundles!617
2023-11-21 12:53:27 +00:00
7e09e0ea54 Merge branch 'issue215_gender_neuter_fix' into 'master'
change all instances of neuter to both

See merge request Chill-Projet/chill-bundles!618
2023-11-21 12:53:13 +00:00
ccf8cc4d6e Merge branch 'fix-phpstan-2023-11-21' into 'master'
Fix type-hinting of DocGenObjectNormalizer and related

See merge request Chill-Projet/chill-bundles!619
2023-11-21 12:48:30 +00:00
63124f8f92 Fix type-hinting of DocGenObjectNormalizer and related 2023-11-21 13:37:23 +01:00
75d80ebd98 Fix migration syntax 2023-11-21 12:13:27 +01:00
0ea6f36297 styles fixes 2023-11-21 11:59:03 +01:00
975ea417b7 Further update gender options 2023-11-21 11:37:19 +01:00
af8e02f76b Migration to change instances of gender neuter to both 2023-11-21 08:13:46 +01:00
cbaeb3d7e8 fix double translation keys 2023-11-21 08:13:25 +01:00
f609ddb315 change all instances of neuter to both 2023-11-21 07:58:45 +01:00
d0bceb59dc Export: fix usage of some Collection returned instead of array in export filters 2023-11-20 18:15:53 +01:00
2883e085ed DX: Fix aggregator: "group activity by reason" 2023-11-20 18:07:06 +01:00
b05ed86d1e DX: Fix aggregator: "group activity by type" 2023-11-20 18:06:55 +01:00
c855d0badc Merge branch 'add_phonenumber_to_user' into 'master'
Add phonenumber to user

See merge request Chill-Projet/chill-bundles!600
2023-11-16 15:12:12 +00:00
be57c96a2f Add phonenumber to user 2023-11-16 15:12:12 +00:00
eb01c7c203 Export: on filter "action by type goals, and results", restore the fields when editing a saved export 2023-11-16 14:22:52 +01:00
53b4747697 fixup! Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order 2023-11-16 11:55:15 +01:00
89e19502d3 Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order 2023-11-16 11:53:57 +01:00
ff344dbb0c Release 2.12.1 2023-11-16 11:07:34 +01:00
8719b4dedd Merge branch '208-export-fix-loading-by-type-goal-result' into 'master'
Resolve "Export: le chargement de l'app vue de "filtrer les actions par type, objectif et résultat" ne se charge pas sur certains exports"

Closes #208

See merge request Chill-Projet/chill-bundles!615
2023-11-16 10:05:56 +00:00
d8fa743bc9 Export: fix loading of form for "filter action by type, goal and result" 2023-11-16 10:57:59 +01:00
eaa40d6725 DX: remove some unnecessary console.log 2023-11-16 10:57:32 +01:00
1f47f157ea Release v2.12.0 2023-11-15 14:03:46 +01:00
5ab0d3f8da add units on the headers for avg duration of accompanying period work 2023-11-15 13:57:48 +01:00
98fd5cae78 Merge branch '204-export-action-creator' into 'master'
[export] add filters/aggregators for creator works action

Closes #204

See merge request Chill-Projet/chill-bundles!610
2023-11-15 12:49:08 +00:00
2bb29242e4 Merge branch '206-add-exports' into 'master'
"Ajouter un export "usagers concernées par un échange" et "usagers concernés par une action""

Closes #203 and #206

See merge request Chill-Projet/chill-bundles!613
2023-11-15 12:45:29 +00:00
e6cab938c8 DX: increase max connection in postgres service 2023-11-15 13:41:35 +01:00
f5f4d8fcdd remove blank line in changie 2023-11-15 13:30:48 +01:00
e9df26c2f7 Export: add clauses on the social work start date and end date within the filter "Filter accompanying period by accompanying period work"' 2023-11-15 13:25:08 +01:00
af6bee2497 Export: add an export which count persons on activity 2023-11-15 13:25:08 +01:00
af585bada3 Export: add a export which count persons on accompanying period work 2023-11-15 13:24:59 +01:00
f9763b866d add 6 new tests for filters/aggrs 2023-11-15 13:00:45 +01:00
7f18a2fb7d [export] better translation since filters are sorted 2023-11-15 13:00:45 +01:00
3cdad6caff Revert "test cs-fixer"
This reverts commit 9aa1d22d69e0f67333a8c39574fa2efed71c2bc8.
2023-11-15 13:00:45 +01:00
200ab836c7 test cs-fixer 2023-11-15 13:00:45 +01:00
3e39c0ced7 rector and cs-fixer 2023-11-15 13:00:45 +01:00
83c3621c26 declare service 2023-11-15 13:00:45 +01:00
b790e2fcf1 complete aggregators 2023-11-15 13:00:45 +01:00
fde6000d0b filters alterQuery 2023-11-15 13:00:45 +01:00
3892d1e877 remove date field 2023-11-15 13:00:45 +01:00
6944773868 create 6 new filters/aggr files 2023-11-15 13:00:45 +01:00
d5bc9d10d5 Merge branch 'issue202_export_duration_actions' into 'master'
Export: create an export which add the average  duration of accompanying period work

Closes #202

See merge request Chill-Projet/chill-bundles!611
2023-11-15 11:42:35 +00:00
3743b336a6 Export: create an export which add the average duration of accompanying period work 2023-11-15 11:42:34 +00:00
3332413fe0 Merge branch '199-missing-exports' into 'master'
Add missing filters and grouping

Closes #189, #200, and #199

See merge request Chill-Projet/chill-bundles!609
2023-11-14 20:24:21 +00:00
86e659edd4 DX: replace some string by constants 2023-11-14 21:17:09 +01:00
2e60ba3137 Export: fix infinite loop in HouseholdVoter 2023-11-14 21:17:08 +01:00
1663c6f7c7 DX: rename CountHousehold => CountHouseholdInPeriod.php + add test 2023-11-14 21:17:08 +01:00
d01b6db5dc DX: remove unused property 2023-11-14 21:17:08 +01:00
847c8238e8 Export: fix typo in filter "filter accompanying period work on end date 2023-11-14 21:17:08 +01:00
2cc5fa06ae Export: split export about person on accompanying period work: one with the
people associated with the work, another one with the people associated with the
  accompanying period
2023-11-14 21:17:07 +01:00
0d741ab886 Export: add grouping "group peoples by postal code" 2023-11-14 21:17:07 +01:00
9cb794fef2 Merge branch 'documentation-configure-absence-sync' into 'master'
Update the description and screenshots for the configuration of calendar

See merge request Chill-Projet/chill-bundles!608
2023-11-14 19:41:04 +00:00
fd03855ee6 Merge branch '205-fix-acpwork-referrers-as-a-list' into 'master'
Fix normalization of accompanying period work

Closes #205

See merge request Chill-Projet/chill-bundles!612
2023-11-14 19:40:42 +00:00
ac9897d9e7 DX: add a test to ensure that accompanyingPeriodWork::getReferrers is a list 2023-11-14 20:33:18 +01:00
88469dbe8e Fix serialization of accompangying period work referrers 2023-11-14 18:34:28 +01:00
cbc83c0e63 Export: add grouping "group activity by person" (activites saved in person context) 2023-11-13 15:29:01 +01:00
27012d842d Export: add an ActivityPresenceFilter 2023-11-13 15:29:01 +01:00
4112e59af4 Export: add an ActivityPresenceAggregator 2023-11-09 17:35:34 +01:00
1b0a30baf8 Merge branch '188-fix-ci' into 'master'
debug ci

Closes #188

See merge request Chill-Projet/chill-bundles!606
2023-11-09 15:20:55 +00:00
9673b369ef DX: restore the requirements of phpunit's tests
The problem with timezone is now fixed
2023-11-09 16:13:58 +01:00
43966c4d5a remove the change of timezone in test's setUp 2023-11-09 16:01:34 +01:00
c9f438319c update the description and screenshots for the configuration of calendar
and absence synchronization
2023-11-08 10:21:03 +01:00
58b45c6f1b Prepare for v2.11.0 2023-11-07 16:18:33 +01:00
f756c0d71e Merge branch '185-fix-inconsistencies-person-geog-unit-aggregator' into 'master'
Fix geographical unit stat aggregator by course: show also the course if they...

Closes #194 and #185

See merge request Chill-Projet/chill-bundles!607
2023-11-07 15:15:12 +00:00
bb1602934c Fix "group activity by creator job" aggregator 2023-11-07 16:07:24 +01:00
83fe3ec3fc Export: add a "filter activity by creator job" filter 2023-11-07 16:06:22 +01:00
abebb79e8b Fix geographical unit stat aggregator by course: show also the course if they are not located within a location 2023-11-07 14:41:56 +01:00
3a269ba953 update changelog 2023-11-07 13:28:11 +01:00
a4a4aa119e Merge branch 'issue182_fix_doublon_bug' into 'master'
Adjust query to transfer relationship from one person to another

See merge request Chill-Projet/chill-bundles!603
2023-11-07 12:26:18 +00:00
139f5a1ff9 Merge branch 'issue182_fix_doublon_bug' of gitlab.com:Chill-Projet/chill-bundles into issue182_fix_doublon_bug 2023-11-07 10:54:36 +01:00
1e43772b17 php cs fixer 2023-11-07 10:54:22 +01:00
c29b356c02 minor change to rerun pipeline 2023-11-07 10:54:22 +01:00
050a2955ca Add a comment 2023-11-07 10:54:22 +01:00
a1132cf82f add changie 2023-11-07 10:54:22 +01:00
db70ce4a61 Adjust query to transfer relationship from one person to another depending on whether original person was in the to or from position 2023-11-07 10:54:22 +01:00
4d20a46717 Fix geographical unit stat aggregator: date range on association with left join 2023-11-06 22:03:37 +01:00
dd75cb695c Fix date range operator in GeographicalUnitStatAggregator 2023-11-06 22:03:08 +01:00
8cb9142800 Release for 2.10.5 2023-11-05 23:50:15 +01:00
4847724f6f temporarily allow failure in phpunit tests, due to a problem with timezone 2023-11-05 23:41:54 +01:00
6280453523 Fix activity date filter: validation of form using RollingDate 2023-11-05 23:29:33 +01:00
68f56671a4 DX: fix data type with new rules for phpstan 2023-11-05 23:19:00 +01:00
dc860d0c46 DX: new CS for new version of php-cs-fixer 2023-11-05 23:14:19 +01:00
6fd80f9f2e [export] fix data type from form: either collection or array 2023-11-05 23:08:13 +01:00
3ce78d0c16 php cs fixer 2023-11-01 10:52:42 +01:00
f43bd2bc58 minor change to rerun pipeline 2023-11-01 09:48:48 +01:00
ec85f05e0b Php cs fixer 2023-10-30 14:09:03 +01:00
bfe0d9a137 Add a comment 2023-10-30 13:52:50 +01:00
cac092c45a add changie 2023-10-30 12:00:25 +01:00
39bb06b991 Adjust query to transfer relationship from one person to another depending on whether original person was in the to or from position 2023-10-30 11:53:41 +01:00
b2aa465b03 unreleased changie file deleted 2023-10-26 17:44:49 +02:00
0fa8944c29 Update changelog 2023-10-26 17:39:55 +02:00
7494dbfc7c changie made 2023-10-26 17:38:22 +02:00
642958bde2 Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles 2023-10-26 17:35:22 +02:00
57bd6d1be4 remove dump 2023-10-26 17:33:39 +02:00
bbcbbf078f remove dump 2023-10-26 17:04:56 +02:00
ba778b1cf8 update changelog 2023-10-26 16:07:34 +02:00
728fd642fa Merge branch 'replace_translator' 2023-10-26 16:05:17 +02:00
4150eb56b4 changie v2.10.2 2023-10-26 15:23:01 +02:00
2927561c02 added changie 2023-10-26 15:22:22 +02:00
5188891108 php style fixer 2023-10-26 15:21:20 +02:00
c6deb21606 replace old method of getting translator with injection of translatorInterface 2023-10-26 15:20:19 +02:00
cdfb084fe4 update changelog 2023-10-26 14:17:15 +02:00
5ce21aadce Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles 2023-10-26 14:14:51 +02:00
b9000a38d3 add changie 2023-10-26 14:14:36 +02:00
89a185a34f replace get->('translator') with injection of translatorInterface 2023-10-26 14:13:12 +02:00
bc6c3a1089 Release: 2.10.1 2023-10-24 20:52:46 +02:00
2c50f484f0 Fix export controller when generating an export without any data in session 2023-10-24 20:46:23 +02:00
4bc1de01d6 Release: version 2.10.0: fix typos and French translation 2023-10-24 18:56:42 +02:00
e21fe70b75 Release: version 2.10.0 2023-10-24 15:50:47 +02:00
461995b56b Merge branch '172-missing-exports' into 'master'
Fix some issues with exports

Closes #172

See merge request Chill-Projet/chill-bundles!601
2023-10-24 13:47:30 +00:00
e635b73256 DX: mark a class as final 2023-10-24 15:39:57 +02:00
54ae17a8d2 Fix label on some filters 2023-10-24 15:39:57 +02:00
617d09ab8a Merge branch '179-remove-filter-by-center-in-exports' into 'master'
Resolve "Export: permettre de ne pas filtrer les résultats par centre"

Closes #179

See merge request Chill-Projet/chill-bundles!599
2023-10-24 13:18:03 +00:00
f8ee2903b2 Merge branch '172-missing-exports' into 'master'
[Export]: add missing grouping and filters and fix some issues

Closes #177 and #172

See merge request Chill-Projet/chill-bundles!598
2023-10-24 13:17:03 +00:00
36b0844e79 Fix issue with duration aggregator as month 2023-10-24 14:17:28 +02:00
7bff5ce39e DX: rename UserScopeFilter to CreatorScopeFilter 2023-10-24 14:17:08 +02:00
4375ecf49a [export controller] skip the page "select a center" when the configuration value of filter_stats_by_center is set to false 2023-10-19 17:43:32 +02:00
a6e930958b [export] create a parameter that will force to skip the filtering by center (ACL) when generating an export 2023-10-19 17:19:28 +02:00
5f805626f7 [export] sort filters and aggregators by title 2023-10-19 14:39:22 +02:00
4c9ea740c8 [export] fix date range selection on filtre and grouping "by status of the course at date" on accompanying periods 2023-10-19 11:44:53 +02:00
981dc6a959 [export] add a filter and aggregator on accompanying periods: group by activity type (accompanying course having at least one activity from this type) 2023-10-19 10:33:56 +02:00
11fb9bcd0b [export] add a filter and aggregator on activities: filter/group by persons taking part to the activity 2023-10-19 10:33:55 +02:00
a4edb34668 [export] add a filter and aggregator on accompanying period work: group/filter by handling third party 2023-10-19 10:33:55 +02:00
f799fe0649 [export] add a grouping of accompanying period by opening and closing date 2023-10-19 10:33:54 +02:00
297 changed files with 9936 additions and 1434 deletions

View File

@@ -0,0 +1,5 @@
kind: Feature
body: '[DX] move async-upload-bundle features into chill-bundles'
time: 2023-12-12T15:48:41.954970271+01:00
custom:
Issue: "221"

20
.changes/v2.10.0.md Normal file
View File

@@ -0,0 +1,20 @@
## v2.10.0 - 2023-10-24
### Feature
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] Add a filter "grouping accompanying period by opening date" and "grouping accompanying period by closing date"
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on accompanying period work: group/filter by handling third party
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on activites: group/filter activities by people participating to the activities
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a grouping on accompanying period export: group by activity type associated to at least one activity within the accompanying period
* [export] sort filters and aggregators by title
* ([#179](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/179)) [export] create a parameter that will force to skip the filtering by center (ACL) when generating an export
### Fixed
* ([#177](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/177)) [export] fix date range selection on filter and grouping "by status of the course at date", on accompanying periods
### Résumé francophone des changements
- Ajout d'un regroupement sur les parcours: par date de cloture et d'ouverture;
- Ajouter d'un filtre et regroupement par tiers traitant sur les actions d'accompagnement;
- ajout d'un filtre et regroupement par usager participant sur les échanges
- ajout d'un regroupement: par type d'activité associé au parcours;
- trie les filtre et regroupements par ordre alphabétique dans els exports
- ajout d'un paramètre qui permet de désactiver le filtre par centre dans les exports
- correction de l'interface de date dans les filtres et regroupements "par statut du parcours à la date"

3
.changes/v2.10.1.md Normal file
View File

@@ -0,0 +1,3 @@
## v2.10.1 - 2023-10-24
### Fixed
* Fix export controller when generating an export without any data in session

3
.changes/v2.10.2.md Normal file
View File

@@ -0,0 +1,3 @@
## v2.10.2 - 2023-10-26
### Fixed
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Use injection of translator instead of ->get().

3
.changes/v2.10.3.md Normal file
View File

@@ -0,0 +1,3 @@
## v2.10.3 - 2023-10-26
### Fixed
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Replace old method of getting translator with injection of translatorInterface

3
.changes/v2.10.4.md Normal file
View File

@@ -0,0 +1,3 @@
## v2.10.4 - 2023-10-26
### Fixed
* Fix null value constraint errors when merging relationships in doubles

4
.changes/v2.10.5.md Normal file
View File

@@ -0,0 +1,4 @@
## v2.10.5 - 2023-11-05
### Fixed
* ([#183](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/183)) Fix "problem during download" on some filters, which used a wrong data type
* ([#184](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/184)) Fix filter "activity by date"

4
.changes/v2.10.6.md Normal file
View File

@@ -0,0 +1,4 @@
## v2.10.6 - 2023-11-07
### Fixed
* ([#182](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/182)) Fix merging of double person files. Adjustement relationship sql statement
* ([#185](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/185)) Export: fix aggregator by geographical unit on person: avoid inconsistencies

6
.changes/v2.11.0.md Normal file
View File

@@ -0,0 +1,6 @@
## v2.11.0 - 2023-11-07
### Feature
* ([#194](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/194)) Export: add a filter "filter activity by creator job"
### Fixed
* ([#185](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/185)) Export: fix "group accompanying period by geographical unit": take into account the accompanying periods when the period is not located within an unit
* Fix "group activity by creator job" aggregator

26
.changes/v2.12.0.md Normal file
View File

@@ -0,0 +1,26 @@
## v2.12.0 - 2023-11-15
### Feature
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add an aggregator "group activities by presence"
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add a filter "filter activity by activity presence"
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add an aggregator "group activities by person" (only for the activities saved in a person context)
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add a new aggregator "group peoples by postal code"
* ([#200](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/200)) Export: split export about person on accompanying period work: one with the people associated with the work, another one with the people associated with the accompanying period
* ([#204](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/204)) Add 3 new filters and 3 new aggregators for work action creator (with jobs and scopes)
* ([#202](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/202)) Create export for the average duration of social work actions
* ([#206](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/206)) Export: add a export which count persons on accompanying period work
* ([#206](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/206)) Export: add an export which count persons on activity
* ([#203](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/203)) Export: add clauses on the social work start date and end date within the filter "Filter accompanying period by accompanying period work"
### Fixed
* Export: fix typo in filter "filter accompanying period work on end date"
* ([#189](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/189)) Export: Fix failure in export linked to household
* ([#205](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/205)) Fix loading of accompanying period work referrers
### Traduction francophone des principaux changements
* export: ajout d'un regroupement "grouper les échanges par présence de l'usager";
* export: ajout d'un filtre "filtre les échanges par présence de l'usager";
* export: ajout d'un regroupement "regrouper les échanges par personne" (seulement pour les échanges enregistrés dans le contexte de l'usager);
* export: ajout d'un regroupement "grouper les usagers par codes postaux"
* export: séparation des exports sur les actions: dans l'un, les filtres des usagers portent sur les usagers concernés par l'action, dans l'autre, les filtres portent sur les usagers concernés par le parcours de l'action;
* export: ajout de 3 nouveaux filtres et regroupements sur le créateur de l'action, son métier et son service;
* export: correction de l'export sur les ménages liés aux parcours;
* correction du chargement des actions d'accompagnement

3
.changes/v2.12.1.md Normal file
View File

@@ -0,0 +1,3 @@
## v2.12.1 - 2023-11-16
### Fixed
* ([#208](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/208)) Export: fix loading of form for "filter action by type, goal and result"

9
.changes/v2.13.0.md Normal file
View File

@@ -0,0 +1,9 @@
## v2.13.0 - 2023-11-21
### Feature
* ([#173](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/173)) Allow user to add a phonenumber to their profile which will be included in automatically generated documents
### Fixed
* ([#211](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/211)) Export: fix loading of "Group activity by type"
* ([#190](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/190)) Export: fix loading of "group activity by reasons"
* ([#213](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/213)) Export: fix usage of some Collection returned instead of array in export filters
* ([#215](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/215)) Use only the string 'both' for gender (with a database migration)
* ([#212](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/212)) Clean the database to make working the "Group people by gender" aggregator

8
.changes/v2.14.0.md Normal file
View File

@@ -0,0 +1,8 @@
## v2.14.0 - 2023-11-24
### 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
### Fixed
* ([#141](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/141)) Export: on filter "action by type goals, and results", restore the fields when editing a saved export
* ([#219](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/219)) Export: fix the list of accompanying period work, when the "calc date" is null
* ([#222](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/222)) Fix rendering of custom fields
* Fix various errors in custom fields administration

5
.changes/v2.14.1.md Normal file
View File

@@ -0,0 +1,5 @@
## 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

11
.changes/v2.15.0.md Normal file
View 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

View File

@@ -11,6 +11,10 @@ cache:
services: services:
- name: postgis/postgis:14-3.3-alpine - name: postgis/postgis:14-3.3-alpine
alias: db alias: db
command:
- postgres
- "-c"
- max_connections=1000
- name: redis - name: redis
alias: redis alias: redis
@@ -28,6 +32,8 @@ variables:
REDIS_PORT: 6379 REDIS_PORT: 6379
REDIS_URL: redis://redis:6379 REDIS_URL: redis://redis:6379
DEFAULT_CARRIER_CODE: BE DEFAULT_CARRIER_CODE: BE
# force a timezone
TZ: Europe/Brussels
stages: stages:
- Composer install - Composer install

View File

@@ -6,6 +6,128 @@ 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.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
### 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
### Fixed
* ([#141](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/141)) Export: on filter "action by type goals, and results", restore the fields when editing a saved export
* ([#219](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/219)) Export: fix the list of accompanying period work, when the "calc date" is null
* ([#222](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/222)) Fix rendering of custom fields
* Fix various errors in custom fields administration
## v2.13.0 - 2023-11-21
### Feature
* ([#173](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/173)) Allow user to add a phonenumber to their profile which will be included in automatically generated documents
### Fixed
* ([#211](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/211)) Export: fix loading of "Group activity by type"
* ([#190](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/190)) Export: fix loading of "group activity by reasons"
* ([#213](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/213)) Export: fix usage of some Collection returned instead of array in export filters
* ([#215](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/215)) Use only the string 'both' for gender (with a database migration)
* ([#212](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/212)) Clean the database to make working the "Group people by gender" aggregator
## v2.12.1 - 2023-11-16
### Fixed
* ([#208](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/208)) Export: fix loading of form for "filter action by type, goal and result"
## v2.12.0 - 2023-11-15
### Feature
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add an aggregator "group activities by presence"
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add a filter "filter activity by activity presence"
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add an aggregator "group activities by person" (only for the activities saved in a person context)
* ([#199](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/199)) Export: add a new aggregator "group peoples by postal code"
* ([#200](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/200)) Export: split export about person on accompanying period work: one with the people associated with the work, another one with the people associated with the accompanying period
* ([#204](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/204)) Add 3 new filters and 3 new aggregators for work action creator (with jobs and scopes)
* ([#202](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/202)) Create export for the average duration of social work actions
* ([#206](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/206)) Export: add a export which count persons on accompanying period work
* ([#206](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/206)) Export: add an export which count persons on activity
* ([#203](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/203)) Export: add clauses on the social work start date and end date within the filter "Filter accompanying period by accompanying period work"
### Fixed
* Export: fix typo in filter "filter accompanying period work on end date"
* ([#189](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/189)) Export: Fix failure in export linked to household
* ([#205](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/205)) Fix loading of accompanying period work referrers
### Traduction francophone des principaux changements
* export: ajout d'un regroupement "grouper les échanges par présence de l'usager";
* export: ajout d'un filtre "filtre les échanges par présence de l'usager";
* export: ajout d'un regroupement "regrouper les échanges par personne" (seulement pour les échanges enregistrés dans le contexte de l'usager);
* export: ajout d'un regroupement "grouper les usagers par codes postaux"
* export: séparation des exports sur les actions: dans l'un, les filtres des usagers portent sur les usagers concernés par l'action, dans l'autre, les filtres portent sur les usagers concernés par le parcours de l'action;
* export: ajout de 3 nouveaux filtres et regroupements sur le créateur de l'action, son métier et son service;
* export: correction de l'export sur les ménages liés aux parcours;
* correction du chargement des actions d'accompagnement
## v2.11.0 - 2023-11-07
### Feature
* ([#194](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/194)) Export: add a filter "filter activity by creator job"
### Fixed
* ([#185](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/185)) Export: fix "group accompanying period by geographical unit": take into account the accompanying periods when the period is not located within an unit
* Fix "group activity by creator job" aggregator
## v2.10.6 - 2023-11-07
### Fixed
* ([#182](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/182)) Fix merging of double person files. Adjustement relationship sql statement
* ([#185](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/185)) Export: fix aggregator by geographical unit on person: avoid inconsistencies
## v2.10.5 - 2023-11-05
### Fixed
* ([#183](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/183)) Fix "problem during download" on some filters, which used a wrong data type
* ([#184](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/184)) Fix filter "activity by date"
## v2.10.4 - 2023-10-26
### Fixed
* Fix null value constraint errors when merging relationships in doubles
## v2.10.3 - 2023-10-26
### Fixed
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Replace old method of getting translator with injection of translatorInterface
## v2.10.2 - 2023-10-26
### Fixed
* ([#175](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/175)) Use injection of translator instead of ->get().
## v2.10.1 - 2023-10-24
### Fixed
* Fix export controller when generating an export without any data in session
## v2.10.0 - 2023-10-24
### Feature
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] Add a filter "grouping accompanying period by opening date" and "grouping accompanying period by closing date"
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on accompanying period work: group/filter by handling third party
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a filter and aggregator on activites: group/filter activities by people participating to the activities
* ([#172](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/172)) [export] add a grouping on accompanying period export: group by activity type associated to at least one activity within the accompanying period
* [export] sort filters and aggregators by title
* ([#179](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/179)) [export] create a parameter that will force to skip the filtering by center (ACL) when generating an export
### Fixed
* ([#177](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/177)) [export] fix date range selection on filter and grouping "by status of the course at date", on accompanying periods
### Résumé francophone des changements
- Ajout d'un regroupement sur les parcours: par date de cloture et d'ouverture;
- Ajouter d'un filtre et regroupement par tiers traitant sur les actions d'accompagnement;
- ajout d'un filtre et regroupement par usager participant sur les échanges
- ajout d'un regroupement: par type d'activité associé au parcours;
- trie les filtre et regroupements par ordre alphabétique dans els exports
- ajout d'un paramètre qui permet de désactiver le filtre par centre dans les exports
- correction de l'interface de date dans les filtres et regroupements "par statut du parcours à la date"
## v2.9.2 - 2023-10-17 ## v2.9.2 - 2023-10-17
### Fixed ### Fixed
* Fix possible null values in string's entities * Fix possible null values in string's entities

View File

@@ -12,7 +12,6 @@
"ext-json": "*", "ext-json": "*",
"ext-openssl": "*", "ext-openssl": "*",
"ext-redis": "*", "ext-redis": "*",
"champs-libres/async-uploader-bundle": "dev-sf4#d57134aee8e504a83c902ff0cf9f8d36ac418290",
"champs-libres/wopi-bundle": "dev-master@dev", "champs-libres/wopi-bundle": "dev-master@dev",
"champs-libres/wopi-lib": "dev-master@dev", "champs-libres/wopi-lib": "dev-master@dev",
"doctrine/doctrine-bundle": "^2.1", "doctrine/doctrine-bundle": "^2.1",

View File

@@ -1,13 +1,15 @@
Configure Chill for calendar sync and SSO with Microsoft Graph (Outlook) Configure Chill for calendar and absence synchronisation and SSO with Microsoft Graph (Outlook)
======================================================================== ===============================================================================================
Chill offers the possibility to: Chill offers the possibility to:
* authenticate users using Microsoft Graph, with relatively small adaptations; * authenticate users using Microsoft Graph, with relatively small adaptations;
* synchronize calendar in both ways (`see the user manual for a large description of the feature <https://gitea.champs-libres.be/Chill-project/manuals>`_). * synchronize calendar in both ways (`see the user manual for a large description of the feature <https://gitea.champs-libres.be/Chill-project/manuals>`_).
Both can be configured separately (synchronising calendars without SSO, or SSO without calendar). When calendar sync is configured without SSL, the user's email address is the key to associate Chill's users with Microsoft's ones. Both can be configured separately (synchronising calendars without SSO, or SSO without calendar).
Please note that the user's email address is the key to associate Chill's users with Microsoft's ones.
Configure SSO Configure SSO
------------- -------------
@@ -46,7 +48,7 @@ Do not forget to provider user's accesses to your app, using the "Utilisateurs e
You must know have gathered all the required variables for SSO: You must know have gathered all the required variables for SSO:
.. code-block:: .. code-block::
SAML_BASE_URL=https://test.chill.be # must be SAML_BASE_URL=https://test.chill.be # must be
SAML_ENTITY_ID=https://test.chill.be # must match the one entered SAML_ENTITY_ID=https://test.chill.be # must match the one entered
@@ -186,20 +188,27 @@ Configure chill app
Configure sync Configure sync and calendar access
-------------- ----------------------------------
The sync processe might be configured in the same app, or into a different app. The purpose of this configuration is the following:
The synchronization processes use Oauth2.0 for authentication and authorization. - let user read their calendar and shared calendar within Chill (with the same permissions as the one configured in Outlook / Azure);
- allow chill instance to write appointment ("Rendez-vous") into their calendar, and invite other users to their appointment;
- allow chill instance to be notified if an appoint is added or removed by the user within another interface than Chill: if the appointment match another one created in the Chill interface, the date and time are updated in Chill;
- allow chill instance to read the absence of the user and, if set, mark the user as absent in Chill;
The sync processe might be configured in the same app, or into a different app on the Azure side.
The synchronization processes use Oauth 2.0 / OpenID Connect for authentication and authorization.
.. note:: .. note::
Two flows are in use: Two flows are in use:
* we authenticate "on behalf of a user", to allow users to see their own calendar or other user's calendar into the web interface. * we authenticate "on behalf of a user", to allow users to see their own calendar or other user's calendar into the web interface.
Typically, when the page is loaded, Chill first check that an authorization token exists. If not, the user is redirected to Microsoft Azure for authentification and a new token is grabbed (most of the times, this is transparent for users). Typically, when the page is loaded, Chill first check that an authorization token exists. If not, the user is redirected to Microsoft Azure for authentification and a new token is grabbed (most of the times, this is transparent for users).
* Chill also acts "as a machine", to synchronize calendars with a daemon background. * Chill also acts "as a machine", to synchronize calendars with a daemon background.
@@ -229,8 +238,9 @@ Some explanation:
The sync daemon must have write access: The sync daemon must have write access:
* the daemon must be allowed to read all users and their profile, to establish a link between them and the Chill's users: (:code:`Users.Read.All`); * the daemon must be allowed to read all users and their profile, to establish a link between them and the Chill's users: (:code:`Users.Read.All`);
* it must also be allowed to read and write into the calendars (:code:`Calendars.ReadWrite.All`) * it must also be allowed to read and write into the calendars (:code:`Calendars.ReadWrite.All`);
* for sending invitation to other users, the permission (:code:`Mail.Send`) must be granted. * for sending invitation to other users, the permission (:code:`Mail.Send`) must be granted;
* and, for reading the absence status of the user and sync it with chill, it must be able to read the mailboxSettings (:code:`MailboxSettings.Read`).
At this step, you might choose to accept those permissions for all users, or let them do it by yourself. At this step, you might choose to accept those permissions for all users, or let them do it by yourself.
@@ -301,7 +311,7 @@ The calendar synchronization is processed using symfony messenger. It seems to b
The association between chill's users and Microsoft's users is done by this cli command: The association between chill's users and Microsoft's users is done by this cli command:
.. code-block:: .. code-block::
bin/console chill:calendar:msgraph-user-map-subscribe bin/console chill:calendar:msgraph-user-map-subscribe

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

After

Width:  |  Height:  |  Size: 166 KiB

View File

@@ -673,8 +673,8 @@ final class ActivityController extends AbstractController
throw $this->createNotFoundException('Accompanying Period not found'); throw $this->createNotFoundException('Accompanying Period not found');
} }
// TODO Add permission // TODO Add permission
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
} else { } else {
throw $this->createNotFoundException('Person or Accompanying Period not found'); throw $this->createNotFoundException('Person or Accompanying Period not found');
} }

View File

@@ -0,0 +1,122 @@
<?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\ActivityBundle\Export\Aggregator\ACPAggregators;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityType;
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
final readonly class ByActivityTypeAggregator implements AggregatorInterface
{
private const PREFIX = 'acp_by_activity_type_agg';
public function __construct(
private RollingDateConverterInterface $rollingDateConverter,
private ActivityTypeRepositoryInterface $activityTypeRepository,
private TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('after_date', PickRollingDateType::class, [
'required' => false,
'label' => 'export.aggregator.acp.by_activity_type.after_date',
])
->add('before_date', PickRollingDateType::class, [
'required' => false,
'label' => 'export.aggregator.acp.by_activity_type.before_date',
]);
}
public function getFormDefaultData(): array
{
return [
'before_date' => null,
'after_date' => null,
];
}
public function getLabels($key, array $values, mixed $data)
{
return function (null|int|string $value): string {
if ('_header' === $value) {
return 'export.aggregator.acp.by_activity_type.activity_type';
}
if ('' === $value || null === $value || null === $activityType = $this->activityTypeRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize($activityType->getName());
};
}
public function getQueryKeys($data)
{
return [self::PREFIX.'_actype_id'];
}
public function getTitle()
{
return 'export.aggregator.acp.by_activity_type.title';
}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
// we make a left join, with acp having at least one activity of the given type
$exists = 'EXISTS (SELECT 1 FROM '.Activity::class." {$p}_activity WHERE {$p}_activity.accompanyingPeriod = acp AND {$p}_activity.activityType = {$p}_activity_type";
if (null !== $data['after_date']) {
$exists .= " AND {$p}_activity.date > :{$p}_after_date";
$qb->setParameter("{$p}_after_date", $this->rollingDateConverter->convert($data['after_date']));
}
if (null !== $data['before_date']) {
$exists .= " AND {$p}_activity.date < :{$p}_before_date";
$qb->setParameter("{$p}_before_date", $this->rollingDateConverter->convert($data['before_date']));
}
$exists .= ')';
$qb->leftJoin(
ActivityType::class,
"{$p}_activity_type",
Join::WITH,
$exists
);
$qb
->addSelect("{$p}_activity_type.id AS {$p}_actype_id")
->addGroupBy("{$p}_actype_id");
}
public function applyOn()
{
return Declarations::ACP_TYPE;
}
}

View File

@@ -0,0 +1,72 @@
<?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\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Repository\ActivityPresenceRepositoryInterface;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
final readonly class ActivityPresenceAggregator implements AggregatorInterface
{
public function __construct(private ActivityPresenceRepositoryInterface $activityPresenceRepository, private TranslatableStringHelperInterface $translatableStringHelper) {}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
}
public function getLabels($key, array $values, mixed $data)
{
return function (null|int|string $value): string {
if ('_header' === $value) {
return 'export.aggregator.activity.by_activity_presence.header';
}
if (null === $value || '' === $value || null === $presence = $this->activityPresenceRepository->find($value)) {
return '';
}
return $this->translatableStringHelper->localize($presence->getName());
};
}
public function getQueryKeys($data)
{
return ['activity_presence_aggregator_attendee'];
}
public function getTitle(): string
{
return 'export.aggregator.activity.by_activity_presence.Group activity by presence';
}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data): void
{
$qb->addSelect('IDENTITY(activity.attendee) AS activity_presence_aggregator_attendee');
$qb->addGroupBy('activity_presence_aggregator_attendee');
}
public function applyOn()
{
return Declarations::ACTIVITY;
}
}

View File

@@ -56,20 +56,15 @@ class ActivityTypeAggregator implements AggregatorInterface
public function getLabels($key, array $values, $data): \Closure public function getLabels($key, array $values, $data): \Closure
{ {
// for performance reason, we load data from db only once return function (null|int|string $value): string {
$this->activityTypeRepository->findBy(['id' => $values]);
return function ($value): string {
if ('_header' === $value) { if ('_header' === $value) {
return 'Activity type'; return 'Activity type';
} }
if (null === $value || '' === $value) { if (null === $value || '' === $value || null === $t = $this->activityTypeRepository->find($value)) {
return ''; return '';
} }
$t = $this->activityTypeRepository->find($value);
return $this->translatableStringHelper->localize($t->getName()); return $this->translatableStringHelper->localize($t->getName());
}; };
} }

View File

@@ -14,18 +14,18 @@ namespace Chill\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class JobScopeAggregator implements AggregatorInterface class CreatorJobAggregator implements AggregatorInterface
{ {
private const PREFIX = 'acp_agg_creator_job'; private const PREFIX = 'acp_agg_creator_job';
public function __construct( public function __construct(
private readonly ScopeRepository $scopeRepository, private readonly UserJobRepositoryInterface $userJobRepository,
private readonly TranslatableStringHelper $translatableStringHelper private readonly TranslatableStringHelper $translatableStringHelper
) {} ) {}
@@ -76,17 +76,15 @@ class JobScopeAggregator implements AggregatorInterface
{ {
return function ($value): string { return function ($value): string {
if ('_header' === $value) { if ('_header' === $value) {
return 'Scope'; return 'Job';
} }
if (null === $value || '' === $value) { if (null === $value || '' === $value || null === $s = $this->userJobRepository->find($value)) {
return ''; return '';
} }
$s = $this->scopeRepository->find($value);
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(
$s->getName() $s->getLabel()
); );
}; };
} }

View File

@@ -73,7 +73,6 @@ class DateAggregator implements AggregatorInterface
'choices' => self::CHOICES, 'choices' => self::CHOICES,
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
'empty_data' => self::DEFAULT_CHOICE,
]); ]);
} }

View File

@@ -99,12 +99,6 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
{ {
match ($data['level']) {
'reasons' => $this->activityReasonRepository->findBy(['id' => $values]),
'categories' => $this->activityReasonCategoryRepository->findBy(['id' => $values]),
default => throw new \RuntimeException(sprintf("The level data '%s' is invalid.", $data['level'])),
};
return function ($value) use ($data) { return function ($value) use ($data) {
if ('_header' === $value) { if ('_header' === $value) {
return 'reasons' === $data['level'] ? 'Group by reasons' : 'Group by categories of reason'; return 'reasons' === $data['level'] ? 'Group by reasons' : 'Group by categories of reason';

View File

@@ -0,0 +1,65 @@
<?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\ActivityBundle\Export\Aggregator\PersonAggregators;
use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
final readonly class PersonAggregator implements AggregatorInterface
{
public function __construct(private LabelPersonHelper $labelPersonHelper) {}
public function buildForm(FormBuilderInterface $builder)
{
// nothing to add here
}
public function getFormDefaultData(): array
{
return [];
}
public function getLabels($key, array $values, mixed $data)
{
return $this->labelPersonHelper->getLabel($key, $values, 'export.aggregator.person.by_person.person');
}
public function getQueryKeys($data)
{
return ['activity_by_person_agg'];
}
public function getTitle()
{
return 'export.aggregator.person.by_person.title';
}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->addSelect('IDENTITY(activity.person) AS activity_by_person_agg')
->addGroupBy('activity_by_person_agg');
}
public function applyOn()
{
return Declarations::ACTIVITY_PERSON;
}
}

View File

@@ -0,0 +1,78 @@
<?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\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Tests\Export\Aggregator\PersonsAggregatorTest;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
/**
* @see PersonsAggregatorTest
*/
final readonly class PersonsAggregator implements AggregatorInterface
{
private const PREFIX = 'act_persons_agg';
public function __construct(private LabelPersonHelper $labelPersonHelper) {}
public function buildForm(FormBuilderInterface $builder)
{
// nothing to add here
}
public function getFormDefaultData(): array
{
return [];
}
public function getLabels($key, array $values, mixed $data)
{
if ($key !== self::PREFIX.'_pid') {
throw new \UnexpectedValueException('this key should not be handled: '.$key);
}
return $this->labelPersonHelper->getLabel($key, $values, 'export.aggregator.activity.by_persons.Persons');
}
public function getQueryKeys($data)
{
return [self::PREFIX.'_pid'];
}
public function getTitle()
{
return 'export.aggregator.activity.by_persons.Group activity by persons';
}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->leftJoin('activity.persons', "{$p}_p")
->addSelect("{$p}_p.id AS {$p}_pid")
->addGroupBy("{$p}_pid");
}
public function applyOn()
{
return Declarations::ACTIVITY;
}
}

View File

@@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Export\Export\LinkedToACP; namespace Chill\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\ExportInterface;
@@ -21,19 +21,19 @@ use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class AvgActivityDuration implements ExportInterface, GroupedExportInterface class AvgActivityDuration implements ExportInterface, GroupedExportInterface
{ {
protected EntityRepository $repository; private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
EntityManagerInterface $em, private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
) { ) {
$this->repository = $em->getRepository(Activity::class); $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
} }
public function buildForm(FormBuilderInterface $builder) {} public function buildForm(FormBuilderInterface $builder) {}
@@ -91,23 +91,25 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
{ {
$centers = array_map(static fn ($el) => $el['center'], $acl); $centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->repository->createQueryBuilder('activity'); $qb = $this->activityRepository->createQueryBuilder('activity');
$qb $qb
->join('activity.accompanyingPeriod', 'acp') ->join('activity.accompanyingPeriod', 'acp')
->select('AVG(activity.durationTime) as export_avg_activity_duration') ->select('AVG(activity.durationTime) as export_avg_activity_duration')
->andWhere($qb->expr()->isNotNull('activity.durationTime')); ->andWhere($qb->expr()->isNotNull('activity.durationTime'));
$qb if ($this->filterStatsByCenters) {
->andWhere( $qb
$qb->expr()->exists( ->andWhere(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part $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) 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) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
' '
)
) )
) ->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers); }
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -24,16 +24,21 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface
{ {
protected EntityRepository $repository; protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) { ) {
$this->repository = $em->getRepository(Activity::class); $this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
@@ -101,16 +106,18 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
->select('AVG(activity.travelTime) as export_avg_activity_visit_duration') ->select('AVG(activity.travelTime) as export_avg_activity_visit_duration')
->andWhere($qb->expr()->isNotNull('activity.travelTime')); ->andWhere($qb->expr()->isNotNull('activity.travelTime'));
$qb if ($this->filterStatsByCenters) {
->andWhere( $qb
$qb->expr()->exists( ->andWhere(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part $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) 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) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
' '
)
) )
) ->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers); }
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -24,16 +24,21 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class CountActivity implements ExportInterface, GroupedExportInterface class CountActivity implements ExportInterface, GroupedExportInterface
{ {
protected EntityRepository $repository; protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) { ) {
$this->repository = $em->getRepository(Activity::class); $this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
} }
public function buildForm(FormBuilderInterface $builder) {} public function buildForm(FormBuilderInterface $builder) {}
@@ -95,16 +100,18 @@ class CountActivity implements ExportInterface, GroupedExportInterface
->createQueryBuilder('activity') ->createQueryBuilder('activity')
->join('activity.accompanyingPeriod', 'acp'); ->join('activity.accompanyingPeriod', 'acp');
$qb if ($this->filterStatsByCenters) {
->andWhere( $qb
$qb->expr()->exists( ->andWhere(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part $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) 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) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
' '
)
) )
) ->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers); }
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -0,0 +1,147 @@
<?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\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
final readonly class CountHouseholdOnActivity implements ExportInterface, GroupedExportInterface
{
private EntityRepository $repository;
private bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
}
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription(): string
{
return 'export.export.count_household_on_activity.description';
}
public function getGroup(): string
{
return 'Exports of activities linked to an accompanying period';
}
public function getLabels($key, array $values, $data)
{
if ('export_count_activity' !== $key) {
throw new \LogicException("the key {$key} is not used by this export");
}
return static fn ($value) => '_header' === $value ? 'export.export.count_household_on_activity.header' : $value;
}
public function getQueryKeys($data): array
{
return ['export_count_activity'];
}
public function getResult($query, $data)
{
return $query->getQuery()->getResult(Query::HYDRATE_SCALAR);
}
public function getTitle(): string
{
return 'export.export.count_household_on_activity.title';
}
public function getType(): string
{
return Declarations::ACTIVITY;
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->repository
->createQueryBuilder('activity')
->join('activity.persons', 'person')
->join('activity.accompanyingPeriod', 'acp')
->join(
HouseholdMember::class,
'householdmember',
Query\Expr\Join::WITH,
'person.id = IDENTITY(householdmember.person) AND householdmember.startDate <= activity.date AND (householdmember.endDate IS NULL OR householdmember.endDate > activity.date)'
)
->join('householdmember.household', 'household');
if ($this->filterStatsByCenters) {
$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);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb->select('COUNT(DISTINCT household.id) as export_count_activity');
return $qb;
}
public function requiredRole(): string
{
return ActivityStatsVoter::STATS;
}
public function supportsModifiers(): array
{
return [
Declarations::ACTIVITY,
Declarations::ACTIVITY_ACP,
PersonDeclarations::ACP_TYPE,
PersonDeclarations::PERSON_TYPE,
PersonDeclarations::HOUSEHOLD_TYPE,
];
}
}

View File

@@ -0,0 +1,138 @@
<?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\ActivityBundle\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
class CountPersonsOnActivity implements ExportInterface, GroupedExportInterface
{
protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct(
EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) {
$this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
}
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription(): string
{
return 'export.export.count_person_on_activity.description';
}
public function getGroup(): string
{
return 'Exports of activities linked to an accompanying period';
}
public function getLabels($key, array $values, $data)
{
if ('export_count_activity' !== $key) {
throw new \LogicException("the key {$key} is not used by this export");
}
return static fn ($value) => '_header' === $value ? 'export.export.count_person_on_activity.header' : $value;
}
public function getQueryKeys($data): array
{
return ['export_count_activity'];
}
public function getResult($query, $data)
{
return $query->getQuery()->getResult(Query::HYDRATE_SCALAR);
}
public function getTitle(): string
{
return 'export.export.count_person_on_activity.title';
}
public function getType(): string
{
return Declarations::ACTIVITY;
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->repository
->createQueryBuilder('activity')
->join('activity.persons', 'person')
->join('activity.accompanyingPeriod', 'acp');
if ($this->filterStatsByCenters) {
$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);
}
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$qb->select('COUNT(DISTINCT person.id) as export_count_activity');
return $qb;
}
public function requiredRole(): string
{
return ActivityStatsVoter::STATS;
}
public function supportsModifiers(): array
{
return [
Declarations::ACTIVITY,
Declarations::ACTIVITY_ACP,
PersonDeclarations::ACP_TYPE,
PersonDeclarations::PERSON_TYPE,
];
}
}

View File

@@ -20,13 +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\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class ListActivity implements ListInterface, GroupedExportInterface final readonly class ListActivity implements ListInterface, GroupedExportInterface
{ {
public function __construct(private readonly ListActivityHelper $helper, private readonly EntityManagerInterface $entityManager, private readonly TranslatableStringExportLabelHelper $translatableStringExportLabelHelper) {} public function __construct(
private ListActivityHelper $helper,
private EntityManagerInterface $entityManager,
private TranslatableStringExportLabelHelper $translatableStringExportLabelHelper,
private FilterListAccompanyingPeriodHelperInterface $filterListAccompanyingPeriodHelper,
) {}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@@ -107,21 +112,15 @@ class ListActivity implements ListInterface, GroupedExportInterface
->join('activity.accompanyingPeriod', 'acp') ->join('activity.accompanyingPeriod', 'acp')
->leftJoin('acp.participations', 'acppart') ->leftJoin('acp.participations', 'acppart')
->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');
->andWhere(
$qb->expr()->exists( $this->filterListAccompanyingPeriodHelper->addFilterAccompanyingPeriods($qb, $requiredModifiers, $acl, $data);
'SELECT 1
FROM '.PersonCenterHistory::class.' acl_count_person_history $qb
WHERE acl_count_person_history.person = person
AND acl_count_person_history.center IN (:authorized_centers)
'
)
)
// some grouping are necessary // some grouping are necessary
->addGroupBy('acp.id') ->addGroupBy('acp.id')
->addOrderBy('activity.date') ->addOrderBy('activity.date')
->addOrderBy('activity.id') ->addOrderBy('activity.id');
->setParameter('authorized_centers', $centers);
$this->helper->addSelect($qb); $this->helper->addSelect($qb);

View File

@@ -24,16 +24,20 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class SumActivityDuration implements ExportInterface, GroupedExportInterface class SumActivityDuration implements ExportInterface, GroupedExportInterface
{ {
protected EntityRepository $repository; protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) { ) {
$this->repository = $em->getRepository(Activity::class); $this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
@@ -101,16 +105,18 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
$qb->select('SUM(activity.durationTime) as export_sum_activity_duration') $qb->select('SUM(activity.durationTime) as export_sum_activity_duration')
->andWhere($qb->expr()->isNotNull('activity.durationTime')); ->andWhere($qb->expr()->isNotNull('activity.durationTime'));
$qb if ($this->filterStatsByCenters) {
->andWhere( $qb
$qb->expr()->exists( ->andWhere(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part $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) 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) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
' '
)
) )
) ->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers); }
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -24,16 +24,20 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface
{ {
protected EntityRepository $repository; protected EntityRepository $repository;
private readonly bool $filterStatsByCenters;
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
ParameterBagInterface $parameterBag,
) { ) {
$this->repository = $em->getRepository(Activity::class); $this->repository = $em->getRepository(Activity::class);
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
@@ -101,16 +105,18 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
$qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration') $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration')
->andWhere($qb->expr()->isNotNull('activity.travelTime')); ->andWhere($qb->expr()->isNotNull('activity.travelTime'));
$qb if ($this->filterStatsByCenters) {
->andWhere( $qb
$qb->expr()->exists( ->andWhere(
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part $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) 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) WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
' '
)
) )
) ->setParameter('authorized_centers', $centers);
->setParameter('authorized_centers', $centers); }
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);

View File

@@ -19,11 +19,19 @@ use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class CountActivity implements ExportInterface, GroupedExportInterface class CountActivity implements ExportInterface, GroupedExportInterface
{ {
public function __construct(protected ActivityRepository $activityRepository) {} private readonly bool $filterStatsByCenters;
public function __construct(
private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {} public function buildForm(FormBuilderInterface $builder) {}
@@ -82,23 +90,25 @@ class CountActivity implements ExportInterface, GroupedExportInterface
$qb = $this->activityRepository $qb = $this->activityRepository
->createQueryBuilder('activity') ->createQueryBuilder('activity')
->join('activity.person', 'person') ->join('activity.person', 'person');
->join('person.centerHistory', 'centerHistory');
$qb->select('COUNT(activity.id) as export_count_activity'); $qb->select('COUNT(activity.id) as export_count_activity');
$qb if ($this->filterStatsByCenters) {
->where( $qb
$qb->expr()->andX( ->join('person.centerHistory', 'centerHistory')
$qb->expr()->lte('centerHistory.startDate', 'activity.date'), ->where(
$qb->expr()->orX( $qb->expr()->andX(
$qb->expr()->isNull('centerHistory.endDate'), $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date') $qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
)
) )
) )
) ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->andWhere($qb->expr()->in('centerHistory.center', ':centers')) ->setParameter('centers', $centers);
->setParameter('centers', $centers); }
return $qb; return $qb;
} }

View File

@@ -0,0 +1,138 @@
<?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\ActivityBundle\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface;
final readonly class CountHouseholdOnActivity implements ExportInterface, GroupedExportInterface
{
private bool $filterStatsByCenters;
public function __construct(
private ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {}
public function getFormDefaultData(): array
{
return [];
}
public function getAllowedFormattersTypes()
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription()
{
return 'export.export.count_household_on_activity_person.description';
}
public function getGroup(): string
{
return 'Exports of activities linked to a person';
}
public function getLabels($key, array $values, $data)
{
if ('export_count_activity' !== $key) {
throw new \LogicException("the key {$key} is not used by this export");
}
return static fn ($value) => '_header' === $value ? 'export.export.count_household_on_activity_person.header' : $value;
}
public function getQueryKeys($data)
{
return ['export_count_activity'];
}
public function getResult($query, $data)
{
return $query->getQuery()->getResult(Query::HYDRATE_SCALAR);
}
public function getTitle()
{
return 'export.export.count_household_on_activity_person.title';
}
public function getType(): string
{
return Declarations::ACTIVITY;
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$qb = $this->activityRepository
->createQueryBuilder('activity')
->join('activity.person', 'person')
->join(
HouseholdMember::class,
'householdmember',
Query\Expr\Join::WITH,
'person = householdmember.person AND householdmember.startDate <= activity.date AND (householdmember.endDate IS NULL OR householdmember.endDate > activity.date)'
)
->join('householdmember.household', 'household');
$qb->select('COUNT(DISTINCT household.id) as export_count_activity');
if ($this->filterStatsByCenters) {
$qb
->join('person.centerHistory', 'centerHistory')
->where(
$qb->expr()->andX(
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
)
)
)
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->setParameter('centers', $centers);
}
return $qb;
}
public function requiredRole(): string
{
return ActivityStatsVoter::STATS;
}
public function supportsModifiers()
{
return [
Declarations::ACTIVITY,
Declarations::ACTIVITY_PERSON,
PersonDeclarations::PERSON_TYPE,
PersonDeclarations::HOUSEHOLD_TYPE,
];
}
}

View File

@@ -23,6 +23,7 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Callback;
@@ -44,8 +45,17 @@ class ListActivity implements ListInterface, GroupedExportInterface
'person_lastname', 'person_lastname',
'person_id', 'person_id',
]; ];
private readonly bool $filterStatsByCenters;
public function __construct(protected EntityManagerInterface $entityManager, protected TranslatorInterface $translator, protected TranslatableStringHelperInterface $translatableStringHelper, private readonly ActivityRepository $activityRepository) {} public function __construct(
protected EntityManagerInterface $entityManager,
protected TranslatorInterface $translator,
protected TranslatableStringHelperInterface $translatableStringHelper,
private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
@@ -188,20 +198,22 @@ class ListActivity implements ListInterface, GroupedExportInterface
$qb $qb
->from('ChillActivityBundle:Activity', 'activity') ->from('ChillActivityBundle:Activity', 'activity')
->join('activity.person', 'actperson') ->join('activity.person', 'actperson');
->join('actperson.centerHistory', 'centerHistory');
$qb->where( if ($this->filterStatsByCenters) {
$qb->expr()->andX( $qb->join('actperson.centerHistory', 'centerHistory');
$qb->expr()->lte('centerHistory.startDate', 'activity.date'), $qb->where(
$qb->expr()->orX( $qb->expr()->andX(
$qb->expr()->isNull('centerHistory.endDate'), $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date') $qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
)
) )
) )
) ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->andWhere($qb->expr()->in('centerHistory.center', ':centers')) ->setParameter('centers', $centers);
->setParameter('centers', $centers); }
foreach ($this->fields as $f) { foreach ($this->fields as $f) {
if (\in_array($f, $data['fields'], true)) { if (\in_array($f, $data['fields'], true)) {

View File

@@ -20,6 +20,7 @@ use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface; use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations; use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
/** /**
@@ -30,17 +31,21 @@ use Symfony\Component\Form\FormBuilderInterface;
class StatActivityDuration implements ExportInterface, GroupedExportInterface class StatActivityDuration implements ExportInterface, GroupedExportInterface
{ {
final public const SUM = 'sum'; final public const SUM = 'sum';
private readonly bool $filterStatsByCenters;
/** /**
* @param string $action the stat to perform * @param string $action the stat to perform
*/ */
public function __construct( public function __construct(
private readonly ActivityRepository $activityRepository, private readonly ActivityRepository $activityRepository,
ParameterBagInterface $parameterBag,
/** /**
* The action for this report. * The action for this report.
*/ */
protected string $action = 'sum' protected string $action = 'sum'
) {} ) {
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
}
public function buildForm(FormBuilderInterface $builder) {} public function buildForm(FormBuilderInterface $builder) {}
@@ -119,21 +124,23 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
} }
$qb->select($select) $qb->select($select)
->join('activity.person', 'person') ->join('activity.person', 'person');
->join('person.centerHistory', 'centerHistory');
$qb if ($this->filterStatsByCenters) {
->where( $qb
$qb->expr()->andX( ->join('person.centerHistory', 'centerHistory')
$qb->expr()->lte('centerHistory.startDate', 'activity.date'), ->where(
$qb->expr()->orX( $qb->expr()->andX(
$qb->expr()->isNull('centerHistory.endDate'), $qb->expr()->lte('centerHistory.startDate', 'activity.date'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date') $qb->expr()->orX(
$qb->expr()->isNull('centerHistory.endDate'),
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
)
) )
) )
) ->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
->andWhere($qb->expr()->in('centerHistory.center', ':centers')) ->setParameter('centers', $centers);
->setParameter('centers', $centers); }
return $qb; return $qb;
} }

View File

@@ -15,17 +15,22 @@ use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Entity\ActivityType;
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class ActivityTypeFilter implements FilterInterface final readonly class ActivityTypeFilter implements FilterInterface
{ {
private const BASE_EXISTS = 'SELECT 1 FROM '.Activity::class.' act_type_filter_activity WHERE act_type_filter_activity.accompanyingPeriod = acp';
public function __construct( public function __construct(
private readonly ActivityTypeRepositoryInterface $activityTypeRepository, private ActivityTypeRepositoryInterface $activityTypeRepository,
private readonly TranslatableStringHelperInterface $translatableStringHelper private TranslatableStringHelperInterface $translatableStringHelper,
private RollingDateConverterInterface $rollingDateConverter,
) {} ) {}
public function addRole(): ?string public function addRole(): ?string
@@ -35,13 +40,26 @@ class ActivityTypeFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data)
{ {
$qb->andWhere( $exists = self::BASE_EXISTS;
$qb->expr()->exists(
'SELECT 1 FROM '.Activity::class.' act_type_filter_activity if (count($data['accepted_activitytypes']) > 0) {
WHERE act_type_filter_activity.activityType IN (:act_type_filter_activity_types) AND act_type_filter_activity.accompanyingPeriod = acp' $exists .= ' AND act_type_filter_activity.activityType IN (:act_type_filter_activity_types)';
) $qb->setParameter('act_type_filter_activity_types', $data['accepted_activitytypes']);
); }
$qb->setParameter('act_type_filter_activity_types', $data['accepted_activitytypes']);
if (null !== $data['date_after']) {
$exists .= ' AND act_type_filter_activity.date >= :act_type_filter_activity_date_after';
$qb->setParameter('act_type_filter_activity_date_after', $this->rollingDateConverter->convert($data['date_after']));
}
if (null !== $data['date_before']) {
$exists .= ' AND act_type_filter_activity.date >= :act_type_filter_activity_date_before';
$qb->setParameter('act_type_filter_activity_date_before', $this->rollingDateConverter->convert($data['date_before']));
}
if (self::BASE_EXISTS !== $exists) {
$qb->andWhere($qb->expr()->exists($exists));
}
} }
public function applyOn() public function applyOn()
@@ -60,11 +78,27 @@ class ActivityTypeFilter implements FilterInterface
'multiple' => true, 'multiple' => true,
'expanded' => true, 'expanded' => true,
]); ]);
$builder->add('date_after', PickRollingDateType::class, [
'label' => 'export.filter.activity.acp_by_activity_type.activity after',
'help' => 'export.filter.activity.acp_by_activity_type.activity after help',
'required' => false,
]);
$builder->add('date_before', PickRollingDateType::class, [
'label' => 'export.filter.activity.acp_by_activity_type.activity before',
'help' => 'export.filter.activity.acp_by_activity_type.activity before help',
'required' => false,
]);
} }
public function getFormDefaultData(): array public function getFormDefaultData(): array
{ {
return []; return [
'accepted_activitytypes' => [],
'date_after' => null,
'date_before' => null,
];
} }
public function describeAction($data, $format = 'string'): array public function describeAction($data, $format = 'string'): array
@@ -75,8 +109,12 @@ class ActivityTypeFilter implements FilterInterface
$types[] = $this->translatableStringHelper->localize($aty->getName()); $types[] = $this->translatableStringHelper->localize($aty->getName());
} }
return ['export.filter.activity.acp_by_activity_type.acp_containing_at_least_one_%activitytypes%', [ return ['export.filter.activity.acp_by_activity_type.acp_containing_at_least_one_activitytypes', [
'%activitytypes%' => implode(', ', $types), 'activitytypes' => implode(', ', $types),
'has_date_after' => null !== $data['date_after'] ? 1 : 0,
'date_after' => $this->rollingDateConverter->convert($data['date_after']),
'has_date_before' => null !== $data['date_before'] ? 1 : 0,
'date_before' => $this->rollingDateConverter->convert($data['date_before']),
]]; ]];
} }

View File

@@ -13,16 +13,12 @@ namespace Chill\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\Export\FilterType;
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 Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class ActivityDateFilter implements FilterInterface class ActivityDateFilter implements FilterInterface
@@ -74,46 +70,6 @@ class ActivityDateFilter implements FilterInterface
->add('date_to', PickRollingDateType::class, [ ->add('date_to', PickRollingDateType::class, [
'label' => 'Activities before this date', 'label' => 'Activities before this date',
]); ]);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/** @var \Symfony\Component\Form\FormInterface $filterForm */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
if (true === $enabled) {
// if the filter is enabled, add some validation
$form = $event->getForm();
$date_from = $form->get('date_from')->getData();
$date_to = $form->get('date_to')->getData();
// check that fields are not empty
if (null === $date_from) {
$form->get('date_from')->addError(new FormError(
$this->translator->trans('This field '
.'should not be empty')
));
}
if (null === $date_to) {
$form->get('date_to')->addError(new FormError(
$this->translator->trans('This field '
.'should not be empty')
));
}
// check that date_from is before date_to
if (
(null !== $date_from && null !== $date_to)
&& $date_from >= $date_to
) {
$form->get('date_to')->addError(new FormError(
$this->translator->trans('This date should be after '
.'the date given in "Implied in an activity after '
.'this date" field')
));
}
}
});
} }
public function getFormDefaultData(): array public function getFormDefaultData(): array

View File

@@ -0,0 +1,82 @@
<?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\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Entity\ActivityPresence;
use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final readonly class ActivityPresenceFilter implements FilterInterface
{
public function __construct(
private TranslatableStringHelperInterface $translatableStringHelper,
private TranslatorInterface $translator
) {}
public function getTitle()
{
return 'export.filter.activity.by_presence.Filter activity by activity presence';
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('presences', EntityType::class, [
'class' => ActivityPresence::class,
'choice_label' => fn (ActivityPresence $presence) => $this->translatableStringHelper->localize($presence->getName())
.($presence->isActive() ? '' : ' ('.$this->translator->trans('inactive').')'),
'multiple' => true,
'expanded' => true,
'label' => 'export.filter.activity.by_presence.presences',
]);
}
public function getFormDefaultData(): array
{
return [];
}
public function describeAction($data, $format = 'string')
{
$presences = array_map(
fn (ActivityPresence $presence) => $this->translatableStringHelper->localize($presence->getName()),
$data['presences'] instanceof Collection ? $data['presences']->toArray() : $data['presences']
);
return [
'export.filter.activity.by_presence.Filtered by activity presence: only %presences%',
['%presences%' => implode(', ', $presences)],
];
}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->andWhere('activity.attendee IN (:activity_presence_filter_presences)')
->setParameter('activity_presence_filter_presences', $data['presences']);
}
public function applyOn()
{
return Declarations::ACTIVITY;
}
}

View File

@@ -80,7 +80,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter
// collect all the reasons'name used in this filter in one array // collect all the reasons'name used in this filter in one array
$reasonsNames = array_map( $reasonsNames = array_map(
fn (ActivityType $t): string => $this->translatableStringHelper->localize($t->getName()), fn (ActivityType $t): string => $this->translatableStringHelper->localize($t->getName()),
$this->activityTypeRepository->findBy(['id' => $data['types']->toArray()]) $this->activityTypeRepository->findBy(['id' => $data['types'] instanceof \Doctrine\Common\Collections\Collection ? $data['types']->toArray() : $data['types']])
); );
return ['Filtered by activity type: only %list%', [ return ['Filtered by activity type: only %list%', [

View File

@@ -0,0 +1,116 @@
<?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\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final readonly class CreatorJobFilter implements FilterInterface
{
private const PREFIX = 'acp_act_filter_creator_job';
public function __construct(
private TranslatableStringHelper $translatableStringHelper,
private TranslatorInterface $translator,
private UserJobRepositoryInterface $userJobRepository,
) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$qb
->leftJoin('activity.createdBy', "{$p}_user")
->leftJoin(
UserJobHistory::class,
"{$p}_history",
Join::WITH,
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
)
// job_at based on activity.date
->andWhere(
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", 'activity.date'),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", 'activity.date')
)
)
)
->andWhere(
$qb->expr()->in("{$p}_history.job", ":{$p}_jobs")
)
->setParameter(
"{$p}_jobs",
$data['jobs'],
);
}
public function applyOn(): string
{
return Declarations::ACTIVITY;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('jobs', EntityType::class, [
'choices' => $this->userJobRepository->findAllOrderedByName(),
'class' => UserJob::class,
'choice_label' => fn (UserJob $s) => $this->translatableStringHelper->localize(
$s->getLabel()
).($s->isActive() ? '' : '('.$this->translator->trans('inactive').')'),
'label' => 'export.filter.activity.by_creator_job.job_form_label',
'multiple' => true,
'expanded' => true,
]);
}
public function describeAction($data, $format = 'string'): array
{
$jobs = array_map(
fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
$data['jobs'] instanceof Collection ? $data['jobs']->toArray() : $data['jobs']
);
return ['export.filter.activity.by_creator_job.Filtered activity by user job: only %jobs%', [
'%jobs%' => implode(', ', $jobs),
]];
}
public function getFormDefaultData(): array
{
return [
'jobs' => [],
];
}
public function getTitle(): string
{
return 'export.filter.activity.by_creator_job.Filter activity by user job';
}
}

View File

@@ -21,9 +21,9 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class UserScopeFilter implements FilterInterface class CreatorScopeFilter implements FilterInterface
{ {
private const PREFIX = 'acp_act_filter_user_scope'; // creator ? cfr translation private const PREFIX = 'acp_act_filter_creator_scope';
public function __construct( public function __construct(
private readonly TranslatableStringHelper $translatableStringHelper private readonly TranslatableStringHelper $translatableStringHelper
@@ -39,7 +39,7 @@ class UserScopeFilter implements FilterInterface
$p = self::PREFIX; $p = self::PREFIX;
$qb $qb
->leftJoin('activity.user', "{$p}_user") // createdBy ? cfr translation ->leftJoin('activity.createdBy', "{$p}_user")
->leftJoin( ->leftJoin(
UserScopeHistory::class, UserScopeHistory::class,
"{$p}_history", "{$p}_history",

View File

@@ -17,6 +17,7 @@ use Chill\ActivityBundle\Repository\ActivityReasonRepository;
use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -79,7 +80,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
// collect all the reasons'name used in this filter in one array // collect all the reasons'name used in this filter in one array
$reasonsNames = array_map( $reasonsNames = array_map(
fn (ActivityReason $r): string => '"'.$this->translatableStringHelper->localize($r->getName()).'"', fn (ActivityReason $r): string => '"'.$this->translatableStringHelper->localize($r->getName()).'"',
$this->activityReasonRepository->findBy(['id' => $data['reasons']->toArray()]) $this->activityReasonRepository->findBy(['id' => $data['reasons'] instanceof Collection ? $data['reasons']->toArray() : $data['reasons']])
); );
return [ return [

View File

@@ -0,0 +1,87 @@
<?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\ActivityBundle\Export\Filter;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Tests\Export\Filter\PersonsFilterTest;
use Chill\MainBundle\Export\FilterInterface;
use Chill\PersonBundle\Form\Type\PickPersonDynamicType;
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
/**
* @see PersonsFilterTest
*/
final readonly class PersonsFilter implements FilterInterface
{
private const PREFIX = 'act_persons_filter';
public function __construct(private PersonRenderInterface $personRender) {}
public function addRole(): ?string
{
return null;
}
public function alterQuery(QueryBuilder $qb, $data)
{
$p = self::PREFIX;
$orX = $qb->expr()->orX();
foreach (array_values($data['accepted_persons']) as $key => $person) {
$orX->add($qb->expr()->isMemberOf(":{$p}_p_{$key}", 'activity.persons'));
$qb->setParameter(":{$p}_p_{$key}", $person);
}
$qb->andWhere($orX);
}
public function applyOn()
{
return Declarations::ACTIVITY;
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('accepted_persons', PickPersonDynamicType::class, [
'multiple' => true,
'label' => 'export.filter.activity.by_persons.persons taking part on the activity',
]);
}
public function getFormDefaultData(): array
{
return [
'accepted_persons' => [],
];
}
public function describeAction($data, $format = 'string')
{
$users = [];
foreach ($data['accepted_persons'] as $u) {
$users[] = $this->personRender->renderString($u, []);
}
return ['export.filter.activity.by_persons.Filtered activity by persons: only %persons%', [
'%persons%' => implode(', ', $users),
]];
}
public function getTitle(): string
{
return 'export.filter.activity.by_persons.Filter activity by persons';
}
}

View File

@@ -23,8 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class SentReceivedFilter implements FilterInterface class SentReceivedFilter implements FilterInterface
{ {
private const CHOICES = [ private const CHOICES = [
'is sent' => Activity::SENTRECEIVED_SENT, 'export.filter.activity.by_sent_received.is sent' => Activity::SENTRECEIVED_SENT,
'is received' => Activity::SENTRECEIVED_RECEIVED, 'export.filter.activity.by_sent_received.is received' => Activity::SENTRECEIVED_RECEIVED,
]; ];
private const DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT; private const DEFAULT_CHOICE = Activity::SENTRECEIVED_SENT;
@@ -64,6 +64,7 @@ class SentReceivedFilter implements FilterInterface
'multiple' => false, 'multiple' => false,
'expanded' => true, 'expanded' => true,
'empty_data' => self::DEFAULT_CHOICE, 'empty_data' => self::DEFAULT_CHOICE,
'label' => 'export.filter.activity.by_sent_received.Sent or received',
]); ]);
} }

View File

@@ -17,6 +17,7 @@ use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@@ -80,7 +81,7 @@ class UsersJobFilter implements FilterInterface
', ', ', ',
array_map( array_map(
fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()), fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
$data['jobs']->toArray() $data['jobs'] instanceof Collection ? $data['jobs']->toArray() : $data['jobs']
) )
), ),
]]; ]];

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\ScopeRepositoryInterface; use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@@ -83,7 +84,7 @@ class UsersScopeFilter implements FilterInterface
', ', ', ',
array_map( array_map(
fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
$data['scopes']->toArray() $data['scopes'] instanceof Collection ? $data['scopes']->toArray() : $data['scopes']
) )
), ),
]]; ]];

View File

@@ -0,0 +1,87 @@
<?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\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByActivityTypeAggregator;
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ByActivityTypeAggregatorTest extends AbstractAggregatorTest
{
private RollingDateConverterInterface $rollingDateConverter;
private ActivityTypeRepositoryInterface $activityTypeRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
$this->activityTypeRepository = self::$container->get(ActivityTypeRepositoryInterface::class);
$this->translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
}
public function getAggregator()
{
return new ByActivityTypeAggregator(
$this->rollingDateConverter,
$this->activityTypeRepository,
$this->translatableStringHelper,
);
}
public function getFormData()
{
return [
[
'after_date' => null,
'before_date' => null,
],
[
'after_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
'before_date' => null,
],
[
'after_date' => null,
'before_date' => new RollingDate(RollingDate::T_TODAY),
],
[
'after_date' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
'before_date' => new RollingDate(RollingDate::T_TODAY),
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(distinct acp.id)')
->from(AccompanyingPeriod::class, 'acp'),
];
}
}

View File

@@ -0,0 +1,62 @@
<?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\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ActivityPresenceAggregator;
use Chill\ActivityBundle\Repository\ActivityPresenceRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class ActivityPresenceAggregatorTest extends AbstractAggregatorTest
{
private TranslatableStringHelperInterface $translatableStringHelper;
private ActivityPresenceRepositoryInterface $activityPresenceRepository;
protected function setUp(): void
{
self::bootKernel();
$this->translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
$this->activityPresenceRepository = self::$container->get(ActivityPresenceRepositoryInterface::class);
}
public function getAggregator()
{
return new ActivityPresenceAggregator($this->activityPresenceRepository, $this->translatableStringHelper);
}
public function getFormData()
{
return [
[],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity'),
];
}
}

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Aggregator; namespace Chill\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\JobScopeAggregator; use Chill\ActivityBundle\Export\Aggregator\CreatorJobAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@@ -21,15 +21,15 @@ use Doctrine\ORM\EntityManagerInterface;
* *
* @coversNothing * @coversNothing
*/ */
final class JobScopeAggregatorTest extends AbstractAggregatorTest final class CreatorJobAggregatorTest extends AbstractAggregatorTest
{ {
private JobScopeAggregator $aggregator; private CreatorJobAggregator $aggregator;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->aggregator = self::$container->get(JobScopeAggregator::class); $this->aggregator = self::$container->get(CreatorJobAggregator::class);
} }
public function getAggregator() public function getAggregator()

View File

@@ -0,0 +1,57 @@
<?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\ActivityBundle\Tests\Export\Aggregator\PersonAggregators;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\PersonAggregators\PersonAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class PersonAggregatorTest extends AbstractAggregatorTest
{
private LabelPersonHelper $labelPersonHelper;
protected function setUp(): void
{
self::bootKernel();
$this->labelPersonHelper = self::$container->get(LabelPersonHelper::class);
}
public function getAggregator()
{
return new PersonAggregator($this->labelPersonHelper);
}
public function getFormData()
{
return [[]];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity'),
];
}
}

View File

@@ -0,0 +1,60 @@
<?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\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\PersonsAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class PersonsAggregatorTest extends AbstractAggregatorTest
{
private LabelPersonHelper $labelPersonHelper;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->labelPersonHelper = self::$container->get(LabelPersonHelper::class);
}
public function getAggregator()
{
return new PersonsAggregator($this->labelPersonHelper);
}
public function getFormData()
{
return [
[],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity'),
];
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP; namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityDuration; use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityDuration;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
/** /**
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/ */
final class AvgActivityDurationTest extends AbstractExportTest final class AvgActivityDurationTest extends AbstractExportTest
{ {
private AvgActivityDuration $export;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->export = self::$container->get('chill.activity.export.avg_activity_duration_linked_to_acp');
} }
public function getExport() public function getExport()
{ {
return $this->export; $activityRepository = self::$container->get(ActivityRepository::class);
yield new AvgActivityDuration($activityRepository, $this->getParameters(true));
yield new AvgActivityDuration($activityRepository, $this->getParameters(false));
} }
public function getFormData(): array public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityVisitDuration; use Chill\ActivityBundle\Export\Export\LinkedToACP\AvgActivityVisitDuration;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/** /**
* @internal * @internal
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/ */
final class AvgActivityVisitDurationTest extends AbstractExportTest final class AvgActivityVisitDurationTest extends AbstractExportTest
{ {
private AvgActivityVisitDuration $export;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->export = self::$container->get('chill.activity.export.avg_activity_visit_duration_linked_to_acp');
} }
public function getExport() public function getExport()
{ {
return $this->export; $em = self::$container->get(EntityManagerInterface::class);
yield new AvgActivityVisitDuration($em, $this->getParameters(true));
yield new AvgActivityVisitDuration($em, $this->getParameters(false));
} }
public function getFormData(): array public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity; use Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/** /**
* @internal * @internal
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/ */
final class CountActivityTest extends AbstractExportTest final class CountActivityTest extends AbstractExportTest
{ {
private CountActivity $export;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->export = self::$container->get('chill.activity.export.count_activity_linked_to_acp');
} }
public function getExport() public function getExport()
{ {
return $this->export; $em = self::$container->get(EntityManagerInterface::class);
yield new CountActivity($em, $this->getParameters(true));
yield new CountActivity($em, $this->getParameters(false));
} }
public function getFormData(): array public function getFormData(): array

View File

@@ -0,0 +1,60 @@
<?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\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Export\Export\LinkedToACP\CountHouseholdOnActivity;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class CountHouseholdOnActivityTest extends AbstractExportTest
{
private EntityManagerInterface $entityManager;
protected function setUp(): void
{
self::bootKernel();
$this->entityManager = self::$container->get(EntityManagerInterface::class);
}
public function getExport()
{
yield new CountHouseholdOnActivity($this->entityManager, $this->getParameters(true));
yield new CountHouseholdOnActivity($this->entityManager, $this->getParameters(false));
}
public function getFormData()
{
return [
[],
];
}
public function getModifiersCombination()
{
return [
[
Declarations::ACTIVITY,
Declarations::ACTIVITY_ACP,
PersonDeclarations::ACP_TYPE,
PersonDeclarations::PERSON_TYPE,
PersonDeclarations::HOUSEHOLD_TYPE,
],
];
}
}

View File

@@ -0,0 +1,54 @@
<?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\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Export\Export\LinkedToACP\CountPersonsOnActivity;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class CountPersonsOnActivityTest extends AbstractExportTest
{
protected function setUp(): void
{
self::bootKernel();
}
public function getExport()
{
$em = self::$container->get(EntityManagerInterface::class);
yield new CountPersonsOnActivity($em, $this->getParameters(true));
yield new CountPersonsOnActivity($em, $this->getParameters(false));
}
public function getFormData()
{
return [[]];
}
public function getModifiersCombination()
{
return [[
Declarations::ACTIVITY,
Declarations::ACTIVITY_ACP,
PersonDeclarations::ACP_TYPE,
PersonDeclarations::PERSON_TYPE,
]];
}
}

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityDuration; use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityDuration;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/** /**
* @internal * @internal
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/ */
final class SumActivityDurationTest extends AbstractExportTest final class SumActivityDurationTest extends AbstractExportTest
{ {
private SumActivityDuration $export;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->export = self::$container->get('chill.activity.export.sum_activity_duration_linked_to_acp');
} }
public function getExport() public function getExport()
{ {
return $this->export; $em = self::$container->get(EntityManagerInterface::class);
yield new SumActivityDuration($em, $this->getParameters(true));
yield new SumActivityDuration($em, $this->getParameters(false));
} }
public function getFormData(): array public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToACP;
use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityVisitDuration; use Chill\ActivityBundle\Export\Export\LinkedToACP\SumActivityVisitDuration;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
/** /**
* @internal * @internal
@@ -32,7 +33,10 @@ final class SumActivityVisitDurationTest extends AbstractExportTest
public function getExport() public function getExport()
{ {
return $this->export; $em = self::$container->get(EntityManagerInterface::class);
yield new SumActivityVisitDuration($em, $this->getParameters(true));
yield new SumActivityVisitDuration($em, $this->getParameters(false));
} }
public function getFormData(): array public function getFormData(): array

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson; namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity; use Chill\ActivityBundle\Export\Export\LinkedToPerson\CountActivity;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
/** /**
@@ -21,18 +22,17 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/ */
final class CountActivityTest extends AbstractExportTest final class CountActivityTest extends AbstractExportTest
{ {
private CountActivity $export;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->export = self::$container->get('chill.activity.export.count_activity_linked_to_person');
} }
public function getExport() public function getExport()
{ {
return $this->export; $activityRepository = self::$container->get(ActivityRepository::class);
yield new CountActivity($activityRepository, $this->getParameters(true));
yield new CountActivity($activityRepository, $this->getParameters(false));
} }
public function getFormData(): array public function getFormData(): array

View File

@@ -0,0 +1,59 @@
<?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\ActivityBundle\Tests\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Declarations;
use Chill\ActivityBundle\Export\Export\LinkedToPerson\CountHouseholdOnActivity;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
/**
* @internal
*
* @coversNothing
*/
class CountHouseholdOnActivityTest extends AbstractExportTest
{
private ActivityRepository $activityRepository;
protected function setUp(): void
{
self::bootKernel();
$this->activityRepository = self::$container->get(ActivityRepository::class);
}
public function getExport()
{
yield new CountHouseholdOnActivity($this->activityRepository, $this->getParameters(true));
yield new CountHouseholdOnActivity($this->activityRepository, $this->getParameters(false));
}
public function getFormData()
{
return [
[],
];
}
public function getModifiersCombination()
{
return [
[
Declarations::ACTIVITY,
Declarations::ACTIVITY_PERSON,
PersonDeclarations::PERSON_TYPE,
PersonDeclarations::HOUSEHOLD_TYPE,
],
];
}
}

View File

@@ -12,8 +12,12 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson; namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity; use Chill\ActivityBundle\Export\Export\LinkedToPerson\ListActivity;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Contracts\Translation\TranslatorInterface;
/** /**
* @internal * @internal
@@ -24,14 +28,12 @@ final class ListActivityTest extends AbstractExportTest
{ {
use ProphecyTrait; use ProphecyTrait;
private ListActivity $export; private readonly ListActivity $export;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->export = self::$container->get('chill.activity.export.list_activity_linked_to_person');
$request = $this->prophesize() $request = $this->prophesize()
->willExtend(\Symfony\Component\HttpFoundation\Request::class); ->willExtend(\Symfony\Component\HttpFoundation\Request::class);
@@ -43,7 +45,26 @@ final class ListActivityTest extends AbstractExportTest
public function getExport() public function getExport()
{ {
return $this->export; $em = self::$container->get(EntityManagerInterface::class);
$translator = self::$container->get(TranslatorInterface::class);
$translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
$activityRepository = self::$container->get(ActivityRepository::class);
yield new ListActivity(
$em,
$translator,
$translatableStringHelper,
$activityRepository,
$this->getParameters(true)
);
yield new ListActivity(
$em,
$translator,
$translatableStringHelper,
$activityRepository,
$this->getParameters(false)
);
} }
public function getFormData() public function getFormData()

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson; namespace Chill\ActivityBundle\Tests\Export\Export\LinkedToPerson;
use Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration; use Chill\ActivityBundle\Export\Export\LinkedToPerson\StatActivityDuration;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Test\Export\AbstractExportTest; use Chill\MainBundle\Test\Export\AbstractExportTest;
/** /**
@@ -23,18 +24,18 @@ use Chill\MainBundle\Test\Export\AbstractExportTest;
*/ */
final class StatActivityDurationTest extends AbstractExportTest final class StatActivityDurationTest extends AbstractExportTest
{ {
private StatActivityDuration $export; private readonly StatActivityDuration $export;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->export = self::$container->get('chill.activity.export.sum_activity_duration_linked_to_person');
} }
public function getExport() public function getExport()
{ {
return $this->export; $activityRepository = self::$container->get(ActivityRepository::class);
yield new StatActivityDuration($activityRepository, $this->getParameters(true), 'sum');
yield new StatActivityDuration($activityRepository, $this->getParameters(false), 'sum');
} }
public function getFormData(): array public function getFormData(): array

View File

@@ -13,6 +13,7 @@ namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Entity\ActivityType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
@@ -55,8 +56,30 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
$data = []; $data = [];
foreach ($array as $a) { foreach ($array as $a) {
$data[] = [
'accepted_activitytypes' => [],
'date_after' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
'date_before' => new RollingDate(RollingDate::T_TODAY),
];
$data[] = [ $data[] = [
'accepted_activitytypes' => new ArrayCollection([$a]), 'accepted_activitytypes' => new ArrayCollection([$a]),
'date_after' => null,
'date_before' => null,
];
$data[] = [
'accepted_activitytypes' => [$a],
'date_after' => null,
'date_before' => null,
];
$data[] = [
'accepted_activitytypes' => [$a],
'date_after' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
'date_before' => new RollingDate(RollingDate::T_TODAY),
];
$data[] = [
'accepted_activitytypes' => [],
'date_after' => null,
'date_before' => null,
]; ];
} }

View File

@@ -0,0 +1,76 @@
<?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\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ActivityPresenceFilter;
use Chill\ActivityBundle\Repository\ActivityPresenceRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @internal
*
* @coversNothing
*/
class ActivityPresenceFilterTest extends AbstractFilterTest
{
private TranslatableStringHelperInterface $translatableStringHelper;
private TranslatorInterface $translator;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->translator = self::$container->get(TranslatorInterface::class);
$this->translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
}
public function getFilter()
{
return new ActivityPresenceFilter($this->translatableStringHelper, $this->translator);
}
public function getFormData()
{
self::bootKernel();
$presences = self::$container->get(ActivityPresenceRepositoryInterface::class)
->findAll();
return [
[
'presences' => $presences,
],
[
'presences' => new ArrayCollection($presences),
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
yield $em->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity');
self::ensureKernelShutdown();
}
}

View File

@@ -52,6 +52,7 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
public function getFormData() public function getFormData()
{ {
self::bootKernel(); self::bootKernel();
$data = [];
$em = self::$container $em = self::$container
->get(EntityManagerInterface::class); ->get(EntityManagerInterface::class);
@@ -62,10 +63,13 @@ final class ActivityReasonFilterTest extends AbstractFilterTest
// generate an array of 5 different combination of results // generate an array of 5 different combination of results
for ($i = 0; 5 > $i; ++$i) { for ($i = 0; 5 > $i; ++$i) {
yield ['reasons' => new ArrayCollection(array_splice($reasons, ($i + 1) * -1))]; $data[] = ['reasons' => new ArrayCollection(array_splice($reasons, ($i + 1) * -1))];
$data[] = ['reasons' => array_splice($reasons, ($i + 1) * -1)];
} }
self::ensureKernelShutdown(); self::ensureKernelShutdown();
return $data;
} }
public function getQueryBuilders(): iterable public function getQueryBuilders(): iterable

View File

@@ -57,6 +57,9 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
$data[] = [ $data[] = [
'types' => new ArrayCollection([$a]), 'types' => new ArrayCollection([$a]),
]; ];
/*$data[] = [
'types' => [$a],
];*/
} }
return $data; return $data;

View File

@@ -0,0 +1,75 @@
<?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\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\CreatorJobFilter;
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @internal
*
* @coversNothing
*/
class CreatorJobFilterTest extends AbstractFilterTest
{
private EntityManagerInterface $entityManager;
private TranslatableStringHelperInterface $translatableStringHelper;
private TranslatorInterface $translator;
private UserJobRepositoryInterface $userJobRepository;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->entityManager = self::$container->get(EntityManagerInterface::class);
$this->translatableStringHelper = self::$container->get(TranslatableStringHelperInterface::class);
$this->translator = self::$container->get(TranslatorInterface::class);
$this->userJobRepository = self::$container->get(UserJobRepositoryInterface::class);
}
public function getFilter()
{
return new CreatorJobFilter(
$this->translatableStringHelper,
$this->translator,
$this->userJobRepository
);
}
public function getFormData()
{
$this->setUp();
$jobs = $this->userJobRepository->findAll();
return [
['jobs' => $jobs],
];
}
public function getQueryBuilders()
{
self::setUp();
return [
$this->entityManager->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity')
->join('activity.user', 'actuser'),
];
}
}

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Filter; namespace Chill\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\UserScopeFilter; use Chill\ActivityBundle\Export\Filter\CreatorScopeFilter;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@@ -22,15 +22,15 @@ use Doctrine\ORM\EntityManagerInterface;
* *
* @coversNothing * @coversNothing
*/ */
final class UserScopeFilterTest extends AbstractFilterTest final class CreatorScopeFilterTest extends AbstractFilterTest
{ {
private UserScopeFilter $filter; private CreatorScopeFilter $filter;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->filter = self::$container->get(UserScopeFilter::class); $this->filter = self::$container->get(CreatorScopeFilter::class);
} }
public function getFilter() public function getFilter()

View File

@@ -0,0 +1,72 @@
<?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\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\PersonsFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class PersonsFilterTest extends AbstractFilterTest
{
private PersonRenderInterface $personRender;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->personRender = self::$container->get(PersonRenderInterface::class);
}
public function getFilter()
{
return new PersonsFilter($this->personRender);
}
public function getFormData()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$persons = $em->createQuery('SELECT p FROM '.Person::class.' p ')
->setMaxResults(2)
->getResult();
self::ensureKernelShutdown();
return [
[
'accepted_persons' => $persons,
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
yield $em->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity');
self::ensureKernelShutdown();
}
}

View File

@@ -16,6 +16,18 @@ services:
tags: tags:
- { name: chill.export, alias: 'list_activity_linked_to_person' } - { name: chill.export, alias: 'list_activity_linked_to_person' }
Chill\ActivityBundle\Export\Export\LinkedToACP\CountPersonsOnActivity:
tags:
- { name: chill.export, alias: 'count_person_on_activity' }
Chill\ActivityBundle\Export\Export\LinkedToACP\CountHouseholdOnActivity:
tags:
- { name: chill.export, alias: 'count_household_on_activity_acp' }
Chill\ActivityBundle\Export\Export\LinkedToPerson\CountHouseholdOnActivity:
tags:
- { name: chill.export, alias: 'count_household_on_activity_person' }
chill.activity.export.count_activity_linked_to_acp: chill.activity.export.count_activity_linked_to_acp:
class: Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity class: Chill\ActivityBundle\Export\Export\LinkedToACP\CountActivity
tags: tags:
@@ -109,10 +121,16 @@ services:
tags: tags:
- { name: chill.export_filter, alias: 'activity_user_filter' } - { name: chill.export_filter, alias: 'activity_user_filter' }
Chill\ActivityBundle\Export\Filter\UserScopeFilter: Chill\ActivityBundle\Export\Filter\CreatorScopeFilter:
tags: tags:
# WARNING: for backward compatibility reason, the alias is named with userscope. Changing this will
# affect all saved exports (unless we write a migration for that)
- { name: chill.export_filter, alias: 'activity_userscope_filter' } - { name: chill.export_filter, alias: 'activity_userscope_filter' }
Chill\ActivityBundle\Export\Filter\CreatorJobFilter:
tags:
- { name: chill.export_filter, alias: 'activity_creatorjob_filter' }
Chill\ActivityBundle\Export\Filter\UsersJobFilter: Chill\ActivityBundle\Export\Filter\UsersJobFilter:
tags: tags:
- { name: chill.export_filter, alias: 'activity_usersjob_filter' } - { name: chill.export_filter, alias: 'activity_usersjob_filter' }
@@ -129,6 +147,11 @@ services:
tags: tags:
- { name: chill.export_filter, alias: 'period_having_activity_betw_dates_filter' } - { name: chill.export_filter, alias: 'period_having_activity_betw_dates_filter' }
Chill\ActivityBundle\Export\Filter\ActivityPresenceFilter:
tags:
- { name: chill.export_filter, alias: 'activity_presence_filter' }
## Aggregators ## Aggregators
Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator: Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator:
tags: tags:
@@ -177,7 +200,7 @@ services:
tags: tags:
- { name: chill.export_aggregator, alias: activity_creator_scope_aggregator } - { name: chill.export_aggregator, alias: activity_creator_scope_aggregator }
Chill\ActivityBundle\Export\Aggregator\JobScopeAggregator: Chill\ActivityBundle\Export\Aggregator\CreatorJobAggregator:
tags: tags:
- { name: chill.export_aggregator, alias: activity_creator_job_aggregator } - { name: chill.export_aggregator, alias: activity_creator_job_aggregator }
@@ -200,3 +223,23 @@ services:
Chill\ActivityBundle\Export\Aggregator\SentReceivedAggregator: Chill\ActivityBundle\Export\Aggregator\SentReceivedAggregator:
tags: tags:
- { name: chill.export_aggregator, alias: activity_sentreceived_aggregator } - { name: chill.export_aggregator, alias: activity_sentreceived_aggregator }
Chill\ActivityBundle\Export\Filter\PersonsFilter:
tags:
- { name: chill.export_filter, alias: activity_by_persons_filter }
Chill\ActivityBundle\Export\Aggregator\PersonsAggregator:
tags:
- { name: chill.export_aggregator, alias: activity_by_persons_aggregator }
Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByActivityTypeAggregator:
tags:
- { name: chill.export_aggregator, alias: acp_by_activity_type_aggregator }
Chill\ActivityBundle\Export\Aggregator\ActivityPresenceAggregator:
tags:
- { name: chill.export_aggregator, alias: activity_presence_agg }
Chill\ActivityBundle\Export\Aggregator\PersonAggregators\PersonAggregator:
tags:
- { name: chill.export_aggregator, alias: activity_person_agg }

View File

@@ -3,7 +3,12 @@ export:
activity: activity:
course_having_activity_between_date: course_having_activity_between_date:
Only course having an activity between from and to: Seulement les parcours ayant reçu au moins un échange entre le {from, date, short} et le {to, date, short} Only course having an activity between from and to: Seulement les parcours ayant reçu au moins un échange entre le {from, date, short} et le {to, date, short}
person_between_dates:
acp_by_activity_type:
'acp_containing_at_least_one_activitytypes': >-
Parcours filtrés: uniquement ceux qui contiennent au moins un échange d'un des types suivants: {activitytypes}
{has_date_after, select, 1 {, après le {date_after, date}} other {}}
{has_date_before, select, 1 {, avant le {date_before, date}} other {}}
describe_action_with_no_subject: >- describe_action_with_no_subject: >-
Filtré par personne ayant eu un échange entre le {date_from, date} et le {date_to, date} Filtré par personne ayant eu un échange entre le {date_from, date} et le {date_to, date}
describe_action_with_subject: >- describe_action_with_subject: >-

View File

@@ -275,7 +275,7 @@ Filter activity by linked socialaction: Filtrer les échanges par action liée
'Filtered activity by linked socialaction: only %actions%': "Filtré par action liée: uniquement %actions%" 'Filtered activity by linked socialaction: only %actions%': "Filtré par action liée: uniquement %actions%"
Filter activity by linked socialissue: Filtrer les échanges par problématique liée Filter activity by linked socialissue: Filtrer les échanges par problématique liée
'Filtered activity by linked socialissue: only %issues%': "Filtré par problématique liée: uniquement %issues%" 'Filtered activity by linked socialissue: only %issues%': "Filtré par problématique liée: uniquement %issues%"
Filter activity by user: Filtrer les échanges par créateur Filter activity by user: Filtrer les échanges par utilisateur principal
Filter activity by users: Filtrer les échanges par utilisateur participant Filter activity by users: Filtrer les échanges par utilisateur participant
Filter activity by creator: Filtrer les échanges par créateur de l'échange Filter activity by creator: Filtrer les échanges par créateur de l'échange
'Filtered activity by user: only %users%': "Filtré par référent: uniquement %users%" 'Filtered activity by user: only %users%': "Filtré par référent: uniquement %users%"
@@ -332,6 +332,19 @@ docgen:
myWorksOnly: Prendre en compte uniquement les actions d'accompagnement dont je suis référent myWorksOnly: Prendre en compte uniquement les actions d'accompagnement dont je suis référent
export: export:
export:
count_person_on_activity:
title: Nombre d'usagers concernés par les échanges
description: Compte le nombre d'usagers concernés par les échanges. Si un usager est présent dans plusieurs échanges, il n'est comptabilisé qu'une seule fois.
header: Nombre d'usagers concernés par des échanges
count_household_on_activity:
title: Nombre de ménages concernés par les échanges
description: Compte le nombre de ménages concernés par les échanges. Si un ménage est présent dans plusieurs échanges, il n'est comptabilisé qu'une seule fois. Les usagers sans ménages ne sont pas comptabilisés.
header: Nombre de ménage concernés par des échanges
count_household_on_activity_person:
title: Nombre de ménages concernés par les échanges
description: Compte le nombre de ménages concernés par les échanges. Si un ménage est présent dans plusieurs échanges, il n'est comptabilisé qu'une seule fois. Les usagers sans ménages ne sont pas comptabilisés. Lorsqu'un usager change de ménage, chaque ménage est comptabilisé une fois.
header: Nombre de ménage concernés par des échanges
list: list:
activity: activity:
users name: Nom des utilisateurs users name: Nom des utilisateurs
@@ -359,26 +372,55 @@ export:
Filter by users job: Filtrer les échanges par métier d'au moins un utilisateur participant Filter by users job: Filtrer les échanges par métier d'au moins un utilisateur participant
'Filtered activity by users job: only %jobs%': 'Filtré par métier d''au moins un utilisateur participant: seulement %jobs%' 'Filtered activity by users job: only %jobs%': 'Filtré par métier d''au moins un utilisateur participant: seulement %jobs%'
by_users_scope: by_users_scope:
Filter by users scope: Filtrer les échanges par services d'au moins un utilisateur participant Filter by users scope: Filtrer les échanges par service d'au moins un utilisateur participant
'Filtered activity by users scope: only %scopes%': 'Filtré par service d''au moins un utilisateur participant: seulement %scopes%' 'Filtered activity by users scope: only %scopes%': 'Filtré par service d''au moins un utilisateur participant: seulement %scopes%'
course_having_activity_between_date: course_having_activity_between_date:
Title: Filtre les parcours ayant reçu un échange entre deux dates Title: Filtrer les parcours ayant reçu un échange entre deux dates
Receiving an activity after: Ayant reçu un échange après le Receiving an activity after: Ayant reçu un échange après le
Receiving an activity before: Ayant reçu un échange avant le Receiving an activity before: Ayant reçu un échange avant le
acp_by_activity_type: acp_by_activity_type:
'acp_containing_at_least_one_%activitytypes%': 'Parcours filtrés: uniquement ceux qui contiennent au moins un échange d''un des types suivants: %activitytypes%' 'activity after': Échanges après le
activity after help: Si laissé vide, ne sera pas pris en compte
activity before: Echanges avant le
activity before help: Si laissé vide, ne sera pas pris en compte
person_between_dates: person_between_dates:
Implied in an activity after this date: Impliqué dans un échange après cette date Implied in an activity after this date: Impliqué dans un échange après cette date
Implied in an activity before this date: Impliqué dans un échange avant cette date Implied in an activity before this date: Impliqué dans un échange avant cette date
Activity reasons for those activities: Sujets de ces échanges Activity reasons for those activities: Sujets de ces échanges
if no reasons: Si aucun sujet n'est coché, tous les sujets seront pris en compte if no reasons: Si aucun sujet n'est coché, tous les sujets seront pris en compte
title: Filtrer les personnes ayant été associés à un échange au cours de la période title: Filtrer les usagers ayant été associés à un échange au cours de la période
date mismatch: La date de fin de la période doit être supérieure à la date du début date mismatch: La date de fin de la période doit être supérieure à la date du début
by_creator_scope: by_creator_scope:
Filter activity by user scope: Filtrer les échanges par service du créateur de l'échange Filter activity by user scope: Filtrer les échanges par service du créateur de l'échange
'Filtered activity by user scope: only %scopes%': "Filtré par service du créateur: uniquement %scopes%" 'Filtered activity by user scope: only %scopes%': "Filtré par service du créateur de l'échange: uniquement %scopes%"
by_creator_job:
job_form_label: Métiers
Filter activity by user job: Filtrer les échanges par métier du créateur de l'échange
'Filtered activity by user job: only %jobs%': "Filtré par service du créateur de l'échange: uniquement %jobs%"
by_persons:
Filter activity by persons: Filtrer les échanges par usager participant
'Filtered activity by persons: only %persons%': 'Échanges filtrés par usagers participants: seulement %persons%'
persons taking part on the activity: Usagers participants à l'échange
by_sent_received:
Sent or received: Envoyé ou reçu
is sent: envoyé
is received: reçu
by_presence:
Filter activity by activity presence: Filtrer les échanges par présence de l'usager
presences: Présences
'Filtered by activity presence: only %presences%': 'Filtré par présence de l''usager: seulement %presences%'
aggregator: aggregator:
person:
by_person:
title: Grouper les échanges par usager (dossier d'usager dans lequel l'échange est enregistré)
person: Usager
acp:
by_activity_type:
title: Grouper les parcours par type d'échange
after_date: Uniquement échanges après cette date
before_date: Uniquement échanges avant cette date
activity_type: Types d'échange
activity: activity:
by_sent_received: by_sent_received:
Sent or received: Envoyé ou reçu Sent or received: Envoyé ou reçu
@@ -398,8 +440,14 @@ export:
Group activity by creator scope: Grouper les échanges par service du créateur de l'échange Group activity by creator scope: Grouper les échanges par service du créateur de l'échange
Calc date: Date de calcul du service du créateur de l'échange Calc date: Date de calcul du service du créateur de l'échange
by_creator_job: by_creator_job:
Group activity by creator job: Grouper les échanges par service du créateur de l'échange Group activity by creator job: Grouper les échanges par métier du créateur de l'échange
Calc date: Date de calcul du service du créateur de l'échange Calc date: Date de calcul du métier du créateur de l'échange
by_persons:
Group activity by persons: Grouper les échanges par usager participant
Persons: Usagers participants
by_activity_presence:
Group activity by presence: Grouper les échanges par présence de l'usager
header: Présence de(s) usager(s)
generic_doc: generic_doc:
filter: filter:

View File

@@ -17,6 +17,7 @@ use Chill\AsideActivityBundle\Repository\AsideActivityCategoryRepository;
use Chill\AsideActivityBundle\Templating\Entity\CategoryRender; use Chill\AsideActivityBundle\Templating\Entity\CategoryRender;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@@ -76,7 +77,7 @@ class ByActivityTypeFilter implements FilterInterface
{ {
$types = array_map( $types = array_map(
fn (AsideActivityCategory $t): string => $this->translatableStringHelper->localize($t->getTitle()), fn (AsideActivityCategory $t): string => $this->translatableStringHelper->localize($t->getTitle()),
$data['types']->toArray() $data['types'] instanceof Collection ? $data['types']->toArray() : $data['types']
); );
return ['export.filter.Filtered by aside activity type: only %type%', [ return ['export.filter.Filtered by aside activity type: only %type%', [

View File

@@ -13,15 +13,11 @@ namespace Chill\AsideActivityBundle\Export\Filter;
use Chill\AsideActivityBundle\Export\Declarations; use Chill\AsideActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\Export\FilterType;
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 Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class ByDateFilter implements FilterInterface class ByDateFilter implements FilterInterface
@@ -66,51 +62,14 @@ class ByDateFilter implements FilterInterface
->add('date_to', PickRollingDateType::class, [ ->add('date_to', PickRollingDateType::class, [
'label' => 'export.filter.Aside activities before this date', 'label' => 'export.filter.Aside activities before this date',
]); ]);
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/** @var \Symfony\Component\Form\FormInterface $filterForm */
$filterForm = $event->getForm()->getParent();
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
if (true === $enabled) {
// if the filter is enabled, add some validation
$form = $event->getForm();
$date_from = $form->get('date_from')->getData();
$date_to = $form->get('date_to')->getData();
// check that fields are not empty
if (null === $date_from) {
$form->get('date_from')->addError(new FormError(
$this->translator->trans('This field '
.'should not be empty')
));
}
if (null === $date_to) {
$form->get('date_to')->addError(new FormError(
$this->translator->trans('This field '
.'should not be empty')
));
}
// check that date_from is before date_to
if (
(null !== $date_from && null !== $date_to)
&& $date_from >= $date_to
) {
$form->get('date_to')->addError(new FormError(
$this->translator->trans('export.filter.This date should be after '
.'the date given in "Implied in an aside activity after '
.'this date" field')
));
}
}
});
} }
public function getFormDefaultData(): array public function getFormDefaultData(): array
{ {
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)]; return [
'date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
'date_to' => new RollingDate(RollingDate::T_TODAY),
];
} }
public function describeAction($data, $format = 'string'): array public function describeAction($data, $format = 'string'): array

View File

@@ -16,6 +16,7 @@ use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickUserLocationType; use Chill\MainBundle\Form\Type\PickUserLocationType;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
@@ -54,7 +55,12 @@ final readonly class ByLocationFilter implements FilterInterface
public function describeAction($data, $format = 'string'): array public function describeAction($data, $format = 'string'): array
{ {
$locations = $data['locations']->map(fn (Location $l): string => $l->getName()); $extractFunction = fn (Location $l): string => $l->getName();
if ($data['locations'] instanceof Collection) {
$locations = $data['locations']->map($extractFunction);
} else {
$locations = array_map($extractFunction, $data['locations']);
}
return ['export.filter.Filtered by aside activity location: only %location%', [ return ['export.filter.Filtered by aside activity location: only %location%', [
'%location%' => implode(', ', $locations), '%location%' => implode(', ', $locations),

View File

@@ -17,6 +17,7 @@ use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@@ -80,7 +81,7 @@ class ByUserJobFilter implements FilterInterface
', ', ', ',
array_map( array_map(
fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()), fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
$data['jobs']->toArray() $data['jobs'] instanceof Collection ? $data['jobs']->toArray() : $data['jobs']
) )
), ),
]]; ]];

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\ScopeRepositoryInterface; use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@@ -83,7 +84,7 @@ class ByUserScopeFilter implements FilterInterface
', ', ', ',
array_map( array_map(
fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
$data['scopes']->toArray() $data['scopes'] instanceof Collection ? $data['scopes']->toArray() : $data['scopes']
) )
), ),
]]; ]];

View File

@@ -23,6 +23,6 @@ class ChargeKindController extends CRUDController
/* @var QueryBuilder $query */ /* @var QueryBuilder $query */
$query->addOrderBy('e.ordering', 'ASC'); $query->addOrderBy('e.ordering', 'ASC');
return $query; return parent::orderQuery($action, $query, $request, $paginator);
} }
} }

View File

@@ -23,6 +23,6 @@ class ResourceKindController extends CRUDController
/* @var QueryBuilder $query */ /* @var QueryBuilder $query */
$query->addOrderBy('e.ordering', 'ASC'); $query->addOrderBy('e.ordering', 'ASC');
return $query; return parent::orderQuery($action, $query, $request, $paginator);
} }
} }

View File

@@ -25,7 +25,9 @@ use Symfony\Component\Validator\Exception\LogicException;
class CountCalendars implements ExportInterface, GroupedExportInterface class CountCalendars implements ExportInterface, GroupedExportInterface
{ {
public function __construct(private readonly CalendarRepository $calendarRepository) {} public function __construct(
private readonly CalendarRepository $calendarRepository,
) {}
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {

View File

@@ -356,20 +356,6 @@ final class CalendarSyncerTest extends TestCase
} }
JSON; JSON;
protected function setUp(): void
{
parent::setUp();
// all tests should run when timezone = +02:00
$brussels = new \DateTimeZone('Europe/Brussels');
if (7200 === $brussels->getOffset(new \DateTimeImmutable())) {
date_default_timezone_set('Europe/Brussels');
} else {
date_default_timezone_set('Europe/Moscow');
}
}
public function testHandleAttendeesConfirmingCalendar(): void public function testHandleAttendeesConfirmingCalendar(): void
{ {
$machineHttpClient = new MockHttpClient([ $machineHttpClient = new MockHttpClient([

View File

@@ -18,16 +18,19 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
/** /**
* Class CustomFieldController. * Class CustomFieldController.
*/ */
class CustomFieldController extends AbstractController class CustomFieldController extends AbstractController
{ {
public function __construct(private readonly TranslatorInterface $translator) {}
/** /**
* Creates a new CustomField entity. * Creates a new CustomField entity.
* *
* @Route("/{_locale}/admin/customfield/new", name="customfield_new") * @Route("/{_locale}/admin/customfield/new", name="customfield_create")
*/ */
public function createAction(Request $request) public function createAction(Request $request)
{ {
@@ -40,13 +43,13 @@ class CustomFieldController extends AbstractController
$em->persist($entity); $em->persist($entity);
$em->flush(); $em->flush();
$this->addFlash('success', $this->get('translator') $this->addFlash('success', $this->translator
->trans('The custom field has been created')); ->trans('The custom field has been created'));
return $this->redirectToRoute('customfieldsgroup_show', ['id' => $entity->getCustomFieldsGroup()->getId()]); return $this->redirectToRoute('customfieldsgroup_show', ['id' => $entity->getCustomFieldsGroup()->getId()]);
} }
$this->addFlash('error', $this->get('translator') $this->addFlash('error', $this->translator
->trans('The custom field form contains errors')); ->trans('The custom field form contains errors'));
return $this->render('@ChillCustomFields/CustomField/new.html.twig', [ return $this->render('@ChillCustomFields/CustomField/new.html.twig', [
@@ -130,13 +133,13 @@ class CustomFieldController extends AbstractController
if ($editForm->isSubmitted() && $editForm->isValid()) { if ($editForm->isSubmitted() && $editForm->isValid()) {
$em->flush(); $em->flush();
$this->addFlash('success', $this->get('translator') $this->addFlash('success', $this->translator
->trans('The custom field has been updated')); ->trans('The custom field has been updated'));
return $this->redirectToRoute('customfield_edit', ['id' => $id]); return $this->redirectToRoute('customfield_edit', ['id' => $id]);
} }
$this->addFlash('error', $this->get('translator') $this->addFlash('error', $this->translator
->trans('The custom field form contains errors')); ->trans('The custom field form contains errors'));
return $this->render('@ChillCustomFields/CustomField/edit.html.twig', [ return $this->render('@ChillCustomFields/CustomField/edit.html.twig', [

View File

@@ -232,7 +232,7 @@ class CustomFieldsGroupController extends AbstractController
/** /**
* Finds and displays a CustomFieldsGroup entity. * Finds and displays a CustomFieldsGroup entity.
* *
* @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup/show") * @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup_show")
*/ */
public function showAction(mixed $id) public function showAction(mixed $id)
{ {
@@ -256,7 +256,7 @@ class CustomFieldsGroupController extends AbstractController
/** /**
* Edits an existing CustomFieldsGroup entity. * Edits an existing CustomFieldsGroup entity.
* *
* @Route("/{_locale}/admin/customfieldsgroup/{id}/update", name="customfieldsgroup/update") * @Route("/{_locale}/admin/customfieldsgroup/{id}/update", name="customfieldsgroup_update")
*/ */
public function updateAction(Request $request, mixed $id) public function updateAction(Request $request, mixed $id)
{ {
@@ -383,7 +383,7 @@ class CustomFieldsGroupController extends AbstractController
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$customFieldsGroupIds = $em->createQuery('SELECT g.id FROM ' $customFieldsGroupIds = $em->createQuery('SELECT g.id FROM '
.'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d ' .CustomFieldsDefaultGroup::class.' d '
.'JOIN d.customFieldsGroup g') .'JOIN d.customFieldsGroup g')
->getResult(Query::HYDRATE_SCALAR); ->getResult(Query::HYDRATE_SCALAR);

View File

@@ -280,7 +280,7 @@ class CustomFieldChoice extends AbstractCustomField
$template = '@ChillCustomFields/CustomFieldsRendering/choice.html.twig'; $template = '@ChillCustomFields/CustomFieldsRendering/choice.html.twig';
if ('csv' === $documentType) { if ('csv' === $documentType) {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.csv.twig'; $template = '@ChillCustomFields/CustomFieldsRendering/choice.csv.twig';
} }
return $this->templating return $this->templating

View File

@@ -68,7 +68,7 @@ class CustomFieldDate extends AbstractCustomField
{ {
$validatorFunction = static function ($value, ExecutionContextInterface $context) { $validatorFunction = static function ($value, ExecutionContextInterface $context) {
try { try {
$date = new \DateTime($value); $date = new \DateTime((string) $value);
} catch (\Exception) { } catch (\Exception) {
$context->buildViolation('The expression "%expression%" is invalid', [ $context->buildViolation('The expression "%expression%" is invalid', [
'%expression%' => $value, '%expression%' => $value,
@@ -125,7 +125,7 @@ class CustomFieldDate extends AbstractCustomField
return $date->format('Y-m-d'); return $date->format('Y-m-d');
default: default:
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:date.' $template = '@ChillCustomFields/CustomFieldsRendering/date.'
.$documentType.'.twig'; .$documentType.'.twig';
return $this->templating return $this->templating

View File

@@ -96,7 +96,7 @@ class CustomFieldLongChoice extends AbstractCustomField
public function render($value, CustomField $customField, $documentType = 'html') public function render($value, CustomField $customField, $documentType = 'html')
{ {
$option = $this->deserialize($value, $customField); $option = $this->deserialize($value, $customField);
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice_long.' $template = '@ChillCustomFields/CustomFieldsRendering/choice_long.'
.$documentType.'.twig'; .$documentType.'.twig';
return $this->templating return $this->templating

View File

@@ -95,7 +95,7 @@ class CustomFieldNumber extends AbstractCustomField
public function render($value, CustomField $customField, $documentType = 'html') public function render($value, CustomField $customField, $documentType = 'html')
{ {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:number.' $template = '@ChillCustomFields/CustomFieldsRendering/number.'
.$documentType.'.twig'; .$documentType.'.twig';
$options = $customField->getOptions(); $options = $customField->getOptions();

View File

@@ -89,7 +89,7 @@ class CustomFieldText extends AbstractCustomField
$template = '@ChillCustomFields/CustomFieldsRendering/text.html.twig'; $template = '@ChillCustomFields/CustomFieldsRendering/text.html.twig';
if ('csv' === $documentType) { if ('csv' === $documentType) {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:text.csv.twig'; $template = '@ChillCustomFields/CustomFieldsRendering/text.csv.twig';
} }
return $this->templating return $this->templating

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\CustomFieldsBundle\Form; namespace Chill\CustomFieldsBundle\Form;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
use Chill\CustomFieldsBundle\Service\CustomFieldProvider; use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\MainBundle\Form\Type\TranslatableStringFormType;
@@ -45,7 +46,7 @@ class CustomFieldType extends AbstractType
if ('entity' === $options['group_widget']) { if ('entity' === $options['group_widget']) {
$builder->add('customFieldsGroup', EntityType::class, [ $builder->add('customFieldsGroup', EntityType::class, [
'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup', 'class' => CustomFieldsGroup::class,
'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()), 'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()),
]); ]);
} elseif ('hidden' === $options['group_widget']) { } elseif ('hidden' === $options['group_widget']) {

View File

@@ -1,4 +1,8 @@
services: services:
_defaults:
autowire: true
autoconfigure: true
Chill\CustomFieldsBundle\Controller\: Chill\CustomFieldsBundle\Controller\:
resource: '../../Controller' resource: '../../Controller'
tags: ['controller.service_arguments'] tags: ['controller.service_arguments']

View File

@@ -11,14 +11,14 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Serializer\Helper; namespace Chill\DocGeneratorBundle\Serializer\Helper;
use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class NormalizeNullValueHelper class NormalizeNullValueHelper
{ {
public function __construct(private readonly NormalizerInterface $normalizer, private readonly ?string $discriminatorType = null, private readonly ?string $discriminatorValue = null) {} public function __construct(private readonly NormalizerInterface $normalizer, private readonly ?string $discriminatorType = null, private readonly ?string $discriminatorValue = null) {}
public function normalize(array $attributes, string $format = 'docgen', ?array $context = [], ClassMetadata $classMetadata = null) public function normalize(array $attributes, string $format = 'docgen', ?array $context = [], ClassMetadataInterface $classMetadata = null)
{ {
$data = []; $data = [];
$data['isNull'] = true; $data['isNull'] = true;
@@ -44,7 +44,7 @@ class NormalizeNullValueHelper
return $data; return $data;
} }
private function getContextForAttribute(string $key, array $initialContext, ?ClassMetadata $classMetadata): array private function getContextForAttribute(string $key, array $initialContext, ?ClassMetadataInterface $classMetadata): array
{ {
if (null === $classMetadata) { if (null === $classMetadata) {
return $initialContext; return $initialContext;

View File

@@ -19,6 +19,7 @@ use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\Serializer\Exception\ExceptionInterface; use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Exception\LogicException; use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Mapping\AttributeMetadata; use Symfony\Component\Serializer\Mapping\AttributeMetadata;
use Symfony\Component\Serializer\Mapping\AttributeMetadataInterface;
use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\ClassMetadata;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
@@ -52,12 +53,15 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
} }
$metadata = $this->classMetadataFactory->getMetadataFor($classMetadataKey); $metadata = $this->classMetadataFactory->getMetadataFor($classMetadataKey);
if (!$metadata instanceof ClassMetadata) {
throw new \LogicException('ClassMetadata should be the only one implementation for ClassMetadataInterface. See https://github.com/symfony/symfony/pull/17114');
}
$expectedGroups = \array_key_exists(AbstractNormalizer::GROUPS, $context) ? $expectedGroups = \array_key_exists(AbstractNormalizer::GROUPS, $context) ?
\is_array($context[AbstractNormalizer::GROUPS]) ? $context[AbstractNormalizer::GROUPS] : [$context[AbstractNormalizer::GROUPS]] \is_array($context[AbstractNormalizer::GROUPS]) ? $context[AbstractNormalizer::GROUPS] : [$context[AbstractNormalizer::GROUPS]]
: []; : [];
$attributes = \array_filter( $attributes = \array_filter(
$metadata->getAttributesMetadata(), $metadata->getAttributesMetadata(),
static function (AttributeMetadata $a) use ($expectedGroups) { static function (AttributeMetadataInterface $a) use ($expectedGroups) {
foreach ($a->getGroups() as $g) { foreach ($a->getGroups() as $g) {
if (\in_array($g, $expectedGroups, true)) { if (\in_array($g, $expectedGroups, true)) {
return true; return true;
@@ -119,7 +123,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
return $type->getName(); return $type->getName();
} }
if ($type instanceof \ReflectionIntersectionType) { if ($type instanceof \ReflectionIntersectionType) {
foreach (array_map(fn (\ReflectionNamedType $t) => $t->getName(), $type->getTypes()) as $classString) { foreach (array_map(fn (\ReflectionType $t) => $t->getName(), $type->getTypes()) as $classString) {
if (ReadableCollection::class === $classString) { if (ReadableCollection::class === $classString) {
return ReadableCollection::class; return ReadableCollection::class;
} }
@@ -211,7 +215,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
} }
/** /**
* @param array|AttributeMetadata[] $attributes * @param array<AttributeMetadata> $attributes
* *
* @return array * @return array
* *

View File

@@ -0,0 +1,90 @@
<?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\DocStoreBundle\AsyncUpload\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class ConfigureOpenstackObjectStorageCommand extends Command
{
private readonly string $basePath;
private readonly string $tempUrlKey;
public function __construct(private readonly HttpClientInterface $client, ParameterBagInterface $parameterBag)
{
$config = $parameterBag->get('chill_doc_store')['openstack']['temp_url'];
$this->tempUrlKey = $config['temp_url_key'];
$this->basePath = $config['temp_url_base_path'];
parent::__construct();
}
protected function configure()
{
$this->setDescription('Configure openstack container to store documents')
->setName('chill:doc-store:configure-openstack')
->addOption('os_token', 'o', InputOption::VALUE_REQUIRED, 'Openstack token')
->addOption('domain', 'd', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Domain name')
;
}
protected function interact(InputInterface $input, OutputInterface $output)
{
if (!$input->hasOption('os_token')) {
$output->writeln('The option os_token is required');
throw new \RuntimeException('The option os_token is required');
}
if (0 === count($input->getOption('domain'))) {
$output->writeln('At least one occurence of option domain is required');
throw new \RuntimeException('At least one occurence of option domain is required');
}
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$domains = trim(implode(' ', $input->getOption('domain')));
if ($output->isVerbose()) {
$output->writeln(['Domains configured will be', $domains]);
}
try {
$response = $this->client->request('POST', $this->basePath, [
'headers' => [
'X-Auth-Token' => $input->getOption('os_token'),
'X-Container-Meta-Access-Control-Allow-Origin' => $domains,
'X-Container-Meta-Temp-URL-Key' => $this->tempUrlKey,
],
]);
$response->getContent();
} catch (HttpExceptionInterface $e) {
$output->writeln('Error');
$output->writeln($e->getMessage());
if ($output->isVerbose()) {
$output->writeln($e->getTraceAsString());
}
}
return 0;
}
}

View File

@@ -0,0 +1,204 @@
<?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\DocStoreBundle\AsyncUpload\Driver\OpenstackObjectStore;
use Chill\DocStoreBundle\AsyncUpload\Event\TempUrlGenerateEvent;
use Chill\DocStoreBundle\AsyncUpload\Exception\TempUrlGeneratorException;
use Chill\DocStoreBundle\AsyncUpload\SignedUrl;
use Chill\DocStoreBundle\AsyncUpload\SignedUrlPost;
use Chill\DocStoreBundle\AsyncUpload\TempUrlGeneratorInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Clock\ClockInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Generate a temp url.
*/
final readonly class TempUrlOpenstackGenerator implements TempUrlGeneratorInterface
{
private const CHARACTERS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
private string $base_url;
private string $key;
private int $max_expire_delay;
private int $max_submit_delay;
private int $max_post_file_size;
private int $max_file_count;
public function __construct(
private LoggerInterface $logger,
private EventDispatcherInterface $event_dispatcher,
private ClockInterface $clock,
ParameterBagInterface $parameterBag,
) {
$config = $parameterBag->get('chill_doc_store')['openstack']['temp_url'];
$this->key = $config['temp_url_key'];
$this->base_url = $config['temp_url_base_path'];
$this->max_expire_delay = $config['max_expires_delay'];
$this->max_submit_delay = $config['max_submit_delay'];
$this->max_post_file_size = $config['max_post_file_size'];
$this->max_file_count = $config['max_post_file_count'];
}
/**
* @throws TempUrlGeneratorException
*/
public function generatePost(
int $expire_delay = null,
int $submit_delay = null,
int $max_file_count = 1,
): SignedUrlPost {
$delay = $expire_delay ?? $this->max_expire_delay;
$submit_delay ??= $this->max_submit_delay;
if ($delay < 2) {
throw new TempUrlGeneratorException("The delay of {$delay} is too ".'short (<2 sec) to properly use this token');
}
if ($delay > $this->max_expire_delay) {
throw new TempUrlGeneratorException('The given delay is greater than the max delay authorized.');
}
if ($submit_delay < 15) {
throw new TempUrlGeneratorException("The submit delay of {$delay} is too ".'short (<15 sec) to properly use this token');
}
if ($submit_delay > $this->max_submit_delay) {
throw new TempUrlGeneratorException('The given submit delay is greater than the max submit delay authorized.');
}
if ($max_file_count > $this->max_file_count) {
throw new TempUrlGeneratorException('The number of files is greater than the authorized number of files');
}
$expires = $this->clock->now()->add(new \DateInterval('PT'.(string) $delay.'S'));
$object_name = $this->generateObjectName();
$g = new SignedUrlPost(
$url = $this->generateUrl($object_name),
$expires,
$this->max_post_file_size,
$max_file_count,
$submit_delay,
'',
$object_name,
$this->generateSignaturePost($url, $expires)
);
$this->event_dispatcher->dispatch(
new TempUrlGenerateEvent($g),
);
$this->logger->info(
'generate signature for url',
(array) $g
);
return $g;
}
/**
* Generate an absolute public url for a GET request on the object.
*/
public function generate(string $method, string $object_name, int $expire_delay = null): SignedUrl
{
if ($expire_delay > $this->max_expire_delay) {
throw new TempUrlGeneratorException(sprintf('The expire delay (%d) is greater than the max_expire_delay (%d)', $expire_delay, $this->max_expire_delay));
}
$url = $this->generateUrl($object_name);
$expires = $this->clock->now()
->add(new \DateInterval(sprintf('PT%dS', $expire_delay ?? $this->max_expire_delay)));
$args = [
'temp_url_sig' => $this->generateSignature($method, $url, $expires),
'temp_url_expires' => $expires->format('U'),
];
$url = $url.'?'.\http_build_query($args);
$signature = new SignedUrl(strtoupper($method), $url, $expires);
$this->event_dispatcher->dispatch(
new TempUrlGenerateEvent($signature)
);
return $signature;
}
private function generateUrl($relative_path): string
{
return match (str_ends_with($this->base_url, '/')) {
true => $this->base_url.$relative_path,
false => $this->base_url.'/'.$relative_path
};
}
private function generateObjectName()
{
// inspiration from https://stackoverflow.com/a/4356295/1572236
$charactersLength = strlen(self::CHARACTERS);
$randomString = '';
for ($i = 0; $i < 21; ++$i) {
$randomString .= self::CHARACTERS[random_int(0, $charactersLength - 1)];
}
return $randomString;
}
private function generateSignaturePost($url, \DateTimeImmutable $expires)
{
$path = \parse_url((string) $url, PHP_URL_PATH);
$body = sprintf(
"%s\n%s\n%s\n%s\n%s",
$path,
'', // redirect is empty
(string) $this->max_post_file_size,
(string) $this->max_file_count,
$expires->format('U')
)
;
$this->logger->debug(
'generate signature post',
['url' => $body, 'method' => 'POST']
);
return \hash_hmac('sha512', $body, $this->key, false);
}
private function generateSignature($method, $url, \DateTimeImmutable $expires)
{
if ('POST' === $method) {
return $this->generateSignaturePost($url, $expires);
}
$path = \parse_url((string) $url, PHP_URL_PATH);
$body = sprintf(
"%s\n%s\n%s",
$method,
$expires->format('U'),
$path
)
;
$this->logger->debug(
'generate signature GET',
['url' => $body, 'method' => 'GET']
);
return \hash_hmac('sha512', $body, $this->key, false);
}
}

Some files were not shown because too many files have changed in this diff Show More