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

namespace Kufer\KuferTools\Basis\Kursdetails\DetailsReiter\Termine\TermineSammelAenderung\HandleTermineSammelAenderung;

abstract class HandleTermineSammelAenderungController extends \Kufer\KuferTools\Basis\Controller\ToolController
{
  protected function getRequestObj()
  {
    $ktApi = new \KurstagAPI();
    $requestObj = new HandleTermineSammelAenderungRequest();
    $requestObj->knr = \GetOperations::getVarValue('knr');
    $requestObj->ktIds = explode(':', \GetOperations::getVarValue('ktIds'));
    $requestObj->changedFields = $ktApi->getChangedFieldsFromPost();
    $requestObj->change = $this->getChangeObjFromPost();

    $action = $this->getActionVal();

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

  protected function getChangeObjFromPost()
  {
    $change = new class() {
      public $date;
      public $bemerkung;
      public $kursort;
      public $ausfall;
      public $beginn;
      public $ende;
      public $pause;
      public $minuten;
      public $ue;
      public $dozent;
    };
    $change->date = \PostOperations::getVarValue('wt_kt_changeDate_val');
    $change->bemerkung = \PostOperations::getVarValue('wt_kt_changeBemerkung_val');
    $change->kursort = \PostOperations::getVarValue('wt_kt_changeKursort_val');
    $change->ausfall = \PostOperations::getVarValue('wt_kt_changeAusfall_val');
    $change->beginn = \PostOperations::getVarValue('wt_kt_changeBeginn_val', null);
    $change->ende = \PostOperations::getVarValue('wt_kt_changeEnde_val', null);
    $change->pause = \PostOperations::getVarValue('wt_kt_changePause_val', null);
    $change->minuten = \PostOperations::getVarValue('wt_kt_changeMinuten_val', null);
    $change->ue = \PostOperations::getVarValue('wt_kt_changeUe_val', null);

    return $change;
  }

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