feat: overview of teamers' custom availabilities
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Administrative\Availability;
|
||||
|
||||
use App\Repository\AvailabilityRepository;
|
||||
use Knp\Component\Pager\PaginatorInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AvailabilityRepository $availabilityRepository,
|
||||
private readonly PaginatorInterface $paginator
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/administrative/availability', name: 'app_administrative_availability_index')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$query = $this
|
||||
->availabilityRepository
|
||||
->getListQuery(true)
|
||||
;
|
||||
|
||||
$pagination = $this->paginator->paginate(
|
||||
$query,
|
||||
$request->query->getInt('page', 1),
|
||||
$request->query->getInt('limit', 10),
|
||||
[
|
||||
'defaultSortFieldName' => 'availability.dateFrom',
|
||||
'defaultSortDirection' => 'asc',
|
||||
]
|
||||
);
|
||||
|
||||
return $this->render('administrative/availability/index.html.twig', [
|
||||
'pagination' => $pagination,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,15 @@ class AdminMenuBuilder extends AbstractMenuBuilder
|
||||
],
|
||||
],
|
||||
]);
|
||||
$menu->addChild('Verfügbarkeiten', [
|
||||
'route' => 'app_administrative_availability_index',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Verfügbarkeiten',
|
||||
],
|
||||
'extras' => [
|
||||
'icon' => 'calendar',
|
||||
],
|
||||
]);
|
||||
$settingsMenu = $menu->addChild('Einstellungen', [
|
||||
'linkAttributes' => [
|
||||
'title' => 'Einstellungen',
|
||||
|
||||
@@ -23,20 +23,28 @@ class AvailabilityRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Availability::class);
|
||||
}
|
||||
|
||||
public function getListQuery(): Query
|
||||
public function getListQuery(bool $custom = false): Query
|
||||
{
|
||||
$qb = $this->createQueryBuilder('availability');
|
||||
|
||||
return $qb
|
||||
$qb
|
||||
->select('availability', 'teamer')
|
||||
->leftJoin('availability.owner', 'teamer')
|
||||
->where($qb->expr()->andX(
|
||||
$qb->expr()->gt('availability.dateFrom', ':today'),
|
||||
$qb->expr()->isNull('availability.owner'),
|
||||
$qb->expr()->isNull('availability.deletedAt')
|
||||
))
|
||||
->orderBy('availability.dateFrom', 'ASC')
|
||||
->setParameter('today', new \DateTimeImmutable())
|
||||
->getQuery()
|
||||
;
|
||||
|
||||
if (false === $custom) {
|
||||
$qb->andWhere($qb->expr()->isNull('availability.owner'));
|
||||
} else {
|
||||
$qb->andWhere($qb->expr()->isNotNull('availability.owner'));
|
||||
}
|
||||
|
||||
return $qb->getQuery();
|
||||
}
|
||||
|
||||
public function getSelectableForTeamer(Teamer $teamer): array
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
{% extends 'admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}Eigene Verfügbarkeiten der Teamer{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="text-2xl font-bold pb-8">
|
||||
Eigene Verfügbarkeiten der Teamer
|
||||
</h1>
|
||||
<div class="data-table-wrapper">
|
||||
<div class="data-table-wrapper__inner">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-1/4">
|
||||
{{ knp_pagination_sortable(pagination, 'Datum von', 'availability.dateFrom') }}
|
||||
</th>
|
||||
<th class="w-1/4">
|
||||
{{ knp_pagination_sortable(pagination, 'Datum bis', 'availability.dateTo') }}
|
||||
</th>
|
||||
<th class="w-1/4">
|
||||
{{ knp_pagination_sortable(pagination, 'Teamer', 'teamer.lastName') }}
|
||||
</th>
|
||||
<th class="w-1/4">
|
||||
{{ knp_pagination_sortable(pagination, 'Beschreibung', 'availability.description') }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for availability in pagination %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ availability.dateFrom|date('d.m.Y') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ availability.dateTo|date('d.m.Y') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ availability.owner.lastName }}, {{ availability.owner.firstName }}
|
||||
</td>
|
||||
<td>
|
||||
{{ availability.description|default('-') }}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
Keine Daten...
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ knp_pagination_render(pagination) }}
|
||||
</div>
|
||||
</div>
|
||||
<button type="button"
|
||||
class="btn"
|
||||
title="Zeitraum hinzufügen"
|
||||
hx-get="{{ path('app_admin_system_availability_create') }}"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend">
|
||||
Zeitraum hinzufügen
|
||||
</button>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user