75 lines
2.3 KiB
PHP
75 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\Administrative\Document;
|
|
|
|
use App\Entity\Upload;
|
|
use App\Repository\UploadRepository;
|
|
use App\Service\Common\DocumentFilterHandler;
|
|
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 IndexController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly UploadRepository $uploadRepository,
|
|
private readonly PaginatorInterface $paginator,
|
|
private readonly DocumentFilterHandler $filterHandler
|
|
) {
|
|
}
|
|
|
|
#[Route('/administrative/document', name: 'app_administrative_document_index')]
|
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
|
public function index(Request $request): Response
|
|
{
|
|
$filterDto = $this->filterHandler->getFilterSettings();
|
|
|
|
$query = $this
|
|
->uploadRepository
|
|
->getUploadListQuery($filterDto)
|
|
;
|
|
|
|
$pagination = $this->paginator->paginate(
|
|
$query,
|
|
$request->query->getInt('page', 1),
|
|
$request->query->getInt('limit', 50),
|
|
);
|
|
|
|
return $this->render('administrative/document/index.html.twig', [
|
|
'pagination' => $pagination,
|
|
'filterDto' => $filterDto,
|
|
]);
|
|
}
|
|
|
|
#[Route(
|
|
path: '/administrative/document/accepted/{type}',
|
|
name: 'app_administrative_document_accepted',
|
|
defaults: ['type' => Upload::TYPE_INVOICE]
|
|
)]
|
|
#[IsGranted('ROLE_ADMINISTRATIVE')]
|
|
public function accepted(string $type, Request $request): Response
|
|
{
|
|
$status = Upload::TYPE_INVOICE === $type ? Upload::STATUS_PAID : Upload::STATUS_CHECKED;
|
|
|
|
$query = $this
|
|
->uploadRepository
|
|
->getBatchDownloadListQuery($type, $status)
|
|
;
|
|
|
|
$pagination = $this->paginator->paginate(
|
|
$query,
|
|
$request->query->getInt('page', 1),
|
|
$request->query->getInt('limit', 50),
|
|
);
|
|
|
|
return $this->render('administrative/document/accepted.html.twig', [
|
|
'pagination' => $pagination,
|
|
'type' => $type,
|
|
'status' => $status,
|
|
]);
|
|
}
|
|
}
|