feat: update status and sign contracts uploaded by admin

This commit is contained in:
Björn Fromme
2025-04-08 16:27:02 +02:00
parent a92832f069
commit a7314ce549
@@ -4,10 +4,13 @@ namespace App\Controller\Administrative\Disposition;
use App\Entity\Disposition;
use App\Entity\Upload;
use App\Entity\User;
use App\Event\DocumentConfirmedEvent;
use App\Event\DocumentUploadedEvent;
use App\Htmx\HxRedirectResponse;
use App\Service\Upload\UploadHandler;
use Doctrine\ORM\EntityManagerInterface;
use Flagception\Manager\FeatureManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -23,6 +26,7 @@ class DocumentUploadController extends AbstractController
private readonly EntityManagerInterface $entityManager,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly LoggerInterface $logger,
private readonly FeatureManagerInterface $featureManager,
) {
}
@@ -63,21 +67,36 @@ class DocumentUploadController extends AbstractController
}
$teamer = $disposition->getTeamer();
$user = $teamer->getUser();
$uploadSession = $this->uploadHandler->getUploadSession();
$upload = Upload::fromUploadDto($uploadSession->getUploads()->first(), $user, Upload::TYPE_CONTRACT);
$upload = Upload::fromUploadDto(
$uploadSession->getUploads()->first(),
$teamer->getUser(),
Upload::TYPE_CONTRACT
);
$upload->setStatus(Upload::STATUS_CHECKED);
$disposition->addDocument($upload);
/** @var User $user */
$user = $this->getUser();
$upload
->setApprovedAt(new \DateTimeImmutable())
->setApprovedBy($user->getInitials())
;
$this->entityManager->flush();
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_CONTRACT, $uploadSession);
$this->uploadHandler->destroyUploadSession();
if (true === $this->featureManager->isActive('sanitize_uploads')) {
$this->uploadHandler->ensurePdf($upload);
}
$this->eventDispatcher->dispatch(new DocumentUploadedEvent($upload), DocumentUploadedEvent::NAME);
$this->eventDispatcher->dispatch(new DocumentConfirmedEvent($upload), DocumentConfirmedEvent::NAME);
$this->logger->info('Document upload for teamer', [
'teamer_id' => $teamer->getId(),