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
|
||||
|
||||
Reference in New Issue
Block a user