feat: dashboard for role 'manager'
This commit is contained in:
@@ -2,17 +2,45 @@
|
||||
|
||||
namespace App\Controller\Manager;
|
||||
|
||||
use App\Entity\Assignment;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
use App\Repository\AssignmentRepository;
|
||||
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;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
#[Route('/management', name: 'app_manager_index')]
|
||||
public function index(): Response
|
||||
public function __construct(private readonly AssignmentRepository $assignmentRepository, private readonly PaginatorInterface $paginator)
|
||||
{
|
||||
return $this->render('manager/index.html.twig', [
|
||||
}
|
||||
|
||||
#[Route('/management', name: 'app_manager_index')]
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$filterDto = new AssignmentFilterDto();
|
||||
$filterDto->setStatus(Assignment::STATUS_UNSTAFFED);
|
||||
|
||||
$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',
|
||||
]
|
||||
);
|
||||
|
||||
return $this->render('manager/index.html.twig', [
|
||||
'pagination' => $pagination,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
public const STATUS_STAFFED = 'staffed';
|
||||
public const STATUS_PARTLY_STAFFED = 'partly_staffed';
|
||||
public const STATUS_STAFFING = 'staffing';
|
||||
public const STATUS_UNSTAFFED = 'unstaffed';
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
|
||||
@@ -97,6 +97,9 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
->andHaving('COUNT(application.id) > 0')
|
||||
;
|
||||
break;
|
||||
case Assignment::STATUS_UNSTAFFED:
|
||||
$qb->having('assignment.availableDispositions > COUNT(disposition.id)');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user