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

namespace Kufer\Web\KuferTools\Basis\Kursdetails\DetailsReiter\Dokumente\DokumenteUpload;

abstract class DokumenteUploadFormularPresenter extends \Kufer\KuferTools\Basis\Presenter\JsonPresenter
{
  
  public function present()
  {
    $view = $this->getView();

    return \JsonOperations::encode4Ajax($this->getAjaxObject($view));
  }

  
  protected function getAjaxObject($pView)
  {
    $result = new \stdClass();
    $result->inhalt = $pView->show(); 
    $result->title = 'Dokument zum Kurs hochladen';
    
    $result->jsdeclarations = $this->getJSDeclarations();

    return $result;
  }

  protected function getNewViewModel(): DokumenteUploadFormularViewModel
  {
    return new DokumenteUploadFormularViewModel();
  }

  protected function getViewModel()
  {
    $viewModel = $this->getNewViewModel();
    $viewModel->kurs = $this->useCaseResponse->kurs;
    $viewModel->toolId = $this->useCaseResponse->toolId;
    $viewModel->allowFirmen = $this->useCaseResponse->allowFirmen;
    $viewModel->allowFirmenDefaultValue = $this->useCaseResponse->allowFirmenDefaultValue;
    $viewModel->allowTeilnehmer = $this->useCaseResponse->allowTeilnehmer;
    $viewModel->allowTeilnehmerDefaultValue = $this->useCaseResponse->allowTeilnehmerDefaultValue;

    return $viewModel;
  }

  protected function getJSDeclarations()
  {
    return '';
  }
}