<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

class ComboboxKursTyp extends Combobox
{
  protected function getDatamodulAry()
  {
    $result = array();

    $herrObj = new class() extends Datamodul {
      public $id;
      public $kurz;
      public $lang;
    };
    $herrObj->id = 1;
    $herrObj->kurz = '';
    $herrObj->lang = 'Normalkurs';

    $frauObj = new class() extends Datamodul {
      public $id;
      public $kurz;
      public $lang;
    };
    $frauObj->id = 2;
    $frauObj->kurz = 'E';
    $frauObj->lang = 'Einzelveranstaltung';

    array_push($result, $herrObj, $frauObj);

    return $result;
  }

  protected function getValueFieldName()
  {
    return 'kurz';
  }

  protected function getTextFieldName()
  {
    return 'lang';
  }

  protected function getDefaultOption()
  {
    $option = new ComboboxOption();
    $option->value = '-1';
    $option->text = 'Kurstyp auswählen';
    $option->isSelected = is_null($this->selectedValue) || $this->selectedValue === $option->value;

    return $option;
  }

  protected function isSelected($option)
  {
    
    return $option->value === $this->selectedValue;
  }
}