ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 378 of file class.ilBookingScheduleGUI.php.

379 {
380 global $ilCtrl, $lng, $tpl, $ilTabs, $ilHelp;
381
382 $ilHelp->setSubScreenId("delete");
383
384
385 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
386 $conf = new ilConfirmationGUI();
387 $conf->setFormAction($ilCtrl->getFormAction($this));
388 $conf->setHeaderText($lng->txt('book_confirm_delete'));
389
390 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
391 $type = new ilBookingSchedule((int)$_GET['schedule_id']);
392 $conf->addItem('schedule_id', (int)$_GET['schedule_id'], $type->getTitle());
393 $conf->setConfirm($lng->txt('delete'), 'delete');
394 $conf->setCancel($lng->txt('cancel'), 'render');
395
396 $tpl->setContent($conf->getHTML());
397 }
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:17

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 402 of file class.ilBookingScheduleGUI.php.

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

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 327 of file class.ilBookingScheduleGUI.php.

328 {
329 global $ilObjDataCache;
330
331 $schedule->setTitle($form->getInput("title"));
332 $schedule->setPoolId($ilObjDataCache->lookupObjId($this->ref_id));
333
334 $from = $form->getItemByPostVar("from");
335 $schedule->setAvailabilityFrom($from->getDate());
336
337 $to = $form->getItemByPostVar("to");
338 $schedule->setAvailabilityTo($to->getDate());
339
340 switch($form->getInput("deadline_opts"))
341 {
342 case "slot_start":
343 $schedule->setDeadline(0);
344 break;
345
346 case "hours":
347 $schedule->setDeadline($form->getInput("deadline"));
348 break;
349
350 case "slot_end":
351 $schedule->setDeadline(-1);
352 break;
353 }
354
355 /*
356 if($form->getInput("type") == "flexible")
357 {
358 $schedule->setRaster($form->getInput("raster"));
359 $schedule->setMinRental($form->getInput("rent_min"));
360 $schedule->setMaxRental($form->getInput("rent_max"));
361 $schedule->setAutoBreak($form->getInput("break"));
362 }
363 else
364 {
365 $schedule->setRaster(NULL);
366 $schedule->setMinRental(NULL);
367 $schedule->setMaxRental(NULL);
368 $schedule->setAutoBreak(NULL);
369 }
370 */
371
372 $schedule->setDefinitionBySlots(ilScheduleInputGUI::getPostData("days"));
373 }
static getPostData($a_post_var, $a_remove_invalid=true)

