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




namespace Kufer\Web\KuferTools\Basis\KursUebersicht\Detailsreiter\Honorar\AddDozent;




abstract class NewDozentDialogUseCase extends \Kufer\KuferTools\Basis\UseCase\ToolUseCase
{
  public function __construct($request)
  {
    parent::__construct($request, new NewDozentDialogResponse());
  }

  abstract protected function getReiterHonorarId(): int;

  abstract protected function getReiterDozentenId(): int;

  public function hasAccess($pToolSectionId = null)
  {
    if (!parent::hasAccess()) {
      return false;
    }
    if (!$this->isRechtAllowed($this->getReiterHonorarId() . '.0.6') && !$this->isRechtAllowed($this->getReiterDozentenId() . '.0.4')) {
      return false;
    }

    return true;
  }

  private function getKurs($knr)
  {
    $dbwKurse = new \DBWorkKurseWT(1, true);

    return $dbwKurse->getKurs($knr);
  }

  public function action()
  {
    
    $kurs = $this->getKurs($this->request->knr);
    $dbwDoz = new \DBWorkDozenten();
    $dozent = $dbwDoz->getNewObject();
    $dozent->gebdat = ''; 

    return $this->getResponse($dozent, $kurs);
  }

  protected function getResponse($pDozent, $pKurs)
  {
    
    $this->handleResponseStrategies();
    $this->response->dozent = $pDozent;
    $this->response->kurs = $pKurs;

    return $this->response;
  }

  protected function getResponseStrategies()
  {
    return array(new \Kufer\KuferTools\Utils\ResponseStrategies\ResponseWss($this));
  }
}

class NewDozentDialogRequest
{
  public $knr;
}

class NewDozentDialogResponse extends \Kufer\KuferTools\Basis\UseCase\ToolResponse
{
  public $dozent;
  public $kurs;
  public $columns;
}