/** * Save new sequence * @return */ protected function saveSequence() { global $ilObjDataCache; $this->initFormSequence(self::MODE_CREATE); if ($this->form->checkInput()) { $this->form->setValuesByPost(); $booking = new ilBookingEntry(); $booking->setObjId($this->getUserId()); $booking->setNumberOfBookings($this->form->getInput('bo')); $deadline = $this->form->getInput('dead'); $deadline = $deadline['dd'] * 24 + $deadline['hh']; $booking->setDeadlineHours($deadline); // consultation hour group include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php'; if (ilConsultationHourGroups::getGroupsOfUser($this->getUserId())) { $booking->setBookingGroup((int) $this->form->getInput('grp')); } $tgt = explode(',', $this->form->getInput('tgt')); $obj_ids = array(); foreach ((array) $tgt as $ref_id) { if (!trim($ref_id)) { continue; } $obj_id = $ilObjDataCache->lookupObjId($ref_id); $type = ilObject::_lookupType($obj_id); $valid_types = array('crs', 'grp'); if (!$obj_id or !in_array($type, $valid_types)) { ilUtil::sendFailure($this->lng->txt('cal_ch_unknown_repository_object')); $this->tpl->setContent($this->form->getHTML()); return; } $obj_ids[] = $obj_id; } $booking->setTargetObjIds($obj_ids); $booking->save(); $this->createAppointments($booking); ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); $this->ctrl->redirect($this, 'appointmentList'); } else { $this->form->setValuesByPost(); $this->tpl->setContent($this->form->getHTML()); } }
/** * Init consultation hours form * * @param bool $a_insert * @return ilPropertyFormGUI */ protected function initForm($a_insert = false) { global $ilCtrl, $ilUser, $lng; include_once "./Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $form->setFormAction($ilCtrl->getFormAction($this)); if ($a_insert) { $form->setTitle($this->lng->txt("cont_insert_consultation_hours")); } else { $form->setTitle($this->lng->txt("cont_update_consultation_hours")); } $mode = new ilRadioGroupInputGUI($this->lng->txt("cont_cach_mode"), "mode"); $mode->setRequired(true); $form->addItem($mode); $opt_auto = new ilRadioOption($this->lng->txt("cont_cach_mode_automatic"), "auto"); $opt_auto->setInfo($this->lng->txt("cont_cach_mode_automatic_info")); $mode->addOption($opt_auto); $opt_manual = new ilRadioOption($this->lng->txt("cont_cach_mode_manual"), "manual"); $opt_manual->setInfo($this->lng->txt("cont_cach_mode_manual_info")); $mode->addOption($opt_manual); if (!$this->getPageConfig()->getEnablePCType("PlaceHolder")) { include_once "Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php"; $grp_ids = ilConsultationHourGroups::getGroupsOfUser($ilUser->getId()); if (sizeof($grp_ids)) { $this->lng->loadLanguageModule("dateplaner"); $groups = new ilCheckboxGroupInputGUI($this->lng->txt("cal_ch_app_grp"), "grp"); $groups->setRequired(true); $opt_manual->addSubItem($groups); foreach ($grp_ids as $grp_obj) { $groups->addOption(new ilCheckboxOption($grp_obj->getTitle(), $grp_obj->getGroupId())); } } else { $opt_manual->setDisabled(true); } } else { $opt_manual->setDisabled(true); } if ($a_insert) { $mode->setValue("auto"); $form->addCommandButton("create_consultation_hours", $this->lng->txt("select")); $form->addCommandButton("cancelCreate", $this->lng->txt("cancel")); } else { // set values $grp_ids = $this->content_obj->getGroupIds(); if (sizeof($grp_ids)) { $mode->setValue("manual"); $groups->setValue($grp_ids); } else { $mode->setValue("auto"); } $form->addCommandButton("update", $this->lng->txt("select")); $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel")); } return $form; }