- Fixed: mandatory fields / form validation for invoice template - Added: Duration as calendar title replacer (open: running records) - Fixed: HTML injection in Calendar - Fixed: Doctrine Proxies are not initialized (leads to empty customer/project) - Fixed: tag creation - Fixed: validation errors do not need to be logged in prod - Removed: Customer VCard download, as used library is outdated and not maintained - Added: supporting translations domains in many new places (menu, help_text, page_setup, report, exporter, calendar)
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai time-tracking app.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\EventSubscriber\Actions;
|
|
|
|
use App\Event\PageActionsEvent;
|
|
use App\Model\InvoiceDocument;
|
|
|
|
final class InvoiceDocumentSubscriber extends AbstractActionsSubscriber
|
|
{
|
|
public static function getActionName(): string
|
|
{
|
|
return 'invoice_document';
|
|
}
|
|
|
|
public function onActions(PageActionsEvent $event): void
|
|
{
|
|
/** @var array<string, InvoiceDocument|null|bool|string> $payload */
|
|
$payload = $event->getPayload();
|
|
if (!\is_array($payload)) {
|
|
return;
|
|
}
|
|
|
|
/** @var InvoiceDocument|null $document */
|
|
$document = \array_key_exists('document', $payload) ? $payload['document'] : null;
|
|
|
|
if ($document === null) {
|
|
return;
|
|
}
|
|
|
|
if (!$this->isGranted('manage_invoice_template')) {
|
|
return;
|
|
}
|
|
|
|
/** @var bool $inUse */
|
|
$inUse = \array_key_exists('in_use', $payload) ? $payload['in_use'] : false;
|
|
/** @var string $token */
|
|
$token = \array_key_exists('token', $payload) ? $payload['token'] : null;
|
|
|
|
$event->addAction('download', ['url' => $this->path('admin_invoice_document_download', ['document' => $document->getId()])]);
|
|
|
|
if ($document->isTwig()) {
|
|
$event->addAction('reload', ['url' => $this->path('admin_invoice_document_reload', ['document' => $document->getId()])]);
|
|
}
|
|
|
|
if (!$inUse) {
|
|
$event->addDelete($this->path('invoice_document_delete', ['id' => $document->getId(), 'token' => $token]), false);
|
|
}
|
|
}
|
|
}
|