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


class ExportKurstage extends ExportBasis
{
  
  public function initiate()
  {
    ExportBasis::initiate();
    $this->dboperations = new DBWorkKurseTage();
  }

  
  public function export()
  {
    $this->clearResult();
    for ($i = 0; $i < count($this->exportsets); $i++) {
      $tmp = $this->dboperations->getKurstagebyKursNR($this->exportsets[$i]->id);
      $this->exportresults = $tmp;
    }
  }

  
  public function getVarValue($varname)
  {
    switch ($this->getVarCategory($varname)) {
      default: return ExportBasis::getVarValue($varname);
      case 'k_': return $this->expCalculation->getVarValue4Kurs($this->getVarName($varname), $this->exportresults[$this->actualset]->kurs);
      case 'kt_': return $this->expCalculation->getVarValue4Kurstag($this->getVarName($varname), $this->exportresults[$this->actualset]);
      case 'doz_': return $this->expCalculation->getVarValue4Dozent($this->getVarName($varname), $this->exportresults[$this->actualset]->dozent);
      case 'kort_':
      case 'ktort_': return $this->expCalculation->getVarValue4Kursort($this->getVarName($varname), $this->exportresults[$this->actualset]->kursort);
      case 'haus_':
        $dbwgebaeude = new DBWorkGebaeude();
        $gebaeude = $dbwgebaeude->getGebaeudeByKnr($this->exportresults[$this->actualset]->kurs->id);
        $exportCalc = new \Kufer\Web\Classes\Export\ExportCalculation\ExportCalcGebaeude($this->getExportCalcBlaettern());

        return $exportCalc->resolveVar($this->getVarName($varname), $gebaeude);
      case 'maplanend_':
        return $this->expCalculation->getVarValue4BasysUser($this->getVarName($varname), $this->getKurs()->getPlanendenMitarbeiter());
      case 'maverwaltend_':
        return $this->expCalculation->getVarValue4BasysUser($this->getVarName($varname), $this->getKurs()->getVerwaltendenMitarbeiter());
    }
  }

  
  protected function getKurs()
  {
    return $this->exportresults[$this->actualset]->kurs;
  }
}