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

namespace Kufer\Web\KuferTools\Basis\Kursdetails\TnZertifikat;

class TnZertifikatView extends \Kufer\Web\KuferTools\Basis\View\ViewSight
{
  public function getTemplatePathRelative()
  {
    return 'basis/kursdetails/tnzertifikat.sgt';
  }

  protected function getDefaultExportAdapter()
  {
    return new \ExpKurse(true);
  }

  protected function getDefaultDataModulArray()
  {
    $kurs = $this->viewModel->kurs;
    $kurs->referer = $this->viewModel->referer;
    $kurs->refererLabel = $this->viewModel->refererLabel;
    $kurs->toolId = $this->viewModel->toolId;
    $kurs->formstatus = $this->viewModel->status;
    $kurs->should_write = $this->viewModel->shouldWrite;

    return array($kurs);
  }

  protected function getBodyExportAdapter()
  {
    return new \ExpBelegung(true);
  }

  protected function getBodyDataModulArray()
  {
    return array_map(function($belegung) {
      $belegung->disabled = !$this->viewModel->isFormular;

      return $belegung;
    }, $this->viewModel->belegungen);
  }
}

class TnZertifikatViewModel
{
  public $toolId;
  public $isFormular;
  public $kurs;
  public $belegungen;
  public $referer;
  public $refererLabel;
  public $status;
  public $shouldWrite;
}