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

namespace Kufer\Web\KuferTools\Veranstalter\KursUebersicht\KursDetails\Feedback;

class SendFeedbackUseCase extends \Kufer\Web\KuferTools\Basis\KursDetails\Feedback\SendFeedbackUseCase
{
  public function hasAccess($pToolSectionId = null)
  {
    if (!parent::hasAccess()) {
      return false;
    } elseif (!$this->isRechtAllowed('632.0.3')) {
      return false;
    }

    return true;
  }

  public static function getToolSectionId()
  {
    return 632;
  }

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

  protected function getActionLink(): string
  {
    return 'kursdetails&knr=' . $this->getKursnummer();
  }

  protected function getKursnummer()
  {
    return $this->request->knr;
  }

  protected function getPerson(): \Personn
  {
    return $this->session->getCurrentWebToolsPerson();
  }

  protected function getCustomEmailEinrichtung(): ?string
  {
    $customEmail = $this->toolSettings->vhsEmailTool8Section377;
    if (trim($customEmail) === '') {
      return null;
    }

    return $customEmail;
  }

  protected function shouldSendToVerwaltendenMitarbeiter(): bool
  {
    return $this->toolSettings->feedbackBenachrichtigungsMailAnVerwMa ?? false;
  }

  protected function shouldSendToPlanendenMitarbeiter(): bool
  {
    return $this->toolSettings->feedbackBenachrichtigungsMailAnPlanMa ?? false;
  }

  protected function shouldSendToVerantwortendenMitarbeiter(): bool
  {
    return $this->toolSettings->feedbackBenachrichtigungsMailAnVerantwMa ?? false;
  }

  protected function shouldSendCopy(): bool
  {
    return $this->toolSettings->feedbackBenachrichtigungsMailAnVeranstalter ?? false;
  }
}

class SendFeedbackRequest extends \Kufer\Web\KuferTools\Basis\KursDetails\Feedback\SendFeedbackRequest
{
  public $knr;
}