added username to export (#1827)

This commit is contained in:
Kevin Papst
2020-07-17 02:32:39 +02:00
committed by GitHub
parent f57b314466
commit 5864c7e127
3 changed files with 50 additions and 28 deletions

View File

@@ -72,6 +72,7 @@ abstract class AbstractSpreadsheetRenderer
'rate' => [],
'rate_internal' => [],
'user' => [],
'username' => [],
'customer' => [],
'project' => [],
'activity' => [],
@@ -251,6 +252,25 @@ abstract class AbstractSpreadsheetRenderer
};
}
if (isset($columns['username'])) {
if (!isset($columns['username']['render'])) {
$columns['username']['render'] = function (Worksheet $sheet, int $row, int $column, ExportItemInterface $entity) {
$username = '';
if (null !== $entity->getUser()) {
$username = $entity->getUser()->getUsername();
}
$sheet->setCellValueByColumnAndRow($column, $row, $username);
};
}
if (!isset($columns['username']['header'])) {
$columns['username']['header'] = function (Worksheet $sheet, $row, $column) {
$sheet->setCellValueByColumnAndRow($column, $row, $this->translator->trans('label.name'));
return 1;
};
}
}
if (isset($columns['customer']) && !isset($columns['customer']['render'])) {
$columns['customer']['render'] = function (Worksheet $sheet, int $row, int $column, ExportItemInterface $entity) {
$customer = '';