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


namespace Kufer\Web\KuferTools\Basis\TeilnehmerInfo\UpdateTeilnehmer\HandleTeilnehmerUpdate;

abstract class HandleTeilnehmerUpdateController extends \Kufer\Web\KuferTools\Basis\Controller\ToolController
{
  protected function getRequestObj()
  {
    $requestObj = new HandleTeilnehmerUpdateRequest();
    $requestObj->tnr = \GetOperations::getVarValue('tnr', -1);
    $requestObj->tguid = \GetOperations::getVarValue('tguid', null);
    $wssHandler = new \Kufer\Web\KuferTools\Utils\WssHandler($this->getToolId(), $this->getToolSectionId(), $this->getUser());
    $requestObj->columnValues = $wssHandler->getColumnValuesFromPost();
    $requestObj->wssHandler = $wssHandler;

    $action = $this->getActionVal();

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

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

  abstract protected function getToolId();

  abstract protected function getToolSectionId();

  abstract protected function getUser();

  protected function getControllerToForward($pUseCaseResponse)
  {
    if ($pUseCaseResponse->tnr == -1) {
      header('Location: index.php?tool_id=' . $this->getToolId());
    } else {
      $guidPart = !is_null($pUseCaseResponse->tguid) ? '&tguid=' . $pUseCaseResponse->tguid : '';
      header('Location: index.php?tool_id=' . $this->getToolId() . '&action=teilnehmerdetails&tnr=' . $pUseCaseResponse->tnr . $guidPart);
    }

    die();
  }
}