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

namespace Kufer\Web\KuferTools\Dozent\Kursplanung\Raumplanung;

class KurstageAnlegenUseCase extends \Kufer\Web\KuferTools\Basis\Raumplanung\KurstageAnlegenUseCase
{
  public const SUCCESS_KURSTAGE_ANGELEGT = 'successKurstageAngelegt';
  public const INFO_KEINE_KURSTAGE_ANGELEGT = 'infoKeineKurstageAngelegt';
  public const ERROR_KURSTAGE_ANLEGEN_FEHLGESCHLAGEN = 'errorKurstageAnlegenFehlgeschlagen';
  public const ERROR_DOPPELT_ABSENDEN = 'DoppeltVersandt';

  public static function getToolSectionId()
  {
    return 10;
  }

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

  protected function isRaumplanungAllowed(): bool
  {
    return $this->isRechtAllowed('10.0.7');
  }

  protected function getResponse()
  {
    $this->response = parent::getResponse();
    $this->response->knr = $this->request->knr;
    if ($this->request->isRefresh) {
      $this->response->statusCode = self::ERROR_DOPPELT_ABSENDEN;
    }

    return $this->response;
  }

  protected function setStatusMeldungen($success)
  {
    if (is_null($success)) {
      $this->response->statusCode = self::INFO_KEINE_KURSTAGE_ANGELEGT;
    } elseif ($success) {
      $this->response->statusCode = self::SUCCESS_KURSTAGE_ANGELEGT;
    } else {
      $this->response->statusCode = self::ERROR_KURSTAGE_ANLEGEN_FEHLGESCHLAGEN;
    }
  }
}