option to use decimal format in user timesheet export (#1489)

This commit is contained in:
Kevin Papst
2020-02-24 18:03:30 +01:00
committed by GitHub
parent 0e507804b1
commit 34d2228d5d
13 changed files with 84 additions and 25 deletions

View File

@@ -34,6 +34,18 @@ final class HtmlRenderer implements TimesheetExportInterface
$this->dispatcher = $dispatcher;
}
private function getOptions(TimesheetQuery $query): array
{
$decimal = false;
if (null !== $query->getCurrentUser()) {
$decimal = (bool) $query->getCurrentUser()->getPreferenceValue('timesheet.export_decimal', $decimal);
} elseif (null !== $query->getUser()) {
$decimal = (bool) $query->getUser()->getPreferenceValue('timesheet.export_decimal', $decimal);
}
return ['decimal' => $decimal];
}
/**
* @param Timesheet[] $timesheets
* @param TimesheetQuery $query
@@ -53,11 +65,12 @@ final class HtmlRenderer implements TimesheetExportInterface
$this->dispatcher->dispatch($event);
$timesheetMetaFields = $event->getFields();
$content = $this->twig->render('timesheet/export.html.twig', [
$content = $this->twig->render('timesheet/export.html.twig', array_merge([
'entries' => $timesheets,
'query' => $query,
'metaColumns' => $timesheetMetaFields,
]);
'decimal' => false,
], $this->getOptions($query)));
$response = new Response();
$response->setContent($content);