ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBookingScheduleGUI Class Reference

Class ilBookingScheduleGUI. More...

+ Collaboration diagram for ilBookingScheduleGUI:

Public Member Functions

 __construct ($a_parent_obj)
 Constructor. More...
 
 executeCommand ()
 main switch More...
 
 render ()
 Render list of booking schedules. More...
 
 create ()
 Render creation form. More...
 
 edit ()
 Render edit form. More...
 
 initForm ($a_mode="create", $id=NULL)
 Build property form. More...
 
 save ()
 Create new dataset. More...
 
 update ()
 Update dataset. More...
 
 confirmDelete ()
 Confirm delete. More...
 
 delete ()
 Delete schedule. More...
 

Protected Member Functions

 setDefinitionFromPost (ilPropertyFormGUI $form)
 Reload definition values from post data. More...
 
 formToObject ($form, $schedule)
 Convert incoming form data to schedule object. More...
 

Detailed Description

Class ilBookingScheduleGUI.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

@ilCtrl_Calls ilBookingScheduleGUI:

Definition at line 12 of file class.ilBookingScheduleGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilBookingScheduleGUI::__construct (   $a_parent_obj)

Constructor.

Parameters
object$a_parent_obj

Definition at line 18 of file class.ilBookingScheduleGUI.php.

19 {
20 $this->ref_id = $a_parent_obj->ref_id;
21 }

Member Function Documentation

◆ confirmDelete()

ilBookingScheduleGUI::confirmDelete ( )

Confirm delete.

Definition at line 383 of file class.ilBookingScheduleGUI.php.

384 {
385 global $ilCtrl, $lng, $tpl, $ilTabs, $ilHelp;
386
387 $ilHelp->setSubScreenId("delete");
388
389
390 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
391 $conf = new ilConfirmationGUI();
392 $conf->setFormAction($ilCtrl->getFormAction($this));
393 $conf->setHeaderText($lng->txt('book_confirm_delete'));
394
395 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
396 $type = new ilBookingSchedule((int)$_GET['schedule_id']);
397 $conf->addItem('schedule_id', (int)$_GET['schedule_id'], $type->getTitle());
398 $conf->setConfirm($lng->txt('delete'), 'delete');
399 $conf->setCancel($lng->txt('cancel'), 'render');
400
401 $tpl->setContent($conf->getHTML());
402 }
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
schedule for booking ressource
Confirmation screen class.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

References $_GET, $ilCtrl, $lng, and $tpl.

◆ create()

ilBookingScheduleGUI::create ( )

Render creation form.

Definition at line 78 of file class.ilBookingScheduleGUI.php.

79 {
80 global $tpl, $ilCtrl, $ilTabs, $lng, $ilHelp;
81
82 $ilTabs->clearTargets();
83 $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render'));
84 $ilHelp->setScreenIdComponent("book");
85 $ilHelp->setScreenId("schedules");
86 $ilHelp->setSubScreenId("create");
87
88 $form = $this->initForm();
89 $tpl->setContent($form->getHTML());
90 }
initForm($a_mode="create", $id=NULL)
Build property form.

References $ilCtrl, $lng, $tpl, and initForm().

+ Here is the call graph for this function:

◆ delete()

ilBookingScheduleGUI::delete ( )

Delete schedule.

Definition at line 407 of file class.ilBookingScheduleGUI.php.

