/**
  * If room attributes are present, display some input fields for the desired
  * amount of those attributes.
  */
 protected function createRoomAttributeFormItem()
 {
     $room_attributes = $this->rooms->getAllAttributes();
     foreach ($room_attributes as $room_attribute) {
         // setup an ilCombinationInputGUI for the room attributes
         $room_attribute_comb = new ilCombinationInputGUI($room_attribute, "attribute_" . $room_attribute);
         $room_attribute_input = new ilRoomSharingNumberInputGUI("\r\n\t\t\t", "attribute_" . $room_attribute . "_amount");
         $room_attribute_input->setMaxLength(8);
         $room_attribute_input->setSize(8);
         $room_attribute_input->setMinValue(0);
         $max_count = $this->rooms->getMaxCountForAttribute($room_attribute);
         $max_count_num = isset($max_count) ? $max_count : 0;
         $room_attribute_input->setMaxValue($max_count_num);
         $room_attribute_comb->addCombinationItem("amount", $room_attribute_input, $this->lng->txt("rep_robj_xrs_amount"));
         $this->addFilterItem($room_attribute_comb);
         $room_attribute_comb->readFromSession();
         $this->filter["attributes"][$room_attribute] = $room_attribute_comb->getValue();
         $value = $_POST[$room_attribute_input->getPostVar()];
         if ($value !== "" && $value > $room_attribute_input->getMaxValue()) {
             if ($this->message != '') {
                 $this->message = $this->message . ', ' . $room_attribute;
             } else {
                 $this->message = $room_attribute;
             }
             if (!$this->messagePlural && $this->messageNeeded) {
                 $this->messagePlural = true;
             }
             $this->messageNeeded = true;
         } elseif ($value !== "" && $value < 0) {
             if ($this->messageLowerZero != '') {
                 $this->messageLowerZero = $this->messageLowerZero . ', ' . $room_attribute;
             } else {
                 $this->messageLowerZero = $room_attribute;
             }
             if (!$this->messagePluralLowerZero && $this->messageNeededLowerZero) {
                 $this->messagePluralLowerZero = true;
             }
             $this->messageNeededLowerZero = true;
         }
     }
 }
 /**
  * Initializes a form for either displaying a room, adding a new room or editing an existing
  * room. The difference between those three forms is subtle but important: the form for
  * displaying rooms displays the information of the room without the ability of editing them.
  * The form for creating a room allows the input of values but contains no values initially. The
  * form for editing a room contains information that have been set before.
  * The creation of either those forms is determined by the mode parameter.
  *
  * @param string $a_mode the mode this form is centered around
  *
  * @return ilPropertyFormGUI the form with the given mode
  */
 private function initForm($a_mode = "show")
 {
     $form_gui =& new ilPropertyFormGUI();
     $form_gui->setMultipart(true);
     $form_gui->setTitle($this->lng->txt("rep_robj_xrs_room_properties"));
     $form_gui->setDescription($this->lng->txt("rep_robj_xrs_room_prop_description"));
     $name = new ilRoomSharingTextInputGUI($this->lng->txt("rep_robj_xrs_room_name"), "name");
     $name->setDisabled(true);
     $form_gui->addItem($name);
     $type = new ilRoomSharingTextInputGUI($this->lng->txt("rep_robj_xrs_room_type"), "type");
     $type->setDisabled(true);
     $form_gui->addItem($type);
     $min_alloc = new ilRoomSharingNumberInputGUI($this->lng->txt("rep_robj_xrs_room_min_alloc"), "min_alloc");
     $min_alloc->setDisabled(true);
     $form_gui->addItem($min_alloc);
     $max_alloc = new ilRoomSharingNumberInputGUI($this->lng->txt("rep_robj_xrs_room_max_alloc"), "max_alloc");
     $max_alloc->setDisabled(true);
     $form_gui->addItem($max_alloc);
     $floor_plan = new ilSelectInputGUI($this->lng->txt("rep_robj_xrs_room_floor_plans"), "file_id");
     $floor_plan->setOptions($this->room_obj->getAllFloorplans());
     $floor_plan->setDisabled(true);
     $form_gui->addItem($floor_plan);
     if (count($this->room_obj->getAllAvailableAttributes())) {
         $defined_attributes = $this->room_obj->getAttributes();
         $show_mode_with_exist_attrs = $a_mode == "show" && count($defined_attributes) > 0;
         if ($a_mode == "edit" || $a_mode == "create" || $show_mode_with_exist_attrs) {
             $attributes_header = new ilFormSectionHeaderGUI();
             $attribute_header_text = $this->createAttributeHeaderText();
             $attributes_header->setTitle($this->lng->txt("rep_robj_xrs_room_attributes") . $attribute_header_text);
             $form_gui->addItem($attributes_header);
         }
         foreach ($this->room_obj->getAllAvailableAttributes() as $attr) {
             $attribute_amount_by_id = $this->room_obj->getAttributeAmountById($attr['id']);
             $amount_not_given = !ilRoomSharingNumericUtils::isPositiveNumber($attribute_amount_by_id, true);
             if ($a_mode == "show" && $amount_not_given) {
                 continue;
             } else {
                 $attr_field = new ilRoomSharingNumberInputGUI($attr['name'], self::ATTRIBUTE_ID_PREFIX . $attr['id']);
                 $attr_field->setValue($attribute_amount_by_id);
                 $attr_field->setMinValue(0);
                 $attr_field->setDisabled($a_mode == "show");
                 $form_gui->addItem($attr_field);
             }
         }
     }
     if ($a_mode == "edit" || $a_mode == "create") {
         $name->setDisabled(false);
         $name->setRequired(true);
         $type->setDisabled(false);
         $min_alloc->setDisabled(false);
         $min_alloc->setMinValue(0);
         $max_alloc->setDisabled(false);
         $max_alloc->setRequired(true);
         $max_alloc->setMinValue(0);
         $floor_plan->setDisabled(false);
         if ($a_mode == "create") {
             $min_alloc->setValue("0");
             $form_gui->addCommandButton($this->ctrl->getLinkTarget($this, "addRoom"), $this->lng->txt("rep_robj_xrs_add_room"));
         } else {
             $form_gui->addCommandButton("saveRoom", $this->lng->txt("save"));
         }
     }
     if ($a_mode == "edit" || $a_mode == "show") {
         $name->setValue($this->room_obj->getName());
         $type->setValue($this->room_obj->getType());
         $min_alloc->setValue($this->room_obj->getMinAlloc());
         $max_alloc->setValue($this->room_obj->getMaxAlloc());
         $floor_plan->setValue($this->room_obj->getFileId());
         if ($a_mode == "show") {
             $floor_plan->setDisabled(true);
             $mobj = new ilObjMediaObject($this->room_obj->getFileId());
             $mitems = $mobj->getMediaItems();
             if (!empty($mitems)) {
                 $med = $mobj->getMediaItem("Standard");
                 $target = $med->getThumbnailTarget();
                 $image_with_link = "<br><a target='_blank' href='" . $mobj->getDataDirectory() . "/" . $med->getLocation() . "'>" . ilUtil::img($target) . "</a>";
                 $floor_plan->setInfo($image_with_link);
             }
         }
     }
     $form_gui->setFormAction($this->ctrl->getFormAction($this));
     return $form_gui;
 }
 /**
  * Creates a form for the davinci import
  *
  * @return \ilPropertyFormGUI the creation form
  */
 protected function initImportForm()
 {
     $import_form = new ilPropertyFormGUI();
     $import_form->setTitle($this->lng->txt("rep_robj_xrs_daVinci_import_title"));
     $file = $this->createFileInputFormItem();
     $import_form->addItem($file);
     $importOption1field = new ilCheckboxInputGUI($this->lng->txt("rep_robj_xrs_daVinci_import_bookings"), 'import_bookings');
     $import_form->addItem($importOption1field);
     $importOption2field = new ilCheckboxInputGUI($this->lng->txt("rep_robj_xrs_daVinci_import_rooms"), 'import_rooms');
     $import_form->addItem($importOption2field);
     $default_cap = new ilRoomSharingNumberInputGUI($this->lng->txt("rep_robj_xrs_daVinci_import_default_cap"), "default_cap");
     $default_cap->setDisabled(false);
     $default_cap->setMinValue(1);
     $default_cap->setValue("20");
     $import_form->addItem($default_cap);
     $import_form->addCommandButton($this->lng->txt("rep_robj_xrs_daVinci_import_button"), $this->lng->txt("import"));
     return $import_form;
 }
 /**
  * If room attributes are present, create the input items for the those attributes.
  */
 private function createRoomAttributeFormItems()
 {
     $room_attribute_items = array();
     $room_attributes = $this->rooms->getAllAttributes();
     foreach ($room_attributes as $room_attribute) {
         // setup an ilRoomSharingNumberInputGUI for the room attributes
         $room_attribute_title = $room_attribute . " (" . $this->lng->txt("rep_robj_xrs_amount") . ")";
         $room_attribute_postvar = "attribute_" . $room_attribute . "_amount";
         $room_attribute_input = new ilRoomSharingNumberInputGUI($room_attribute_title, $room_attribute_postvar);
         $room_attribute_input->setParent($this->search_form);
         $room_attribute_input->setMaxLength(8);
         $room_attribute_input->setSize(8);
         $room_attribute_input->setMinValue(0);
         $max = $this->rooms->getMaxCountForAttribute($room_attribute);
         $max_num = isset($max) ? $max : 0;
         $room_attribute_input->setMaxValue($max_num);
         $room_attribute_input->readFromSession();
         $room_attribute_items[] = $room_attribute_input;
     }
     return $room_attribute_items;
 }