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


namespace Kufer\Web\KuferTools\Mitarbeiter\KursUebersicht\Detailsreiter\Honorar\DozentenHonorar;

class DozHonorarDialogPresenter 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 = $this->getAjaxDialogTitle();

    return $result;
  }

  protected function getAjaxDialogTitle(): string
  {
    
    return 'Honorarvereinbarungen für ' . $this->useCaseResponse->dozhonorar->dozent->namevorname;
  }

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

  protected function getViewModel()
  {
    $viewModel = new DozHonorarDialogViewModel();
    $viewModel->dozhonorar = $this->useCaseResponse->dozhonorar;

    
    $viewModel->dozhonorar->keinhonorarChecked = '';
    $viewModel->dozhonorar->spesenprotnChecked = '';
    if ($viewModel->dozhonorar->keinhonorar) {
      $viewModel->dozhonorar->keinhonorarChecked = 'checked="checked"';
    }
    if ($viewModel->dozhonorar->spesenprotn) {
      $viewModel->dozhonorar->spesenprotnChecked = 'checked="checked"';
    }

    
    $viewModel->dozhonorar->hongesamt = $this->useCaseResponse->hongesamt;
    $viewModel->dozhonorar->fahrtgesamt = $this->useCaseResponse->fahrtgesamt;

    
    $viewModel->dozhonorar->fkstatuschecked_FKpauschal = '';
    $viewModel->dozhonorar->fkstatuschecked_FKnachkm = '';
    $viewModel->dozhonorar->fkstatuschecked_keineFK = '';
    if ($this->useCaseResponse->fkStatusChecked == 'keineFK') {
      $viewModel->dozhonorar->fkstatuschecked_keineFK = 'checked="checked"';
    }

    if ($this->useCaseResponse->fkStatusChecked == 'FKnachkm') {
      $viewModel->dozhonorar->fkstatuschecked_FKnachkm = 'checked="checked"';
    }
    if ($this->useCaseResponse->fkStatusChecked == 'FKpauschal') {
      $viewModel->dozhonorar->fkstatuschecked_FKpauschal = 'checked="checked"';
    }

    return $viewModel;
  }
}