feat: list upcoming season assignments among a teamer's dispositions
This commit is contained in:
1 parent
300bb2058f
commit
c00dd86eb4
17 files changed
+386
-97
No files matched your search
@@ -5,8 +5,8 @@ namespace App\Controller\Admin\Teamer;
|
||||
use App\Entity\Teamer;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use App\Repository\ApplicationRepository;
|
||||
use App\Repository\DispositionRepository;
|
||||
use App\Service\Teamer\AccountDeletionHandler;
|
||||
use App\Service\Teamer\UpcomingPlacementCollector;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -18,7 +18,7 @@ class DeleteAccountController extends AbstractController
|
||||
public function __construct(
|
||||
private readonly AccountDeletionHandler $accountDeletionHandler,
|
||||
private readonly ApplicationRepository $applicationRepository,
|
||||
private readonly DispositionRepository $dispositionRepository,
|
||||
private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ class DeleteAccountController extends AbstractController
|
||||
return $this->render('admin/teamer/modal_delete_account.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
'pendingApplicationCount' => count($this->applicationRepository->getPendingForTeamer($teamer, 100)),
|
||||
'upcomingDispositionCount' => count($this->dispositionRepository->getUpcomingDispositionsByTeamer($teamer, 100)),
|
||||
// season assignments included: an active season placement is an open commitment as well
|
||||
'upcomingPlacementCount' => count($this->upcomingPlacementCollector->collect($teamer)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Controller\Administrative\Teamer;
|
||||
|
||||
use App\Entity\Teamer;
|
||||
use App\Repository\DispositionRepository;
|
||||
use App\Service\Teamer\UpcomingPlacementCollector;
|
||||
use Knp\Component\Pager\PaginatorInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -14,7 +14,7 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
class UpcomingAssignmentsController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DispositionRepository $dispositionRepository,
|
||||
private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
|
||||
private readonly PaginatorInterface $paginator,
|
||||
) {
|
||||
}
|
||||
@@ -23,19 +23,11 @@ class UpcomingAssignmentsController extends AbstractController
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Teamer $teamer, Request $request): Response
|
||||
{
|
||||
$query = $this
|
||||
->dispositionRepository
|
||||
->getUpcomingDispositionsByTeamerQuery($teamer)
|
||||
;
|
||||
|
||||
// an array rather than a query: dispositions and season assignments are merged in PHP
|
||||
$pagination = $this->paginator->paginate(
|
||||
$query,
|
||||
$this->upcomingPlacementCollector->collect($teamer),
|
||||
$request->query->getInt('page', 1),
|
||||
10,
|
||||
[
|
||||
'defaultSortFieldName' => 'destination.dateFrom',
|
||||
'defaultSortDirection' => 'asc',
|
||||
]
|
||||
10
|
||||
);
|
||||
|
||||
return $this->render('administrative/teamer/upcoming_assignments.html.twig', [
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace App\Controller\Teamer\Disposition;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Repository\DispositionRepository;
|
||||
use App\Service\Season\SeasonAssignmentResolver;
|
||||
use App\Service\Teamer\UpcomingPlacementCollector;
|
||||
use Knp\Component\Pager\PaginatorInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -14,7 +15,8 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
class UpcomingController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DispositionRepository $dispositionRepository,
|
||||
private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
|
||||
private readonly SeasonAssignmentResolver $seasonAssignmentResolver,
|
||||
private readonly PaginatorInterface $paginator,
|
||||
) {
|
||||
}
|
||||
@@ -27,24 +29,18 @@ class UpcomingController extends AbstractController
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
|
||||
$query = $this
|
||||
->dispositionRepository
|
||||
->getUpcomingDispositionsByTeamerQuery($teamer)
|
||||
;
|
||||
|
||||
// an array rather than a query: dispositions and season assignments are merged in PHP
|
||||
$pagination = $this->paginator->paginate(
|
||||
$query,
|
||||
$this->upcomingPlacementCollector->collect($teamer),
|
||||
$request->query->getInt('page', 1),
|
||||
9,
|
||||
[
|
||||
'defaultSortFieldName' => 'destination.dateFrom',
|
||||
'defaultSortDirection' => 'asc',
|
||||
]
|
||||
9
|
||||
);
|
||||
|
||||
return $this->render('teamer/disposition/upcoming.html.twig', [
|
||||
'teamer' => $teamer,
|
||||
'pagination' => $pagination,
|
||||
// the season page shows only this one, so only this one is linked
|
||||
'linkedSeasonAssignment' => $this->seasonAssignmentResolver->resolveFor($teamer),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ use App\Entity\Disposition;
|
||||
use App\Entity\Feedback;
|
||||
use App\Entity\News;
|
||||
use App\Entity\User;
|
||||
use App\Service\Season\SeasonAssignmentResolver;
|
||||
use App\Service\Teamer\UpcomingPlacementCollector;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -16,8 +18,11 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
|
||||
private readonly SeasonAssignmentResolver $seasonAssignmentResolver,
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/teamer', name: 'app_teamer_index')]
|
||||
@@ -66,6 +71,9 @@ class IndexController extends AbstractController
|
||||
|
||||
$dispositionDocuments = $this->processDocuments($upcomingDispositions);
|
||||
|
||||
// the list merges in season assignments; the document notices above stay on dispositions
|
||||
$upcomingPlacements = array_slice($this->upcomingPlacementCollector->collect($teamer), 0, 5);
|
||||
|
||||
return $this->render('teamer/index.html.twig', [
|
||||
'news' => $news,
|
||||
'teamer' => $teamer,
|
||||
@@ -73,7 +81,9 @@ class IndexController extends AbstractController
|
||||
'recentFeedback' => $recentFeedback,
|
||||
'pendingApplications' => $pendingApplications,
|
||||
'currentDispositions' => $currentDispositions,
|
||||
'upcomingDispositions' => $upcomingDispositions,
|
||||
'upcomingPlacements' => $upcomingPlacements,
|
||||
// the season page shows only this one, so only this one is linked
|
||||
'linkedSeasonAssignment' => $this->seasonAssignmentResolver->resolveFor($teamer),
|
||||
'dispositionDocuments' => $dispositionDocuments,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,17 @@ class DispositionRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* All of them, unlike getUpcomingDispositionsByTeamer(): merged with the season assignments
|
||||
* by App\Service\Teamer\UpcomingPlacementCollector, which sorts and pages the result.
|
||||
*
|
||||
* @return Disposition[]
|
||||
*/
|
||||
public function findAllUpcomingByTeamer(Teamer $teamer): array
|
||||
{
|
||||
return $this->getUpcomingDispositionsByTeamerQuery($teamer)->getResult();
|
||||
}
|
||||
|
||||
public function getUpcomingDispositionsByTeamer(Teamer $teamer, int $limit = 5): array
|
||||
{
|
||||
return $this
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Entity\Teamer;
|
||||
use App\Model\SeasonAssignmentFilterDto;
|
||||
use App\Repository\Traits\QueryHelperTrait;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
@@ -91,6 +92,42 @@ class SeasonAssignmentRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* A teamer's season assignments that have not ended yet, earliest first - listed alongside
|
||||
* the upcoming dispositions. A running season counts, just as a running disposition does.
|
||||
*
|
||||
* @return SeasonAssignment[]
|
||||
*/
|
||||
public function findUpcomingByTeamer(Teamer $teamer): array
|
||||
{
|
||||
return $this
|
||||
->createUpcomingByTeamerQueryBuilder($teamer)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted so the conditions can be pinned by a test compiling the DQL.
|
||||
*/
|
||||
public function createUpcomingByTeamerQueryBuilder(Teamer $teamer): QueryBuilder
|
||||
{
|
||||
$qb = $this->createQueryBuilder('season_assignment');
|
||||
|
||||
return $qb
|
||||
->select('season_assignment', 'job_profile')
|
||||
->innerJoin('season_assignment.jobProfile', 'job_profile')
|
||||
->where($qb->expr()->andX(
|
||||
$qb->expr()->eq('season_assignment.teamer', ':teamer'),
|
||||
$qb->expr()->isNull('season_assignment.deletedAt'),
|
||||
$qb->expr()->gte('season_assignment.dateTo', ':today')
|
||||
))
|
||||
->setParameter('teamer', $teamer)
|
||||
->setParameter('today', new \DateTimeImmutable('today'), Types::DATE_IMMUTABLE)
|
||||
->addOrderBy('season_assignment.dateFrom', \SortDirection::Ascending)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracted so the conditions can be pinned by a test compiling the DQL - the suite has no
|
||||
* fixtures, so what is asserted is what the query says, not what it returns.
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Teamer;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\SeasonAssignment;
|
||||
use App\Entity\Teamer;
|
||||
use App\Repository\DispositionRepository;
|
||||
use App\Repository\SeasonAssignmentRepository;
|
||||
|
||||
/**
|
||||
* A teamer's upcoming placements as one list, earliest first.
|
||||
*
|
||||
* "Placement" covers both ways a teamer is placed: a Disposition on an Assignment, or a
|
||||
* SeasonAssignment. It is not an entity, only the name for the two together.
|
||||
*
|
||||
* The two live in separate tables, so no single query can sort or page across both. A teamer
|
||||
* has a few dozen upcoming dispositions at most, so both are loaded in full and merged here;
|
||||
* callers page or slice the result. Each row carries exactly one of the two records.
|
||||
*/
|
||||
class UpcomingPlacementCollector
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DispositionRepository $dispositionRepository,
|
||||
private readonly SeasonAssignmentRepository $seasonAssignmentRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{dateFrom: ?\DateTimeImmutable, dateTo: ?\DateTimeImmutable, disposition: ?Disposition, seasonAssignment: ?SeasonAssignment}>
|
||||
*/
|
||||
public function collect(Teamer $teamer): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
// season assignments first: the sort is stable, so on the same start day the season,
|
||||
// which frames the dispositions inside it, comes before them
|
||||
foreach ($this->seasonAssignmentRepository->findUpcomingByTeamer($teamer) as $seasonAssignment) {
|
||||
$rows[] = [
|
||||
'dateFrom' => $seasonAssignment->getDateFrom(),
|
||||
'dateTo' => $seasonAssignment->getDateTo(),
|
||||
'disposition' => null,
|
||||
'seasonAssignment' => $seasonAssignment,
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($this->dispositionRepository->findAllUpcomingByTeamer($teamer) as $disposition) {
|
||||
$destination = $disposition->getAssignment()?->getDestination();
|
||||
|
||||
$rows[] = [
|
||||
'dateFrom' => $destination?->getDateFrom(),
|
||||
'dateTo' => $destination?->getDateTo(),
|
||||
'disposition' => $disposition,
|
||||
'seasonAssignment' => null,
|
||||
];
|
||||
}
|
||||
|
||||
usort($rows, static fn (array $a, array $b): int => $a['dateFrom'] <=> $b['dateFrom']);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
{# Marks a season assignment listed among dispositions. #}
|
||||
<span class="inline-block py-1 px-2 text-xs bg-primary text-white">Saison</span>
|
||||
@@ -11,15 +11,15 @@
|
||||
sich nicht mehr anmelden. Bestehende Einsätze, Dokumente und Feedbacks bleiben erhalten
|
||||
und weiterhin sichtbar.
|
||||
</div>
|
||||
{% if pendingApplicationCount > 0 or upcomingDispositionCount > 0 %}
|
||||
{% if pendingApplicationCount > 0 or upcomingPlacementCount > 0 %}
|
||||
<div class="p-4 bg-red-50 border border-red-200 rounded-md">
|
||||
<div class="font-bold pb-2">Achtung: offene Vorgänge</div>
|
||||
<ul class="list-disc list-inside">
|
||||
{% if pendingApplicationCount > 0 %}
|
||||
<li>{{ pendingApplicationCount }} offene Bewerbung(en)</li>
|
||||
{% endif %}
|
||||
{% if upcomingDispositionCount > 0 %}
|
||||
<li>{{ upcomingDispositionCount }} anstehende(r) Einsatz/Einsätze</li>
|
||||
{% if upcomingPlacementCount > 0 %}
|
||||
<li>{{ upcomingPlacementCount }} anstehende(r) Einsatz/Einsätze</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="pt-2">
|
||||
|
||||
@@ -28,24 +28,41 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for disposition in pagination %}
|
||||
{% for row in pagination %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ disposition.assignment.destination.dateFrom|date('d.m.Y') }} - {{ disposition.assignment.destination.dateTo|date('d.m.Y') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ disposition.assignment.destination.product }}
|
||||
<br>
|
||||
{{ disposition.assignment.destination.hotel }}
|
||||
</td>
|
||||
<td>
|
||||
{{ disposition.assignment.jobProfile.name }}
|
||||
{{ row.dateFrom|date('d.m.Y') }} - {{ row.dateTo|date('d.m.Y') }}
|
||||
</td>
|
||||
{% if row.seasonAssignment is not null %}
|
||||
{% set seasonAssignment = row.seasonAssignment %}
|
||||
<td>
|
||||
{% include '_partials/_season_badge.html.twig' %}
|
||||
<a href="{{ path('app_administrative_season_assignment_detail', { 'uuid': seasonAssignment.uuid, 'r': return_url() }) }}"
|
||||
class="underline">
|
||||
{{ seasonAssignment|season_assignment_label }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ seasonAssignment.jobProfile.name }}
|
||||
</td>
|
||||
{% else %}
|
||||
{% set assignment = row.disposition.assignment %}
|
||||
<td>
|
||||
{{ assignment.destination.product }}
|
||||
<br>
|
||||
{{ assignment.destination.hotel }}
|
||||
</td>
|
||||
<td>
|
||||
{{ assignment.jobProfile.name }}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% else %}
|
||||
<td colspan="3">
|
||||
Keine Daten...
|
||||
</td>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
Keine Daten...
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
{% set assignment = disposition.assignment %}
|
||||
<div class="relative flex flex-col justify-between rounded-md border border-gray-200 bg-gray-100 p-4">
|
||||
<div class="flex flex-col space-y-2 pb-2">
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('flag-' ~ assignment.destination.country, 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1 font-bold">{{ assignment.destination.product }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('calendar', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ assignment.destination.dateFrom|date('d.m.Y') }} - {{ assignment.destination.dateTo|date('d.m.Y') }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('profile', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ assignment.jobProfile.name }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('house', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ assignment.destination.hotel }}</span>
|
||||
</div>
|
||||
{% if assignment.pickup %}
|
||||
{% set pickup = assignment.destination.pickup(assignment.pickup) %}
|
||||
{% if pickup is not null %}
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('bus', 'w-5 h-5 shrink-0') }}
|
||||
<span>{{ pickup.city }}, {{ pickup.time }} Uhr</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<a href="{{ path('app_teamer_disposition_detail', { 'uuid': disposition.uuid, 'r': return_url() }) }}"
|
||||
class="btn btn--small flex items-center space-x-2">
|
||||
{{ icon('info', 'w-4 h-4 shrink-0') }}
|
||||
<span>Details</span>
|
||||
</a>
|
||||
</div>
|
||||
@@ -1,40 +1,6 @@
|
||||
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-4 pb-4">
|
||||
{% for disposition in pagination %}
|
||||
{% set assignment = disposition.assignment %}
|
||||
<div class="relative flex flex-col justify-between rounded-md border border-gray-200 bg-gray-100 p-4">
|
||||
<div class="flex flex-col space-y-2 pb-2">
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('flag-' ~ assignment.destination.country, 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1 font-bold">{{ assignment.destination.product }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('calendar', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ assignment.destination.dateFrom|date('d.m.Y') }} - {{ assignment.destination.dateTo|date('d.m.Y') }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('profile', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ assignment.jobProfile.name }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('house', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ assignment.destination.hotel }}</span>
|
||||
</div>
|
||||
{% if assignment.pickup %}
|
||||
{% set pickup = assignment.destination.pickup(assignment.pickup) %}
|
||||
{% if pickup is not null %}
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('bus', 'w-5 h-5 shrink-0') }}
|
||||
<span>{{ pickup.city }}, {{ pickup.time }} Uhr</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<a href="{{ path('app_teamer_disposition_detail', { 'uuid': disposition.uuid, 'r': return_url() }) }}"
|
||||
class="btn btn--small flex items-center space-x-2">
|
||||
{{ icon('info', 'w-4 h-4 shrink-0') }}
|
||||
<span>Details</span>
|
||||
</a>
|
||||
</div>
|
||||
{% include 'teamer/disposition/_card.html.twig' %}
|
||||
{% else %}
|
||||
Keine Einträge...
|
||||
{% endfor %}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{# A season assignment among the upcoming dispositions. Linked only when it is the one the season
|
||||
page shows - that page resolves a single assignment and 404s for any other. #}
|
||||
<div class="relative flex flex-col justify-between rounded-md border border-gray-200 bg-gray-100 p-4">
|
||||
<div class="flex flex-col space-y-2 pb-2">
|
||||
<div class="flex items-start space-x-2">
|
||||
<span class="flex-1 font-bold">{{ seasonAssignment|season_assignment_label }}</span>
|
||||
{% include '_partials/_season_badge.html.twig' %}
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('calendar', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ seasonAssignment.dateFrom|date('d.m.Y') }} - {{ seasonAssignment.dateTo|date('d.m.Y') }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('profile', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ seasonAssignment.jobProfile.name }}</span>
|
||||
</div>
|
||||
<div class="flex items-start space-x-2">
|
||||
{{ icon('house', 'w-5 h-5 shrink-0') }}
|
||||
<span class="flex-1">{{ seasonAssignment.hotelCode|house_label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if seasonAssignment is same as(linkedSeasonAssignment) %}
|
||||
<a href="{{ path('app_teamer_season_index') }}"
|
||||
class="btn btn--small flex items-center space-x-2">
|
||||
{{ icon('info', 'w-4 h-4 shrink-0') }}
|
||||
<span>Details</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -6,5 +6,16 @@
|
||||
<h1 class="text-2xl font-bold pb-8">
|
||||
Meine nächsten Einsätze
|
||||
</h1>
|
||||
{% include 'teamer/disposition/_list.html.twig' %}
|
||||
{% endblock %}
|
||||
<div class="grid sm:grid-cols-2 md:grid-cols-3 gap-4 pb-4">
|
||||
{% for row in pagination %}
|
||||
{% if row.seasonAssignment is not null %}
|
||||
{% include 'teamer/disposition/_season_card.html.twig' with { 'seasonAssignment': row.seasonAssignment } %}
|
||||
{% else %}
|
||||
{% include 'teamer/disposition/_card.html.twig' with { 'disposition': row.disposition } %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
Keine Einträge...
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ knp_pagination_render(pagination, 'paginator/sliding_boxes.html.twig') }}
|
||||
{% endblock %}
|
||||
@@ -116,20 +116,42 @@
|
||||
Meine Einsätze
|
||||
</h2>
|
||||
<ul class="divide-y divide-gray-200">
|
||||
{% for disposition in upcomingDispositions %}
|
||||
{% set assignment = disposition.assignment %}
|
||||
{% for row in upcomingPlacements %}
|
||||
<li class="py-2 first:pt-0 last:pb-0">
|
||||
<a href="{{ path('app_teamer_disposition_detail', { 'uuid': disposition.uuid }) }}">
|
||||
<div class="flex items-center space-x-1">
|
||||
{{ icon('check', 'w-4 h-4 shrink-0') }}
|
||||
<div class="flex items-center space-x-1 truncate">
|
||||
<span class="whitespace-nowrap">{{ assignment.destination.dateFrom|date('d.m.y') }} - {{ assignment.destination.dateTo|date('d.m.y') }}</span>
|
||||
{% include '_partials/_dot.html.twig' %}
|
||||
<span class="whitespace-nowrap">{{ assignment.destination.hotel }}</span>
|
||||
{% if row.seasonAssignment is not null %}
|
||||
{% set seasonAssignment = row.seasonAssignment %}
|
||||
{% set content %}
|
||||
<div class="flex items-center space-x-1">
|
||||
{{ icon('check', 'w-4 h-4 shrink-0') }}
|
||||
<div class="flex items-center space-x-1 truncate">
|
||||
<span class="whitespace-nowrap">{{ row.dateFrom|date('d.m.y') }} - {{ row.dateTo|date('d.m.y') }}</span>
|
||||
{% include '_partials/_dot.html.twig' %}
|
||||
<span class="whitespace-nowrap">{{ seasonAssignment.hotelCode|house_label }}</span>
|
||||
{% include '_partials/_season_badge.html.twig' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-5 whitespace-nowrap">{{ assignment.jobProfile.name }}</div>
|
||||
</a>
|
||||
<div class="pl-5 whitespace-nowrap">{{ seasonAssignment.jobProfile.name }}</div>
|
||||
{% endset %}
|
||||
{% if seasonAssignment is same as(linkedSeasonAssignment) %}
|
||||
<a href="{{ path('app_teamer_season_index') }}">{{ content }}</a>
|
||||
{% else %}
|
||||
{{ content }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% set disposition = row.disposition %}
|
||||
{% set assignment = disposition.assignment %}
|
||||
<a href="{{ path('app_teamer_disposition_detail', { 'uuid': disposition.uuid }) }}">
|
||||
<div class="flex items-center space-x-1">
|
||||
{{ icon('check', 'w-4 h-4 shrink-0') }}
|
||||
<div class="flex items-center space-x-1 truncate">
|
||||
<span class="whitespace-nowrap">{{ assignment.destination.dateFrom|date('d.m.y') }} - {{ assignment.destination.dateTo|date('d.m.y') }}</span>
|
||||
{% include '_partials/_dot.html.twig' %}
|
||||
<span class="whitespace-nowrap">{{ assignment.destination.hotel }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-5 whitespace-nowrap">{{ assignment.jobProfile.name }}</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="py-2 first:pt-0 last:pb-0">
|
||||
|
||||
@@ -52,6 +52,25 @@ class SeasonAssignmentRepositoryTest extends KernelTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upcoming means "not ended yet", like the dispositions it is listed with - a running season
|
||||
* is still shown - and a deleted placement is not.
|
||||
*/
|
||||
public function testTheUpcomingQueryKeepsRunningAssignmentsAndDropsDeletedOnes(): void
|
||||
{
|
||||
/** @var EntityManagerInterface $entityManager */
|
||||
$entityManager = static::getContainer()->get(EntityManagerInterface::class);
|
||||
|
||||
/** @var SeasonAssignmentRepository $repository */
|
||||
$repository = $entityManager->getRepository(SeasonAssignment::class);
|
||||
|
||||
$dql = $repository->createUpcomingByTeamerQueryBuilder(new Teamer())->getQuery()->getDQL();
|
||||
|
||||
$this->assertStringContainsString('season_assignment.dateTo >= :today', $dql);
|
||||
$this->assertStringContainsString('season_assignment.deletedAt IS NULL', $dql);
|
||||
$this->assertStringNotContainsString('season_assignment.dateFrom >=', $dql);
|
||||
}
|
||||
|
||||
private function createInSeasonWindowQueryBuilder(?int $excludeId = null): \Doctrine\ORM\QueryBuilder
|
||||
{
|
||||
/** @var EntityManagerInterface $entityManager */
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service\Teamer;
|
||||
|
||||
use App\Entity\Application;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\Destination;
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\SeasonAssignment;
|
||||
use App\Entity\Teamer;
|
||||
use App\Repository\DispositionRepository;
|
||||
use App\Repository\SeasonAssignmentRepository;
|
||||
use App\Service\Teamer\UpcomingPlacementCollector;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UpcomingPlacementCollectorTest extends TestCase
|
||||
{
|
||||
public function testBothKindsAreMergedEarliestFirst(): void
|
||||
{
|
||||
$early = $this->disposition('2026-10-25', '2026-11-01');
|
||||
$late = $this->disposition('2027-05-01', '2027-05-08');
|
||||
$season = (new SeasonAssignment())
|
||||
->setDateFrom(new \DateTimeImmutable('2026-11-01'))
|
||||
->setDateTo(new \DateTimeImmutable('2027-04-30'));
|
||||
|
||||
$rows = $this->collector([$late, $early], [$season])->collect(new Teamer());
|
||||
|
||||
$this->assertSame([$early, null, $late], array_column($rows, 'disposition'));
|
||||
$this->assertSame([null, $season, null], array_column($rows, 'seasonAssignment'));
|
||||
$this->assertSame('2027-04-30', $rows[1]['dateTo']?->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* The season frames the dispositions inside it, so on the same first day it comes first.
|
||||
*/
|
||||
public function testASeasonStartingOnTheSameDayComesBeforeTheDisposition(): void
|
||||
{
|
||||
$disposition = $this->disposition('2026-11-01', '2026-11-08');
|
||||
$season = (new SeasonAssignment())
|
||||
->setDateFrom(new \DateTimeImmutable('2026-11-01'))
|
||||
->setDateTo(new \DateTimeImmutable('2027-04-30'));
|
||||
|
||||
$rows = $this->collector([$disposition], [$season])->collect(new Teamer());
|
||||
|
||||
$this->assertSame($season, $rows[0]['seasonAssignment']);
|
||||
$this->assertSame($disposition, $rows[1]['disposition']);
|
||||
}
|
||||
|
||||
public function testNothingUpcomingYieldsNoRows(): void
|
||||
{
|
||||
$this->assertSame([], $this->collector([], [])->collect(new Teamer()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Disposition[] $dispositions
|
||||
* @param SeasonAssignment[] $seasonAssignments
|
||||
*/
|
||||
private function collector(array $dispositions, array $seasonAssignments): UpcomingPlacementCollector
|
||||
{
|
||||
$dispositionRepository = $this->createStub(DispositionRepository::class);
|
||||
$dispositionRepository->method('findAllUpcomingByTeamer')->willReturn($dispositions);
|
||||
|
||||
$seasonAssignmentRepository = $this->createStub(SeasonAssignmentRepository::class);
|
||||
$seasonAssignmentRepository->method('findUpcomingByTeamer')->willReturn($seasonAssignments);
|
||||
|
||||
return new UpcomingPlacementCollector($dispositionRepository, $seasonAssignmentRepository);
|
||||
}
|
||||
|
||||
private function disposition(string $dateFrom, string $dateTo): Disposition
|
||||
{
|
||||
$destination = (new Destination())
|
||||
->setDateFrom(new \DateTimeImmutable($dateFrom))
|
||||
->setDateTo(new \DateTimeImmutable($dateTo));
|
||||
|
||||
return new Disposition(new Application((new Assignment())->setDestination($destination), new Teamer()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user