Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
29 / 29 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Base | |
100.00% |
29 / 29 |
|
100.00% |
3 / 3 |
9 | |
100.00% |
1 / 1 |
writeInfoHeader | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
5 | |||
setDateTime | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
getFormatedDates | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * @package zmsstatistic |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsstatistic\Download; |
9 | |
10 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
11 | |
12 | class Base extends \BO\Zmsstatistic\BaseController |
13 | { |
14 | public static $ignoreColumns = [ |
15 | 'subjectid', |
16 | 'max', |
17 | 'sum' |
18 | ]; |
19 | public static $subjectTranslations = [ |
20 | 'waitingscope' => 'Wartesituation', |
21 | 'waitingdepartment' => 'Wartesituation', |
22 | 'waitingorganisation' => 'Wartesituation', |
23 | 'notificationscope' => 'SMS Auswertung', |
24 | 'notificationdepartment' => 'SMS Auswertung', |
25 | 'notificationorganisation' => 'SMS Auswertung', |
26 | 'clientscope' => 'Kundenstatistik', |
27 | 'clientdepartment' => 'Kundenstatistik', |
28 | 'clientorganisation' => 'Kundenstatistik', |
29 | 'requestscope' => 'Dienstleistungsstatistik', |
30 | 'requestdepartment' => 'Dienstleistungsstatistik', |
31 | 'requestorganisation' => 'Dienstleistungsstatistik', |
32 | 'raw-waitingscope' => 'Rohdaten Wartesituation', |
33 | 'raw-waitingdepartment' => 'Rohdaten Wartesituation', |
34 | 'raw-waitingorganisation' => 'Rohdaten Wartesituation', |
35 | 'raw-clientscope' => 'Rohdaten Wartende', |
36 | 'raw-clientdepartment' => 'Rohdaten Wartende', |
37 | 'raw-clientorganisation' => 'Rohdaten Wartende', |
38 | 'raw-notificationscope' => 'Rohdaten SMS', |
39 | 'raw-notificationdepartment' => 'Rohdaten SMS', |
40 | 'raw-notificationorganisation' => 'Rohdaten SMS', |
41 | 'raw-requestscope' => 'Rohdaten Dienstleistungsstatistik', |
42 | 'raw-requestdepartment' => 'Rohdaten Dienstleistungsstatistik', |
43 | 'raw-requestorganisation' => 'Rohdaten Dienstleistungsstatistik' |
44 | ]; |
45 | |
46 | public static $headlines = [ |
47 | 'subjectid' => 'ID', |
48 | 'date' => 'Datum', |
49 | 'notificationscount' => 'SMS*', |
50 | 'notificationscost' => 'SMS-Kosten**', |
51 | 'clientscount' => 'Kunden Erschienen', |
52 | 'missed' => 'Kunden Nicht Erschienen', |
53 | 'withappointment' => 'davon Terminkunden Erschienen', |
54 | 'missedwithappointment' => 'davon Terminkunden Nicht Erschienen', |
55 | 'noappointment' => 'davon Spontankunden Erschienen', |
56 | 'missednoappointment' => 'davon Spontankunden Nicht Erschienen', |
57 | 'requestscount' => 'Dienstleistungen', |
58 | 'organisationname' => 'Organisation', |
59 | 'departmentname' => 'Behörde', |
60 | 'scopename' => 'Standort' |
61 | ]; |
62 | |
63 | protected function writeInfoHeader(array $args, Spreadsheet $spreadsheet) |
64 | { |
65 | $sheet = $spreadsheet->getActiveSheet(); |
66 | $infoData[] = static::$subjectTranslations[$args['category']]; |
67 | if (isset($args['organisation'])) { |
68 | $infoData[] = $args['organisation']['name'] ; |
69 | } |
70 | if (isset($args['department'])) { |
71 | $infoData[] = $args['department']['name']; |
72 | } |
73 | if (isset($args['scope'])) { |
74 | $infoData[] = $args['scope']['contact']['name'] . ' ' . $args['scope']['shortName']; |
75 | } |
76 | $infoData = array_chunk($infoData, 1); |
77 | $sheet->fromArray($infoData, null, 'A' . $sheet->getHighestRow()); |
78 | |
79 | if (isset($args['reports'][0]->firstDay)) { |
80 | $firstDay = $args['reports'][0]->firstDay->toDateTime()->format('d.m.Y'); |
81 | $lastDay = $args['reports'][0]->lastDay->toDateTime()->format('d.m.Y'); |
82 | $range = array('Zeitraum:', $firstDay, 'bis', $lastDay); |
83 | $sheet->fromArray($range, null, 'A' . ($sheet->getHighestRow() + 1)); |
84 | } |
85 | |
86 | return $spreadsheet; |
87 | } |
88 | |
89 | protected function setDateTime($dateString) |
90 | { |
91 | $dateArr = explode('-', $dateString); |
92 | if (2 == count($dateArr)) { |
93 | $dateString = $dateString . '-01'; |
94 | } |
95 | /* ignore because not in use now */ |
96 | //@codeCoverageIgnoreStart |
97 | if (1 == count($dateArr)) { |
98 | $dateString = $dateString . '-01-01'; |
99 | } |
100 | //@codeCoverageIgnoreEnd |
101 | return new \DateTime($dateString); |
102 | } |
103 | |
104 | protected function getFormatedDates($date, $pattern = 'MMMM') |
105 | { |
106 | $dateFormatter = new \IntlDateFormatter( |
107 | 'de-DE', |
108 | \IntlDateFormatter::MEDIUM, |
109 | \IntlDateFormatter::MEDIUM, |
110 | \App::TIMEZONE, |
111 | \IntlDateFormatter::GREGORIAN, |
112 | $pattern |
113 | ); |
114 | |
115 | return $dateFormatter->format($date->getTimestamp()); |
116 | } |
117 | } |