mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'master' into 'issue428_person_resource_ameliorations'
# Conflicts: # CHANGELOG.md
This commit is contained in:
@@ -13,7 +13,9 @@ namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\MainBundle\Serializer\Model\Counter;
|
||||
use Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestionInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
@@ -23,8 +25,11 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
@@ -32,13 +37,14 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
|
||||
use function array_values;
|
||||
use function count;
|
||||
|
||||
@@ -46,6 +52,8 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
{
|
||||
private AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository;
|
||||
|
||||
private AccompanyingPeriodRepository $accompanyingPeriodRepository;
|
||||
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
private ReferralsSuggestionInterface $referralAvailable;
|
||||
@@ -55,17 +63,19 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
private ValidatorInterface $validator;
|
||||
|
||||
public function __construct(
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
ValidatorInterface $validator,
|
||||
Registry $registry,
|
||||
AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository,
|
||||
ReferralsSuggestionInterface $referralAvailable
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
ReferralsSuggestionInterface $referralAvailable,
|
||||
Registry $registry,
|
||||
ValidatorInterface $validator
|
||||
) {
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->validator = $validator;
|
||||
$this->registry = $registry;
|
||||
$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
|
||||
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->referralAvailable = $referralAvailable;
|
||||
$this->registry = $registry;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
public function commentApi($id, Request $request, string $_format): Response
|
||||
@@ -99,6 +109,57 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-course/list/by-recent-attributions")
|
||||
*/
|
||||
public function findMyRecentCourseAttribution(Request $request): JsonResponse
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||
$user = $this->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new AccessDeniedException();
|
||||
}
|
||||
|
||||
$since = (new DateTimeImmutable('now'))->sub(new DateInterval('P15D'));
|
||||
|
||||
$total = $this->accompanyingPeriodRepository->countByRecentUserHistory($user, $since);
|
||||
|
||||
if ($request->query->getBoolean('countOnly', false)) {
|
||||
return new JsonResponse(
|
||||
$this->getSerializer()->serialize(new Counter($total), 'json'),
|
||||
JsonResponse::HTTP_OK,
|
||||
[],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$paginator = $this->getPaginatorFactory()->create($total);
|
||||
|
||||
if (0 === $total) {
|
||||
return new JsonResponse(
|
||||
$this->getSerializer()->serialize(new Collection([], $paginator), 'json'),
|
||||
JsonResponse::HTTP_OK,
|
||||
[],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$courses = $this->accompanyingPeriodRepository->findByRecentUserHistory(
|
||||
$user,
|
||||
$since,
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
||||
return new JsonResponse(
|
||||
$this->getSerializer()->serialize(new Collection($courses, $paginator), 'json', ['groups' => ['read']]),
|
||||
JsonResponse::HTTP_OK,
|
||||
[],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ParamConverter("person", options={"id": "person_id"})
|
||||
*/
|
||||
|
@@ -12,10 +12,54 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\MainBundle\Serializer\Model\Counter;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class AccompanyingCourseWorkApiController extends ApiController
|
||||
{
|
||||
private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository;
|
||||
|
||||
public function __construct(AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository)
|
||||
{
|
||||
$this->accompanyingPeriodWorkRepository = $accompanyingPeriodWorkRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-period/work/my-near-end")
|
||||
*/
|
||||
public function myWorksNearEndDate(Request $request): JsonResponse
|
||||
{
|
||||
$since = (new DateTimeImmutable('now'))
|
||||
->sub(new DateInterval('P' . $request->query->getInt('since', 15) . 'D'));
|
||||
$until = (new DateTimeImmutable('now'))
|
||||
->add(new DateInterval('P' . $request->query->getInt('since', 15) . 'D'));
|
||||
$total = $this->accompanyingPeriodWorkRepository
|
||||
->countNearEndDateByUser($this->getUser(), $since, $until);
|
||||
|
||||
if ($request->query->getBoolean('countOnly', false)) {
|
||||
return $this->json(
|
||||
new Counter($total),
|
||||
JsonResponse::HTTP_OK,
|
||||
[],
|
||||
['groups' => ['read']]
|
||||
);
|
||||
}
|
||||
|
||||
$paginator = $this->getPaginatorFactory()->create($total);
|
||||
$works = $this->accompanyingPeriodWorkRepository
|
||||
->findNearEndDateByUser($this->getUser(), $since, $until, $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
|
||||
|
||||
$collection = new Collection($works, $paginator);
|
||||
|
||||
return $this->json($collection, 200, [], ['groups' => ['read']]);
|
||||
}
|
||||
|
||||
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
|
||||
{
|
||||
switch ($action) {
|
||||
|
@@ -15,11 +15,15 @@ use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\MainBundle\Serializer\Model\Counter;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
@@ -28,20 +32,28 @@ use function in_array;
|
||||
|
||||
class AccompanyingPeriodWorkEvaluationApiController
|
||||
{
|
||||
private AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository;
|
||||
|
||||
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private Security $security;
|
||||
|
||||
private SerializerInterface $serializer;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository,
|
||||
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
||||
SerializerInterface $serializer,
|
||||
PaginatorFactory $paginatorFactory
|
||||
PaginatorFactory $paginatorFactory,
|
||||
Security $security
|
||||
) {
|
||||
$this->accompanyingPeriodWorkEvaluationRepository = $accompanyingPeriodWorkEvaluationRepository;
|
||||
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
|
||||
$this->serializer = $serializer;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +88,39 @@ class AccompanyingPeriodWorkEvaluationApiController
|
||||
]
|
||||
), JsonResponse::HTTP_OK, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-period/work/evaluation/my-near-end")
|
||||
*/
|
||||
public function myWorksNearEndDate(Request $request): JsonResponse
|
||||
{
|
||||
$total = $this->accompanyingPeriodWorkEvaluationRepository
|
||||
->countNearMaxDateByUser($this->security->getUser());
|
||||
|
||||
if ($request->query->getBoolean('countOnly', false)) {
|
||||
return new JsonResponse(
|
||||
$this->serializer->serialize(new Counter($total), 'json', ['groups' => 'read']),
|
||||
JsonResponse::HTTP_OK,
|
||||
[],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
$works = $this->accompanyingPeriodWorkEvaluationRepository
|
||||
->findNearMaxDateByUser(
|
||||
$this->security->getUser(),
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
||||
$collection = new Collection($works, $paginator);
|
||||
|
||||
return new JsonResponse(
|
||||
$this->serializer->serialize($collection, 'json', ['groups' => 'read']),
|
||||
JsonResponse::HTTP_OK,
|
||||
[],
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\UserHistory;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\AccompanyingPeriodValidity;
|
||||
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap;
|
||||
@@ -338,6 +339,14 @@ class AccompanyingPeriod implements
|
||||
*/
|
||||
private ?User $user = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=UserHistory::class, mappedBy="accompanyingPeriod", orphanRemoval=true,
|
||||
* cascade={"persist", "remove"})
|
||||
*
|
||||
* @var Collection|UserHistory[]
|
||||
*/
|
||||
private Collection $userHistories;
|
||||
|
||||
/**
|
||||
* Temporary field, which is filled when the user is changed.
|
||||
*
|
||||
@@ -370,6 +379,7 @@ class AccompanyingPeriod implements
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->works = new ArrayCollection();
|
||||
$this->resources = new ArrayCollection();
|
||||
$this->userHistories = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1214,10 +1224,20 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUser(User $user): self
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
if ($this->user !== $user) {
|
||||
$this->userPrevious = $this->user;
|
||||
|
||||
foreach ($this->userHistories as $history) {
|
||||
if (null === $history->getEndDate()) {
|
||||
$history->setEndDate(new DateTimeImmutable('now'));
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $user) {
|
||||
$this->userHistories->add(new UserHistory($this, $user));
|
||||
}
|
||||
}
|
||||
|
||||
$this->user = $user;
|
||||
|
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table("chill_person_accompanying_period_user_history")
|
||||
*/
|
||||
class UserHistory implements TrackCreationInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?AccompanyingPeriod $accompanyingPeriod;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
private ?DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||
*/
|
||||
private DateTimeImmutable $startDate;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private User $user;
|
||||
|
||||
public function __construct(AccompanyingPeriod $accompanyingPeriod, User $user, ?DateTimeImmutable $startDate = null)
|
||||
{
|
||||
$this->startDate = $startDate ?? new DateTimeImmutable('now');
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function getAccompanyingPeriod(): AccompanyingPeriod
|
||||
{
|
||||
return $this->accompanyingPeriod;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getStartDate(): DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setEndDate(?DateTimeImmutable $endDate): UserHistory
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@@ -11,9 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||
@@ -25,6 +28,12 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||
$this->repository = $entityManager->getRepository(AccompanyingPeriodWorkEvaluation::class);
|
||||
}
|
||||
|
||||
public function countNearMaxDateByUser(User $user): int
|
||||
{
|
||||
return $this->buildQueryNearMaxDateByUser($user)
|
||||
->select('count(e)')->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function find($id): ?AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
@@ -39,8 +48,8 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|mixed $limit
|
||||
* @param null|mixed $offset
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
*
|
||||
* @return array|AccompanyingPeriodWorkEvaluation[]
|
||||
*/
|
||||
@@ -49,13 +58,45 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?AccompanyingPeriodWorkEvaluation
|
||||
public function findNearMaxDateByUser(User $user, int $limit = 20, int $offset = 0): array
|
||||
{
|
||||
return $this->findOneBy($criteria);
|
||||
return $this->buildQueryNearMaxDateByUser($user)
|
||||
->select('e')
|
||||
->setFirstResult($offset)
|
||||
->setMaxResults($limit)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function getClassName()
|
||||
public function findOneBy(array $criteria): ?AccompanyingPeriodWorkEvaluation
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return AccompanyingPeriodWorkEvaluation::class;
|
||||
}
|
||||
|
||||
private function buildQueryNearMaxDateByUser(User $user): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('e');
|
||||
|
||||
$qb
|
||||
->join('e.accompanyingPeriodWork', 'work')
|
||||
->join('work.accompanyingPeriod', 'period')
|
||||
->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq('period.user', ':user'),
|
||||
$qb->expr()->isNull('e.endDate'),
|
||||
$qb->expr()->gte(':now', $qb->expr()->diff('e.maxDate', 'e.warningInterval'))
|
||||
)
|
||||
)
|
||||
->setParameters([
|
||||
'user' => $user,
|
||||
'now' => new DateTimeImmutable('now'),
|
||||
]);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
|
@@ -11,10 +11,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
@@ -41,6 +45,12 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): int
|
||||
{
|
||||
return $this->buildQueryNearEndDateByUser($user, $since, $until)
|
||||
->select('count(w)')->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function find($id): ?AccompanyingPeriodWork
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
@@ -68,6 +78,16 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
return $this->repository->findByAccompanyingPeriod($period, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until, int $limit = 20, int $offset = 0): array
|
||||
{
|
||||
return $this->buildQueryNearEndDateByUser($user, $since, $until)
|
||||
->select('w')
|
||||
->setFirstResult($offset)
|
||||
->setMaxResults($limit)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?AccompanyingPeriodWork
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
@@ -78,22 +98,6 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
return AccompanyingPeriodWork::class;
|
||||
}
|
||||
|
||||
public function toDelete()
|
||||
{
|
||||
$qb = $this->buildQueryBySocialActionWithDescendants($action);
|
||||
$qb->select('g');
|
||||
|
||||
foreach ($orderBy as $sort => $order) {
|
||||
$qb->addOrderBy('g.' . $sort, $order);
|
||||
}
|
||||
|
||||
return $qb
|
||||
->setMaxResults($limit)
|
||||
->setFirstResult($offset)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
private function buildQueryBySocialActionWithDescendants(SocialAction $action): QueryBuilder
|
||||
{
|
||||
$actions = $action->getDescendantsWithThis();
|
||||
@@ -103,12 +107,34 @@ final class AccompanyingPeriodWorkRepository implements ObjectRepository
|
||||
$orx = $qb->expr()->orX();
|
||||
$i = 0;
|
||||
|
||||
foreach ($actions as $action) {
|
||||
foreach ($actions as $a) {
|
||||
$orx->add(":action_{$i} MEMBER OF g.socialActions");
|
||||
$qb->setParameter("action_{$i}", $action);
|
||||
$qb->setParameter("action_{$i}", $a);
|
||||
}
|
||||
$qb->where($orx);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
private function buildQueryNearEndDateByUser(User $user, DateTimeImmutable $since, DateTimeImmutable $until): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('w');
|
||||
|
||||
$qb
|
||||
->join('w.accompanyingPeriod', 'period')
|
||||
->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq('period.user', ':user'),
|
||||
$qb->expr()->gte('w.endDate', ':since'),
|
||||
$qb->expr()->lte('w.startDate', ':until')
|
||||
)
|
||||
)
|
||||
->setParameters([
|
||||
'user' => $user,
|
||||
'since' => $since,
|
||||
'until' => $until,
|
||||
]);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
@@ -26,6 +28,13 @@ final class AccompanyingPeriodRepository implements ObjectRepository
|
||||
$this->repository = $entityManager->getRepository(AccompanyingPeriod::class);
|
||||
}
|
||||
|
||||
public function countByRecentUserHistory(User $user, DateTimeImmutable $since): int
|
||||
{
|
||||
$qb = $this->buildQueryByRecentUserHistory($user, $since);
|
||||
|
||||
return $qb->select('count(a)')->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countBy(array $criteria): int
|
||||
{
|
||||
return $this->repository->count($criteria);
|
||||
@@ -54,6 +63,21 @@ final class AccompanyingPeriodRepository implements ObjectRepository
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|AccompanyingPeriod[]
|
||||
*/
|
||||
public function findByRecentUserHistory(User $user, DateTimeImmutable $since, ?int $limit = 20, ?int $offset = 0): array
|
||||
{
|
||||
$qb = $this->buildQueryByRecentUserHistory($user, $since);
|
||||
|
||||
return $qb->select('a')
|
||||
->distinct(true)
|
||||
->getQuery()
|
||||
->setMaxResults($limit)
|
||||
->setFirstResult($offset)
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?AccompanyingPeriod
|
||||
{
|
||||
return $this->findOneBy($criteria);
|
||||
@@ -63,4 +87,19 @@ final class AccompanyingPeriodRepository implements ObjectRepository
|
||||
{
|
||||
return AccompanyingPeriod::class;
|
||||
}
|
||||
|
||||
private function buildQueryByRecentUserHistory(User $user, DateTimeImmutable $since): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('a');
|
||||
|
||||
$qb
|
||||
->join('a.userHistories', 'userHistory')
|
||||
->where($qb->expr()->eq('a.user', ':user'))
|
||||
->andWhere($qb->expr()->gte('userHistory.startDate', ':since'))
|
||||
->andWhere($qb->expr()->isNull('userHistory.endDate'))
|
||||
->setParameter('user', $user)
|
||||
->setParameter('since', $since);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
|
@@ -80,6 +80,8 @@ div.dashboard {
|
||||
}
|
||||
}
|
||||
div.dashboard,
|
||||
h4.badge-title,
|
||||
h3.badge-title,
|
||||
h2.badge-title {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -128,6 +130,8 @@ ul.columns { // XS:1 SM:2 MD:1 LG:2 XL:2 XXL:2
|
||||
/// dashboard_like_badge in AccompanyingCourse Work list Page
|
||||
div[class*='accompanying_course_work'] {
|
||||
div.dashboard,
|
||||
h4.badge-title,
|
||||
h3.badge-title,
|
||||
h2.badge-title {
|
||||
span.title_label {
|
||||
// Calculate same color then border:groove
|
||||
@@ -143,6 +147,8 @@ div[class*='accompanying_course_work'] {
|
||||
/// dashboard_like_badge in Activities on resume page
|
||||
div[class*='activity-'] {
|
||||
div.dashboard,
|
||||
h4.badge-title,
|
||||
h3.badge-title,
|
||||
h2.badge-title {
|
||||
span.title_label {
|
||||
// Calculate same color then border:groove
|
||||
|
@@ -152,8 +152,8 @@ const appMessages = {
|
||||
not_valid: "Sélectionnez un métier du référent"
|
||||
},
|
||||
startdate: {
|
||||
change: "Modifier la date de début",
|
||||
date: "Date de début",
|
||||
change: "Date d'ouverture",
|
||||
date: "Date d'ouverture",
|
||||
},
|
||||
// catch errors
|
||||
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",
|
||||
|
@@ -244,16 +244,15 @@
|
||||
|
||||
</div>
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<!--
|
||||
FAIT REPETER tout le template de App.vue plusieurs fois
|
||||
<li>
|
||||
<pick-workflow
|
||||
<list-workflow-modal
|
||||
:workflows="this.work.workflows"
|
||||
:allowCreate="true"
|
||||
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork"
|
||||
:relatedEntityId="this.work.id"
|
||||
:workflows="this.workflows"
|
||||
></pick-workflow>
|
||||
:workflowsAvailables="this.work.workflows_availables"
|
||||
></list-workflow-modal>
|
||||
</li>
|
||||
-->
|
||||
|
||||
<li v-if="!isPosting">
|
||||
<button class="btn btn-save" @click="submit">
|
||||
@@ -282,6 +281,7 @@ import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRe
|
||||
import ThirdPartyRenderBox from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyRenderBox.vue';
|
||||
import PickTemplate from 'ChillDocGeneratorAssets/vuejs/_components/PickTemplate.vue';
|
||||
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
|
||||
import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue';
|
||||
import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue';
|
||||
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
|
||||
|
||||
@@ -331,9 +331,11 @@ export default {
|
||||
AddressRenderBox,
|
||||
ThirdPartyRenderBox,
|
||||
PickTemplate,
|
||||
ListWorkflowModal,
|
||||
OnTheFly,
|
||||
PickWorkflow,
|
||||
OnTheFly,
|
||||
PersonText,
|
||||
PersonText,
|
||||
},
|
||||
i18n,
|
||||
data() {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<a id="evaluations"></a>
|
||||
<div class="item-title" :title="evaluation.id || 'no id yet'">
|
||||
<span>{{ evaluation.evaluation.title.fr }}</span>
|
||||
</div>
|
||||
@@ -9,12 +10,16 @@
|
||||
|
||||
<ul class="record_actions">
|
||||
<li v-if="evaluation.workflows_availables.length > 0">
|
||||
<pick-workflow
|
||||
|
||||
<list-workflow-modal
|
||||
:workflows="evaluation.workflows"
|
||||
:allowCreate="true"
|
||||
relatedEntityClass="faked"
|
||||
:relatedEntityId="evaluation.id"
|
||||
:workflowsAvailables="evaluation.workflows_availables"
|
||||
@goToGenerateWorkflow="goToGenerateWorkflow"
|
||||
></pick-workflow>
|
||||
></list-workflow-modal>
|
||||
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-delete" @click="modal.showModal = true" :title="$t('action.delete')"></a>
|
||||
@@ -43,7 +48,7 @@
|
||||
<script>
|
||||
import FormEvaluation from './FormEvaluation.vue';
|
||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
|
||||
import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue';
|
||||
import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/ListWorkflowModal.vue';
|
||||
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
|
||||
|
||||
const i18n = {
|
||||
@@ -72,7 +77,7 @@ export default {
|
||||
components: {
|
||||
FormEvaluation,
|
||||
Modal,
|
||||
PickWorkflow,
|
||||
ListWorkflowModal,
|
||||
},
|
||||
props: ['evaluation'],
|
||||
i18n,
|
||||
|
@@ -77,7 +77,7 @@ export default {
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
<style lang="scss">
|
||||
div.results {
|
||||
div.list-item {
|
||||
padding: 0.4em 0.8em;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<span class="name">
|
||||
{{ item.result.text }}
|
||||
</span>
|
||||
<span class="location">
|
||||
<span class="location">
|
||||
<template v-if="hasAddress">
|
||||
{{ getAddress.text }} -
|
||||
{{ getAddress.postcode.name }}
|
||||
@@ -89,5 +89,13 @@ export default {
|
||||
font-variant: all-small-caps;
|
||||
}
|
||||
}
|
||||
.tparty-identification {
|
||||
span:not(.name) {
|
||||
margin-left: 0.5em;
|
||||
opacity: 0.5;
|
||||
font-size: 90%;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -184,7 +184,25 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class="mbloc col col-sm-6 col-lg-4">
|
||||
<div class="notification-counter">
|
||||
<h4 class="item-key">{{ 'notification.Notifications'|trans }}</h4>
|
||||
{% set notif_counter = chill_count_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod', accompanyingCourse.id) %}
|
||||
{% if notif_counter.total > 0 %}
|
||||
<div class="my-2">
|
||||
<a href="#notification-list">
|
||||
{{ chill_counter_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod', accompanyingCourse.id) }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="d-grid gap-2">
|
||||
<a class="btn btn-notify" href="{{ chill_path_add_return_path('chill_main_notification_create', {'entityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod', 'entityId': accompanyingCourse.id}) }}">
|
||||
{{ 'notification.Notify'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="social-actions my-4">
|
||||
@@ -210,18 +228,16 @@
|
||||
{% include 'ChillActivityBundle:Activity:list_recent.html.twig' with { 'context': 'accompanyingCourse', 'no_action': true } %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
<div class="notification notification-list">
|
||||
{% set notifications = chill_list_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod', accompanyingCourse.id) %}
|
||||
{% if notifications is not empty %}
|
||||
{{ notifications|raw }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block block_post_menu %}
|
||||
<div class="post-menu pt-4">
|
||||
<div class="d-grid gap-2">
|
||||
<a class="btn btn-primary" href="{{ chill_path_add_return_path('chill_main_notification_create', {'entityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod', 'entityId': accompanyingCourse.id}) }}">
|
||||
<i class="fa fa-paper-plane fa-fw"></i>
|
||||
{{ 'notification.Notify'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
{{ chill_list_notifications('Chill\\PersonBundle\\Entity\\AccompanyingPeriod', accompanyingCourse.id) }}
|
||||
</div>
|
||||
<div class="post-menu pt-4"></div>
|
||||
{% endblock %}
|
||||
|
@@ -16,12 +16,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block block_post_menu %}
|
||||
<div class="post-menu pt-4">
|
||||
{% set workflows_frame = chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork', work.id) %}
|
||||
{% if workflows_frame is not empty %}
|
||||
{{ workflows_frame|raw }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="post-menu pt-4"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
|
@@ -82,7 +82,7 @@
|
||||
<div class="wl-col title">
|
||||
<h3 class="courseid mb-2">
|
||||
<i class="fa fa-random fa-fw"></i>
|
||||
{{ 'File number'|trans }} {{ acp.id }}
|
||||
{{ 'Course number'|trans }} {{ acp.id }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="wl-col list">
|
||||
|
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20220128133039 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_person_accompanying_period_user_history_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_person_accompanying_period_user_history');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add table for tracking user history on accompanying period';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_person_accompanying_period_user_history_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_person_accompanying_period_user_history (id INT NOT NULL, user_id INT, endDate TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, startDate TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, accompanyingPeriod_id INT, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_6C258C49D7FA8EF0 ON chill_person_accompanying_period_user_history (accompanyingPeriod_id)');
|
||||
$this->addSql('CREATE INDEX IDX_6C258C49A76ED395 ON chill_person_accompanying_period_user_history (user_id)');
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_user_history.endDate IS \'(DC2Type:datetime_immutable)\'');
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_user_history.startDate IS \'(DC2Type:datetime_immutable)\'');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ADD CONSTRAINT FK_6C258C49D7FA8EF0 FOREIGN KEY (accompanyingPeriod_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ADD CONSTRAINT FK_6C258C49A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ADD CHECK (startdate <= enddate)');
|
||||
$this->addSql('INSERT INTO chill_person_accompanying_period_user_history (id, user_id, accompanyingperiod_id, startDate, endDate) ' .
|
||||
'SELECT nextval(\'chill_person_accompanying_period_user_history_id_seq\'), user_id, id, openingDate, null FROM chill_person_accompanying_period WHERE user_id IS NOT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL;');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ADD createdBy_id INT DEFAULT NULL;');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ALTER user_id SET NOT NULL;');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ALTER accompanyingperiod_id SET NOT NULL;');
|
||||
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_user_history.createdAt IS \'(DC2Type:datetime_immutable)\';');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ADD CONSTRAINT FK_6C258C493174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE;');
|
||||
$this->addSql('CREATE INDEX IDX_6C258C493174800F ON chill_person_accompanying_period_user_history (createdBy_id);');
|
||||
}
|
||||
}
|
@@ -81,7 +81,7 @@ Married: Marié(e)
|
||||
'Family information': Famille
|
||||
'Contact information': 'Informations de contact'
|
||||
'Administrative information': Administratif
|
||||
File number: Dossier n°
|
||||
Course number: Parcours n°
|
||||
Civility: Civilité
|
||||
choose civility: --
|
||||
All genders: tous les genres
|
||||
|
Reference in New Issue
Block a user