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

namespace Kufer\Web\KuferTools\Mitarbeiter\DozentenInfo\Detailsreiter\Kurse\vertragsformularpdf\VertragsformularDialog;

class VertragsformularDialogUseCase extends \Kufer\Web\KuferTools\Basis\UseCase\ToolUseCase
{
  protected $dbwKurse;
  protected $totalKursdata;

  public function __construct($request)
  {
    parent::__construct($request, new VertragsformularDialogResponse());
    $this->dbwKurse = new \DBWorkKurseWT();
  }

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

  public static function getToolSectionId()
  {
    return 399;
  }

  protected function getMainReiterId()
  {
    return 397;
  }

  public function hasAccess($pToolSectionId = null)
  {
    if (!parent::hasAccess($this->getMainReiterId())) {
      return false;
    }
    if (!$this->isRechtAllowed($this->getMainReiterId() . '.1.3')) {
      return false;
    }

    if (!\DBWorkBASysSettings::isDonnersbergkreisVhs()) {
      return false;
    }

    return true;
  }

  public function action()
  {
    $this->response->dnr = $this->request->dnr;
    $this->response->knr = $this->request->knr;
    $kurs = $this->dbwKurse->getKurs($this->request->knr);
    $this->response->semester = $kurs->semester;
    $this->response->honorarbetrag = '0';

    return $this->response;
  }
}

class VertragsformularDialogRequest
{
  public $dnr;
  public $knr;
}

class VertragsformularDialogResponse extends \Kufer\Web\KuferTools\Basis\UseCase\ToolResponse
{
  public $honorarbetrag;
  public $semester;
  public $dnr;
  public $knr;
}