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

namespace Kufer\Web\KuferTools\Basis\Raumbelegung\Raumdetails\RaumGrafik;

class RaumGrafikEntryView extends \Kufer\Web\KuferTools\Basis\View\ViewSight
{
  public function getTemplatePathRelative()
  {
    return 'basis/raumgrafik/raumgrafik_tableentry.sgt';
  }

  protected function getDefaultDataModulArray()
  {
    return array($this->viewModel->row);
  }

  protected function getBodyDataModulArray()
  {
    return array($this->viewModel->entry);
  }

  protected function getBodyExportAdapter()
  {
    return new class($this->viewModel) extends \ExpBasis {
      public function __construct($viewModel)
      {
        parent::__construct(true);
        $this->export = new class($viewModel) extends \ExportBasis {
          protected $viewModel;

          public function __construct($viewModel)
          {
            parent::__construct();

            $this->viewModel = $viewModel;
          }

          public function getVarValue($varname)
          {
            switch ($this->getVarCategory($varname)) {
              default: return parent::getVarValue($varname);
              case 'row_': return $this->viewModel->row->getVarValue($this->getVarName($varname));
              case 'cell_': return $this->viewModel->cell->getVarValue($this->getVarName($varname));
              case 'entry_': return $this->exportresults[$this->actualset]->getVarValue($this->getVarName($varname));
              case 'ort_': return $this->exportresults[$this->actualset]->getVarValueEx($this->getVarName($varname), 'kursort');
              case 'k_': return $this->exportresults[$this->actualset]->getVarValueEx($this->getVarName($varname), 'kurs');
              case 'kt_': return $this->exportresults[$this->actualset]->getVarValueEx($this->getVarName($varname), 'kurstag');
              case 'doz_':
              case 'd_': return $this->expCalculation->getVarValue4Dozent($this->getVarName($varname), $this->exportresults[$this->actualset]->getDatamodulByName('dozent'));
              case 'sperrzeit_': return $this->exportresults[$this->actualset]->getVarValueEx($this->getVarName($varname), 'ortverf');
              case 'grafik_': return $this->viewModel->{$this->getVarName($varname)} ?? '';
            }
          }
        };
      }
    };
  }
}

class RaumGrafikEntryViewModel
{
  public $row;
  public $cell;
  public $entry;

  public $showDozent;
  public $showKursNr;
  public $showKursTitel;
  public $kursDetailsAllowed;
  public $showMedien;
}