feat: timeline for role house manager
closes #869b9vmmx
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Controller\Administrative\Assignment;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Repository\AssignmentRepository;
|
||||
use App\Service\Assignment\TimelineService;
|
||||
use App\Service\Common\TimelineFilterHandler;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
@@ -20,17 +22,26 @@ class TimelineController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/administrative/timeline', name: 'app_administrative_timeline')]
|
||||
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
||||
#[IsGranted(new Expression('is_granted("ROLE_ADMINISTRATIVE") or is_granted("ROLE_HOUSE_MANAGER")'))]
|
||||
public function index(): Response
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
|
||||
$period = $this->timelineService->getActiveWindow();
|
||||
$this->filterHandler->setPeriod($period);
|
||||
|
||||
$filterDto = $this->filterHandler->getFilterSettings();
|
||||
|
||||
$hotelCodes = null;
|
||||
if ($this->isGranted('ROLE_HOUSE_MANAGER')) {
|
||||
$filterDto->setHotels([]);
|
||||
$hotelCodes = $user->getHotelCodes();
|
||||
}
|
||||
|
||||
$assignments = $this
|
||||
->assignmentRepository
|
||||
->getListQuery($filterDto, 'destination.dateFrom')
|
||||
->getListQuery($filterDto, 'destination.dateFrom', $hotelCodes)
|
||||
->getResult()
|
||||
;
|
||||
$timelineData = $this->timelineService->preprocess($assignments);
|
||||
|
||||
Reference in New Issue
Block a user