Release 1.20.3 (#3340)
* fix edit timesheet link * fix drag & drop creates record for wrong user * fix search with multiple bindings * hide user switcher in calendar if there is only one user to choose * make quick entry responsive for mobile-only users * mark invoices as exported by default * fix serialization deprecation warning * fix duration calculation for fixed rate entries * updated composer packages * fix checkbox for horizontal forms * support pdfContext for PDF invoice templates
This commit is contained in:
@@ -110,7 +110,7 @@ abstract class AbstractCalculator
|
||||
{
|
||||
$time = 0;
|
||||
foreach ($this->model->getEntries() as $entry) {
|
||||
if (null === $entry->getFixedRate() && null !== $entry->getDuration()) {
|
||||
if (null !== $entry->getDuration()) {
|
||||
$time += $entry->getDuration();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class AbstractTwigRenderer implements RendererInterface
|
||||
$this->twig = $twig;
|
||||
}
|
||||
|
||||
protected function renderTwigTemplate(InvoiceDocument $document, InvoiceModel $model): string
|
||||
protected function renderTwigTemplate(InvoiceDocument $document, InvoiceModel $model, array $options = []): string
|
||||
{
|
||||
$language = $model->getTemplate()->getLanguage();
|
||||
$formatLocale = $model->getFormatter()->getLocale();
|
||||
@@ -42,14 +42,14 @@ abstract class AbstractTwigRenderer implements RendererInterface
|
||||
$entries[] = $model->itemToArray($entry);
|
||||
}
|
||||
|
||||
$options = [
|
||||
$options = array_merge([
|
||||
// model should not be used in the future, but we can likely not remove it
|
||||
'model' => $model,
|
||||
// new since 1.16.7 - templates should only use the pre-generated values
|
||||
'invoice' => $model->toArray(),
|
||||
// new since 1.19.5 - templates should only use the pre-generated values
|
||||
'entries' => $entries
|
||||
];
|
||||
], $options);
|
||||
|
||||
return $this->renderTwigTemplateWithLanguage($this->twig, $template, $options, $language, $formatLocale);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
namespace App\Invoice\Renderer;
|
||||
|
||||
use App\Entity\InvoiceDocument;
|
||||
use App\Export\ExportContext;
|
||||
use App\Invoice\InvoiceFilename;
|
||||
use App\Invoice\InvoiceModel;
|
||||
use App\Utils\HtmlToPdfConverter;
|
||||
@@ -37,16 +38,23 @@ final class PdfRenderer extends AbstractTwigRenderer
|
||||
|
||||
public function render(InvoiceDocument $document, InvoiceModel $model): Response
|
||||
{
|
||||
$content = $this->renderTwigTemplate($document, $model);
|
||||
$filename = new InvoiceFilename($model);
|
||||
|
||||
$content = $this->converter->convertToPdf($content, [
|
||||
'setAutoTopMargin' => 'pad',
|
||||
'setAutoBottomMargin' => 'pad',
|
||||
'margin_top' => 12,
|
||||
'margin_bottom' => 8,
|
||||
]);
|
||||
$context = new ExportContext();
|
||||
$context->setOption('filename', $filename->getFilename());
|
||||
$context->setOption('setAutoTopMargin', 'pad');
|
||||
$context->setOption('setAutoBottomMargin', 'pad');
|
||||
$context->setOption('margin_top', '12');
|
||||
$context->setOption('margin_bottom', '8');
|
||||
|
||||
$filename = (string) new InvoiceFilename($model);
|
||||
$content = $this->renderTwigTemplate($document, $model, ['pdfContext' => $context]);
|
||||
$content = $this->converter->convertToPdf($content, $context->getOptions());
|
||||
|
||||
$filename = $context->getOption('filename');
|
||||
if (empty($filename)) {
|
||||
$filename = new InvoiceFilename($model);
|
||||
$filename = $filename->getFilename();
|
||||
}
|
||||
|
||||
$response = new Response($content);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user