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

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

abstract class GrafikRowView extends \Kufer\KuferTools\Basis\View\ViewSight
{
  protected function getDefaultDataModulArray()
  {
    return array($this->viewModel->index => $this->viewModel->daystep);
  }

  protected function getDefaultExportAdaper()
  {
    return new \ExpBasis(true);
  }

  protected function getBodyDataModulArray()
  {
    return \array_map(function($timestep) {
      $timestep->daystep = $this->viewModel->daystep;

      return $timestep;
    }, $this->viewModel->daystep->timesteps);
  }

  protected function getBodyExportAdapter()
  {
    return new class() extends \ExpBasis {
      public function __construct()
      {
        parent::__construct(true);
        $this->export = new class() extends \ExportBasis {
          public function getVarValue($varname)
          {
            switch ($this->getVarCategory($varname)) {
              default: parent::getVarValue($varname);
              
              case 'timestep_': return $this->exportresults[$this->actualset]->{$this->getVarName($varname)} ?? '';
              case 'grafik_': return $this->exportresults[$this->actualset]->daystep->{$this->getVarName($varname)} ?? '';
            }
          }
        };
      }
    };
  }
}

class GrafikRowViewModel
{
  public $daystep;
  public $index;
}