feat: dashboard for role manager
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user