/**
  * Init fieldset for input data
  */
 protected function initFieldsetForInputData()
 {
     $this->FieldsetInput = new FormularFieldset(__('Input'));
     foreach ($this->InfoLines as $InfoMessage) {
         $this->FieldsetInput->addInfo($InfoMessage);
     }
     $FieldModel = new FormularSelectBox('model', __('Model'));
     $FieldModel->addOption('jack-daniels', 'Jack Daniels (VDOT)');
     $FieldModel->addOption('robert-bock', 'Robert Bock (CPP)');
     $FieldModel->addOption('herbert-steffny', 'Herbert Steffny');
     $FieldModel->addOption('david-cameron', 'David Cameron');
     $FieldModel->addAttribute('onchange', '$(\'#prognosis-calculator .only-\'+$(this).val()).closest(\'div\').show();$(\'#prognosis-calculator .hide-on-model-change:not(.only-\'+$(this).val()+\')\').closest(\'div\').hide();');
     $FieldModel->setLayout(FormularFieldset::$LAYOUT_FIELD_W50_AS_W100);
     $FieldDistances = new FormularInput('distances', __('Distances'));
     $FieldDistances->setLayout(FormularFieldset::$LAYOUT_FIELD_W50_AS_W100);
     $FieldDistances->setSize(FormularInput::$SIZE_FULL_INLINE);
     $this->FieldsetInput->addField($FieldModel);
     $this->FieldsetInput->addField($FieldDistances);
     $this->addFieldsForJackDaniels();
     $this->addFieldsForBockAndSteffny();
 }
예제 #2
0
 /**
  * Display fieldset: Equipment
  */
 protected function initEquipmentFieldset()
 {
     $isCreateForm = $this->submitMode == StandardFormular::$SUBMIT_MODE_CREATE;
     $Factory = new Factory(SessionAccountHandler::getId());
     $AllEquipment = $Factory->allEquipments();
     $RelatedEquipment = $isCreateForm ? array() : $Factory->equipmentForActivity($this->dataObject->id(), true);
     $Fieldset = new FormularFieldset(__('Equipment'));
     $Fieldset->addField(new FormularInputHidden('equipment_old', '', implode(',', $RelatedEquipment)));
     if (isset($_POST['equipment'])) {
         $RelatedEquipment = self::readEquipmentFromPost();
     }
     foreach ($Factory->allEquipmentTypes() as $EquipmentType) {
         $options = array();
         $values = array();
         $attributes = array();
         foreach ($AllEquipment as $Equipment) {
             if ($Equipment->typeid() == $EquipmentType->id() && (!$isCreateForm || $Equipment->isInUse())) {
                 $options[$Equipment->id()] = $Equipment->name();
                 $attributes[$Equipment->id()] = array('data-start' => $Equipment->startDate(), 'data-end' => $Equipment->endDate());
                 if (in_array($Equipment->id(), $RelatedEquipment)) {
                     $values[$Equipment->id()] = 'on';
                 }
             }
         }
         if (empty($options)) {
             continue;
         }
         if ($EquipmentType->allowsMultipleValues()) {
             $Field = new FormularCheckboxes('equipment[' . $EquipmentType->id() . ']', $EquipmentType->name(), $values);
             foreach ($options as $key => $label) {
                 $Field->addCheckbox($key, $label, $attributes[$key]);
             }
         } else {
             $selected = !empty($values) ? array_keys($values) : array(0);
             $Field = new FormularSelectBox('equipment[' . $EquipmentType->id() . ']', $EquipmentType->name(), $selected[0]);
             $Field->addOption(0, '');
             foreach ($options as $key => $label) {
                 $Field->addOption($key, $label, $attributes[$key]);
             }
         }
         $SportClasses = 'only-specific-sports';
         foreach ($Factory->sportForEquipmentType($EquipmentType->id(), true) as $id) {
             $SportClasses .= ' only-sport-' . $id;
         }
         $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100_IN_W50);
         $Field->addLayoutClass($SportClasses . ' depends-on-date');
         $Field->addAttribute('class', FormularInput::$SIZE_FULL_INLINE);
         $Fieldset->addField($Field);
     }
     $this->addFieldset($Fieldset);
 }