public function addToForm()
 {
     global $lng;
     $adt_date = $this->getADT()->getDate();
     $date = new ilDateTimeInputGUI($this->getTitle(), $this->getElementId());
     $date->setShowTime(true);
     if (!(bool) $this->text_input) {
         $checked = !(!$adt_date || $adt_date->isNull());
         $date->enableDateActivation($lng->txt("enabled"), $this->addToElementId("tgl"), $checked);
     } else {
         $date->setMode(ilDateTimeInputGUI::MODE_INPUT);
     }
     $date->setDate($adt_date);
     $this->addToParentElement($date);
 }
 /**
  * Add filter by standard type
  * 
  * @param	string	$id
  * @param	int		$type
  * @param	bool	$a_optional
  * @param	string	$caption
  * @return	object
  */
 function addFilterItemByMetaType($id, $type = self::FILTER_TEXT, $a_optional = false, $caption = NULL)
 {
     global $lng;
     if (!$caption) {
         $caption = $lng->txt($id);
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     switch ($type) {
         case self::FILTER_SELECT:
             include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
             $item = new ilSelectInputGUI($caption, $id);
             break;
         case self::FILTER_DATE:
             include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php";
             $item = new ilDateTimeInputGUI($caption, $id);
             $item->setMode(ilDateTimeInputGUI::MODE_INPUT);
             break;
         case self::FILTER_TEXT:
             include_once "./Services/Form/classes/class.ilTextInputGUI.php";
             $item = new ilTextInputGUI($caption, $id);
             $item->setMaxLength(64);
             $item->setSize(20);
             // $item->setSubmitFormOnEnter(true);
             break;
         case self::FILTER_LANGUAGE:
             $lng->loadLanguageModule("meta");
             include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
             $item = new ilSelectInputGUI($caption, $id);
             $options = array("" => $lng->txt("trac_all"));
             foreach ($lng->getInstalledLanguages() as $lang_key) {
                 $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
             }
             $item->setOptions($options);
             break;
         case self::FILTER_NUMBER_RANGE:
             include_once "./Services/Form/classes/class.ilCombinationInputGUI.php";
             include_once "./Services/Form/classes/class.ilNumberInputGUI.php";
             $item = new ilCombinationInputGUI($caption, $id);
             $combi_item = new ilNumberInputGUI("", $id . "_from");
             $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
             $combi_item = new ilNumberInputGUI("", $id . "_to");
             $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
             $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
             $item->setMaxLength(7);
             $item->setSize(20);
             break;
         case self::FILTER_DATE_RANGE:
             include_once "./Services/Form/classes/class.ilCombinationInputGUI.php";
             include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php";
             $item = new ilCombinationInputGUI($caption, $id);
             $combi_item = new ilDateTimeInputGUI("", $id . "_from");
             $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
             $combi_item = new ilDateTimeInputGUI("", $id . "_to");
             $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
             $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
             $item->setMode(ilDateTimeInputGUI::MODE_INPUT);
             break;
         case self::FILTER_DATETIME_RANGE:
             include_once "./Services/Form/classes/class.ilCombinationInputGUI.php";
             include_once "./Services/Form/classes/class.ilDateTimeInputGUI.php";
             $item = new ilCombinationInputGUI($caption, $id);
             $combi_item = new ilDateTimeInputGUI("", $id . "_from");
             $combi_item->setShowTime(true);
             $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
             $combi_item = new ilDateTimeInputGUI("", $id . "_to");
             $combi_item->setShowTime(true);
             $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
             $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
             $item->setMode(ilDateTimeInputGUI::MODE_INPUT);
             break;
         case self::FILTER_DURATION_RANGE:
             $lng->loadLanguageModule("form");
             include_once "./Services/Form/classes/class.ilCombinationInputGUI.php";
             include_once "./Services/Form/classes/class.ilDurationInputGUI.php";
             $item = new ilCombinationInputGUI($caption, $id);
             $combi_item = new ilDurationInputGUI("", $id . "_from");
             $combi_item->setShowMonths(false);
             $combi_item->setShowDays(true);
             $combi_item->setShowSeconds(true);
             $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
             $combi_item = new ilDurationInputGUI("", $id . "_to");
             $combi_item->setShowMonths(false);
             $combi_item->setShowDays(true);
             $combi_item->setShowSeconds(true);
             $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
             $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
             break;
         default:
             return false;
     }
     $this->addFilterItem($item, $a_optional);
     $item->readFromSession();
     return $item;
 }
 /**
  * Add filter items
  *
  */
 public function initFilter()
 {
     if ($this->isColumnSelected('id')) {
         $this->addFilterItemWithValue(new ilTextInputGUI($this->pl->txt('cert_id'), 'id'));
     }
     if ($this->isColumnSelected('firstname')) {
         $this->addFilterItemWithValue(new ilTextInputGUI($this->pl->txt('firstname'), 'firstname'));
     }
     if ($this->isColumnSelected('lastname')) {
         $this->addFilterItemWithValue(new ilTextInputGUI($this->pl->txt('lastname'), 'lastname'));
     }
     if ($this->isColumnSelected('crs_title')) {
         $this->addFilterItemWithValue(new ilTextInputGUI($this->pl->txt('crs_title'), 'crs_title'));
     }
     if ($this->isColumnSelected('valid_from')) {
         $item = new ilDateTimeInputGUI($this->pl->txt('valid_from'), 'valid_from');
         $item->setMode(ilDateTimeInputGUI::MODE_INPUT);
         $this->addFilterItemWithValue($item);
     }
     if ($this->isColumnSelected('valid_to')) {
         $item = new ilDateTimeInputGUI($this->pl->txt('valid_to'), 'valid_to');
         $item->setMode(ilDateTimeInputGUI::MODE_INPUT);
         $this->addFilterItemWithValue($item);
     }
     if ($this->isColumnSelected('cert_type')) {
         $item = new ilSelectInputGUI($this->pl->txt('cert_type'), 'type_id');
         $options = array('' => '') + srCertificateType::getArray('id', 'title');
         $item->setOptions($options);
         $this->addFilterItemWithValue($item);
     }
     if (!$this->getOption('newest_version_only')) {
         $item = new ilCheckboxInputGUI($this->pl->txt('only_newest_version'), 'active');
         $this->addFilterItemWithValue($item);
     }
 }
 /**
  * Get input GUI depending on identifier
  *
  * @return ilFormPropertyGUI|null
  */
 protected function getInputByIdentifier()
 {
     $name = 'default_value';
     $title = $this->pl->txt('default_value');
     switch ($this->identifier) {
         case srCertificateTypeSetting::IDENTIFIER_DEFAULT_LANG:
             $input = new ilSelectInputGUI($title, $name);
             $options = array();
             foreach ($this->type->getLanguages() as $lang) {
                 $options[$lang] = $this->lng->txt("meta_l_{$lang}");
             }
             $input->setOptions($options);
             $input->setValue($this->setting->getValue());
             break;
         case srCertificateTypeSetting::IDENTIFIER_GENERATION:
             $input = new ilRadioGroupInputGUI($title, $name);
             $option = new ilRadioOption($this->pl->txt('setting_generation_auto'), srCertificateTypeSetting::GENERATION_AUTO);
             $input->addOption($option);
             $option = new ilRadioOption($this->pl->txt('setting_generation_manually'), srCertificateTypeSetting::GENERATION_MANUAL);
             $input->addOption($option);
             $input->setValue($this->setting->getValue());
             break;
         case srCertificateTypeSetting::IDENTIFIER_VALIDITY_TYPE:
             $input = new ilRadioGroupInputGUI($title, $name);
             $option = new ilRadioOption($this->pl->txt('always'), srCertificateTypeSetting::VALIDITY_TYPE_ALWAYS);
             $input->addOption($option);
             $option = new ilRadioOption($this->pl->txt('setting_validity_range'), srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE);
             $input->addOption($option);
             $option = new ilRadioOption($this->pl->txt('setting_validity_date'), srCertificateTypeSetting::VALIDITY_TYPE_DATE);
             $input->addOption($option);
             $input->setValue($this->setting->getValue());
             break;
         case srCertificateTypeSetting::IDENTIFIER_VALIDITY:
             $validity_value = $this->setting->getValue();
             switch ($this->type->getSettingByIdentifier(srCertificateTypeSetting::IDENTIFIER_VALIDITY_TYPE)->getValue()) {
                 case srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE:
                     $input = new ilDurationInputGUI($title, $name);
                     $input->setShowMinutes(false);
                     $input->setShowHours(false);
                     $input->setShowDays(true);
                     $input->setShowMonths(true);
                     if ($validity_value) {
                         $range_array = json_decode($validity_value, true);
                         $data = array();
                         $data[$input->getPostVar()]['MM'] = $range_array['m'];
                         $data[$input->getPostVar()]['dd'] = $range_array['d'];
                         $input->setValueByArray($data);
                     }
                     break;
                 case srCertificateTypeSetting::VALIDITY_TYPE_DATE:
                     $input = new ilDateTimeInputGUI($title, $name);
                     $input->setMode(ilDateTimeInputGUI::MODE_INPUT);
                     if ($validity_value) {
                         $input->setDate(new ilDateTime($validity_value, IL_CAL_DATE));
                     }
                     break;
                 case srCertificateTypeSetting::VALIDITY_TYPE_ALWAYS:
                     // Makes no sence to configure this further
                     $input = null;
                     break;
                 default:
                     $input = new ilTextInputGUI($title, $name);
             }
             break;
         case srCertificateTypeSetting::IDENTIFIER_DOWNLOADABLE:
         case srCertificateTypeSetting::IDENTIFIER_SCORM_TIMING:
         case srCertificateTypeSetting::IDENTIFIER_NOTIFICATION_USER:
             $input = new ilCheckboxInputGUI($title, $name);
             if ($this->setting->getValue()) {
                 $input->setChecked(true);
             }
             break;
         default:
             $input = new ilTextInputGUI($title, $name);
             $input->setValue($this->setting->getValue());
     }
     return $input;
 }
 /**
  * Build ValidityInput
  *
  * @param srCertificateDefinitionSetting $setting
  * @return ilRadioGroupInputGUI
  */
 protected function getValidityInput(srCertificateDefinitionSetting $setting)
 {
     $validity_value = $this->definition->getValidity();
     // Always
     $input = new ilRadioGroupInputGUI($this->pl->txt('setting_id_validity'), $setting->getIdentifier());
     $input->setRequired(true);
     $option = new ilRadioOption($this->pl->txt('always'), srCertificateTypeSetting::VALIDITY_TYPE_ALWAYS);
     $input->addOption($option);
     // Date range
     $option = new ilRadioOption($this->pl->txt('setting_validity_range'), srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE);
     $subitem = new ilDurationInputGUI($this->pl->txt('date_range'), $setting->getIdentifier() . '_' . srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE);
     $subitem->setShowMinutes(false);
     $subitem->setShowHours(false);
     $subitem->setShowDays(true);
     $subitem->setShowMonths(true);
     if ($setting->getValue() == srCertificateTypeSetting::VALIDITY_TYPE_DATE_RANGE && $validity_value) {
         $range_array = json_decode($validity_value, true);
         $data = array();
         $data[$subitem->getPostVar()]['MM'] = $range_array['m'];
         $data[$subitem->getPostVar()]['dd'] = $range_array['d'];
         $subitem->setValueByArray($data);
     }
     $option->addSubItem($subitem);
     $input->addOption($option);
     // Date
     $option = new ilRadioOption($this->pl->txt('setting_validity_date'), srCertificateTypeSetting::VALIDITY_TYPE_DATE);
     $subitem = new ilDateTimeInputGUI($this->pl->txt('date'), $setting->getIdentifier() . '_' . srCertificateTypeSetting::VALIDITY_TYPE_DATE);
     $subitem->setMode(ilDateTimeInputGUI::MODE_INPUT);
     if ($setting->getValue() == srCertificateTypeSetting::VALIDITY_TYPE_DATE && $validity_value) {
         $subitem->setDate(new ilDateTime($validity_value, IL_CAL_DATE));
     }
     $option->addSubItem($subitem);
     $input->addOption($option);
     $subitem->setDisabled(!$setting->isEditable());
     // SW This seems to have no effect...
     return $input;
 }