References 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 include_once "Modules/BookingManager/classes/class.ilScheduleInputGUI.php";
132 $definition = new ilScheduleInputGUI($lng->txt("book_schedule_days"), "days");
133 $definition->setInfo($lng->txt("book_schedule_days_info"));
134 $definition->setRequired(true);
135 $form_gui->addItem($definition);
136
137 $deadline_opts = new ilRadioGroupInputGUI($lng->txt("book_deadline_options"), "deadline_opts");
138 $deadline_opts->setRequired(true);
139 $form_gui->addItem($deadline_opts);
140
141 $deadline_time = new ilRadioOption($lng->txt("book_deadline_hours"), "hours");
142 $deadline_opts->addOption($deadline_time);
143
144 $deadline = new ilNumberInputGUI($lng->txt("book_deadline"), "deadline");
145 $deadline->setInfo($lng->txt("book_deadline_info"));
146 $deadline->setSuffix($lng->txt("book_hours"));
147 $deadline->setMinValue(1);
148 $deadline->setSize(3);
149 $deadline->setMaxLength(3);
150 $deadline_time->addSubItem($deadline);
151
152 $deadline_start = new ilRadioOption($lng->txt("book_deadline_slot_start"), "slot_start");
153 $deadline_opts->addOption($deadline_start);
154
155 $deadline_slot = new ilRadioOption($lng->txt("book_deadline_slot_end"), "slot_end");
156 $deadline_opts->addOption($deadline_slot);
157
158 if ($a_mode == "edit")
159 {
160 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
161 $schedule = new ilBookingSchedule($id);
162 }
163
164 $av = new ilFormSectionHeaderGUI();
165 $av->setTitle($lng->txt("obj_activation_list_gui"));
166 $form_gui->addItem($av);
167
168 // #18221
169 $lng->loadLanguageModule('rep');
170
171 $from = new ilDateTimeInputGUI($lng->txt("rep_activation_limited_start"), "from");
172 $from->setShowTime(true);
173 $form_gui->addItem($from);
174
175 $to = new ilDateTimeInputGUI($lng->txt("rep_activation_limited_end"), "to");
176 $to->setShowTime(true);
177 $form_gui->addItem($to);
178
179 if ($a_mode == "edit")
180 {
181 $form_gui->setTitle($lng->txt("book_edit_schedule"));
182
183 $item = new ilHiddenInputGUI('schedule_id');
184 $item->setValue($id);
185 $form_gui->addItem($item);
186
187 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
188 $schedule = new ilBookingSchedule($id);
189 $title->setValue($schedule->getTitle());
190 $from->setDate($schedule->getAvailabilityFrom());
191 $to->setDate($schedule->getAvailabilityTo());
192
193 if($schedule->getDeadline() == 0)
194 {
195 $deadline_opts->setValue("slot_start");
196 }
197 else if($schedule->getDeadline() > 0)
198 {
199 $deadline->setValue($schedule->getDeadline());
200 $deadline_opts->setValue("hours");
201 }
202 else
203 {
204 $deadline->setValue(0);
205 $deadline_opts->setValue("slot_end");
206 }
207
208 /*
209 if($schedule->getRaster())
210 {
211 $type->setValue("flexible");
212 $raster->setValue($schedule->getRaster());
213 $rent_min->setValue($schedule->getMinRental());
214 $rent_max->setValue($schedule->getMaxRental());
215 $break->setValue($schedule->getAutoBreak());
216 }
217 else
218 {
219 $type->setValue("fix");
220 }
221 */
222
223 $definition->setValue($schedule->getDefinitionBySlots());
224
225 $form_gui->addCommandButton("update", $lng->txt("save"));
226 }
227 else
228 {
229 $form_gui->setTitle($lng->txt("book_add_schedule"));
230 $form_gui->addCommandButton("save", $lng->txt("save"));
231 $form_gui->addCommandButton("render", $lng->txt("cancel"));
232 }
233 $form_gui->setFormAction($ilCtrl->getFormAction($this));
234
235 return $form_gui;
236 }
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 property in a property form.
This class represents an option in a radio group.
This class represents a text property in a property form.
This class represents a text property in a property form.

References $ilCtrl, $lng, and $title.

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 241 of file class.ilBookingScheduleGUI.php.

242 {
243 global $tpl, $lng;
244
245 $form = $this->initForm();
246 if($form->checkInput())
247 {
248 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
249 $obj = new ilBookingSchedule;
250 $this->formToObject($form, $obj);
251 $obj->save();
252
253 ilUtil::sendSuccess($lng->txt("book_schedule_added"));
254 $this->render();
255 }
256 else
257 {
258 $form->setValuesByPost();
259 $this->setDefinitionFromPost($form);
260 $tpl->setContent($form->getHTML());
261 }
262 }
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 295 of file class.ilBookingScheduleGUI.php.

296 {
297 $days = $form->getInput("days");
298 if($days)
299 {
300 $days_group = $form->getItemByPostVar("days");
301 foreach($days_group->getOptions() as $option)
302 {
303 $days_fields[$option->getValue()] = $option;
304 }
305
306 foreach($days as $day)
307 {
308 $slot = $form->getInput($day."_slot");
309 $subs = $days_fields[$day]->getSubItems();
310 if($slot[0])
311 {
312 $subs[0]->setValue($slot[0]);
313 }
314 if($slot[1])
315 {
316 $subs[1]->setValue($slot[1]);
317 }
318 }
319 }
320 }
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 267 of file class.ilBookingScheduleGUI.php.

268 {
269 global $tpl, $lng;
270
271 $form = $this->initForm('edit', (int)$_POST['schedule_id']);
272 if($form->checkInput())
273 {
274 include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
275 $obj = new ilBookingSchedule((int)$_POST['schedule_id']);
276 $this->formToObject($form, $obj);
277 $obj->update();
278
279 ilUtil::sendSuccess($lng->txt("book_schedule_updated"));
280 $this->render();
281 }
282 else
283 {
284 $form->setValuesByPost();
285 $this->setDefinitionFromPost($form);
286 $tpl->setContent($form->getHTML());
287 }
288 }

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: