ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

Protected Attributes

 $tpl
 
 $tabs
 
 $ctrl
 
 $lng
 
 $access
 
 $help
 
 $obj_data_cache
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBookingScheduleGUI::__construct (   $a_parent_obj)

Constructor.

Parameters
object$a_parent_obj

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

References $DIC.

54  {
55  global $DIC;
56 
57  $this->tpl = $DIC["tpl"];
58  $this->tabs = $DIC->tabs();
59  $this->ctrl = $DIC->ctrl();
60  $this->lng = $DIC->language();
61  $this->access = $DIC->access();
62  $this->help = $DIC["ilHelp"];
63  $this->obj_data_cache = $DIC["ilObjDataCache"];
64  $this->ref_id = $a_parent_obj->ref_id;
65  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ confirmDelete()

ilBookingScheduleGUI::confirmDelete ( )

Confirm delete.

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

References $_GET, $ctrl, $help, $ilCtrl, $lng, $tabs, $tpl, and $type.

414  {
416  $lng = $this->lng;
417  $tpl = $this->tpl;
418  $ilTabs = $this->tabs;
419  $ilHelp = $this->help;
420 
421  $ilHelp->setSubScreenId("delete");
422 
423 
424  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
425  $conf = new ilConfirmationGUI();
426  $conf->setFormAction($ilCtrl->getFormAction($this));
427  $conf->setHeaderText($lng->txt('book_confirm_delete'));
428 
429  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
430  $type = new ilBookingSchedule((int) $_GET['schedule_id']);
431  $conf->addItem('schedule_id', (int) $_GET['schedule_id'], $type->getTitle());
432  $conf->setConfirm($lng->txt('delete'), 'delete');
433  $conf->setCancel($lng->txt('cancel'), 'render');
434 
435  $tpl->setContent($conf->getHTML());
436  }
$type
$_GET["client_id"]
schedule for booking ressource
global $ilCtrl
Definition: ilias.php:18
Confirmation screen class.

◆ create()

ilBookingScheduleGUI::create ( )

Render creation form.

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

References $ctrl, $form, $help, $ilCtrl, $lng, $tabs, $tpl, and initForm().

124  {
125  $tpl = $this->tpl;
127  $ilTabs = $this->tabs;
128  $lng = $this->lng;
129  $ilHelp = $this->help;
130 
131  $ilTabs->clearTargets();
132  $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render'));
133  $ilHelp->setScreenIdComponent("book");
134  $ilHelp->setScreenId("schedules");
135  $ilHelp->setSubScreenId("create");
136 
137  $form = $this->initForm();
138  $tpl->setContent($form->getHTML());
139  }
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
initForm($a_mode="create", $id=null)
Build property form.
+ Here is the call graph for this function:

◆ delete()

ilBookingScheduleGUI::delete ( )

Delete schedule.

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

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

442  {
444  $lng = $this->lng;
445 
446  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
447  $obj = new ilBookingSchedule((int) $_POST['schedule_id']);
448  $obj->delete();
449 
450  ilUtil::sendSuccess($lng->txt('book_schedule_deleted'), true);
451  $ilCtrl->redirect($this, 'render');
452  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
schedule for booking ressource
global $ilCtrl
Definition: ilias.php:18
$_POST["username"]
+ Here is the call graph for this function:

◆ edit()

ilBookingScheduleGUI::edit ( )

Render edit form.

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

References $_GET, $ctrl, $form, $help, $ilCtrl, $lng, $tabs, $tpl, and initForm().

145  {
146  $tpl = $this->tpl;
148  $ilTabs = $this->tabs;
149  $lng = $this->lng;
150  $ilHelp = $this->help;
151 
152  $ilTabs->clearTargets();
153  $ilTabs->setBackTarget($lng->txt('book_back_to_list'), $ilCtrl->getLinkTarget($this, 'render'));
154  $ilHelp->setScreenIdComponent("book");
155  $ilHelp->setScreenId("schedules");
156  $ilHelp->setSubScreenId("edit");
157 
158  $form = $this->initForm('edit', (int) $_GET['schedule_id']);
159  $tpl->setContent($form->getHTML());
160  }
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
initForm($a_mode="create", $id=null)
Build property form.
+ Here is the call graph for this function:

◆ executeCommand()

ilBookingScheduleGUI::executeCommand ( )

main switch

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

References $ctrl, $ilCtrl, $tabs, and $tpl.

71  {
72  $tpl = $this->tpl;
73  $ilTabs = $this->tabs;
75 
76  $next_class = $ilCtrl->getNextClass($this);
77 
78  switch ($next_class) {
79  default:
80  $cmd = $ilCtrl->getCmd("render");
81  $this->$cmd();
82  break;
83  }
84  return true;
85  }
global $ilCtrl
Definition: ilias.php:18

◆ formToObject()

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

Convert incoming form data to schedule object.

Parameters
object$form
object$schedule

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

References $form, $from, $obj_data_cache, and ilScheduleInputGUI\getPostData().

Referenced by save(), and update().

364  {
365  $ilObjDataCache = $this->obj_data_cache;
366 
367  $schedule->setTitle($form->getInput("title"));
368  $schedule->setPoolId($ilObjDataCache->lookupObjId($this->ref_id));
369 
370  $from = $form->getItemByPostVar("from");
371  $schedule->setAvailabilityFrom($from->getDate());
372 
373  $to = $form->getItemByPostVar("to");
374  $schedule->setAvailabilityTo($to->getDate());
375 
376  switch ($form->getInput("deadline_opts")) {
377  case "slot_start":
378  $schedule->setDeadline(0);
379  break;
380 
381  case "hours":
382  $schedule->setDeadline($form->getInput("deadline"));
383  break;
384 
385  case "slot_end":
386  $schedule->setDeadline(-1);
387  break;
388  }
389 
390  /*
391  if($form->getInput("type") == "flexible")
392  {
393  $schedule->setRaster($form->getInput("raster"));
394  $schedule->setMinRental($form->getInput("rent_min"));
395  $schedule->setMaxRental($form->getInput("rent_max"));
396  $schedule->setAutoBreak($form->getInput("break"));
397  }
398  else
399  {
400  $schedule->setRaster(NULL);
401  $schedule->setMinRental(NULL);
402  $schedule->setMaxRental(NULL);
403  $schedule->setAutoBreak(NULL);
404  }
405  */
406 
407  $schedule->setDefinitionBySlots(ilScheduleInputGUI::getPostData("days"));
408  }
$from
if(isset($_POST['submit'])) $form
static getPostData($a_post_var, $a_remove_invalid=true)
+ 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 168 of file class.ilBookingScheduleGUI.php.

References $ctrl, $from, $id, $ilCtrl, $lng, $title, ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), and ilDateTimeInputGUI\setShowTime().

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

169  {
170  $lng = $this->lng;
172 
173  $lng->loadLanguageModule("dateplaner");
174 
175  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
176 
177  $form_gui = new ilPropertyFormGUI();
178 
179  $title = new ilTextInputGUI($lng->txt("title"), "title");
180  $title->setRequired(true);
181  $title->setSize(40);
182  $title->setMaxLength(120);
183  $form_gui->addItem($title);
184 
185  include_once "Modules/BookingManager/classes/class.ilScheduleInputGUI.php";
186  $definition = new ilScheduleInputGUI($lng->txt("book_schedule_days"), "days");
187  $definition->setInfo($lng->txt("book_schedule_days_info"));
188  $definition->setRequired(true);
189  $form_gui->addItem($definition);
190 
191  $deadline_opts = new ilRadioGroupInputGUI($lng->txt("book_deadline_options"), "deadline_opts");
192  $deadline_opts->setRequired(true);
193  $form_gui->addItem($deadline_opts);
194 
195  $deadline_time = new ilRadioOption($lng->txt("book_deadline_hours"), "hours");
196  $deadline_opts->addOption($deadline_time);
197 
198  $deadline = new ilNumberInputGUI($lng->txt("book_deadline"), "deadline");
199  $deadline->setInfo($lng->txt("book_deadline_info"));
200  $deadline->setSuffix($lng->txt("book_hours"));
201  $deadline->setMinValue(1);
202  $deadline->setSize(3);
203  $deadline->setMaxLength(3);
204  $deadline_time->addSubItem($deadline);
205 
206  $deadline_start = new ilRadioOption($lng->txt("book_deadline_slot_start"), "slot_start");
207  $deadline_opts->addOption($deadline_start);
208 
209  $deadline_slot = new ilRadioOption($lng->txt("book_deadline_slot_end"), "slot_end");
210  $deadline_opts->addOption($deadline_slot);
211 
212  if ($a_mode == "edit") {
213  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
214  $schedule = new ilBookingSchedule($id);
215  }
216 
217  $av = new ilFormSectionHeaderGUI();
218  $av->setTitle($lng->txt("obj_activation_list_gui"));
219  $form_gui->addItem($av);
220 
221  // #18221
222  $lng->loadLanguageModule('rep');
223 
224  $from = new ilDateTimeInputGUI($lng->txt("rep_activation_limited_start"), "from");
225  $from->setShowTime(true);
226  $form_gui->addItem($from);
227 
228  $to = new ilDateTimeInputGUI($lng->txt("rep_activation_limited_end"), "to");
229  $to->setShowTime(true);
230  $form_gui->addItem($to);
231 
232  if ($a_mode == "edit") {
233  $form_gui->setTitle($lng->txt("book_edit_schedule"));
234 
235  $item = new ilHiddenInputGUI('schedule_id');
236  $item->setValue($id);
237  $form_gui->addItem($item);
238 
239  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
240  $schedule = new ilBookingSchedule($id);
241  $title->setValue($schedule->getTitle());
242  $from->setDate($schedule->getAvailabilityFrom());
243  $to->setDate($schedule->getAvailabilityTo());
244 
245  if ($schedule->getDeadline() == 0) {
246  $deadline_opts->setValue("slot_start");
247  } elseif ($schedule->getDeadline() > 0) {
248  $deadline->setValue($schedule->getDeadline());
249  $deadline_opts->setValue("hours");
250  } else {
251  $deadline->setValue(0);
252  $deadline_opts->setValue("slot_end");
253  }
254 
255  /*
256  if($schedule->getRaster())
257  {
258  $type->setValue("flexible");
259  $raster->setValue($schedule->getRaster());
260  $rent_min->setValue($schedule->getMinRental());
261  $rent_max->setValue($schedule->getMaxRental());
262  $break->setValue($schedule->getAutoBreak());
263  }
264  else
265  {
266  $type->setValue("fix");
267  }
268  */
269 
270  $definition->setValue($schedule->getDefinitionBySlots());
271 
272  $form_gui->addCommandButton("update", $lng->txt("save"));
273  } else {
274  $form_gui->setTitle($lng->txt("book_add_schedule"));
275  $form_gui->addCommandButton("save", $lng->txt("save"));
276  $form_gui->addCommandButton("render", $lng->txt("cancel"));
277  }
278  $form_gui->setFormAction($ilCtrl->getFormAction($this));
279 
280  return $form_gui;
281  }
This class represents an option in a radio group.
This class represents a property form user interface.
This class represents a section header in a property form.
schedule for booking ressource
if(!array_key_exists('StateId', $_REQUEST)) $id
$from
This class represents a text property in a property form.
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
This class represents a hidden form property in a property form.
This class represents a property in a property form.
This class represents a number property in a property form.
This class represents a text property in a property form.
setRequired($a_required)
Set Required.
setShowTime($a_showtime)
Set Show Time Information.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilBookingScheduleGUI::render ( )

Render list of booking schedules.

uses ilBookingSchedulesTableGUI

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

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

Referenced by save(), and update().

93  {
94  $tpl = $this->tpl;
95  $lng = $this->lng;
97  $ilAccess = $this->access;
98 
99  include_once 'Modules/BookingManager/classes/class.ilBookingSchedulesTableGUI.php';
100  $table = new ilBookingSchedulesTableGUI($this, 'render', $this->ref_id);
101 
102  if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
103  // if we have schedules but no objects - show info
104  if (sizeof($table->getData())) {
105  include_once "Modules/BookingManager/classes/class.ilBookingObject.php";
106  if (!sizeof(ilBookingObject::getList(ilObject::_lookupObjId($this->ref_id)))) {
107  ilUtil::sendInfo($lng->txt("book_type_warning"));
108  }
109  }
110 
111  include_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
112  $bar = new ilToolbarGUI;
113  $bar->addButton($lng->txt('book_add_schedule'), $ilCtrl->getLinkTarget($this, 'create'));
114  $bar = $bar->getHTML();
115  }
116 
117  $tpl->setContent($bar . $table->getHTML());
118  }
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type.
List booking schedules (for booking pool)
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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.
if(empty($password)) $table
Definition: pwgen.php:24
+ 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 286 of file class.ilBookingScheduleGUI.php.

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

