WIP: Implement teamer document upload handling

This commit is contained in:
Björn Fromme
2023-10-12 19:50:08 +02:00
parent bfd18b21ce
commit 6df725edc4
25 changed files with 611 additions and 165 deletions
+1
View File
@@ -55,6 +55,7 @@
"symfony/validator": "6.3.*", "symfony/validator": "6.3.*",
"symfony/web-link": "6.3.*", "symfony/web-link": "6.3.*",
"symfony/webpack-encore-bundle": "^2.0", "symfony/webpack-encore-bundle": "^2.0",
"symfony/workflow": "6.3.*",
"symfony/yaml": "6.3.*", "symfony/yaml": "6.3.*",
"twig/extra-bundle": "^2.12|^3.0", "twig/extra-bundle": "^2.12|^3.0",
"twig/html-extra": "^3.7", "twig/html-extra": "^3.7",
Generated
+86 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d714db6b49b6684caaf4544a90193da3", "content-hash": "51c0d10a5e4bd074ddab5fe5717af560",
"packages": [ "packages": [
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
@@ -8116,6 +8116,91 @@
], ],
"time": "2023-09-26T14:41:29+00:00" "time": "2023-09-26T14:41:29+00:00"
}, },
{
"name": "symfony/workflow",
"version": "v6.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/workflow.git",
"reference": "a2a506b81556dea75a18f0d4a34462ff633e3522"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/workflow/zipball/a2a506b81556dea75a18f0d4a34462ff633e3522",
"reference": "a2a506b81556dea75a18f0d4a34462ff633e3522",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3"
},
"conflict": {
"symfony/event-dispatcher": "<5.4"
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/expression-language": "^5.4|^6.0",
"symfony/security-core": "^5.4|^6.0",
"symfony/validator": "^5.4|^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Workflow\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "[email protected]"
},
{
"name": "Grégoire Pineau",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides tools for managing a workflow or finite state machine",
"homepage": "https://symfony.com",
"keywords": [
"petrinet",
"place",
"state",
"statemachine",
"transition",
"workflow"
],
"support": {
"source": "https://github.com/symfony/workflow/tree/v6.3.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2023-08-01T15:55:06+00:00"
},
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v6.3.3", "version": "v6.3.3",
+6
View File
@@ -18,6 +18,12 @@ oneup_uploader:
namer: app.upload_namer namer: app.upload_namer
storage: storage:
directory: '%kernel.project_dir%/uploads/contract' directory: '%kernel.project_dir%/uploads/contract'
invoice:
frontend: dropzone
use_orphanage: true
namer: app.upload_namer
storage:
directory: '%kernel.project_dir%/uploads/invoice'
document: document:
frontend: dropzone frontend: dropzone
use_orphanage: true use_orphanage: true
+33
View File
@@ -0,0 +1,33 @@
framework:
workflows:
disposition:
type: state_machine
marking_store:
type: method
property: status
supports:
- App\Entity\Disposition
initial_marking: new
places:
- new
- checking_contract
- confirmed
- checking_invoice
- paid
- completed
transitions:
upload_contract:
from: new
to: checking_contract
confirm_contract:
from: checking_contract
to: confirmed
upload_invoice:
from: confirmed
to: checking_invoice
confirm_invoice:
from: checking_invoice
to: paid
complete:
from: confirmed
to: completed
+45
View File
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231012164550 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE disposition DROP FOREIGN KEY FK_4C58BF60EA295441');
$this->addSql('ALTER TABLE disposition DROP FOREIGN KEY FK_4C58BF606D5F2C5F');
$this->addSql('DROP INDEX UNIQ_4C58BF606D5F2C5F ON disposition');
$this->addSql('DROP INDEX UNIQ_4C58BF60EA295441 ON disposition');
$this->addSql('ALTER TABLE disposition DROP contract_pdf_id, DROP invoice_pdf_id');
$this->addSql('ALTER TABLE upload ADD disposition_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE upload ADD CONSTRAINT FK_17BDE61F287B65ED FOREIGN KEY (disposition_id) REFERENCES disposition (id)');
$this->addSql('CREATE INDEX IDX_17BDE61F287B65ED ON upload (disposition_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE disposition ADD contract_pdf_id INT DEFAULT NULL, ADD invoice_pdf_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE disposition ADD CONSTRAINT FK_4C58BF60EA295441 FOREIGN KEY (invoice_pdf_id) REFERENCES upload (id)');
$this->addSql('ALTER TABLE disposition ADD CONSTRAINT FK_4C58BF606D5F2C5F FOREIGN KEY (contract_pdf_id) REFERENCES upload (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4C58BF606D5F2C5F ON disposition (contract_pdf_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4C58BF60EA295441 ON disposition (invoice_pdf_id)');
$this->addSql('ALTER TABLE upload DROP FOREIGN KEY FK_17BDE61F287B65ED');
$this->addSql('DROP INDEX IDX_17BDE61F287B65ED ON upload');
$this->addSql('ALTER TABLE upload DROP disposition_id');
}
}
@@ -22,14 +22,17 @@ class IndexController extends AbstractController
#[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response public function index(Request $request): Response
{ {
$query = $this->uploadRepository->getDocumentListQuery(); $query = $this
->uploadRepository
->getUploadListQuery()
;
$pagination = $this->paginator->paginate( $pagination = $this->paginator->paginate(
$query, $query,
$request->query->getInt('page', 1), $request->query->getInt('page', 1),
10, 10,
[ [
'defaultSortFieldName' => 'upload.originalFilename', 'defaultSortFieldName' => 'upload.createdAt',
'defaultSortDirection' => 'asc', 'defaultSortDirection' => 'asc',
] ]
); );
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\Document; namespace App\Controller\Admin\System\Document;
use App\Entity\Upload; use App\Entity\Upload;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@@ -18,7 +18,7 @@ class DeleteController extends AbstractController
) { ) {
} }
#[Route('/admin/document/delete/{uuid}', name: 'app_admin_document_delete')] #[Route('/admin/system/document/delete/{uuid}', name: 'app_admin_system_document_delete')]
#[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('ROLE_ADMINISTRATIVE')]
#[IsGranted('DELETE', subject: 'document')] #[IsGranted('DELETE', subject: 'document')]
public function index(Upload $document): Response public function index(Upload $document): Response
@@ -31,6 +31,6 @@ class DeleteController extends AbstractController
'document' => $document->getOriginalFilename(), 'document' => $document->getOriginalFilename(),
]); ]);
return $this->redirectToRoute('app_admin_document_index'); return $this->redirectToRoute('app_admin_system_document_index');
} }
} }
@@ -0,0 +1,41 @@
<?php
namespace App\Controller\Admin\System\Document;
use App\Repository\UploadRepository;
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\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(
private readonly UploadRepository $uploadRepository,
private readonly PaginatorInterface $paginator
) {
}
#[Route('/admin/system/document', name: 'app_admin_system_document_index')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$query = $this->uploadRepository->getDocumentListQuery();
$pagination = $this->paginator->paginate(
$query,
$request->query->getInt('page', 1),
10,
[
'defaultSortFieldName' => 'upload.originalFilename',
'defaultSortDirection' => 'asc',
]
);
return $this->render('admin/system/document/index.html.twig', [
'pagination' => $pagination,
]);
}
}
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\Document; namespace App\Controller\Admin\System\Document;
use App\Entity\Upload; use App\Entity\Upload;
use App\Model\AjaxModalResponseDto; use App\Model\AjaxModalResponseDto;
@@ -21,12 +21,12 @@ class RenameController extends AbstractController
) { ) {
} }
#[Route('/admin/document/rename/{uuid}', name: 'app_admin_document_rename')] #[Route('/admin/system/document/rename/{uuid}', name: 'app_admin_system_document_rename')]
#[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Upload $upload, Request $request): JsonResponse public function index(Upload $upload, Request $request): JsonResponse
{ {
$response = new AjaxModalResponseDto(); $response = new AjaxModalResponseDto();
$formAction = $this->generateUrl('app_admin_document_rename', ['uuid' => $upload->getUuid()]); $formAction = $this->generateUrl('app_admin_system_document_rename', ['uuid' => $upload->getUuid()]);
$form = $this $form = $this
->createFormBuilder($upload, ['action' => $formAction, 'ajax_submit' => true]) ->createFormBuilder($upload, ['action' => $formAction, 'ajax_submit' => true])
@@ -42,9 +42,9 @@ class RenameController extends AbstractController
$this->addFlash('success', 'Das Dokument wurden umbenannt'); $this->addFlash('success', 'Das Dokument wurden umbenannt');
$this->logger->info('Rename document'); $this->logger->info('Rename document');
$response->setCloseAndRedirect($this->generateUrl('app_admin_document_index')); $response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index'));
} else { } else {
$response->setContent($this->renderView('admin/document/rename.html.twig', [ $response->setContent($this->renderView('admin/system/document/rename.html.twig', [
'form' => $form, 'form' => $form,
])); ]));
} }
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\Document; namespace App\Controller\Admin\System\Document;
use App\Entity\Upload; use App\Entity\Upload;
use App\Entity\User; use App\Entity\User;
@@ -23,7 +23,7 @@ class ReplaceController extends AbstractController
) { ) {
} }
#[Route('/admin/document/replace/{uuid}', name: 'app_admin_document_replace')] #[Route('/admin/system/document/replace/{uuid}', name: 'app_admin_system_document_replace')]
#[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Upload $upload, Request $request): JsonResponse public function index(Upload $upload, Request $request): JsonResponse
{ {
@@ -39,7 +39,7 @@ class ReplaceController extends AbstractController
} }
$response = new AjaxModalResponseDto(); $response = new AjaxModalResponseDto();
$formAction = $this->generateUrl('app_admin_document_replace', ['uuid' => $upload->getUuid()]); $formAction = $this->generateUrl('app_admin_system_document_replace', ['uuid' => $upload->getUuid()]);
$form = $this $form = $this
->createFormBuilder(null, ['action' => $formAction, 'ajax_submit' => true]) ->createFormBuilder(null, ['action' => $formAction, 'ajax_submit' => true])
@@ -51,9 +51,9 @@ class ReplaceController extends AbstractController
$this->addFlash('success', 'Das Dokument wurden ersetzt'); $this->addFlash('success', 'Das Dokument wurden ersetzt');
$this->logger->info('Replace document'); $this->logger->info('Replace document');
$response->setCloseAndRedirect($this->generateUrl('app_admin_document_index')); $response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index'));
} else { } else {
$response->setContent($this->renderView('admin/document/replace.html.twig', [ $response->setContent($this->renderView('admin/system/document/replace.html.twig', [
'form' => $form, 'form' => $form,
])); ]));
} }
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\Document; namespace App\Controller\Admin\System\Document;
use App\Entity\Upload; use App\Entity\Upload;
use App\Entity\User; use App\Entity\User;
@@ -23,7 +23,7 @@ class UploadController extends AbstractController
) { ) {
} }
#[Route('/admin/document/upload', name: 'app_admin_document_upload')] #[Route('/admin/system/document/upload', name: 'app_admin_system_document_upload')]
#[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): JsonResponse public function index(Request $request): JsonResponse
{ {
@@ -42,7 +42,7 @@ class UploadController extends AbstractController
} }
$response = new AjaxModalResponseDto(); $response = new AjaxModalResponseDto();
$formAction = $this->generateUrl('app_admin_document_upload'); $formAction = $this->generateUrl('app_admin_system_document_upload');
$form = $this $form = $this
->createFormBuilder(null, ['action' => $formAction, 'ajax_submit' => true]) ->createFormBuilder(null, ['action' => $formAction, 'ajax_submit' => true])
@@ -54,9 +54,9 @@ class UploadController extends AbstractController
$this->addFlash('success', 'Das/die Dokument/e wurden hochgeladen'); $this->addFlash('success', 'Das/die Dokument/e wurden hochgeladen');
$this->logger->info('Upload document'); $this->logger->info('Upload document');
$response->setCloseAndRedirect($this->generateUrl('app_admin_document_index')); $response->setCloseAndRedirect($this->generateUrl('app_admin_system_document_index'));
} else { } else {
$response->setContent($this->renderView('admin/document/upload.html.twig', [ $response->setContent($this->renderView('admin/system/document/upload.html.twig', [
'form' => $form, 'form' => $form,
])); ]));
} }
@@ -10,12 +10,12 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Security\Http\Attribute\IsGranted;
class ContractController extends AbstractController class ContractPdfController extends AbstractController
{ {
public function __construct(private readonly ContractRenderer $renderer) public function __construct(private readonly ContractRenderer $renderer)
{} {}
#[Route('/teamer/disposition/contract/{uuid}', name: 'app_teamer_disposition_contract')] #[Route('/teamer/disposition/contract/{uuid}', name: 'app_teamer_disposition_contractpdf')]
#[IsGranted('CONTRACT', subject: 'disposition')] #[IsGranted('CONTRACT', subject: 'disposition')]
public function index(Disposition $disposition): Response public function index(Disposition $disposition): Response
{ {
@@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Workflow\WorkflowInterface;
class DetailController extends AbstractController class DetailController extends AbstractController
{ {
@@ -23,6 +24,7 @@ class DetailController extends AbstractController
public function __construct( public function __construct(
private readonly UploadHandler $uploadHandler, private readonly UploadHandler $uploadHandler,
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
private readonly WorkflowInterface $dispositionStateMachine,
private readonly LoggerInterface $logger private readonly LoggerInterface $logger
) { ) {
} }
@@ -31,16 +33,22 @@ class DetailController extends AbstractController
#[IsGranted('VIEW', subject: 'disposition')] #[IsGranted('VIEW', subject: 'disposition')]
public function index(Disposition $disposition, Request $request): Response public function index(Disposition $disposition, Request $request): Response
{ {
// Handle upload independently from form submission to avoid issues with failing validation // Create dummy form without fields to generate POST requests
$uploadSession = $this->uploadHandler->getUploadSession();
if (true === $request->isMethod('POST') && 0 < $uploadSession->getCount()) {
$this->updateContract($disposition, $uploadSession);
}
$form = $this->createFormBuilder()->getForm(); $form = $this->createFormBuilder()->getForm();
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$uploadSession = $this->uploadHandler->getUploadSession();
if (0 < $uploadSession->getCount()) {
if (true === $this->dispositionStateMachine->can($disposition, 'upload_contract')) {
$this->uploadContract($disposition, $uploadSession);
}
if (true === $this->dispositionStateMachine->can($disposition, 'upload_invoice')) {
$this->uploadInvoice($disposition, $uploadSession);
}
}
return $this->redirectToRoute('app_teamer_disposition_detail', [ return $this->redirectToRoute('app_teamer_disposition_detail', [
'uuid' => $disposition->getUuid(), 'uuid' => $disposition->getUuid(),
]); ]);
@@ -48,28 +56,61 @@ class DetailController extends AbstractController
return $this->render('teamer/disposition/detail.html.twig', [ return $this->render('teamer/disposition/detail.html.twig', [
'disposition' => $disposition, 'disposition' => $disposition,
'returnUrl' => $this->getReturnUrl($request, 'app_teamer_index'),
'form' => $form, 'form' => $form,
'returnUrl' => $this->getReturnUrl($request, 'app_teamer_index'),
]); ]);
} }
private function uploadContract(Disposition $disposition, UploadSessionDto $uploadSession): void
private function updateContract(Disposition $disposition, UploadSessionDto $uploadSession): void
{ {
if (null !== $existingUpload = $disposition->getContractPdf()) { if (null !== $existingUpload = $disposition->getDocumentByType(Upload::TYPE_CONTRACT)) {
$this->entityManager->remove($existingUpload); $this->entityManager->remove($existingUpload);
} }
/** @var User $user */ /** @var User $user */
$user = $this->getUser(); $user = $this->getUser();
$upload = Upload::fromUploadDto($uploadSession->getUploads()->first(), $user, Upload::TYPE_CONTRACT); $upload = Upload::fromUploadDto($uploadSession->getUploads()->first(), $user, Upload::TYPE_CONTRACT);
$disposition->setContractPdf($upload); $upload->setStatus(Upload::STATUS_NEW);
$disposition->addDocument($upload);
$this->dispositionStateMachine->apply($disposition, 'upload_contract');
$this->entityManager->flush(); $this->entityManager->flush();
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_CONTRACT, $uploadSession); $this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_CONTRACT, $uploadSession);
$this->uploadHandler->destroyUploadSession(); $this->uploadHandler->destroyUploadSession();
$this->addFlash('success', 'Der Honorarvertrag wurde hochgeladen'); $this->addFlash('success', 'Der Honorarvertrag wurde hochgeladen');
$this->logger->info('Update contract', [
$this->logger->info('Upload contract', [
'user' => $user->getUserIdentifier(),
]);
}
private function uploadInvoice(Disposition $disposition, UploadSessionDto $uploadSession): void
{
if (null !== $existingUpload = $disposition->getDocumentByType(Upload::TYPE_INVOICE)) {
$this->entityManager->remove($existingUpload);
}
/** @var User $user */
$user = $this->getUser();
$upload = Upload::fromUploadDto($uploadSession->getUploads()->first(), $user, Upload::TYPE_INVOICE);
$upload->setStatus(Upload::STATUS_NEW);
$disposition->addDocument($upload);
$this->dispositionStateMachine->apply($disposition, 'upload_invoice');
$this->entityManager->flush();
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_INVOICE, $uploadSession);
$this->uploadHandler->destroyUploadSession();
$this->addFlash('success', 'Die Honornote wurde hochgeladen');
$this->logger->info('Upload invoice', [
'user' => $user->getUserIdentifier(), 'user' => $user->getUserIdentifier(),
]); ]);
} }
+37 -17
View File
@@ -5,6 +5,8 @@ namespace App\Entity;
use App\Entity\Traits\BlameableEntity; use App\Entity\Traits\BlameableEntity;
use App\Entity\Traits\TimestampableEntity; use App\Entity\Traits\TimestampableEntity;
use App\Repository\DispositionRepository; use App\Repository\DispositionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
@@ -16,8 +18,11 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
use TimestampableEntity; use TimestampableEntity;
public const STATUS_NEW = 'new'; public const STATUS_NEW = 'new';
public const STATUS_PENDING = 'pending'; public const STATUS_CHECKING_CONTRACT = 'checking_contract';
public const STATUS_CONFIRMED = 'confirmed'; public const STATUS_CONFIRMED = 'confirmed';
public const STATUS_CHECKING_INVOICE = 'checking_invoice';
public const STATUS_PAID = 'paid';
public const STATUS_COMPLETED = 'completed';
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
@@ -39,11 +44,8 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
#[ORM\Column(type: Types::TEXT, nullable: true)] #[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $remarks; private ?string $remarks;
#[ORM\OneToOne(cascade: ['persist', 'remove'])] #[ORM\OneToMany(mappedBy: 'disposition', targetEntity: Upload::class, cascade: ['persist', 'remove'])]
private ?Upload $contractPdf = null; private Collection $documents;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?Upload $invoicePdf = null;
public function __construct(Application $application) public function __construct(Application $application)
{ {
@@ -52,6 +54,7 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
$this->assignment = $application->getAssignment(); $this->assignment = $application->getAssignment();
$this->teamer = $application->getTeamer(); $this->teamer = $application->getTeamer();
$this->remarks = $application->getRemarks(); $this->remarks = $application->getRemarks();
$this->documents = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
@@ -112,26 +115,43 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
return $this; return $this;
} }
public function getContractPdf(): ?Upload /**
* @return Collection<int, Upload>
*/
public function getDocuments(): Collection
{ {
return $this->contractPdf; return $this->documents;
} }
public function setContractPdf(?Upload $contractPdf): static public function getDocumentByType(string $type): ?Upload
{ {
$this->contractPdf = $contractPdf; foreach ($this->getDocuments() as $upload) {
if ($type === $upload->getType()) {
return $upload;
}
}
return null;
}
public function addDocument(Upload $document): static
{
if (!$this->documents->contains($document)) {
$this->documents->add($document);
$document->setDisposition($this);
}
return $this; return $this;
} }
public function getInvoicePdf(): ?Upload public function removeDocument(Upload $document): static
{ {
return $this->invoicePdf; if ($this->documents->removeElement($document)) {
} // set the owning side to null (unless already changed)
if ($document->getDisposition() === $this) {
public function setInvoicePdf(?Upload $invoicePdf): static $document->setDisposition(null);
{ }
$this->invoicePdf = $invoicePdf; }
return $this; return $this;
} }
+17 -2
View File
@@ -22,9 +22,9 @@ class Upload implements BlameableEntityInterface, TimestampableEntityInterface
public const TYPE_DOCUMENT = 'document'; public const TYPE_DOCUMENT = 'document';
public const STATUS_NEW = 'new'; public const STATUS_NEW = 'new';
public const STATUS_IN_PROCESS = 'in_process'; public const CHECKING = 'checking';
public const STATUS_CHECKED = 'checked'; public const STATUS_CHECKED = 'checked';
public const STATUS_PAYED = 'payed'; public const STATUS_PAID = 'paid';
public const STATUS_ERROR = 'error'; public const STATUS_ERROR = 'error';
#[ORM\Id] #[ORM\Id]
@@ -59,6 +59,9 @@ class Upload implements BlameableEntityInterface, TimestampableEntityInterface
#[ORM\ManyToOne] #[ORM\ManyToOne]
private ?User $owner = null; private ?User $owner = null;
#[ORM\ManyToOne(inversedBy: 'documents')]
private ?Disposition $disposition = null;
public function __construct() public function __construct()
{ {
$this->uuid = Uuid::v4(); $this->uuid = Uuid::v4();
@@ -184,4 +187,16 @@ class Upload implements BlameableEntityInterface, TimestampableEntityInterface
return $this; return $this;
} }
public function getDisposition(): ?Disposition
{
return $this->disposition;
}
public function setDisposition(?Disposition $disposition): static
{
$this->disposition = $disposition;
return $this;
}
} }
+4
View File
@@ -83,6 +83,10 @@ class AdminMenuBuilder extends AbstractMenuBuilder
], ],
], ],
], ],
[
'route' => 'app_admin_system_document_index',
'title' => 'Dokumente',
],
], ],
], ],
]; ];
+15
View File
@@ -68,4 +68,19 @@ class UploadRepository extends ServiceEntityRepository
return $data; return $data;
} }
public function getUploadListQuery(): Query
{
$qb = $this->createQueryBuilder('upload');
return $qb
->select('upload', 'disposition', 'assignment', 'job_profile', 'destination', 'teamer')
->innerJoin('upload.disposition', 'disposition')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.jobProfile', 'job_profile')
->innerJoin('assignment.destination', 'destination')
->innerJoin('disposition.teamer', 'teamer')
->getQuery()
;
}
} }
+12
View File
@@ -341,6 +341,18 @@
"webpack.config.js" "webpack.config.js"
] ]
}, },
"symfony/workflow": {
"version": "6.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.3",
"ref": "3b2f8ca32a07fcb00f899649053943fa3d8bbfb6"
},
"files": [
"config/packages/workflow.yaml"
]
},
"twig/extra-bundle": { "twig/extra-bundle": {
"version": "v3.6.1" "version": "v3.6.1"
} }
+71 -87
View File
@@ -6,94 +6,78 @@
<h1 class="text-2xl font-bold pb-8"> <h1 class="text-2xl font-bold pb-8">
Dokumentenübersicht Dokumentenübersicht
</h1> </h1>
<div class="data-table-wrapper"> <div class="data-table-wrapper">
<div class="data-table-wrapper__inner"> <div class="data-table-wrapper__inner">
<table class="data-table"> <table class="data-table">
<thead> <thead>
<tr>
<th>
{{ knp_pagination_sortable(pagination, 'Dateiname', 'upload.originalFilename') }}
</th>
<th>
Dateigröße
</th>
<th>
Upload am
</th>
<th>
Upload von
</th>
<th></th>
</tr>
</thead>
<tbody>
{% for document in pagination %}
<tr> <tr>
<td> <th>
{{ document.displayName ? document.displayName : document.originalFilename }} {{ knp_pagination_sortable(pagination, 'Einsatzzeitraum', 'destination.dateFrom') }}
</td> </th>
<td> <th>
{{ document.size|file_size }} {{ knp_pagination_sortable(pagination, 'Jobprofil', 'job_profile.name') }}
</td> </th>
<td> <th>
{{ document.createdAt|date('d.m.Y') }} {{ knp_pagination_sortable(pagination, 'Destination', 'destination.product') }}
</td> </th>
<td> <th>
{{ document.createdBy }} {{ knp_pagination_sortable(pagination, 'Dokument', 'upload.type') }}
</td> </th>
<td> <th>
<div class="flex items-center space-x-2 justify-end"> {{ knp_pagination_sortable(pagination, 'Teamer', 'teamer.lastName') }}
<button type="button" </th>
class="text-red-500" <th>
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }} {{ knp_pagination_sortable(pagination, 'Status', 'disposition.status') }}
{{ stimulus_action('modal-button', 'confirmation', null, { </th>
'title': 'Bist du sicher?', <th></th>
'content': 'Möchtest du das Dokument wirklich löschen?',
'target-url': path('app_admin_document_delete', { 'uuid': document.uuid })
}) }}>
{{ icon('delete') }}
</button>
<button type="button"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokument ersetzen',
'url': path('app_admin_document_replace', { 'uuid': document.uuid })
}) }}>
{{ icon('refresh') }}
</button>
<button type="button"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokument umbenennen',
'url': path('app_admin_document_rename', { 'uuid': document.uuid })
}) }}>
{{ icon('edit') }}
</button>
<a href="{{ path('app_common_download', { 'uuid': document.uuid }) }}"
title="Download">
{{ icon('download') }}
</a>
</div>
</td>
</tr> </tr>
{% else %} </thead>
<tr> <tbody>
<td colspan="7"> {% for upload in pagination %}
Keine Daten... {% set disposition = upload.disposition %}
</td> {% set assignment = disposition.assignment %}
</tr> <tr>
{% endfor %} <td>
</tbody> {{ assignment.destination.dateFrom|date('d.m.Y') }}
</table> -
{{ assignment.destination.dateTo|date('d.m.Y') }}
</td>
<td>
{{ assignment.jobProfile.name }}
</td>
<td>
{{ assignment.destination.product }}
<br>
{{ assignment.destination.hotel }}
</td>
<td>
{{ ('label.document.type.' ~ upload.type)|trans }}
</td>
<td>
{{ disposition.teamer }}
</td>
<td>
{{ ('label.document.status.' ~ upload.status)|trans }}
</td>
<td>
<div class="flex items-center space-x-2">
<a href="{{ path('app_common_download', { 'uuid': upload.uuid }) }}"
title="Download"
target="_blank">
{{ icon('download') }}
</a>
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="7">
Keine Daten...
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div> </div>
</div>
<button type="button"
class="btn"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokumente hinzufügen',
'url': path('app_admin_document_upload')
}) }}>
Dokumente hinzufügen
</button>
{% endblock %} {% endblock %}
@@ -0,0 +1,99 @@
{% extends 'admin/layout.html.twig' %}
{% block title %}Dokumentenübersicht{% endblock %}
{% block content %}
<h1 class="text-2xl font-bold pb-8">
Dokumentenübersicht
</h1>
<div class="data-table-wrapper">
<div class="data-table-wrapper__inner">
<table class="data-table">
<thead>
<tr>
<th>
{{ knp_pagination_sortable(pagination, 'Dateiname', 'upload.originalFilename') }}
</th>
<th>
Dateigröße
</th>
<th>
Upload am
</th>
<th>
Upload von
</th>
<th></th>
</tr>
</thead>
<tbody>
{% for document in pagination %}
<tr>
<td>
{{ document.displayName ? document.displayName : document.originalFilename }}
</td>
<td>
{{ document.size|file_size }}
</td>
<td>
{{ document.createdAt|date('d.m.Y') }}
</td>
<td>
{{ document.createdBy }}
</td>
<td>
<div class="flex items-center space-x-2 justify-end">
<button type="button"
class="text-red-500"
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }}
{{ stimulus_action('modal-button', 'confirmation', null, {
'title': 'Bist du sicher?',
'content': 'Möchtest du das Dokument wirklich löschen?',
'target-url': path('app_admin_system_document_delete', { 'uuid': document.uuid })
}) }}>
{{ icon('delete') }}
</button>
<button type="button"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokument ersetzen',
'url': path('app_admin_system_document_replace', { 'uuid': document.uuid })
}) }}>
{{ icon('refresh') }}
</button>
<button type="button"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokument umbenennen',
'url': path('app_admin_system_document_rename', { 'uuid': document.uuid })
}) }}>
{{ icon('edit') }}
</button>
<a href="{{ path('app_common_download', { 'uuid': document.uuid }) }}"
title="Download">
{{ icon('download') }}
</a>
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="7">
Keine Daten...
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<button type="button"
class="btn"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokumente hinzufügen',
'url': path('app_admin_system_document_upload')
}) }}>
Dokumente hinzufügen
</button>
{% endblock %}
+65 -23
View File
@@ -20,29 +20,71 @@
<br> <br>
{{ assignment.contact }}, <a href="mailto:{{ assignment.contact.email }}" class="underline">{{ assignment.contact.email }}</a> {{ assignment.contact }}, <a href="mailto:{{ assignment.contact.email }}" class="underline">{{ assignment.contact.email }}</a>
</p> </p>
<h3 class="text-xl font-bold pb-4"> {% if workflow_can(disposition, 'upload_contract') %}
Hier findest du deinen Honorarvertrag <h3 class="text-xl font-bold pb-4">
</h3> Hier findest du deinen Honorarvertrag
<div class="pb-4"> </h3>
<a href="{{ path('app_teamer_disposition_contract', { 'uuid': disposition.uuid }) }}" target="_blank" class="inline-block"> <div class="pb-4">
<img src="{{ asset('build/images/contract_thumb.jpg') }}" alt="Honorarvertrag" class="block w-32 h-auto shadow-md"> <a href="{{ path('app_teamer_disposition_contractpdf', { 'uuid': disposition.uuid }) }}" target="_blank" class="inline-block">
</a> <img src="{{ asset('build/images/contract_thumb.jpg') }}" alt="Honorarvertrag" class="block w-32 h-auto shadow-md">
</div> </a>
<p class="pb-4"> </div>
Bitte lade ihn unterschrieben hier wieder hoch: <p class="pb-4">
</p> Bitte lade ihn unterschrieben hier wieder hoch:
{{ form_start(form) }} </p>
<div class="pb-4"> {{ form_start(form) }}
{% include '_partials/_upload_collection_form.html.twig' with { <div class="pb-4">
'endpoint_upload': path('_uploader_upload_contract'), {% include '_partials/_upload_collection_form.html.twig' with {
'accepted_files': 'image/jpg,image/jpeg,application/pdf', 'endpoint_upload': path('_uploader_upload_contract'),
} %} 'accepted_files': 'image/jpg,image/jpeg,application/pdf',
</div> } %}
<button type="submit" class="btn"> </div>
Aktualisieren <button type="submit" class="btn">
</button> Aktualisieren
{{ form_rest(form) }} </button>
{{ form_end(form) }} {{ form_rest(form) }}
{{ form_end(form) }}
{% elseif workflow_can(disposition, 'upload_invoice') %}
<h3 class="text-xl font-bold pb-4">
Hier findest du deine Honorarnote
</h3>
<div class="pb-4">
<a href="{{ path('app_teamer_disposition_contractpdf', { 'uuid': disposition.uuid }) }}" target="_blank" class="inline-block">
<img src="{{ asset('build/images/contract_thumb.jpg') }}" alt="Honorarvertrag" class="block w-32 h-auto shadow-md">
</a>
</div>
<p class="pb-4">
Bitte lade sie ausgefüllt und unterschrieben hier wieder hoch:
</p>
{{ form_start(form) }}
<div class="pb-4">
{% include '_partials/_upload_collection_form.html.twig' with {
'endpoint_upload': path('_uploader_upload_invoice'),
'accepted_files': 'image/jpg,image/jpeg,application/pdf',
} %}
</div>
<button type="submit" class="btn">
Aktualisieren
</button>
{{ form_rest(form) }}
{{ form_end(form) }}
{% elseif workflow_has_marked_place(disposition, 'checking_contract') %}
<h3 class="text-xl font-bold pb-4">
Danke für den Upload des Honorarvertrags
</h3>
{% elseif workflow_has_marked_place(disposition, 'checking_invoice') %}
<h3 class="text-xl font-bold pb-4">
Danke für den Upload der Honorarnote
</h3>
{% elseif workflow_has_marked_place(disposition, 'paid') %}
<h3 class="text-xl font-bold pb-4">
Dein Honorar wurde überwiesen
</h3>
{% else %}
<h3 class="text-xl font-bold pb-4">
Dein Einsatz ist abgeschlossen
</h3>
{% endif %}
<div class="pt-4"> <div class="pt-4">
<a href="{{ returnUrl }}" class="underline"> <a href="{{ returnUrl }}" class="underline">
zurück zurück
+1 -1
View File
@@ -17,7 +17,7 @@ label:
photo: Foto photo: Foto
status: status:
new: neu new: neu
in_process: in Bearbeitung checking: in Bearbeitung
checked: geprüft checked: geprüft
payed: bezahlt payed: bezahlt
error: Fehler error: Fehler