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

class HonorarDruckListen extends DruckListen
{
  
  private $_selIds4Zahlung;

  
  private $_hasAllNrAry;

  public function __construct(
    $pUrl,
    $pToolID,
    $pToolSectionID,
    $pChangeHL = false,
    $pUserMayOverrideHL = false,
    $pDozId = -1,
    $pSelIds4Zahlung = '',
    $pHasAllNrAry = false
  ) {
    parent::__construct($pUrl, $pToolID, $pToolSectionID, $pChangeHL, $pUserMayOverrideHL, $pDozId);
    
    $this->_selIds4Zahlung = $pSelIds4Zahlung;
    $this->_hasAllNrAry = $pHasAllNrAry;
    
  }

  
  protected function _getHiddenInput4Zahlung()
  {
    $hiddenStr = '';
    
    $selStr4Zahlung = implode(':', $this->_selIds4Zahlung);
    if ($selStr4Zahlung !== '') {
      $hiddenStr .= $this->htmlOperations->CreateInputTag('knr4Zahlung', 'hidden', '', '', $selStr4Zahlung);
    }

    return $hiddenStr;
  }

  
  protected function getUrlString4ZahlungsKnr()
  {
    $delimiter = ':';
    $urlpart4Zahlung = '';
    $selStr4Zahlung = implode($delimiter, $this->_selIds4Zahlung);
    if ($selStr4Zahlung !== '') {
      $urlpart4Zahlung = '&knr4Zahlung=' . $selStr4Zahlung;
    }

    return $urlpart4Zahlung;
  }

  
  protected function getUrlString4AllNrAry()
  {
    $delimiter = ',';
    $urlPart4AllNr = '';
    if ($this->_hasAllNrAry) {
      $selStr4Zahlung = implode($delimiter, $this->_selIds4Zahlung);
      if ($selStr4Zahlung !== '') {
        $urlPart4AllNr = '&allNrAry[]=' . $selStr4Zahlung;
      }
    }

    return $urlPart4AllNr;
  }

  
  public function getListAry()
  {
    $sprachsettings = new SprachSettingsObject();
    $honlisteText = 'Liste Ihrer ' . $sprachsettings->Kurs['Plural']['Nominativ'] . ' mit Honorarangaben';
    $faVorlageText = '&Uuml;bersicht Ihrer Honorare f&uuml;r das Finanzamt';
    if ($this->toolID == \ToolsAPI::TOOL_DOZENTENINFO_MA) {
      $honlisteText = 'Liste der ' . $sprachsettings->Kurs['Plural']['Nominativ'] . ' mit Honorarangaben';
      $faVorlageText = '&Uuml;bersicht der Honorare f&uuml;r das Finanzamt';
    }

    return array(
      'Honorarliste' => $honlisteText,
      'UebersichtHonorar' => 'Honorar&uuml;bersicht',
      'SummenHonorarjournal' => 'Honorarjournal (Summen)',
      'UebersichtHonorarjournal' => 'Honorarjournal (&Uuml;bersicht)',
      'GesamtHonorarjournal' => 'Honorarjournal (Gesamt)',
      
      'FinanzamtVorlage' => $faVorlageText,
      'Stundenabrechnung' => 'Stundenabrechnung',
      'Honorarabrechnung' => 'Honorarabrechnung');
  }

  
  public function getListenrechte($pListe)
  {
    $druckallowed = 0;
    $einstellallowed = 0;
    $infoallowed = 0; 
    
    switch ($pListe) {
      case 'Honorarliste':
        $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.2') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.3') > 1;
        $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.2') > 1;
        break;
      case 'UebersichtHonorar':
        $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.4') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.5') > 1;
        $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.3') > 1;
        break;
      case 'SummenHonorarjournal':
        $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.6') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.7') > 1;
        $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.4') > 1;
        break;
      case 'UebersichtHonorarjournal':
        $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.8') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.9') > 1;
        $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.5') > 1;
        break;
      case 'GesamtHonorarjournal':
        $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.10') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.11') > 1;
        $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.6') > 1;
        break;
      case 'FinanzamtVorlage':
        $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.12') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.13') > 1;
        $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.7') > 1;
        break;
      case 'Stundenabrechnung':
        $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.14') > 1;
        $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.15') > 1;
        $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.8') > 1;
        break;
      case 'Honorarabrechnung':
        $druckallowed = $einstellallowed = $infoallowed = false;
        if (DBWorkBASysSettings::isMemmingenVHS()) {
          $druckallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.16') > 1;
          $einstellallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.0.17') > 1;
          $infoallowed = \SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.9') > 1;
        }
        break;
    }
    if (\SecurityOperations::privilegAllowedCurrentUser($this->toolID, $this->toolSectionID . '.2.1') <= 1) {
      $infoallowed = 0;
    }

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

  
  public function _getFastHeader()
  {
    $sprachsettings = new SprachSettingsObject();
    $headertext = 'Listen mit Honorarinformationen';
    if ($this->toolID == \ToolsAPI::TOOL_DOZENTENINFO_MA) {
      $headertext .= ' ' . CleanOperations::cleanStringForHtml($sprachsettings->Dozent['Singular_mit_Artikel']['Genitiv']);
    }

    return '<h1>' . $headertext . ':</h1>';
  }

  protected function _getListFastClassName()
  {
    return 'honorar';
  }
}