diff --git a/assets/images/invoice_thumb.jpg b/assets/images/invoice_thumb.jpg new file mode 100644 index 0000000..a4aac49 Binary files /dev/null and b/assets/images/invoice_thumb.jpg differ diff --git a/config/services.yaml b/config/services.yaml index a40437b..8d46b37 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -109,3 +109,7 @@ services: App\Service\Pdf\ContractRenderer: arguments: $options: { 'project_dir': '%kernel.project_dir%' } + + App\Service\Pdf\InvoiceRenderer: + arguments: + $options: { 'project_dir': '%kernel.project_dir%' } diff --git a/src/Controller/Teamer/Disposition/InvoicePdfController.php b/src/Controller/Teamer/Disposition/InvoicePdfController.php new file mode 100644 index 0000000..10d29c3 --- /dev/null +++ b/src/Controller/Teamer/Disposition/InvoicePdfController.php @@ -0,0 +1,36 @@ +renderer->render($disposition); + + $teamer = $disposition->getTeamer(); + + $filename = sprintf('Honorarnote_%s_%s.pdf', $teamer, $disposition->getAssignment()->getDestination()); + $disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $filename, md5($filename)); + + $response = new Response($pdf->Output('S')); + $response->setPrivate(); + $response->headers->set('Content-type', 'application/pdf'); + $response->headers->set('Content-Disposition', $disposition); + + return $response; + } +} \ No newline at end of file diff --git a/src/Security/Voter/DispositionVoter.php b/src/Security/Voter/DispositionVoter.php index cc3dbeb..21cd1e9 100644 --- a/src/Security/Voter/DispositionVoter.php +++ b/src/Security/Voter/DispositionVoter.php @@ -13,6 +13,7 @@ class DispositionVoter extends Voter public const EDIT = 'EDIT'; public const DELETE = 'DELETE'; public const CONTRACT = 'CONTRACT'; + public const INVOICE = 'INVOICE'; protected function supports(string $attribute, mixed $subject): bool { @@ -20,7 +21,7 @@ class DispositionVoter extends Voter return false; } - return in_array($attribute, [static::VIEW, static::EDIT, static::DELETE, static::CONTRACT]); + return in_array($attribute, [static::VIEW, static::EDIT, static::DELETE, static::CONTRACT, static::INVOICE]); } protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool @@ -31,14 +32,20 @@ class DispositionVoter extends Voter } // Teamers may only view or edit their own dispositions - if (in_array('ROLE_TEAMER', $token->getRoleNames()) && in_array($attribute, [static::VIEW, static::EDIT, static::CONTRACT])) { + if (in_array('ROLE_TEAMER', $token->getRoleNames())) { /** @var User $user */ $user = $token->getUser(); $teamer = $user->getTeamer(); /** @var Disposition $disposition */ $disposition = $subject; - return $teamer === $disposition->getTeamer(); + switch ($attribute) { + case static::VIEW: + case static::EDIT: + case static::CONTRACT: + case static::INVOICE: + return $teamer === $disposition->getTeamer(); + } } return false; diff --git a/templates/teamer/disposition/detail.html.twig b/templates/teamer/disposition/detail.html.twig index e8ef6ae..771a018 100644 --- a/templates/teamer/disposition/detail.html.twig +++ b/templates/teamer/disposition/detail.html.twig @@ -68,8 +68,8 @@ Hier findest du deine Honorarnote
- - Honorarvertrag + + Honorarnote