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

  
  class FormVar extends FormVarBasic
  {
    
    
    
    public $formoptary;
    
    
    public $formopt0txt;
    
    public $formgrptxt;

    
    public function __construct(
      $formvarna,
      $formname,
      $formtext,
      $formoptary = null,
      $formopt0txt = '',
      $formgrptxt = ''
    ) {
      
      parent::__construct($formvarna, $formname, $formtext);
      $this->formoptary = $formoptary;
      $this->formopt0txt = $formopt0txt;
      $this->formgrptxt = $formgrptxt;
    }

    
    public function getSelectBox()
    {
      $selStr
                = "<select  name= '" . CleanOperations::cleanStringForHtml($this->formname) . "' size='1'>\n
                <option value='0'>" . CleanOperations::cleanStringForHtml($this->formopt0txt) . "</option>\n";
      foreach ($this->formoptary as $key => $wert) {
        if ($wert == $this->formvarna) {
          $selected = 'selected';
        } else {
          $selected = '';
        }
        $selStr .= '<option ' . $selected . " value='" . CleanOperations::cleanStringForHtml($wert) . "'>"
                  . CleanOperations::cleanStringForHtml($key) . "</option>\n";
      }
      $selStr .= "</select>\n";

      return($selStr);
    }

    

    
    public function ausgabeFormElem()
    {
      
      FormVarBasic::ausgabeFormElem();
      echo "<tr><th class='form'></th>";
      echo 		"<td class='formelemtext'>" . CleanOperations::cleanStringForHtml($this->formtext) . "</td>\n"
                . "<td class='formelement'>" . $this->getSelectBox() . "</td>\n"
             . '</tr>';
    }
  }