287  {
288  $tpl = $this->tpl;
289  $lng = $this->lng;
290 
291  $form = $this->initForm();
292  if ($form->checkInput()) {
293  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
294  $obj = new ilBookingSchedule;
295  $this->formToObject($form, $obj);
296  $obj->save();
297 
298  ilUtil::sendSuccess($lng->txt("book_schedule_added"));
299  $this->render();
300  } else {
301  $form->setValuesByPost();
303  $tpl->setContent($form->getHTML());
304  }
305  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
schedule for booking ressource
if(isset($_POST['submit'])) $form
initForm($a_mode="create", $id=null)
Build property form.
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.
+ 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 336 of file class.ilBookingScheduleGUI.php.

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

Referenced by save(), and update().

337  {
338  $days = $form->getInput("days");
339  if ($days) {
340  $days_group = $form->getItemByPostVar("days");
341  foreach ($days_group->getOptions() as $option) {
342  $days_fields[$option->getValue()] = $option;
343  }
344 
345  foreach ($days as $day) {
346  $slot = $form->getInput($day . "_slot");
347  $subs = $days_fields[$day]->getSubItems();
348  if ($slot[0]) {
349  $subs[0]->setValue($slot[0]);
350  }
351  if ($slot[1]) {
352  $subs[1]->setValue($slot[1]);
353  }
354  }
355  }
356  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilBookingScheduleGUI::update ( )

Update dataset.

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

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

311  {
312  $tpl = $this->tpl;
313  $lng = $this->lng;
314 
315  $form = $this->initForm('edit', (int) $_POST['schedule_id']);
316  if ($form->checkInput()) {
317  include_once 'Modules/BookingManager/classes/class.ilBookingSchedule.php';
318  $obj = new ilBookingSchedule((int) $_POST['schedule_id']);
319  $this->formToObject($form, $obj);
320  $obj->update();
321 
322  ilUtil::sendSuccess($lng->txt("book_schedule_updated"));
323  $this->render();
324  } else {
325  $form->setValuesByPost();
327  $tpl->setContent($form->getHTML());
328  }
329  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
schedule for booking ressource
if(isset($_POST['submit'])) $form
initForm($a_mode="create", $id=null)
Build property form.
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.
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilBookingScheduleGUI::$access
protected

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

Referenced by render().

◆ $ctrl

ilBookingScheduleGUI::$ctrl
protected

◆ $help

ilBookingScheduleGUI::$help
protected

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

Referenced by confirmDelete(), create(), and edit().

◆ $lng

ilBookingScheduleGUI::$lng
protected

◆ $obj_data_cache

ilBookingScheduleGUI::$obj_data_cache
protected

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

Referenced by formToObject().

◆ $tabs

ilBookingScheduleGUI::$tabs
protected

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

Referenced by confirmDelete(), create(), edit(), and executeCommand().

◆ $tpl

ilBookingScheduleGUI::$tpl
protected

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