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

namespace Kufer\KuferTools\Basis\Kursdetails\DetailsReiter\Dozenten;

class DozentenPresenter extends \Kufer\KuferTools\Basis\Presenter\Presenter
{
  public function present()
  {
    
    
    $dbwDozHon = new \DBWorkDozentenHonorar();
    $emptyDozHon = $dbwDozHon->getNewObject();
    $dozHonorare = \array_merge(array($emptyDozHon), $this->useCaseResponse->honorare);

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

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

  protected function getAnderenContent($datamodul, $key)
  {
    $viewModel = new DozentenViewModel();
    $viewModel->columns = $this->useCaseResponse->columns;
    
    
    $viewModel->dozHonorar = $datamodul;
    $viewModel->index = $key;
    $viewModel->showCheckbox = $this->useCaseResponse->markierenButtons;
    $dozView = new DozentenView($viewModel);

    return $dozView->show();
  }

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

  protected function getViewModel()
  {
    $viewModel = new DozentenReiterViewModel();
    $viewModel->kurs = $this->useCaseResponse->kurs;
    $viewModel->kurs->toolId = $this->useCaseResponse->toolId;
    $viewModel->kurs->reiterButtons = $this->getButtonHtml();
    $viewModel->kurs->markierenButtons = $this->useCaseResponse->markierenButtons;

    $viewModel->jsdeclarations = $this->getJsDeclarations();

    return $viewModel;
  }

  protected function getButtonHtml()
  {
    $buttonleiste = new \Kufer\KuferTools\Basis\Button\Buttonleiste();

    return $buttonleiste->getHtmlButtonleiste($this->useCaseResponse->reiterButtons, 'dozenten_buttons');
  }

  
  protected function getJSDeclarations()
  {
    $result = 'registerNamespace("KuferTools.KursDetails.DozentDelete");' . "\n";
    
    
    $result .= \JsOperations::getDeclarationString('KuferTools.KursDetails.DozentDelete.Xsrf', $this->useCaseResponse->dozentDeleteXsrf);
    $result .= \JsOperations::getDeclarationBoolean('KuferTools.KursDetails.newDozentAllow', (bool)$this->useCaseResponse->newDozentAllow);
    $result .= \JsOperations::getDeclarationJson('KuferTools.KursDetails.DozKursIdZuDnrMapping', $this->useCaseResponse->dozKursIdZuDnrMapping);

    return $result;
  }
}