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

namespace Kufer\Web\KuferTools\Veranstalter\KursUebersicht\Detailsreiter\Teilnehmer\AbmeldenDialog;

use Kufer\Web\KuferTools\Basis\View\DetailsTabelleRowView;
use Kufer\Web\KuferTools\Basis\View\DetailsTabelleRowViewModel;

class AbmeldenDialogPresenter extends \Kufer\Web\KuferTools\Basis\Presenter\Presenter
{
  public function present()
  {
    
    $dbwBelegungen = new \DBWorkBelegung(1, true);
    $emptyBelegung = $dbwBelegungen->getNewObject();
    $belegungen = \array_merge(array($emptyBelegung), $this->useCaseResponse->belegungen);

    return $this->getAnderenContentAlsBody($belegungen);
  }

  protected function isDatamodulAryEmpty(array $datamodulArray): bool
  {
    
    return count($datamodulArray) <= 1;
  }

  protected function getAnderenContent($datamodul, $key): string
  {
    $isHeader = empty($datamodul->id);
    $viewDetailsModel = new KursRowViewModel();
    $viewDetailsModel->belegung = $datamodul;
    $viewDetails = new KursRowView($viewDetailsModel);

    $viewModel = new DetailsTabelleRowViewModel(
      $this->useCaseResponse->toolSection,
      $this->useCaseResponse->toolSettings,
      false,
      $isHeader,
      trim($viewDetails->getHeader()),
      $this->useCaseResponse->columns,
      $datamodul->id,
      $datamodul
    );

    $view = new DetailsTabelleRowView($viewModel);

    return $view->show();
  }

  protected function getView()
  {
    return new AbmeldenDialogView($this->getViewModel());
  }

  protected function getViewModel()
  {
    $viewModel = new AbmeldenDialogViewModel();
    $viewModel->kurs = $this->useCaseResponse->kurs;
    $viewModel->kurs->toolId = $this->useCaseResponse->toolId;

    return $viewModel;
  }
}