PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
← All changes | sh4/schedule/html/view/download.php +0 -114 4.9.974.9.66 View file →
@@ -12,9 +12,8 @@
12 12 HC3_Settings $settings,
13 13
14 14 SH4_Shifts_Presenter $shiftsPresenter,
15 15
16 - SH4_Shifts_Query $shiftsQuery,
17 16 SH4_Calendars_Presenter $calendarsPresenter,
18 17 SH4_Shifts_View_Widget $widget,
19 18 SH4_Schedule_Html_View_Common $common
20 19 )
@@ -25,9 +24,8 @@
25 24 $this->translate = $translate;
26 25
27 26 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
28 27 $this->shiftsPresenter = $hooks->wrap( $shiftsPresenter );
29 - $this->shiftsQuery = $hooks->wrap( $shiftsQuery );
30 28
31 29 $this->widget = $hooks->wrap( $widget );
32 30 $this->common = $hooks->wrap( $common );
33 31 $this->settings = $hooks->wrap($settings);
@@ -34,123 +32,11 @@
34 32
35 33 $this->self = $hooks->wrap( $this );
36 34 }
37 35
38 - private function report()
39 - {
40 - $params = $this->request->getParams();
41 - $startDate = $params['start'];
42 -
43 - $session = HC3_Session::instance();
44 - $separator = $session->getUserdata('pref_csv_separator');
45 - if (!$separator) {
46 - $separator = $this->settings->get('pref_csv_separator');
47 - }
48 - if (!$separator) {
49 - $separator = ',';
50 - }
51 -
52 - $groupby = $session->getUserdata('scheduleViewGroupby');
53 - if (!$groupby) {
54 - $groupby = $this->settings->get('default_schedule_groupby');
55 - }
56 - if (!$groupby) {
57 - $groupby = 'employee';
58 - }
59 -
60 - $shifts = $this->common->getShifts();
61 -
62 - $dt1 = $this->shiftsQuery->getStart();
63 - $dt2 = $this->shiftsQuery->getEnd();
64 - // $d1 = $this->t->setDateTimeDb($dt1)->formatDateDb();
65 - // $d2 = $this->t->setDateTimeDb($dt2)->formatDateDb();
66 -
67 - $d1 = $this->t->setDateTimeDb($dt1)->formatDate();
68 - $d1 = $this->translate->translate($d1);
69 - $d2 = $this->t->setDateTimeDb($dt2)->formatDate();
70 - $d2 = $this->translate->translate($d2);
71 -
72 - $allEmployees = $this->common->findAllEmployees();
73 - $allCalendars = $this->common->findAllCalendars();
74 -
75 - $body = [];
76 - foreach ($shifts as $shift) {
77 - $shiftOut = $this->shiftsPresenter->export($shift);
78 -
79 - if ('employee' == $groupby) {
80 - $key = $shiftOut['employee_id'];
81 - } elseif ('calendar' == $groupby) {
82 - $key = $shiftOut['calendar_id'];
83 - } else {
84 - $key = 0;
85 - }
86 -
87 - if (!isset($body[$key])) {
88 - if ('employee' == $groupby) {
89 - $body[$key]['employee_id'] = $shiftOut['employee_id'];
90 - $body[$key]['employee'] = $shiftOut['employee'];
91 - } elseif ('calendar' == $groupby) {
92 - $body[$key]['calendar_id'] = $shiftOut['calendar_id'];
93 - $body[$key]['calendar'] = $shiftOut['calendar'];
94 - } else {
95 - $key = 0;
96 - }
97 -
98 - $body[$key]['duration'] = 0;
99 - $body[$key]['qty'] = 0;
100 - if (array_key_exists('salary', $shiftOut)) {
101 - $body[$key]['salary'] = 0;
102 - }
103 - }
104 -
105 - $body[$key]['qty'] += 1;
106 - $body[$key]['duration'] += $shiftOut['duration'];
107 - if (isset($shiftOut['salary'])) {
108 - $body[$key]['salary'] += $shiftOut['salary'];
109 - }
110 - }
111 -
112 - $out = array();
113 - foreach ($body as $line) {
114 - $keys = array_keys($line);
115 -
116 - reset($keys);
117 - foreach ($keys as $k) {
118 - if (isset($line[$k])) {
119 - $line[$k] = $this->translate->translate($line[$k]);
120 - }
121 - }
122 -
123 - $out[] = HC3_Functions::buildCsv($line, $separator);
124 - }
125 -
126 - if ($out) {
127 - $header = array_keys(current($body));
128 - $header = array_combine($header, $header);
129 - $header = HC3_Functions::buildCsv($header, $separator);
130 - array_unshift($out, $header);
131 - }
132 -
133 - $out = join("\n", $out);
134 -
135 - $fileName = 'report-' . $d1 . '-' . $d2;
136 - // $fileName .= '-' . date('Y-m-d_H-i') . '.csv';
137 - $fileName .= '--' . date('YmdHi') . '.csv';
138 -// echo $fileName;
139 -// exit;
140 -
141 - HC3_Functions::pushDownload( $fileName, $out );
142 - exit;
143 - }
144 -
145 36 public function render()
146 37 {
147 38 $params = $this->request->getParams();
148 - if (isset($params['report']) && $params['report']) {
149 - return $this->report();
150 - }
151 -
152 -
153 39 $startDate = $params['start'];
154 40
155 41 $shifts = $this->common->getShifts();
156 42