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

namespace Kufer\KuferTools\Veranstalter\KursUebersicht\Detailsreiter\Honorar;

class HonorarPresenter 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 HonorarViewModel();
    $viewModel->columns = $this->useCaseResponse->columns;
    
    $viewModel->dozHonorar = $datamodul;
    $viewModel->index = $key;
    $viewModel->showCheckbox = $this->useCaseResponse->markierenButtons;
    $honorarView = new HonorarView($viewModel);

    return $honorarView->show();
  }

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

  protected function getViewModel()
  {
    $viewModel = new HonorarReiterViewModel();
    $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, 'honorar_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', $this->useCaseResponse->newDozentAllow ? true : false);

    return $result;
  }

  
  
  
  
}