<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */


class ExportDatDoc extends ExportBasis
{
  
  public function export()
  {
    $this->clearResult();
    $this->exportresults = $this->exportsets;
  }

  
  public function getVarValue($varname)
  {
    switch ($this->getVarCategory($varname)) {
      default: return parent::getVarValue($varname);
      case 'datdoc_': return $this->expCalculation->getVarValue4DatDoc($this->getVarName($varname), $this->exportresults[$this->actualset]);
      case 'kterstelltvon_':
        if (!($this->exportresults[$this->actualset] instanceof \Dat_doc)) {
          return '';
        }

        $person = $this->exportresults[$this->actualset]->getKtErstelltVon();
        if (is_null($person)) {
          return '';
        }

        switch (get_class($person)) {
          case \BASysBenutzer::class:
            return $this->expCalculation->getVarValue4BasysUser($this->getVarName($varname), $person);
          case \Adresse::class:
            return $person->getVarValue($this->getVarName($varname));
          case \Dozent::class:
            return $this->expCalculation->getVarValue4Dozent($this->getVarName($varname), $person);
          case \Teilnehmer::class:
            return $this->expCalculation->getVarValue4Teilnehmer($this->getVarName($varname), $person);
        }

        return '';
      case 'ktfach_':
        if (!($this->exportresults[$this->actualset] instanceof \Dat_doc)) {
          return '';
        }

        $fach = $this->exportresults[$this->actualset]->getKtFach();
        if (is_null($fach)) {
          return '';
        }

        return $fach->getVarValue($this->getVarName($varname));
    }
  }
}