added username to export (#1827)
This commit is contained in:
@@ -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 = '';
|
||||
|
||||
@@ -85,25 +85,26 @@ class CsvRendererTest extends AbstractRendererTest
|
||||
4 => '0',
|
||||
5 => '',
|
||||
6 => 'kevin',
|
||||
7 => 'Customer Name',
|
||||
8 => 'project name',
|
||||
9 => 'activity description',
|
||||
10 => '',
|
||||
7 => 'kevin',
|
||||
8 => 'Customer Name',
|
||||
9 => 'project name',
|
||||
10 => 'activity description',
|
||||
11 => '',
|
||||
12 => 'foo,bar',
|
||||
13 => '',
|
||||
14 => ' EUR 84.00 ',
|
||||
15 => 'meta-bar',
|
||||
16 => 'meta-bar2',
|
||||
17 => 'customer-bar',
|
||||
18 => '',
|
||||
19 => 'project-foo2',
|
||||
20 => 'activity-bar',
|
||||
12 => '',
|
||||
13 => 'foo,bar',
|
||||
14 => '',
|
||||
15 => ' EUR 84.00 ',
|
||||
16 => 'meta-bar',
|
||||
17 => 'meta-bar2',
|
||||
18 => 'customer-bar',
|
||||
19 => '',
|
||||
20 => 'project-foo2',
|
||||
21 => 'activity-bar',
|
||||
];
|
||||
|
||||
self::assertEquals(7, \count($all));
|
||||
self::assertEquals($expected, $all[5]);
|
||||
self::assertEquals(\count($expected), \count($all[0]));
|
||||
self::assertEquals('foo', $all[4][12]);
|
||||
self::assertEquals('foo', $all[4][13]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,25 +82,26 @@ class CsvRendererTest extends AbstractRendererTest
|
||||
4 => '0',
|
||||
5 => '',
|
||||
6 => 'kevin',
|
||||
7 => 'Customer Name',
|
||||
8 => 'project name',
|
||||
9 => 'activity description',
|
||||
10 => '',
|
||||
7 => 'kevin',
|
||||
8 => 'Customer Name',
|
||||
9 => 'project name',
|
||||
10 => 'activity description',
|
||||
11 => '',
|
||||
12 => 'foo,bar',
|
||||
13 => '',
|
||||
14 => ' EUR 84.00 ',
|
||||
15 => 'meta-bar',
|
||||
16 => 'meta-bar2',
|
||||
17 => 'customer-bar',
|
||||
18 => '',
|
||||
19 => 'project-foo2',
|
||||
20 => 'activity-bar',
|
||||
12 => '',
|
||||
13 => 'foo,bar',
|
||||
14 => '',
|
||||
15 => ' EUR 84.00 ',
|
||||
16 => 'meta-bar',
|
||||
17 => 'meta-bar2',
|
||||
18 => 'customer-bar',
|
||||
19 => '',
|
||||
20 => 'project-foo2',
|
||||
21 => 'activity-bar',
|
||||
];
|
||||
|
||||
self::assertEquals(7, \count($all));
|
||||
self::assertEquals($expected, $all[5]);
|
||||
self::assertEquals(\count($expected), \count($all[0]));
|
||||
self::assertEquals('foo', $all[4][12]);
|
||||
self::assertEquals('foo', $all[4][13]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user