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


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

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

    return $result;
  }

  protected function getAjaxDialogTitle()
  {
    
    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;
  }
}