408 {
409 global $ilCtrl, $lng;
410
411 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
412 $obj = new ilBookingSchedule((int)$_POST['schedule_id']);
413 $obj->delete();
414
415 ilUtil::sendSuccess($lng->txt('book_schedule_deleted'), true);
416 $ilCtrl->redirect($this, 'render');
417 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12

References $_POST, $ilCtrl, $lng, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ edit()

ilBookingScheduleGUI::edit ( )

Render edit form.

Definition at line 95 of file class.ilBookingScheduleGUI.php.

96 {
97 global $tpl, $ilCtrl, $ilTabs, $lng, $ilHelp;
98
99 $ilTabs->clearTargets();
100 $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render'));
101 $ilHelp->setScreenIdComponent("book");
102 $ilHelp->setScreenId("schedules");
103 $ilHelp->setSubScreenId("edit");
104
105 $form = $this->initForm('edit', (int)$_GET['schedule_id']);
106 $tpl->setContent($form->getHTML());
107 }

References $_GET, $ilCtrl, $lng, $tpl, and initForm().

+ Here is the call graph for this function:

◆ executeCommand()

ilBookingScheduleGUI::executeCommand ( )

main switch

Definition at line 26 of file class.ilBookingScheduleGUI.php.

27 {
28 global $tpl, $ilTabs, $ilCtrl;
29
30 $next_class = $ilCtrl->getNextClass($this);
31
32 switch($next_class)
33 {
34 default:
35 $cmd = $ilCtrl->getCmd("render");
36 $this->$cmd();
37 break;
38 }
39 return true;
40 }
$cmd
Definition: sahs_server.php:35

References $cmd, $ilCtrl, and $tpl.

◆ formToObject()

ilBookingScheduleGUI::formToObject (   $form,
  $schedule 
)
protected

Convert incoming form data to schedule object.

Parameters
object$form
object$schedule

Definition at line 344 of file class.ilBookingScheduleGUI.php.

345 {
346 global $ilObjDataCache;
347
348 $schedule->setTitle($form->getInput("title"));
349 $schedule->setPoolId($ilObjDataCache->lookupObjId($this->ref_id));
350 $schedule->setDeadline($form->getInput("deadline"));
351
352 $from = $form->getItemByPostVar("from");
353 $from_tgl = $from->getActivationPostVar();
354 $schedule->setAvailabilityFrom($_POST[$from_tgl] ? $from->getDate(): null);
355
356 $to = $form->getItemByPostVar("to");
357 $to_tgl = $to->getActivationPostVar();
358 $schedule->setAvailabilityTo($_POST[$to_tgl] ? $to->getDate(): null);
359
360 /*
361 if($form->getInput("type") == "flexible")
362 {
363 $schedule->setRaster($form->getInput("raster"));
364 $schedule->setMinRental($form->getInput("rent_min"));
365 $schedule->setMaxRental($form->getInput("rent_max"));
366 $schedule->setAutoBreak($form->getInput("break"));
367 }
368 else
369 {
370 $schedule->setRaster(NULL);
371 $schedule->setMinRental(NULL);
372 $schedule->setMaxRental(NULL);
373 $schedule->setAutoBreak(NULL);
374 }
375 */
376
377 $schedule->setDefinitionBySlots(ilScheduleInputGUI::getPostData("days"));
378 }
static getPostData($a_post_var, $a_remove_invalid=true)

References $_POST, and ilScheduleInputGUI\getPostData().

Referenced by save(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilBookingScheduleGUI::initForm (   $a_mode = "create",
  $id = NULL 
)

Build property form.

Parameters
string$a_mode
int$id
Returns
object

Definition at line 115 of file class.ilBookingScheduleGUI.php.

116 {
117 global $lng, $ilCtrl;
118
119 $lng->loadLanguageModule("dateplaner");
120
121 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
122
123 $form_gui = new ilPropertyFormGUI();
124
125 $title = new ilTextInputGUI($lng->txt("title"), "title");
126 $title->setRequired(true);
127 $title->setSize(40);
128 $title->setMaxLength(120);
129 $form_gui->addItem($title);
130
131 /*
132 $type = new ilRadioGroupInputGUI($lng->txt("book_schedule_type"), "type");
133 $type->setRequired(true);
134 $form_gui->addItem($type);
135 $fix = new ilRadioOption($lng->txt("book_schedule_type_fix"), "fix");
136 $fix->setInfo($lng->txt("book_schedule_type_fix_info"));
137 $type->addOption($fix);
138 $flex = new ilRadioOption($lng->txt("book_schedule_type_flexible"), "flexible");
139 $flex->setInfo($lng->txt("book_schedule_type_flexible_info"));
140 $type->addOption($flex);
141
142 $raster = new ilNumberInputGUI($lng->txt("book_schedule_raster"), "raster");
143 $raster->setRequired(true);
144 $raster->setInfo($lng->txt("book_schedule_raster_info"));
145 $raster->setMinValue(1);
146 $raster->setSize(3);
147 $raster->setMaxLength(3);
148 $raster->setSuffix($lng->txt("book_minutes"));
149 $flex->addSubItem($raster);
150
151 $rent_min = new ilNumberInputGUI($lng->txt("book_schedule_rent_min"), "rent_min");
152 $rent_min->setInfo($lng->txt("book_schedule_rent_info"));
153 $rent_min->setMinValue(1);
154 $rent_min->setSize(3);
155 $rent_min->setMaxLength(3);
156 $flex->addSubItem($rent_min);
157
158 $rent_max = new ilNumberInputGUI($lng->txt("book_schedule_rent_max"), "rent_max");
159 $rent_max->setInfo($lng->txt("book_schedule_rent_info"));
160 $rent_max->setMinValue(1);
161 $rent_max->setSize(3);
162 $rent_max->setMaxLength(3);
163 $flex->addSubItem($rent_max);
164
165 $break = new ilNumberInputGUI($lng->txt("book_schedule_break"), "break");
166 $break->setInfo($lng->txt("book_schedule_break_info"));
167 $break->setMinValue(1);
168 $break->setSize(3);
169 $break->setMaxLength(3);
170 $flex->addSubItem($break);
171 */
172
173 include_once "Modules/BookingManager/classes/class.ilScheduleInputGUI.php";
174 $definition = new ilScheduleInputGUI($lng->txt("book_schedule_days"), "days");
175 $definition->setInfo($lng->txt("book_schedule_days_info"));
176 $definition->setRequired(true);
177 $form_gui->addItem($definition);
178
179 $deadline = new ilNumberInputGUI($lng->txt("book_deadline"), "deadline");
180 $deadline->setInfo($lng->txt("book_deadline_info"));
181 $deadline->setSuffix($lng->txt("book_hours"));
182 $deadline->setMinValue(0);
183 $deadline->setSize(3);
184 $deadline->setMaxLength(3);
185 $form_gui->addItem($deadline);
186
187 if ($a_mode == "edit")
188 {
189 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
190 $schedule = new ilBookingSchedule($id);
191 }
192
193 $av = new ilFormSectionHeaderGUI();
194 $av->setTitle($lng->txt("obj_activation_list_gui"));
195 $form_gui->addItem($av);
196
197 // #18221
198 $lng->loadLanguageModule('rep');
199
200 $from = new ilDateTimeInputGUI($lng->txt("rep_activation_limited_start"), "from");
201 $from->enableDateActivation("", "from_tgl", $schedule ? is_object($schedule->getAvailabilityFrom()) : false);
202 $from->setShowTime(true);
203 $form_gui->addItem($from);
204
205 $to = new ilDateTimeInputGUI($lng->txt("rep_activation_limited_end"), "to");
206 $to->enableDateActivation("", "to_tgl", $schedule ? is_object($schedule->getAvailabilityTo()) : false);
207 $to->setShowTime(true);
208 $form_gui->addItem($to);
209
210 if ($a_mode == "edit")
211 {
212 $form_gui->setTitle($lng->txt("book_edit_schedule"));
213
214 $item = new ilHiddenInputGUI('schedule_id');
215 $item->setValue($id);
216 $form_gui->addItem($item);
217
218 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
219 $schedule = new ilBookingSchedule($id);
220 $title->setValue($schedule->getTitle());
221 $deadline->setValue($schedule->getDeadline());
222 $from->setDate($schedule->getAvailabilityFrom());
223 $to->setDate($schedule->getAvailabilityTo());
224
225 /*
226 if($schedule->getRaster())
227 {
228 $type->setValue("flexible");
229 $raster->setValue($schedule->getRaster());
230 $rent_min->setValue($schedule->getMinRental());
231 $rent_max->setValue($schedule->getMaxRental());
232 $break->setValue($schedule->getAutoBreak());
233 }
234 else
235 {
236 $type->setValue("fix");
237 }
238 */
239
240 $definition->setValue($schedule->getDefinitionBySlots());
241
242 $form_gui->addCommandButton("update", $lng->txt("save"));
243 }
244 else
245 {
246 $form_gui->setTitle($lng->txt("book_add_schedule"));
247 $form_gui->addCommandButton("save", $lng->txt("save"));
248 $form_gui->addCommandButton("render", $lng->txt("cancel"));
249 }
250 $form_gui->setFormAction($ilCtrl->getFormAction($this));
251
252 return $form_gui;
253 }
This class represents a date/time property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a text property in a property form.
This class represents a text property in a property form.

References $ilCtrl, and $lng.

Referenced by create(), edit(), save(), and update().

+ Here is the caller graph for this function:

◆ render()

ilBookingScheduleGUI::render ( )

Render list of booking schedules.

uses ilBookingSchedulesTableGUI

Definition at line 47 of file class.ilBookingScheduleGUI.php.

48 {
49 global $tpl, $lng, $ilCtrl, $ilAccess;
50
51 include_once 'Modules/BookingManager/classes/class.ilBookingSchedulesTableGUI.php';
52 $table = new ilBookingSchedulesTableGUI($this, 'render', $this->ref_id);
53
54 if ($ilAccess->checkAccess('write', '', $this->ref_id))
55 {
56 // if we have schedules but no objects - show info
57 if(sizeof($table->getData()))
58 {
59 include_once "Modules/BookingManager/classes/class.ilBookingObject.php";
60 if(!sizeof(ilBookingObject::getList(ilObject::_lookupObjId($this->ref_id))))
61 {
62 ilUtil::sendInfo($lng->txt("book_type_warning"));
63 }
64 }
65
66 include_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
67 $bar = new ilToolbarGUI;
68 $bar->addButton($lng->txt('book_add_schedule'), $ilCtrl->getLinkTarget($this, 'create'));
69 $bar = $bar->getHTML();
70 }
71
72 $tpl->setContent($bar.$table->getHTML());
73 }
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type
List booking schedules (for booking pool)
static _lookupObjId($a_id)
addButton($a_txt, $a_cmd, $a_target="", $a_acc_key="", $a_additional_attrs='', $a_id="", $a_class='submit')
Add button to toolbar.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $ilCtrl, $lng, $tpl, ilObject\_lookupObjId(), ilToolbarGUI\addButton(), ilBookingObject\getList(), and ilUtil\sendInfo().

Referenced by save(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilBookingScheduleGUI::save ( )

Create new dataset.

Definition at line 258 of file class.ilBookingScheduleGUI.php.

259 {
260 global $tpl, $lng;
261
262 $form = $this->initForm();
263 if($form->checkInput())
264 {
265 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
266 $obj = new ilBookingSchedule;
267 $this->formToObject($form, $obj);
268 $obj->save();
269
270 ilUtil::sendSuccess($lng->txt("book_schedule_added"));
271 $this->render();
272 }
273 else
274 {
275 $form->setValuesByPost();
276 $this->setDefinitionFromPost($form);
277 $tpl->setContent($form->getHTML());
278 }
279 }
formToObject($form, $schedule)
Convert incoming form data to schedule object.
render()
Render list of booking schedules.
setDefinitionFromPost(ilPropertyFormGUI $form)
Reload definition values from post data.

References $lng, $tpl, formToObject(), initForm(), render(), ilUtil\sendSuccess(), and setDefinitionFromPost().

+ Here is the call graph for this function:

◆ setDefinitionFromPost()

ilBookingScheduleGUI::setDefinitionFromPost ( ilPropertyFormGUI  $form)
protected

Reload definition values from post data.

Parameters
ilPropertyFormGUI$form

Definition at line 312 of file class.ilBookingScheduleGUI.php.

313 {
314 $days = $form->getInput("days");
315 if($days)
316 {
317 $days_group = $form->getItemByPostVar("days");
318 foreach($days_group->getOptions() as $option)
319 {
320 $days_fields[$option->getValue()] = $option;
321 }
322
323 foreach($days as $day)
324 {
325 $slot = $form->getInput($day."_slot");
326 $subs = $days_fields[$day]->getSubItems();
327 if($slot[0])
328 {
329 $subs[0]->setValue($slot[0]);
330 }
331 if($slot[1])
332 {
333 $subs[1]->setValue($slot[1]);
334 }
335 }
336 }
337 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
getItemByPostVar($a_post_var)
Get Item by POST variable.

References ilPropertyFormGUI\getInput(), and ilPropertyFormGUI\getItemByPostVar().

Referenced by save(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilBookingScheduleGUI::update ( )

Update dataset.

Definition at line 284 of file class.ilBookingScheduleGUI.php.

285 {
286 global $tpl, $lng;
287
288 $form = $this->initForm('edit', (int)$_POST['schedule_id']);
289 if($form->checkInput())
290 {
291 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
292 $obj = new ilBookingSchedule((int)$_POST['schedule_id']);
293 $this->formToObject($form, $obj);
294 $obj->update();
295
296 ilUtil::sendSuccess($lng->txt("book_schedule_updated"));
297 $this->render();
298 }
299 else
300 {
301 $form->setValuesByPost();
302 $this->setDefinitionFromPost($form);
303 $tpl->setContent($form->getHTML());
304 }
305 }

References $_POST, $lng, $tpl, formToObject(), initForm(), render(), ilUtil\sendSuccess(), and setDefinitionFromPost().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: