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

namespace Kufer\Web\KuferTools\Dozent\KursUebersicht\Detailsreiter\Termine\TerminAbrechnen;

class SendAbrechnungController extends \Kufer\Web\KuferTools\Basis\Controller\ToolController
{
  protected function getUseCase(): \Kufer\Web\KuferTools\Basis\UseCase\UseCase
  {
    return new SendAbrechnungUseCase(
      $this->getRequestObj()
    );
  }

  protected function getRequestObj()
  {
    $requestObj = new SendAbrechnungRequest();
    $requestObj->knr = \GetOperations::getVarValue('knr');
    $ktids = \GetOperations::getVarValue('ktids');
    $requestObj->kursTagIds = explode(':', $ktids);
    $requestObj->kursTagIdsStr = $ktids;
    $requestObj = $this->getFormularValuesFromPost($requestObj);

    
    $action = \GetOperations::getVarValue('action');

    return $this->handleXsrf($requestObj, $action, $ktids);
  }

  private function getFormularValuesFromPost($pRequestObj)
  {
    $pRequestObj->abrechnung = \PostOperations::getVarValue('abrechnung');
    $pRequestObj->honorarSatz1 = \PostOperations::getVarValue('honsatz_1');
    $pRequestObj->honorarSatz2 = \PostOperations::getVarValue('honsatz_2');
    $pRequestObj->honorarSatz3 = \PostOperations::getVarValue('honsatz_3');
    $pRequestObj->stundenAnzahl1 = \PostOperations::getVarValue('stdanz_1');
    $pRequestObj->stundenAnzahl2 = \PostOperations::getVarValue('stdanz_2');
    $pRequestObj->stundenAnzahl3 = \PostOperations::getVarValue('stdanz_3');
    $pRequestObj->honorarBetrag1 = \PostOperations::getVarValue('honbetrag_1');
    $pRequestObj->honorarBetrag2 = \PostOperations::getVarValue('honbetrag_2');
    $pRequestObj->honorarBetrag3 = \PostOperations::getVarValue('honbetrag_3');
    $pRequestObj->honorarGesamt = \PostOperations::getVarValue('hongesamt');
    $pRequestObj->iban = \PostOperations::getVarValue('iban');
    $pRequestObj->bic = \PostOperations::getVarValue('bic');
    $pRequestObj->bankbez = \PostOperations::getVarValue('bankbez');
    $pRequestObj->steuernr = \PostOperations::getVarValue('steuernr');
    $pRequestObj->bemerkung = \PostOperations::getVarValue('bemerkung');

    return $pRequestObj;
  }

  protected function getControllerToForward($pUseCaseResponse)
  {
    return new TerminAbrechnenNachAbsendenController($pUseCaseResponse);
  }

  protected function getPresenter($pUseCaseResponse)
  {
    return null;
  }
}