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

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

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

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

  
  protected function getAjaxObject($pView): \stdClass
  {
    $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(): string
  {
    return '';
  }
}