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

 use Kufer\Web\Classes\Export\ExportCalculation;


class ExportZahlplanAuswahl extends ExportBasis
{
  
  public function getVarValue($varname)
  {
    $kurs = $this->exportresults[$this->actualset]->kurs;
    switch ($this->getVarCategory($varname)) {
      default: return parent::getVarValue($varname);
      case 'k_': return $this->expCalculation->getVarValue4Kurs($this->getVarName($varname), $kurs);
      case 'doz_': return $this->expCalculation->getVarValue4Dozent($this->getVarName($varname), $kurs->getVarValue('hauptdozent'));
      case 'wk_': return (new \Kufer\Web\Classes\Export\ExportCalculation\ExportCalcWarenkorb())->resolveVar($this->getVarName($varname), $kurs);
      case 'kg_': return $this->expCalculation->getVarValue4Kursgebuehr($this->getVarName($varname), $kurs);
      case 'ktort_': 
      case 'kort_': 
        $dbwkorte = new DBWorkKursorte();
        $kursortObj = $dbwkorte->getKursortbymktext($kurs->ort); 

        return $this->expCalculation->getVarValue4Kursort($this->getVarName($varname), $kursortObj); 
      
      case 'kh_': return $this->expCalculation->getVarValue4KursHoteldaten($this->getVarName($varname), $kurs);
      case 'aus_': 
        $dbwas = new DBWorkHLAussenstellen();
        $as = $dbwas->getAussenstelleByKurs($kurs->id);

        return $this->expCalculation->getVarValue4Aussenstelle($this->getVarName($varname), $as);
      case 'haus_':
        $dbwgebaeude = new DBWorkGebaeude();
        $gebaeude = $dbwgebaeude->getGebaeudeByKnr($kurs->id);
        $exportCalc = new \Kufer\Web\Classes\Export\ExportCalculation\ExportCalcGebaeude($this->getExportCalcBlaettern());

        return $exportCalc->resolveVar($this->getVarName($varname), $gebaeude);
      case 'bedit_': return $this->expCalculation->getVarValue4BelegungEdit($this->getVarName($varname), $this->exportresults[$this->actualset]);
    }
  }
}