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

namespace Kufer\Web\KuferTools\Veranstalter\Anmeldung\DetailsDialog;

class DetailsDialogUseCase extends \Kufer\Web\KuferTools\Basis\UseCase\ToolUseCase
{
  public function __construct($request)
  {
    parent::__construct($request, new DetailsDialogResponse());
  }

  public static function getToolId()
  {
    return \ToolsAPI::TOOL_ANMELDUNGBUCHEN_VA;
  }

  public static function getToolSectionId()
  {
    return 634;
  }

  public function action()
  {
    $dbwFreiFeld = new \DBWorkFreiWaehlbareEingabefelder4Belegung(1, true);
    $freiWaehlbareFelder = $dbwFreiFeld->getFreiWaehlbareFelder();

    return $this->getResponse($freiWaehlbareFelder);
  }

  protected function getResponse($freiWaehlbareFelder)
  {
    $this->response->freiWaehlbareFelder = $freiWaehlbareFelder;
    $this->response->readonly = $this->isFormReadonly();

    return $this->response;
  }

  private function isFormReadonly()
  {
    return \SessionOperations::getVarValueWTIntern('AnmeldungReadonly_' . $this->getToolId()) == 1;
  }
}

class DetailsDialogRequest
{
}

class DetailsDialogResponse extends \Kufer\Web\KuferTools\Basis\UseCase\ToolResponse
{
  public $freiWaehlbareFelder;
}