<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Basis\PdfListen;


class DruckPdfListen
{
  
  protected $toolId;

  
  protected $userId;

  
  protected $toolSectionID;

  
  public function __construct($pToolId, $pToolsectionId, \Kufer\Web\Classes\Identifier\Identifier $pUserId)
  {
    $this->toolId = $pToolId;
    $this->toolSectionID = $pToolsectionId;
    $this->userId = $pUserId;
  }

  

  
  public function getListAry()
  {
    
    $sprachSettings = \SettingsFactory::getSettings(\SprachSettingsObject::class);

    $kursdatenlisteText = 'Liste Ihrer ' . $sprachSettings->Kurs['Plural']['Genitiv'];
    $kurstagelisteText = 'Liste Ihrer ' . $sprachSettings->Kurstag['Plural']['Genitiv'];

    if ($this->toolId == \ToolsAPI::TOOL_DOZENTENINFO_MA) {
      $kursdatenlisteText = 'Liste der ' . $sprachSettings->Kurs['Plural']['Genitiv'];
      $kurstagelisteText = 'Liste der ' . $sprachSettings->Kurstag['Plural']['Genitiv'];
    }

    return array(
      'Kursdatenliste' => $kursdatenlisteText,
      'Kurstageliste' => $kurstagelisteText,
      'Einsatzplanliste' => 'Einsatzplan',
      'Kursstammblattliste' => $sprachSettings->Kurs['Singular']['Nominativ'] . 'stammblätter',
      'Lehrplanliste' => 'Lehrplanliste',
      'Lehrplantabelle' => 'Lehrplantabelle',
      'Stundennachweis' => 'Stundennachweis'
    );
  }

  

  
  public function getListenrechte($pListe)
  {
    $druckallowed = false;
    $einstellallowed = false;
    $infoallowed = false; 
    
    $sectID = $this->toolSectionID;
    switch ($pListe) {
      case 'Kursdatenliste':
        $druckallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.2') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.3') > 1;
        $infoallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.2') > 1;
        break;
      case 'Kurstageliste':
        $druckallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.4') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.5') > 1;
        $infoallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.3') > 1;
        break;
      case 'Einsatzplanliste':
        $druckallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.6') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.7') > 1;
        $infoallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.4') > 1;
        break;
      case 'Kursstammblattliste':
        $druckallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.8') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.9') > 1;
        $infoallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.5') > 1;
        break;
      case 'Lehrplanliste':
        $druckallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.10') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.11') > 1;
        $infoallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.6') > 1;
        break;
      case 'Lehrplantabelle':
        $druckallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.12') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.13') > 1;
        $infoallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.6') > 1;
        break;
      case 'Stundennachweis':
        $druckallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.14') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.15') > 1;
        $infoallowed = \SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.6') > 1;
        break;
    }
    
    if (\SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.0.1') <= 1) {
      $einstellallowed = false;
    }
    
    if (\SecurityOperations::privilegAllowed($this->userId, $this->toolId, $sectID . '.2.1') <= 1) {
      $infoallowed = false;
    }

    return array('druck' => $druckallowed, 'einstell' => $einstellallowed, 'info' => $infoallowed);
  }

  
}