47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Administrative\System\StaffingRule;
|
|
|
|
use App\Service\Assignment\StaffingConfigurationException;
|
|
use App\Service\Export\StaffingPreviewExporter;
|
|
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 PreviewController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly StaffingPreviewExporter $previewExporter,
|
|
private readonly PaginatorInterface $paginator,
|
|
) {
|
|
}
|
|
|
|
#[Route('/administrative/system/staffing-rule/preview', name: 'app_administrative_system_staffing_rule_preview')]
|
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
|
public function index(Request $request): Response
|
|
{
|
|
try {
|
|
$rows = $this->previewExporter->rows();
|
|
} catch (StaffingConfigurationException $e) {
|
|
$this->addFlash('error', 'Ein Jobprofil oder Honorar der Besetzungsmatrix ist nicht (mehr) vorhanden: '.$e->getMessage());
|
|
|
|
return $this->redirectToRoute('app_administrative_system_staffing_rule_index');
|
|
}
|
|
|
|
// The candidates are a computed list, not a query: page the finished rows. The Excel
|
|
// export stays the full list.
|
|
$pagination = $this->paginator->paginate(
|
|
$rows,
|
|
$request->query->getInt('page', 1),
|
|
$request->query->getInt('limit', 50),
|
|
);
|
|
|
|
return $this->render('administrative/system/staffing_rule/preview.html.twig', [
|
|
'pagination' => $pagination,
|
|
]);
|
|
}
|
|
}
|