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


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

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

  
  public function getVarValue($varname)
  {
    switch ($this->getVarCategory($varname)) {
      default: return ExportBasis::getVarValue($varname);
      case 'aus_': return $this->expCalculation->getVarValue4Aussenstelle($this->getVarName($varname), $this->exportresults[$this->actualset]);
      case 'foto_':   
        $foto = FotoAPI::getFotoByVarname($varname, 'S', $this->exportresults[$this->actualset]->id);
        if (!is_null($foto)) {
          return (new \Kufer\Web\Classes\Export\ExportCalculation\ExportCalcFotos())->resolveVar($foto['fotovarname'], $foto['foto'], $varname);
        } else {
          return '';
        }
    }
  }
}