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

class ComboboxErmaessigung extends Combobox
{
  public function getOptionen()
  {
    $optionen = array();
    foreach ($this->dataModulAry as $datamodul) {
      $option = new ComboboxOption();
      $option->value = $datamodul->getVarValue($this->getValueFieldName());
      $option->text = $this->getText($datamodul);
      $option->isSelected = ($datamodul->getVarValue('text') . ' (' . $datamodul->getVarValue('prozente') . '%)' == $this->selectedValue);
      $optionen[] = $option;
    }

    return $optionen;
  }

  protected function getDatamodulAry()
  {
    $dbwErmaess = new DBWorkErmaessigung(1, true);

    return $dbwErmaess->getErmaessigungen(true);
  }

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

  protected function getTextFieldName()
  {
    return '';
  }

  protected function getText($datamodul)
  {
    return $datamodul->getVarValue('nr') . ' - ' . $datamodul->getVarValue('text') . ' (' . $datamodul->getVarValue('prozente') . '%)';
  }

  protected function getDefaultOption()
  {
    return null;
  }
}