mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge remote-tracking branch 'origin/master' into track-address-reference-update
This commit is contained in:
@@ -651,8 +651,8 @@ final class ActivityController extends AbstractController
|
||||
throw $this->createNotFoundException('Accompanying Period not found');
|
||||
}
|
||||
|
||||
// TODO Add permission
|
||||
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||
// TODO Add permission
|
||||
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||
} else {
|
||||
throw $this->createNotFoundException('Person or Accompanying Period not found');
|
||||
}
|
||||
|
@@ -195,7 +195,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private User $user;
|
||||
private ?User $user;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
|
||||
@@ -494,7 +494,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
return $this->activityType;
|
||||
}
|
||||
|
||||
public function getUser(): User
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
@@ -681,14 +681,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUser(UserInterface $user): self
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUsers(?Collection $users): self
|
||||
public function setUsers(Collection $users): self
|
||||
{
|
||||
$this->users = $users;
|
||||
|
||||
|
@@ -380,6 +380,7 @@ class ActivityType
|
||||
throw new InvalidArgumentException('Field "' . $field . '" not found');
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
return $this->{$property};
|
||||
}
|
||||
|
||||
@@ -538,6 +539,7 @@ class ActivityType
|
||||
throw new InvalidArgumentException('Field "' . $field . '" not found');
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
return self::FIELD_REQUIRED === $this->{$property};
|
||||
}
|
||||
|
||||
@@ -549,6 +551,7 @@ class ActivityType
|
||||
throw new InvalidArgumentException('Field "' . $field . '" not found');
|
||||
}
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
return self::FIELD_INVISIBLE !== $this->{$property};
|
||||
}
|
||||
|
||||
|
@@ -58,7 +58,8 @@ class DateAggregator implements AggregatorInterface
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$fmt = 'YYYY'; $order = 'DESC';
|
||||
$fmt = 'YYYY';
|
||||
$order = 'DESC';
|
||||
|
||||
break; // order DESC does not works !
|
||||
|
||||
|
@@ -73,7 +73,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
||||
};
|
||||
|
||||
case 'scopesNames':
|
||||
return $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles');
|
||||
return $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles');
|
||||
|
||||
default:
|
||||
return $this->helper->getLabels($key, $values, $data);
|
||||
|
@@ -20,13 +20,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class LocationFilter implements FilterInterface
|
||||
{
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
|
@@ -225,6 +225,7 @@ class ActivityType extends AbstractType
|
||||
$builder->add('user', PickUserDynamicType::class, [
|
||||
'label' => $activityType->getLabel('user'),
|
||||
'required' => $activityType->isRequired('user'),
|
||||
'multiple' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,9 @@ use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @implements LocalMenuBuilderInterface<array{accompanyingCourse: AccompanyingPeriod}>
|
||||
*/
|
||||
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
protected Security $security;
|
||||
|
@@ -15,6 +15,9 @@ use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @implements LocalMenuBuilderInterface<array>
|
||||
*/
|
||||
final class AdminMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
private Security $security;
|
||||
|
@@ -13,11 +13,15 @@ namespace Chill\ActivityBundle\Menu;
|
||||
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
/**
|
||||
* @implements LocalMenuBuilderInterface<array{person: Person}>
|
||||
*/
|
||||
final class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var AuthorizationCheckerInterface
|
||||
@@ -44,7 +48,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
|
||||
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {
|
||||
$menu->addChild(
|
||||
$this->translator->trans('Activity list'),
|
||||
$this->translator->trans('Activities'),
|
||||
[
|
||||
'route' => 'chill_activity_activity_list',
|
||||
'routeParameters' => ['person_id' => $person->getId()],
|
||||
|
@@ -225,10 +225,9 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
|
||||
$personToCenter = $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'];
|
||||
|
||||
// acls:
|
||||
$role = new Role(ActivityVoter::SEE);
|
||||
$reachableCenters = $this->authorizationHelper->getReachableCenters(
|
||||
$this->tokenStorage->getToken()->getUser(),
|
||||
$role
|
||||
ActivityVoter::SEE
|
||||
);
|
||||
|
||||
if (count($reachableCenters) === 0) {
|
||||
@@ -239,7 +238,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
|
||||
if ('person' === $context) {
|
||||
// we start with activities having the person_id linked to person
|
||||
$where .= sprintf('%s = ? AND ', $activityToPerson);
|
||||
$parameters[] = $person->getId();
|
||||
$parameters[] = $args['context']->getId();
|
||||
}
|
||||
|
||||
// we add acl (reachable center and scopes)
|
||||
@@ -252,7 +251,7 @@ final class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInte
|
||||
continue;
|
||||
}
|
||||
// we get all the reachable scopes for this center
|
||||
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
|
||||
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), ActivityVoter::SEE, $center);
|
||||
// we get the ids for those scopes
|
||||
$reachablesScopesId = array_map(
|
||||
static function (Scope $scope) {
|
||||
|
@@ -63,7 +63,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if activity.user and t.userVisible %}
|
||||
{% if activity.user is not null and t.userVisible %}
|
||||
<div class="wl-row">
|
||||
<div class="wl-col title"><h3>{{ 'Referrer'|trans }}</h3></div>
|
||||
<div class="wl-col list">
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
Maybe should we think about abstracting this file a bit more ? Moving it to PersonBundle ?
|
||||
#}
|
||||
{% if context == 'calendar_accompanyingCourse' %}
|
||||
{% if context == 'calendar_accompanyingCourse' or context == 'calendar_person' %}
|
||||
{% import "@ChillCalendar/_invite.html.twig" as invite %}
|
||||
{% endif %}
|
||||
|
||||
|
@@ -34,10 +34,12 @@
|
||||
|
||||
<div class="item-row separator">
|
||||
<dl class="chill_view_data">
|
||||
<dt class="inline">{{ 'Referrer'|trans|capitalize }}</dt>
|
||||
<dd>
|
||||
<span class="badge-user">{{ entity.user|chill_entity_render_box }}</span>
|
||||
</dd>
|
||||
{%- if entity.user is not null %}
|
||||
<dt class="inline">{{ 'Referrer'|trans|capitalize }}</dt>
|
||||
<dd>
|
||||
<span class="badge-user">{{ entity.user|chill_entity_render_box }}</span>
|
||||
</dd>
|
||||
{% endif %}
|
||||
|
||||
{%- if entity.scope -%}
|
||||
<dt class="inline">{{ 'Scope'|trans }}</dt>
|
||||
|
@@ -32,6 +32,9 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @implements DocGeneratorContextWithPublicFormInterface<Activity>
|
||||
*/
|
||||
class ActivityContext implements
|
||||
DocGeneratorContextWithAdminFormInterface,
|
||||
DocGeneratorContextWithPublicFormInterface
|
||||
@@ -237,9 +240,6 @@ class ActivityContext implements
|
||||
return $denormalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Activity $entity
|
||||
*/
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
||||
{
|
||||
$storedObject->setTitle($this->translatableStringHelper->localize($template->getName()));
|
||||
|
@@ -13,13 +13,18 @@ namespace Chill\ActivityBundle\Templating\Entity;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
||||
use Chill\MainBundle\Templating\Entity\BoxUtilsChillEntityRenderTrait;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
|
||||
/**
|
||||
* Render activity reason.
|
||||
*
|
||||
* @implements ChillEntityRenderInterface<ActivityReason>
|
||||
*/
|
||||
class ActivityReasonRender extends AbstractChillEntityRender
|
||||
class ActivityReasonRender implements ChillEntityRenderInterface
|
||||
{
|
||||
use BoxUtilsChillEntityRenderTrait;
|
||||
/**
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
@@ -51,9 +56,6 @@ class ActivityReasonRender extends AbstractChillEntityRender
|
||||
$this->getDefaultClosingBox();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ActivityReason $entity
|
||||
*/
|
||||
public function renderString($entity, array $options): string
|
||||
{
|
||||
$category = '';
|
||||
|
@@ -121,14 +121,14 @@ final class ActivityControllerTest extends WebTestCase
|
||||
$client->getResponse()->getStatusCode(),
|
||||
'Unexpected HTTP status code for GET /activity/'
|
||||
);
|
||||
$crawler = $client->click($crawler->selectLink('Ajouter une nouvelle activité')
|
||||
$crawler = $client->click($crawler->selectLink('Ajouter un nouvel échange')
|
||||
->link());
|
||||
|
||||
$reason1 = $this->getRandomActivityReason();
|
||||
$reason2 = $this->getRandomActivityReason([$reason1->getId()]);
|
||||
|
||||
// Fill in the form and submit it
|
||||
$form = $crawler->selectButton('Ajouter une nouvelle activité')->form([
|
||||
$form = $crawler->selectButton('Ajouter un nouvel échange')->form([
|
||||
'chill_activitybundle_activity' => [
|
||||
'date' => '15-01-2015',
|
||||
'durationTime' => 600,
|
||||
@@ -152,9 +152,9 @@ final class ActivityControllerTest extends WebTestCase
|
||||
);
|
||||
|
||||
// Edit the entity
|
||||
$crawler = $client->click($crawler->selectLink("Modifier l'activité")->link());
|
||||
$crawler = $client->click($crawler->selectLink("Modifier l'échange")->link());
|
||||
|
||||
$form = $crawler->selectButton("Sauver l'activité")->form([
|
||||
$form = $crawler->selectButton("Sauver l'échange")->form([
|
||||
'chill_activitybundle_activity' => [
|
||||
'date' => '25-01-2015',
|
||||
// 'remark' => 'Foo'
|
||||
@@ -234,7 +234,7 @@ final class ActivityControllerTest extends WebTestCase
|
||||
$user = new \Chill\MainBundle\Entity\User();
|
||||
$user
|
||||
->setPassword($container->get('security.password_encoder')
|
||||
->encodePassword($user, 'password'))
|
||||
->encodePassword($user, 'password'))
|
||||
->setUsername($username)
|
||||
->addGroupCenter($groupCenter);
|
||||
|
||||
|
@@ -112,9 +112,9 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
'attendee' => true,
|
||||
]]);
|
||||
|
||||
// var_dump($form->getErrors()->count()); var_dump($form->isValid());
|
||||
// foreach($form->getErrors() as $e) { fwrite(STDOUT, var_dump($e->getMessage())); }
|
||||
// var_dump($form->getErrors());
|
||||
// var_dump($form->getErrors()->count()); var_dump($form->isValid());
|
||||
// foreach($form->getErrors() as $e) { fwrite(STDOUT, var_dump($e->getMessage())); }
|
||||
// var_dump($form->getErrors());
|
||||
|
||||
$this->assertTrue($form->isSynchronized(), 'Test the form is synchronized');
|
||||
$this->assertTrue($form->isValid(), 'test the form is valid');
|
||||
|
@@ -1,41 +1,41 @@
|
||||
#general
|
||||
Show the activity: Voir l'activité
|
||||
Edit the activity: Modifier l'activité
|
||||
Activity: Activité
|
||||
Show the activity: Voir l'échange
|
||||
Edit the activity: Modifier l'échange
|
||||
Activity: Échange
|
||||
Duration time: Durée
|
||||
Duration Time: Durée
|
||||
durationTime: durée
|
||||
Travel time: Durée de déplacement
|
||||
Attendee: Présence de la personne
|
||||
attendee: présence de la personne
|
||||
Attendee: Présence de l'usager
|
||||
attendee: présence de l'usager
|
||||
list_reasons: liste des sujets
|
||||
user_username: nom de l'utilisateur
|
||||
circle_name: nom du cercle
|
||||
Remark: Commentaire
|
||||
No comments: Aucun commentaire
|
||||
Add a new activity: Ajouter une nouvelle activité
|
||||
Activity list: Liste des activités
|
||||
Add a new activity: Ajouter une nouvel échange
|
||||
Activity list: Liste des échanges
|
||||
present: présent
|
||||
not present: absent
|
||||
Delete: Supprimer
|
||||
Update: Mettre à jour
|
||||
Update activity: Modifier l'activité
|
||||
Update activity: Modifier l'échange
|
||||
Scope: Cercle
|
||||
Activity data: Données de l'activité
|
||||
Activity location: Localisation de l'activité
|
||||
Activity data: Données de l'échange
|
||||
Activity location: Localisation de l'échange
|
||||
No reason associated: Aucun sujet
|
||||
No social issues associated: Aucune problématique sociale
|
||||
No social actions associated: Aucune action d'accompagnement
|
||||
There isn't any activities.: Aucune activité enregistrée.
|
||||
type_name: type de l'activité
|
||||
There isn't any activities.: Aucun échange enregistré.
|
||||
type_name: type de l'échange
|
||||
person_firstname: prénom
|
||||
person_lastname: nom de famille
|
||||
person_id: identifiant de la personne
|
||||
person_id: identifiant de l'usager
|
||||
Type: Type
|
||||
Invisible: Invisible
|
||||
Optional: Optionnel
|
||||
Required: Obligatoire
|
||||
Persons: Personnes
|
||||
Persons: Usagers
|
||||
Users: Utilisateurs
|
||||
Emergency: Urgent
|
||||
Sent received: Entrant / Sortant
|
||||
@@ -50,10 +50,10 @@ received: Reçu
|
||||
|
||||
|
||||
#forms
|
||||
Activity creation: Nouvelle activité
|
||||
Activity creation: Nouvel échange
|
||||
Create: Créer
|
||||
Back to the list: Retour à la liste
|
||||
Save activity: Sauver l'activité
|
||||
Save activity: Sauver l'échange
|
||||
Reset form: Remise à zéro du formulaire
|
||||
Choose the duration: Choisir la durée
|
||||
Choose a type: Choisir un type
|
||||
@@ -90,40 +90,40 @@ activity:
|
||||
No documents: Aucun document
|
||||
|
||||
#timeline
|
||||
'%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"'
|
||||
'%user% has done an %activity_type%': '%user% a effectué un échange de type "%activity_type%"'
|
||||
|
||||
#controller
|
||||
'Success : activity created!': L'activité a été créée.
|
||||
'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'activité n'a pas été créée.
|
||||
'Success : activity updated!': L'activité a été mise à jour.
|
||||
'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'activité n'a pas été mise à jour.
|
||||
'Success : activity created!': L'échange a été créé.
|
||||
'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'échange n'a pas été créé.
|
||||
'Success : activity updated!': L'échange a été mis à jour.
|
||||
'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'échange n'a pas été mise à jour.
|
||||
|
||||
# ROLES
|
||||
CHILL_ACTIVITY_CREATE: Créer une activité
|
||||
CHILL_ACTIVITY_UPDATE: Modifier une activité
|
||||
CHILL_ACTIVITY_SEE: Voir une activité
|
||||
CHILL_ACTIVITY_SEE_DETAILS: Voir le détail des activités
|
||||
CHILL_ACTIVITY_DELETE: Supprimer une activité
|
||||
CHILL_ACTIVITY_STATS: Statistique des activités
|
||||
CHILL_ACTIVITY_LIST: Liste des activités
|
||||
CHILL_ACTIVITY_CREATE: Créer un échange
|
||||
CHILL_ACTIVITY_UPDATE: Modifier un échange
|
||||
CHILL_ACTIVITY_SEE: Voir un échange
|
||||
CHILL_ACTIVITY_SEE_DETAILS: Voir le détail des échanges
|
||||
CHILL_ACTIVITY_DELETE: Supprimer un échange
|
||||
CHILL_ACTIVITY_STATS: Statistique des échanges
|
||||
CHILL_ACTIVITY_LIST: Liste des échanges
|
||||
|
||||
# admin
|
||||
Activities: Activités
|
||||
Activity configuration: Configuration des activités
|
||||
Activity configuration menu: Configuration des activités
|
||||
Activity types: Types d'activité
|
||||
Activity type configuration: Configuration des categories d'activités
|
||||
Activity Reasons: Sujets d'une activité
|
||||
Activity Reasons Category: Catégories de sujet d'activités
|
||||
Activity Types Categories: Catégories des types d'activité
|
||||
Activity Presences: Presences aux activités
|
||||
Activities: Échanges
|
||||
Activity configuration: Configuration des échanges
|
||||
Activity configuration menu: Configuration des échanges
|
||||
Activity types: Types d'échange
|
||||
Activity type configuration: Configuration des catégories d'échanges
|
||||
Activity Reasons: Sujets d'un échange
|
||||
Activity Reasons Category: Catégories de sujet d'échanges
|
||||
Activity Types Categories: Catégories des types d'échange
|
||||
Activity Presences: Presences aux échanges
|
||||
Associated activity reason category is inactive: La catégorie de sujet attachée est inactive
|
||||
|
||||
|
||||
# Crud
|
||||
crud:
|
||||
activity_type:
|
||||
title_new: Nouveau type d'activité
|
||||
title_new: Nouveau type d'échange
|
||||
title_edit: Edition d'un type d'activité
|
||||
activity_type_category:
|
||||
title_new: Nouvelle catégorie de type d'activité
|
||||
@@ -159,8 +159,8 @@ Create a new activity presence: Créer une nouvelle "Présence aux activités"
|
||||
# activity type type admin
|
||||
ActivityType list: Types d'activités
|
||||
Create a new activity type: Créer un nouveau type d'activité
|
||||
Persons visible: Visibilité du champ Personnes
|
||||
Persons label: Libellé du champ Personnes
|
||||
Persons visible: Visibilité du champ Usagers
|
||||
Persons label: Libellé du champ Usagers
|
||||
User visible: Visibilité du champ Utilisateur
|
||||
User label: Libellé du champ Utilisateur
|
||||
Date visible: Visibilité du champ Date
|
||||
@@ -183,8 +183,8 @@ Private comment visible: Visibilité du champ Commentaire Privé
|
||||
Private comment label: Libellé du champ Commentaire Privé
|
||||
Emergency visible: Visibilité du champ Urgent
|
||||
Emergency label: Libellé du champ Urgent
|
||||
Accompanying period visible: Visibilité du champ Période d'accompagnement
|
||||
Accompanying period label: Libellé du champ Période d'accompagnement
|
||||
Accompanying period visible: Visibilité du champ parcours d'accompagnement
|
||||
Accompanying period label: Libellé du champ parcours d'accompagnement
|
||||
Social issues visible: Visibilité du champ Problématiques sociales
|
||||
Social issues label: Libellé du champ Problématiques sociales
|
||||
Social actions visible: Visibilité du champ Action sociale
|
||||
@@ -206,10 +206,10 @@ Are you sure you want to remove the activity about "%name%" ?: Êtes-vous sûr d
|
||||
The activity has been successfully removed.: L'activité a été supprimée.
|
||||
|
||||
# exports
|
||||
Exports of activities linked to a person: Exports des activités liées à une personne
|
||||
Number of activities linked to a person: Nombre d'activités liées à une personne
|
||||
Exports of activities linked to a person: Exports des activités liées à un usager
|
||||
Number of activities linked to a person: Nombre d'activités liées à un usager
|
||||
Count activities linked to a person: Nombre d'activités
|
||||
Count activities linked to a person by various parameters.: Compte le nombre d'activités enregistrées et liées à une personne en fonction de différents paramètres.
|
||||
Count activities linked to a person by various parameters.: Compte le nombre d'activités enregistrées et liées à un usager en fonction de différents paramètres.
|
||||
Sum activity linked to a person duration: Durée des activités
|
||||
Sum activities linked to a person duration: Durée des activités liés à un usager
|
||||
Sum activities linked to a person duration by various parameters.: Additionne la durée des activités en fonction de différents paramètres.
|
||||
@@ -244,10 +244,10 @@ Activities before this date: Activités avant cette date
|
||||
"Filtered by date of activity: only between %date_from% and %date_to%": "Filtré par date de l'activité: uniquement entre %date_from% et %date_to%"
|
||||
This date should be after the date given in "Implied in an activity after this date" field: Cette date devrait être postérieure à la date donnée dans le champ "activités après cette date"
|
||||
|
||||
Filtered by person having an activity in a period: Uniquement les personnes ayant eu une activité dans la période donnée
|
||||
Filtered by person having an activity in a period: Uniquement les usagers ayant eu une activité dans la période donnée
|
||||
Implied in an activity after this date: Impliqué dans une activité après cette date
|
||||
Implied in an activity before this date: Impliqué dans une activité avant cette date
|
||||
Filtered by person having an activity between %date_from% and %date_to% with reasons %reasons_name%: Filtré par personnes associées à une activité entre %date_from% et %date_to% avec les sujets %reasons_name%
|
||||
Filtered by person having an activity between %date_from% and %date_to% with reasons %reasons_name%: Filtré par usager associées à une activité entre %date_from% et %date_to% avec les sujets %reasons_name%
|
||||
Activity reasons for those activities: Sujets de ces activités
|
||||
|
||||
Filter by activity type: Filtrer les activités par type
|
||||
@@ -336,8 +336,8 @@ export:
|
||||
users name: Nom des utilisateurs
|
||||
users ids: Identifiant des utilisateurs
|
||||
third parties ids: Identifiant des tiers
|
||||
persons ids: Identifiant des personnes
|
||||
persons name: Nom des personnes
|
||||
persons ids: Identifiant des usagers
|
||||
persons name: Nom des usagers
|
||||
thirds parties: Tiers
|
||||
date: Date de l'activité
|
||||
locationName: Localisation
|
||||
|
@@ -47,10 +47,10 @@ Reasons: Onderwerpen
|
||||
|
||||
|
||||
#forms
|
||||
Activity creation: Nouvelle activité
|
||||
Activity creation: Nouvel échange
|
||||
Create: Créer
|
||||
Back to the list: Retour à la liste
|
||||
Save activity: Sauver l'activité
|
||||
Save activity: Sauver l'échange
|
||||
Reset form: Remise à zéro du formulaire
|
||||
Choose the duration: Choisir la durée
|
||||
Choose a type: Choisir un type
|
||||
@@ -79,43 +79,43 @@ activity:
|
||||
No documents: Aucun document
|
||||
|
||||
#timeline
|
||||
'%user% has done an %activity_type%': '%user% a effectué une activité de type "%activity_type%"'
|
||||
'%user% has done an %activity_type%': '%user% a effectué un échange de type "%activity_type%"'
|
||||
|
||||
#controller
|
||||
'Success : activity created!': L'activité a été créée.
|
||||
'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'activité n'a pas été créée.
|
||||
'Success : activity updated!': L'activité a été mise à jour.
|
||||
'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'activité n'a pas été mise à jour.
|
||||
'Success : activity created!': L'échange a été créé.
|
||||
'The form is not valid. The activity has not been created !': Le formulaire est invalide. L'échange n'a pas été créé.
|
||||
'Success : activity updated!': L'échange a été mis à jour.
|
||||
'The form is not valid. The activity has not been updated !': Le formulaire est invalide. L'échange n'a pas été mis à jour.
|
||||
|
||||
# ROLES
|
||||
CHILL_ACTIVITY_CREATE: Créer une activité
|
||||
CHILL_ACTIVITY_UPDATE: Modifier une activité
|
||||
CHILL_ACTIVITY_SEE: Voir une activité
|
||||
CHILL_ACTIVITY_SEE_DETAILS: Voir le détail des activités
|
||||
CHILL_ACTIVITY_DELETE: Supprimer une activité
|
||||
CHILL_ACTIVITY_STATS: Statistique des activités
|
||||
CHILL_ACTIVITY_LIST: Liste des activités
|
||||
CHILL_ACTIVITY_CREATE: Créer un échange
|
||||
CHILL_ACTIVITY_UPDATE: Modifier un échange
|
||||
CHILL_ACTIVITY_SEE: Voir un échange
|
||||
CHILL_ACTIVITY_SEE_DETAILS: Voir le détail des échanges
|
||||
CHILL_ACTIVITY_DELETE: Supprimer un échange
|
||||
CHILL_ACTIVITY_STATS: Statistique des échanges
|
||||
CHILL_ACTIVITY_LIST: Liste des échanges
|
||||
|
||||
# admin
|
||||
Activities: Activités
|
||||
Activity configuration: Configuration des activités
|
||||
Activity configuration menu: Configuration des activités
|
||||
Activity types: Types d'activité
|
||||
Activity type configuration: Configuration des categories d'activités
|
||||
Activity Reasons: Sujets d'une activité
|
||||
Activity Reasons Category: Catégories de sujet d'activités
|
||||
Activity Types Categories: Catégories des types d'activité
|
||||
Activity Presences: Presences des activités
|
||||
Activities: Échanges
|
||||
Activity configuration: Configuration des échanges
|
||||
Activity configuration menu: Configuration des échanges
|
||||
Activity types: Types d'échange
|
||||
Activity type configuration: Configuration des categories d'échanges
|
||||
Activity Reasons: Sujets d'un échange
|
||||
Activity Reasons Category: Catégories de sujet d'échanges
|
||||
Activity Types Categories: Catégories des types d'échanges
|
||||
Activity Presences: Presences des échanges
|
||||
|
||||
|
||||
# Crud
|
||||
crud:
|
||||
activity_type:
|
||||
title_new: Nouveau type d'activité
|
||||
title_edit: Edition d'un type d'activité
|
||||
title_new: Nouveau type d'échange
|
||||
title_edit: Edition d'un type d'échange
|
||||
activity_type_category:
|
||||
title_new: Nouvelle catégorie de type d'activité
|
||||
title_edit: Edition d'une catégorie de type d'activité
|
||||
title_new: Nouvelle catégorie de type d'échange
|
||||
title_edit: Edition d'une catégorie de type d'échange
|
||||
|
||||
# activity reason admin
|
||||
ActivityReason list: Liste des sujets
|
||||
@@ -124,7 +124,7 @@ Active: Actif
|
||||
Category: Catégorie
|
||||
ActivityReason creation: Nouveau sujet
|
||||
ActivityReason edit: Modification d'un sujet
|
||||
ActivityReason: Sujet d'activité
|
||||
ActivityReason: Sujet d'échange
|
||||
The entity is inactive and won't be proposed: Le sujet est inactif et ne sera pas proposé
|
||||
The entity is active and will be proposed: Le sujet est actif et sera proposé
|
||||
|
||||
@@ -133,13 +133,13 @@ ActivityReasonCategory list: Catégories de sujets
|
||||
Create a new activity category reason: Créer une nouvelle catégorie
|
||||
ActivityReasonCategory creation: Nouvelle catégorie de sujet
|
||||
ActivityReasonCategory edit: Modification d'une catégorie de sujet
|
||||
ActivityReasonCategory: Catégorie de sujet d'activité
|
||||
ActivityReasonCategory: Catégorie de sujet d'échange
|
||||
ActivityReasonCategory is active and will be proposed: La catégorie est active et sera proposée
|
||||
ActivityReasonCategory is inactive and won't be proposed: La catégorie est inactive et ne sera pas proposée
|
||||
|
||||
# activity type type admin
|
||||
ActivityType list: Types d'activités
|
||||
Create a new activity type: Créer un nouveau type d'activité
|
||||
ActivityType list: Types d'échanges
|
||||
Create a new activity type: Créer un nouveau type d'échange
|
||||
Persons visible: Visibilité du champ Personnes
|
||||
Persons label: Libellé du champ Personnes
|
||||
User visible: Visibilité du champ Utilisateur
|
||||
@@ -177,20 +177,20 @@ Documents label: Libellé du champ Documents
|
||||
|
||||
# activity type category admin
|
||||
ActivityTypeCategory list: Liste des catégories des types d'activité
|
||||
Create a new activity type category: Créer une nouvelle catégorie de type d'activité
|
||||
Create a new activity type category: Créer une nouvelle catégorie de type d'échange
|
||||
|
||||
# activity delete
|
||||
Remove activity: Supprimer une activité
|
||||
Are you sure you want to remove the activity about "%name%" ?: Êtes-vous sûr de vouloir supprimer une activité qui concerne "%name%" ?
|
||||
The activity has been successfully removed.: L'activité a été supprimée.
|
||||
Remove activity: Supprimer un échange
|
||||
Are you sure you want to remove the activity about "%name%" ?: Êtes-vous sûr de vouloir supprimer un échange qui concerne "%name%" ?
|
||||
The activity has been successfully removed.: L'échange a été supprimée.
|
||||
|
||||
# exports
|
||||
Count activities: Nombre d'activités
|
||||
Count activities by various parameters.: Compte le nombre d'activités enregistrées en fonction de différents paramètres.
|
||||
Sum activity duration: Total de la durée des activités
|
||||
Sum activities duration by various parameters.: Additionne la durée des activités en fonction de différents paramètres.
|
||||
List activities: Liste les activités
|
||||
Number of activities: Nombre d'activités
|
||||
Count activities: Nombre d'échanges
|
||||
Count activities by various parameters.: Compte le nombre d'échanges enregistrées en fonction de différents paramètres.
|
||||
Sum activity duration: Total de la durée des échanges
|
||||
Sum activities duration by various parameters.: Additionne la durée des échanges en fonction de différents paramètres.
|
||||
List activities: Liste les échanges
|
||||
Number of activities: Nombre d'échanges
|
||||
|
||||
#filters
|
||||
Filter by reason: Filtrer par sujet d'activité
|
||||
|
@@ -1,22 +1,22 @@
|
||||
The reasons's level should not be empty: Le niveau du sujet ne peut pas être vide
|
||||
At least one reason must be choosen: Au moins un sujet doit être choisi
|
||||
For this type of activity, you must add at least one person: Pour ce type d'activité, vous devez ajouter au moins un usager
|
||||
For this type of activity, you must add at least one user: Pour ce type d'activité, vous devez ajouter au moins un utilisateur
|
||||
For this type of activity, you must add at least one third party: Pour ce type d'activité, vous devez ajouter au moins un tiers
|
||||
For this type of activity, user is required: Pour ce type d'activité, l'utilisateur est requis
|
||||
For this type of activity, date is required: Pour ce type d'activité, la date est requise
|
||||
For this type of activity, location is required: Pour ce type d'activité, la localisation est requise
|
||||
For this type of activity, attendee is required: Pour ce type d'activité, le champ "Présence de la personne" est requis
|
||||
For this type of activity, duration time is required: Pour ce type d'activité, la durée est requise
|
||||
For this type of activity, travel time is required: Pour ce type d'activité, la durée du trajet est requise
|
||||
For this type of activity, reasons is required: Pour ce type d'activité, le champ "sujet" est requis
|
||||
For this type of activity, comment is required: Pour ce type d'activité, un commentaire est requis
|
||||
For this type of activity, sent/received is required: Pour ce type d'activité, le champ Entrant/Sortant est requis
|
||||
For this type of activity, document is required: Pour ce type d'activité, un document est requis
|
||||
For this type of activity, emergency is required: Pour ce type d'activité, le champ "Urgent" est requis
|
||||
For this type of activity, accompanying period is required: Pour ce type d'activité, le parcours d'accompagnement est requis
|
||||
For this type of activity, you must add at least one social issue: Pour ce type d'activité, vous devez ajouter au moins une problématique sociale
|
||||
For this type of activity, you must add at least one social action: Pour ce type d'activité, vous devez indiquer au moins une action sociale
|
||||
For this type of activity, you must add at least one person: Pour ce type d'échange, vous devez ajouter au moins un usager
|
||||
For this type of activity, you must add at least one user: Pour ce type d'échange, vous devez ajouter au moins un utilisateur
|
||||
For this type of activity, you must add at least one third party: Pour ce type d'échange, vous devez ajouter au moins un tiers
|
||||
For this type of activity, user is required: Pour ce type d'échange, l'utilisateur est requis
|
||||
For this type of activity, date is required: Pour ce type d'échange, la date est requise
|
||||
For this type of activity, location is required: Pour ce type d'échange, la localisation est requise
|
||||
For this type of activity, attendee is required: Pour ce type d'échange, le champ "Présence de l'usager" est requis
|
||||
For this type of activity, duration time is required: Pour ce type d'échange, la durée est requise
|
||||
For this type of activity, travel time is required: Pour ce type d'échange, la durée du trajet est requise
|
||||
For this type of activity, reasons is required: Pour ce type d'échange, le champ "sujet" est requis
|
||||
For this type of activity, comment is required: Pour ce type d'échange, un commentaire est requis
|
||||
For this type of activity, sent/received is required: Pour ce type d'échange, le champ Entrant/Sortant est requis
|
||||
For this type of activity, document is required: Pour ce type d'échange, un document est requis
|
||||
For this type of activity, emergency is required: Pour ce type d'échange, le champ "Urgent" est requis
|
||||
For this type of activity, accompanying period is required: Pour ce type d'échange, le parcours d'accompagnement est requis
|
||||
For this type of activity, you must add at least one social issue: Pour ce type d'échange, vous devez ajouter au moins une problématique sociale
|
||||
For this type of activity, you must add at least one social action: Pour ce type d'échange, vous devez indiquer au moins une action sociale
|
||||
|
||||
# admin
|
||||
This parameter must be equal to social issue parameter: Ce paramètre doit être égal au paramètre "Visibilité du champs Problématiques sociales"
|
||||
|
@@ -55,7 +55,7 @@ class LoadAsideActivity extends Fixture implements DependentFixtureInterface
|
||||
$this->getReference('aside_activity_category_0')
|
||||
)
|
||||
->setDate((new DateTimeImmutable('today'))
|
||||
->sub(new DateInterval('P' . random_int(1, 100) . 'D')));
|
||||
->sub(new DateInterval('P' . random_int(1, 100) . 'D')));
|
||||
|
||||
$manager->persist($activity);
|
||||
}
|
||||
|
@@ -160,8 +160,8 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
|
||||
return 'export.aside_activity.main_center';
|
||||
}
|
||||
|
||||
/** @var Center $c */
|
||||
if (null === $value || '' === $value || null === $c = $this->centerRepository->find($value)) {
|
||||
/** @var Center $c */
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -190,10 +190,6 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QueryBuilder $query
|
||||
* @param array $data
|
||||
*/
|
||||
public function getResult($query, $data): array
|
||||
{
|
||||
return $query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY);
|
||||
|
@@ -28,22 +28,17 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
use function in_array;
|
||||
|
||||
final class AsideActivityFormType extends AbstractType
|
||||
{
|
||||
private TokenStorageInterface $storage;
|
||||
|
||||
private array $timeChoices;
|
||||
|
||||
public function __construct(
|
||||
ParameterBagInterface $parameterBag,
|
||||
TokenStorageInterface $storage
|
||||
) {
|
||||
$this->timeChoices = $parameterBag->get('chill_aside_activity.form.time_duration');
|
||||
$this->storage = $storage;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
|
@@ -44,17 +44,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
'order' => 11,
|
||||
'icons' => ['plus'],
|
||||
]);
|
||||
$menu->addChild($this->translator->trans('Phonecall'), [
|
||||
'route' => 'chill_crud_aside_activity_new',
|
||||
'routeParameters' => [
|
||||
'type' => 1,
|
||||
'duration' => 900,
|
||||
],
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 12,
|
||||
'icons' => ['plus'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,9 @@ use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
/**
|
||||
* @implements ChillEntityRenderInterface<AsideActivityCategory>
|
||||
*/
|
||||
final class CategoryRender implements ChillEntityRenderInterface
|
||||
{
|
||||
public const DEFAULT_ARGS = [
|
||||
@@ -45,9 +48,6 @@ final class CategoryRender implements ChillEntityRenderInterface
|
||||
return $parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AsideActivityCategory $asideActivityCategory
|
||||
*/
|
||||
public function renderBox($asideActivityCategory, array $options): string
|
||||
{
|
||||
$options = array_merge(self::DEFAULT_ARGS, $options);
|
||||
@@ -63,9 +63,6 @@ final class CategoryRender implements ChillEntityRenderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AsideActivityCategory $asideActivityCategory
|
||||
*/
|
||||
public function renderString($asideActivityCategory, array $options): string
|
||||
{
|
||||
$options = array_merge(self::DEFAULT_ARGS, $options);
|
||||
@@ -84,9 +81,6 @@ final class CategoryRender implements ChillEntityRenderInterface
|
||||
return implode($options[self::SEPERATOR_KEY], $titles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AsideActivityCategory $asideActivityCategory
|
||||
*/
|
||||
public function supports($asideActivityCategory, array $options): bool
|
||||
{
|
||||
return $asideActivityCategory instanceof AsideActivityCategory;
|
||||
|
@@ -21,7 +21,7 @@ Type: Type
|
||||
Invisible: Invisible
|
||||
Optional: Optionnel
|
||||
Required: Obligatoire
|
||||
Persons: Personnes
|
||||
Persons: Usagers
|
||||
Users: Utilisateurs
|
||||
Emergency: Urgent
|
||||
by: "Par "
|
||||
@@ -50,7 +50,7 @@ For agent: Pour l'utilisateur
|
||||
date: Date
|
||||
Duration: Durée
|
||||
Note: Note
|
||||
Choose the agent for whom this activity is created: Choisissez l'agent pour qui l'activité est créée
|
||||
Choose the agent for whom this activity is created: Choisissez l'agent pour qui l'échange est créé
|
||||
Choose the activity category: Choisir la catégorie
|
||||
|
||||
#Duration
|
||||
|
@@ -11,12 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\BudgetBundle\Calculator;
|
||||
|
||||
use Chill\BudgetBundle\Entity\AbstractElement;
|
||||
use Chill\BudgetBundle\Entity\Charge;
|
||||
use Chill\BudgetBundle\Entity\Resource;
|
||||
|
||||
interface CalculatorInterface
|
||||
{
|
||||
/**
|
||||
* @param AbstractElement[] $elements
|
||||
* @param array<Charge|Resource> $elements
|
||||
*/
|
||||
public function calculate(array $elements): ?CalculatorResult;
|
||||
|
||||
|
@@ -12,6 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\BudgetBundle\Calculator;
|
||||
|
||||
use Chill\BudgetBundle\Entity\AbstractElement;
|
||||
use Chill\BudgetBundle\Entity\Charge;
|
||||
use Chill\BudgetBundle\Entity\Resource;
|
||||
use OutOfBoundsException;
|
||||
|
||||
use function array_key_exists;
|
||||
@@ -21,11 +23,14 @@ use function implode;
|
||||
class CalculatorManager
|
||||
{
|
||||
/**
|
||||
* @var CalculatorInterface[]
|
||||
* @var array<string, CalculatorInterface>
|
||||
*/
|
||||
protected $calculators = [];
|
||||
private array $calculators = [];
|
||||
|
||||
protected $defaultCalculator = [];
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private array $defaultCalculator = [];
|
||||
|
||||
public function addCalculator(CalculatorInterface $calculator, bool $default)
|
||||
{
|
||||
@@ -37,7 +42,7 @@ class CalculatorManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractElement[] $elements
|
||||
* @param array<Resource|Charge> $elements
|
||||
*
|
||||
* @return CalculatorResult[]
|
||||
*/
|
||||
@@ -46,23 +51,17 @@ class CalculatorManager
|
||||
$results = [];
|
||||
|
||||
foreach ($this->defaultCalculator as $alias) {
|
||||
$calculator = $this->calculators[$alias];
|
||||
$result = $calculator->calculate($elements);
|
||||
$result = $this->getCalculator($alias)->calculate($elements);
|
||||
|
||||
if (null !== $result) {
|
||||
$results[$calculator->getAlias()] = $result;
|
||||
$results[$alias] = $result;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $alias
|
||||
*
|
||||
* @return CalculatorInterface
|
||||
*/
|
||||
public function getCalculator($alias)
|
||||
public function getCalculator(string $alias): CalculatorInterface
|
||||
{
|
||||
if (false === array_key_exists($alias, $this->calculators)) {
|
||||
throw new OutOfBoundsException("The calculator with alias '{$alias}' does "
|
||||
|
@@ -14,6 +14,8 @@ namespace Chill\BudgetBundle\Controller;
|
||||
use Chill\BudgetBundle\Calculator\CalculatorManager;
|
||||
use Chill\BudgetBundle\Entity\Charge;
|
||||
use Chill\BudgetBundle\Entity\Resource;
|
||||
use Chill\BudgetBundle\Repository\ChargeRepository;
|
||||
use Chill\BudgetBundle\Repository\ResourceRepository;
|
||||
use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
@@ -29,24 +31,20 @@ use function count;
|
||||
|
||||
class ElementController extends AbstractController
|
||||
{
|
||||
protected CalculatorManager $calculator;
|
||||
private CalculatorManager $calculator;
|
||||
|
||||
protected LoggerInterface $chillMainLogger;
|
||||
private ResourceRepository $resourceRepository;
|
||||
|
||||
protected EntityManagerInterface $em;
|
||||
|
||||
protected TranslatorInterface $translator;
|
||||
private ChargeRepository $chargeRepository;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
TranslatorInterface $translator,
|
||||
LoggerInterface $chillMainLogger,
|
||||
CalculatorManager $calculator
|
||||
CalculatorManager $calculator,
|
||||
ResourceRepository $resourceRepository,
|
||||
ChargeRepository $chargeRepository,
|
||||
) {
|
||||
$this->em = $em;
|
||||
$this->translator = $translator;
|
||||
$this->chillMainLogger = $chillMainLogger;
|
||||
$this->calculator = $calculator;
|
||||
$this->resourceRepository = $resourceRepository;
|
||||
$this->chargeRepository = $chargeRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,24 +57,10 @@ class ElementController extends AbstractController
|
||||
{
|
||||
$this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $person);
|
||||
|
||||
$charges = $this->em
|
||||
->getRepository(Charge::class)
|
||||
->findByPerson($person);
|
||||
$charges = $this->chargeRepository->findAllByEntity($person);
|
||||
$resources = $this->resourceRepository->findAllByEntity($person);
|
||||
|
||||
$ressources = $this->em
|
||||
->getRepository(Resource::class)
|
||||
->findByPerson($person);
|
||||
|
||||
$now = new DateTime('now');
|
||||
|
||||
$actualCharges = $this->em
|
||||
->getRepository(Charge::class)
|
||||
->findByEntityAndDate($person, $now);
|
||||
$actualResources = $this->em
|
||||
->getRepository(Resource::class)
|
||||
->findByEntityAndDate($person, $now);
|
||||
|
||||
$elements = array_merge($actualCharges, $actualResources);
|
||||
$elements = array_merge($charges, $resources);
|
||||
|
||||
if (count($elements) > 0) {
|
||||
$results = $this->calculator->calculateDefault($elements);
|
||||
@@ -85,7 +69,7 @@ class ElementController extends AbstractController
|
||||
return $this->render('ChillBudgetBundle:Person:index.html.twig', [
|
||||
'person' => $person,
|
||||
'charges' => $charges,
|
||||
'resources' => $ressources,
|
||||
'resources' => $resources,
|
||||
'results' => $results ?? [],
|
||||
]);
|
||||
}
|
||||
@@ -100,60 +84,19 @@ class ElementController extends AbstractController
|
||||
{
|
||||
$this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $household);
|
||||
|
||||
$charges = $this->em
|
||||
->getRepository(Charge::class)
|
||||
->findByHousehold($household);
|
||||
$charges = $this->chargeRepository->findAllByEntity($household);
|
||||
$resources = $this->resourceRepository->findAllByEntity($household);
|
||||
|
||||
$ressources = $this->em
|
||||
->getRepository(Resource::class)
|
||||
->findByHousehold($household);
|
||||
|
||||
$now = new DateTime('now');
|
||||
|
||||
$actualCharges = $this->em
|
||||
->getRepository(Charge::class)
|
||||
->findByEntityAndDate($household, $now);
|
||||
$actualResources = $this->em
|
||||
->getRepository(Resource::class)
|
||||
->findByEntityAndDate($household, $now);
|
||||
|
||||
$elements = array_merge($actualCharges, $actualResources);
|
||||
$elements = array_merge($charges, $resources);
|
||||
|
||||
if (count($elements) > 0) {
|
||||
$results = $this->calculator->calculateDefault($elements);
|
||||
}
|
||||
|
||||
// quick solution to calculate the sum, difference and amount from
|
||||
// controller. This should be done from the calculators
|
||||
// TODO replace this by calculators
|
||||
$wholeCharges = $actualCharges;
|
||||
$wholeResources = $actualResources;
|
||||
|
||||
foreach ($household->getCurrentPersons() as $person) {
|
||||
$wholeCharges = array_merge(
|
||||
$wholeCharges,
|
||||
$this->em
|
||||
->getRepository(Charge::class)
|
||||
->findByEntityAndDate($person, $now)
|
||||
);
|
||||
$wholeResources = array_merge(
|
||||
$wholeResources,
|
||||
$this->em
|
||||
->getRepository(Resource::class)
|
||||
->findByEntityAndDate($person, $now)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->render('ChillBudgetBundle:Household:index.html.twig', [
|
||||
'household' => $household,
|
||||
'charges' => $charges,
|
||||
'resources' => $ressources,
|
||||
'wholeResources' => array_filter($wholeResources, static function (Resource $r) use ($now) {
|
||||
return $r->getStartDate() <= $now && ($r->getEndDate() === null || $r->getEndDate() >= $now);
|
||||
}),
|
||||
'wholeCharges' => array_filter($wholeCharges, static function (Charge $c) use ($now) {
|
||||
return $c->getStartDate() <= $now && ($c->getEndDate() === null || $c->getEndDate() >= $now);
|
||||
}),
|
||||
'resources' => $resources,
|
||||
'results' => $results ?? [],
|
||||
]);
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ final class ChargeKindRepository implements ChargeKindRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
@@ -38,7 +38,7 @@ final class ChargeKindRepository implements ChargeKindRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findAllActive(): array
|
||||
{
|
||||
@@ -53,7 +53,7 @@ final class ChargeKindRepository implements ChargeKindRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findAllByType(string $type): array
|
||||
{
|
||||
@@ -64,7 +64,7 @@ final class ChargeKindRepository implements ChargeKindRepositoryInterface
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
|
@@ -19,25 +19,25 @@ interface ChargeKindRepositoryInterface extends ObjectRepository
|
||||
public function find($id): ?ChargeKind;
|
||||
|
||||
/**
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findAll(): array;
|
||||
|
||||
/**
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findAllActive(): array;
|
||||
|
||||
/**
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findAllByType(string $type): array;
|
||||
|
||||
/**
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
* @param int|null $limit
|
||||
* @param int|null $offset
|
||||
*
|
||||
* @return ChargeType[]
|
||||
* @return array<ChargeKind>
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
|
||||
|
@@ -11,9 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\BudgetBundle\Repository;
|
||||
|
||||
use Chill\BudgetBundle\Entity\Charge;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* ChargeRepository.
|
||||
@@ -21,24 +24,44 @@ use Doctrine\ORM\EntityRepository;
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
class ChargeRepository extends EntityRepository
|
||||
class ChargeRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Charge::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Charge[]
|
||||
*/
|
||||
public function findAllByEntity(Person|Household $entity): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('c');
|
||||
|
||||
$property = $entity instanceof Person ? 'person' : 'household';
|
||||
|
||||
$qb->where("c.{$property} = :entity")
|
||||
->setParameter('entity', $entity);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findByEntityAndDate($entity, DateTime $date, $sort = null)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('c');
|
||||
|
||||
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
||||
|
||||
$qb->where("c.{$entityStr} = :{$entityStr}")
|
||||
->andWhere('c.startDate < :date')
|
||||
->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||
$qb->where("c.{$entityStr} = :entity")
|
||||
->andWhere('c.startDate <= :date')
|
||||
->andWhere('c.endDate > :date OR c.endDate IS NULL');
|
||||
|
||||
if (null !== $sort) {
|
||||
$qb->orderBy($sort);
|
||||
}
|
||||
|
||||
$qb->setParameters([
|
||||
$entityStr => $entity,
|
||||
'entity' => $entity,
|
||||
'date' => $date,
|
||||
]);
|
||||
|
||||
|
@@ -30,7 +30,7 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
@@ -38,7 +38,7 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findAllActive(): array
|
||||
{
|
||||
@@ -52,8 +52,13 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findOneByKind(string $kind): ?ResourceKind
|
||||
{
|
||||
return $this->repository->findOneBy(['kind' => $kind]) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findAllByType(string $type): array
|
||||
{
|
||||
@@ -64,7 +69,7 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
*
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
@@ -76,11 +81,6 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function findOneByKind(string $kind): ?ResourceKind
|
||||
{
|
||||
return $this->repository->findOneBy(['kind' => $kind]);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return ResourceKind::class;
|
||||
|
@@ -19,25 +19,25 @@ interface ResourceKindRepositoryInterface extends ObjectRepository
|
||||
public function find($id): ?ResourceKind;
|
||||
|
||||
/**
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findAll(): array;
|
||||
|
||||
/**
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findAllActive(): array;
|
||||
|
||||
/**
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findAllByType(string $type): array;
|
||||
|
||||
/**
|
||||
* @param mixed|null $limit
|
||||
* @param mixed|null $offset
|
||||
* @param int|null $limit
|
||||
* @param int|null $offset
|
||||
*
|
||||
* @return ResourceType[]
|
||||
* @return list<ResourceKind>
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
||||
|
||||
|
@@ -11,9 +11,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\BudgetBundle\Repository;
|
||||
|
||||
use Chill\BudgetBundle\Entity\Resource;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTime;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* ResourceRepository.
|
||||
@@ -21,28 +25,45 @@ use Doctrine\ORM\EntityRepository;
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
class ResourceRepository extends EntityRepository
|
||||
class ResourceRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function findByEntityAndDate($entity, DateTime $date, $sort = null)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Resource::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Resource[]
|
||||
*/
|
||||
public function findAllByEntity(Person|Household $entity): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('r');
|
||||
|
||||
$property = $entity instanceof Person ? 'person' : 'household';
|
||||
|
||||
$qb->where("r.{$property} = :entity")
|
||||
->setParameter('entity', $entity);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findByEntityAndDate(Person|Household $entity, DateTime $date, $sort = null)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('c');
|
||||
|
||||
$entityStr = $entity instanceof Person ? 'person' : 'household';
|
||||
|
||||
$qb->where("c.{$entityStr} = :{$entityStr}")
|
||||
// TODO: in controller, the budget and charges asked are also for future and actual
|
||||
//->andWhere('c.startDate < :date')
|
||||
// TODO: there is a misconception here, the end date must be lower or null. startDate are never null
|
||||
//->andWhere('c.startDate < :date OR c.startDate IS NULL');
|
||||
;
|
||||
$qb->where("c.{$entityStr} = :entity")
|
||||
->andWhere('c.startDate <= :date')
|
||||
->andWhere('c.endDate > :date OR c.endDate IS NULL');
|
||||
|
||||
if (null !== $sort) {
|
||||
$qb->orderBy($sort);
|
||||
}
|
||||
|
||||
$qb->setParameters([
|
||||
$entityStr => $entity,
|
||||
//'date' => $date,
|
||||
'entity' => $entity,
|
||||
'date' => $date,
|
||||
]);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
|
@@ -17,6 +17,9 @@ use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
/**
|
||||
* @implements ChillEntityRenderInterface<ResourceKind|ChargeKind>
|
||||
*/
|
||||
final class BudgetElementTypeRender implements ChillEntityRenderInterface
|
||||
{
|
||||
private EngineInterface $engine;
|
||||
|
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\Budget;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20230328155010 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'budget elements: restore the previous type to resource/charge kind if applicable';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
WITH type_to_id AS (
|
||||
SELECT DISTINCT charge.charge_id AS id, charge.type
|
||||
FROM chill_budget.charge
|
||||
WHERE type <> ''
|
||||
)
|
||||
UPDATE chill_budget.charge_type
|
||||
SET kind = type_to_id.type
|
||||
FROM type_to_id
|
||||
WHERE type_to_id.type <> '' AND type_to_id.id = charge_type.id
|
||||
SQL);
|
||||
|
||||
$this->addSql(<<<'SQL'
|
||||
WITH type_to_id AS (
|
||||
SELECT DISTINCT resource.resource_id AS id, resource.type
|
||||
FROM chill_budget. resource
|
||||
WHERE type <> ''
|
||||
)
|
||||
UPDATE chill_budget.resource_type
|
||||
SET kind = type_to_id.type
|
||||
FROM type_to_id
|
||||
WHERE type_to_id.type <> '' AND type_to_id.id = resource_type.id
|
||||
SQL);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("UPDATE chill_budget.resource_type SET kind=md5(random()::text) WHERE kind = ''");
|
||||
$this->addSql("UPDATE chill_budget.charge_type SET kind=md5(random()::text) WHERE kind = ''");
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ End of validity period: Fin de la période de validité
|
||||
Total: Total
|
||||
Create new resource: Créer une nouvelle ressource
|
||||
Create new charge: Créer une nouvelle charge
|
||||
See person: Voir personne
|
||||
See person: Voir usagers
|
||||
|
||||
There isn't any element recorded: Aucun élément enregistré
|
||||
No resources registered: Aucune ressource enregistrée
|
||||
|
@@ -207,6 +207,7 @@ class CalendarController extends AbstractController
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
'template' => $template->getId(),
|
||||
'returnPath' => $request->getRequestUri(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -377,7 +378,9 @@ class CalendarController extends AbstractController
|
||||
$this->addFlash('success', $this->translator->trans('Success : calendar item created!'));
|
||||
|
||||
if ($form->get('save_and_upload_doc')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_new', ['id' => $entity->getId()]);
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_new', [
|
||||
'id' => $entity->getId()
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
@@ -386,6 +389,7 @@ class CalendarController extends AbstractController
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
'template' => $template->getId(),
|
||||
'returnPath' => $this->generateUrl('chill_calendar_calendar_edit', ['id' => $entity->getId()]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -526,14 +530,20 @@ class CalendarController extends AbstractController
|
||||
'comment' => $calendar->getComment()->getComment(),
|
||||
];
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'chill_activity_activity_new',
|
||||
[
|
||||
'accompanying_period_id' => $calendar->getAccompanyingPeriod()->getId(),
|
||||
'activityData' => $activityData,
|
||||
'returnPath' => $request->query->get('returnPath', null),
|
||||
]
|
||||
);
|
||||
$routeParams = [
|
||||
'activityData' => $activityData,
|
||||
'returnPath' => $request->query->get('returnPath', null),
|
||||
];
|
||||
|
||||
if ($calendar->getContext() === 'accompanying_period') {
|
||||
$routeParams['accompanying_period_id'] = $calendar->getAccompanyingPeriod()->getId();
|
||||
} elseif ($calendar->getContext() === 'person') {
|
||||
$routeParams['person_id'] = $calendar->getPerson()->getId();
|
||||
} else {
|
||||
throw new RuntimeException('context not found for this calendar');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('chill_activity_activity_new', $routeParams);
|
||||
}
|
||||
|
||||
private function buildListFilterOrder(): FilterOrderHelper
|
||||
@@ -544,21 +554,6 @@ class CalendarController extends AbstractController
|
||||
return $filterOrder->build();
|
||||
}
|
||||
|
||||
private function buildParamsToUrl(?User $user, ?AccompanyingPeriod $accompanyingPeriod): array
|
||||
{
|
||||
$params = [];
|
||||
|
||||
if (null !== $user) {
|
||||
$params['user_id'] = $user->getId();
|
||||
}
|
||||
|
||||
if (null !== $accompanyingPeriod) {
|
||||
$params['id'] = $accompanyingPeriod->getId();
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to delete a Calendar entity by id.
|
||||
*/
|
||||
|
@@ -145,6 +145,9 @@ class CalendarDocController
|
||||
$returnParams = ['id' => $calendarDoc->getCalendar()->getPerson()->getId()];
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \LogicException(sprintf("This context '%s' is not supported", $calendarDoc->getCalendar()->getContext()));
|
||||
}
|
||||
|
||||
$form = $this->formFactory->createBuilder()
|
||||
|
@@ -29,6 +29,7 @@ use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
@@ -92,6 +93,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars")
|
||||
* @Serializer\Groups({"calendar:read", "read"})
|
||||
*/
|
||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||
|
||||
@@ -507,12 +509,14 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|User[]
|
||||
* @return ReadableCollection<(int|string), User>
|
||||
* @Serializer\Groups({"calendar:read", "read"})
|
||||
*/
|
||||
public function getUsers(): Collection
|
||||
public function getUsers(): ReadableCollection
|
||||
{
|
||||
return $this->getInvites()->map(static function (Invite $i) { return $i->getUser(); });
|
||||
return $this->getInvites()->map(static function (Invite $i) {
|
||||
return $i->getUser();
|
||||
});
|
||||
}
|
||||
|
||||
public function hasCalendarRange(): bool
|
||||
@@ -597,7 +601,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
}
|
||||
|
||||
$invite = $this->invites
|
||||
->filter(static function (Invite $invite) use ($user) { return $invite->getUser() === $user; })
|
||||
->filter(static function (Invite $invite) use ($user) {
|
||||
return $invite->getUser() === $user;
|
||||
})
|
||||
->first();
|
||||
$this->removeInvite($invite);
|
||||
|
||||
|
@@ -44,14 +44,7 @@ class UrgencyAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('cal.urgent AS urgency_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
if (!empty($groupBy)) {
|
||||
$qb->addGroupBy('urgency_aggregator');
|
||||
} else {
|
||||
$qb->groupBy('urgency_aggregator');
|
||||
}
|
||||
$qb->addGroupBy('urgency_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
|
@@ -52,7 +52,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
|
||||
return 'Exports of calendar';
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if ('export_result' !== $key) {
|
||||
throw new LogicException("the key {$key} is not used by this export");
|
||||
|
@@ -49,23 +49,11 @@ class CalendarRangeFilter implements FilterInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
dump($data);
|
||||
|
||||
if ($data['hasCalendarRange']) {
|
||||
$clause = $qb->expr()->isNotNull('cal.calendarRange');
|
||||
if (null !== $data['hasCalendarRange']) {
|
||||
$qb->andWhere($qb->expr()->isNotNull('cal.calendarRange'));
|
||||
} else {
|
||||
$clause = $qb->expr()->isNull('cal.calendarRange');
|
||||
$qb->andWhere($qb->expr()->isNull('cal.calendarRange'));
|
||||
}
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -87,6 +75,8 @@ class CalendarRangeFilter implements FilterInterface
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
$choice = '';
|
||||
|
||||
foreach (self::CHOICES as $k => $v) {
|
||||
if ($v === $data['hasCalendarRange']) {
|
||||
$choice = $k;
|
||||
|
@@ -26,9 +26,6 @@ class CalendarDocEditType extends AbstractType
|
||||
->add('title', TextType::class, [
|
||||
'label' => 'chill_calendar.Document title',
|
||||
'required' => true,
|
||||
])
|
||||
->add('doc', StoredObjectType::class, [
|
||||
'label' => 'chill_calendar.Document object',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,9 @@ use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarMessage;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRemovedMessage;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Event\PostRemoveEventArgs;
|
||||
use Doctrine\ORM\Event\PostUpdateEventArgs;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
@@ -37,7 +40,7 @@ class CalendarEntityListener
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function postPersist(Calendar $calendar, LifecycleEventArgs $args): void
|
||||
public function postPersist(Calendar $calendar, PostPersistEventArgs $args): void
|
||||
{
|
||||
if (!$calendar->preventEnqueueChanges) {
|
||||
$this->messageBus->dispatch(
|
||||
@@ -50,7 +53,7 @@ class CalendarEntityListener
|
||||
}
|
||||
}
|
||||
|
||||
public function postRemove(Calendar $calendar, LifecycleEventArgs $args): void
|
||||
public function postRemove(Calendar $calendar, PostRemoveEventArgs $args): void
|
||||
{
|
||||
if (!$calendar->preventEnqueueChanges) {
|
||||
$this->messageBus->dispatch(
|
||||
@@ -62,7 +65,7 @@ class CalendarEntityListener
|
||||
}
|
||||
}
|
||||
|
||||
public function postUpdate(Calendar $calendar, LifecycleEventArgs $args): void
|
||||
public function postUpdate(Calendar $calendar, PostUpdateEventArgs $args): void
|
||||
{
|
||||
if (!$calendar->preventEnqueueChanges) {
|
||||
$this->messageBus->dispatch(
|
||||
|
@@ -22,6 +22,9 @@ use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRangeMessage;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRangeRemovedMessage;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Event\PostRemoveEventArgs;
|
||||
use Doctrine\ORM\Event\PostUpdateEventArgs;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
@@ -37,7 +40,7 @@ class CalendarRangeEntityListener
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function postPersist(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
|
||||
public function postPersist(CalendarRange $calendarRange, PostPersistEventArgs $eventArgs): void
|
||||
{
|
||||
if (!$calendarRange->preventEnqueueChanges) {
|
||||
$this->messageBus->dispatch(
|
||||
@@ -50,7 +53,7 @@ class CalendarRangeEntityListener
|
||||
}
|
||||
}
|
||||
|
||||
public function postRemove(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
|
||||
public function postRemove(CalendarRange $calendarRange, PostRemoveEventArgs $eventArgs): void
|
||||
{
|
||||
if (!$calendarRange->preventEnqueueChanges) {
|
||||
$this->messageBus->dispatch(
|
||||
@@ -62,7 +65,7 @@ class CalendarRangeEntityListener
|
||||
}
|
||||
}
|
||||
|
||||
public function postUpdate(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
|
||||
public function postUpdate(CalendarRange $calendarRange, PostUpdateEventArgs $eventArgs): void
|
||||
{
|
||||
if (!$calendarRange->preventEnqueueChanges) {
|
||||
$this->messageBus->dispatch(
|
||||
|
@@ -89,10 +89,14 @@ class CalendarToRemoteHandler implements MessageHandlerInterface
|
||||
|
||||
$newInvites = array_filter(
|
||||
array_map(
|
||||
function ($id) { return $this->inviteRepository->find($id); },
|
||||
function ($id) {
|
||||
return $this->inviteRepository->find($id);
|
||||
},
|
||||
$calendarMessage->getNewInvitesIds(),
|
||||
),
|
||||
static function (?Invite $invite) { return null !== $invite; }
|
||||
static function (?Invite $invite) {
|
||||
return null !== $invite;
|
||||
}
|
||||
);
|
||||
|
||||
$this->calendarConnector->syncCalendar(
|
||||
|
@@ -22,6 +22,7 @@ use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use LogicException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use function array_key_exists;
|
||||
|
||||
@@ -74,9 +75,18 @@ class MapCalendarToUser
|
||||
|
||||
public function getDefaultUserCalendar(string $idOrUserPrincipalName): ?array
|
||||
{
|
||||
$value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [
|
||||
'query' => ['$filter' => 'isDefaultCalendar eq true'],
|
||||
])->toArray()['value'];
|
||||
try {
|
||||
$value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [
|
||||
'query' => ['$filter' => 'isDefaultCalendar eq true'],
|
||||
])->toArray()['value'];
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
$this->logger->error('[MapCalendarToUser] Error while listing calendars for a user', [
|
||||
'http_status_code' => $e->getResponse()->getStatusCode(),
|
||||
'id_user' => $idOrUserPrincipalName,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value[0] ?? null;
|
||||
}
|
||||
|
@@ -110,11 +110,11 @@ class CalendarSyncer
|
||||
$endDate = RemoteEventConverter::convertStringDateWithoutTimezone($new['end']['dateTime']);
|
||||
|
||||
if ($startDate->getTimestamp() !== $calendar->getStartDate()->getTimestamp()) {
|
||||
$calendar->setStartDate($startDate)->setStatus(Calendar::STATUS_MOVED);
|
||||
$calendar->setStartDate($startDate);
|
||||
}
|
||||
|
||||
if ($endDate->getTimestamp() !== $calendar->getEndDate()->getTimestamp()) {
|
||||
$calendar->setEndDate($endDate)->setStatus(Calendar::STATUS_MOVED);
|
||||
$calendar->setEndDate($endDate);
|
||||
}
|
||||
|
||||
$calendar
|
||||
|
@@ -34,6 +34,7 @@ use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
@@ -64,6 +65,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
|
||||
private OnBehalfOfUserHttpClient $userHttpClient;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
CalendarRepository $calendarRepository,
|
||||
CalendarRangeRepository $calendarRangeRepository,
|
||||
@@ -74,7 +77,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
OnBehalfOfUserHttpClient $userHttpClient,
|
||||
RemoteEventConverter $remoteEventConverter,
|
||||
TranslatorInterface $translator,
|
||||
UrlGeneratorInterface $urlGenerator
|
||||
UrlGeneratorInterface $urlGenerator,
|
||||
Security $security
|
||||
) {
|
||||
$this->calendarRepository = $calendarRepository;
|
||||
$this->calendarRangeRepository = $calendarRangeRepository;
|
||||
@@ -86,6 +90,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$this->translator = $translator;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->userHttpClient = $userHttpClient;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int
|
||||
@@ -133,6 +138,24 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
|
||||
public function isReady(): bool
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
// this is not a user from chill. This is not the role of this class to
|
||||
// restrict access, so we will just say that we do not have to do anything more
|
||||
// here...
|
||||
return true;
|
||||
}
|
||||
|
||||
if (null === $this->mapCalendarToUser->getUserId($user)) {
|
||||
// this user is not mapped with remote calendar. The user will have to wait for
|
||||
// the next calendar subscription iteration
|
||||
$this->logger->debug('mark user ready for msgraph calendar as he does not have any mapping', [
|
||||
'userId' => $user->getId(),
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->tokenStorage->hasToken();
|
||||
}
|
||||
|
||||
@@ -167,7 +190,9 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
]
|
||||
)->toArray();
|
||||
|
||||
$ids = array_map(static function ($item) { return $item['id']; }, $bareEvents['value']);
|
||||
$ids = array_map(static function ($item) {
|
||||
return $item['id'];
|
||||
}, $bareEvents['value']);
|
||||
$existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids);
|
||||
$existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids);
|
||||
|
||||
|
@@ -215,7 +215,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
$qb
|
||||
->where(
|
||||
$qb->expr()->orX(
|
||||
// the calendar where the person is the main person:
|
||||
// the calendar where the person is the main person:
|
||||
$qb->expr()->eq('c.person', ':person'),
|
||||
// when the calendar is in a reachable period, and contains person
|
||||
$qb->expr()->andX(
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import {EventInput} from '@fullcalendar/vue3';
|
||||
import {EventInput} from '@fullcalendar/core';
|
||||
import {DateTime, Location, User, UserAssociatedInterface} from '../../../ChillMainBundle/Resources/public/types' ;
|
||||
import {Person} from "../../../ChillPersonBundle/Resources/public/types";
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
:picked="null !== this.$store.getters.getMainUser ? [this.$store.getters.getMainUser] : []"
|
||||
:removableIfSet="false"
|
||||
:displayPicked="false"
|
||||
:suggested="this.suggestedUsers"
|
||||
@addNewEntity="setMainUser"
|
||||
></pick-entity>
|
||||
</div>
|
||||
@@ -116,7 +117,6 @@
|
||||
<script>
|
||||
import ConcernedGroups from 'ChillActivityAssets/vuejs/Activity/components/ConcernedGroups.vue';
|
||||
import Location from 'ChillActivityAssets/vuejs/Activity/components/Location.vue';
|
||||
import '@fullcalendar/core/vdom'; // solves problem with Vite
|
||||
import frLocale from '@fullcalendar/core/locales/fr';
|
||||
import FullCalendar from '@fullcalendar/vue3';
|
||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||
@@ -144,6 +144,7 @@ export default {
|
||||
slotMinTime: '09:00:00',
|
||||
slotMaxTime: '18:00:00',
|
||||
hideWeekEnds: true,
|
||||
previousUser: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -189,11 +190,23 @@ export default {
|
||||
users.push(this.$store.getters.getUserDataById(id).user);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
},
|
||||
suggestedUsers() {
|
||||
const suggested = [];
|
||||
|
||||
this.$data.previousUser.forEach(u => {
|
||||
if (u.id !== this.$store.getters.getMainUser.id) {
|
||||
suggested.push(u)
|
||||
}
|
||||
});
|
||||
|
||||
return suggested;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
setMainUser(user) {
|
||||
console.log('setMainUser APP', user);
|
||||
setMainUser({entity}) {
|
||||
const user = entity;
|
||||
console.log('setMainUser APP', entity);
|
||||
|
||||
if (user.id !== this.$store.getters.getMainUser && (
|
||||
this.$store.state.activity.calendarRange !== null
|
||||
@@ -206,6 +219,14 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
// add the previous user, if any, in the previous user list (in use for suggestion)
|
||||
if (null !== this.$store.getters.getMainUser) {
|
||||
const suggestedUids = new Set(this.$data.previousUser.map(u => u.id));
|
||||
if (!suggestedUids.has(this.$store.getters.getMainUser.id)){
|
||||
this.$data.previousUser.push(this.$store.getters.getMainUser);
|
||||
}
|
||||
}
|
||||
|
||||
this.$store.dispatch('setMainUser', user);
|
||||
this.$store.commit('showUserOnCalendar', {user, ranges: true, remotes: true});
|
||||
},
|
||||
|
@@ -202,6 +202,8 @@ export default {
|
||||
|
||||
return dispatch('associateCalendarToRange', { range: null }).then(() => {
|
||||
commit('setMainUser', mainUser);
|
||||
|
||||
return dispatch('fetchCalendarEvents');
|
||||
});
|
||||
},
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import {ISOToDatetime} from '../../../../../../ChillMainBundle/Resources/public/
|
||||
import {DateTime, User} from '../../../../../../ChillMainBundle/Resources/public/types';
|
||||
import {CalendarLight, CalendarRange, CalendarRemote} from '../../../types';
|
||||
import type {EventInputCalendarRange} from '../../../types';
|
||||
import {EventInput} from '@fullcalendar/vue3';
|
||||
import {EventInput} from '@fullcalendar/core';
|
||||
|
||||
export interface UserData {
|
||||
user: User,
|
||||
@@ -54,7 +54,7 @@ export const mapEntity = (entity: EventInput): EventInput => {
|
||||
|
||||
export const createUserData = (user: User, colorIndex: number): UserData => {
|
||||
const colorId = colorIndex % COLORS.length;
|
||||
console.log('colorId', colorId);
|
||||
|
||||
return {
|
||||
user: user,
|
||||
calendarRanges: [],
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<label class="form-label">Lieu des plages de disponibilités créées</label>
|
||||
<label class="form-label">{{ $t('created_availabilities') }}</label>
|
||||
<vue-multiselect
|
||||
v-model="pickedLocation"
|
||||
:options="locations"
|
||||
@@ -116,13 +116,11 @@
|
||||
import type {
|
||||
CalendarOptions,
|
||||
DatesSetArg,
|
||||
EventInput,
|
||||
EventInstance
|
||||
} from '@fullcalendar/vue3';
|
||||
EventInput
|
||||
} from '@fullcalendar/core';
|
||||
import {reactive, computed, ref} from "vue";
|
||||
import {useStore} from "vuex";
|
||||
import {key} from './store';
|
||||
import '@fullcalendar/core/vdom'; // solves problem with Vite
|
||||
import FullCalendar from '@fullcalendar/vue3';
|
||||
import frLocale from '@fullcalendar/core/locales/fr';
|
||||
import interactionPlugin, {DropArg, EventResizeDoneArg} from "@fullcalendar/interaction";
|
||||
|
@@ -26,7 +26,7 @@
|
||||
<script setup lang="ts">
|
||||
import Modal from "../../../../../../ChillMainBundle/Resources/public/vuejs/_components/Modal.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import {EventApi} from "@fullcalendar/vue3";
|
||||
import {EventApi} from "@fullcalendar/core";
|
||||
import {useStore} from "vuex";
|
||||
import {key} from "../store";
|
||||
import {Location} from "../../../../../../ChillMainBundle/Resources/public/types";
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const appMessages = {
|
||||
fr: {
|
||||
created_availabilities: "Lieu des plages de disponibilités créées",
|
||||
edit_your_calendar_range: "Planifiez vos plages de disponibilités",
|
||||
show_my_calendar: "Afficher mon calendrier",
|
||||
show_weekends: "Afficher les week-ends",
|
||||
|
@@ -2,7 +2,7 @@ import {State} from './../index';
|
||||
import {ActionContext, Module} from 'vuex';
|
||||
import {CalendarLight} from '../../../../types';
|
||||
import {fetchCalendarLocalForUser} from '../../../Calendar/api';
|
||||
import {EventInput} from '@fullcalendar/vue3';
|
||||
import {EventInput} from '@fullcalendar/core';
|
||||
import {localsToFullCalendarEvent} from "../../../Calendar/store/utils";
|
||||
import {TransportExceptionInterface} from "../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods";
|
||||
import {COLORS} from "../../../Calendar/const";
|
||||
|
@@ -4,7 +4,7 @@ import {CalendarRange, CalendarRangeCreate, CalendarRangeEdit, isEventInputCalen
|
||||
import {Location} from "../../../../../../../ChillMainBundle/Resources/public/types";
|
||||
import {fetchCalendarRangeForUser} from '../../../Calendar/api';
|
||||
import {calendarRangeToFullCalendarEvent} from '../../../Calendar/store/utils';
|
||||
import {EventInput} from '@fullcalendar/vue3';
|
||||
import {EventInput} from '@fullcalendar/core';
|
||||
import {makeFetch} from "../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods";
|
||||
import {
|
||||
datetimeToISO,
|
||||
|
@@ -2,7 +2,7 @@ import {State} from './../index';
|
||||
import {ActionContext, Module} from 'vuex';
|
||||
import {CalendarRemote} from '../../../../types';
|
||||
import {fetchCalendarRemoteForUser} from '../../../Calendar/api';
|
||||
import {EventInput, EventSource} from '@fullcalendar/vue3';
|
||||
import {EventInput} from '@fullcalendar/core';
|
||||
import {remoteToFullCalendarEvent} from "../../../Calendar/store/utils";
|
||||
import {TransportExceptionInterface} from "../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods";
|
||||
import {COLORS} from "../../../Calendar/const";
|
||||
|
@@ -20,15 +20,24 @@
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
{{ d.storedObject.title }}
|
||||
{% if d.dateTimeVersion < d.calendar.dateTimeVersion %}
|
||||
</div>
|
||||
{% if d.dateTimeVersion < d.calendar.dateTimeVersion %}
|
||||
<div class="col text-start">
|
||||
<span class="badge bg-danger">{{ 'chill_calendar.Document outdated'|trans }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-md-auto text-center">
|
||||
{{ mm.mimeIcon(d.storedObject.type) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col col-lg-4 text-end">
|
||||
{{ d.storedObject|chill_document_button_group(d.storedObject.title, is_granted('CHILL_CALENDAR_DOC_EDIT', d), {'small': true}) }}
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
{{ d.storedObject|chill_document_button_group(d.storedObject.title, is_granted('CHILL_CALENDAR_DOC_EDIT', d), {'small': true}) }}
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendardoc_edit', {id: d.id}) }}" class="btn btn-sm btn-edit"></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ chill_path_add_return_path('chill_calendar_calendardoc_delete', {id: d.id}) }}" class="btn btn-sm btn-delete"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
@@ -110,7 +110,46 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item-row">
|
||||
{% if calendar.activity is not null %}
|
||||
<div class="item-row separator">
|
||||
<div class="item-col">
|
||||
<div class="wrap-list">
|
||||
<div class="wl-row">
|
||||
<div class="wl-col title"><h3>{{ 'Activity'|trans }}</h3></div>
|
||||
<div class="wl-col list activity-linked">
|
||||
<h2 class="badge-title">
|
||||
<span class="title_label"></span>
|
||||
<span class="title_action">
|
||||
{{ calendar.activity.type.name | localize_translatable_string }}
|
||||
|
||||
{% if calendar.activity.emergency %}
|
||||
<span class="badge bg-danger rounded-pill fs-6 float-end">{{ 'Emergency'|trans|upper }}</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</h2>
|
||||
|
||||
<ul class="record_actions">
|
||||
<li class="cancel">
|
||||
<span class="createdBy">
|
||||
{{ 'Created by'|trans }}
|
||||
<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) %}
|
||||
<li>
|
||||
<a href="{{ chill_path_add_return_path('chill_activity_activity_show', {'id': calendar.activity.id}) }}" class="btn btn-sm btn-show" ></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="item-row separator">
|
||||
<ul class="record_actions">
|
||||
{% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', calendar) %}
|
||||
{% if templates|length == 0 %}
|
||||
@@ -147,7 +186,12 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if accompanyingCourse is defined and is_granted('CHILL_ACTIVITY_CREATE', accompanyingCourse) and calendar.activity is null %}
|
||||
{% if calendar.activity is null and (
|
||||
(calendar.context == 'accompanying_period' and is_granted('CHILL_ACTIVITY_CREATE', calendar.accompanyingPeriod))
|
||||
or
|
||||
(calendar.context == 'person' and is_granted('CHILL_ACTIVITY_CREATE', calendar.person))
|
||||
)
|
||||
%}
|
||||
<li>
|
||||
<a class="btn btn-create"
|
||||
href="{{ chill_path_add_return_path('chill_calendar_calendar_to_activity', { 'id': calendar.id }) }}">
|
||||
|
@@ -9,13 +9,13 @@
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('mod_answer') }}
|
||||
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||
{{ encore_entry_script_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_link_tags('mod_answer') }}
|
||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||
{{ encore_entry_link_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@@ -24,7 +24,6 @@
|
||||
{{ form_start(form) }}
|
||||
|
||||
{{ form_row(form.title) }}
|
||||
{{ form_row(form.doc) }}
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
|
@@ -23,7 +23,6 @@
|
||||
{{ form_start(form) }}
|
||||
|
||||
{{ form_row(form.title) }}
|
||||
{{ form_row(form.doc) }}
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
|
@@ -28,7 +28,7 @@
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="cancel">
|
||||
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_calendar_calendar_list_by_accompanying_period', {'id': accompanyingCourse.id }) }}">{{ 'Cancel'|trans|chill_return_path_label }}</a>
|
||||
<a class="btn btn-cancel" href="{{ chill_return_path_or('chill_calendar_calendar_edit', {'id': calendar_doc.calendar.id }) }}">{{ 'Cancel'|trans|chill_return_path_label }}</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
@@ -31,6 +31,8 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
*/
|
||||
final class CalendarContext implements CalendarContextInterface
|
||||
{
|
||||
private BaseContextData $baseContextData;
|
||||
@@ -148,7 +150,7 @@ final class CalendarContext implements CalendarContextInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData
|
||||
* param array{mainPerson?: Person, thirdParty?: ThirdParty, title: string} $contextGenerationData
|
||||
* @param mixed $entity
|
||||
*/
|
||||
public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array
|
||||
@@ -286,7 +288,7 @@ final class CalendarContext implements CalendarContextInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{askMainPerson: bool, mainPersonLabel: ?string, askThirdParty: bool, thirdPartyLabel: ?string, trackDateTime: bool} $options
|
||||
* return array{askMainPerson: bool, mainPersonLabel: ?string, askThirdParty: bool, thirdPartyLabel: ?string, trackDateTime: bool} $options
|
||||
*/
|
||||
private function getOptions(DocGeneratorTemplate $template): array
|
||||
{
|
||||
|
@@ -18,6 +18,9 @@ use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @template-extends DocGeneratorContextWithPublicFormInterface<Calendar>
|
||||
*/
|
||||
interface CalendarContextInterface extends DocGeneratorContextWithPublicFormInterface, DocGeneratorContextWithAdminFormInterface
|
||||
{
|
||||
public function adminFormReverseTransform(array $data): array;
|
||||
@@ -26,23 +29,14 @@ interface CalendarContextInterface extends DocGeneratorContextWithPublicFormInte
|
||||
|
||||
public function buildAdminForm(FormBuilderInterface $builder): void;
|
||||
|
||||
/**
|
||||
* @param Calendar $entity
|
||||
*/
|
||||
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void;
|
||||
|
||||
/**
|
||||
* @param Calendar $entity
|
||||
*/
|
||||
public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array;
|
||||
|
||||
public function getDescription(): string;
|
||||
|
||||
public function getEntityClass(): string;
|
||||
|
||||
/**
|
||||
* @param Calendar $entity
|
||||
*/
|
||||
public function getFormData(DocGeneratorTemplate $template, $entity): array;
|
||||
|
||||
public static function getKey(): string;
|
||||
@@ -51,17 +45,11 @@ interface CalendarContextInterface extends DocGeneratorContextWithPublicFormInte
|
||||
|
||||
public function hasAdminForm(): bool;
|
||||
|
||||
/**
|
||||
* @param Calendar $entity
|
||||
*/
|
||||
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool;
|
||||
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array;
|
||||
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array;
|
||||
|
||||
/**
|
||||
* @param Calendar $entity
|
||||
*/
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void;
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
];
|
||||
|
||||
$calendar = new Calendar();
|
||||
$calendar->setMainUser(new class() extends User {
|
||||
$calendar->setMainUser(new class () extends User {
|
||||
public function getId()
|
||||
{
|
||||
return '1';
|
||||
@@ -114,8 +114,12 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
$this->assertEquals(8, $calendar->getCalendarRange()->getId());
|
||||
$this->assertEquals(9, $calendar->getLocation()->getId());
|
||||
$this->assertEquals(true, $calendar->getSendSMS());
|
||||
$this->assertContains(2, $calendar->getUsers()->map(static function (User $u) { return $u->getId(); }));
|
||||
$this->assertContains(3, $calendar->getUsers()->map(static function (User $u) { return $u->getId(); }));
|
||||
$this->assertContains(2, $calendar->getUsers()->map(static function (User $u) {
|
||||
return $u->getId();
|
||||
}));
|
||||
$this->assertContains(3, $calendar->getUsers()->map(static function (User $u) {
|
||||
return $u->getId();
|
||||
}));
|
||||
}
|
||||
|
||||
protected function getExtensions()
|
||||
@@ -147,7 +151,9 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
->will(static function ($args) {
|
||||
return implode(
|
||||
',',
|
||||
array_map(static function ($p) { return $p->getId(); }, $args[0])
|
||||
array_map(static function ($p) {
|
||||
return $p->getId();
|
||||
}, $args[0])
|
||||
);
|
||||
});
|
||||
$transformer->transform(Argument::exact(null))
|
||||
@@ -156,7 +162,9 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
->will(static function ($args) {
|
||||
return implode(
|
||||
',',
|
||||
array_map(static function ($p) { return $p->getId(); }, $args[0]->toArray())
|
||||
array_map(static function ($p) {
|
||||
return $p->getId();
|
||||
}, $args[0]->toArray())
|
||||
);
|
||||
});
|
||||
$transformer->reverseTransform(Argument::type('string'))
|
||||
|
@@ -132,8 +132,8 @@ docgen:
|
||||
Base context for calendar: 'Rendez-vous: contexte de base'
|
||||
A base context for generating document on calendar: Contexte pour générer des documents à partir des rendez-vous
|
||||
Track changes on datetime and warn user if date time is updated after the doc generation: Suivre les changements sur le document et prévenir les utilisateurs que la date et l'heure ont été modifiée après la génération du document
|
||||
Ask main person: Demander de choisir une personne parmi les participants aux rendez-vous
|
||||
Main person label: Label pour choisir la personne
|
||||
Ask main person: Demander de choisir un usager parmi les participants aux rendez-vous
|
||||
Main person label: Label pour choisir l'usager
|
||||
Ask third party: Demander de choisir un tiers parmi les participants aux rendez-vous
|
||||
Third party label: Label pour choisir le tiers
|
||||
Destinee: Destinataire
|
||||
|
@@ -1,5 +1,5 @@
|
||||
calendar:
|
||||
At least {{ limit }} person is required.: Au moins {{ limit }} personne doit être associée à ce rendez-vous
|
||||
At least {{ limit }} person is required.: Au moins {{ limit }} usager doit être associée à ce rendez-vous
|
||||
An end date is required: Indiquez une date et heure de fin
|
||||
A start date is required: Indiquez une date et heure de début
|
||||
A location is required: Indiquez un lieu
|
||||
|
@@ -16,15 +16,17 @@ use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
|
||||
/**
|
||||
* Interface for context for document generation.
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
interface DocGeneratorContextInterface
|
||||
{
|
||||
/**
|
||||
* Get the data that will be injected to the generated document.
|
||||
*
|
||||
* @param mixed $entity
|
||||
* @param T $entity
|
||||
*/
|
||||
public function getData(DocGeneratorTemplate $template, $entity, array $contextGenerationData = []): array;
|
||||
public function getData(DocGeneratorTemplate $template, object $entity, array $contextGenerationData = []): array;
|
||||
|
||||
public function getDescription(): string;
|
||||
|
||||
@@ -34,5 +36,8 @@ interface DocGeneratorContextInterface
|
||||
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* @param T $entity
|
||||
*/
|
||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void;
|
||||
}
|
||||
|
@@ -14,34 +14,43 @@ namespace Chill\DocGeneratorBundle\Context;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
interface DocGeneratorContextWithPublicFormInterface extends DocGeneratorContextInterface
|
||||
{
|
||||
/**
|
||||
* Generate the form that display.
|
||||
*
|
||||
* @param mixed $entity
|
||||
* @param T $entity
|
||||
*/
|
||||
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void;
|
||||
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, mixed $entity): void;
|
||||
|
||||
/**
|
||||
* Fill the form with initial data
|
||||
*
|
||||
* @param T $entity
|
||||
*/
|
||||
public function getFormData(DocGeneratorTemplate $template, $entity): array;
|
||||
public function getFormData(DocGeneratorTemplate $template, mixed $entity): array;
|
||||
|
||||
/**
|
||||
* has form.
|
||||
*
|
||||
* @param mixed $entity
|
||||
* @param T $entity
|
||||
*/
|
||||
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool;
|
||||
public function hasPublicForm(DocGeneratorTemplate $template, mixed $entity): bool;
|
||||
|
||||
/**
|
||||
* Transform the data from the form into serializable data, storable into messenger's message
|
||||
*
|
||||
* @param T $entity
|
||||
*/
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, $entity, array $data): array;
|
||||
public function contextGenerationDataNormalize(DocGeneratorTemplate $template, mixed $entity, array $data): array;
|
||||
|
||||
/**
|
||||
* Reverse the data from the messenger's message into data usable for doc's generation
|
||||
*
|
||||
* @param T $entity
|
||||
*/
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, $entity, array $data): array;
|
||||
public function contextGenerationDataDenormalize(DocGeneratorTemplate $template, mixed $entity, array $data): array;
|
||||
}
|
||||
|
@@ -258,7 +258,8 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
return $this->render('@ChillDocGenerator/Generator/debug_value.html.twig', [
|
||||
'datas' => json_encode($context->getData($template, $entity, $contextGenerationData), JSON_PRETTY_PRINT),
|
||||
]);
|
||||
} elseif ($isTest) {
|
||||
}
|
||||
if ($isTest) {
|
||||
$generated = $this->generator->generateDocFromTemplate(
|
||||
$template,
|
||||
$entityId,
|
||||
@@ -284,7 +285,7 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
// we prepare the object to store the document
|
||||
$storedObject = (new StoredObject())
|
||||
->setStatus(StoredObject::STATUS_PENDING)
|
||||
;
|
||||
;
|
||||
|
||||
$this->entityManager->persist($storedObject);
|
||||
|
||||
|
@@ -61,7 +61,7 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
->setFilename($template['file']['filename'])
|
||||
->setKeyInfos(json_decode($template['file']['key'], true))
|
||||
->setIv(json_decode($template['file']['iv'], true))
|
||||
->setCreationDate(new DateTime('today'))
|
||||
->setCreatedAt(new DateTime('today'))
|
||||
->setType($template['file']['type']);
|
||||
|
||||
$manager->persist($newStoredObj);
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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\Service\Generator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\ContextManagerInterface;
|
||||
@@ -74,7 +83,7 @@ class Generator implements GeneratorInterface
|
||||
$entity = $this
|
||||
->entityManager
|
||||
->find($context->getEntityClass(), $entityId)
|
||||
;
|
||||
;
|
||||
|
||||
if (null === $entity) {
|
||||
throw new RelatedEntityNotFoundException($template->getEntity(), $entityId);
|
||||
@@ -82,10 +91,10 @@ class Generator implements GeneratorInterface
|
||||
|
||||
$contextGenerationDataNormalized = array_merge(
|
||||
$contextGenerationDataNormalized,
|
||||
['creator' => $creator],
|
||||
$context instanceof DocGeneratorContextWithPublicFormInterface ?
|
||||
$context->contextGenerationDataDenormalize($template, $entity, $contextGenerationDataNormalized)
|
||||
: []
|
||||
['creator' => $creator],
|
||||
$context instanceof DocGeneratorContextWithPublicFormInterface ?
|
||||
$context->contextGenerationDataDenormalize($template, $entity, $contextGenerationDataNormalized)
|
||||
: []
|
||||
);
|
||||
|
||||
$data = $context->getData($template, $entity, $contextGenerationDataNormalized);
|
||||
@@ -116,7 +125,7 @@ class Generator implements GeneratorInterface
|
||||
throw new GeneratorException($e->getErrors(), $e);
|
||||
}
|
||||
|
||||
if ($isTest) {
|
||||
if (true === $isTest) {
|
||||
$this->logger->info(self::LOG_PREFIX.'Finished generation of a document', [
|
||||
'is_test' => true,
|
||||
'entity_id' => $entityId,
|
||||
@@ -125,12 +134,12 @@ class Generator implements GeneratorInterface
|
||||
return $generatedResource;
|
||||
}
|
||||
|
||||
/** @var StoredObject $storedObject */
|
||||
/** @var StoredObject $destinationStoredObject */
|
||||
$destinationStoredObject
|
||||
->setType($template->getFile()->getType())
|
||||
->setFilename(sprintf('%s_odt', uniqid('doc_', true)))
|
||||
->setStatus(StoredObject::STATUS_READY)
|
||||
;
|
||||
;
|
||||
|
||||
$this->storedObjectManager->write($destinationStoredObject, $generatedResource);
|
||||
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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\Service\Generator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
|
@@ -15,7 +15,7 @@ use RuntimeException;
|
||||
|
||||
class RelatedEntityNotFoundException extends RuntimeException
|
||||
{
|
||||
public function __construct(string $relatedEntityClass, int $relatedEntityId, ?Throwable $previous = null)
|
||||
public function __construct(string $relatedEntityClass, int $relatedEntityId, ?\Throwable $previous = null)
|
||||
{
|
||||
parent::__construct(
|
||||
sprintf('Related entity not found: %s, %s', $relatedEntityClass, $relatedEntityId),
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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\Service\Messenger;
|
||||
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
@@ -31,7 +40,7 @@ final class OnGenerationFails implements EventSubscriberInterface
|
||||
|
||||
private UserRepositoryInterface $userRepository;
|
||||
|
||||
const LOG_PREFIX = '[docgen failed] ';
|
||||
public const LOG_PREFIX = '[docgen failed] ';
|
||||
|
||||
/**
|
||||
* @param DocGeneratorTemplateRepository $docGeneratorTemplateRepository
|
||||
@@ -108,10 +117,7 @@ final class OnGenerationFails implements EventSubscriberInterface
|
||||
|
||||
private function warnCreator(RequestGenerationMessage $message, WorkerMessageFailedEvent $event): void
|
||||
{
|
||||
if (null === $creatorId = $message->getCreatorId()) {
|
||||
$this->logger->info(self::LOG_PREFIX.'creator id is null');
|
||||
return;
|
||||
}
|
||||
$creatorId = $message->getCreatorId();
|
||||
|
||||
if (null === $creator = $this->userRepository->find($creatorId)) {
|
||||
$this->logger->error(self::LOG_PREFIX.'Creator not found with given id', ['creator_id', $creatorId]);
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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\Service\Messenger;
|
||||
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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\Service\Messenger;
|
||||
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
@@ -8,17 +17,17 @@ use Chill\MainBundle\Entity\User;
|
||||
|
||||
class RequestGenerationMessage
|
||||
{
|
||||
private int $creatorId;
|
||||
private int $creatorId;
|
||||
|
||||
private int $templateId;
|
||||
private int $templateId;
|
||||
|
||||
private int $entityId;
|
||||
private int $entityId;
|
||||
|
||||
private int $destinationStoredObjectId;
|
||||
private int $destinationStoredObjectId;
|
||||
|
||||
private array $contextGenerationData;
|
||||
private array $contextGenerationData;
|
||||
|
||||
private \DateTimeImmutable $createdAt;
|
||||
private \DateTimeImmutable $createdAt;
|
||||
|
||||
public function __construct(
|
||||
User $creator,
|
||||
|
@@ -2,6 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\DocGenerator;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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\tests\Service\Context\Generator;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\ContextManagerInterface;
|
||||
@@ -17,6 +26,10 @@ use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class GeneratorTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
@@ -29,7 +42,7 @@ class GeneratorTest extends TestCase
|
||||
$reflection = new \ReflectionClass($destinationStoredObject);
|
||||
$reflection->getProperty('id')->setAccessible(true);
|
||||
$reflection->getProperty('id')->setValue($destinationStoredObject, 1);
|
||||
$entity = new class {};
|
||||
$entity = new class () {};
|
||||
$data = [];
|
||||
|
||||
$context = $this->prophesize(DocGeneratorContextInterface::class);
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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;
|
||||
|
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\HasCentersInterface;
|
||||
use Chill\MainBundle\Entity\HasScopesInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -19,7 +20,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table("chill_doc.accompanyingcourse_document")
|
||||
*/
|
||||
class AccompanyingCourseDocument extends Document implements HasScopesInterface
|
||||
class AccompanyingCourseDocument extends Document implements HasScopesInterface, HasCentersInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||
@@ -27,6 +28,11 @@ class AccompanyingCourseDocument extends Document implements HasScopesInterface
|
||||
*/
|
||||
private ?AccompanyingPeriod $course = null;
|
||||
|
||||
public function getCenters(): ?iterable
|
||||
{
|
||||
return $this->course->getCenters();
|
||||
}
|
||||
|
||||
public function getCourse(): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->course;
|
||||
|
@@ -35,12 +35,11 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
*/
|
||||
class StoredObject implements AsyncFileInterface, Document, TrackCreationInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
public const STATUS_READY = "ready";
|
||||
public const STATUS_PENDING = "pending";
|
||||
public const STATUS_FAILURE = "failure";
|
||||
|
||||
use TrackCreationTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", name="datas")
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
|
@@ -51,16 +51,9 @@
|
||||
</div>
|
||||
<ul class="item-col record_actions flex-shrink-1">
|
||||
{% if document.course is defined %}
|
||||
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %}
|
||||
<li class="delete">
|
||||
<a href="{{ chill_return_path_or('chill_docstore_accompanying_course_document_delete', {'course': accompanyingCourse.id, 'id': document.id}) }}" class="btn btn-delete"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
|
||||
<li>
|
||||
<a href="{{ path('accompanying_course_document_edit', {'course': accompanyingCourse.id, 'id': document.id }) }}" class="btn btn-update"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
{{ chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) }}
|
||||
</li>
|
||||
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
|
||||
<li>
|
||||
{{ document.object|chill_document_button_group(document.title, is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document)) }}
|
||||
@@ -69,20 +62,17 @@
|
||||
<a href="{{ chill_path_add_return_path('accompanying_course_document_show', {'course': accompanyingCourse.id, 'id': document.id}) }}" class="btn btn-show"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
{{ chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) }}
|
||||
</li>
|
||||
{% else %}
|
||||
{% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %}
|
||||
<li class="delete">
|
||||
<a href="{{ chill_return_path_or('chill_docstore_person_document_delete', {'person': person.id, 'id': document.id}) }}" class="btn btn-delete"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %}
|
||||
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
|
||||
<li>
|
||||
<a href="{{ path('person_document_edit', {'person': person.id, 'id': document.id}) }}" class="btn btn-update"></a>
|
||||
<a href="{{ path('accompanying_course_document_edit', {'course': accompanyingCourse.id, 'id': document.id }) }}" class="btn btn-update"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %}
|
||||
<li class="delete">
|
||||
<a href="{{ chill_return_path_or('chill_docstore_accompanying_course_document_delete', {'course': accompanyingCourse.id, 'id': document.id}) }}" class="btn btn-delete"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if is_granted('CHILL_PERSON_DOCUMENT_SEE_DETAILS', document) %}
|
||||
<li>
|
||||
{{ document.object|chill_document_button_group(document.title, is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document)) }}
|
||||
@@ -91,6 +81,16 @@
|
||||
<a href="{{ path('person_document_show', {'person': person.id, 'id': document.id}) }}" class="btn btn-show"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %}
|
||||
<li>
|
||||
<a href="{{ path('person_document_edit', {'person': person.id, 'id': document.id}) }}" class="btn btn-update"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %}
|
||||
<li class="delete">
|
||||
<a href="{{ chill_return_path_or('chill_docstore_person_document_delete', {'person': person.id, 'id': document.id}) }}" class="btn btn-delete"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
|
@@ -78,12 +78,12 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
return $this->voterHelper->supports($attribute, $subject);
|
||||
}
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
if (!$token->getUser() instanceof User) {
|
||||
return false;
|
||||
|
@@ -95,6 +95,16 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array
|
||||
{
|
||||
$suggestedUsers = $entityWorkflow->getUsersInvolved();
|
||||
|
||||
$referrer = $this->getRelatedEntity($entityWorkflow)->getCourse()->getUser();
|
||||
$suggestedUsers[spl_object_hash($referrer)] = $referrer;
|
||||
|
||||
return $suggestedUsers;
|
||||
}
|
||||
|
||||
public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string
|
||||
{
|
||||
return '@ChillDocStore/AccompanyingCourseDocument/_workflow.html.twig';
|
||||
|
@@ -2,6 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\DocStore;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
@@ -197,7 +197,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return in_array($offset, [
|
||||
'person', 'role', 'status', 'event',
|
||||
@@ -207,30 +207,21 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
/**
|
||||
* @param mixed $offset
|
||||
*
|
||||
* @return Event|mixed|Person|Role|Status
|
||||
* @return Event|Person|Role|Status
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
public function offsetGet($offset): mixed
|
||||
{
|
||||
switch ($offset) {
|
||||
case 'person':
|
||||
return $this->getPerson();
|
||||
|
||||
break;
|
||||
|
||||
case 'role':
|
||||
return $this->getRole();
|
||||
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
return $this->getStatus();
|
||||
|
||||
break;
|
||||
|
||||
case 'event':
|
||||
return $this->getEvent();
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new \LogicException("this offset does not exists : " . $offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,28 +229,28 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
* @param mixed $offset
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Participation|void
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
public function offsetSet($offset, $value): void
|
||||
{
|
||||
switch ($offset) {
|
||||
case 'person':
|
||||
return $this->setPerson($value);
|
||||
$this->setPerson($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'role':
|
||||
return $this->setRole($value);
|
||||
$this->setRole($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
return $this->setStatus($value);
|
||||
$this->setStatus($value);
|
||||
|
||||
break;
|
||||
|
||||
case 'event':
|
||||
return $this->setEvent($value);
|
||||
$this->setEvent($value);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -268,7 +259,7 @@ class Participation implements ArrayAccess, HasCenterInterface, HasScopeInterfac
|
||||
/**
|
||||
* @param mixed $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
public function offsetUnset($offset): void
|
||||
{
|
||||
$this->offsetSet($offset, null);
|
||||
}
|
||||
|
@@ -113,27 +113,23 @@ class EventSearch extends AbstractSearch
|
||||
]
|
||||
);
|
||||
}
|
||||
// format is "json"
|
||||
$results = [];
|
||||
$search = $this->search($terms, $start, $limit, $options);
|
||||
|
||||
if ('json' === $format) {
|
||||
$results = [];
|
||||
$search = $this->search($terms, $start, $limit, $options);
|
||||
|
||||
foreach ($search as $item) {
|
||||
$results[] = [
|
||||
'id' => $item->getId(),
|
||||
'text' => $item->getDate()->format('d/m/Y, H:i') . ' → ' .
|
||||
// $item->getType()->getName()['fr'] . ': ' . // display the type of event
|
||||
$item->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'results' => $results,
|
||||
'pagination' => [
|
||||
'more' => $paginator->hasNextPage(),
|
||||
],
|
||||
foreach ($search as $item) {
|
||||
$results[] = [
|
||||
'id' => $item->getId(),
|
||||
'text' => $item->getDate()->format('d/m/Y, H:i') . ' → ' .
|
||||
// $item->getType()->getName()['fr'] . ': ' . // display the type of event
|
||||
$item->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'results' => $results,
|
||||
'more' => $paginator->hasNextPage(),
|
||||
];
|
||||
}
|
||||
|
||||
public function supports($domain, $format)
|
||||
@@ -174,8 +170,8 @@ class EventSearch extends AbstractSearch
|
||||
}
|
||||
|
||||
if (
|
||||
(isset($terms['name']) || isset($terms['_default']))
|
||||
&& (!empty($terms['name']) || !empty($terms['_default']))
|
||||
(isset($terms['name']) || isset($terms['_default']))
|
||||
&& (!empty($terms['name']) || !empty($terms['_default']))
|
||||
) {
|
||||
// the form with name:"xyz" has precedence
|
||||
$name = $terms['name'] ?? $terms['_default'];
|
||||
|
@@ -34,7 +34,7 @@ Edit the participation: Modifier la participation
|
||||
Participation Edit: Modifier une participation
|
||||
Add a participation: Ajouter un participant
|
||||
Participation creation: Ajouter une participation
|
||||
Associated person: Personne associée
|
||||
Associated person: Usager associé
|
||||
Associated event: Événement associé
|
||||
Back to the event: Retour à l'événement
|
||||
The participation was created: La participation a été créée
|
||||
@@ -108,4 +108,4 @@ csv: csv
|
||||
|
||||
Create a new role: Créer un nouveau rôle
|
||||
Create a new type: Créer un nouveau type
|
||||
Create a new status: Créer un nouveau statut
|
||||
Create a new status: Créer un nouveau statut
|
||||
|
@@ -34,6 +34,29 @@ abstract class AbstractCRUDController extends AbstractController
|
||||
*/
|
||||
protected array $crudConfig = [];
|
||||
|
||||
/**
|
||||
* get the role given from the config.
|
||||
*
|
||||
* @param mixed $entity
|
||||
* @param mixed $_format
|
||||
*/
|
||||
protected function getRoleFor(string $action, Request $request, $entity, $_format): string
|
||||
{
|
||||
$actionConfig = $this->getActionConfig($action);
|
||||
|
||||
if (null !== $actionConfig['roles'][$request->getMethod()]) {
|
||||
return $actionConfig['roles'][$request->getMethod()];
|
||||
}
|
||||
|
||||
if ($this->crudConfig['base_role']) {
|
||||
return $this->crudConfig['base_role'];
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('the config does not have any role for the ' .
|
||||
'method %s nor a global role for the whole action. Add those to your ' .
|
||||
'configuration or override the required method', $request->getMethod()));
|
||||
}
|
||||
|
||||
public static function getSubscribedServices(): array
|
||||
{
|
||||
return array_merge(
|
||||
|
@@ -280,11 +280,13 @@ class ApiController extends AbstractCRUDController
|
||||
switch ($request->getMethod()) {
|
||||
case Request::METHOD_DELETE:
|
||||
// oups... how to use property accessor to remove element ?
|
||||
/* @phpstan-ignore-next-line as we do not find a simpler way to do this */
|
||||
$entity->{'remove' . ucfirst($property)}($postedData);
|
||||
|
||||
break;
|
||||
|
||||
case Request::METHOD_POST:
|
||||
/* @phpstan-ignore-next-line as we do not find a simpler way to do this */
|
||||
$entity->{'add' . ucfirst($property)}($postedData);
|
||||
|
||||
break;
|
||||
@@ -499,28 +501,6 @@ class ApiController extends AbstractCRUDController
|
||||
return ['groups' => ['read']];
|
||||
}
|
||||
|
||||
/**
|
||||
* get the role given from the config.
|
||||
*
|
||||
* @param mixed $entity
|
||||
* @param mixed $_format
|
||||
*/
|
||||
protected function getRoleFor(string $action, Request $request, $entity, $_format): string
|
||||
{
|
||||
$actionConfig = $this->getActionConfig($action);
|
||||
|
||||
if (null !== $actionConfig['roles'][$request->getMethod()]) {
|
||||
return $actionConfig['roles'][$request->getMethod()];
|
||||
}
|
||||
|
||||
if ($this->crudConfig['base_role']) {
|
||||
return $this->crudConfig['base_role'];
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf('the config does not have any role for the ' .
|
||||
'method %s nor a global role for the whole action. Add those to your ' .
|
||||
'configuration or override the required method', $request->getMethod()));
|
||||
}
|
||||
|
||||
protected function getSerializer(): SerializerInterface
|
||||
{
|
||||
|
@@ -101,7 +101,7 @@ class CRUDRoutesLoader extends Loader
|
||||
$singleCollection = $action['single_collection'] ?? '_entity' === $name ? 'single' : null;
|
||||
|
||||
if ('collection' === $singleCollection) {
|
||||
// continue;
|
||||
// continue;
|
||||
}
|
||||
|
||||
// compute default action
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?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\Controller;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user