mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-24 15:44:59 +00:00
Compare commits
9 Commits
v3.0.0-RC3
...
signature-
Author | SHA1 | Date | |
---|---|---|---|
7aa63a25a7
|
|||
610239930b
|
|||
b65e2c62c4 | |||
89f5231649
|
|||
99818c211d
|
|||
a9f0059743
|
|||
5bc542a567
|
|||
c8ccce83fd
|
|||
4a229ebf6b |
8
.changes/unreleased/Feature-20240614-153236.yaml
Normal file
8
.changes/unreleased/Feature-20240614-153236.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
kind: Feature
|
||||
body: |-
|
||||
Electronic signature
|
||||
|
||||
Implementation of the electronic signature for documents within chill.
|
||||
time: 2024-06-14T15:32:36.875891692+02:00
|
||||
custom:
|
||||
Issue: ""
|
@@ -1,21 +0,0 @@
|
||||
## v2.20.0 - 2024-06-05
|
||||
### Fixed
|
||||
* ([#170](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/170)) Display agents traitants instead of accompanying period referrer in export list social actions.
|
||||
* Added translations for choices of durations (> 5 hours)
|
||||
### Feature
|
||||
* ([#145](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/145)) Allow to open documents in LibreOffice locally (need configuration within security);
|
||||
|
||||
This endpoint should be added to make the endpoint works properly:
|
||||
|
||||
```yaml
|
||||
security:
|
||||
firewalls:
|
||||
dav:
|
||||
pattern: ^/dav
|
||||
provider: chain_provider
|
||||
stateless: true
|
||||
guard:
|
||||
authenticators:
|
||||
- Chill\DocStoreBundle\Security\Guard\JWTOnDavUrlAuthenticator
|
||||
|
||||
```
|
@@ -1,3 +0,0 @@
|
||||
## v2.20.1 - 2024-06-05
|
||||
### Fixed
|
||||
* Do not allow StoredObjectCreated for edit and convert buttons
|
@@ -1,31 +0,0 @@
|
||||
## v2.21.0 - 2024-06-18
|
||||
### Feature
|
||||
* Add flash menu buttons in search results, to open directly a new calendar, or a new activity in an accompanying period
|
||||
* ([#122](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/122)) Improve the list of calendar in the search results: make all calendar clicable, and display a list of calendars
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] add start date and end date on filters "filter course by referrer job" and "filter course by referrer scope"
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] the aggregator "Group by referrer" now accept a date range.
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] add date range on "group course by referrer's scope"
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] add date range on "group course by referrer's jobs"
|
||||
* ([#168](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/168) In the UX, display user job and service at the time when he performs an action:
|
||||
now, the job and service is shown:
|
||||
* at the activity's date,
|
||||
* at the appointment's date,
|
||||
* when the user is marked as referrer for an accompanying period work,
|
||||
* when the user apply a transition in a workflow,
|
||||
* when the user updates or creates "something" ("created/updated by ... at ..."),
|
||||
* or when he wrote a comment,
|
||||
* …
|
||||
|
||||
### Traduction francophone
|
||||
* Ajout d'un menu "flash" dans les résultats de recherche, pour créer un rendez-vous ou un échange dans un parcours depuis les résultats de recherche;
|
||||
* Améliore la liste des rendez-vous dans les résultats de recherche: les rendez-vous sont cliquables;
|
||||
* [exports] Ajout d'intervalles de dates pour des filtres et regroupements des parcours par référent, métier du référent, service du référent;
|
||||
* Affiche le métier et le service des utilisateurs à la date à laquelle il a exécuté une action. Le métier et le service est affiché:
|
||||
* à la date d'un échange,
|
||||
* au jour d'un rendez-vous,
|
||||
* quand l'utilisateur est devenu référent d'un parcours d'accompagnement,
|
||||
* quand il a appliqué une transition sur un workflow,
|
||||
* quand il a mise à jour ou créé une fiche, dans les mentions "créé / mise à jour par ..., le ...",
|
||||
* quand il a mis à jour un commentaire,
|
||||
* …
|
||||
|
58
CHANGELOG.md
58
CHANGELOG.md
@@ -6,64 +6,6 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||
|
||||
|
||||
## v2.21.0 - 2024-06-18
|
||||
### Feature
|
||||
* Add flash menu buttons in search results, to open directly a new calendar, or a new activity in an accompanying period
|
||||
* ([#122](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/122)) Improve the list of calendar in the search results: make all calendar clicable, and display a list of calendars
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] add start date and end date on filters "filter course by referrer job" and "filter course by referrer scope"
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] the aggregator "Group by referrer" now accept a date range.
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] add date range on "group course by referrer's scope"
|
||||
* ([#282](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/282)) [export] add date range on "group course by referrer's jobs"
|
||||
* ([#168](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/168) In the UX, display user job and service at the time when he performs an action:
|
||||
now, the job and service is shown:
|
||||
* at the activity's date,
|
||||
* at the appointment's date,
|
||||
* when the user is marked as referrer for an accompanying period work,
|
||||
* when the user apply a transition in a workflow,
|
||||
* when the user updates or creates "something" ("created/updated by ... at ..."),
|
||||
* or when he wrote a comment,
|
||||
* …
|
||||
|
||||
### Traduction francophone
|
||||
* Ajout d'un menu "flash" dans les résultats de recherche, pour créer un rendez-vous ou un échange dans un parcours depuis les résultats de recherche;
|
||||
* Améliore la liste des rendez-vous dans les résultats de recherche: les rendez-vous sont cliquables;
|
||||
* [exports] Ajout d'intervalles de dates pour des filtres et regroupements des parcours par référent, métier du référent, service du référent;
|
||||
* Affiche le métier et le service des utilisateurs à la date à laquelle il a exécuté une action. Le métier et le service est affiché:
|
||||
* à la date d'un échange,
|
||||
* au jour d'un rendez-vous,
|
||||
* quand l'utilisateur est devenu référent d'un parcours d'accompagnement,
|
||||
* quand il a appliqué une transition sur un workflow,
|
||||
* quand il a mise à jour ou créé une fiche, dans les mentions "créé / mise à jour par ..., le ...",
|
||||
* quand il a mis à jour un commentaire,
|
||||
* …
|
||||
|
||||
|
||||
## v2.20.1 - 2024-06-05
|
||||
### Fixed
|
||||
* Do not allow StoredObjectCreated for edit and convert buttons
|
||||
|
||||
## v2.20.0 - 2024-06-05
|
||||
### Fixed
|
||||
* ([#170](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/170)) Display agents traitants instead of accompanying period referrer in export list social actions.
|
||||
* Added translations for choices of durations (> 5 hours)
|
||||
### Feature
|
||||
* ([#145](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/145)) Allow to open documents in LibreOffice locally (need configuration within security);
|
||||
|
||||
This endpoint should be added to make the endpoint works properly:
|
||||
|
||||
```yaml
|
||||
security:
|
||||
firewalls:
|
||||
dav:
|
||||
pattern: ^/dav
|
||||
provider: chain_provider
|
||||
stateless: true
|
||||
guard:
|
||||
authenticators:
|
||||
- Chill\DocStoreBundle\Security\Guard\JWTOnDavUrlAuthenticator
|
||||
|
||||
```
|
||||
|
||||
## v2.19.0 - 2024-05-14
|
||||
### Feature
|
||||
* ([#197](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/197)) Make the script which subscribe to microsoft calendars changes more tolerant to errors or missing configuration on the microsoft side
|
||||
|
@@ -32,6 +32,7 @@
|
||||
"phpoffice/phpspreadsheet": "^1.16",
|
||||
"ramsey/uuid-doctrine": "^1.7",
|
||||
"sensio/framework-extra-bundle": "^5.5",
|
||||
"smalot/pdfparser": "^2.10",
|
||||
"spomky-labs/base64url": "^2.0",
|
||||
"symfony/asset": "^5.4",
|
||||
"symfony/browser-kit": "^5.4",
|
||||
@@ -92,12 +93,11 @@
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpstan/phpstan-deprecation-rules": "^1.1",
|
||||
"phpstan/phpstan-strict-rules": "^1.0",
|
||||
"phpunit/phpunit": "^10.5.24",
|
||||
"phpunit/phpunit": ">= 7.5",
|
||||
"rector/rector": "^1.1.0",
|
||||
"symfony/debug-bundle": "^5.4",
|
||||
"symfony/dotenv": "^5.4",
|
||||
"symfony/maker-bundle": "^1.20",
|
||||
"symfony/phpunit-bridge": "^7.1",
|
||||
"symfony/runtime": "^5.4",
|
||||
"symfony/stopwatch": "^5.4",
|
||||
"symfony/var-dumper": "^5.4"
|
||||
|
@@ -95,7 +95,7 @@ custom developments. But most of the time, this should be fine.
|
||||
|
||||
You have to configure some local variables, which are described in the :code:`.env` file. The secrets should not be stored
|
||||
in this :code:`.env` file, but instead using the `secrets management tool <https://symfony.com/doc/current/configuration/secrets.html>`_
|
||||
or in the :code:`.env.local` file, which should not be committed to the git repository.
|
||||
or in the :code:`.env.local` file, which should not be commited to the git repository.
|
||||
|
||||
You do not need to set variables for the smtp server, redis server and relatorio server, as they are generated automatically
|
||||
by the symfony server, from the docker compose services.
|
||||
@@ -114,12 +114,6 @@ you can either:
|
||||
- add the generated password to the secrets manager (**note**: you must add the generated hashed password to the secrets env,
|
||||
not the password in clear text).
|
||||
|
||||
- set up the jwt authentication bundle
|
||||
|
||||
Some environment variables are available for the JWT authentication bundle in the :code:`.env` file. You must also run the command
|
||||
:code:`symfony console lexik:jwt:generate-keypair` to generate some keys that will be stored in the paths set up in the :code:`JWT_SECRET_KEY`
|
||||
and the :code:`JWT_PUBLIC_KEY` env variables. This is only required for using the stored documents in Chill.
|
||||
|
||||
Prepare migrations and other tools
|
||||
**********************************
|
||||
|
||||
@@ -185,7 +179,7 @@ Install fixtures
|
||||
This will generate user accounts, centers, and some basic configuration.
|
||||
|
||||
The accounts created are: :code:`center a_social`, :code:`center b_social`, :code:`center a_direction`, ... The full list is
|
||||
visible in the "users" table: :code:`docker compose exec database psql -U app -c "SELECT username FROM users"`.
|
||||
visibile in the "users" table: :code:`docker compose exec database psql -U app -c "SELECT username FROM users"`.
|
||||
|
||||
The password is always :code:`password`.
|
||||
|
||||
|
@@ -46,11 +46,9 @@
|
||||
"@fullcalendar/vue3": "^6.1.4",
|
||||
"@popperjs/core": "^2.9.2",
|
||||
"@types/leaflet": "^1.9.3",
|
||||
"@types/dompurify": "^3.0.5",
|
||||
"dropzone": "^5.7.6",
|
||||
"es6-promise": "^4.2.8",
|
||||
"leaflet": "^1.7.1",
|
||||
"marked": "^12.0.2",
|
||||
"masonry-layout": "^4.2.2",
|
||||
"mime": "^4.0.0",
|
||||
"swagger-ui": "^4.15.5",
|
||||
|
@@ -1,49 +0,0 @@
|
||||
<?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\Menu;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final readonly class AccompanyingCourseQuickMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
public function __construct(private Security $security) {}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return ['accompanying_course_quick_menu'];
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingCourse */
|
||||
$accompanyingCourse = $parameters['accompanying-course'];
|
||||
|
||||
if ($this->security->isGranted(ActivityVoter::CREATE, $accompanyingCourse)) {
|
||||
$menu
|
||||
->addChild('Create a new activity in accompanying course', [
|
||||
'route' => 'chill_activity_activity_new',
|
||||
'routeParameters' => [
|
||||
// 'activityType_id' => '',
|
||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
],
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 10,
|
||||
'icon' => 'plus',
|
||||
])
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
@@ -68,7 +68,7 @@
|
||||
<div class="wl-col title"><h3>{{ 'Referrer'|trans }}</h3></div>
|
||||
<div class="wl-col list">
|
||||
<p class="wl-item">
|
||||
<span class="badge-user">{{ activity.user|chill_entity_render_box({'at_date': activity.date}) }}</span>
|
||||
<span class="badge-user">{{ activity.user|chill_entity_render_box }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -87,8 +87,7 @@
|
||||
<li>
|
||||
{% if bloc.type == 'user' %}
|
||||
<span class="badge-user">
|
||||
hello
|
||||
{{ item|chill_entity_render_box({'render': 'raw', 'addAltNames': false, 'at_date': entity.date }) }}
|
||||
{{ item|chill_entity_render_box({'render': 'raw', 'addAltNames': false }) }}
|
||||
</span>
|
||||
{% else %}
|
||||
{{ _self.insert_onthefly(bloc.type, item) }}
|
||||
@@ -115,7 +114,7 @@
|
||||
<li>
|
||||
{% if bloc.type == 'user' %}
|
||||
<span class="badge-user">
|
||||
{{ item|chill_entity_render_box({'render': 'raw', 'addAltNames': false, 'at_date': entity.date }) }}
|
||||
{{ item|chill_entity_render_box({'render': 'raw', 'addAltNames': false }) }}
|
||||
</span>
|
||||
{% else %}
|
||||
{{ _self.insert_onthefly(bloc.type, item) }}
|
||||
@@ -143,7 +142,7 @@
|
||||
<span class="wl-item">
|
||||
{% if bloc.type == 'user' %}
|
||||
<span class="badge-user">
|
||||
{{ item|chill_entity_render_box({'render': 'raw', 'addAltNames': false, 'at_date': entity.date }) }}
|
||||
{{ item|chill_entity_render_box({'render': 'raw', 'addAltNames': false }) }}
|
||||
{%- if context == 'calendar_accompanyingCourse' or context == 'calendar_person' %}
|
||||
{% set invite = entity.inviteForUser(item) %}
|
||||
{% if invite is not null %}
|
||||
|
@@ -41,7 +41,7 @@
|
||||
{% if activity.user and t.userVisible %}
|
||||
<li>
|
||||
<span class="item-key">{{ 'Referrer'|trans ~ ': ' }}</span>
|
||||
<span class="badge-user">{{ activity.user|chill_entity_render_box({'at_date': activity.date}) }}</span>
|
||||
<span class="badge-user">{{ activity.user|chill_entity_render_box }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
|
@@ -37,7 +37,7 @@
|
||||
{%- if entity.user is not null %}
|
||||
<dt class="inline">{{ 'Referrer'|trans|capitalize }}</dt>
|
||||
<dd>
|
||||
<span class="badge-user">{{ entity.user|chill_entity_render_box({'at_date': entity.date}) }}</span>
|
||||
<span class="badge-user">{{ entity.user|chill_entity_render_box }}</span>
|
||||
</dd>
|
||||
{% endif %}
|
||||
|
||||
|
@@ -145,7 +145,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
throw new \RuntimeException('Could not determine context of activity.');
|
||||
}
|
||||
} elseif ($subject instanceof AccompanyingPeriod) {
|
||||
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep() || AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) {
|
||||
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
|
||||
if (\in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE], true)) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -77,18 +77,6 @@ Choose a type: Choisir un type
|
||||
4 hours: 4 heures
|
||||
4 hours 30: 4 heures 30
|
||||
5 hours: 5 heures
|
||||
5 hours 30: 5 heure 30
|
||||
6 hours: 6 heures
|
||||
6 hours 30: 6 heure 30
|
||||
7 hours: 7 heures
|
||||
7 hours 30: 7 heure 30
|
||||
8 hours: 8 heures
|
||||
8 hours 30: 8 heure 30
|
||||
9 hours: 9 heures
|
||||
9 hours 30: 9 heure 30
|
||||
10 hours: 10 heures
|
||||
11 hours: 11 heures
|
||||
12 hours: 12 heures
|
||||
Concerned groups: Parties concernées par l'échange
|
||||
Persons in accompanying course: Usagers du parcours
|
||||
Third persons: Tiers non-pro.
|
||||
@@ -222,7 +210,6 @@ Documents label: Libellé du champ Documents
|
||||
# activity type category admin
|
||||
ActivityTypeCategory list: Liste des catégories des types d'échange
|
||||
Create a new activity type category: Créer une nouvelle catégorie de type d'échange
|
||||
Create a new activity in accompanying course: Créer un échange dans le parcours
|
||||
|
||||
# activity delete
|
||||
Remove activity: Supprimer un échange
|
||||
|
@@ -49,13 +49,13 @@
|
||||
<li>
|
||||
<span>
|
||||
<abbr class="referrer" title={{ 'Created by'|trans }}>{{ 'By'|trans }}:</abbr>
|
||||
<b>{{ entity.createdBy|chill_entity_render_box({'at_date': entity.date}) }}</b>
|
||||
<b>{{ entity.createdBy|chill_entity_render_box }}</b>
|
||||
</span>
|
||||
</li>
|
||||
<li>
|
||||
<span>
|
||||
<abbr class="referrer" title={{ 'Created for'|trans }}>{{ 'For'|trans }}:</abbr>
|
||||
<b>{{ entity.agent|chill_entity_render_box({'at_date': entity.date}) }}</b>
|
||||
<b>{{ entity.agent|chill_entity_render_box }}</b>
|
||||
|
||||
</span>
|
||||
</li>
|
||||
|
@@ -18,11 +18,11 @@
|
||||
<dd>{{ entity.type|chill_entity_render_box }}</dd>
|
||||
|
||||
<dt class="inline">{{ 'Created by'|trans }}</dt>
|
||||
<dd>{{ entity.createdBy|chill_entity_render_box({'at_date': entity.date}) }}</dd>
|
||||
<dd>{{ entity.createdBy }}</dd>
|
||||
|
||||
<dt class="inline">{{ 'Created for'|trans }}</dt>
|
||||
<dd>{{ entity.agent|chill_entity_render_box({'at_date': entity.date}) }}</dd>
|
||||
|
||||
<dd>{{ entity.agent }}</dd>
|
||||
|
||||
<dt class="inline">{{ 'Asideactivity location'|trans }}</dt>
|
||||
{%- if entity.location.name is defined -%}
|
||||
<dd>{{ entity.location.name }}</dd>
|
||||
|
@@ -72,21 +72,21 @@ days: jours
|
||||
1 hour 30: 1 heure 30
|
||||
1 hour 45: 1 heure 45
|
||||
2 hours: 2 heures
|
||||
2 hours 30: 2 heures 30
|
||||
2 hours 30: 2 heure 30
|
||||
3 hours: 3 heures
|
||||
3 hours 30: 3 heures 30
|
||||
3 hours 30: 3 heure 30
|
||||
4 hours: 4 heures
|
||||
4 hours 30: 4 heures 30
|
||||
4 hours 30: 4 heure 30
|
||||
5 hours: 5 heures
|
||||
5 hours 30: 5 heures 30
|
||||
5 hours 30: 5 heure 30
|
||||
6 hours: 6 heures
|
||||
6 hours 30: 6 heures 30
|
||||
6 hours 30: 6 heure 30
|
||||
7 hours: 7 heures
|
||||
7 hours 30: 7 heures 30
|
||||
7 hours 30: 7 heure 30
|
||||
8 hours: 8 heures
|
||||
8 hours 30: 8 heures 30
|
||||
8 hours 30: 8 heure 30
|
||||
9 hours: 9 heures
|
||||
9 hours 30: 9 heures 30
|
||||
9 hours 30: 9 heure 30
|
||||
10 hours: 10 heures
|
||||
1/2 day: 1/2 jour
|
||||
1 day: 1 jour
|
||||
|
@@ -440,16 +440,6 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the date of the calendar.
|
||||
*
|
||||
* Useful for showing the date of the calendar event, required by twig in some places.
|
||||
*/
|
||||
public function getDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->getStartDate();
|
||||
}
|
||||
|
||||
public function getStatus(): ?string
|
||||
{
|
||||
return $this->status;
|
||||
|
@@ -1,48 +0,0 @@
|
||||
<?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\CalendarBundle\Menu;
|
||||
|
||||
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final readonly class AccompanyingCourseQuickMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
public function __construct(private Security $security) {}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return ['accompanying_course_quick_menu'];
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingCourse */
|
||||
$accompanyingCourse = $parameters['accompanying-course'];
|
||||
|
||||
if ($this->security->isGranted(CalendarVoter::CREATE, $accompanyingCourse)) {
|
||||
$menu
|
||||
->addChild('Create a new calendar in accompanying course', [
|
||||
'route' => 'chill_calendar_calendar_new',
|
||||
'routeParameters' => [
|
||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
],
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 20,
|
||||
'icon' => 'plus',
|
||||
])
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,2 +1 @@
|
||||
import './scss/badge.scss';
|
||||
import './scss/calendar-list.scss';
|
||||
|
@@ -1,26 +0,0 @@
|
||||
ul.calendar-list {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
& > li {
|
||||
display: inline-block;
|
||||
}
|
||||
& > li:nth-child(n+2) {
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
div.calendar-list {
|
||||
|
||||
ul.calendar-list {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
& > a.calendar-list__global {
|
||||
display: inline-block;;
|
||||
padding: 0.2rem;
|
||||
min-width: 2rem;
|
||||
border: 1px solid var(--bs-chill-blue);
|
||||
border-radius: 0.25rem;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
@@ -55,7 +55,7 @@
|
||||
<div class="item-col">
|
||||
<ul class="list-content">
|
||||
{% if calendar.mainUser is not empty %}
|
||||
<span class="badge-user">{{ calendar.mainUser|chill_entity_render_box({'at_date': calendar.startDate}) }}</span>
|
||||
<span class="badge-user">{{ calendar.mainUser|chill_entity_render_box }}</span>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -132,7 +132,7 @@
|
||||
<li class="cancel">
|
||||
<span class="createdBy">
|
||||
{{ 'Created by'|trans }}
|
||||
<b>{{ calendar.activity.createdBy|chill_entity_render_string({'at_date': calendar.activity.createdAt}) }}</b>, {{ 'on'|trans }} {{ calendar.activity.createdAt|format_datetime('short', 'short') }}
|
||||
<b>{{ calendar.activity.createdBy|chill_entity_render_string }}</b>, {{ 'on'|trans }} {{ calendar.activity.createdAt|format_datetime('short', 'short') }}
|
||||
</span>
|
||||
</li>
|
||||
{% if is_granted('CHILL_ACTIVITY_SEE', calendar.activity) %}
|
||||
|
@@ -89,7 +89,7 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
switch ($attribute) {
|
||||
case self::SEE:
|
||||
case self::CREATE:
|
||||
if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep() || AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
|
||||
if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,6 @@ The calendar item has been successfully removed.: Le rendez-vous a été supprim
|
||||
From the day: Du
|
||||
to the day: au
|
||||
Transform to activity: Transformer en échange
|
||||
Create a new calendar in accompanying course: Créer un rendez-vous dans le parcours
|
||||
Will send SMS: Un SMS de rappel sera envoyé
|
||||
Will not send SMS: Aucun SMS de rappel ne sera envoyé
|
||||
SMS already sent: Un SMS a été envoyé
|
||||
|
@@ -1,65 +0,0 @@
|
||||
<?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\DocGeneratorBundle\Test;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
* @template T of object
|
||||
*/
|
||||
abstract class DocGenNormalizerTestAbstract extends KernelTestCase
|
||||
{
|
||||
public function testNullValueHasSameKeysAsNull(): void
|
||||
{
|
||||
$normalizedObject = $this->getNormalizer()->normalize($this->provideNotNullObject(), 'docgen', [
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => $this->provideDocGenExpectClass(),
|
||||
]);
|
||||
$nullNormalizedObject = $this->getNormalizer()->normalize(null, 'docgen', [
|
||||
AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => $this->provideDocGenExpectClass(),
|
||||
]);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($normalizedObject), array_keys($nullNormalizedObject));
|
||||
self::assertArrayHasKey('isNull', $nullNormalizedObject, 'each object must have an "isNull" key');
|
||||
self::assertTrue($nullNormalizedObject['isNull'], 'isNull key must be true for null objects');
|
||||
self::assertFalse($normalizedObject['isNull'], 'isNull key must be false for null objects');
|
||||
|
||||
foreach ($normalizedObject as $key => $value) {
|
||||
if (in_array($key, ['isNull', 'type'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
if (array_is_list($value)) {
|
||||
self::assertEquals([], $nullNormalizedObject[$key], "list must be serialized as an empty array, in {$key}");
|
||||
} else {
|
||||
self::assertEqualsCanonicalizing(array_keys($value), array_keys($nullNormalizedObject[$key]), "sub-object must have the same keys, in {$key}");
|
||||
}
|
||||
} elseif (is_string($value)) {
|
||||
self::assertEquals('', $nullNormalizedObject[$key], 'strings must be ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T
|
||||
*/
|
||||
abstract public function provideNotNullObject(): object;
|
||||
|
||||
/**
|
||||
* @return class-string<T>
|
||||
*/
|
||||
abstract public function provideDocGenExpectClass(): string;
|
||||
|
||||
abstract public function getNormalizer(): NormalizerInterface;
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
<?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\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Service\Signature\Driver\BaseSigner\RequestPdfSignMessage;
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFPage;
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
|
||||
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class SignatureRequestController
|
||||
{
|
||||
public function __construct(
|
||||
private MessageBusInterface $messageBus,
|
||||
private StoredObjectManagerInterface $storedObjectManager,
|
||||
) {}
|
||||
|
||||
#[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')]
|
||||
public function processSignature(StoredObject $storedObject): Response
|
||||
{
|
||||
$content = $this->storedObjectManager->read($storedObject);
|
||||
|
||||
$this->messageBus->dispatch(new RequestPdfSignMessage(
|
||||
0,
|
||||
new PDFSignatureZone(10.0, 10.0, 180.0, 180.0, new PDFPage(0, 500.0, 800.0)),
|
||||
0,
|
||||
'test signature',
|
||||
$content
|
||||
));
|
||||
|
||||
return new Response('<html><head><title>test</title></head><body><p>ok</p></body></html>');
|
||||
}
|
||||
}
|
@@ -313,19 +313,4 @@ class StoredObject implements Document, TrackCreationInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function saveHistory(): void
|
||||
{
|
||||
if ('' === $this->getFilename()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->datas['history'][] = [
|
||||
'filename' => $this->getFilename(),
|
||||
'iv' => $this->getIv(),
|
||||
'key_infos' => $this->getKeyInfos(),
|
||||
'type' => $this->getType(),
|
||||
'before' => (new \DateTimeImmutable('now'))->getTimestamp(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -57,8 +57,8 @@ class StoredObjectDataMapper implements DataMapperInterface
|
||||
|
||||
/** @var StoredObject $viewData */
|
||||
if ($viewData->getFilename() !== $forms['stored_object']->getData()['filename']) {
|
||||
// we want to keep the previous history
|
||||
$viewData->saveHistory();
|
||||
// we do not want to erase the previous object
|
||||
$viewData = new StoredObject();
|
||||
}
|
||||
|
||||
$viewData->setFilename($forms['stored_object']->getData()['filename']);
|
||||
|
@@ -4,13 +4,13 @@
|
||||
Actions
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li v-if="props.canEdit && is_extension_editable(props.storedObject.type) && props.storedObject.status !== 'stored_object_created'">
|
||||
<li v-if="props.canEdit && is_extension_editable(props.storedObject.type)">
|
||||
<wopi-edit-button :stored-object="props.storedObject" :classes="{'dropdown-item': true}" :execute-before-leave="props.executeBeforeLeave"></wopi-edit-button>
|
||||
</li>
|
||||
<li v-if="props.canEdit && is_extension_editable(props.storedObject.type) && props.davLink !== undefined && props.davLinkExpiration !== undefined">
|
||||
<desktop-edit-button :classes="{'dropdown-item': true}" :edit-link="props.davLink" :expiration-link="props.davLinkExpiration"></desktop-edit-button>
|
||||
</li>
|
||||
<li v-if="props.storedObject.type != 'application/pdf' && is_extension_viewable(props.storedObject.type) && props.canConvertPdf && props.storedObject.status !== 'stored_object_created'">
|
||||
<li v-if="props.storedObject.type != 'application/pdf' && is_extension_viewable(props.storedObject.type) && props.canConvertPdf">
|
||||
<convert-button :stored-object="props.storedObject" :filename="filename" :classes="{'dropdown-item': true}"></convert-button>
|
||||
</li>
|
||||
<li v-if="props.canDownload">
|
||||
|
@@ -13,7 +13,7 @@ import {reactive} from "vue";
|
||||
import {StoredObject, StoredObjectCreated} from "../../types";
|
||||
|
||||
interface ConvertButtonConfig {
|
||||
storedObject: StoredObject,
|
||||
storedObject: StoredObject|StoredObjectCreated,
|
||||
classes: { [key: string]: boolean},
|
||||
filename?: string,
|
||||
};
|
||||
|
@@ -11,7 +11,7 @@ import {build_wopi_editor_link} from "./helpers";
|
||||
import {StoredObject, StoredObjectCreated, WopiEditButtonExecutableBeforeLeaveFunction} from "../../types";
|
||||
|
||||
interface WopiEditButtonConfig {
|
||||
storedObject: StoredObject,
|
||||
storedObject: StoredObject|StoredObjectCreated,
|
||||
returnPath?: string,
|
||||
classes: {[k: string] : boolean},
|
||||
executeBeforeLeave?: WopiEditButtonExecutableBeforeLeaveFunction,
|
||||
|
@@ -0,0 +1,25 @@
|
||||
<?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\Service\Signature\Driver\BaseSigner;
|
||||
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
|
||||
|
||||
final readonly class RequestPdfSignMessage
|
||||
{
|
||||
public function __construct(
|
||||
public int $signatureId,
|
||||
public PDFSignatureZone $PDFSignatureZone,
|
||||
public int $signatureZoneIndex,
|
||||
public string $reason,
|
||||
public string $content,
|
||||
) {}
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
<?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\Service\Signature\Driver\BaseSigner;
|
||||
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
|
||||
use Symfony\Component\Messenger\Stamp\NonSendableStampInterface;
|
||||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
final readonly class RequestPdfSignMessageSerializer implements SerializerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private NormalizerInterface $normalizer,
|
||||
private DenormalizerInterface $denormalizer,
|
||||
) {}
|
||||
|
||||
public function decode(array $encodedEnvelope): Envelope
|
||||
{
|
||||
$body = $encodedEnvelope['body'];
|
||||
$headers = $encodedEnvelope['headers'];
|
||||
|
||||
if (RequestPdfSignMessage::class !== ($headers['Message'] ?? null)) {
|
||||
throw new MessageDecodingFailedException('serializer does not support this message');
|
||||
}
|
||||
|
||||
$data = json_decode($body, true);
|
||||
|
||||
$zoneSignature = $this->denormalizer->denormalize($data['signatureZone'], PDFSignatureZone::class, 'json', [
|
||||
AbstractNormalizer::GROUPS => ['write'],
|
||||
]);
|
||||
|
||||
$message = new RequestPdfSignMessage(
|
||||
$data['signatureId'],
|
||||
$zoneSignature,
|
||||
$data['signatureZoneIndex'],
|
||||
$data['reason'],
|
||||
base64_decode($data['content']),
|
||||
);
|
||||
|
||||
// in case of redelivery, unserialize any stamps
|
||||
$stamps = [];
|
||||
if (isset($headers['stamps'])) {
|
||||
$stamps = unserialize($headers['stamps']);
|
||||
}
|
||||
|
||||
return new Envelope($message, $stamps);
|
||||
}
|
||||
|
||||
public function encode(Envelope $envelope): array
|
||||
{
|
||||
$message = $envelope->getMessage();
|
||||
|
||||
if (!$message instanceof RequestPdfSignMessage) {
|
||||
throw new MessageDecodingFailedException('Message is not a RequestPdfSignMessage');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'signatureId' => $message->signatureId,
|
||||
'signatureZoneIndex' => $message->signatureZoneIndex,
|
||||
'signatureZone' => $this->normalizer->normalize($message->PDFSignatureZone, 'json', [AbstractNormalizer::GROUPS => ['read']]),
|
||||
'reason' => $message->reason,
|
||||
'content' => base64_encode($message->content),
|
||||
];
|
||||
|
||||
$allStamps = [];
|
||||
foreach ($envelope->all() as $stamp) {
|
||||
if ($stamp instanceof NonSendableStampInterface) {
|
||||
continue;
|
||||
}
|
||||
$allStamps = [...$allStamps, ...$stamp];
|
||||
}
|
||||
|
||||
return [
|
||||
'body' => json_encode($data, JSON_THROW_ON_ERROR, 512),
|
||||
'headers' => [
|
||||
'stamps' => serialize($allStamps),
|
||||
'Message' => RequestPdfSignMessage::class,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
33
src/Bundle/ChillDocStoreBundle/Service/Signature/PDFPage.php
Normal file
33
src/Bundle/ChillDocStoreBundle/Service/Signature/PDFPage.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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\Service\Signature;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
final readonly class PDFPage
|
||||
{
|
||||
public function __construct(
|
||||
#[Groups(['read'])]
|
||||
public int $index,
|
||||
#[Groups(['read'])]
|
||||
public float $width,
|
||||
#[Groups(['read'])]
|
||||
public float $height,
|
||||
) {}
|
||||
|
||||
public function equals(self $page): bool
|
||||
{
|
||||
return $page->index === $this->index
|
||||
&& round($page->width, 2) === round($this->width, 2)
|
||||
&& round($page->height, 2) === round($this->height, 2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
<?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\Service\Signature;
|
||||
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
final readonly class PDFSignatureZone
|
||||
{
|
||||
public function __construct(
|
||||
#[Groups(['read'])]
|
||||
public float $x,
|
||||
#[Groups(['read'])]
|
||||
public float $y,
|
||||
#[Groups(['read'])]
|
||||
public float $height,
|
||||
#[Groups(['read'])]
|
||||
public float $width,
|
||||
#[Groups(['read'])]
|
||||
public PDFPage $PDFPage,
|
||||
) {}
|
||||
|
||||
public function equals(self $other): bool
|
||||
{
|
||||
return
|
||||
$this->x == $other->x
|
||||
&& $this->y == $other->y
|
||||
&& $this->height == $other->height
|
||||
&& $this->width == $other->width
|
||||
&& $this->PDFPage->equals($other->PDFPage);
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Service\Signature;
|
||||
|
||||
use Smalot\PdfParser\Parser;
|
||||
|
||||
class PDFSignatureZoneParser
|
||||
{
|
||||
public const ZONE_SIGNATURE_START = 'signature_zone';
|
||||
|
||||
private Parser $parser;
|
||||
|
||||
public function __construct(
|
||||
public float $defaultHeight = 180.0,
|
||||
public float $defaultWidth = 180.0,
|
||||
) {
|
||||
$this->parser = new Parser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<PDFSignatureZone>
|
||||
*/
|
||||
public function findSignatureZones(string $fileContent): array
|
||||
{
|
||||
$pdf = $this->parser->parseContent($fileContent);
|
||||
$zones = [];
|
||||
|
||||
$defaults = $pdf->getObjectsByType('Pages');
|
||||
$defaultPage = reset($defaults);
|
||||
$defaultPageDetails = $defaultPage->getDetails();
|
||||
|
||||
foreach ($pdf->getPages() as $index => $page) {
|
||||
$details = $page->getDetails();
|
||||
$pdfPage = new PDFPage(
|
||||
$index,
|
||||
(float) ($details['MediaBox'][2] ?? $defaultPageDetails['MediaBox'][2]),
|
||||
(float) ($details['MediaBox'][3] ?? $defaultPageDetails['MediaBox'][3]),
|
||||
);
|
||||
|
||||
foreach ($page->getDataTm() as $dataTm) {
|
||||
if (str_starts_with($dataTm[1], self::ZONE_SIGNATURE_START)) {
|
||||
$zones[] = new PDFSignatureZone((float) $dataTm[0][4], (float) $dataTm[0][5], $this->defaultHeight, $this->defaultWidth, $pdfPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $zones;
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
<?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\Tests\Entity;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class StoredObjectTest extends KernelTestCase
|
||||
{
|
||||
public function testSaveHistory(): void
|
||||
{
|
||||
$storedObject = new StoredObject();
|
||||
$storedObject
|
||||
->setFilename('test_0')
|
||||
->setIv([2, 4, 6, 8])
|
||||
->setKeyInfos(['key' => ['data0' => 'data0']])
|
||||
->setType('text/html');
|
||||
|
||||
$storedObject->saveHistory();
|
||||
|
||||
$storedObject
|
||||
->setFilename('test_1')
|
||||
->setIv([8, 10, 12])
|
||||
->setKeyInfos(['key' => ['data1' => 'data1']])
|
||||
->setType('text/text');
|
||||
|
||||
$storedObject->saveHistory();
|
||||
|
||||
self::assertEquals('test_0', $storedObject->getDatas()['history'][0]['filename']);
|
||||
self::assertEquals([2, 4, 6, 8], $storedObject->getDatas()['history'][0]['iv']);
|
||||
self::assertEquals(['key' => ['data0' => 'data0']], $storedObject->getDatas()['history'][0]['key_infos']);
|
||||
self::assertEquals('text/html', $storedObject->getDatas()['history'][0]['type']);
|
||||
|
||||
self::assertEquals('test_1', $storedObject->getDatas()['history'][1]['filename']);
|
||||
self::assertEquals([8, 10, 12], $storedObject->getDatas()['history'][1]['iv']);
|
||||
self::assertEquals(['key' => ['data1' => 'data1']], $storedObject->getDatas()['history'][1]['key_infos']);
|
||||
self::assertEquals('text/text', $storedObject->getDatas()['history'][1]['type']);
|
||||
}
|
||||
}
|
@@ -56,14 +56,14 @@ class StoredObjectTypeTest extends TypeTestCase
|
||||
{"filename":"abcdef","iv":[10, 15, 20, 30],"keyInfos":[],"type":"text/html","status":"object_store_created"}
|
||||
JSON];
|
||||
$model = new StoredObject();
|
||||
$originalObjectId = spl_object_hash($model);
|
||||
$originalObjectId = spl_object_id($model);
|
||||
$form = $this->factory->create(StoredObjectType::class, $model, ['has_title' => true]);
|
||||
|
||||
$form->submit($formData);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$model = $form->getData();
|
||||
$this->assertEquals($originalObjectId, spl_object_hash($model));
|
||||
$this->assertNotEquals($originalObjectId, spl_object_hash($model));
|
||||
$this->assertEquals('abcdef', $model->getFilename());
|
||||
$this->assertEquals([10, 15, 20, 30], $model->getIv());
|
||||
$this->assertEquals('text/html', $model->getType());
|
||||
|
@@ -0,0 +1,132 @@
|
||||
<?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\Tests\Service\Signature\Driver\BaseSigner;
|
||||
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFPage;
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
|
||||
use Chill\DocStoreBundle\Service\Signature\Driver\BaseSigner\RequestPdfSignMessage;
|
||||
use Chill\DocStoreBundle\Service\Signature\Driver\BaseSigner\RequestPdfSignMessageSerializer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class RequestPdfSignMessageSerializerTest extends TestCase
|
||||
{
|
||||
public function testEncode(): void
|
||||
{
|
||||
$serializer = $this->buildSerializer();
|
||||
|
||||
$envelope = new Envelope(
|
||||
$request = new RequestPdfSignMessage(
|
||||
0,
|
||||
new PDFSignatureZone(10.0, 10.0, 180.0, 180.0, new PDFPage(0, 500.0, 800.0)),
|
||||
0,
|
||||
'metadata to add to the signature',
|
||||
'abc'
|
||||
),
|
||||
);
|
||||
|
||||
$actual = $serializer->encode($envelope);
|
||||
$expectedBody = json_encode([
|
||||
'signatureId' => $request->signatureId,
|
||||
'signatureZoneIndex' => $request->signatureZoneIndex,
|
||||
'signatureZone' => ['x' => 10.0],
|
||||
'reason' => $request->reason,
|
||||
'content' => base64_encode($request->content),
|
||||
]);
|
||||
|
||||
self::assertIsArray($actual);
|
||||
self::assertArrayHasKey('body', $actual);
|
||||
self::assertArrayHasKey('headers', $actual);
|
||||
self::assertEquals($expectedBody, $actual['body']);
|
||||
}
|
||||
|
||||
public function testDecode(): void
|
||||
{
|
||||
$serializer = $this->buildSerializer();
|
||||
|
||||
$request = new RequestPdfSignMessage(
|
||||
0,
|
||||
new PDFSignatureZone(10.0, 10.0, 180.0, 180.0, new PDFPage(0, 500.0, 800.0)),
|
||||
0,
|
||||
'metadata to add to the signature',
|
||||
'abc'
|
||||
);
|
||||
|
||||
$bodyAsString = json_encode([
|
||||
'signatureId' => $request->signatureId,
|
||||
'signatureZoneIndex' => $request->signatureZoneIndex,
|
||||
'signatureZone' => ['x' => 10.0],
|
||||
'reason' => $request->reason,
|
||||
'content' => base64_encode($request->content),
|
||||
], JSON_THROW_ON_ERROR);
|
||||
|
||||
$actual = $serializer->decode([
|
||||
'body' => $bodyAsString,
|
||||
'headers' => [
|
||||
'Message' => RequestPdfSignMessage::class,
|
||||
],
|
||||
]);
|
||||
|
||||
self::assertInstanceOf(RequestPdfSignMessage::class, $actual->getMessage());
|
||||
self::assertEquals($request->signatureId, $actual->getMessage()->signatureId);
|
||||
self::assertEquals($request->signatureZoneIndex, $actual->getMessage()->signatureZoneIndex);
|
||||
self::assertEquals($request->reason, $actual->getMessage()->reason);
|
||||
self::assertEquals($request->content, $actual->getMessage()->content);
|
||||
self::assertNotNull($actual->getMessage()->PDFSignatureZone);
|
||||
}
|
||||
|
||||
private function buildSerializer(): RequestPdfSignMessageSerializer
|
||||
{
|
||||
$normalizer =
|
||||
new class () implements NormalizerInterface {
|
||||
public function normalize($object, ?string $format = null, array $context = []): array
|
||||
{
|
||||
if (!$object instanceof PDFSignatureZone) {
|
||||
throw new UnexpectedValueException('expected RequestPdfSignMessage');
|
||||
}
|
||||
|
||||
return [
|
||||
'x' => $object->x,
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, ?string $format = null): bool
|
||||
{
|
||||
return $data instanceof PDFSignatureZone;
|
||||
}
|
||||
};
|
||||
$denormalizer = new class () implements DenormalizerInterface {
|
||||
public function denormalize($data, string $type, ?string $format = null, array $context = [])
|
||||
{
|
||||
return new PDFSignatureZone(10.0, 10.0, 180.0, 180.0, new PDFPage(0, 500.0, 800.0));
|
||||
}
|
||||
|
||||
public function supportsDenormalization($data, string $type, ?string $format = null)
|
||||
{
|
||||
return PDFSignatureZone::class === $type;
|
||||
}
|
||||
};
|
||||
|
||||
$serializer = new Serializer([$normalizer, $denormalizer]);
|
||||
|
||||
return new RequestPdfSignMessageSerializer($serializer, $serializer);
|
||||
}
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
<?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 Tests\Service\Signature;
|
||||
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFPage;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZoneParser;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class PDFSignatureZoneParserTest extends TestCase
|
||||
{
|
||||
private static PDFSignatureZoneParser $parser;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$parser = new PDFSignatureZoneParser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFiles
|
||||
*
|
||||
* @param list<PDFSignatureZone> $expected
|
||||
*/
|
||||
public function testFindSignatureZones(string $filePath, array $expected): void
|
||||
{
|
||||
$content = file_get_contents($filePath);
|
||||
|
||||
if (false === $content) {
|
||||
throw new \LogicException("Unable to read file {$filePath}");
|
||||
}
|
||||
|
||||
$actual = self::$parser->findSignatureZones($content);
|
||||
|
||||
self::assertEquals(count($expected), count($actual));
|
||||
|
||||
foreach ($actual as $index => $signatureZone) {
|
||||
self::assertObjectEquals($expected[$index], $signatureZone);
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideFiles(): iterable
|
||||
{
|
||||
yield [
|
||||
__DIR__.'/data/signature_2_signature_page_1.pdf',
|
||||
[
|
||||
new PDFSignatureZone(
|
||||
127.7,
|
||||
95.289,
|
||||
180.0,
|
||||
180.0,
|
||||
$page = new PDFPage(0, 595.30393, 841.8897)
|
||||
),
|
||||
new PDFSignatureZone(
|
||||
269.5,
|
||||
95.289,
|
||||
180.0,
|
||||
180.0,
|
||||
$page,
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
Binary file not shown.
@@ -632,7 +632,7 @@ class ExportController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
private function rebuildRawData(?string $key): array
|
||||
private function rebuildRawData(string $key): array
|
||||
{
|
||||
if (null === $key) {
|
||||
throw $this->createNotFoundException('key does not exists');
|
||||
|
@@ -216,13 +216,13 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
|
||||
return $this->mainLocation;
|
||||
}
|
||||
|
||||
public function getMainScope(?\DateTimeImmutable $atDate = null): ?Scope
|
||||
public function getMainScope(?\DateTimeImmutable $at = null): ?Scope
|
||||
{
|
||||
$atDate ??= new \DateTimeImmutable('now');
|
||||
$at ??= new \DateTimeImmutable('now');
|
||||
|
||||
foreach ($this->scopeHistories as $scopeHistory) {
|
||||
if ($atDate >= $scopeHistory->getStartDate() && (
|
||||
null === $scopeHistory->getEndDate() || $atDate < $scopeHistory->getEndDate()
|
||||
if ($at >= $scopeHistory->getStartDate() && (
|
||||
null === $scopeHistory->getEndDate() || $at < $scopeHistory->getEndDate()
|
||||
)) {
|
||||
return $scopeHistory->getScope();
|
||||
}
|
||||
@@ -265,13 +265,13 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
|
||||
return $this->salt;
|
||||
}
|
||||
|
||||
public function getUserJob(?\DateTimeImmutable $atDate = null): ?UserJob
|
||||
public function getUserJob(?\DateTimeImmutable $at = null): ?UserJob
|
||||
{
|
||||
$atDate ??= new \DateTimeImmutable('now');
|
||||
$at ??= new \DateTimeImmutable('now');
|
||||
|
||||
foreach ($this->jobHistories as $jobHistory) {
|
||||
if ($atDate >= $jobHistory->getStartDate() && (
|
||||
null === $jobHistory->getEndDate() || $atDate < $jobHistory->getEndDate()
|
||||
if ($at >= $jobHistory->getStartDate() && (
|
||||
null === $jobHistory->getEndDate() || $at < $jobHistory->getEndDate()
|
||||
)) {
|
||||
return $jobHistory->getJob();
|
||||
}
|
||||
@@ -285,11 +285,6 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
|
||||
return $this->jobHistories;
|
||||
}
|
||||
|
||||
public function getUserScopeHistories(): Collection
|
||||
{
|
||||
return $this->scopeHistories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection|UserJobHistory[]
|
||||
*/
|
||||
|
@@ -1,25 +0,0 @@
|
||||
<?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\MainBundle\Export;
|
||||
|
||||
/**
|
||||
* Transform data from filter.
|
||||
*
|
||||
* This interface defines a method for transforming filter's form data before it is processed.
|
||||
*
|
||||
* You can implement this interface on @see{FilterInterface} or @see{AggregatorInterface}, to allow to transform existing data in saved exports
|
||||
* and replace it with some default values, or new default values.
|
||||
*/
|
||||
interface DataTransformerInterface
|
||||
{
|
||||
public function transformData(?array $before): array;
|
||||
}
|
@@ -32,9 +32,6 @@ interface FilterInterface extends ModifierInterface
|
||||
|
||||
/**
|
||||
* Get the default data, that can be use as "data" for the form.
|
||||
*
|
||||
* In case of adding new parameters to a filter, you can implement a @see{DataTransformerFilterInterface} to
|
||||
* transforme the filters's data saved in an export to the desired state.
|
||||
*/
|
||||
public function getFormDefaultData(): array;
|
||||
|
||||
|
@@ -11,9 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Form\Type\Export;
|
||||
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -21,7 +19,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class AggregatorType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
public function __construct() {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$exportManager = $options['export_manager'];
|
||||
$aggregator = $exportManager->getAggregator($options['aggregator_alias']);
|
||||
@@ -32,24 +32,17 @@ class AggregatorType extends AbstractType
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
$aggregatorFormBuilder = $builder->create('form', FormType::class, [
|
||||
$filterFormBuilder = $builder->create('form', FormType::class, [
|
||||
'compound' => true,
|
||||
'required' => false,
|
||||
'error_bubbling' => false,
|
||||
]);
|
||||
$aggregator->buildForm($aggregatorFormBuilder);
|
||||
$aggregator->buildForm($filterFormBuilder);
|
||||
|
||||
if ($aggregator instanceof DataTransformerInterface) {
|
||||
$aggregatorFormBuilder->addViewTransformer(new CallbackTransformer(
|
||||
fn (?array $data) => $data,
|
||||
fn (?array $data) => $aggregator->transformData($data),
|
||||
));
|
||||
}
|
||||
|
||||
$builder->add($aggregatorFormBuilder);
|
||||
$builder->add($filterFormBuilder);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setRequired('aggregator_alias')
|
||||
->setRequired('export_manager')
|
||||
|
@@ -11,10 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Form\Type\Export;
|
||||
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -43,13 +41,6 @@ class FilterType extends AbstractType
|
||||
]);
|
||||
$filter->buildForm($filterFormBuilder);
|
||||
|
||||
if ($filter instanceof DataTransformerInterface) {
|
||||
$filterFormBuilder->addViewTransformer(new CallbackTransformer(
|
||||
fn (?array $data) => $data,
|
||||
fn (?array $data) => $filter->transformData($data),
|
||||
));
|
||||
}
|
||||
|
||||
$builder->add($filterFormBuilder);
|
||||
}
|
||||
|
||||
|
@@ -43,14 +43,7 @@ export const download_report = (url, container) => {
|
||||
content = URL.createObjectURL(blob);
|
||||
}
|
||||
|
||||
const extensions = new Map();
|
||||
extensions.set('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx');
|
||||
extensions.set('application/vnd.oasis.opendocument.spreadsheet', 'ods');
|
||||
extensions.set('application/vnd.ms-excel', 'xlsx');
|
||||
extensions.set('text/csv', 'csv');
|
||||
extensions.set('text/csv; charset=utf-8', 'csv');
|
||||
|
||||
extension = extensions.get(type);
|
||||
extension = mime.getExtension(type);
|
||||
|
||||
link.appendChild(document.createTextNode(download_text));
|
||||
link.classList.add("btn", "btn-action");
|
||||
@@ -62,7 +55,7 @@ export const download_report = (url, container) => {
|
||||
container.innerHTML = "";
|
||||
container.appendChild(link);
|
||||
}).catch(function(error) {
|
||||
console.error(error);
|
||||
console.log(error);
|
||||
var problem_text =
|
||||
document.createTextNode("Problem during download");
|
||||
|
||||
|
@@ -12,5 +12,5 @@ window.addEventListener("DOMContentLoaded", function(e) {
|
||||
container = document.querySelector("#download_container")
|
||||
;
|
||||
|
||||
download_report(export_generate_url + query.toString(), container);
|
||||
download_report(export_generate_url + "?" + query.toString(), container);
|
||||
});
|
||||
|
@@ -139,7 +139,7 @@ const postprocess = (html: string): string => {
|
||||
}
|
||||
|
||||
const convertMarkdownToHtml = (markdown: string): string => {
|
||||
marked.use({'hooks': {postprocess, preprocess}, 'async': false});
|
||||
marked.use({'hooks': {postprocess, preprocess}});
|
||||
const rawHtml = marked(markdown) as string;
|
||||
return rawHtml;
|
||||
};
|
||||
|
@@ -40,10 +40,10 @@
|
||||
{{ 'by_user'|trans ~ ' ' }}
|
||||
{% endif %}
|
||||
<span class="user">
|
||||
{{ user|chill_entity_render_box({'at_date': comment.date}) }}
|
||||
{{ user|chill_entity_render_box(options['user']) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</blockquote>
|
||||
{{ closing_box|raw }}
|
||||
{{ closing_box|raw }}
|
@@ -1,10 +1,10 @@
|
||||
<span class="chill-entity entity-user">
|
||||
{{- user.label }}
|
||||
{%- if opts['user_job'] and user.userJob(opts['at_date']) is not null %}
|
||||
<span class="user-job">({{ user.userJob(opts['at_date']).label|localize_translatable_string }})</span>
|
||||
{%- if opts['user_job'] and user.userJob(opts['at']) is not null %}
|
||||
<span class="user-job">({{ user.userJob(opts['at']).label|localize_translatable_string }})</span>
|
||||
{%- endif -%}
|
||||
{%- if opts['main_scope'] and user.mainScope(opts['at_date']) is not null %}
|
||||
<span class="main-scope">({{ user.mainScope(opts['at_date']).name|localize_translatable_string }})</span>
|
||||
{%- if opts['main_scope'] and user.mainScope(opts['at']) is not null %}
|
||||
<span class="main-scope">({{ user.mainScope(opts['at']).name|localize_translatable_string }})</span>
|
||||
{%- endif -%}
|
||||
{%- if opts['absence'] and user.isAbsent %}
|
||||
<span class="badge bg-danger rounded-pill" title="{{ 'absence.Absent'|trans|escape('html_attr') }}">{{ 'absence.A'|trans }}</span>
|
||||
|
@@ -1,20 +0,0 @@
|
||||
{% if menus|length > 0 %}
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle btn btn-sm btn-outline-primary"
|
||||
href="#"
|
||||
role="button"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
<i class="fa fa-flash"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu">
|
||||
{% for menu in menus %}
|
||||
<a class="dropdown-item"
|
||||
href="{{ menu.uri }}"
|
||||
><i class="fa fa-{{- menu.extras.icon }} fa-fw"></i>
|
||||
{{ menu.label|trans }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
@@ -21,7 +21,7 @@
|
||||
</span>
|
||||
{% if not c.notification.isSystem %}
|
||||
<span class="badge-user">
|
||||
{{ c.notification.sender|chill_entity_render_string({'at_date': c.notification.date}) }}
|
||||
{{ c.notification.sender|chill_entity_render_string }}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="badge-user system">{{ 'notification.is_system'|trans }}</span>
|
||||
@@ -53,7 +53,7 @@
|
||||
{% endif %}
|
||||
{% for a in c.notification.addressees %}
|
||||
<span class="badge-user">
|
||||
{{ a|chill_entity_render_string({'at_date': c.notification.date}) }}
|
||||
{{ a|chill_entity_render_string }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
{% for a in c.notification.addressesEmails %}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{% extends "@ChillMain/layout.html.twig" %}
|
||||
|
||||
{% block title 'notification.show notification from %sender%'|trans(
|
||||
{ '%sender%': notification.sender|chill_entity_render_string({'at_date': notification.date}) }
|
||||
{ '%sender%': notification.sender|chill_entity_render_string }
|
||||
) ~ ' ' ~ notification.title %}
|
||||
|
||||
{% block js %}
|
||||
|
@@ -31,14 +31,14 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{{ 'By'|trans }}
|
||||
{{ step.previous.transitionBy|chill_entity_render_box({'at_date': step.previous.transitionAt }) }},
|
||||
{{ step.previous.transitionBy|chill_entity_render_box }},
|
||||
{{ step.previous.transitionAt|format_datetime('short', 'short') }}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="row">
|
||||
<div class="col-sm-4">{{ 'workflow.Created by'|trans }}</div>
|
||||
<div class="col-sm-8">{{ step.entityWorkflow.createdBy|chill_entity_render_box({'at_date': step.entityWorkflow.createdAt}) }}</div>
|
||||
<div class="col-sm-8">{{ step.entityWorkflow.createdBy|chill_entity_render_box }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4">{{ 'Le'|trans }}</div>
|
||||
@@ -110,8 +110,8 @@
|
||||
{% if entity_workflow.currentStep.destUserByAccessKey|length > 0 %}
|
||||
<p><b>{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :</b></p>
|
||||
<ul>
|
||||
{% for u in entity_workflow.currentStepChained.destUserByAccessKey %}
|
||||
<li>{{ u|chill_entity_render_box({'at_date': entity_workflow.currentStepChained.previous.transitionAt }) }}</li>
|
||||
{% for u in entity_workflow.currentStep.destUserByAccessKey %}
|
||||
<li>{{ u|chill_entity_render_box }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
@@ -42,7 +42,7 @@
|
||||
<div class="item-col" style="width: inherit;">
|
||||
{% if step.transitionBy is not null %}
|
||||
<div>
|
||||
{{ step.transitionBy|chill_entity_render_box({'at_date': step.transitionAt}) }}
|
||||
{{ step.transitionBy|chill_entity_render_box }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>
|
||||
@@ -76,7 +76,7 @@
|
||||
<p><b>{{ 'workflow.Users allowed to apply transition'|trans }} : </b></p>
|
||||
<ul>
|
||||
{% for u in step.destUser %}
|
||||
<li>{{ u|chill_entity_render_box({'at_date': step.previous.transitionAt}) }}</li>
|
||||
<li>{{ u|chill_entity_render_box }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
@@ -85,7 +85,7 @@
|
||||
<p><b>{{ 'workflow.Users put in Cc'|trans }} : </b></p>
|
||||
<ul>
|
||||
{% for u in step.ccUser %}
|
||||
<li>{{ u|chill_entity_render_box({'at_date': step.previous.transitionAt}) }}</li>
|
||||
<li>{{ u|chill_entity_render_box }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
@@ -103,7 +103,7 @@
|
||||
<p><b>{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :</b></p>
|
||||
<ul>
|
||||
{% for u in step.destUserByAccessKey %}
|
||||
<li>{{ u|chill_entity_render_box({'at_date': step.previous.transitionAt}) }}</li>
|
||||
<li>{{ u|chill_entity_render_box }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
{% if step.previous is not null %}
|
||||
<li>
|
||||
<span class="item-key">{{ 'By'|trans ~ ' : ' }}</span>
|
||||
<b>{{ step.previous.transitionBy|chill_entity_render_box({'at_date': step.previous.transitionAt }) }}</b>
|
||||
<b>{{ step.previous.transitionBy|chill_entity_render_box }}</b>
|
||||
</li>
|
||||
<li>
|
||||
<span class="item-key">{{ 'Le'|trans ~ ' : ' }}</span>
|
||||
@@ -12,19 +12,19 @@
|
||||
<li>
|
||||
<span class="item-key">{{ 'workflow.For'|trans ~ ' : ' }}</span>
|
||||
<b>
|
||||
{% for d in step.destUser %}{{ d|chill_entity_render_string({'at_date': step.previous.transitionAt}) }}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
{% for d in step.destUser %}{{ d|chill_entity_render_string }}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</b>
|
||||
</li>
|
||||
<li>
|
||||
<span class="item-key">{{ 'workflow.Cc'|trans ~ ' : ' }}</span>
|
||||
<b>
|
||||
{% for u in step.ccUser %}{{ u|chill_entity_render_string({'at_date': step.previous.transitionAt }) }}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
{% for u in step.ccUser %}{{ u|chill_entity_render_string }}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</b>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<span class="item-key">{{ 'workflow.Created by'|trans ~ ' : ' }}</span>
|
||||
<b>{{ step.entityWorkflow.createdBy|chill_entity_render_box({'at_date': step.entityWorkflow.createdAt }) }}</b>
|
||||
<b>{{ step.entityWorkflow.createdBy|chill_entity_render_box }}</b>
|
||||
</li>
|
||||
<li>
|
||||
<span class="item-key">{{ 'Le'|trans ~ ' : ' }}</span>
|
||||
|
@@ -11,6 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Routing;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
@@ -18,8 +20,10 @@ use Twig\TwigFunction;
|
||||
/**
|
||||
* Add the filter 'chill_menu'.
|
||||
*/
|
||||
class MenuTwig extends AbstractExtension
|
||||
class MenuTwig extends AbstractExtension implements ContainerAwareInterface
|
||||
{
|
||||
private ?ContainerInterface $container = null;
|
||||
|
||||
/**
|
||||
* the default parameters for chillMenu.
|
||||
*
|
||||
@@ -80,4 +84,9 @@ class MenuTwig extends AbstractExtension
|
||||
{
|
||||
return 'chill_menu';
|
||||
}
|
||||
|
||||
public function setContainer(?ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ class EntityWorkflowStepNormalizer implements NormalizerAwareInterface, Normaliz
|
||||
$data['transitionPreviousBy'] = $this->normalizer->normalize(
|
||||
$previous->getTransitionBy(),
|
||||
$format,
|
||||
[...$context, UserNormalizer::AT_DATE => $previous->getTransitionAt()]
|
||||
$context
|
||||
);
|
||||
$data['transitionPreviousAt'] = $this->normalizer->normalize(
|
||||
$previous->getTransitionAt(),
|
||||
|
@@ -45,7 +45,7 @@ class NotificationNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
'message' => $object->getMessage(),
|
||||
'relatedEntityClass' => $object->getRelatedEntityClass(),
|
||||
'relatedEntityId' => $object->getRelatedEntityId(),
|
||||
'sender' => $this->normalizer->normalize($object->getSender(), $format, [...$context, UserNormalizer::AT_DATE => $object->getDate()]),
|
||||
'sender' => $this->normalizer->normalize($object->getSender(), $format, $context),
|
||||
'title' => $object->getTitle(),
|
||||
'entity' => null !== $entity ? $this->normalizer->normalize($entity, $format, $context) : null,
|
||||
];
|
||||
|
@@ -19,7 +19,6 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
@@ -28,8 +27,6 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
final public const AT_DATE = 'chill:user:at_date';
|
||||
|
||||
final public const NULL_USER = [
|
||||
'type' => 'user',
|
||||
'id' => '',
|
||||
@@ -41,16 +38,10 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
'isAbsent' => false,
|
||||
];
|
||||
|
||||
public function __construct(private readonly UserRender $userRender, private readonly ClockInterface $clock) {}
|
||||
public function __construct(private readonly UserRender $userRender) {}
|
||||
|
||||
/**
|
||||
* @param mixed|null $format
|
||||
*
|
||||
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
|
||||
*/
|
||||
public function normalize($object, $format = null, array $context = [])
|
||||
{
|
||||
/** @var array{"chill:user:at_date"?: \DateTimeImmutable|\DateTime} $context */
|
||||
/** @var User $object */
|
||||
$userJobContext = array_merge(
|
||||
$context,
|
||||
@@ -81,23 +72,18 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
|
||||
return [...self::NULL_USER, 'phonenumber' => $this->normalizer->normalize(null, $format, $phonenumberContext), 'civility' => $this->normalizer->normalize(null, $format, $civilityContext), 'user_job' => $this->normalizer->normalize(null, $format, $userJobContext), 'main_center' => $this->normalizer->normalize(null, $format, $centerContext), 'main_scope' => $this->normalizer->normalize(null, $format, $scopeContext), 'current_location' => $this->normalizer->normalize(null, $format, $locationContext), 'main_location' => $this->normalizer->normalize(null, $format, $locationContext)];
|
||||
}
|
||||
|
||||
$at = $context[self::AT_DATE] ?? $this->clock->now();
|
||||
if ($at instanceof \DateTime) {
|
||||
$at = \DateTimeImmutable::createFromMutable($at);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'type' => 'user',
|
||||
'id' => $object->getId(),
|
||||
'username' => $object->getUsername(),
|
||||
'text' => $this->userRender->renderString($object, ['at_date' => $at]),
|
||||
'text' => $this->userRender->renderString($object, []),
|
||||
'text_without_absent' => $this->userRender->renderString($object, ['absence' => false]),
|
||||
'label' => $object->getLabel(),
|
||||
'email' => (string) $object->getEmail(),
|
||||
'phonenumber' => $this->normalizer->normalize($object->getPhonenumber(), $format, $phonenumberContext),
|
||||
'user_job' => $this->normalizer->normalize($object->getUserJob($at), $format, $userJobContext),
|
||||
'user_job' => $this->normalizer->normalize($object->getUserJob(), $format, $userJobContext),
|
||||
'main_center' => $this->normalizer->normalize($object->getMainCenter(), $format, $centerContext),
|
||||
'main_scope' => $this->normalizer->normalize($object->getMainScope($at), $format, $scopeContext),
|
||||
'main_scope' => $this->normalizer->normalize($object->getMainScope(), $format, $scopeContext),
|
||||
'isAbsent' => $object->isAbsent(),
|
||||
];
|
||||
|
||||
|
@@ -12,14 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
|
||||
/**
|
||||
* @implements ChillEntityRenderInterface<User>
|
||||
@@ -30,31 +24,15 @@ class UserRender implements ChillEntityRenderInterface
|
||||
'main_scope' => true,
|
||||
'user_job' => true,
|
||||
'absence' => true,
|
||||
'at_date' => null, // instanceof DateTimeInterface
|
||||
'at' => null,
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private readonly \Twig\Environment $engine,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly ClockInterface $clock,
|
||||
) {}
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator) {}
|
||||
|
||||
/**
|
||||
* @throws LoaderError
|
||||
* @throws RuntimeError
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
public function renderBox($entity, array $options): string
|
||||
{
|
||||
$opts = \array_merge(self::DEFAULT_OPTIONS, $options);
|
||||
|
||||
if (null === $opts['at_date']) {
|
||||
$opts['at_date'] = $this->clock->now();
|
||||
} elseif ($opts['at_date'] instanceof \DateTime) {
|
||||
$opts['at_date'] = \DateTimeImmutable::createFromMutable($opts['at_date']);
|
||||
}
|
||||
|
||||
return $this->engine->render('@ChillMain/Entity/user.html.twig', [
|
||||
'user' => $entity,
|
||||
'opts' => $opts,
|
||||
@@ -65,24 +43,16 @@ class UserRender implements ChillEntityRenderInterface
|
||||
{
|
||||
$opts = \array_merge(self::DEFAULT_OPTIONS, $options);
|
||||
|
||||
// $immutableAtDate = $opts['at_date'] instanceOf DateTime ? DateTimeImmutable::createFromMutable($opts['at_date']) : $opts['at_date'];
|
||||
|
||||
if (null === $opts['at_date']) {
|
||||
$opts['at_date'] = $this->clock->now();
|
||||
} elseif ($opts['at_date'] instanceof \DateTime) {
|
||||
$opts['at_date'] = \DateTimeImmutable::createFromMutable($opts['at_date']);
|
||||
}
|
||||
|
||||
$str = $entity->getLabel();
|
||||
|
||||
if (null !== $entity->getUserJob($opts['at_date']) && $opts['user_job']) {
|
||||
if (null !== $entity->getUserJob($opts['at']) && $opts['user_job']) {
|
||||
$str .= ' ('.$this->translatableStringHelper
|
||||
->localize($entity->getUserJob($opts['at_date'])->getLabel()).')';
|
||||
->localize($entity->getUserJob($opts['at'])->getLabel()).')';
|
||||
}
|
||||
|
||||
if (null !== $entity->getMainScope($opts['at_date']) && $opts['main_scope']) {
|
||||
if (null !== $entity->getMainScope($opts['at']) && $opts['main_scope']) {
|
||||
$str .= ' ('.$this->translatableStringHelper
|
||||
->localize($entity->getMainScope($opts['at_date'])->getName()).')';
|
||||
->localize($entity->getMainScope($opts['at'])->getName()).')';
|
||||
}
|
||||
|
||||
if ($entity->isAbsent() && $opts['absence']) {
|
||||
|
@@ -338,11 +338,15 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
.'is a string or an be converted to a string', $key)
|
||||
);
|
||||
|
||||
$head = \call_user_func($closure, '_header');
|
||||
|
||||
self::assertIsString($head);
|
||||
self::assertNotEquals('', $head);
|
||||
self::assertNotEquals('_header', $head);
|
||||
$this->assertTrue(
|
||||
// conditions
|
||||
\is_string((string) \call_user_func($closure, '_header'))
|
||||
&& !empty(\call_user_func($closure, '_header'))
|
||||
&& '_header' !== \call_user_func($closure, '_header'),
|
||||
// message
|
||||
sprintf('Test that the callable return by `getLabels` for key %s '
|
||||
.'can provide an header', $key)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@ use libphonenumber\PhoneNumberUtil;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\Clock\MockClock;
|
||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
@@ -123,9 +122,7 @@ final class UserNormalizerTest extends TestCase
|
||||
$userRender = $this->prophesize(UserRender::class);
|
||||
$userRender->renderString(Argument::type(User::class), Argument::type('array'))->willReturn($user ? $user->getLabel() : '');
|
||||
|
||||
$clock = new MockClock(new \DateTimeImmutable('now'));
|
||||
|
||||
$normalizer = new UserNormalizer($userRender->reveal(), $clock);
|
||||
$normalizer = new UserNormalizer($userRender->reveal());
|
||||
$normalizer->setNormalizer(new class () implements NormalizerInterface {
|
||||
public function normalize($object, ?string $format = null, array $context = [])
|
||||
{
|
||||
|
@@ -1,109 +0,0 @@
|
||||
<?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 Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\Clock\MockClock;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class UserRenderTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testRenderUserWithJobAndScopeAtCertainDate(): void
|
||||
{
|
||||
// Create a user with a certain user job
|
||||
|
||||
$user = new User();
|
||||
$userJobA = new UserJob();
|
||||
$scopeA = new Scope();
|
||||
|
||||
$userJobA->setLabel(['fr' => 'assistant social'])
|
||||
->setActive(true);
|
||||
$scopeA->setName(['fr' => 'service A']);
|
||||
$user->setLabel('BOB ISLA');
|
||||
|
||||
$userJobB = new UserJob();
|
||||
$scopeB = new Scope();
|
||||
|
||||
$userJobB->setLabel(['fr' => 'directrice'])
|
||||
->setActive(true);
|
||||
$scopeB->setName(['fr' => 'service B']);
|
||||
|
||||
$userJobHistoryA = (new User\UserJobHistory())
|
||||
->setUser($user)
|
||||
->setJob($userJobA)
|
||||
->setStartDate(new \DateTimeImmutable('2023-11-01 12:00:00'))
|
||||
->setEndDate(new \DateTimeImmutable('2023-11-30 00:00:00'));
|
||||
|
||||
$userScopeHistoryA = (new User\UserScopeHistory())
|
||||
->setUser($user)
|
||||
->setScope($scopeA)
|
||||
->setStartDate(new \DateTimeImmutable('2023-11-01 12:00:00'))
|
||||
->setEndDate(new \DateTimeImmutable('2023-11-30 00:00:00'));
|
||||
|
||||
$userJobHistoryB = (new User\UserJobHistory())
|
||||
->setUser($user)
|
||||
->setJob($userJobB)
|
||||
->setStartDate(new \DateTimeImmutable('2023-12-01 12:00:00'));
|
||||
|
||||
$userScopeHistoryB = (new User\UserScopeHistory())
|
||||
->setUser($user)
|
||||
->setScope($scopeB)
|
||||
->setStartDate(new \DateTimeImmutable('2023-12-01 12:00:00'));
|
||||
|
||||
$user->getUserJobHistories()->add($userJobHistoryA);
|
||||
$user->getUserScopeHistories()->add($userScopeHistoryA);
|
||||
|
||||
$user->getUserJobHistories()->add($userJobHistoryB);
|
||||
$user->getUserScopeHistories()->add($userScopeHistoryB);
|
||||
|
||||
// Create renderer
|
||||
$translatableStringHelperMock = $this->prophesize(TranslatableStringHelperInterface::class);
|
||||
$translatableStringHelperMock->localize(Argument::type('array'))->will(fn ($args) => $args[0]['fr']);
|
||||
|
||||
$engineMock = $this->createMock(Environment::class);
|
||||
$translatorMock = $this->createMock(TranslatorInterface::class);
|
||||
$clock = new MockClock(new \DateTimeImmutable('2023-12-15 12:00:00'));
|
||||
|
||||
$renderer = new UserRender($translatableStringHelperMock->reveal(), $engineMock, $translatorMock, $clock);
|
||||
|
||||
$optionsNoDate['at_date'] = null;
|
||||
$options['at_date'] = new \DateTime('2023-11-25 12:00:00');
|
||||
$optionsTwo['at_date'] = new \DateTime('2024-01-30 12:00:00');
|
||||
|
||||
// Check that the user render for the first activity corresponds with the first user job
|
||||
$expectedStringA = 'BOB ISLA (assistant social) (service A)';
|
||||
$this->assertEquals($expectedStringA, $renderer->renderString($user, $options));
|
||||
|
||||
// Check that the user render for the second activity corresponds with the second user job
|
||||
$expectedStringB = 'BOB ISLA (directrice) (service B)';
|
||||
$this->assertEquals($expectedStringB, $renderer->renderString($user, $optionsTwo));
|
||||
|
||||
// Check that the user renders the job and scope that is active now, when no date is given
|
||||
$expectedStringC = 'BOB ISLA (directrice) (service B)';
|
||||
$this->assertEquals($expectedStringC, $renderer->renderString($user, $optionsNoDate));
|
||||
}
|
||||
}
|
@@ -20,5 +20,9 @@ services:
|
||||
|
||||
chill.main.twig.chill_menu:
|
||||
class: Chill\MainBundle\Routing\MenuTwig
|
||||
arguments:
|
||||
- "@chill.main.menu_composer"
|
||||
calls:
|
||||
- [setContainer, ["@service_container"]]
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
@@ -707,24 +707,19 @@ class AccompanyingPeriod implements
|
||||
public function getNextCalendarsForPerson(Person $person, $limit = 5): ReadableCollection
|
||||
{
|
||||
$today = new \DateTimeImmutable('today');
|
||||
$criteria = Criteria::create()
|
||||
->where(Criteria::expr()->gte('startDate', $today))
|
||||
// ->andWhere(Criteria::expr()->memberOf('persons', $person))
|
||||
->orderBy(['startDate' => 'DESC'])
|
||||
->setMaxResults($limit * 2);
|
||||
|
||||
$criteria = Criteria::create();
|
||||
$expr = Criteria::expr();
|
||||
|
||||
$criteria
|
||||
->where(
|
||||
$expr->gte('startDate', $today),
|
||||
)
|
||||
->orderBy(['startDate' => 'ASC']);
|
||||
|
||||
$criteriaByPerson = Criteria::create();
|
||||
$criteriaByPerson
|
||||
->where(
|
||||
$expr->memberOf('persons', $person)
|
||||
)
|
||||
->setMaxResults($limit);
|
||||
|
||||
return $this->calendars->matching($criteria)->matching($criteriaByPerson);
|
||||
return $this->calendars->matching($criteria)
|
||||
->matching(
|
||||
// due to a bug, filter two times
|
||||
Criteria::create()
|
||||
->where(Criteria::expr()->memberOf('persons', $person))
|
||||
->setMaxResults($limit)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1337,16 +1332,6 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserHistories(): ReadableCollection
|
||||
{
|
||||
return $this->userHistories;
|
||||
}
|
||||
|
||||
public function getCurrentUserHistory(): ?UserHistory
|
||||
{
|
||||
return $this->getUserHistories()->findFirst(fn (int $key, UserHistory $userHistory) => null === $userHistory->getEndDate());
|
||||
}
|
||||
|
||||
private function addStepHistory(AccompanyingPeriodStepHistory $stepHistory, array $context = []): self
|
||||
{
|
||||
if (!$this->stepHistories->contains($stepHistory)) {
|
||||
|
@@ -42,10 +42,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodWorkEvaluation>
|
||||
*
|
||||
* @internal the serialization for write evaluations is handled in `accompanyingperiodworkdenormalizer`
|
||||
* @internal the serialization for context docgen:read is handled in `accompanyingperiodworknormalizer`
|
||||
* @internal /!\ the serialization for write evaluations is handled in `AccompanyingPeriodWorkDenormalizer`
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\OneToMany(targetEntity: AccompanyingPeriodWorkEvaluation::class, mappedBy: 'accompanyingPeriodWork', cascade: ['remove', 'persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['startDate' => \Doctrine\Common\Collections\Criteria::DESC, 'id' => 'DESC'])]
|
||||
private Collection $accompanyingPeriodWorkEvaluations;
|
||||
@@ -292,20 +291,18 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
/**
|
||||
* @return ReadableCollection<int, User>
|
||||
*/
|
||||
#[Serializer\Groups(['accompanying_period_work:edit'])]
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'accompanying_period_work:edit', 'accompanying_period_work:create'])]
|
||||
public function getReferrers(): ReadableCollection
|
||||
{
|
||||
$users = $this->referrersHistory
|
||||
->filter(fn (AccompanyingPeriodWorkReferrerHistory $h) => null === $h->getEndDate())
|
||||
->map(fn (AccompanyingPeriodWorkReferrerHistory $h) => $h->getUser())
|
||||
->getValues();
|
||||
->getValues()
|
||||
;
|
||||
|
||||
return new ArrayCollection(array_values($users));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, AccompanyingPeriodWorkReferrerHistory>
|
||||
*/
|
||||
public function getReferrersHistory(): Collection
|
||||
{
|
||||
return $this->referrersHistory;
|
||||
@@ -473,9 +470,9 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $user): self
|
||||
public function setCreatedBy(?User $createdBy): self
|
||||
{
|
||||
$this->createdBy = $user;
|
||||
$this->createdBy = $createdBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -517,14 +514,14 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
|
||||
public function setStartDate(\DateTimeInterface $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate instanceof \DateTime ? \DateTimeImmutable::createFromMutable($startDate) : $startDate;
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(\DateTimeInterface $datetime): TrackUpdateInterface
|
||||
{
|
||||
$this->updatedAt = $datetime instanceof \DateTime ? \DateTimeImmutable::createFromMutable($datetime) : $datetime;
|
||||
$this->updatedAt = $datetime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -132,11 +132,6 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->getCreator();
|
||||
}
|
||||
|
||||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
@@ -22,17 +21,13 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class ReferrerAggregator implements AggregatorInterface, DataTransformerInterface
|
||||
final readonly class ReferrerAggregator implements AggregatorInterface
|
||||
{
|
||||
private const A = 'acp_ref_agg_uhistory';
|
||||
|
||||
private const P = 'acp_ref_agg_date';
|
||||
|
||||
public function __construct(
|
||||
private UserRepository $userRepository,
|
||||
private UserRender $userRender,
|
||||
private RollingDateConverterInterface $rollingDateConverter
|
||||
) {}
|
||||
public function __construct(private UserRepository $userRepository, private UserRender $userRender, private RollingDateConverterInterface $rollingDateConverter) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
@@ -49,16 +44,18 @@ final readonly class ReferrerAggregator implements AggregatorInterface, DataTran
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull(self::A),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lt(self::A.'.startDate', ':'.self::P.'_end_date'),
|
||||
$qb->expr()->lte(self::A.'.startDate', ':'.self::P),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull(self::A.'.endDate'),
|
||||
$qb->expr()->gte(self::A.'.endDate', ':'.self::P.'_start_date')
|
||||
$qb->expr()->gt(self::A.'.endDate', ':'.self::P)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter(':'.self::P.'_end_date', $this->rollingDateConverter->convert($data['end_date']))
|
||||
->setParameter(':'.self::P.'_start_date', $this->rollingDateConverter->convert($data['end_date']));
|
||||
->setParameter(
|
||||
self::P,
|
||||
$this->rollingDateConverter->convert($data['date_calc'])
|
||||
);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -69,37 +66,15 @@ final readonly class ReferrerAggregator implements AggregatorInterface, DataTran
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer.Referrer after',
|
||||
'required' => true,
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer.Until',
|
||||
->add('date_calc', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer.Computation date for referrer',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
$data = [];
|
||||
|
||||
if (null === $before) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$data['start_date'] = $before['date_calc'] ?? $before['start_date'] ?? $default['start_date'];
|
||||
$data['end_date'] = $before['date_calc'] ?? $before['end_date'] ?? $default['end_date'];
|
||||
|
||||
return $data;
|
||||
return ['date_calc' => new RollingDate(RollingDate::T_TODAY)];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
|
@@ -13,25 +13,20 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
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;
|
||||
|
||||
readonly class ReferrerScopeAggregator implements AggregatorInterface, DataTransformerInterface
|
||||
readonly class ReferrerScopeAggregator implements AggregatorInterface
|
||||
{
|
||||
private const PREFIX = 'acp_agg_referrer_scope';
|
||||
|
||||
public function __construct(
|
||||
private ScopeRepositoryInterface $scopeRepository,
|
||||
private TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -51,16 +46,11 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface, DataTrans
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
|
||||
$qb->expr()->andX(
|
||||
// check that the user is referrer when the accompanying period is opened
|
||||
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_userHistory.endDate"),
|
||||
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_userHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_userHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -76,15 +66,9 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface, DataTrans
|
||||
$qb->expr()->isNull("{$p}_scopeHistory.endDate"),
|
||||
$qb->expr()->gt("{$p}_scopeHistory.endDate", "{$p}_userHistory.startDate")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_scopeHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_scopeHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']))
|
||||
->addSelect("IDENTITY({$p}_scopeHistory.scope) AS {$p}_select")
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
@@ -94,36 +78,11 @@ readonly class ReferrerScopeAggregator implements AggregatorInterface, DataTrans
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_scope.Referrer and scope after',
|
||||
'required' => true,
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_scope.Until',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
$data = [];
|
||||
|
||||
$data['start_date'] = $before['start_date'] ?? new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01'));
|
||||
$data['end_date'] = $before['end_date'] ?? $default['end_date'];
|
||||
|
||||
return $data;
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
|
@@ -13,25 +13,20 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\UserJobRepository;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class UserJobAggregator implements AggregatorInterface, DataTransformerInterface
|
||||
final readonly class UserJobAggregator implements AggregatorInterface
|
||||
{
|
||||
private const PREFIX = 'acp_agg_user_job';
|
||||
|
||||
public function __construct(
|
||||
private UserJobRepository $jobRepository,
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
private TranslatableStringHelper $translatableStringHelper
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -56,10 +51,6 @@ final readonly class UserJobAggregator implements AggregatorInterface, DataTrans
|
||||
$qb->expr()->isNull("{$p}_userHistory.endDate"),
|
||||
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_userHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_userHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -75,15 +66,9 @@ final readonly class UserJobAggregator implements AggregatorInterface, DataTrans
|
||||
$qb->expr()->isNull("{$p}_jobHistory.endDate"),
|
||||
$qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate")
|
||||
)
|
||||
),
|
||||
$qb->expr()->andX(
|
||||
"{$p}_jobHistory.startDate <= :{$p}_endDate",
|
||||
"COALESCE({$p}_jobHistory.endDate, CURRENT_TIMESTAMP()) > :{$p}_startDate"
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']))
|
||||
->addSelect("IDENTITY({$p}_jobHistory.job) AS {$p}_select")
|
||||
->addGroupBy("{$p}_select");
|
||||
}
|
||||
@@ -93,36 +78,11 @@ final readonly class UserJobAggregator implements AggregatorInterface, DataTrans
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_job.Referrer and job after',
|
||||
'required' => true,
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.aggregator.course.by_referrer_job.Until',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
$data = [];
|
||||
|
||||
$data['start_date'] = $before['start_date'] ?? new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01'));
|
||||
$data['end_date'] = $before['end_date'] ?? $default['end_date'];
|
||||
|
||||
return $data;
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
|
@@ -54,6 +54,7 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
'socialAction',
|
||||
'socialIssue',
|
||||
'acp_id',
|
||||
'acp_user',
|
||||
'startDate',
|
||||
'endDate',
|
||||
'goalsId',
|
||||
@@ -69,8 +70,8 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
'personsName',
|
||||
'thirdParties',
|
||||
'handlingThierParty',
|
||||
'acpwReferrers',
|
||||
'referrer',
|
||||
// 'acpwReferrers',
|
||||
'referrers',
|
||||
'createdAt',
|
||||
'createdBy',
|
||||
'updatedAt',
|
||||
@@ -155,9 +156,9 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
[]
|
||||
);
|
||||
},
|
||||
'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'referrer' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'acpwReferrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
|
||||
'createdBy', 'updatedBy', 'acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'referrers' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
// 'acpwReferrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
|
||||
'personsName' => $this->personHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
|
||||
'handlingThierParty' => $this->thirdPartyHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'thirdParties' => $this->thirdPartyHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
|
||||
@@ -271,7 +272,8 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
|
||||
// join acp
|
||||
$qb
|
||||
->addSelect('acp.id AS acp_id');
|
||||
->addSelect('acp.id AS acp_id')
|
||||
->addSelect('IDENTITY(acp.user) AS acp_user');
|
||||
|
||||
// persons
|
||||
$qb
|
||||
@@ -280,18 +282,21 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeri
|
||||
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM '.Person::class.' person1_acpw_member '
|
||||
.'WHERE person1_acpw_member MEMBER OF acpw.persons) AS personsName');
|
||||
|
||||
// referrer => at date XXXX
|
||||
// referrers => at date XXXX
|
||||
$qb
|
||||
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM '.UserHistory::class.' history '.
|
||||
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calcDate AND (history.endDate IS NULL OR history.endDate > :calcDate)) AS referrers');
|
||||
|
||||
/*
|
||||
// acpwReferrers at date XXX
|
||||
$qb
|
||||
->addSelect('(
|
||||
SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM '.UserHistory::class.' history '.
|
||||
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calcDate AND (history.endDate IS NULL OR history.endDate > :calcDate)) AS referrer');
|
||||
|
||||
// acpwReferrer at date XXX
|
||||
$qb->addSelect('(SELECT AGGREGATE(IDENTITY(acpwrh.user)) FROM '.AccompanyingPeriodWorkReferrerHistory::class.' acpwrh
|
||||
WHERE acpwrh.accompanyingPeriodWork = acpw
|
||||
AND acpwrh.startDate <= :calcDate AND (acpwrh.endDate IS NULL or acpwrh.endDate > :calcDate)
|
||||
) AS acpwReferrers');
|
||||
$qb->setParameter('calcDate', $calcDate);
|
||||
SELECT IDENTITY(acpw_ref_history.accompanyingPeriodWork) AS acpw_ref_history_id,
|
||||
JSON_BUILD_OBJECT(\'uid\', IDENTITY(acpw_ref_history.user), \'d\', acpw_ref_history.startDate)
|
||||
FROM ' . AccompanyingPeriodWorkReferrerHistory::class . ' acpw_ref_history ' .
|
||||
'WHERE acpw_ref_history.accompanyingPeriodWork = acpw AND acpw_ref_history.startDate <= :calcDate AND (acpw_ref_history.endDate IS NULL or acpw_ref_history.endDate > :calcDate) GROUP BY acpw_ref_history_id) AS acpwReferrers'
|
||||
);
|
||||
*/
|
||||
|
||||
// thirdparties
|
||||
$qb
|
||||
|
@@ -54,6 +54,7 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
'socialAction',
|
||||
'socialIssue',
|
||||
'acp_id',
|
||||
'acp_user',
|
||||
'startDate',
|
||||
'endDate',
|
||||
'goalsId',
|
||||
@@ -69,8 +70,8 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
'personsName',
|
||||
'thirdParties',
|
||||
'handlingThierParty',
|
||||
'acpwReferrers',
|
||||
'referrer',
|
||||
// 'acpwReferrers',
|
||||
'referrers',
|
||||
'createdAt',
|
||||
'createdBy',
|
||||
'updatedAt',
|
||||
@@ -155,9 +156,9 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
[]
|
||||
);
|
||||
},
|
||||
'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'referrer' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'acpwReferrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
|
||||
'createdBy', 'updatedBy', 'acp_user' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'referrers' => $this->userHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
// 'acpwReferrers' => $this->userHelper->getLabelMulti($key, $values, 'export.list.acpw.' . $key),
|
||||
'personsName' => $this->personHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
|
||||
'handlingThierParty' => $this->thirdPartyHelper->getLabel($key, $values, 'export.list.acpw.'.$key),
|
||||
'thirdParties' => $this->thirdPartyHelper->getLabelMulti($key, $values, 'export.list.acpw.'.$key),
|
||||
@@ -266,7 +267,8 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
|
||||
// join acp
|
||||
$qb
|
||||
->addSelect('acp.id AS acp_id');
|
||||
->addSelect('acp.id AS acp_id')
|
||||
->addSelect('IDENTITY(acp.user) AS acp_user');
|
||||
|
||||
// persons
|
||||
$qb
|
||||
@@ -275,17 +277,21 @@ final readonly class ListAccompanyingPeriodWorkAssociatePersonOnWork implements
|
||||
->addSelect('(SELECT AGGREGATE(person1_acpw_member.id) FROM '.Person::class.' person1_acpw_member '
|
||||
.'WHERE person1_acpw_member MEMBER OF acpw.persons) AS personsName');
|
||||
|
||||
// referrer => at date XXXX
|
||||
// referrers => at date XXXX
|
||||
$qb
|
||||
->addSelect('(SELECT JSON_BUILD_OBJECT(\'uid\', IDENTITY(history.user), \'d\', history.startDate) FROM '.UserHistory::class.' history '.
|
||||
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calcDate AND (history.endDate IS NULL OR history.endDate > :calcDate)) AS referrer');
|
||||
'WHERE history.accompanyingPeriod = acp AND history.startDate <= :calcDate AND (history.endDate IS NULL OR history.endDate > :calcDate)) AS referrers');
|
||||
|
||||
/*
|
||||
// acpwReferrers at date XXX
|
||||
$qb->addSelect('(SELECT AGGREGATE(IDENTITY(acpwrh.user)) FROM '.AccompanyingPeriodWorkReferrerHistory::class.' acpwrh
|
||||
WHERE acpwrh.accompanyingPeriodWork = acpw
|
||||
AND acpwrh.startDate <= :calcDate AND (acpwrh.endDate IS NULL or acpwrh.endDate > :calcDate)
|
||||
) AS acpwReferrers');
|
||||
$qb->setParameter('calcDate', $calcDate);
|
||||
$qb
|
||||
->addSelect('(
|
||||
SELECT IDENTITY(acpw_ref_history.accompanyingPeriodWork) AS acpw_ref_history_id,
|
||||
JSON_BUILD_OBJECT(\'uid\', IDENTITY(acpw_ref_history.user), \'d\', acpw_ref_history.startDate)
|
||||
FROM ' . AccompanyingPeriodWorkReferrerHistory::class . ' acpw_ref_history ' .
|
||||
'WHERE acpw_ref_history.accompanyingPeriodWork = acpw AND acpw_ref_history.startDate <= :calcDate AND (acpw_ref_history.endDate IS NULL or acpw_ref_history.endDate > :calcDate) GROUP BY acpw_ref_history_id) AS acpwReferrers'
|
||||
);
|
||||
*/
|
||||
|
||||
// thirdparties
|
||||
$qb
|
||||
|
@@ -13,28 +13,23 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
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;
|
||||
|
||||
final readonly class UserJobFilter implements FilterInterface, DataTransformerInterface
|
||||
class UserJobFilter implements FilterInterface
|
||||
{
|
||||
private const PREFIX = 'acp_filter_user_job';
|
||||
|
||||
public function __construct(
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private UserJobRepositoryInterface $userJobRepository,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||
private readonly UserJobRepositoryInterface $userJobRepository,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -46,31 +41,42 @@ final readonly class UserJobFilter implements FilterInterface, DataTransformerIn
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb->andWhere(
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
<<<DQL
|
||||
SELECT 1
|
||||
FROM %s {$p}_userHistory
|
||||
JOIN %s {$p}_userJobHistory
|
||||
WITH
|
||||
{$p}_userHistory.user = {$p}_userJobHistory.user
|
||||
AND OVERLAPSI({$p}_userHistory.startDate, {$p}_userHistory.endDate),({$p}_userJobHistory.startDate, {$p}_userJobHistory.endDate) = TRUE
|
||||
WHERE {$p}_userHistory.accompanyingPeriod = acp
|
||||
AND {$p}_userHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userHistory.endDate IS NULL OR {$p}_userHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userJobHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userJobHistory.endDate IS NULL OR {$p}_userJobHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userJobHistory.job IN (:{$p}_jobs)
|
||||
DQL,
|
||||
UserHistory::class,
|
||||
UserJobHistory::class,
|
||||
),
|
||||
$qb
|
||||
->leftJoin(
|
||||
'acp.userHistories',
|
||||
"{$p}_userHistory",
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_userHistory.endDate"),
|
||||
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->leftJoin(
|
||||
UserJobHistory::class,
|
||||
"{$p}_jobHistory",
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_jobHistory.user", "{$p}_userHistory.user"),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_jobHistory.startDate", "{$p}_userHistory.startDate"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_jobHistory".'.endDate'),
|
||||
$qb->expr()->gt("{$p}_jobHistory.endDate", "{$p}_userHistory.startDate")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in("{$p}_jobHistory.job", ":{$p}_job"))
|
||||
->setParameter(
|
||||
"{$p}_job",
|
||||
$data['jobs'],
|
||||
)
|
||||
)
|
||||
->setParameter("{$p}_jobs", $data['jobs'])
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -89,29 +95,20 @@ final readonly class UserJobFilter implements FilterInterface, DataTransformerIn
|
||||
'expanded' => true,
|
||||
'choice_label' => fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
|
||||
'label' => 'Job',
|
||||
])
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_job.Start from',
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_job.Until',
|
||||
])
|
||||
;
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'exports.filter.course.by_user_job.Filtered by user job: only job', [
|
||||
'job' => implode(
|
||||
'export.filter.course.by_user_job.Filtered by user job: only %job%', [
|
||||
'%job%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()),
|
||||
$data['jobs'] instanceof Collection ? $data['jobs']->toArray() : $data['jobs']
|
||||
)
|
||||
),
|
||||
'startDate' => $this->rollingDateConverter->convert($data['start_date']),
|
||||
'endDate' => $this->rollingDateConverter->convert($data['end_date']),
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -120,30 +117,9 @@ final readonly class UserJobFilter implements FilterInterface, DataTransformerIn
|
||||
{
|
||||
return [
|
||||
'jobs' => [],
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
|
||||
if (null === $before) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (!array_key_exists('start_date', $before) || null === $before['start_date']) {
|
||||
$before['start_date'] = $default['start_date'];
|
||||
}
|
||||
|
||||
if (!array_key_exists('end_date', $before) || null === $before['end_date']) {
|
||||
$before['end_date'] = $default['end_date'];
|
||||
}
|
||||
|
||||
return $before;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.by_user_job.Filter by user job';
|
||||
|
@@ -13,28 +13,23 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Chill\MainBundle\Export\DataTransformerInterface;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
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;
|
||||
|
||||
final readonly class UserScopeFilter implements FilterInterface, DataTransformerInterface
|
||||
class UserScopeFilter implements FilterInterface
|
||||
{
|
||||
private const PREFIX = 'acp_filter_main_scope';
|
||||
|
||||
public function __construct(
|
||||
private ScopeRepositoryInterface $scopeRepository,
|
||||
private TranslatableStringHelper $translatableStringHelper,
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
private readonly ScopeRepositoryInterface $scopeRepository,
|
||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -42,35 +37,47 @@ final readonly class UserScopeFilter implements FilterInterface, DataTransformer
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb->andWhere(
|
||||
$qb->expr()->exists(
|
||||
sprintf(
|
||||
<<<DQL
|
||||
SELECT 1
|
||||
FROM %s {$p}_userHistory
|
||||
JOIN %s {$p}_userScopeHistory
|
||||
WITH
|
||||
{$p}_userHistory.user = {$p}_userScopeHistory.user
|
||||
AND OVERLAPSI({$p}_userHistory.startDate, {$p}_userHistory.endDate),({$p}_userScopeHistory.startDate, {$p}_userScopeHistory.endDate) = TRUE
|
||||
WHERE {$p}_userHistory.accompanyingPeriod = acp
|
||||
AND {$p}_userHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userHistory.endDate IS NULL OR {$p}_userHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userScopeHistory.startDate <= :{$p}_endDate
|
||||
AND ({$p}_userScopeHistory.endDate IS NULL OR {$p}_userScopeHistory.endDate > :{$p}_startDate)
|
||||
AND {$p}_userScopeHistory.scope IN (:{$p}_scopes)
|
||||
DQL,
|
||||
UserHistory::class,
|
||||
UserScopeHistory::class,
|
||||
),
|
||||
$qb
|
||||
->join(
|
||||
'acp.userHistories',
|
||||
"{$p}_userHistory",
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_userHistory.accompanyingPeriod", 'acp.id'),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->gte('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.startDate"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_userHistory.endDate"),
|
||||
$qb->expr()->lt('COALESCE(acp.closingDate, CURRENT_TIMESTAMP())', "{$p}_userHistory.endDate")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter("{$p}_scopes", $data['scopes'])
|
||||
->setParameter("{$p}_startDate", $this->rollingDateConverter->convert($data['start_date']))
|
||||
->setParameter("{$p}_endDate", $this->rollingDateConverter->convert($data['end_date']));
|
||||
->join(
|
||||
UserScopeHistory::class,
|
||||
"{$p}_scopeHistory",
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq("{$p}_scopeHistory.user", "{$p}_userHistory.user"),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_scopeHistory.startDate", "{$p}_userHistory.startDate"),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_scopeHistory.endDate"),
|
||||
$qb->expr()->gt("{$p}_scopeHistory.endDate", "{$p}_userHistory.startDate")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in("{$p}_scopeHistory.scope", ":{$p}_scopes"))
|
||||
->setParameter(
|
||||
"{$p}_scopes",
|
||||
$data['scopes'],
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -87,28 +94,20 @@ final readonly class UserScopeFilter implements FilterInterface, DataTransformer
|
||||
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
])
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_scope.Start from',
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.by_user_scope.Until',
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'exports.filter.course.by_user_scope.Filtered by user main scope: only scopes', [
|
||||
'scopes' => implode(
|
||||
'export.filter.course.by_user_scope.Filtered by user main scope: only %scope%', [
|
||||
'%scope%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
|
||||
$data['scopes'] instanceof Collection ? $data['scopes']->toArray() : $data['scopes']
|
||||
)
|
||||
),
|
||||
'startDate' => $this->rollingDateConverter->convert($data['start_date']),
|
||||
'endDate' => $this->rollingDateConverter->convert($data['end_date']),
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -117,30 +116,9 @@ final readonly class UserScopeFilter implements FilterInterface, DataTransformer
|
||||
{
|
||||
return [
|
||||
'scopes' => [],
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
}
|
||||
|
||||
public function transformData(?array $before): array
|
||||
{
|
||||
$default = $this->getFormDefaultData();
|
||||
|
||||
if (null === $before) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (!array_key_exists('start_date', $before) || null === $before['start_date']) {
|
||||
$before['start_date'] = $default['start_date'];
|
||||
}
|
||||
|
||||
if (!array_key_exists('end_date', $before) || null === $before['end_date']) {
|
||||
$before['end_date'] = $default['end_date'];
|
||||
}
|
||||
|
||||
return $before;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.by_user_scope.Filter by user scope';
|
||||
|
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Menu;
|
||||
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
|
||||
final readonly class PersonQuickMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
public function __construct(private AuthorizationCheckerInterface $authorizationChecker) {}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return ['person_quick_menu'];
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
||||
$person = $parameters['person'];
|
||||
|
||||
if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::CREATE, $person)) {
|
||||
$menu->addChild(
|
||||
'Create Accompanying Course',
|
||||
[
|
||||
'route' => 'chill_person_accompanying_course_new',
|
||||
'routeParameters' => [
|
||||
'person_id' => [$person->getId()],
|
||||
],
|
||||
]
|
||||
)
|
||||
->setExtras([
|
||||
'order' => 10,
|
||||
'icon' => 'plus',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,7 +30,7 @@ div.list-with-period {
|
||||
|
||||
// override wrap-list
|
||||
div.wrap-list.periods-list {
|
||||
padding-right: 0;
|
||||
padding-right: 1rem;
|
||||
div.wl-row {
|
||||
flex-wrap: nowrap;
|
||||
div.wl-col {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<a class="btn" :class="getClassButton" :title="$t(buttonTitle || '')" @click="openModal">
|
||||
<span v-if="displayTextButton">{{ $t(buttonTitle || '') }}</span>
|
||||
<a class="btn" :class="getClassButton" :title="$t(buttonTitle)" @click="openModal">
|
||||
<span v-if="displayTextButton">{{ $t(buttonTitle) }}</span>
|
||||
</a>
|
||||
|
||||
<teleport to="body">
|
||||
|
@@ -7,8 +7,10 @@
|
||||
{% endif %}
|
||||
<a id="comment-{{ comment.id }}" href="{{ '#comment-' ~ comment.id }}" class="fa fa-pencil-square-o fa-fw"></a>
|
||||
|
||||
{{ 'by'|trans }}
|
||||
<span class="badge-user">{{ comment.createdBy|chill_entity_render_box({'at_date': comment.createdAt }) }}</span>{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}<br>
|
||||
{% set creator = comment.creator is defined ? comment.creator : comment.createdBy %}
|
||||
{{ 'by'|trans }}<b>{{ creator }}</b>
|
||||
|
||||
{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}<br>
|
||||
<i>{{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }}</i>
|
||||
</div>
|
||||
<ul class="record_actions">
|
||||
|
@@ -99,7 +99,7 @@
|
||||
<div class="metadata">
|
||||
{{ 'Last updated by'| trans }}
|
||||
<span class="user">
|
||||
{{ accompanyingCourse.pinnedComment.updatedBy|chill_entity_render_box({'at_date': accompanyingCourse.pinnedComment.updatedAt}) }}
|
||||
{{ accompanyingCourse.pinnedComment.updatedBy|chill_entity_render_box }}
|
||||
</span>
|
||||
{{ 'on'|trans ~ ' ' }}
|
||||
<span class="date">
|
||||
|
@@ -83,9 +83,9 @@
|
||||
</div>
|
||||
<div class="wl-col list">
|
||||
{%- if w.referrers|length > 0 -%}
|
||||
{% for r in w.referrersHistory %}
|
||||
{% for u in w.referrers %}
|
||||
<span class="wl-item">
|
||||
<span class="badge-user">{{ r.user|chill_entity_render_box({'at_date': r.startDate}) }}</span>
|
||||
<span class="badge-user">{{ u|chill_entity_render_box }}</span>
|
||||
{% if not loop.last %}, {% endif %}
|
||||
</span>
|
||||
{% endfor %}
|
||||
|
@@ -33,8 +33,8 @@
|
||||
{% if w.referrers %}
|
||||
<li>
|
||||
<span class="item-key">{{ 'Referrers'|trans ~ ' : ' }}</span>
|
||||
{% for rh in w.referrersHistory %}
|
||||
<span class="badge-user">{{ rh.user|chill_entity_render_box({'at_date': rh.startDate}) }}</span>
|
||||
{% for u in w.referrers %}
|
||||
<span class="badge-user">{{ u|chill_entity_render_box }}</span>
|
||||
{% endfor %}
|
||||
{% if w.referrers|length == 0 %}
|
||||
<span class="chill-no-data-statement">{{ 'Not given'|trans }}</span>
|
||||
|
@@ -89,7 +89,7 @@
|
||||
<li>
|
||||
{% if evaluation.createdBy is not null %}
|
||||
<span class="item-key">créé par</span>
|
||||
<b>{{ evaluation.createdBy|chill_entity_render_string({'at_date': evaluation.createdAt}) }}</b>
|
||||
<b>{{ evaluation.createdBy.username }}</b>
|
||||
{% endif %}
|
||||
{% if evaluation.createdAt is not null %}
|
||||
<span class="item-key">{{ 'le'|trans }}</span>
|
||||
|
@@ -13,7 +13,7 @@
|
||||
{{ 'Last updated by'|trans }}
|
||||
{% endif %}
|
||||
<span class="user">
|
||||
{{ entity.updatedBy|chill_entity_render_box({'at_date': entity.updatedAt }) }}
|
||||
{{ entity.updatedBy|chill_entity_render_box }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -34,8 +34,8 @@
|
||||
{{ 'Created by'|trans }}
|
||||
{% endif %}
|
||||
<span class="user">
|
||||
{{ entity.createdBy|chill_entity_render_string({'at_date': entity.createdAt}) }}
|
||||
{{ entity.createdBy|chill_entity_render_string }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
{% endmacro %}
|
@@ -1,19 +1,13 @@
|
||||
{% macro button_person_before(person) %}
|
||||
{{ chill_menu('person_quick_menu', {
|
||||
'layout': '@ChillMain/Menu/quick_menu.html.twig',
|
||||
'args' : { 'person': person }
|
||||
}) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro button_person_after(person) %}
|
||||
{% set household = person.getCurrentHousehold %}
|
||||
{% if household is not null and is_granted('CHILL_PERSON_HOUSEHOLD_SEE', household) %}
|
||||
<li>
|
||||
<a href="{{ path('chill_person_household_summary', { 'household_id': household.id }) }}"
|
||||
class="btn btn-sm btn-chill-beige"
|
||||
title="{{ 'Show household'|trans }}"
|
||||
><i class="fa fa-home"></i>
|
||||
</a>
|
||||
<a href="{{ path('chill_person_household_summary', { 'household_id': household.id }) }}" class="btn btn-sm btn-chill-beige"><i class="fa fa-home"></i></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE', person) %}
|
||||
<li>
|
||||
<a href="{{ path('chill_person_accompanying_course_new', { 'person_id': [ person.id ]}) }}" class="btn btn-sm btn-create change-icon" title="{{ 'Create an accompanying period'|trans }}"><i class="fa fa-random"></i></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
@@ -171,24 +165,7 @@
|
||||
<h3>{{ 'chill_calendar.Next calendars'|trans }}</h3>
|
||||
</div>
|
||||
<div class="wl-col list">
|
||||
<div class="calendar-list">
|
||||
<ul class="calendar-list">
|
||||
{% for c in calendars %}
|
||||
<li>
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %}
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_edit', {id: c.id}) }}">
|
||||
<span class="badge bg-secondary">{{ c.startDate|format_datetime('long', 'short') }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">{{ c.startDate|format_datetime('long', 'short') }}</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', acp) %}
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_list_by_period', {'id': acp.id}) }}" class="calendar-list__global"><i class="fa fa-list"></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% for c in calendars %}<span>{{ c.startDate|format_datetime('long', 'short') }}</span>{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -207,20 +184,13 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<ul class="record_actions">
|
||||
{{ chill_menu('accompanying_course_quick_menu', {
|
||||
'layout': '@ChillMain/Menu/quick_menu.html.twig',
|
||||
'args' : { 'accompanying-course': acp }
|
||||
}) }}
|
||||
|
||||
<ul class="record_actions record_actions_column">
|
||||
<li>
|
||||
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': acp.id }) }}"
|
||||
class="btn btn-sm btn-primary"
|
||||
title="{{ 'See accompanying period'|trans }}"
|
||||
><i class="fa fa-random fa-fw"></i>
|
||||
class="btn btn-sm btn-outline-primary" title="{{ 'See accompanying period'|trans }}">
|
||||
<i class="fa fa-random fa-fw"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -277,7 +247,7 @@
|
||||
'addAltNames': true,
|
||||
'addCenter': true,
|
||||
'address_multiline': false,
|
||||
'customButtons': { 'after': _self.button_person_after(person), 'before': _self.button_person_before((person)) }
|
||||
'customButtons': { 'after': _self.button_person_after(person) }
|
||||
}) }}
|
||||
|
||||
{#- 'acps' is for AcCompanyingPeriodS #}
|
||||
|
@@ -296,7 +296,7 @@ This view should receive those arguments:
|
||||
<div class="created-updated">
|
||||
{% if person.createdBy %}
|
||||
<div class="createdBy">
|
||||
{{ 'Created by'|trans}}: <b>{{ person.createdBy|chill_entity_render_box({'at_date': person.createdAt}) }}</b>,<br>
|
||||
{{ 'Created by'|trans}}: <b>{{ person.createdBy|chill_entity_render_box }}</b>,<br>
|
||||
{{ 'on'|trans ~ person.createdAt|format_datetime('long', 'short') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@@ -64,7 +64,7 @@
|
||||
<li>
|
||||
{% if evaluation.createdBy is not null %}
|
||||
<span class="item-key">créé par</span>
|
||||
<b>{{ evaluation.createdBy|chill_entity_render_string({'at_date': evaluation.createdAt}) }}</b>
|
||||
<b>{{ evaluation.createdBy.username }}</b>
|
||||
{% endif %}
|
||||
{% if evaluation.createdAt is not null %}
|
||||
<span class="item-key">{{ 'le'|trans }}</span>
|
||||
|
@@ -92,7 +92,7 @@
|
||||
<li>
|
||||
{% if evaluation.createdBy is not null %}
|
||||
<span class="item-key">créé par</span>
|
||||
<b>{{ evaluation.createdBy|chill_entity_render_string({'at_date': evaluation.createdAt}) }}</b>
|
||||
<b>{{ evaluation.createdBy.username }}</b>
|
||||
{% endif %}
|
||||
{% if evaluation.createdAt is not null %}
|
||||
<span class="item-key">{{ 'le'|trans }}</span>
|
||||
|
@@ -17,7 +17,6 @@ use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
|
||||
use Chill\MainBundle\Serializer\Normalizer\UserNormalizer;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
@@ -82,7 +81,6 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
{
|
||||
if ($period instanceof AccompanyingPeriod) {
|
||||
$scopes = $this->scopeResolverDispatcher->isConcerned($period) ? $this->scopeResolverDispatcher->resolveScope($period) : [];
|
||||
$userHistory = $period->getCurrentUserHistory();
|
||||
|
||||
if (!\is_array($scopes)) {
|
||||
$scopes = [$scopes];
|
||||
@@ -103,7 +101,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'closingMotive' => $this->normalizer->normalize($period->getClosingMotive(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\ClosingMotive::class])),
|
||||
'confidential' => $period->isConfidential(),
|
||||
'createdAt' => $this->normalizer->normalize($period->getCreatedAt(), $format, $dateContext),
|
||||
'createdBy' => $this->normalizer->normalize($period->getCreatedBy(), $format, [...$userContext, UserNormalizer::AT_DATE => $period->getCreatedAt()]),
|
||||
'createdBy' => $this->normalizer->normalize($period->getCreatedBy(), $format, $userContext),
|
||||
'emergency' => $period->isEmergency(),
|
||||
'openingDate' => $this->normalizer->normalize($period->getOpeningDate(), $format, $dateContext),
|
||||
'origin' => $this->normalizer->normalize($period->getOrigin(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Origin::class])),
|
||||
@@ -125,7 +123,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'isClosed' => null !== $period->getClosingDate(),
|
||||
'closingMotiveText' => null !== $period->getClosingMotive() ?
|
||||
$this->closingMotiveRender->renderString($period->getClosingMotive(), []) : '',
|
||||
'ref' => $this->normalizer->normalize($userHistory?->getUser(), $format, [...$userContext, UserNormalizer::AT_DATE => $userHistory?->getStartDate()]),
|
||||
'ref' => $this->normalizer->normalize($period->getUser(), $format, $userContext),
|
||||
'hasRef' => null !== $period->getUser(),
|
||||
'socialIssuesText' => implode(', ', array_map(fn (SocialIssue $s) => $this->socialIssueRender->renderString($s, []), $period->getSocialIssues()->toArray())),
|
||||
'scopesText' => implode(', ', array_map(fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), $scopes)),
|
||||
@@ -137,7 +135,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'locationPerson' => $this->normalizer->normalize($period->getPersonLocation(), $format, array_merge($context, ['docgen:expects' => Person::class])),
|
||||
'location' => $this->normalizer->normalize($period->getLocation(), $format, $addressContext),
|
||||
'administrativeLocation' => $this->normalizer->normalize($period->getAdministrativeLocation(), $format, $administrativeLocationContext),
|
||||
'works' => $this->normalizer->normalize($period->getWorks()->getValues(), $format, $workContext),
|
||||
'works' => $this->normalizer->normalize($period->getWorks(), $format, $workContext),
|
||||
'comments' => $this->normalizer->normalize($period->getComments(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Comment::class])),
|
||||
'pinnedComment' => $this->normalizer->normalize($period->getPinnedComment(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\Comment::class])),
|
||||
];
|
||||
|
@@ -11,16 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
|
||||
use Chill\MainBundle\Serializer\Normalizer\UserNormalizer;
|
||||
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
@@ -34,48 +30,16 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
|
||||
|
||||
public function __construct(private readonly Registry $registry, private readonly EntityWorkflowRepository $entityWorkflowRepository, private readonly MetadataExtractor $metadataExtractor) {}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriodWork $object
|
||||
*
|
||||
* @throws ExceptionInterface
|
||||
*/
|
||||
public function normalize($object, ?string $format = null, array $context = []): array|\ArrayObject|bool|float|int|string|null
|
||||
{
|
||||
if (!$object instanceof AccompanyingPeriodWork && 'json' === $format) {
|
||||
throw new UnexpectedValueException('Object cannot be null or empty when format is json');
|
||||
}
|
||||
if ('docgen' === $format && !($object instanceof AccompanyingPeriodWork || null === $object)) {
|
||||
throw new UnexpectedValueException(sprintf('Object must be an instanceof AccompanyingPeriodWork or null when format is docgen, %s given', get_debug_type($object)));
|
||||
}
|
||||
|
||||
$cleanContext = array_filter($context, fn (string|int $key) => !in_array($key, ['docgen:expects', self::IGNORE_WORK], true), ARRAY_FILTER_USE_KEY);
|
||||
|
||||
if (null === $object && 'docgen' === $format) {
|
||||
$dateNull = $this->normalizer->normalize(null, $format, [...$context, 'docgen:expects' => \DateTimeImmutable::class]);
|
||||
$userNull = $this->normalizer->normalize(null, $format, [...$context, 'docgen:expects' => User::class]);
|
||||
|
||||
return [
|
||||
'isNull' => true,
|
||||
'type' => 'accompanying_period_work',
|
||||
'accompanyingPeriodWorkEvaluations' => [],
|
||||
'referrers' => [],
|
||||
'createdAt' => $dateNull,
|
||||
'createdAutomatically' => 'false',
|
||||
'createdAutomaticallyReason' => '',
|
||||
'createdBy' => $userNull,
|
||||
'endDate' => $dateNull,
|
||||
'goals' => [],
|
||||
'handlingThierParty' => $this->normalizer->normalize(null, $format, [...$cleanContext, 'docgen:expects' => ThirdParty::class]),
|
||||
'id' => '',
|
||||
'note' => '',
|
||||
'persons' => [],
|
||||
'results' => [],
|
||||
'socialAction' => $this->normalizer->normalize(null, $format, [...$cleanContext, 'docgen:expects' => SocialAction::class]),
|
||||
'startDate' => $dateNull,
|
||||
'thirdParties' => [],
|
||||
'updatedAt' => $dateNull,
|
||||
'updatedBy' => $userNull,
|
||||
];
|
||||
}
|
||||
|
||||
$initial = $this->normalizer->normalize($object, $format, array_merge(
|
||||
$cleanContext,
|
||||
[self::IGNORE_WORK => null === $object ? null : spl_object_hash($object)]
|
||||
$context,
|
||||
[self::IGNORE_WORK => spl_object_hash($object)]
|
||||
));
|
||||
|
||||
// due to bug: https://api-platform.com/docs/core/serialization/#collection-relation
|
||||
@@ -84,57 +48,38 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
|
||||
$initial['accompanyingPeriodWorkEvaluations'] = $this->normalizer->normalize(
|
||||
$object->getAccompanyingPeriodWorkEvaluations()->getValues(),
|
||||
$format,
|
||||
[...$cleanContext]
|
||||
$context
|
||||
);
|
||||
|
||||
// add the referrers
|
||||
$initial['referrers'] = [];
|
||||
// then, we add normalization for things which are not into the entity
|
||||
|
||||
foreach ($object->getReferrersHistory() as $referrerHistory) {
|
||||
if (null !== $referrerHistory->getEndDate()) {
|
||||
continue;
|
||||
}
|
||||
$initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWork::class,
|
||||
$object->getId()
|
||||
);
|
||||
|
||||
$initial['referrers'][] = $this->normalizer->normalize(
|
||||
$referrerHistory->getUser(),
|
||||
$format,
|
||||
[...$cleanContext, UserNormalizer::AT_DATE => $referrerHistory->getStartDate()]
|
||||
);
|
||||
}
|
||||
$initial['workflows_availables_evaluation'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluation::class
|
||||
);
|
||||
|
||||
if ('json' === $format) {
|
||||
// then, we add normalization for things which are not into the entity
|
||||
$initial['workflows_availables'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWork::class,
|
||||
$object->getId()
|
||||
);
|
||||
$initial['workflows_availables_evaluation_documents'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluationDocument::class
|
||||
);
|
||||
|
||||
$initial['workflows_availables_evaluation'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluation::class
|
||||
);
|
||||
$workflows = $this->entityWorkflowRepository->findBy([
|
||||
'relatedEntityClass' => AccompanyingPeriodWork::class,
|
||||
'relatedEntityId' => $object->getId(),
|
||||
]);
|
||||
|
||||
$initial['workflows_availables_evaluation_documents'] = $this->metadataExtractor->availableWorkflowFor(
|
||||
AccompanyingPeriodWorkEvaluationDocument::class
|
||||
);
|
||||
|
||||
$workflows = $this->entityWorkflowRepository->findBy([
|
||||
'relatedEntityClass' => AccompanyingPeriodWork::class,
|
||||
'relatedEntityId' => $object->getId(),
|
||||
]);
|
||||
|
||||
$initial['workflows'] = $this->normalizer->normalize($workflows, 'json', $context);
|
||||
}
|
||||
$initial['workflows'] = $this->normalizer->normalize($workflows, 'json', $context);
|
||||
|
||||
return $initial;
|
||||
}
|
||||
|
||||
public function supportsNormalization($data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return match ($format) {
|
||||
'json' => $data instanceof AccompanyingPeriodWork && ($context[self::IGNORE_WORK] ?? null) !== spl_object_hash($data),
|
||||
'docgen' => ($data instanceof AccompanyingPeriodWork || (null === $data && ($context['docgen:expects'] ?? null) === AccompanyingPeriodWork::class))
|
||||
&& !array_key_exists(self::IGNORE_WORK, $context),
|
||||
default => false,
|
||||
};
|
||||
return 'json' === $format
|
||||
&& $data instanceof AccompanyingPeriodWork
|
||||
&& !\array_key_exists(self::IGNORE_WORK, $context);
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class SocialActionNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
'type' => 'social_work_social_action',
|
||||
'text' => $this->render->renderString($socialAction, []),
|
||||
'title' => $socialAction->getTitle(),
|
||||
'parent' => $this->normalizer->normalize($socialAction->getParent(), $format, [...$context, 'docgen:expects' => SocialAction::class]),
|
||||
'parent' => $this->normalizer->normalize($socialAction->getParent(), $format, $context),
|
||||
'issue' => $this->normalizer->normalize($socialAction->getIssue(), $format, $context),
|
||||
];
|
||||
|
||||
|
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Serializer\Normalizer\UserNormalizer;
|
||||
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
@@ -47,7 +46,7 @@ class WorkflowNormalizer implements ContextAwareNormalizerInterface, NormalizerA
|
||||
$data['workflow'] = $this->metadataExtractor->buildArrayPresentationForWorkflow($workflow);
|
||||
$data['current_place'] = $this->metadataExtractor->buildArrayPresentationForPlace($object);
|
||||
$data['current_place_at'] = $this->normalizer->normalize($object->getCurrentStepCreatedAt(), 'json', ['groups' => ['read']]);
|
||||
$data['current_place_by'] = $this->normalizer->normalize($object->getCurrentStepCreatedBy(), 'json', ['groups' => ['read'], UserNormalizer::AT_DATE => $object->getCurrentStepCreatedAt()]);
|
||||
$data['current_place_by'] = $this->normalizer->normalize($object->getCurrentStepCreatedBy(), 'json', ['groups' => ['read']]);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@@ -33,40 +33,7 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
||||
$this->aggregator = self::getContainer()->get('chill.person.export.aggregator_referrer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideBeforeData
|
||||
*/
|
||||
public function testDataTransformer(?array $before, array $expected): void
|
||||
{
|
||||
$actual = $this->getAggregator()->transformData($before);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
foreach (['start_date', 'end_date'] as $key) {
|
||||
self::assertInstanceOf(RollingDate::class, $actual[$key]);
|
||||
self::assertEquals($expected[$key]->getRoll(), $actual[$key]->getRoll(), "Check that the roll is the same for {$key}");
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideBeforeData(): iterable
|
||||
{
|
||||
yield [
|
||||
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_TODAY), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
null,
|
||||
// this is the default configuration
|
||||
['start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
public function getAggregator(): ReferrerAggregator
|
||||
public function getAggregator()
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
@@ -74,10 +41,7 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
||||
public static function getFormData(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,6 @@ namespace Export\Aggregator\AccompanyingCourseAggregators;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
@@ -49,46 +48,16 @@ final class ReferrerScopeAggregatorTest extends AbstractAggregatorTest
|
||||
return new ReferrerScopeAggregator(
|
||||
$scopeRepository->reveal(),
|
||||
$translatableStringHelper->reveal(),
|
||||
new RollingDateConverter(),
|
||||
$dateConverter->reveal()
|
||||
);
|
||||
}
|
||||
|
||||
public static function getFormData(): array
|
||||
{
|
||||
return [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideBeforeData
|
||||
*/
|
||||
public function testDataTransformer(?array $before, array $expected): void
|
||||
{
|
||||
$actual = $this->getAggregator()->transformData($before);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
foreach (['start_date', 'end_date'] as $key) {
|
||||
self::assertInstanceOf(RollingDate::class, $actual[$key]);
|
||||
self::assertEquals($expected[$key]->getRoll(), $actual[$key]->getRoll(), "Check that the roll is the same for {$key}");
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideBeforeData(): iterable
|
||||
{
|
||||
yield [
|
||||
null,
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
[],
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
[
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -33,39 +33,7 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest
|
||||
$this->aggregator = self::getContainer()->get('chill.person.export.aggregator_referrer_job');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideBeforeData
|
||||
*/
|
||||
public function testDataTransformer(?array $before, array $expected): void
|
||||
{
|
||||
$actual = $this->getAggregator()->transformData($before);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
foreach (['start_date', 'end_date'] as $key) {
|
||||
self::assertInstanceOf(RollingDate::class, $actual[$key]);
|
||||
self::assertEquals($expected[$key]->getRoll(), $actual[$key]->getRoll(), "Check that the roll is the same for {$key}");
|
||||
}
|
||||
}
|
||||
|
||||
public static function provideBeforeData(): iterable
|
||||
{
|
||||
yield [
|
||||
null,
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
[],
|
||||
['start_date' => new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('1970-01-01')), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
public function getAggregator(): UserJobAggregator
|
||||
public function getAggregator()
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
@@ -73,7 +41,9 @@ final class UserJobAggregatorTest extends AbstractAggregatorTest
|
||||
public static function getFormData(): array
|
||||
{
|
||||
return [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
[
|
||||
'job_at' => new RollingDate(RollingDate::T_FIXED_DATE, \DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -50,13 +50,11 @@ final class UserJobFilterTest extends AbstractFilterTest
|
||||
$data = [];
|
||||
$data[] = [
|
||||
'jobs' => new ArrayCollection($jobs),
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
$data[] = [
|
||||
'jobs' => $jobs,
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
];
|
||||
|
||||
return $data;
|
||||
|
@@ -50,13 +50,11 @@ final class UserScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
return [
|
||||
[
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'scopes' => new ArrayCollection($scopes),
|
||||
],
|
||||
[
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
'date_calc' => new RollingDate(RollingDate::T_TODAY),
|
||||
'scopes' => $scopes,
|
||||
],
|
||||
];
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user