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

class ComboboxDseUnterschriebenWiderrufenWeg extends Combobox
{
  protected function getDatamodulAry()
  {
    $dbwHLDatenschutzWeg = DBWorkHLDatenschutzWeg::getDefaultInstance(1, true);

    return $dbwHLDatenschutzWeg->getAll();
  }

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

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

  public function getSelectedText()
  {
    $result = parent::getSelectedText();
    if ($result === '') {
      $result = $this->getNichtBearbeitbareStatusText();
    }

    return $result;
  }

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

  private function getNichtBearbeitbareStatusText()
  {
    $result = $this->selectedValue;
    if ($this->selectedValue != '') {
      $dbw = DBWorkHLDatenschutzWeg::getDefaultInstance(1, true);
      $hlDatenschutzWeg = $dbw->getBySchluessel($this->selectedValue);
      $text = $hlDatenschutzWeg->getVarValue('text');
      if ($text != '') {
        $result .= ' - ' . $text;
      }
    }

    return $result;
  }
}