feat: hotel manager dashboard
This commit is contained in:
@@ -2,15 +2,52 @@
|
||||
|
||||
namespace App\Controller\HouseManager;
|
||||
|
||||
use App\BusProNet\DataProvider\HotelDataProvider;
|
||||
use App\BusProNet\Model\Hotel;
|
||||
use App\Entity\User;
|
||||
use App\Repository\DispositionRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly HotelDataProvider $hotelDataProvider,
|
||||
private readonly DispositionRepository $dispositionRepository
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/house-manager', name: 'app_house_manager_index')]
|
||||
#[IsGranted('ROLE_HOUSE_MANAGER')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('house_manager/index.html.twig');
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
|
||||
$hotels = $this
|
||||
->hotelDataProvider
|
||||
->findByCode($user->getHotelCode())
|
||||
;
|
||||
|
||||
$hotelBusProIds = array_map(function (Hotel $hotel) {
|
||||
return $hotel->getBusProId();
|
||||
}, $hotels);
|
||||
|
||||
$newDispositions = $this
|
||||
->dispositionRepository
|
||||
->getNewByHotelBusProIds($hotelBusProIds)
|
||||
;
|
||||
|
||||
$pendingFeedbacks = $this
|
||||
->dispositionRepository
|
||||
->getPendingFeedbackByHotelBusProIds($hotelBusProIds)
|
||||
;
|
||||
|
||||
return $this->render('house_manager/index.html.twig', [
|
||||
'newDispositions' => $newDispositions,
|
||||
'pendingFeedbacks' => $pendingFeedbacks,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -113,6 +113,25 @@ class DispositionRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
public function getNewByHotelBusProIds(array $hotelBusProIds): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('disposition');
|
||||
|
||||
return $qb
|
||||
->select('disposition', 'assignment', 'destination')
|
||||
->innerJoin('disposition.assignment', 'assignment')
|
||||
->innerJoin('assignment.destination', 'destination')
|
||||
->where($qb->expr()->andX(
|
||||
$qb->expr()->in('destination.hotelBusProId', ':hotelBusProIds'),
|
||||
$qb->expr()->lt('destination.dateTo', ':dateTo')
|
||||
))
|
||||
->setParameter('hotelBusProIds', $hotelBusProIds)
|
||||
->setParameter('dateTo', new \DateTimeImmutable())
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
public function getPendingFeedbackQuery(array $hotelBusProIds = null): Query
|
||||
{
|
||||
$qb = $this->createQueryBuilder('disposition');
|
||||
@@ -137,4 +156,12 @@ class DispositionRepository extends ServiceEntityRepository
|
||||
|
||||
return $qb->getQuery();
|
||||
}
|
||||
|
||||
public function getPendingFeedbackByHotelBusProIds(array $hotelBusProIds): array
|
||||
{
|
||||
return $this
|
||||
->getPendingFeedbackQuery($hotelBusProIds)
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user