diff --git a/src/Controller/Manager/IndexController.php b/src/Controller/Manager/IndexController.php index 277d5ba..c9373ef 100644 --- a/src/Controller/Manager/IndexController.php +++ b/src/Controller/Manager/IndexController.php @@ -2,45 +2,35 @@ namespace App\Controller\Manager; -use App\Entity\Assignment; -use App\Model\AssignmentFilterDto; -use App\Repository\AssignmentRepository; -use Knp\Component\Pager\PaginatorInterface; +use App\Entity\Upload; +use App\Repository\DispositionRepository; +use App\Repository\UploadRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class IndexController extends AbstractController { - public function __construct(private readonly AssignmentRepository $assignmentRepository, private readonly PaginatorInterface $paginator) - { + public function __construct( + private readonly DispositionRepository $dispositionRepository, + private readonly UploadRepository $uploadRepository, + ) { } #[Route('/management', name: 'app_manager_index')] - public function index(Request $request): Response + public function index(): Response { - $filterDto = new AssignmentFilterDto(); - $filterDto->setStatus(Assignment::STATUS_UNSTAFFED); + $dispositions = $this->dispositionRepository->getNew(); - $query = $this - ->assignmentRepository - ->getListQuery($filterDto) - ; - - $pagination = $this->paginator->paginate( - $query, - $request->query->getInt('page', 1), - 10, - [ - 'wrap-queries' => true, // Required for query with 'having' clause - 'defaultSortFieldName' => 'destination.dateFrom', - 'defaultSortDirection' => 'desc', - ] - ); + $documents = $this->uploadRepository->getNew(); + $newDocumentsCount = $this->uploadRepository->getCountByStatus(Upload::STATUS_NEW); + $pendingDocumentsCount = $this->uploadRepository->getCountByStatus(Upload::STATUS_PENDING); return $this->render('manager/index.html.twig', [ - 'pagination' => $pagination, + 'dispositions' => $dispositions, + 'documents' => $documents, + 'newDocumentsCount' => $newDocumentsCount, + 'pendingDocumentsCount' => $pendingDocumentsCount, ]); } } \ No newline at end of file diff --git a/src/Repository/DispositionRepository.php b/src/Repository/DispositionRepository.php index bcd24c5..c97b3dd 100644 --- a/src/Repository/DispositionRepository.php +++ b/src/Repository/DispositionRepository.php @@ -245,4 +245,22 @@ class DispositionRepository extends ServiceEntityRepository ->getResult() ; } + + public function getNew(int $limit = 5): array + { + $qb = $this->createQueryBuilder('disposition'); + + return $qb + ->select('disposition', 'assignment', 'destination', 'job_profile') + ->innerJoin('disposition.assignment', 'assignment') + ->innerJoin('assignment.destination', 'destination') + ->innerJoin('assignment.jobProfile', 'job_profile') + ->where($qb->expr()->gt('destination.dateFrom', ':dateFrom')) + ->orderBy('disposition.createdAt', 'DESC') + ->setParameter('dateFrom', new \DateTimeImmutable()) + ->setMaxResults($limit) + ->getQuery() + ->getResult() + ; + } } diff --git a/templates/manager/index.html.twig b/templates/manager/index.html.twig index 83e666b..41f09df 100644 --- a/templates/manager/index.html.twig +++ b/templates/manager/index.html.twig @@ -1,144 +1,67 @@ {% extends 'manager/layout.html.twig' %} -{% block title %}Offene Einsätze{% endblock %} +{% macro dispositionData(disposition) %} + {% set assignment = disposition.assignment %} + {{ disposition.teamer.fullName(true) }} + {% include '_partials/_dot.html.twig' %} + {{ assignment.effectivePeriod.start|date('d.m.y') }} - {{ assignment.effectivePeriod.end|date('d.m.y') }} + {% include '_partials/_dot.html.twig' %} + {{ assignment.destination.hotel }} + {% include '_partials/_dot.html.twig' %} + {{ assignment.jobProfile.name }} +{% endmacro %} {% block content %} -
-

- Offene Einsätze -

-
- -
-
- - - - - - - - - - - - - - {% for assignment in pagination %} - - - - - - - - - +
+
+

+ Neue Dokumente +

+ {% if newDocumentsCount > 0 or pendingDocumentsCount > 0 %} +

+ {{ newDocumentsCount }} neu {{ pendingDocumentsCount }} in Bearbeitung +

+ {% endif %} +
    + {% for document in documents %} +
  • + +
  • {% else %} -
- - +
  • + - +
  • {% endfor %} - -
    - Status - - {{ knp_pagination_sortable(pagination, 'Einsatz­zeitraum', 'destination.dateFrom') }} - - {{ knp_pagination_sortable(pagination, 'Destination', 'destination.product') }} - - {{ knp_pagination_sortable(pagination, 'Jobprofil', 'job_profile.name') }} - - {{ knp_pagination_sortable(pagination, 'Bus', 'assignment.pickup') }} - - Einteilungen -
    -
    - {% if assignment.status == 'draft' %} - - - - {{ icon('edit', 'w-4 h-4') }} - {% else %} - {% if assignment.staffed %} - - - - {% elseif assignment.partlyStaffed %} - - - - {% elseif assignment.staffing %} - - - - {% else %} - - - - {% endif %} - {% if assignment.status == 'closed' %} - {{ icon('locked', 'w-4 h-4 text-red-500') }} - {% else %} - {{ icon('unlocked', 'w-4 h-4') }} - {% endif %} - {% endif %} -
    -
    - - {{ assignment.effectivePeriod.start|date('d.m.Y') }} - -
    - {{ assignment.effectivePeriod.end|date('d.m.Y') }} -
    -
    - - {{ icon('flag-' ~ assignment.destination.country, 'w-5 h-5 shrink-0') }} -
    - {{ assignment.destination.hotel }} -
    -
    -
    - - {{ assignment.jobProfile.name }} - - - {% if assignment.pickup %} - {% set pickup = assignment.destination.pickup(assignment.pickup) %} - {% if pickup %} - - ab {{ pickup.city }} -
    - {{ pickup.time }} -
    - {% else %} - ungültiger Zustieg - {% endif %} - {% else %} - - - {% endif %} -
    - {{ assignment.dispositions|length }}/{{ assignment.availableDispositions }} -
      - {% for disposition in assignment.dispositions %} -
    • -
      - {{ disposition.teamer }} - -
      -
    • - {% endfor %} -
    -
    -
    - Keine Daten... -
    - {{ knp_pagination_render(pagination) }} + +
    +
    +

    + Neue Einteilungen +

    +
    -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/translations/messages.de.yaml b/translations/messages.de.yaml index 4c3c059..917fc10 100644 --- a/translations/messages.de.yaml +++ b/translations/messages.de.yaml @@ -10,6 +10,7 @@ label: checking_contract: in Bearbeitung checking_invoice: in Bearbeitung confirmed: bestätigt + ended: beendet completed: abgeschlossen document: type: