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

namespace Kufer\Web\KuferTools\Teilnehmer\BayerischerApothekertagEhrengaeste\Detailsreiter\Termine;

use Kufer\Web\KuferTools\Basis\UseCaseBuilder\SpecificToolSection;
use Kufer\Web\KuferTools\Basis\UseCaseBuilder\ToolSection;

class TermineUseCase extends \Kufer\Web\KuferTools\Basis\Kursdetails\Detailsreiter\Termine\TermineUseCase
{
  private $apotag;

  public function __construct($request)
  {
    parent::__construct($request);
    $this->apotag = new \Kufer\Web\KuferTools\Teilnehmer\BayerischerApothekertag\Utils\Apothekertag();
  }

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

  public static function getToolSectionId()
  {
    return 96;
  }

  protected function getMainReiterId()
  {
    return 337;
  }

  protected function getDatamodulHelper($kurs): \Kufer\Web\KuferTools\Utils\DatamodulHelper\KursTage\KurstageZuKurs
  {
    return new \Kufer\Web\KuferTools\Utils\DatamodulHelper\KursTage\TnKurstageZuKurs($this->toolSettings, $this->getUser(), $this->request, $kurs, null);
  }

  public function hasAccess($pToolSectionId = null)
  {
    return $this->apotag->isBATKurs($this->request->knr);
  }

  public static function getColumns(\ToolSettings $toolSettings, ?int $toolSectionId = null): array
  {
    
    $wssInFiles = new \Kufer\Web\KuferTools\Utils\WssInFiles();

    return $wssInFiles->getWss(
      new SpecificToolSection(static::getToolId(), $toolSectionId ?? static::getToolSectionId()),
      $toolSettings,
      static::getToolSectionId()
    );
  }

  protected function getButtons()
  {
    $buttonsObj = new \Kufer\Web\KuferTools\Basis\Kursdetails\Detailsreiter\TnTermineReiterButtons($this, $this->request, $this->response);
    $buttonsArray = $buttonsObj->getButtons();
    $selectionDependentButtons = array('Terminplan');
    $this->response->markierenButtons = $this->markierenButtonNotwendig($buttonsArray, $selectionDependentButtons);

    return $buttonsArray;
  }
}