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

namespace Kufer\Web\KuferTools\Mitarbeiter\RaumUebersicht;

use Kufer\Web\KuferTools\Basis\Kursdetails\Detailsreiter\MerkeReiter\MerkeReiterUseCase as MerkeReiterUseCase;
use Kufer\Web\KuferTools\Utils\FilterSettings\Kursorte\KursorteFilterSettingsHelper;

class RaumUebersichtUseCase extends \Kufer\Web\KuferTools\Basis\Raumbelegung\RaumUebersicht\RaumUebersichtUseCase
{
  public static function getToolId()
  {
    return \ToolsAPI::TOOL_RAUMBELEGUNG_MA;
  }

  public static function getToolSectionId()
  {
    return 415;
  }

  protected function createFilterSettings(): \Kufer\Web\KuferTools\Utils\FilterSettings\IFilterSettings
  {
    return KursorteFilterSettingsHelper::createMitarbeiterRaumUebersicht($this->getUser(), $this->toolSettings);
  }

  protected function getButtons(bool $showAllButtons = false): array
  {
    $buttons = array();
    $listId = $this->getHMDruckListPageId();
    $buttonFactory = new \Kufer\Web\KuferTools\Basis\Button\ButtonFactory();

    if ($this->isRechtAllowed($this->getToolSectionId() . '.0.2')) {
      $buttons[] = array($buttonFactory->getBelegungsplanButton(34));
    }
    if ($this->isRechtAllowed($this->getToolSectionId() . '.0.3') && \ToolsAPI::rechteOR(array($listId . '.0.2', $listId . '.0.4'), $this->getToolId())) {
      $buttons[] = array($buttonFactory->getHausmeisterPdfListenButton());
    }
    if ($this->isRechtAllowed($this->getToolSectionId() . '.0.6')) {
      $link = 'index.php?tool_id=' . $this->response->toolId . '&action=druckQuartalsUebersicht';
      $buttons[] = array($buttonFactory->getQuartalsUebersichtButton($link, 'Quartalsübersicht', 'quartalsuebersicht_raumuebersicht'));
    }
    if ($this->isRechtAllowed($this->getToolSectionId() . '.0.7')) {
      $buttons[] = array($buttonFactory->getStundenplanGrafikButton());
    }
    if ($this->checkboxNeeded() == 2) {
      $buttons[] = array($buttonFactory->getMarkierenButton());
    }
    if ($this->isRechtAllowed($this->getToolSectionId() . '.0.4')) {
      $buttonGruppeFilter = array();
      $buttonGruppeFilter[] = $buttonFactory->getFilterButton();
      if ($this->isFilterGesetzt()) {
        $buttonGruppeFilter[] = $buttonFactory->getFilterLeerenButton('leeren', 'reset_filter_button_raeume');
      }
      $buttons[] = $buttonGruppeFilter;
    }

    return $buttons;
  }

  protected function getHMDruckListPageId(): int
  {
    return 423;
  }

  protected function checkboxNeeded(): bool
  {
    $listId = $this->getHMDruckListPageId();

    return (($this->isRechtAllowed($this->getToolSectionId() . '.0.3') && \ToolsAPI::rechteOR(array($listId . '.0.2', $listId . '.0.4'), $this->getToolId()))
            && (\SecurityOperations::privilegAllowedCurrentUser($this->getToolId(), $this->getToolSectionId() . '.0.5')));
  }
}

class RaumUebersichtRequest extends \Kufer\Web\KuferTools\Basis\Raumbelegung\RaumUebersicht\RaumUebersichtRequest
{
}