support template variable entry.row for docx if description is not used (#504)

This commit is contained in:
Kevin Papst
2019-01-18 16:19:02 +01:00
committed by GitHub
parent 64330e6cc4
commit 1ad440f488
4 changed files with 15 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ use App\Entity\InvoiceDocument;
use App\Invoice\RendererInterface;
use App\Model\InvoiceModel;
use PhpOffice\PhpWord\Escaper\Xml;
use PhpOffice\PhpWord\Exception\Exception as OfficeException;
use PhpOffice\PhpWord\TemplateProcessor;
use Symfony\Component\HttpFoundation\File\Stream;
use Symfony\Component\HttpFoundation\Response;
@@ -40,7 +41,12 @@ class DocxRenderer extends AbstractRenderer implements RendererInterface
$template->setValue($search, $replace);
}
$template->cloneRow('entry.description', count($model->getCalculator()->getEntries()));
try {
$template->cloneRow('entry.description', count($model->getCalculator()->getEntries()));
} catch (OfficeException $ex) {
$template->cloneRow('entry.row', count($model->getCalculator()->getEntries()));
}
$i = 1;
foreach ($model->getCalculator()->getEntries() as $entry) {
$values = $this->timesheetToArray($entry);

View File

@@ -161,6 +161,7 @@ trait RendererTrait
$end = $timesheet->getEnd();
return [
'entry.row' => '',
'entry.description' => $description,
'entry.amount' => $amount,
'entry.rate' => $this->getFormattedMoney($hourlyRate),