Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* print.php - contains Resources_PrintController
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Moritz Strohm <strohm@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @copyright 2017-2019
* @category Stud.IP
* @since 4.5
*/
/**
* Resources_PrintController contains actions for printing resource data.
*/
class Resources_PrintController extends AuthenticatedController
{
public function individual_booking_plan_action($resource_id = null)
{
if (Navigation::hasItem('/resources/planning')) {
Navigation::activateItem('/resources/planning');
}
if (Navigation::hasItem('/resources/planning/individual_booking_plan')) {
Navigation::activateItem('/resources/planning/individual_booking_plan');
}
$this->resource = Resource::find($resource_id);
if (!$this->resource) {
PageLayout::postError(
_('Die Ressource wurde nicht gefunden!')
);
return;
}
$this->resource = $this->resource->getDerivedClassInstance();
$current_user = User::findCurrent();
PageLayout::setTitle(
sprintf(
_('Individueller Belegungsdruck: %s'),
$this->resource->getFullName()
)
);
throw new AccessDeniedException();
}
$this->timestamp = Request::get('timestamp', time());
$this->date = new DateTime();
$this->date->setTimestamp($this->timestamp);
$sidebar = Sidebar::get();
$views = new ViewsWidget();
if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) {
$views->addLink(
_('Standard Zeitfenster'),
'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp))
]
),
null,
['class' => 'booking-plan-std_view']
)->setActive(!Request::get('allday'));
$views->addLink(
_('Ganztägiges Zeitfenster'),
'defaultDate' => Request::get('defaultDate', date('Y-m-d', $this->timestamp))
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
]
),
null,
['class' => 'booking-plan-allday_view']
)->setActive(Request::get('allday'));
}
}
$sidebar->addWidget($views);
$template = $GLOBALS['template_factory']->open(
'sidebar/resources_individual_booking_plan_sidebar.php'
);
$html_widget = new TemplateWidget(
_('Farbwähler'),
$template
);
$sidebar->addWidget($html_widget);
}
/**
* This action is responsible for printing all schedules of all rooms
* which are part of a clipboard.
*/
public function clipboard_rooms_action()
{
if (Navigation::hasItem('/resources/export')) {
Navigation::activateItem('/resources/export');
}
if (Navigation::hasItem('/resources/export/print_clipboard_rooms')) {
Navigation::activateItem('/resources/export/print_clipboard_rooms');
}
PageLayout::setTitle(_('Belegungsplan-Seriendruck'));
$this->clipboard_selected = false;
$this->print_schedules = false;
if (Request::submitted('select_clipboard')) {
$this->clipboard_selected = true;
} elseif (Request::submitted('print')) {
$this->print_schedules = true;
}
//The parameters are collected here since they are used in all cases
//and In both cases we must collect the selected
//clipboard, the selected date and the selected schedule type.
//Furthermore a date and the type of schedule has been selected.
// Also check for booking types to export.
$this->selected_clipboard_id = Request::get('clipboard_id');
$this->schedule_type = Request::get('schedule_type');
$this->selected_date_string = Request::get('date');
$this->selected_booking_types = Request::intArray('bookingtypes') ?:
Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT;
// All available booking types.
$this->booking_types = [
0 => _('Buchung'),
1 => _('Reservierung'),
2 => _('Sperrbuchung'),

Thomas Hackl
committed
3 => _('geplante Buchung')
// Get additional text to print
$this->additional_text = Config::get()->RESOURCES_ADDITIONAL_TEXT_ROOM_EXPORT;
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
if (!$this->clipboard_selected && !$this->print_schedules) {
//We have to load all selectable clipboards of the current user:
$this->available_clipboards = Clipboard::getClipboardsForUser(
$GLOBALS['user']->id
);
} else {
//Either a clipboard has been selected or the print view
//is requested.
//Now we check for CSRF:
CSRFProtection::verifyUnsafeRequest();
$this->selected_clipboard = Clipboard::find(
$this->selected_clipboard_id
);
if (!$this->selected_clipboard) {
PageLayout::postError(
_('Die gewählte Raumgruppe wurde nicht gefunden!')
);
return;
}
if ($this->clipboard_selected) {
//We must load a list of available rooms.
//The rooms are loaded one by one to keep the
//sorting of the room clipboard.
$this->available_rooms = [];
$room_ids = $this->selected_clipboard->getAllRangeIds(
'Room'
);
foreach ($room_ids as $room_id) {
$room = Room::find($room_id);
if ($room instanceof Room) {
$this->available_rooms[] = $room;
}
}
} elseif ($this->print_schedules) {
//Load the list of selected rooms, but make sure
//the rooms are placed inside the selected clipboard and that
//they are loaded in the order defined in the room clipboard.
$this->selected_room_ids = Request::getArray('selected_room_ids');
$this->selected_rooms = [];
$room_ids = $this->selected_clipboard->getAllRangeIds(
'Room'
);
foreach ($room_ids as $room_id) {
if (!in_array($room_id, $this->selected_room_ids)) {
continue;
}
$room = Room::find($room_id);
if ($room instanceof Room) {
$this->selected_rooms[] = $room;
}
}
$date_parts = explode('.', $this->selected_date_string);
$date = new DateTime();
$date->setDate(
intval($date_parts[2]),
intval($date_parts[1]),
intval($date_parts[0])
);
$date->setTime(12, 0, 0);
$this->print_date = $date->format('Y-m-d');
$this->schedules = [];
$this->rooms = [];
//Add a sidebar action to init the printing process:
$sidebar = Sidebar::get();
$actions = new ActionsWidget();
$actions->addLink(
_('Drucken'),
'javascript:void(window.print());',
Icon::create('print')
);
$sidebar->addWidget($actions);
}
}
}
}