mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-01 05:27:44 +00:00
apply more cs rules for php-cs
This commit is contained in:
parent
0b0cbed9db
commit
bc2041cbdd
@ -91,7 +91,7 @@ $rules = array_merge(
|
|||||||
[
|
[
|
||||||
'@PhpCsFixer' => true,
|
'@PhpCsFixer' => true,
|
||||||
'@PhpCsFixer:risky' => false,
|
'@PhpCsFixer:risky' => false,
|
||||||
'@Symfony' => false,
|
'@Symfony' => true,
|
||||||
'@Symfony:risky' => false,
|
'@Symfony:risky' => false,
|
||||||
'ordered_class_elements' => [
|
'ordered_class_elements' => [
|
||||||
'order' => [
|
'order' => [
|
||||||
@ -111,13 +111,13 @@ $rules = array_merge(
|
|||||||
'method_private',
|
'method_private',
|
||||||
],
|
],
|
||||||
'sort_algorithm' => 'alpha',
|
'sort_algorithm' => 'alpha',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
$rules,
|
$rules,
|
||||||
$riskyRules,
|
$riskyRules,
|
||||||
$untilFullSwitchToPhp8,
|
$untilFullSwitchToPhp8,
|
||||||
);
|
);
|
||||||
|
|
||||||
$rules['header_comment']['header'] = trim(file_get_contents(__DIR__ . '/resource/header.txt'));
|
$rules['header_comment']['header'] = trim(file_get_contents(__DIR__.'/resource/header.txt'));
|
||||||
|
|
||||||
return $config->setRules($rules);
|
return $config->setRules($rules);
|
||||||
|
@ -18,7 +18,6 @@ use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface;
|
|||||||
use Chill\ActivityBundle\Repository\ActivityRepository;
|
use Chill\ActivityBundle\Repository\ActivityRepository;
|
||||||
use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository;
|
use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository;
|
||||||
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
|
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
|
||||||
use Chill\ActivityBundle\Repository\ActivityUserJobRepository;
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
@ -35,11 +34,8 @@ use Chill\PersonBundle\Privacy\PrivacyEvent;
|
|||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||||
use Chill\PersonBundle\Repository\PersonRepository;
|
use Chill\PersonBundle\Repository\PersonRepository;
|
||||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||||
use DateTime;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use InvalidArgumentException;
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
@ -49,7 +45,6 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
use function array_key_exists;
|
|
||||||
|
|
||||||
final class ActivityController extends AbstractController
|
final class ActivityController extends AbstractController
|
||||||
{
|
{
|
||||||
@ -76,6 +71,7 @@ final class ActivityController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a Activity entity.
|
* Deletes a Activity entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/delete", name="chill_activity_activity_delete", methods={"GET", "POST", "DELETE"})
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/delete", name="chill_activity_activity_delete", methods={"GET", "POST", "DELETE"})
|
||||||
*/
|
*/
|
||||||
public function deleteAction(Request $request, mixed $id)
|
public function deleteAction(Request $request, mixed $id)
|
||||||
@ -102,7 +98,7 @@ final class ActivityController extends AbstractController
|
|||||||
|
|
||||||
$form = $this->createDeleteForm($activity->getId(), $person, $accompanyingPeriod);
|
$form = $this->createDeleteForm($activity->getId(), $person, $accompanyingPeriod);
|
||||||
|
|
||||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
@ -145,6 +141,7 @@ final class ActivityController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit an existing Activity entity.
|
* Displays a form to edit an existing Activity entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/edit", name="chill_activity_activity_edit", methods={"GET", "POST", "PUT"})
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/{id}/edit", name="chill_activity_activity_edit", methods={"GET", "POST", "PUT"})
|
||||||
*/
|
*/
|
||||||
public function editAction(int $id, Request $request): Response
|
public function editAction(int $id, Request $request): Response
|
||||||
@ -239,6 +236,7 @@ final class ActivityController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all Activity entities.
|
* Lists all Activity entities.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/", name="chill_activity_activity_list")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/activity/", name="chill_activity_activity_list")
|
||||||
*/
|
*/
|
||||||
public function listAction(Request $request): Response
|
public function listAction(Request $request): Response
|
||||||
@ -295,7 +293,7 @@ final class ActivityController extends AbstractController
|
|||||||
|
|
||||||
$view = '@ChillActivity/Activity/listAccompanyingCourse.html.twig';
|
$view = '@ChillActivity/Activity/listAccompanyingCourse.html.twig';
|
||||||
} else {
|
} else {
|
||||||
throw new \LogicException("Unsupported");
|
throw new \LogicException('Unsupported');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
@ -325,19 +323,19 @@ final class ActivityController extends AbstractController
|
|||||||
->addEntityChoice('activity_types', 'activity_filter.Types', \Chill\ActivityBundle\Entity\ActivityType::class, $types, [
|
->addEntityChoice('activity_types', 'activity_filter.Types', \Chill\ActivityBundle\Entity\ActivityType::class, $types, [
|
||||||
'choice_label' => function (\Chill\ActivityBundle\Entity\ActivityType $activityType) {
|
'choice_label' => function (\Chill\ActivityBundle\Entity\ActivityType $activityType) {
|
||||||
$text = match ($activityType->hasCategory()) {
|
$text = match ($activityType->hasCategory()) {
|
||||||
true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()) . ' > ',
|
true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()).' > ',
|
||||||
false => '',
|
false => '',
|
||||||
};
|
};
|
||||||
|
|
||||||
return $text . $this->translatableStringHelper->localize($activityType->getName());
|
return $text.$this->translatableStringHelper->localize($activityType->getName());
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 < count($jobs)) {
|
if (1 < count($jobs)) {
|
||||||
$filterBuilder
|
$filterBuilder
|
||||||
->addEntityChoice('jobs', 'activity_filter.Jobs', UserJob::class, $jobs, [
|
->addEntityChoice('jobs', 'activity_filter.Jobs', UserJob::class, $jobs, [
|
||||||
'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel())
|
'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +361,7 @@ final class ActivityController extends AbstractController
|
|||||||
$activityType = $this->activityTypeRepository->find($activityType_id);
|
$activityType = $this->activityTypeRepository->find($activityType_id);
|
||||||
|
|
||||||
if (isset($activityType) && !$activityType->isActive()) {
|
if (isset($activityType) && !$activityType->isActive()) {
|
||||||
throw new InvalidArgumentException('Activity type must be active');
|
throw new \InvalidArgumentException('Activity type must be active');
|
||||||
}
|
}
|
||||||
|
|
||||||
$activityData = null;
|
$activityData = null;
|
||||||
@ -398,45 +396,45 @@ final class ActivityController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$entity->setActivityType($activityType);
|
$entity->setActivityType($activityType);
|
||||||
$entity->setDate(new DateTime('now'));
|
$entity->setDate(new \DateTime('now'));
|
||||||
|
|
||||||
if ($request->query->has('activityData')) {
|
if ($request->query->has('activityData')) {
|
||||||
$activityData = $request->query->get('activityData');
|
$activityData = $request->query->get('activityData');
|
||||||
|
|
||||||
if (array_key_exists('durationTime', $activityData) && $activityType->getDurationTimeVisible() > 0) {
|
if (\array_key_exists('durationTime', $activityData) && $activityType->getDurationTimeVisible() > 0) {
|
||||||
$durationTimeInMinutes = $activityData['durationTime'];
|
$durationTimeInMinutes = $activityData['durationTime'];
|
||||||
$hours = floor($durationTimeInMinutes / 60);
|
$hours = floor($durationTimeInMinutes / 60);
|
||||||
$minutes = $durationTimeInMinutes % 60;
|
$minutes = $durationTimeInMinutes % 60;
|
||||||
$duration = DateTime::createFromFormat('H:i', $hours . ':' . $minutes);
|
$duration = \DateTime::createFromFormat('H:i', $hours.':'.$minutes);
|
||||||
|
|
||||||
if ($duration) {
|
if ($duration) {
|
||||||
$entity->setDurationTime($duration);
|
$entity->setDurationTime($duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('date', $activityData)) {
|
if (\array_key_exists('date', $activityData)) {
|
||||||
$date = DateTime::createFromFormat('Y-m-d', $activityData['date']);
|
$date = \DateTime::createFromFormat('Y-m-d', $activityData['date']);
|
||||||
|
|
||||||
if ($date) {
|
if ($date) {
|
||||||
$entity->setDate($date);
|
$entity->setDate($date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('personsId', $activityData) && $activityType->getPersonsVisible() > 0) {
|
if (\array_key_exists('personsId', $activityData) && $activityType->getPersonsVisible() > 0) {
|
||||||
foreach ($activityData['personsId'] as $personId) {
|
foreach ($activityData['personsId'] as $personId) {
|
||||||
$concernedPerson = $this->personRepository->find($personId);
|
$concernedPerson = $this->personRepository->find($personId);
|
||||||
$entity->addPerson($concernedPerson);
|
$entity->addPerson($concernedPerson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('professionalsId', $activityData) && $activityType->getThirdPartiesVisible() > 0) {
|
if (\array_key_exists('professionalsId', $activityData) && $activityType->getThirdPartiesVisible() > 0) {
|
||||||
foreach ($activityData['professionalsId'] as $professionalsId) {
|
foreach ($activityData['professionalsId'] as $professionalsId) {
|
||||||
$professional = $this->thirdPartyRepository->find($professionalsId);
|
$professional = $this->thirdPartyRepository->find($professionalsId);
|
||||||
$entity->addThirdParty($professional);
|
$entity->addThirdParty($professional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('usersId', $activityData) && $activityType->getUsersVisible() > 0) {
|
if (\array_key_exists('usersId', $activityData) && $activityType->getUsersVisible() > 0) {
|
||||||
foreach ($activityData['usersId'] as $userId) {
|
foreach ($activityData['usersId'] as $userId) {
|
||||||
$user = $this->userRepository->find($userId);
|
$user = $this->userRepository->find($userId);
|
||||||
|
|
||||||
@ -446,16 +444,16 @@ final class ActivityController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('location', $activityData) && $activityType->getLocationVisible() > 0) {
|
if (\array_key_exists('location', $activityData) && $activityType->getLocationVisible() > 0) {
|
||||||
$location = $this->locationRepository->find($activityData['location']);
|
$location = $this->locationRepository->find($activityData['location']);
|
||||||
$entity->setLocation($location);
|
$entity->setLocation($location);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('comment', $activityData) && $activityType->getCommentVisible() > 0) {
|
if (\array_key_exists('comment', $activityData) && $activityType->getCommentVisible() > 0) {
|
||||||
$comment = new CommentEmbeddable();
|
$comment = new CommentEmbeddable();
|
||||||
$comment->setComment($activityData['comment']);
|
$comment->setComment($activityData['comment']);
|
||||||
$comment->setUserId($this->getUser()->getid());
|
$comment->setUserId($this->getUser()->getid());
|
||||||
$comment->setDate(new DateTime('now'));
|
$comment->setDate(new \DateTime('now'));
|
||||||
$entity->setComment($comment);
|
$entity->setComment($comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -593,7 +591,7 @@ final class ActivityController extends AbstractController
|
|||||||
} elseif ($person instanceof Person) {
|
} elseif ($person instanceof Person) {
|
||||||
$view = '@ChillActivity/Activity/showPerson.html.twig';
|
$view = '@ChillActivity/Activity/showPerson.html.twig';
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('the activity should be linked with a period or person');
|
throw new \RuntimeException('the activity should be linked with a period or person');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $accompanyingPeriod) {
|
if (null !== $accompanyingPeriod) {
|
||||||
|
@ -24,6 +24,7 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a new ActivityReasonCategory entity.
|
* Creates a new ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/create", name="chill_activity_activityreasoncategory_create", methods={"POST"})
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/create", name="chill_activity_activityreasoncategory_create", methods={"POST"})
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request)
|
||||||
@ -48,6 +49,7 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit an existing ActivityReasonCategory entity.
|
* Displays a form to edit an existing ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/edit", name="chill_activity_activityreasoncategory_edit")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/edit", name="chill_activity_activityreasoncategory_edit")
|
||||||
*/
|
*/
|
||||||
public function editAction(mixed $id)
|
public function editAction(mixed $id)
|
||||||
@ -70,6 +72,7 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all ActivityReasonCategory entities.
|
* Lists all ActivityReasonCategory entities.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/", name="chill_activity_activityreasoncategory")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/", name="chill_activity_activityreasoncategory")
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
@ -85,6 +88,7 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to create a new ActivityReasonCategory entity.
|
* Displays a form to create a new ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/new", name="chill_activity_activityreasoncategory_new")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/new", name="chill_activity_activityreasoncategory_new")
|
||||||
*/
|
*/
|
||||||
public function newAction()
|
public function newAction()
|
||||||
@ -100,6 +104,7 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds and displays a ActivityReasonCategory entity.
|
* Finds and displays a ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/show", name="chill_activity_activityreasoncategory_show")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/show", name="chill_activity_activityreasoncategory_show")
|
||||||
*/
|
*/
|
||||||
public function showAction(mixed $id)
|
public function showAction(mixed $id)
|
||||||
@ -119,6 +124,7 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits an existing ActivityReasonCategory entity.
|
* Edits an existing ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/update", name="chill_activity_activityreasoncategory_update", methods={"POST", "PUT"})
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreasoncategory/{id}/update", name="chill_activity_activityreasoncategory_update", methods={"POST", "PUT"})
|
||||||
*/
|
*/
|
||||||
public function updateAction(Request $request, mixed $id)
|
public function updateAction(Request $request, mixed $id)
|
||||||
|
@ -28,6 +28,7 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ActivityReason entity.
|
* Creates a new ActivityReason entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/create", name="chill_activity_activityreason_create", methods={"POST"})
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/create", name="chill_activity_activityreason_create", methods={"POST"})
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request)
|
||||||
@ -52,6 +53,7 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit an existing ActivityReason entity.
|
* Displays a form to edit an existing ActivityReason entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/edit", name="chill_activity_activityreason_edit")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/edit", name="chill_activity_activityreason_edit")
|
||||||
*/
|
*/
|
||||||
public function editAction(mixed $id)
|
public function editAction(mixed $id)
|
||||||
@ -74,6 +76,7 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all ActivityReason entities.
|
* Lists all ActivityReason entities.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/", name="chill_activity_activityreason")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/", name="chill_activity_activityreason")
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
@ -89,6 +92,7 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to create a new ActivityReason entity.
|
* Displays a form to create a new ActivityReason entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/new", name="chill_activity_activityreason_new")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/new", name="chill_activity_activityreason_new")
|
||||||
*/
|
*/
|
||||||
public function newAction()
|
public function newAction()
|
||||||
@ -104,6 +108,7 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds and displays a ActivityReason entity.
|
* Finds and displays a ActivityReason entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/show", name="chill_activity_activityreason_show")
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/show", name="chill_activity_activityreason_show")
|
||||||
*/
|
*/
|
||||||
public function showAction(mixed $id)
|
public function showAction(mixed $id)
|
||||||
@ -123,6 +128,7 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits an existing ActivityReason entity.
|
* Edits an existing ActivityReason entity.
|
||||||
|
*
|
||||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/update", name="chill_activity_activityreason_update", methods={"POST", "PUT"})
|
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/activityreason/{id}/update", name="chill_activity_activityreason_update", methods={"POST", "PUT"})
|
||||||
*/
|
*/
|
||||||
public function updateAction(Request $request, mixed $id)
|
public function updateAction(Request $request, mixed $id)
|
||||||
|
@ -24,7 +24,7 @@ class AdminActivityPresenceController extends CRUDController
|
|||||||
*/
|
*/
|
||||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
{
|
{
|
||||||
/** @var \Doctrine\ORM\QueryBuilder $query */
|
/* @var \Doctrine\ORM\QueryBuilder $query */
|
||||||
return $query->orderBy('e.id', 'ASC');
|
return $query->orderBy('e.id', 'ASC');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class AdminActivityTypeCategoryController extends CRUDController
|
|||||||
*/
|
*/
|
||||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
{
|
{
|
||||||
/** @var \Doctrine\ORM\QueryBuilder $query */
|
/* @var \Doctrine\ORM\QueryBuilder $query */
|
||||||
return $query->orderBy('e.ordering', 'ASC');
|
return $query->orderBy('e.ordering', 'ASC');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class AdminActivityTypeController extends CRUDController
|
|||||||
*/
|
*/
|
||||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
{
|
{
|
||||||
/** @var \Doctrine\ORM\QueryBuilder $query */
|
/* @var \Doctrine\ORM\QueryBuilder $query */
|
||||||
return $query->orderBy('e.ordering', 'ASC')
|
return $query->orderBy('e.ordering', 'ASC')
|
||||||
->addOrderBy('e.id', 'ASC');
|
->addOrderBy('e.id', 'ASC');
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,13 @@ class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterf
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($reasons as $r) {
|
foreach ($reasons as $r) {
|
||||||
echo 'Creating activity reason : ' . $r['name']['en'] . "\n";
|
echo 'Creating activity reason : '.$r['name']['en']."\n";
|
||||||
$activityReason = (new ActivityReason())
|
$activityReason = (new ActivityReason())
|
||||||
->setName(($r['name']))
|
->setName($r['name'])
|
||||||
->setActive(true)
|
->setActive(true)
|
||||||
->setCategory($this->getReference($r['category']));
|
->setCategory($this->getReference($r['category']));
|
||||||
$manager->persist($activityReason);
|
$manager->persist($activityReason);
|
||||||
$reference = 'activity_reason_' . $r['name']['en'];
|
$reference = 'activity_reason_'.$r['name']['en'];
|
||||||
$this->addReference($reference, $activityReason);
|
$this->addReference($reference, $activityReason);
|
||||||
static::$references[] = $reference;
|
static::$references[] = $reference;
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,13 @@ class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtu
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($categs as $c) {
|
foreach ($categs as $c) {
|
||||||
echo 'Creating activity reason category : ' . $c['name']['en'] . "\n";
|
echo 'Creating activity reason category : '.$c['name']['en']."\n";
|
||||||
$activityReasonCategory = (new ActivityReasonCategory())
|
$activityReasonCategory = (new ActivityReasonCategory())
|
||||||
->setName(($c['name']))
|
->setName($c['name'])
|
||||||
->setActive(true);
|
->setActive(true);
|
||||||
$manager->persist($activityReasonCategory);
|
$manager->persist($activityReasonCategory);
|
||||||
$this->addReference(
|
$this->addReference(
|
||||||
'cat_' . $c['name']['en'],
|
'cat_'.$c['name']['en'],
|
||||||
$activityReasonCategory
|
$activityReasonCategory
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,14 @@ class LoadActivityType extends Fixture implements OrderedFixtureInterface
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($types as $t) {
|
foreach ($types as $t) {
|
||||||
echo 'Creating activity type : ' . $t['name']['fr'] . ' (cat:' . $t['category'] . " \n";
|
echo 'Creating activity type : '.$t['name']['fr'].' (cat:'.$t['category']." \n";
|
||||||
$activityType = (new ActivityType())
|
$activityType = (new ActivityType())
|
||||||
->setName(($t['name']))
|
->setName($t['name'])
|
||||||
->setCategory($this->getReference('activity_type_cat_' . $t['category']))
|
->setCategory($this->getReference('activity_type_cat_'.$t['category']))
|
||||||
->setSocialIssuesVisible(1)
|
->setSocialIssuesVisible(1)
|
||||||
->setSocialActionsVisible(1);
|
->setSocialActionsVisible(1);
|
||||||
$manager->persist($activityType);
|
$manager->persist($activityType);
|
||||||
$reference = 'activity_type_' . $t['name']['fr'];
|
$reference = 'activity_type_'.$t['name']['fr'];
|
||||||
$this->addReference($reference, $activityType);
|
$this->addReference($reference, $activityType);
|
||||||
static::$references[] = $reference;
|
static::$references[] = $reference;
|
||||||
}
|
}
|
||||||
|
@ -42,13 +42,13 @@ class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterfac
|
|||||||
];
|
];
|
||||||
|
|
||||||
foreach ($categories as $cat) {
|
foreach ($categories as $cat) {
|
||||||
echo 'Creating activity type category : ' . $cat['ref'] . "\n";
|
echo 'Creating activity type category : '.$cat['ref']."\n";
|
||||||
|
|
||||||
$newCat = (new ActivityTypeCategory())
|
$newCat = (new ActivityTypeCategory())
|
||||||
->setName(($cat['name']));
|
->setName($cat['name']);
|
||||||
|
|
||||||
$manager->persist($newCat);
|
$manager->persist($newCat);
|
||||||
$reference = 'activity_type_cat_' . $cat['ref'];
|
$reference = 'activity_type_cat_'.$cat['ref'];
|
||||||
|
|
||||||
$this->addReference($reference, $newCat);
|
$this->addReference($reference, $newCat);
|
||||||
static::$references[] = $reference;
|
static::$references[] = $reference;
|
||||||
|
@ -20,8 +20,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
|
|||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
|
* Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
|
||||||
* and a role CHILL_ACTIVITY_SEE for administrative.
|
* and a role CHILL_ACTIVITY_SEE for administrative.
|
||||||
@ -40,10 +38,10 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
|||||||
|
|
||||||
foreach (LoadScopes::$references as $scopeRef) {
|
foreach (LoadScopes::$references as $scopeRef) {
|
||||||
$scope = $this->getReference($scopeRef);
|
$scope = $this->getReference($scopeRef);
|
||||||
//create permission group
|
// create permission group
|
||||||
switch ($permissionsGroup->getName()) {
|
switch ($permissionsGroup->getName()) {
|
||||||
case 'social':
|
case 'social':
|
||||||
if ($scope->getName()['en'] === 'administrative') {
|
if ('administrative' === $scope->getName()['en']) {
|
||||||
break 2; // we do not want any power on administrative
|
break 2; // we do not want any power on administrative
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +49,7 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
|||||||
|
|
||||||
case 'administrative':
|
case 'administrative':
|
||||||
case 'direction':
|
case 'direction':
|
||||||
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
if (\in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
||||||
break 2; // we do not want any power on social or administrative
|
break 2; // we do not want any power on social or administrative
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +58,7 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
|||||||
|
|
||||||
printf(
|
printf(
|
||||||
'Adding CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE & CHILL_ACTIVITY_DELETE, and stats and list permissions to %s '
|
'Adding CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE & CHILL_ACTIVITY_DELETE, and stats and list permissions to %s '
|
||||||
. "permission group, scope '%s' \n",
|
."permission group, scope '%s' \n",
|
||||||
$permissionsGroup->getName(),
|
$permissionsGroup->getName(),
|
||||||
$scope->getName()['en']
|
$scope->getName()['en']
|
||||||
);
|
);
|
||||||
|
@ -32,7 +32,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
|
|
||||||
$container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']);
|
$container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']);
|
||||||
|
|
||||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||||
$loader->load('services.yaml');
|
$loader->load('services.yaml');
|
||||||
$loader->load('services/export.yaml');
|
$loader->load('services/export.yaml');
|
||||||
$loader->load('services/repositories.yaml');
|
$loader->load('services/repositories.yaml');
|
||||||
@ -73,7 +73,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
*/
|
*/
|
||||||
public function prependRoutes(ContainerBuilder $container)
|
public function prependRoutes(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
//add routes for custom bundle
|
// add routes for custom bundle
|
||||||
$container->prependExtensionConfig('chill_main', [
|
$container->prependExtensionConfig('chill_main', [
|
||||||
'routing' => [
|
'routing' => [
|
||||||
'resources' => [
|
'resources' => [
|
||||||
|
@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\DependencyInjection;
|
|||||||
|
|
||||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
|
|
||||||
use function is_int;
|
use function is_int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +58,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->info('The number of seconds of this duration. Must be an integer.')
|
->info('The number of seconds of this duration. Must be an integer.')
|
||||||
->cannotBeEmpty()
|
->cannotBeEmpty()
|
||||||
->validate()
|
->validate()
|
||||||
->ifTrue(static fn ($data) => !is_int($data))->thenInvalid('The value %s is not a valid integer')
|
->ifTrue(static fn ($data) => !\is_int($data))->thenInvalid('The value %s is not a valid integer')
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->scalarNode('label')
|
->scalarNode('label')
|
||||||
|
@ -36,7 +36,6 @@ use DateTime;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||||
@ -46,11 +45,15 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
* Class Activity.
|
* Class Activity.
|
||||||
*
|
*
|
||||||
* @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository")
|
* @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository")
|
||||||
|
*
|
||||||
* @ORM\Table(name="activity")
|
* @ORM\Table(name="activity")
|
||||||
|
*
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
|
*
|
||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "activity": Activity::class
|
* "activity": Activity::class
|
||||||
* })
|
* })
|
||||||
|
*
|
||||||
* @ActivityValidator\ActivityValidity
|
* @ActivityValidator\ActivityValidity
|
||||||
*
|
*
|
||||||
* TODO see if necessary
|
* TODO see if necessary
|
||||||
@ -71,39 +74,48 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
|
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
|
||||||
|
*
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*
|
||||||
* @SerializedName("activityType")
|
* @SerializedName("activityType")
|
||||||
|
*
|
||||||
* @ORM\JoinColumn(name="type_id")
|
* @ORM\JoinColumn(name="type_id")
|
||||||
*/
|
*/
|
||||||
private ActivityType $activityType;
|
private ActivityType $activityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence")
|
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence")
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private ?ActivityPresence $attendee = null;
|
private ?ActivityPresence $attendee = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
|
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private CommentEmbeddable $comment;
|
private CommentEmbeddable $comment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime")
|
* @ORM\Column(type="datetime")
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private DateTime $date;
|
private \DateTime $date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"})
|
* @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject", cascade={"persist"})
|
||||||
|
*
|
||||||
* @Assert\Valid(traverse=true)
|
* @Assert\Valid(traverse=true)
|
||||||
|
*
|
||||||
* @var Collection<StoredObject>
|
* @var Collection<StoredObject>
|
||||||
*/
|
*/
|
||||||
private Collection $documents;
|
private Collection $documents;
|
||||||
@ -111,24 +123,29 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="time", nullable=true)
|
* @ORM\Column(type="time", nullable=true)
|
||||||
*/
|
*/
|
||||||
private ?DateTime $durationTime = null;
|
private ?\DateTime $durationTime = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="boolean", options={"default": false})
|
* @ORM\Column(type="boolean", options={"default": false})
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private bool $emergency = false;
|
private bool $emergency = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
*
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
*
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
||||||
|
*
|
||||||
* @groups({"read", "docgen:read"})
|
* @groups({"read", "docgen:read"})
|
||||||
*/
|
*/
|
||||||
private ?Location $location = null;
|
private ?Location $location = null;
|
||||||
@ -140,7 +157,9 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person")
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*
|
||||||
* @var Collection<Person>
|
* @var Collection<Person>
|
||||||
*/
|
*/
|
||||||
private Collection $persons;
|
private Collection $persons;
|
||||||
@ -152,42 +171,54 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
|
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
|
*
|
||||||
* @var Collection<ActivityReason>
|
* @var Collection<ActivityReason>
|
||||||
*/
|
*/
|
||||||
private Collection $reasons;
|
private Collection $reasons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private ?Scope $scope = null;
|
private ?Scope $scope = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", options={"default": ""})
|
* @ORM\Column(type="string", options={"default": ""})
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private string $sentReceived = '';
|
private string $sentReceived = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
|
||||||
|
*
|
||||||
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*
|
||||||
* @var Collection<SocialAction>
|
* @var Collection<SocialAction>
|
||||||
*/
|
*/
|
||||||
private Collection $socialActions;
|
private Collection $socialActions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
|
||||||
|
*
|
||||||
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*
|
||||||
* @var Collection<SocialIssue>
|
* @var Collection<SocialIssue>
|
||||||
*/
|
*/
|
||||||
private Collection $socialIssues;
|
private Collection $socialIssues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
|
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*
|
||||||
* @var Collection<ThirdParty>
|
* @var Collection<ThirdParty>
|
||||||
*/
|
*/
|
||||||
private Collection $thirdParties;
|
private Collection $thirdParties;
|
||||||
@ -195,17 +226,20 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="time", nullable=true)
|
* @ORM\Column(type="time", nullable=true)
|
||||||
*/
|
*/
|
||||||
private ?DateTime $travelTime = null;
|
private ?\DateTime $travelTime = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private ?User $user = null;
|
private ?User $user = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*
|
||||||
* @var Collection<User>
|
* @var Collection<User>
|
||||||
*/
|
*/
|
||||||
private Collection $users;
|
private Collection $users;
|
||||||
@ -275,7 +309,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
$this->socialIssues[] = $socialIssue;
|
$this->socialIssues[] = $socialIssue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getAccompanyingPeriod() !== null) {
|
if (null !== $this->getAccompanyingPeriod()) {
|
||||||
$this->getAccompanyingPeriod()->addSocialIssue($socialIssue);
|
$this->getAccompanyingPeriod()->addSocialIssue($socialIssue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +375,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this->comment;
|
return $this->comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDate(): DateTime
|
public function getDate(): \DateTime
|
||||||
{
|
{
|
||||||
return $this->date;
|
return $this->date;
|
||||||
}
|
}
|
||||||
@ -363,7 +397,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return (int) round(($this->durationTime->getTimestamp() + $this->durationTime->getOffset()) / 60.0, 0);
|
return (int) round(($this->durationTime->getTimestamp() + $this->durationTime->getOffset()) / 60.0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDurationTime(): ?DateTime
|
public function getDurationTime(): ?\DateTime
|
||||||
{
|
{
|
||||||
return $this->durationTime;
|
return $this->durationTime;
|
||||||
}
|
}
|
||||||
@ -417,7 +451,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
|
|
||||||
// TODO better semantic with: return $this->persons->filter(...);
|
// TODO better semantic with: return $this->persons->filter(...);
|
||||||
foreach ($this->persons as $person) {
|
foreach ($this->persons as $person) {
|
||||||
if ($this->accompanyingPeriod->getOpenParticipationContainsPerson($person) === null) {
|
if (null === $this->accompanyingPeriod->getOpenParticipationContainsPerson($person)) {
|
||||||
$personsNotAssociated[] = $person;
|
$personsNotAssociated[] = $person;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,7 +510,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this->thirdParties;
|
return $this->thirdParties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTravelTime(): ?DateTime
|
public function getTravelTime(): ?\DateTime
|
||||||
{
|
{
|
||||||
return $this->travelTime;
|
return $this->travelTime;
|
||||||
}
|
}
|
||||||
@ -587,7 +621,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDate(DateTime $date): self
|
public function setDate(\DateTime $date): self
|
||||||
{
|
{
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
|
|
||||||
@ -601,7 +635,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDurationTime(?DateTime $durationTime): self
|
public function setDurationTime(?\DateTime $durationTime): self
|
||||||
{
|
{
|
||||||
$this->durationTime = $durationTime;
|
$this->durationTime = $durationTime;
|
||||||
|
|
||||||
@ -671,7 +705,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTravelTime(DateTime $travelTime): self
|
public function setTravelTime(\DateTime $travelTime): self
|
||||||
{
|
{
|
||||||
$this->travelTime = $travelTime;
|
$this->travelTime = $travelTime;
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
|||||||
* Class ActivityPresence.
|
* Class ActivityPresence.
|
||||||
*
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
|
*
|
||||||
* @ORM\Table(name="activitytpresence")
|
* @ORM\Table(name="activitytpresence")
|
||||||
|
*
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
*/
|
*/
|
||||||
class ActivityPresence
|
class ActivityPresence
|
||||||
@ -30,15 +32,20 @@ class ActivityPresence
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
*
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
*
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
*
|
||||||
* @Serializer\Groups({"docgen:read"})
|
* @Serializer\Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json")
|
||||||
|
*
|
||||||
* @Serializer\Groups({"docgen:read"})
|
* @Serializer\Groups({"docgen:read"})
|
||||||
|
*
|
||||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private array $name = [];
|
private array $name = [];
|
||||||
|
@ -17,7 +17,9 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
* Class ActivityReason.
|
* Class ActivityReason.
|
||||||
*
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
|
*
|
||||||
* @ORM\Table(name="activityreason")
|
* @ORM\Table(name="activityreason")
|
||||||
|
*
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
*/
|
*/
|
||||||
class ActivityReason
|
class ActivityReason
|
||||||
@ -28,7 +30,6 @@ class ActivityReason
|
|||||||
private bool $active = true;
|
private bool $active = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ActivityReasonCategory
|
|
||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory",
|
* targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory",
|
||||||
* inversedBy="reasons")
|
* inversedBy="reasons")
|
||||||
@ -36,16 +37,15 @@ class ActivityReason
|
|||||||
private ?ActivityReasonCategory $category = null;
|
private ?ActivityReasonCategory $category = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
|
||||||
*
|
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
*
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
*
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json")
|
||||||
*/
|
*/
|
||||||
private array $name;
|
private array $name;
|
||||||
|
@ -19,7 +19,9 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
* Class ActivityReasonCategory.
|
* Class ActivityReasonCategory.
|
||||||
*
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
|
*
|
||||||
* @ORM\Table(name="activityreasoncategory")
|
* @ORM\Table(name="activityreasoncategory")
|
||||||
|
*
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
*/
|
*/
|
||||||
class ActivityReasonCategory implements \Stringable
|
class ActivityReasonCategory implements \Stringable
|
||||||
@ -30,16 +32,17 @@ class ActivityReasonCategory implements \Stringable
|
|||||||
private bool $active = true;
|
private bool $active = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
|
||||||
*
|
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
*
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
*
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
*
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json")
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
@ -48,6 +51,7 @@ class ActivityReasonCategory implements \Stringable
|
|||||||
* Array of ActivityReason.
|
* Array of ActivityReason.
|
||||||
*
|
*
|
||||||
* @var Collection<ActivityReason>
|
* @var Collection<ActivityReason>
|
||||||
|
*
|
||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(
|
||||||
* targetEntity="Chill\ActivityBundle\Entity\ActivityReason",
|
* targetEntity="Chill\ActivityBundle\Entity\ActivityReason",
|
||||||
* mappedBy="category")
|
* mappedBy="category")
|
||||||
@ -62,12 +66,9 @@ class ActivityReasonCategory implements \Stringable
|
|||||||
$this->reasons = new ArrayCollection();
|
$this->reasons = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return 'ActivityReasonCategory(' . $this->getName('x') . ')';
|
return 'ActivityReasonCategory('.$this->getName('x').')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,6 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use InvalidArgumentException;
|
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
@ -22,7 +21,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||||||
* Class ActivityType.
|
* Class ActivityType.
|
||||||
*
|
*
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
|
*
|
||||||
* @ORM\Table(name="activitytype")
|
* @ORM\Table(name="activitytype")
|
||||||
|
*
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
*/
|
*/
|
||||||
class ActivityType
|
class ActivityType
|
||||||
@ -35,18 +36,21 @@ class ActivityType
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated not in use
|
* @deprecated not in use
|
||||||
|
*
|
||||||
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
||||||
*/
|
*/
|
||||||
private string $accompanyingPeriodLabel = '';
|
private string $accompanyingPeriodLabel = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated not in use
|
* @deprecated not in use
|
||||||
|
*
|
||||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||||
*/
|
*/
|
||||||
private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE;
|
private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(type="boolean")
|
||||||
|
*
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private bool $active = true;
|
private bool $active = true;
|
||||||
@ -118,8 +122,11 @@ class ActivityType
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
*
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
*
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
*
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
@ -136,7 +143,9 @@ class ActivityType
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="json")
|
* @ORM\Column(type="json")
|
||||||
|
*
|
||||||
* @Groups({"read", "docgen:read"})
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*
|
||||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||||
*/
|
*/
|
||||||
private array $name = [];
|
private array $name = [];
|
||||||
@ -158,6 +167,7 @@ class ActivityType
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||||
|
*
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private int $personsVisible = self::FIELD_OPTIONAL;
|
private int $personsVisible = self::FIELD_OPTIONAL;
|
||||||
@ -238,6 +248,7 @@ class ActivityType
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||||
|
*
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private int $thirdPartiesVisible = self::FIELD_INVISIBLE;
|
private int $thirdPartiesVisible = self::FIELD_INVISIBLE;
|
||||||
@ -264,6 +275,7 @@ class ActivityType
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||||
|
*
|
||||||
* @Groups({"read"})
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private int $usersVisible = self::FIELD_OPTIONAL;
|
private int $usersVisible = self::FIELD_OPTIONAL;
|
||||||
@ -372,13 +384,13 @@ class ActivityType
|
|||||||
|
|
||||||
public function getLabel(string $field): ?string
|
public function getLabel(string $field): ?string
|
||||||
{
|
{
|
||||||
$property = $field . 'Label';
|
$property = $field.'Label';
|
||||||
|
|
||||||
if (!property_exists($this, $property)) {
|
if (!property_exists($this, $property)) {
|
||||||
throw new InvalidArgumentException('Field "' . $field . '" not found');
|
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
return $this->{$property};
|
return $this->{$property};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,25 +543,25 @@ class ActivityType
|
|||||||
|
|
||||||
public function isRequired(string $field): bool
|
public function isRequired(string $field): bool
|
||||||
{
|
{
|
||||||
$property = $field . 'Visible';
|
$property = $field.'Visible';
|
||||||
|
|
||||||
if (!property_exists($this, $property)) {
|
if (!property_exists($this, $property)) {
|
||||||
throw new InvalidArgumentException('Field "' . $field . '" not found');
|
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
return self::FIELD_REQUIRED === $this->{$property};
|
return self::FIELD_REQUIRED === $this->{$property};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isVisible(string $field): bool
|
public function isVisible(string $field): bool
|
||||||
{
|
{
|
||||||
$property = $field . 'Visible';
|
$property = $field.'Visible';
|
||||||
|
|
||||||
if (!property_exists($this, $property)) {
|
if (!property_exists($this, $property)) {
|
||||||
throw new InvalidArgumentException('Field "' . $field . '" not found');
|
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
return self::FIELD_INVISIBLE !== $this->{$property};
|
return self::FIELD_INVISIBLE !== $this->{$property};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
|
*
|
||||||
* @ORM\Table(name="activitytypecategory")
|
* @ORM\Table(name="activitytypecategory")
|
||||||
|
*
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
*/
|
*/
|
||||||
class ActivityTypeCategory
|
class ActivityTypeCategory
|
||||||
@ -27,7 +29,9 @@ class ActivityTypeCategory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
*
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
*
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
@ -15,11 +15,8 @@ use Chill\ActivityBundle\Entity\Activity;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||||
use DateTimeImmutable;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ActivityEntityListener
|
class ActivityEntityListener
|
||||||
{
|
{
|
||||||
public function __construct(private readonly EntityManagerInterface $em, private readonly AccompanyingPeriodWorkRepository $workRepository) {}
|
public function __construct(private readonly EntityManagerInterface $em, private readonly AccompanyingPeriodWorkRepository $workRepository) {}
|
||||||
@ -31,11 +28,11 @@ class ActivityEntityListener
|
|||||||
|
|
||||||
$accompanyingCourseWorks = $this->workRepository->findByAccompanyingPeriod($period);
|
$accompanyingCourseWorks = $this->workRepository->findByAccompanyingPeriod($period);
|
||||||
$periodActions = [];
|
$periodActions = [];
|
||||||
$now = new DateTimeImmutable();
|
$now = new \DateTimeImmutable();
|
||||||
|
|
||||||
foreach ($accompanyingCourseWorks as $key => $work) {
|
foreach ($accompanyingCourseWorks as $key => $work) {
|
||||||
// take only the actions which are still opened
|
// take only the actions which are still opened
|
||||||
if ($work->getEndDate() === null || $work->getEndDate() > ($activity->getDate() ?? $now)) {
|
if (null === $work->getEndDate() || $work->getEndDate() > ($activity->getDate() ?? $now)) {
|
||||||
$periodActions[$key] = spl_object_hash($work->getSocialAction());
|
$periodActions[$key] = spl_object_hash($work->getSocialAction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,14 +41,14 @@ class ActivityEntityListener
|
|||||||
$associatedThirdparties = $activity->getThirdParties();
|
$associatedThirdparties = $activity->getThirdParties();
|
||||||
|
|
||||||
foreach ($activity->getSocialActions() as $action) {
|
foreach ($activity->getSocialActions() as $action) {
|
||||||
if (in_array(spl_object_hash($action), $periodActions, true)) {
|
if (\in_array(spl_object_hash($action), $periodActions, true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$newAction = new AccompanyingPeriodWork();
|
$newAction = new AccompanyingPeriodWork();
|
||||||
$newAction->setSocialAction($action);
|
$newAction->setSocialAction($action);
|
||||||
$period->addWork($newAction);
|
$period->addWork($newAction);
|
||||||
|
|
||||||
$date = DateTimeImmutable::createFromMutable($activity->getDate());
|
$date = \DateTimeImmutable::createFromMutable($activity->getDate());
|
||||||
$newAction->setStartDate($date);
|
$newAction->setStartDate($date);
|
||||||
|
|
||||||
foreach ($associatedPersons as $person) {
|
foreach ($associatedPersons as $person) {
|
||||||
|
@ -27,7 +27,7 @@ class ByActivityNumberAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data): void
|
public function alterQuery(QueryBuilder $qb, $data): void
|
||||||
{
|
{
|
||||||
$qb
|
$qb
|
||||||
->addSelect('(SELECT COUNT(activity.id) FROM ' . Activity::class . ' activity WHERE activity.accompanyingPeriod = acp) AS activity_by_number_aggregator')
|
->addSelect('(SELECT COUNT(activity.id) FROM '.Activity::class.' activity WHERE activity.accompanyingPeriod = acp) AS activity_by_number_aggregator')
|
||||||
->addGroupBy('activity_by_number_aggregator');
|
->addGroupBy('activity_by_number_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ class ByActivityNumberAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// No form needed
|
// No form needed
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -17,7 +17,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
|||||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class BySocialActionAggregator implements AggregatorInterface
|
class BySocialActionAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -30,7 +29,7 @@ class BySocialActionAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
if (!\in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.socialActions', 'actsocialaction');
|
$qb->leftJoin('activity.socialActions', 'actsocialaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ class BySocialActionAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// no form
|
// no form
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -17,7 +17,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
|||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class BySocialIssueAggregator implements AggregatorInterface
|
class BySocialIssueAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -30,7 +29,7 @@ class BySocialIssueAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
if (!\in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.socialIssues', 'actsocialissue');
|
$qb->leftJoin('activity.socialIssues', 'actsocialissue');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ class BySocialIssueAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// no form
|
// no form
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -12,14 +12,9 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Export\Aggregator;
|
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Export\Declarations;
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\MainBundle\Repository\LocationRepository;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
|
||||||
use Closure;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
final readonly class ActivityLocationAggregator implements AggregatorInterface
|
final readonly class ActivityLocationAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -32,7 +27,7 @@ final readonly class ActivityLocationAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
if (!\in_array('actloc', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.location', 'actloc');
|
$qb->leftJoin('activity.location', 'actloc');
|
||||||
}
|
}
|
||||||
$qb->addSelect(sprintf('actloc.name AS %s', self::KEY));
|
$qb->addSelect(sprintf('actloc.name AS %s', self::KEY));
|
||||||
@ -48,12 +43,13 @@ final readonly class ActivityLocationAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// no form required for this aggregator
|
// no form required for this aggregator
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data): Closure
|
public function getLabels($key, array $values, $data): \Closure
|
||||||
{
|
{
|
||||||
return function ($value): string {
|
return function ($value): string {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
|
@ -15,10 +15,8 @@ use Chill\ActivityBundle\Export\Declarations;
|
|||||||
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
|
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Closure;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ActivityTypeAggregator implements AggregatorInterface
|
class ActivityTypeAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -33,7 +31,7 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('acttype', $qb->getAllAliases(), true)) {
|
if (!\in_array('acttype', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.activityType', 'acttype');
|
$qb->leftJoin('activity.activityType', 'acttype');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,12 +48,13 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// no form required for this aggregator
|
// no form required for this aggregator
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data): Closure
|
public function getLabels($key, array $values, $data): \Closure
|
||||||
{
|
{
|
||||||
// for performance reason, we load data from db only once
|
// for performance reason, we load data from db only once
|
||||||
$this->activityTypeRepository->findBy(['id' => $values]);
|
$this->activityTypeRepository->findBy(['id' => $values]);
|
||||||
|
@ -15,7 +15,6 @@ use Chill\ActivityBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\MainBundle\Repository\UserRepository;
|
use Chill\MainBundle\Repository\UserRepository;
|
||||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
use Closure;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
@ -48,12 +47,13 @@ class ActivityUserAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// nothing to add
|
// nothing to add
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, $values, $data): Closure
|
public function getLabels($key, $values, $data): \Closure
|
||||||
{
|
{
|
||||||
return function ($value) {
|
return function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
|
@ -17,7 +17,6 @@ use Chill\MainBundle\Repository\UserRepositoryInterface;
|
|||||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ActivityUsersAggregator implements AggregatorInterface
|
class ActivityUsersAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -30,7 +29,7 @@ class ActivityUsersAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
if (!\in_array('actusers', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.users', 'actusers');
|
$qb->leftJoin('activity.users', 'actusers');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +47,7 @@ class ActivityUsersAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// nothing to add on the form
|
// nothing to add on the form
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -39,7 +39,7 @@ class ActivityUsersJobAggregator implements AggregatorInterface
|
|||||||
$p = self::PREFIX;
|
$p = self::PREFIX;
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->leftJoin("activity.users", "{$p}_user")
|
->leftJoin('activity.users', "{$p}_user")
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
UserJobHistory::class,
|
UserJobHistory::class,
|
||||||
"{$p}_history",
|
"{$p}_history",
|
||||||
@ -49,10 +49,10 @@ class ActivityUsersJobAggregator implements AggregatorInterface
|
|||||||
// job_at based on activity.date
|
// job_at based on activity.date
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->lte("{$p}_history.startDate", "activity.date"),
|
$qb->expr()->lte("{$p}_history.startDate", 'activity.date'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||||
$qb->expr()->gt("{$p}_history.endDate", "activity.date")
|
$qb->expr()->gt("{$p}_history.endDate", 'activity.date')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -93,7 +93,7 @@ class ActivityUsersJobAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data): array
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return [self::PREFIX . '_select'];
|
return [self::PREFIX.'_select'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
|
@ -39,7 +39,7 @@ class ActivityUsersScopeAggregator implements AggregatorInterface
|
|||||||
$p = self::PREFIX;
|
$p = self::PREFIX;
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->leftJoin("activity.users", "{$p}_user")
|
->leftJoin('activity.users', "{$p}_user")
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
UserScopeHistory::class,
|
UserScopeHistory::class,
|
||||||
"{$p}_history",
|
"{$p}_history",
|
||||||
@ -49,10 +49,10 @@ class ActivityUsersScopeAggregator implements AggregatorInterface
|
|||||||
// scope_at based on activity.date
|
// scope_at based on activity.date
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->lte("{$p}_history.startDate", "activity.date"),
|
$qb->expr()->lte("{$p}_history.startDate", 'activity.date'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||||
$qb->expr()->gt("{$p}_history.endDate", "activity.date")
|
$qb->expr()->gt("{$p}_history.endDate", 'activity.date')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -93,7 +93,7 @@ class ActivityUsersScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data): array
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return [self::PREFIX . '_select'];
|
return [self::PREFIX.'_select'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
|
@ -42,6 +42,7 @@ class ByCreatorAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// no form
|
// no form
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -17,7 +17,6 @@ use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
|||||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ByThirdpartyAggregator implements AggregatorInterface
|
class ByThirdpartyAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -30,7 +29,7 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('acttparty', $qb->getAllAliases(), true)) {
|
if (!\in_array('acttparty', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.thirdParties', 'acttparty');
|
$qb->leftJoin('activity.thirdParties', 'acttparty');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// no form
|
// no form
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -39,7 +39,7 @@ class CreatorScopeAggregator implements AggregatorInterface
|
|||||||
$p = self::PREFIX;
|
$p = self::PREFIX;
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->leftJoin("activity.createdBy", "{$p}_user")
|
->leftJoin('activity.createdBy', "{$p}_user")
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
UserScopeHistory::class,
|
UserScopeHistory::class,
|
||||||
"{$p}_history",
|
"{$p}_history",
|
||||||
@ -49,10 +49,10 @@ class CreatorScopeAggregator implements AggregatorInterface
|
|||||||
// scope_at based on activity.date
|
// scope_at based on activity.date
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->lte("{$p}_history.startDate", "activity.date"),
|
$qb->expr()->lte("{$p}_history.startDate", 'activity.date'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||||
$qb->expr()->gt("{$p}_history.endDate", "activity.date")
|
$qb->expr()->gt("{$p}_history.endDate", 'activity.date')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -93,7 +93,7 @@ class CreatorScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data): array
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return [self::PREFIX . '_select'];
|
return [self::PREFIX.'_select'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
|
@ -14,10 +14,8 @@ namespace Chill\ActivityBundle\Export\Aggregator;
|
|||||||
use Chill\ActivityBundle\Export\Declarations;
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
||||||
|
|
||||||
class DateAggregator implements AggregatorInterface
|
class DateAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -56,7 +54,7 @@ class DateAggregator implements AggregatorInterface
|
|||||||
break; // order DESC does not works !
|
break; // order DESC does not works !
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException(sprintf("The frequency data '%s' is invalid.", $data['frequency']));
|
throw new \RuntimeException(sprintf("The frequency data '%s' is invalid.", $data['frequency']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect(sprintf("TO_CHAR(activity.date, '%s') AS date_aggregator", $fmt));
|
$qb->addSelect(sprintf("TO_CHAR(activity.date, '%s') AS date_aggregator", $fmt));
|
||||||
@ -78,6 +76,7 @@ class DateAggregator implements AggregatorInterface
|
|||||||
'empty_data' => self::DEFAULT_CHOICE,
|
'empty_data' => self::DEFAULT_CHOICE,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return ['frequency' => self::DEFAULT_CHOICE];
|
return ['frequency' => self::DEFAULT_CHOICE];
|
||||||
@ -87,7 +86,7 @@ class DateAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
return static function ($value) use ($data): string {
|
return static function ($value) use ($data): string {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return 'by ' . $data['frequency'];
|
return 'by '.$data['frequency'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
|
@ -13,7 +13,6 @@ namespace Chill\ActivityBundle\Export\Aggregator;
|
|||||||
|
|
||||||
use Chill\ActivityBundle\Export\Declarations;
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\MainBundle\Repository\ScopeRepository;
|
use Chill\MainBundle\Repository\ScopeRepository;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
@ -40,7 +39,7 @@ class JobScopeAggregator implements AggregatorInterface
|
|||||||
$p = self::PREFIX;
|
$p = self::PREFIX;
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->leftJoin("activity.createdBy", "{$p}_user")
|
->leftJoin('activity.createdBy', "{$p}_user")
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
UserJobHistory::class,
|
UserJobHistory::class,
|
||||||
"{$p}_history",
|
"{$p}_history",
|
||||||
@ -50,10 +49,10 @@ class JobScopeAggregator implements AggregatorInterface
|
|||||||
// job_at based on activity.date
|
// job_at based on activity.date
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->lte("{$p}_history.startDate", "activity.date"),
|
$qb->expr()->lte("{$p}_history.startDate", 'activity.date'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||||
$qb->expr()->gt("{$p}_history.endDate", "activity.date")
|
$qb->expr()->gt("{$p}_history.endDate", 'activity.date')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -94,7 +93,7 @@ class JobScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data): array
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return [self::PREFIX . '_select'];
|
return [self::PREFIX.'_select'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
|
@ -17,7 +17,6 @@ use Chill\MainBundle\Repository\LocationTypeRepository;
|
|||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class LocationTypeAggregator implements AggregatorInterface
|
class LocationTypeAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
@ -30,7 +29,7 @@ class LocationTypeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
if (!\in_array('actloc', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.location', 'actloc');
|
$qb->leftJoin('activity.location', 'actloc');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,7 @@ class LocationTypeAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// no form
|
// no form
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -17,17 +17,12 @@ use Chill\ActivityBundle\Repository\ActivityReasonRepository;
|
|||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
use function count;
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ActivityReasonAggregator implements AggregatorInterface, ExportElementValidatedInterface
|
class ActivityReasonAggregator implements AggregatorInterface, ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
public function __construct(protected ActivityReasonCategoryRepository $activityReasonCategoryRepository, protected ActivityReasonRepository $activityReasonRepository, protected TranslatableStringHelper $translatableStringHelper) {}
|
public function __construct(protected ActivityReasonCategoryRepository $activityReasonCategoryRepository, protected ActivityReasonRepository $activityReasonRepository, protected TranslatableStringHelper $translatableStringHelper) {}
|
||||||
@ -47,20 +42,20 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
|
|||||||
$elem = 'actreasoncat.id';
|
$elem = 'actreasoncat.id';
|
||||||
$alias = 'activity_categories_id';
|
$alias = 'activity_categories_id';
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('The data provided are not recognized.');
|
throw new \RuntimeException('The data provided are not recognized.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect($elem . ' as ' . $alias);
|
$qb->addSelect($elem.' as '.$alias);
|
||||||
|
|
||||||
// make a jointure only if needed
|
// make a jointure only if needed
|
||||||
if (!in_array('actreasons', $qb->getAllAliases(), true)) {
|
if (!\in_array('actreasons', $qb->getAllAliases(), true)) {
|
||||||
$qb->innerJoin('activity.reasons', 'actreasons');
|
$qb->innerJoin('activity.reasons', 'actreasons');
|
||||||
}
|
}
|
||||||
|
|
||||||
// join category if necessary
|
// join category if necessary
|
||||||
if ('activity_categories_id' === $alias) {
|
if ('activity_categories_id' === $alias) {
|
||||||
// add join only if needed
|
// add join only if needed
|
||||||
if (!in_array('actreasoncat', $qb->getAllAliases(), true)) {
|
if (!\in_array('actreasoncat', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('actreasons.category', 'actreasoncat');
|
$qb->join('actreasons.category', 'actreasoncat');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +63,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
|
|||||||
// add the "group by" part
|
// add the "group by" part
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
if (count($groupBy) > 0) {
|
if (\count($groupBy) > 0) {
|
||||||
$qb->addGroupBy($alias);
|
$qb->addGroupBy($alias);
|
||||||
} else {
|
} else {
|
||||||
$qb->groupBy($alias);
|
$qb->groupBy($alias);
|
||||||
@ -96,6 +91,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -106,7 +102,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
|
|||||||
match ($data['level']) {
|
match ($data['level']) {
|
||||||
'reasons' => $this->activityReasonRepository->findBy(['id' => $values]),
|
'reasons' => $this->activityReasonRepository->findBy(['id' => $values]),
|
||||||
'categories' => $this->activityReasonCategoryRepository->findBy(['id' => $values]),
|
'categories' => $this->activityReasonCategoryRepository->findBy(['id' => $values]),
|
||||||
default => throw new RuntimeException(sprintf("The level data '%s' is invalid.", $data['level'])),
|
default => throw new \RuntimeException(sprintf("The level data '%s' is invalid.", $data['level'])),
|
||||||
};
|
};
|
||||||
|
|
||||||
return function ($value) use ($data) {
|
return function ($value) use ($data) {
|
||||||
@ -147,7 +143,7 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali
|
|||||||
return ['activity_categories_id'];
|
return ['activity_categories_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RuntimeException('The data provided are not recognised.');
|
throw new \RuntimeException('The data provided are not recognised.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
|
@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Export\Aggregator;
|
|||||||
use Chill\ActivityBundle\Export\Declarations;
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
@ -42,6 +41,7 @@ class SentReceivedAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
// No form needed
|
// No form needed
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -66,7 +66,7 @@ class SentReceivedAggregator implements AggregatorInterface
|
|||||||
return $this->translator->trans('export.aggregator.activity.by_sent_received.is received');
|
return $this->translator->trans('export.aggregator.activity.by_sent_received.is received');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new LogicException(sprintf('The value %s is not valid', $value));
|
throw new \LogicException(sprintf('The value %s is not valid', $value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class AvgActivityDuration implements ExportInterface, GroupedExportInterface
|
class AvgActivityDuration implements ExportInterface, GroupedExportInterface
|
||||||
@ -38,6 +37,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder) {}
|
public function buildForm(FormBuilderInterface $builder) {}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -61,7 +61,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_avg_activity_duration' !== $key) {
|
if ('export_avg_activity_duration' !== $key) {
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
throw new \LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period duration' : $value;
|
return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period duration' : $value;
|
||||||
@ -101,8 +101,8 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
$qb
|
$qb
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part
|
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
|
||||||
JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
||||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
||||||
'
|
'
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface
|
class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterface
|
||||||
@ -41,6 +40,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
{
|
{
|
||||||
// TODO: Implement buildForm() method.
|
// TODO: Implement buildForm() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -64,7 +64,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_avg_activity_visit_duration' !== $key) {
|
if ('export_avg_activity_visit_duration' !== $key) {
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
throw new \LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period visit duration' : $value;
|
return static fn ($value) => '_header' === $value ? 'Average activities linked to an accompanying period visit duration' : $value;
|
||||||
@ -104,8 +104,8 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
$qb
|
$qb
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part
|
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
|
||||||
JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
||||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
||||||
'
|
'
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class CountActivity implements ExportInterface, GroupedExportInterface
|
class CountActivity implements ExportInterface, GroupedExportInterface
|
||||||
@ -38,6 +37,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder) {}
|
public function buildForm(FormBuilderInterface $builder) {}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -61,7 +61,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface
|
|||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_count_activity' !== $key) {
|
if ('export_count_activity' !== $key) {
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
throw new \LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static fn ($value) => '_header' === $value ? 'Number of activities linked to an accompanying period' : $value;
|
return static fn ($value) => '_header' === $value ? 'Number of activities linked to an accompanying period' : $value;
|
||||||
@ -98,8 +98,8 @@ class CountActivity implements ExportInterface, GroupedExportInterface
|
|||||||
$qb
|
$qb
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part
|
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
|
||||||
JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
||||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
||||||
'
|
'
|
||||||
)
|
)
|
||||||
|
@ -32,6 +32,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
{
|
{
|
||||||
$this->helper->buildForm($builder);
|
$this->helper->buildForm($builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -44,7 +45,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
return ListActivityHelper::MSG_KEY . 'List activities linked to an accompanying course';
|
return ListActivityHelper::MSG_KEY.'List activities linked to an accompanying course';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGroup(): string
|
public function getGroup(): string
|
||||||
@ -57,12 +58,12 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
return match ($key) {
|
return match ($key) {
|
||||||
'acpId' => static function ($value) {
|
'acpId' => static function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return ListActivityHelper::MSG_KEY . 'accompanying course id';
|
return ListActivityHelper::MSG_KEY.'accompanying course id';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value ?? '';
|
return $value ?? '';
|
||||||
},
|
},
|
||||||
'scopesNames' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles'),
|
'scopesNames' => $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY.'course circles'),
|
||||||
default => $this->helper->getLabels($key, $values, $data),
|
default => $this->helper->getLabels($key, $values, $data),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return ListActivityHelper::MSG_KEY . 'List activity linked to a course';
|
return ListActivityHelper::MSG_KEY.'List activity linked to a course';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
@ -110,7 +111,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1
|
'SELECT 1
|
||||||
FROM ' . PersonCenterHistory::class . ' acl_count_person_history
|
FROM '.PersonCenterHistory::class.' acl_count_person_history
|
||||||
WHERE acl_count_person_history.person = person
|
WHERE acl_count_person_history.person = person
|
||||||
AND acl_count_person_history.center IN (:authorized_centers)
|
AND acl_count_person_history.center IN (:authorized_centers)
|
||||||
'
|
'
|
||||||
@ -127,7 +128,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
// add select for this step
|
// add select for this step
|
||||||
$qb
|
$qb
|
||||||
->addSelect('acp.id AS acpId')
|
->addSelect('acp.id AS acpId')
|
||||||
->addSelect('(SELECT AGGREGATE(acpScope.name) FROM ' . Scope::class . ' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames')
|
->addSelect('(SELECT AGGREGATE(acpScope.name) FROM '.Scope::class.' acpScope WHERE acpScope MEMBER OF acp.scopes) AS scopesNames')
|
||||||
->addGroupBy('scopesNames');
|
->addGroupBy('scopesNames');
|
||||||
|
|
||||||
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
|
||||||
|
@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class SumActivityDuration implements ExportInterface, GroupedExportInterface
|
class SumActivityDuration implements ExportInterface, GroupedExportInterface
|
||||||
@ -41,6 +40,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
{
|
{
|
||||||
// TODO: Implement buildForm() method.
|
// TODO: Implement buildForm() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -64,7 +64,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_sum_activity_duration' !== $key) {
|
if ('export_sum_activity_duration' !== $key) {
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
throw new \LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period duration' : $value;
|
return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period duration' : $value;
|
||||||
@ -104,8 +104,8 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
$qb
|
$qb
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part
|
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
|
||||||
JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
||||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
||||||
'
|
'
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,6 @@ use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface
|
class SumActivityVisitDuration implements ExportInterface, GroupedExportInterface
|
||||||
@ -41,6 +40,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
{
|
{
|
||||||
// TODO: Implement buildForm() method.
|
// TODO: Implement buildForm() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -64,7 +64,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_sum_activity_visit_duration' !== $key) {
|
if ('export_sum_activity_visit_duration' !== $key) {
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
throw new \LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period visit duration' : $value;
|
return static fn ($value) => '_header' === $value ? 'Sum activities linked to an accompanying period visit duration' : $value;
|
||||||
@ -104,8 +104,8 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac
|
|||||||
$qb
|
$qb
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . AccompanyingPeriodParticipation::class . ' acl_count_part
|
'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part
|
||||||
JOIN ' . PersonCenterHistory::class . ' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person)
|
||||||
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers)
|
||||||
'
|
'
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,6 @@ use Chill\MainBundle\Export\FormatterInterface;
|
|||||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||||
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class CountActivity implements ExportInterface, GroupedExportInterface
|
class CountActivity implements ExportInterface, GroupedExportInterface
|
||||||
@ -27,6 +26,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface
|
|||||||
public function __construct(protected ActivityRepository $activityRepository) {}
|
public function __construct(protected ActivityRepository $activityRepository) {}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder) {}
|
public function buildForm(FormBuilderInterface $builder) {}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -50,7 +50,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface
|
|||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_count_activity' !== $key) {
|
if ('export_count_activity' !== $key) {
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
throw new \LogicException("the key {$key} is not used by this export");
|
||||||
}
|
}
|
||||||
|
|
||||||
return static fn ($value) => '_header' === $value ? 'Number of activities linked to a person' : $value;
|
return static fn ($value) => '_header' === $value ? 'Number of activities linked to a person' : $value;
|
||||||
|
@ -20,7 +20,6 @@ use Chill\MainBundle\Export\GroupedExportInterface;
|
|||||||
use Chill\MainBundle\Export\ListInterface;
|
use Chill\MainBundle\Export\ListInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
||||||
use DateTime;
|
|
||||||
use Doctrine\DBAL\Exception\InvalidArgumentException;
|
use Doctrine\DBAL\Exception\InvalidArgumentException;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
@ -30,10 +29,6 @@ use Symfony\Component\Validator\Constraints\Callback;
|
|||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use function array_key_exists;
|
|
||||||
use function count;
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ListActivity implements ListInterface, GroupedExportInterface
|
class ListActivity implements ListInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
protected array $fields = [
|
protected array $fields = [
|
||||||
@ -61,7 +56,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
'label' => 'Fields to include in export',
|
'label' => 'Fields to include in export',
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback([
|
||||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
||||||
if (count($selected) === 0) {
|
if (0 === \count($selected)) {
|
||||||
$context->buildViolation('You must select at least one element')
|
$context->buildViolation('You must select at least one element')
|
||||||
->atPath('fields')
|
->atPath('fields')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
@ -70,6 +65,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
])],
|
])],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -99,7 +95,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
return 'date';
|
return 'date';
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
||||||
|
|
||||||
return $date->format('d-m-Y');
|
return $date->format('d-m-Y');
|
||||||
};
|
};
|
||||||
@ -123,11 +119,11 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
|
|
||||||
$activity = $activityRepository->find($value);
|
$activity = $activityRepository->find($value);
|
||||||
|
|
||||||
return implode(', ', array_map(fn (ActivityReason $r) => '"' .
|
return implode(', ', array_map(fn (ActivityReason $r) => '"'.
|
||||||
$this->translatableStringHelper->localize($r->getCategory()->getName())
|
$this->translatableStringHelper->localize($r->getCategory()->getName())
|
||||||
. ' > ' .
|
.' > '.
|
||||||
$this->translatableStringHelper->localize($r->getName())
|
$this->translatableStringHelper->localize($r->getName())
|
||||||
. '"', $activity->getReasons()->toArray()));
|
.'"', $activity->getReasons()->toArray()));
|
||||||
};
|
};
|
||||||
|
|
||||||
case 'circle_name':
|
case 'circle_name':
|
||||||
@ -184,7 +180,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||||
|
|
||||||
// throw an error if any fields are present
|
// throw an error if any fields are present
|
||||||
if (!array_key_exists('fields', $data)) {
|
if (!\array_key_exists('fields', $data)) {
|
||||||
throw new InvalidArgumentException('Any fields have been checked.');
|
throw new InvalidArgumentException('Any fields have been checked.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +204,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
|||||||
->setParameter('centers', $centers);
|
->setParameter('centers', $centers);
|
||||||
|
|
||||||
foreach ($this->fields as $f) {
|
foreach ($this->fields as $f) {
|
||||||
if (in_array($f, $data['fields'], true)) {
|
if (\in_array($f, $data['fields'], true)) {
|
||||||
switch ($f) {
|
switch ($f) {
|
||||||
case 'id':
|
case 'id':
|
||||||
$qb->addSelect('activity.id AS id');
|
$qb->addSelect('activity.id AS id');
|
||||||
|
@ -20,7 +20,6 @@ use Chill\MainBundle\Export\FormatterInterface;
|
|||||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||||
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
use Chill\PersonBundle\Export\Declarations as PersonDeclarations;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,6 +43,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder) {}
|
public function buildForm(FormBuilderInterface $builder) {}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -60,7 +60,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
return 'Sum activities linked to a person duration by various parameters.';
|
return 'Sum activities linked to a person duration by various parameters.';
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new LogicException('this action is not supported: ' . $this->action);
|
throw new \LogicException('this action is not supported: '.$this->action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGroup(): string
|
public function getGroup(): string
|
||||||
@ -71,7 +71,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
if ('export_stat_activity' !== $key) {
|
if ('export_stat_activity' !== $key) {
|
||||||
throw new LogicException(sprintf('The key %s is not used by this export', $key));
|
throw new \LogicException(sprintf('The key %s is not used by this export', $key));
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = self::SUM === $this->action ? 'Sum activities linked to a person duration' : false;
|
$header = self::SUM === $this->action ? 'Sum activities linked to a person duration' : false;
|
||||||
@ -95,7 +95,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface
|
|||||||
return 'Sum activity linked to a person duration';
|
return 'Sum activity linked to a person duration';
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new LogicException('This action is not supported: ' . $this->action);
|
throw new \LogicException('This action is not supported: '.$this->action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
|
@ -23,10 +23,8 @@ use Chill\PersonBundle\Export\Helper\LabelPersonHelper;
|
|||||||
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
use Chill\ThirdPartyBundle\Export\Helper\LabelThirdPartyHelper;
|
||||||
use Doctrine\ORM\AbstractQuery;
|
use Doctrine\ORM\AbstractQuery;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
use const SORT_NUMERIC;
|
|
||||||
|
|
||||||
class ListActivityHelper
|
class ListActivityHelper
|
||||||
{
|
{
|
||||||
@ -88,7 +86,7 @@ class ListActivityHelper
|
|||||||
return match ($key) {
|
return match ($key) {
|
||||||
'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel($key),
|
'createdAt', 'updatedAt' => $this->dateTimeHelper->getLabel($key),
|
||||||
'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, $key),
|
'createdBy', 'updatedBy' => $this->userHelper->getLabel($key, $values, $key),
|
||||||
'date' => $this->dateTimeHelper->getLabel(self::MSG_KEY . $key),
|
'date' => $this->dateTimeHelper->getLabel(self::MSG_KEY.$key),
|
||||||
'attendeeName' => function ($value) {
|
'attendeeName' => function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return 'Attendee';
|
return 'Attendee';
|
||||||
@ -112,13 +110,13 @@ class ListActivityHelper
|
|||||||
|
|
||||||
return $this->translatableStringHelper->localize($type->getName());
|
return $this->translatableStringHelper->localize($type->getName());
|
||||||
},
|
},
|
||||||
'usersNames' => $this->userHelper->getLabelMulti($key, $values, self::MSG_KEY . 'users name'),
|
'usersNames' => $this->userHelper->getLabelMulti($key, $values, self::MSG_KEY.'users name'),
|
||||||
'usersIds', 'thirdPartiesIds', 'personsIds' => static function ($value) use ($key) {
|
'usersIds', 'thirdPartiesIds', 'personsIds' => static function ($value) use ($key) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return match ($key) {
|
return match ($key) {
|
||||||
'usersIds' => self::MSG_KEY . 'users ids',
|
'usersIds' => self::MSG_KEY.'users ids',
|
||||||
'thirdPartiesIds' => self::MSG_KEY . 'third parties ids',
|
'thirdPartiesIds' => self::MSG_KEY.'third parties ids',
|
||||||
'personsIds' => self::MSG_KEY . 'persons ids',
|
'personsIds' => self::MSG_KEY.'persons ids',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,15 +126,15 @@ class ListActivityHelper
|
|||||||
'|',
|
'|',
|
||||||
array_unique(
|
array_unique(
|
||||||
array_filter($decoded, static fn (?int $id) => null !== $id),
|
array_filter($decoded, static fn (?int $id) => null !== $id),
|
||||||
SORT_NUMERIC
|
\SORT_NUMERIC
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'personsNames' => $this->labelPersonHelper->getLabelMulti($key, $values, self::MSG_KEY . 'persons name'),
|
'personsNames' => $this->labelPersonHelper->getLabelMulti($key, $values, self::MSG_KEY.'persons name'),
|
||||||
'thirdPartiesNames' => $this->labelThirdPartyHelper->getLabelMulti($key, $values, self::MSG_KEY . 'thirds parties'),
|
'thirdPartiesNames' => $this->labelThirdPartyHelper->getLabelMulti($key, $values, self::MSG_KEY.'thirds parties'),
|
||||||
'sentReceived' => function ($value) {
|
'sentReceived' => function ($value) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return self::MSG_KEY . 'sent received';
|
return self::MSG_KEY.'sent received';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
@ -147,7 +145,7 @@ class ListActivityHelper
|
|||||||
},
|
},
|
||||||
default => function ($value) use ($key) {
|
default => function ($value) use ($key) {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return self::MSG_KEY . $key;
|
return self::MSG_KEY.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
|
@ -37,7 +37,7 @@ class ActivityTypeFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$qb->andWhere(
|
$qb->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . Activity::class . ' act_type_filter_activity
|
'SELECT 1 FROM '.Activity::class.' act_type_filter_activity
|
||||||
WHERE act_type_filter_activity.activityType IN (:act_type_filter_activity_types) AND act_type_filter_activity.accompanyingPeriod = acp'
|
WHERE act_type_filter_activity.activityType IN (:act_type_filter_activity_types) AND act_type_filter_activity.accompanyingPeriod = acp'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -54,13 +54,14 @@ class ActivityTypeFilter implements FilterInterface
|
|||||||
$builder->add('accepted_activitytypes', EntityType::class, [
|
$builder->add('accepted_activitytypes', EntityType::class, [
|
||||||
'class' => ActivityType::class,
|
'class' => ActivityType::class,
|
||||||
'choices' => $this->activityTypeRepository->findAllActive(),
|
'choices' => $this->activityTypeRepository->findAllActive(),
|
||||||
'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '')
|
'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()).' > ' : '')
|
||||||
.
|
.
|
||||||
$this->translatableStringHelper->localize($aty->getName()),
|
$this->translatableStringHelper->localize($aty->getName()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -18,7 +18,6 @@ use Chill\PersonBundle\Form\Type\PickSocialActionType;
|
|||||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class BySocialActionFilter implements FilterInterface
|
class BySocialActionFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
@ -31,7 +30,7 @@ class BySocialActionFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
if (!\in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialActions', 'actsocialaction');
|
$qb->join('activity.socialActions', 'actsocialaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +54,7 @@ class BySocialActionFilter implements FilterInterface
|
|||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -18,7 +18,6 @@ use Chill\PersonBundle\Form\Type\PickSocialIssueType;
|
|||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class BySocialIssueFilter implements FilterInterface
|
class BySocialIssueFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
@ -31,7 +30,7 @@ class BySocialIssueFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
if (!\in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialIssues', 'actsocialissue');
|
$qb->join('activity.socialIssues', 'actsocialissue');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +54,7 @@ class BySocialIssueFilter implements FilterInterface
|
|||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -18,7 +18,7 @@ use Doctrine\ORM\QueryBuilder;
|
|||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter accompanying periods to keep only the one without any activity
|
* Filter accompanying periods to keep only the one without any activity.
|
||||||
*/
|
*/
|
||||||
class HasNoActivityFilter implements FilterInterface
|
class HasNoActivityFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ class HasNoActivityFilter implements FilterInterface
|
|||||||
$qb
|
$qb
|
||||||
->andWhere('
|
->andWhere('
|
||||||
NOT EXISTS (
|
NOT EXISTS (
|
||||||
SELECT 1 FROM ' . Activity::class . ' activity
|
SELECT 1 FROM '.Activity::class.' activity
|
||||||
WHERE activity.accompanyingPeriod = acp
|
WHERE activity.accompanyingPeriod = acp
|
||||||
)
|
)
|
||||||
');
|
');
|
||||||
@ -45,8 +45,9 @@ class HasNoActivityFilter implements FilterInterface
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
//no form needed
|
// no form needed
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -34,10 +34,10 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt
|
|||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('start_date', PickRollingDateType::class, [
|
->add('start_date', PickRollingDateType::class, [
|
||||||
'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity after'
|
'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity after',
|
||||||
])
|
])
|
||||||
->add('end_date', PickRollingDateType::class, [
|
->add('end_date', PickRollingDateType::class, [
|
||||||
'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity before'
|
'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity before',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||||
'end_date' => new RollingDate(RollingDate::T_TODAY)
|
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt
|
|||||||
[
|
[
|
||||||
'from' => $this->rollingDateConverter->convert($data['start_date']),
|
'from' => $this->rollingDateConverter->convert($data['start_date']),
|
||||||
'to' => $this->rollingDateConverter->convert($data['end_date']),
|
'to' => $this->rollingDateConverter->convert($data['end_date']),
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt
|
|||||||
|
|
||||||
$qb->andWhere(
|
$qb->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM ' . Activity::class . " {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp"
|
'SELECT 1 FROM '.Activity::class." {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -90,14 +90,14 @@ class ActivityDateFilter implements FilterInterface
|
|||||||
if (null === $date_from) {
|
if (null === $date_from) {
|
||||||
$form->get('date_from')->addError(new FormError(
|
$form->get('date_from')->addError(new FormError(
|
||||||
$this->translator->trans('This field '
|
$this->translator->trans('This field '
|
||||||
. 'should not be empty')
|
.'should not be empty')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $date_to) {
|
if (null === $date_to) {
|
||||||
$form->get('date_to')->addError(new FormError(
|
$form->get('date_to')->addError(new FormError(
|
||||||
$this->translator->trans('This field '
|
$this->translator->trans('This field '
|
||||||
. 'should not be empty')
|
.'should not be empty')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,13 +108,14 @@ class ActivityDateFilter implements FilterInterface
|
|||||||
) {
|
) {
|
||||||
$form->get('date_to')->addError(new FormError(
|
$form->get('date_to')->addError(new FormError(
|
||||||
$this->translator->trans('This date should be after '
|
$this->translator->trans('This date should be after '
|
||||||
. 'the date given in "Implied in an activity after '
|
.'the date given in "Implied in an activity after '
|
||||||
. 'this date" field')
|
.'this date" field')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];
|
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];
|
||||||
|
@ -22,8 +22,6 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
use function count;
|
|
||||||
|
|
||||||
class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface
|
class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@ -54,7 +52,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter
|
|||||||
$builder->add('types', EntityType::class, [
|
$builder->add('types', EntityType::class, [
|
||||||
'choices' => $this->activityTypeRepository->findAllActive(),
|
'choices' => $this->activityTypeRepository->findAllActive(),
|
||||||
'class' => ActivityType::class,
|
'class' => ActivityType::class,
|
||||||
'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '')
|
'choice_label' => fn (ActivityType $aty) => ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()).' > ' : '')
|
||||||
.
|
.
|
||||||
$this->translatableStringHelper->localize($aty->getName()),
|
$this->translatableStringHelper->localize($aty->getName()),
|
||||||
'group_by' => function (ActivityType $type) {
|
'group_by' => function (ActivityType $type) {
|
||||||
@ -71,6 +69,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -96,7 +95,7 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter
|
|||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
if (null === $data['types'] || count($data['types']) === 0) {
|
if (null === $data['types'] || 0 === \count($data['types'])) {
|
||||||
$context
|
$context
|
||||||
->buildViolation('At least one type must be chosen')
|
->buildViolation('At least one type must be chosen')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
@ -32,8 +32,8 @@ class ActivityUsersFilter implements FilterInterface
|
|||||||
$orX = $qb->expr()->orX();
|
$orX = $qb->expr()->orX();
|
||||||
|
|
||||||
foreach ($data['accepted_users'] as $key => $user) {
|
foreach ($data['accepted_users'] as $key => $user) {
|
||||||
$orX->add($qb->expr()->isMemberOf(':activity_users_filter_u' . $key, 'activity.users'));
|
$orX->add($qb->expr()->isMemberOf(':activity_users_filter_u'.$key, 'activity.users'));
|
||||||
$qb->setParameter('activity_users_filter_u' . $key, $user);
|
$qb->setParameter('activity_users_filter_u'.$key, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->andWhere($orX);
|
$qb->andWhere($orX);
|
||||||
@ -51,6 +51,7 @@ class ActivityUsersFilter implements FilterInterface
|
|||||||
'label' => 'Users',
|
'label' => 'Users',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -47,6 +47,7 @@ class ByCreatorFilter implements FilterInterface
|
|||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -65,6 +65,7 @@ class EmergencyFilter implements FilterInterface
|
|||||||
'empty_data' => self::DEFAULT_CHOICE,
|
'empty_data' => self::DEFAULT_CHOICE,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return ['accepted_emergency' => self::DEFAULT_CHOICE];
|
return ['accepted_emergency' => self::DEFAULT_CHOICE];
|
||||||
|
@ -14,7 +14,6 @@ namespace Chill\ActivityBundle\Export\Filter;
|
|||||||
use Chill\ActivityBundle\Export\Declarations;
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Form\Type\PickUserLocationType;
|
use Chill\MainBundle\Form\Type\PickUserLocationType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
@ -46,6 +45,7 @@ class LocationFilter implements FilterInterface
|
|||||||
'label' => 'pick location',
|
'label' => 'pick location',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -18,7 +18,6 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|||||||
use Doctrine\ORM\Query\Expr\Andx;
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class LocationTypeFilter implements FilterInterface
|
class LocationTypeFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
@ -31,7 +30,7 @@ class LocationTypeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
if (!\in_array('actloc', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.location', 'actloc');
|
$qb->join('activity.location', 'actloc');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,9 +56,10 @@ class LocationTypeFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$builder->add('accepted_locationtype', PickLocationTypeType::class, [
|
$builder->add('accepted_locationtype', PickLocationTypeType::class, [
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
//'label' => false,
|
// 'label' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -17,16 +17,12 @@ use Chill\ActivityBundle\Repository\ActivityReasonRepository;
|
|||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
use function count;
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInterface
|
class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInterface
|
||||||
{
|
{
|
||||||
public function __construct(protected TranslatableStringHelper $translatableStringHelper, protected ActivityReasonRepository $activityReasonRepository) {}
|
public function __construct(protected TranslatableStringHelper $translatableStringHelper, protected ActivityReasonRepository $activityReasonRepository) {}
|
||||||
@ -42,7 +38,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
|
|||||||
$join = $qb->getDQLPart('join');
|
$join = $qb->getDQLPart('join');
|
||||||
$clause = $qb->expr()->in('actreasons', ':selected_activity_reasons');
|
$clause = $qb->expr()->in('actreasons', ':selected_activity_reasons');
|
||||||
|
|
||||||
if (!in_array('actreasons', $qb->getAllAliases(), true)) {
|
if (!\in_array('actreasons', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.reasons', 'actreasons');
|
$qb->join('activity.reasons', 'actreasons');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +68,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
|
|||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
@ -81,7 +78,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
|
|||||||
{
|
{
|
||||||
// collect all the reasons'name used in this filter in one array
|
// collect all the reasons'name used in this filter in one array
|
||||||
$reasonsNames = array_map(
|
$reasonsNames = array_map(
|
||||||
fn (ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
|
fn (ActivityReason $r): string => '"'.$this->translatableStringHelper->localize($r->getName()).'"',
|
||||||
$this->activityReasonRepository->findBy(['id' => $data['reasons']->toArray()])
|
$this->activityReasonRepository->findBy(['id' => $data['reasons']->toArray()])
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -100,7 +97,7 @@ class ActivityReasonFilter implements ExportElementValidatedInterface, FilterInt
|
|||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
if (null === $data['reasons'] || count($data['reasons']) === 0) {
|
if (null === $data['reasons'] || 0 === \count($data['reasons'])) {
|
||||||
$context
|
$context
|
||||||
->buildViolation('At least one reason must be chosen')
|
->buildViolation('At least one reason must be chosen')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
|
@ -49,11 +49,11 @@ final readonly class PersonHavingActivityBetweenDateFilter implements ExportElem
|
|||||||
|
|
||||||
// add clause between date
|
// add clause between date
|
||||||
$sqb->where('activity_person_having_activity.date BETWEEN '
|
$sqb->where('activity_person_having_activity.date BETWEEN '
|
||||||
. ':person_having_activity_between_date_from'
|
.':person_having_activity_between_date_from'
|
||||||
. ' AND '
|
.' AND '
|
||||||
. ':person_having_activity_between_date_to'
|
.':person_having_activity_between_date_to'
|
||||||
. ' AND '
|
.' AND '
|
||||||
. '(person_person_having_activity.id = person.id OR person MEMBER OF activity_person_having_activity.persons)');
|
.'(person_person_having_activity.id = person.id OR person MEMBER OF activity_person_having_activity.persons)');
|
||||||
|
|
||||||
if (isset($data['reasons']) && [] !== $data['reasons']) {
|
if (isset($data['reasons']) && [] !== $data['reasons']) {
|
||||||
// add clause activity reason
|
// add clause activity reason
|
||||||
@ -111,6 +111,7 @@ final readonly class PersonHavingActivityBetweenDateFilter implements ExportElem
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -132,7 +133,7 @@ final readonly class PersonHavingActivityBetweenDateFilter implements ExportElem
|
|||||||
'reasons' => implode(
|
'reasons' => implode(
|
||||||
', ',
|
', ',
|
||||||
array_map(
|
array_map(
|
||||||
fn (ActivityReason $r): string => '"' . $this->translatableStringHelper->localize($r->getName()) . '"',
|
fn (ActivityReason $r): string => '"'.$this->translatableStringHelper->localize($r->getName()).'"',
|
||||||
$data['reasons']
|
$data['reasons']
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -66,6 +66,7 @@ class SentReceivedFilter implements FilterInterface
|
|||||||
'empty_data' => self::DEFAULT_CHOICE,
|
'empty_data' => self::DEFAULT_CHOICE,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return ['accepted_sentreceived' => self::DEFAULT_CHOICE];
|
return ['accepted_sentreceived' => self::DEFAULT_CHOICE];
|
||||||
|
@ -56,6 +56,7 @@ class UserFilter implements FilterInterface
|
|||||||
'label' => 'Creators',
|
'label' => 'Creators',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -39,7 +39,7 @@ class UserScopeFilter implements FilterInterface
|
|||||||
$p = self::PREFIX;
|
$p = self::PREFIX;
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->leftJoin("activity.user", "{$p}_user") // createdBy ? cfr translation
|
->leftJoin('activity.user', "{$p}_user") // createdBy ? cfr translation
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
UserScopeHistory::class,
|
UserScopeHistory::class,
|
||||||
"{$p}_history",
|
"{$p}_history",
|
||||||
@ -49,10 +49,10 @@ class UserScopeFilter implements FilterInterface
|
|||||||
// scope_at based on activity.date
|
// scope_at based on activity.date
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->lte("{$p}_history.startDate", "activity.date"),
|
$qb->expr()->lte("{$p}_history.startDate", 'activity.date'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||||
$qb->expr()->gt("{$p}_history.endDate", "activity.date")
|
$qb->expr()->gt("{$p}_history.endDate", 'activity.date')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -61,7 +61,7 @@ class UserScopeFilter implements FilterInterface
|
|||||||
)
|
)
|
||||||
->setParameter(
|
->setParameter(
|
||||||
"{$p}_scopes",
|
"{$p}_scopes",
|
||||||
$data["scopes"],
|
$data['scopes'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,19 +41,19 @@ class UsersJobFilter implements FilterInterface
|
|||||||
$qb
|
$qb
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
"SELECT 1 FROM " . Activity::class . " {$p}_act "
|
'SELECT 1 FROM '.Activity::class." {$p}_act "
|
||||||
. "JOIN {$p}_act.users {$p}_user "
|
."JOIN {$p}_act.users {$p}_user "
|
||||||
. "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
.'JOIN '.UserJobHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||||
. "WHERE {$p}_act = activity "
|
."WHERE {$p}_act = activity "
|
||||||
// job_at based on activity.date
|
// job_at based on activity.date
|
||||||
. "AND {$p}_history.startDate <= activity.date "
|
."AND {$p}_history.startDate <= activity.date "
|
||||||
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) "
|
."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) "
|
||||||
. "AND {$p}_history.job IN ( :{$p}_jobs )"
|
."AND {$p}_history.job IN ( :{$p}_jobs )"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameter(
|
->setParameter(
|
||||||
"{$p}_jobs",
|
"{$p}_jobs",
|
||||||
$data["jobs"]
|
$data['jobs']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,19 +43,19 @@ class UsersScopeFilter implements FilterInterface
|
|||||||
$qb
|
$qb
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
"SELECT 1 FROM " . Activity::class . " {$p}_act "
|
'SELECT 1 FROM '.Activity::class." {$p}_act "
|
||||||
. "JOIN {$p}_act.users {$p}_user "
|
."JOIN {$p}_act.users {$p}_user "
|
||||||
. "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
.'JOIN '.UserScopeHistory::class." {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||||
. "WHERE {$p}_act = activity "
|
."WHERE {$p}_act = activity "
|
||||||
// scope_at based on activity.date
|
// scope_at based on activity.date
|
||||||
. "AND {$p}_history.startDate <= activity.date "
|
."AND {$p}_history.startDate <= activity.date "
|
||||||
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) "
|
."AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > activity.date) "
|
||||||
. "AND {$p}_history.scope IN ( :{$p}_scopes )"
|
."AND {$p}_history.scope IN ( :{$p}_scopes )"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameter(
|
->setParameter(
|
||||||
"{$p}_scopes",
|
"{$p}_scopes",
|
||||||
$data["scopes"]
|
$data['scopes']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,8 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|||||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use DateInterval;
|
|
||||||
use DateTime;
|
|
||||||
use DateTimeZone;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
@ -53,8 +49,6 @@ use Symfony\Component\Form\FormEvents;
|
|||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ActivityType extends AbstractType
|
class ActivityType extends AbstractType
|
||||||
{
|
{
|
||||||
protected User $user;
|
protected User $user;
|
||||||
@ -69,7 +63,7 @@ class ActivityType extends AbstractType
|
|||||||
protected SocialActionRender $socialActionRender
|
protected SocialActionRender $socialActionRender
|
||||||
) {
|
) {
|
||||||
if (!$tokenStorage->getToken()->getUser() instanceof User) {
|
if (!$tokenStorage->getToken()->getUser() instanceof User) {
|
||||||
throw new RuntimeException('you should have a valid user');
|
throw new \RuntimeException('you should have a valid user');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
@ -102,16 +96,16 @@ class ActivityType extends AbstractType
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var ? \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod */
|
/** @var \Chill\PersonBundle\Entity\AccompanyingPeriod|null $accompanyingPeriod */
|
||||||
$accompanyingPeriod = null;
|
$accompanyingPeriod = null;
|
||||||
|
|
||||||
if ($options['accompanyingPeriod'] instanceof AccompanyingPeriod) {
|
if ($options['accompanyingPeriod'] instanceof AccompanyingPeriod) {
|
||||||
$accompanyingPeriod = $options['accompanyingPeriod'];
|
$accompanyingPeriod = $options['accompanyingPeriod'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
|
if ($activityType->isVisible('socialIssues') && null !== $accompanyingPeriod) {
|
||||||
$builder->add('socialIssues', HiddenType::class, [
|
$builder->add('socialIssues', HiddenType::class, [
|
||||||
'required' => $activityType->getSocialIssuesVisible() === 2,
|
'required' => 2 === $activityType->getSocialIssuesVisible(),
|
||||||
]);
|
]);
|
||||||
$builder->get('socialIssues')
|
$builder->get('socialIssues')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
@ -137,9 +131,9 @@ class ActivityType extends AbstractType
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
|
if ($activityType->isVisible('socialActions') && null !== $accompanyingPeriod) {
|
||||||
$builder->add('socialActions', HiddenType::class, [
|
$builder->add('socialActions', HiddenType::class, [
|
||||||
'required' => $activityType->getSocialActionsVisible() === 2,
|
'required' => 2 === $activityType->getSocialActionsVisible(),
|
||||||
]);
|
]);
|
||||||
$builder->get('socialActions')
|
$builder->get('socialActions')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
@ -323,7 +317,7 @@ class ActivityType extends AbstractType
|
|||||||
|
|
||||||
if ($activityType->isVisible('location')) {
|
if ($activityType->isVisible('location')) {
|
||||||
$builder->add('location', HiddenType::class, [
|
$builder->add('location', HiddenType::class, [
|
||||||
'required' => $activityType->getLocationVisible() === 2,
|
'required' => 2 === $activityType->getLocationVisible(),
|
||||||
])
|
])
|
||||||
->get('location')
|
->get('location')
|
||||||
->addModelTransformer(new CallbackTransformer(
|
->addModelTransformer(new CallbackTransformer(
|
||||||
@ -374,16 +368,16 @@ class ActivityType extends AbstractType
|
|||||||
) {
|
) {
|
||||||
// set the timezone to GMT, and fix the difference between current and GMT
|
// set the timezone to GMT, and fix the difference between current and GMT
|
||||||
// the datetimetransformer will then handle timezone as GMT
|
// the datetimetransformer will then handle timezone as GMT
|
||||||
$timezoneUTC = new DateTimeZone('GMT');
|
$timezoneUTC = new \DateTimeZone('GMT');
|
||||||
/** @var DateTime $data */
|
/** @var \DateTime $data */
|
||||||
$data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300');
|
$data = $formEvent->getData() ?? \DateTime::createFromFormat('U', '300');
|
||||||
$seconds = $data->getTimezone()->getOffset($data);
|
$seconds = $data->getTimezone()->getOffset($data);
|
||||||
$data->setTimeZone($timezoneUTC);
|
$data->setTimeZone($timezoneUTC);
|
||||||
$data->add(new DateInterval('PT' . $seconds . 'S'));
|
$data->add(new \DateInterval('PT'.$seconds.'S'));
|
||||||
|
|
||||||
// test if the timestamp is in the choices.
|
// test if the timestamp is in the choices.
|
||||||
// If not, recreate the field with the new timestamp
|
// If not, recreate the field with the new timestamp
|
||||||
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
|
if (!\in_array($data->getTimestamp(), $timeChoices, true)) {
|
||||||
// the data are not in the possible values. add them
|
// the data are not in the possible values. add them
|
||||||
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
||||||
$form = $builder->create($fieldName, ChoiceType::class, array_merge(
|
$form = $builder->create($fieldName, ChoiceType::class, array_merge(
|
||||||
|
@ -56,8 +56,8 @@ class ActivityTypeType extends AbstractType
|
|||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$builder
|
$builder
|
||||||
->add($field . 'Visible', ActivityFieldPresence::class)
|
->add($field.'Visible', ActivityFieldPresence::class)
|
||||||
->add($field . 'Label', TextType::class, [
|
->add($field.'Label', TextType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'empty_data' => '',
|
'empty_data' => '',
|
||||||
]);
|
]);
|
||||||
|
@ -31,7 +31,7 @@ class TranslatableActivityReasonCategoryType extends AbstractType
|
|||||||
[
|
[
|
||||||
'class' => ActivityReasonCategory::class,
|
'class' => ActivityReasonCategory::class,
|
||||||
'choice_label' => fn (ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName())
|
'choice_label' => fn (ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName())
|
||||||
. (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''),
|
.(!$category->getActive() ? ' ('.$this->translator->trans('inactive').')' : ''),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,6 @@ final readonly class ActivityNotificationHandler implements NotificationHandlerI
|
|||||||
|
|
||||||
public function supports(Notification $notification, array $options = []): bool
|
public function supports(Notification $notification, array $options = []): bool
|
||||||
{
|
{
|
||||||
return $notification->getRelatedEntityClass() === Activity::class;
|
return Activity::class === $notification->getRelatedEntityClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,6 @@ use Doctrine\ORM\QueryBuilder;
|
|||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
use function count;
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface
|
final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepositoryInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@ -75,7 +72,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
return $qb->getQuery()->getSingleScalarResult();
|
return $qb->getQuery()->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array
|
public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array
|
||||||
{
|
{
|
||||||
$qb = $this->buildBaseQuery($filters);
|
$qb = $this->buildBaseQuery($filters);
|
||||||
@ -83,7 +79,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
$qb->andWhere('a.accompanyingPeriod = :period')->setParameter('period', $period);
|
$qb->andWhere('a.accompanyingPeriod = :period')->setParameter('period', $period);
|
||||||
|
|
||||||
foreach ($orderBy as $field => $order) {
|
foreach ($orderBy as $field => $order) {
|
||||||
$qb->addOrderBy('a.' . $field, $order);
|
$qb->addOrderBy('a.'.$field, $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $start) {
|
if (null !== $start) {
|
||||||
@ -124,25 +120,25 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
sprintf(
|
sprintf(
|
||||||
"SELECT 1 FROM %s ujh_creator WHERE ujh_creator.user = a.createdBy "
|
'SELECT 1 FROM %s ujh_creator WHERE ujh_creator.user = a.createdBy '
|
||||||
. "AND ujh_creator.job IN (:jobs) AND a.createdAt > ujh_creator.startDate "
|
.'AND ujh_creator.job IN (:jobs) AND a.createdAt > ujh_creator.startDate '
|
||||||
. "AND (ujh_creator.endDate IS NULL or ujh_creator.endDate > a.date)",
|
.'AND (ujh_creator.endDate IS NULL or ujh_creator.endDate > a.date)',
|
||||||
User\UserJobHistory::class
|
User\UserJobHistory::class
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
sprintf(
|
sprintf(
|
||||||
"SELECT 1 FROM %s ujh_u WHERE ujh_u.user = a.user "
|
'SELECT 1 FROM %s ujh_u WHERE ujh_u.user = a.user '
|
||||||
. "AND ujh_u.job IN (:jobs) AND a.createdAt > ujh_u.startDate "
|
.'AND ujh_u.job IN (:jobs) AND a.createdAt > ujh_u.startDate '
|
||||||
. "AND (ujh_u.endDate IS NULL or ujh_u.endDate > a.date)",
|
.'AND (ujh_u.endDate IS NULL or ujh_u.endDate > a.date)',
|
||||||
User\UserJobHistory::class
|
User\UserJobHistory::class
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
sprintf(
|
sprintf(
|
||||||
"SELECT 1 FROM %s ujh_users WHERE ujh_users.user MEMBER OF a.users "
|
'SELECT 1 FROM %s ujh_users WHERE ujh_users.user MEMBER OF a.users '
|
||||||
. "AND ujh_users.job IN (:jobs) AND a.createdAt > ujh_users.startDate "
|
.'AND ujh_users.job IN (:jobs) AND a.createdAt > ujh_users.startDate '
|
||||||
. "AND (ujh_users.endDate IS NULL or ujh_users.endDate > a.date)",
|
.'AND (ujh_users.endDate IS NULL or ujh_users.endDate > a.date)',
|
||||||
User\UserJobHistory::class
|
User\UserJobHistory::class
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -163,7 +159,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AccompanyingPeriod|Person $associated
|
|
||||||
* @return array<ActivityType>
|
* @return array<ActivityType>
|
||||||
*/
|
*/
|
||||||
public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array
|
public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array
|
||||||
@ -225,7 +220,6 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
return $qb->getQuery()->getResult();
|
return $qb->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function findByAccompanyingPeriodSimplified(AccompanyingPeriod $period, ?int $limit = 1000): array
|
public function findByAccompanyingPeriodSimplified(AccompanyingPeriod $period, ?int $limit = 1000): array
|
||||||
{
|
{
|
||||||
$rsm = new ResultSetMappingBuilder($this->em);
|
$rsm = new ResultSetMappingBuilder($this->em);
|
||||||
@ -313,7 +307,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
$qb = $this->filterBaseQueryByPerson($qb, $person, $role);
|
$qb = $this->filterBaseQueryByPerson($qb, $person, $role);
|
||||||
|
|
||||||
foreach ($orderBy as $field => $direction) {
|
foreach ($orderBy as $field => $direction) {
|
||||||
$qb->addOrderBy('a.' . $field, $direction);
|
$qb->addOrderBy('a.'.$field, $direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $start) {
|
if (null !== $start) {
|
||||||
@ -340,7 +334,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
$orX->add(sprintf('a.person = :person AND a.scope IN (:scopes_%d)', $counter));
|
$orX->add(sprintf('a.person = :person AND a.scope IN (:scopes_%d)', $counter));
|
||||||
$qb->setParameter(sprintf('scopes_%d', $counter), $scopes);
|
$qb->setParameter(sprintf('scopes_%d', $counter), $scopes);
|
||||||
$qb->setParameter('person', $person);
|
$qb->setParameter('person', $person);
|
||||||
$counter++;
|
++$counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($person->getAccompanyingPeriodParticipations() as $participation) {
|
foreach ($person->getAccompanyingPeriodParticipations() as $participation) {
|
||||||
@ -363,7 +357,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
->setParameter(sprintf('participation_end_%d', $counter), $participation->getEndDate());
|
->setParameter(sprintf('participation_end_%d', $counter), $participation->getEndDate());
|
||||||
}
|
}
|
||||||
$orX->add($and);
|
$orX->add($and);
|
||||||
$counter++;
|
++$counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 === $orX->count()) {
|
if (0 === $orX->count()) {
|
||||||
@ -384,10 +378,10 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $metadataActivity->getTableName()
|
'id' => $metadataActivity->getTableName()
|
||||||
. '.' . $metadataActivity->getColumnName('id'),
|
.'.'.$metadataActivity->getColumnName('id'),
|
||||||
'type' => 'activity',
|
'type' => 'activity',
|
||||||
'date' => $metadataActivity->getTableName()
|
'date' => $metadataActivity->getTableName()
|
||||||
. '.' . $metadataActivity->getColumnName('date'),
|
.'.'.$metadataActivity->getColumnName('date'),
|
||||||
'FROM' => $from,
|
'FROM' => $from,
|
||||||
'WHERE' => $where,
|
'WHERE' => $where,
|
||||||
'parameters' => $parameters,
|
'parameters' => $parameters,
|
||||||
@ -400,12 +394,12 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||||
|
|
||||||
return $metadataActivity->getTableName() . ' JOIN '
|
return $metadataActivity->getTableName().' JOIN '
|
||||||
. $metadataPerson->getTableName() . ' ON '
|
.$metadataPerson->getTableName().' ON '
|
||||||
. $metadataPerson->getTableName() . '.' .
|
.$metadataPerson->getTableName().'.'.
|
||||||
$associationMapping['joinColumns'][0]['referencedColumnName']
|
$associationMapping['joinColumns'][0]['referencedColumnName']
|
||||||
. ' = '
|
.' = '
|
||||||
. $associationMapping['joinColumns'][0]['name'];
|
.$associationMapping['joinColumns'][0]['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getWhereClause(string $context, array $args): array
|
private function getWhereClause(string $context, array $args): array
|
||||||
@ -424,7 +418,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
ActivityVoter::SEE
|
ActivityVoter::SEE
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($reachableCenters) === 0) {
|
if (0 === \count($reachableCenters)) {
|
||||||
// insert a dummy condition
|
// insert a dummy condition
|
||||||
return 'FALSE = TRUE';
|
return 'FALSE = TRUE';
|
||||||
}
|
}
|
||||||
@ -441,7 +435,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
|
|
||||||
foreach ($reachableCenters as $center) {
|
foreach ($reachableCenters as $center) {
|
||||||
// we pass if not in centers
|
// we pass if not in centers
|
||||||
if (!in_array($center, $args['centers'], true)) {
|
if (!\in_array($center, $args['centers'], true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// we get all the reachable scopes for this center
|
// we get all the reachable scopes for this center
|
||||||
@ -463,7 +457,7 @@ final readonly class ActivityACLAwareRepository implements ActivityACLAwareRepos
|
|||||||
|
|
||||||
// begin loop for scopes
|
// begin loop for scopes
|
||||||
$where .= ' AND (';
|
$where .= ' AND (';
|
||||||
$scopesI = 0; //like scope#i
|
$scopesI = 0; // like scope#i
|
||||||
|
|
||||||
foreach ($reachablesScopesId as $scopeId) {
|
foreach ($reachablesScopesId as $scopeId) {
|
||||||
if (0 < $scopesI) {
|
if (0 < $scopesI) {
|
||||||
|
@ -22,8 +22,8 @@ interface ActivityACLAwareRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* Return all the activities associated to an accompanying period and that the user is allowed to apply the given role.
|
* Return all the activities associated to an accompanying period and that the user is allowed to apply the given role.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param array{my_activities?: bool, types?: array<ActivityType>, jobs?: array<UserJob>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
* @param array{my_activities?: bool, types?: array<ActivityType>, jobs?: array<UserJob>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
||||||
|
*
|
||||||
* @return array<Activity>
|
* @return array<Activity>
|
||||||
*/
|
*/
|
||||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array;
|
public function findByAccompanyingPeriod(AccompanyingPeriod $period, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array;
|
||||||
@ -49,20 +49,20 @@ interface ActivityACLAwareRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{my_activities?: bool, types?: array<ActivityType>, jobs?: array<UserJob>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
* @param array{my_activities?: bool, types?: array<ActivityType>, jobs?: array<UserJob>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
||||||
|
*
|
||||||
* @return array<Activity>
|
* @return array<Activity>
|
||||||
*/
|
*/
|
||||||
public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array;
|
public function findByPerson(Person $person, string $role, ?int $start = 0, ?int $limit = 1000, array $orderBy = ['date' => 'DESC'], array $filters = []): array;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of the type for the activities associated to person or accompanying period
|
* Return a list of the type for the activities associated to person or accompanying period.
|
||||||
*
|
*
|
||||||
* @return array<ActivityType>
|
* @return array<ActivityType>
|
||||||
*/
|
*/
|
||||||
public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array;
|
public function findActivityTypeByAssociated(AccompanyingPeriod|Person $associated): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of the user job for the activities associated to person or accompanying period
|
* Return a list of the user job for the activities associated to person or accompanying period.
|
||||||
*
|
*
|
||||||
* Associated mean the job:
|
* Associated mean the job:
|
||||||
* - of the creator;
|
* - of the creator;
|
||||||
|
@ -15,25 +15,15 @@ use Chill\ActivityBundle\Entity\Activity;
|
|||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
use Chill\ActivityBundle\Service\GenericDoc\Providers\AccompanyingPeriodActivityGenericDocProvider;
|
use Chill\ActivityBundle\Service\GenericDoc\Providers\AccompanyingPeriodActivityGenericDocProvider;
|
||||||
use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocProvider;
|
use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocProvider;
|
||||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
|
||||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\DocStoreBundle\GenericDoc\FetchQuery;
|
use Chill\DocStoreBundle\GenericDoc\FetchQuery;
|
||||||
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
||||||
use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider;
|
|
||||||
use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
|
|
||||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Mapping\MappingException;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
final readonly class ActivityDocumentACLAwareRepository implements ActivityDocumentACLAwareRepositoryInterface
|
final readonly class ActivityDocumentACLAwareRepository implements ActivityDocumentACLAwareRepositoryInterface
|
||||||
@ -45,14 +35,14 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum
|
|||||||
private Security $security
|
private Security $security
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface
|
public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface
|
||||||
{
|
{
|
||||||
$query = $this->buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext($person, $startDate, $endDate, $content);
|
$query = $this->buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext($person, $startDate, $endDate, $content);
|
||||||
|
|
||||||
return $this->addFetchQueryByPersonACL($query, $person);
|
return $this->addFetchQueryByPersonACL($query, $person);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
|
public function buildBaseFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
|
||||||
{
|
{
|
||||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||||
$activityMetadata = $this->em->getClassMetadata(Activity::class);
|
$activityMetadata = $this->em->getClassMetadata(Activity::class);
|
||||||
@ -81,7 +71,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum
|
|||||||
return $this->addWhereClauses($query, $startDate, $endDate, $content);
|
return $this->addWhereClauses($query, $startDate, $endDate, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
|
public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
|
||||||
{
|
{
|
||||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||||
$activityMetadata = $this->em->getClassMetadata(Activity::class);
|
$activityMetadata = $this->em->getClassMetadata(Activity::class);
|
||||||
@ -116,8 +106,8 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum
|
|||||||
$storedObjectMetadata->getColumnName('createdAt')
|
$storedObjectMetadata->getColumnName('createdAt')
|
||||||
);
|
);
|
||||||
$orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(),
|
$orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(),
|
||||||
DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
\DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
||||||
null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
null === $participation->getEndDate() ? null : \DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
||||||
$orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE];
|
$orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +122,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum
|
|||||||
return $this->addWhereClauses($query, $startDate, $endDate, $content);
|
return $this->addWhereClauses($query, $startDate, $endDate, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addWhereClauses(FetchQuery $query, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
|
private function addWhereClauses(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
|
||||||
{
|
{
|
||||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||||
|
|
||||||
@ -155,7 +145,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum
|
|||||||
if (null !== $content and '' !== $content) {
|
if (null !== $content and '' !== $content) {
|
||||||
$query->addWhereClause(
|
$query->addWhereClause(
|
||||||
'stored_obj.title ilike ?',
|
'stored_obj.title ilike ?',
|
||||||
['%' . $content . '%'],
|
['%'.$content.'%'],
|
||||||
[Types::STRING]
|
[Types::STRING]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -172,7 +162,7 @@ final readonly class ActivityDocumentACLAwareRepository implements ActivityDocum
|
|||||||
foreach ($this->centerResolverManager->resolveCenters($person) as $center) {
|
foreach ($this->centerResolverManager->resolveCenters($person) as $center) {
|
||||||
$reachableScopes = [
|
$reachableScopes = [
|
||||||
...$reachableScopes,
|
...$reachableScopes,
|
||||||
...$this->authorizationHelperForCurrentUser->getReachableScopes(ActivityVoter::SEE, $center)
|
...$this->authorizationHelperForCurrentUser->getReachableScopes(ActivityVoter::SEE, $center),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,24 +14,23 @@ namespace Chill\ActivityBundle\Repository;
|
|||||||
use Chill\DocStoreBundle\GenericDoc\FetchQuery;
|
use Chill\DocStoreBundle\GenericDoc\FetchQuery;
|
||||||
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTimeImmutable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives queries usable for fetching documents, with ACL aware
|
* Gives queries usable for fetching documents, with ACL aware.
|
||||||
*/
|
*/
|
||||||
interface ActivityDocumentACLAwareRepositoryInterface
|
interface ActivityDocumentACLAwareRepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return a fetch query for querying document's activities for a person
|
* Return a fetch query for querying document's activities for a person.
|
||||||
*
|
*
|
||||||
* This method must check the rights to see a document: the user must be allowed to see the given activities
|
* This method must check the rights to see a document: the user must be allowed to see the given activities
|
||||||
*/
|
*/
|
||||||
public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQueryInterface;
|
public function buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQueryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a fetch query for querying document's activities for an activity in accompanying periods, but for a given person
|
* Return a fetch query for querying document's activities for an activity in accompanying periods, but for a given person.
|
||||||
*
|
*
|
||||||
* This method must check the rights to see a document: the user must be allowed to see the given accompanying periods
|
* This method must check the rights to see a document: the user must be allowed to see the given accompanying periods
|
||||||
*/
|
*/
|
||||||
public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery;
|
public function buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class ActivityPresenceRepository implements ActivityPresenceRepositoryInterface
|
|||||||
return $this->repository->findAll();
|
return $this->repository->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||||
{
|
{
|
||||||
return $this->findBy($criteria, $orderBy, $limit, $offset);
|
return $this->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ interface ActivityPresenceRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @return array|ActivityPresence[]
|
* @return array|ActivityPresence[]
|
||||||
*/
|
*/
|
||||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array;
|
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array;
|
||||||
|
|
||||||
public function findOneBy(array $criteria): ?ActivityPresence;
|
public function findOneBy(array $criteria): ?ActivityPresence;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class ActivityRepository extends ServiceEntityRepository
|
|||||||
->setParameter('period', $period);
|
->setParameter('period', $period);
|
||||||
|
|
||||||
foreach ($orderBy as $k => $dir) {
|
foreach ($orderBy as $k => $dir) {
|
||||||
$qb->addOrderBy('a.' . $k, $dir);
|
$qb->addOrderBy('a.'.$k, $dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->setMaxResults($limit)->setFirstResult($offset);
|
$qb->setMaxResults($limit)->setFirstResult($offset);
|
||||||
@ -90,7 +90,7 @@ class ActivityRepository extends ServiceEntityRepository
|
|||||||
->setParameter('person', $person);
|
->setParameter('person', $person);
|
||||||
|
|
||||||
foreach ($orderBy as $k => $dir) {
|
foreach ($orderBy as $k => $dir) {
|
||||||
$qb->addOrderBy('a.' . $k, $dir);
|
$qb->addOrderBy('a.'.$k, $dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->setMaxResults($limit)->setFirstResult($offset);
|
$qb->setMaxResults($limit)->setFirstResult($offset);
|
||||||
|
@ -11,13 +11,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\ActivityBundle\Repository;
|
namespace Chill\ActivityBundle\Repository;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
|
||||||
|
|
||||||
final class ActivityTypeRepository implements ActivityTypeRepositoryInterface
|
final class ActivityTypeRepository implements ActivityTypeRepositoryInterface
|
||||||
{
|
{
|
||||||
@ -52,7 +48,7 @@ final class ActivityTypeRepository implements ActivityTypeRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @return array|ActivityType[]
|
* @return array|ActivityType[]
|
||||||
*/
|
*/
|
||||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||||
{
|
{
|
||||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Repository;
|
namespace Chill\ActivityBundle\Repository;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Doctrine\Persistence\ObjectRepository;
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
interface ActivityTypeRepositoryInterface extends ObjectRepository
|
interface ActivityTypeRepositoryInterface extends ObjectRepository
|
||||||
|
@ -21,12 +21,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -145,11 +142,11 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
|||||||
return $this->voterHelper->voteOnAttribute(self::CREATE_ACCOMPANYING_COURSE, $subject->getAccompanyingPeriod(), $token);
|
return $this->voterHelper->voteOnAttribute(self::CREATE_ACCOMPANYING_COURSE, $subject->getAccompanyingPeriod(), $token);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('Could not determine context of activity.');
|
throw new \RuntimeException('Could not determine context of activity.');
|
||||||
}
|
}
|
||||||
} elseif ($subject instanceof AccompanyingPeriod) {
|
} elseif ($subject instanceof AccompanyingPeriod) {
|
||||||
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
|
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
|
||||||
if (in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE], true)) {
|
if (\in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE], true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
|
|||||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||||
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
|
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
|
||||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\DocStoreBundle\Repository\DocumentCategoryRepository;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
@ -127,7 +126,7 @@ class ActivityContext implements
|
|||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'label' => $options[$key . 'Label'],
|
'label' => $options[$key.'Label'],
|
||||||
'placeholder' => $this->translator->trans('Any person selected'),
|
'placeholder' => $this->translator->trans('Any person selected'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -210,7 +209,7 @@ class ActivityContext implements
|
|||||||
if ($options['thirdParty']) {
|
if ($options['thirdParty']) {
|
||||||
$data['thirdParty'] = $this->normalizer->normalize($contextGenerationData['thirdParty'], 'docgen', [
|
$data['thirdParty'] = $this->normalizer->normalize($contextGenerationData['thirdParty'], 'docgen', [
|
||||||
'docgen:expects' => ThirdParty::class,
|
'docgen:expects' => ThirdParty::class,
|
||||||
'groups' => 'docgen:read'
|
'groups' => 'docgen:read',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +252,7 @@ class ActivityContext implements
|
|||||||
{
|
{
|
||||||
$options = $template->getOptions();
|
$options = $template->getOptions();
|
||||||
|
|
||||||
return $options['mainPerson'] || $options['person1'] || $options['person2'] || $options ['thirdParty'];
|
return $options['mainPerson'] || $options['person1'] || $options['person2'] || $options['thirdParty'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void
|
||||||
|
@ -32,13 +32,11 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
|||||||
use Chill\PersonBundle\Service\DocGenerator\AccompanyingPeriodContext;
|
use Chill\PersonBundle\Service\DocGenerator\AccompanyingPeriodContext;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||||
use DateTime;
|
|
||||||
use libphonenumber\PhoneNumber;
|
use libphonenumber\PhoneNumber;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @implements DocGeneratorContextWithPublicFormInterface<AccompanyingPeriod>
|
* @implements DocGeneratorContextWithPublicFormInterface<AccompanyingPeriod>
|
||||||
@ -122,7 +120,8 @@ class ListActivitiesByAccompanyingPeriodContext implements
|
|||||||
$activities,
|
$activities,
|
||||||
function ($activity) use ($user) {
|
function ($activity) use ($user) {
|
||||||
$activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []);
|
$activityUsernames = array_map(static fn ($user) => $user['username'], $activity['users'] ?? []);
|
||||||
return in_array($user->getUsername(), $activityUsernames, true);
|
|
||||||
|
return \in_array($user->getUsername(), $activityUsernames, true);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -139,7 +138,7 @@ class ListActivitiesByAccompanyingPeriodContext implements
|
|||||||
function ($work) use ($user) {
|
function ($work) use ($user) {
|
||||||
$workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []);
|
$workUsernames = array_map(static fn ($user) => $user['username'], $work['referrers'] ?? []);
|
||||||
|
|
||||||
return in_array($user->getUsername(), $workUsernames, true);
|
return \in_array($user->getUsername(), $workUsernames, true);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -163,6 +162,7 @@ class ListActivitiesByAccompanyingPeriodContext implements
|
|||||||
if ($myWorksOnly && isset($contextGenerationData['creator'])) {
|
if ($myWorksOnly && isset($contextGenerationData['creator'])) {
|
||||||
$data['course']['works'] = $this->filterWorksByUser($data['course']['works'], $contextGenerationData['creator']);
|
$data['course']['works'] = $this->filterWorksByUser($data['course']['works'], $contextGenerationData['creator']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ class ListActivitiesByAccompanyingPeriodContext implements
|
|||||||
$activity = $row[0];
|
$activity = $row[0];
|
||||||
|
|
||||||
$activity['date'] = $this->normalizer->normalize($activity['date'], 'docgen', [
|
$activity['date'] = $this->normalizer->normalize($activity['date'], 'docgen', [
|
||||||
AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => DateTime::class,
|
AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => \DateTime::class,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (null === $activity['location']) {
|
if (null === $activity['location']) {
|
||||||
@ -229,8 +229,8 @@ class ListActivitiesByAccompanyingPeriodContext implements
|
|||||||
$activity['location']['type'] = 'location';
|
$activity['location']['type'] = 'location';
|
||||||
|
|
||||||
foreach (['1', '2'] as $key) {
|
foreach (['1', '2'] as $key) {
|
||||||
$activity['location']['phonenumber' . $key] = $this->normalizer->normalize(
|
$activity['location']['phonenumber'.$key] = $this->normalizer->normalize(
|
||||||
$activity['location']['phonenumber' . $key],
|
$activity['location']['phonenumber'.$key],
|
||||||
'docgen',
|
'docgen',
|
||||||
[AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => PhoneNumber::class]
|
[AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => PhoneNumber::class]
|
||||||
);
|
);
|
||||||
|
@ -22,10 +22,8 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
|||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
use DateTimeImmutable;
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Mapping\MappingException;
|
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
final readonly class AccompanyingPeriodActivityGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface, GenericDocForPersonProviderInterface
|
final readonly class AccompanyingPeriodActivityGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface, GenericDocForPersonProviderInterface
|
||||||
@ -38,7 +36,7 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen
|
|||||||
private ActivityDocumentACLAwareRepositoryInterface $activityDocumentACLAwareRepository,
|
private ActivityDocumentACLAwareRepositoryInterface $activityDocumentACLAwareRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||||
{
|
{
|
||||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||||
$activityMetadata = $this->em->getClassMetadata(Activity::class);
|
$activityMetadata = $this->em->getClassMetadata(Activity::class);
|
||||||
@ -83,7 +81,7 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen
|
|||||||
if (null !== $content) {
|
if (null !== $content) {
|
||||||
$query->addWhereClause(
|
$query->addWhereClause(
|
||||||
'doc_obj.title ilike ?',
|
'doc_obj.title ilike ?',
|
||||||
['%' . $content . '%'],
|
['%'.$content.'%'],
|
||||||
[Types::STRING]
|
[Types::STRING]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -91,10 +89,6 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen
|
|||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param AccompanyingPeriod $accompanyingPeriod
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool
|
public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool
|
||||||
{
|
{
|
||||||
return $this->security->isGranted(ActivityVoter::SEE, $accompanyingPeriod);
|
return $this->security->isGranted(ActivityVoter::SEE, $accompanyingPeriod);
|
||||||
@ -105,7 +99,7 @@ final readonly class AccompanyingPeriodActivityGenericDocProvider implements Gen
|
|||||||
return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person);
|
return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||||
{
|
{
|
||||||
return $this->activityDocumentACLAwareRepository
|
return $this->activityDocumentACLAwareRepository
|
||||||
->buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext($person, $startDate, $endDate, $content);
|
->buildFetchQueryActivityDocumentLinkedToAccompanyingPeriodFromPersonContext($person, $startDate, $endDate, $content);
|
||||||
|
@ -11,15 +11,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\ActivityBundle\Service\GenericDoc\Providers;
|
namespace Chill\ActivityBundle\Service\GenericDoc\Providers;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepository;
|
|
||||||
use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepositoryInterface;
|
use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepositoryInterface;
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
||||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||||
use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTimeImmutable;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
final readonly class PersonActivityGenericDocProvider implements GenericDocForPersonProviderInterface
|
final readonly class PersonActivityGenericDocProvider implements GenericDocForPersonProviderInterface
|
||||||
@ -27,11 +23,11 @@ final readonly class PersonActivityGenericDocProvider implements GenericDocForPe
|
|||||||
public const KEY = 'person_activity_document';
|
public const KEY = 'person_activity_document';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private Security $security,
|
private Security $security,
|
||||||
private ActivityDocumentACLAwareRepositoryInterface $personActivityDocumentACLAwareRepository,
|
private ActivityDocumentACLAwareRepositoryInterface $personActivityDocumentACLAwareRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||||
{
|
{
|
||||||
return $this->personActivityDocumentACLAwareRepository->buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(
|
return $this->personActivityDocumentACLAwareRepository->buildFetchQueryActivityDocumentLinkedToPersonFromPersonContext(
|
||||||
$person,
|
$person,
|
||||||
@ -41,10 +37,6 @@ final readonly class PersonActivityGenericDocProvider implements GenericDocForPe
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Person $person
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isAllowedForPerson(Person $person): bool
|
public function isAllowedForPerson(Person $person): bool
|
||||||
{
|
{
|
||||||
return $this->security->isGranted(ActivityVoter::SEE, $person);
|
return $this->security->isGranted(ActivityVoter::SEE, $person);
|
||||||
|
@ -17,7 +17,6 @@ use Chill\ActivityBundle\Service\GenericDoc\Providers\PersonActivityGenericDocPr
|
|||||||
use Chill\DocStoreBundle\GenericDoc\GenericDocDTO;
|
use Chill\DocStoreBundle\GenericDoc\GenericDocDTO;
|
||||||
use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
|
use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
|
||||||
use Chill\DocStoreBundle\Repository\StoredObjectRepository;
|
use Chill\DocStoreBundle\Repository\StoredObjectRepository;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
|
|
||||||
final readonly class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface
|
final readonly class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface
|
||||||
{
|
{
|
||||||
@ -25,7 +24,7 @@ final readonly class AccompanyingPeriodActivityGenericDocRenderer implements Gen
|
|||||||
|
|
||||||
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
|
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
|
||||||
{
|
{
|
||||||
return $genericDocDTO->key === AccompanyingPeriodActivityGenericDocProvider::KEY || $genericDocDTO->key === PersonActivityGenericDocProvider::KEY;
|
return AccompanyingPeriodActivityGenericDocProvider::KEY === $genericDocDTO->key || PersonActivityGenericDocProvider::KEY === $genericDocDTO->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
|
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
|
||||||
|
@ -12,7 +12,6 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Templating\Entity;
|
namespace Chill\ActivityBundle\Templating\Entity;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
|
||||||
use Chill\MainBundle\Templating\Entity\BoxUtilsChillEntityRenderTrait;
|
use Chill\MainBundle\Templating\Entity\BoxUtilsChillEntityRenderTrait;
|
||||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
@ -38,21 +37,21 @@ class ActivityReasonRender implements ChillEntityRenderInterface
|
|||||||
public function renderBox($entity, array $options): string
|
public function renderBox($entity, array $options): string
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
$this->getDefaultOpeningBox('activity-reason') .
|
$this->getDefaultOpeningBox('activity-reason').
|
||||||
'<span class="badge bg-chill-pink">' .
|
'<span class="badge bg-chill-pink">'.
|
||||||
'<i class="fa fa-question-circle"></i> ' .
|
'<i class="fa fa-question-circle"></i> '.
|
||||||
'<span class="category">' .
|
'<span class="category">'.
|
||||||
$this->translatableStringHelper->localize(
|
$this->translatableStringHelper->localize(
|
||||||
$entity->getCategory()->getName()
|
$entity->getCategory()->getName()
|
||||||
) .
|
).
|
||||||
'</span>' .
|
'</span>'.
|
||||||
'<span class="separator"> > </span>' .
|
'<span class="separator"> > </span>'.
|
||||||
'<span class="reason">' .
|
'<span class="reason">'.
|
||||||
$this->translatableStringHelper->localize(
|
$this->translatableStringHelper->localize(
|
||||||
$entity->getName()
|
$entity->getName()
|
||||||
) .
|
).
|
||||||
'</span>' .
|
'</span>'.
|
||||||
'</span>' .
|
'</span>'.
|
||||||
$this->getDefaultClosingBox();
|
$this->getDefaultClosingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,10 +62,10 @@ class ActivityReasonRender implements ChillEntityRenderInterface
|
|||||||
if (null !== $entity->getCategory()) {
|
if (null !== $entity->getCategory()) {
|
||||||
$category = $this->translatableStringHelper->localize(
|
$category = $this->translatableStringHelper->localize(
|
||||||
$entity->getCategory()->getName()
|
$entity->getCategory()->getName()
|
||||||
) . ' > ';
|
).' > ';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $category .
|
return $category.
|
||||||
$this->translatableStringHelper->localize(
|
$this->translatableStringHelper->localize(
|
||||||
$entity->getName()
|
$entity->getName()
|
||||||
);
|
);
|
||||||
|
@ -12,14 +12,12 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Tests\Controller;
|
namespace Chill\ActivityBundle\Tests\Controller;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use function count;
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityControllerTest extends WebTestCase
|
final class ActivityControllerTest extends WebTestCase
|
||||||
@ -206,19 +204,19 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
$container = self::$kernel->getContainer();
|
$container = self::$kernel->getContainer();
|
||||||
$em = $container->get('doctrine.orm.entity_manager');
|
$em = $container->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
//get the social PermissionGroup, and remove CHILL_ACTIVITY_*
|
// get the social PermissionGroup, and remove CHILL_ACTIVITY_*
|
||||||
$socialPermissionGroup = $em
|
$socialPermissionGroup = $em
|
||||||
->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)
|
->getRepository(\Chill\MainBundle\Entity\PermissionsGroup::class)
|
||||||
->findOneByName('social');
|
->findOneByName('social');
|
||||||
$withoutActivityPermissionGroup = (new \Chill\MainBundle\Entity\PermissionsGroup())
|
$withoutActivityPermissionGroup = (new \Chill\MainBundle\Entity\PermissionsGroup())
|
||||||
->setName('social without activity');
|
->setName('social without activity');
|
||||||
//copy role scopes where ACTIVITY is not present
|
// copy role scopes where ACTIVITY is not present
|
||||||
foreach ($socialPermissionGroup->getRoleScopes() as $roleScope) {
|
foreach ($socialPermissionGroup->getRoleScopes() as $roleScope) {
|
||||||
if (!strpos((string) $roleScope->getRole(), 'ACTIVITY')) {
|
if (!strpos((string) $roleScope->getRole(), 'ACTIVITY')) {
|
||||||
$withoutActivityPermissionGroup->addRoleScope($roleScope);
|
$withoutActivityPermissionGroup->addRoleScope($roleScope);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//create groupCenter
|
// create groupCenter
|
||||||
$groupCenter = new \Chill\MainBundle\Entity\GroupCenter();
|
$groupCenter = new \Chill\MainBundle\Entity\GroupCenter();
|
||||||
$groupCenter->setCenter($em->getRepository(\Chill\MainBundle\Entity\Center::class)
|
$groupCenter->setCenter($em->getRepository(\Chill\MainBundle\Entity\Center::class)
|
||||||
->findOneBy(['name' => 'Center A']))
|
->findOneBy(['name' => 'Center A']))
|
||||||
@ -226,7 +224,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
$em->persist($withoutActivityPermissionGroup);
|
$em->persist($withoutActivityPermissionGroup);
|
||||||
$em->persist($groupCenter);
|
$em->persist($groupCenter);
|
||||||
|
|
||||||
//create user
|
// create user
|
||||||
$faker = \Faker\Factory::create();
|
$faker = \Faker\Factory::create();
|
||||||
$username = $faker->name;
|
$username = $faker->name;
|
||||||
$user = new \Chill\MainBundle\Entity\User();
|
$user = new \Chill\MainBundle\Entity\User();
|
||||||
@ -251,9 +249,8 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
$activities = $em->getRepository(\Chill\ActivityBundle\Entity\Activity::class)
|
$activities = $em->getRepository(\Chill\ActivityBundle\Entity\Activity::class)
|
||||||
->findBy(['person' => $person]);
|
->findBy(['person' => $person]);
|
||||||
|
|
||||||
if (count($activities) === 0) {
|
if (0 === \count($activities)) {
|
||||||
throw new RuntimeException('We need activities associated with this '
|
throw new \RuntimeException('We need activities associated with this person. Did you forget to add fixtures ?');
|
||||||
. 'person. Did you forget to add fixtures ?');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $activities;
|
return $activities;
|
||||||
@ -285,8 +282,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (null === $person) {
|
if (null === $person) {
|
||||||
throw new RuntimeException('We need a person with firstname Gérard and'
|
throw new \RuntimeException('We need a person with firstname Gérard and lastname Depardieu. Did you add fixtures ?');
|
||||||
. ' lastname Depardieu. Did you add fixtures ?');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $person;
|
return $person;
|
||||||
@ -306,7 +302,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
|
|
||||||
$reason = $reasons[array_rand($reasons)];
|
$reason = $reasons[array_rand($reasons)];
|
||||||
|
|
||||||
if (in_array($reason->getId(), $excludeIds, true)) {
|
if (\in_array($reason->getId(), $excludeIds, true)) {
|
||||||
return $this->getRandomActivityReason($excludeIds);
|
return $this->getRandomActivityReason($excludeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,8 +336,7 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
->findOneByUsername($username);
|
->findOneByUsername($username);
|
||||||
|
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
throw new RuntimeException("The user with username {$username} "
|
throw new \RuntimeException("The user with username {$username} ".'does not exists in database. Did you add fixtures ?');
|
||||||
. 'does not exists in database. Did you add fixtures ?');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$center = self::$kernel->getContainer()
|
$center = self::$kernel->getContainer()
|
||||||
@ -369,13 +364,12 @@ final class ActivityControllerTest extends WebTestCase
|
|||||||
array_map(static fn ($s) => $s->getId(), $reachableScopesUpdate)
|
array_map(static fn ($s) => $s->getId(), $reachableScopesUpdate)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($reachableScopesId) === 0) {
|
if (0 === \count($reachableScopesId)) {
|
||||||
throw new RuntimeException('there are not scope reachable for '
|
throw new \RuntimeException('there are not scope reachable for both CHILL_ACTIVITY_UPDATE and CHILL_ACTIVITY_DELETE');
|
||||||
. 'both CHILL_ACTIVITY_UPDATE and CHILL_ACTIVITY_DELETE');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($reachableScopesUpdate as $scope) {
|
foreach ($reachableScopesUpdate as $scope) {
|
||||||
if (in_array($scope->getId(), $reachableScopesId, true)) {
|
if (\in_array($scope->getId(), $reachableScopesId, true)) {
|
||||||
$reachableScopes[] = $scope;
|
$reachableScopes[] = $scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityReasonCategoryControllerTest extends WebTestCase
|
final class ActivityReasonCategoryControllerTest extends WebTestCase
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityReasonControllerTest extends WebTestCase
|
final class ActivityReasonControllerTest extends WebTestCase
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityTypeControllerTest extends WebTestCase
|
final class ActivityTypeControllerTest extends WebTestCase
|
||||||
|
@ -22,6 +22,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityTest extends TestCase
|
final class ActivityTest extends TestCase
|
||||||
|
@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class BySocialActionAggregatorTest extends AbstractAggregatorTest
|
final class BySocialActionAggregatorTest extends AbstractAggregatorTest
|
||||||
|
@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class BySocialIssueAggregatorTest extends AbstractAggregatorTest
|
final class BySocialIssueAggregatorTest extends AbstractAggregatorTest
|
||||||
|
@ -12,7 +12,6 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Tests\Export\Aggregator;
|
namespace Chill\ActivityBundle\Tests\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
|
||||||
use Chill\ActivityBundle\Export\Aggregator\ActivityTypeAggregator;
|
use Chill\ActivityBundle\Export\Aggregator\ActivityTypeAggregator;
|
||||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
@ -22,6 +21,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
|
|||||||
* Add tests for ActivityTypeAggregator.
|
* Add tests for ActivityTypeAggregator.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
final class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
||||||
|
@ -21,6 +21,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
|
|||||||
* Add tests for ActivityUsernAggregator.
|
* Add tests for ActivityUsernAggregator.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
final class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
||||||
|
@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest
|
final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest
|
||||||
|
@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class ByUserAggregatorTest extends AbstractAggregatorTest
|
final class ByUserAggregatorTest extends AbstractAggregatorTest
|
||||||
|
@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class CreatorScopeAggregatorTest extends AbstractAggregatorTest
|
final class CreatorScopeAggregatorTest extends AbstractAggregatorTest
|
||||||
|
@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
*
|
||||||
* @coversNothing
|
* @coversNothing
|
||||||
*/
|
*/
|
||||||
final class DateAggregatorTest extends AbstractAggregatorTest
|
final class DateAggregatorTest extends AbstractAggregatorTest
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user