<?php

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

class DataMenuMatAusgUebersicht extends DataMenuMain
{
  
  public function __construct($urlparameter)
  {
    parent::__construct($urlparameter);
    $this->exportadapter = new ExpMatAusg();
    $this->dbwMat = DBWorkMatAusg::getDefaultInstance();
  }

  public function getsight($pSigthID = 720)
  {
    parent::getsight($pSigthID);
  }

  public function prepareMainmenu()
  {
    $alleIds = $this->dbwMat->getMaterialNrsAscDescByText($this->toolsettings->matAusgSortierrichtung);
    $seite = isset($this->urlparameter->seite) ? $this->urlparameter->seite : 1;
    $this->blaettern = new \Kufer\KuferTools\Utils\Blaettern($alleIds, $this->toolsettings->matAusgProSeite, $seite);

    $link = $this->urlparameter->copy();
    $link->seite = '';
    $link->implodeSettings();

    $blaetternLink = \Kufer\Web\Classes\Api\BlaetternAPI::getInstance()->convertBlaetternToBlaetternLink($this->blaettern, $link->stream);
    $this->exportadapter->setBlaetternInfo($blaetternLink);

    parent::prepareMainmenu();
  }

  public function _getClickPath($pName = 'Materialausgabe Übersicht')
  {
    if ($this->toolsettings->clickMaterialAusgabeUebersichtText != '') {
      $pName = $this->toolsettings->clickMaterialAusgabeUebersichtText;
    }

    DataMenuMain::_getClickPath();
    if ($this->toolsettings->titleKursBereich != '') {
      $this->clickpfad = '<span class="clickadresse"> ' . CleanOperations::cleanStringForHtml(stripslashes($this->toolsettings->titleKursBereich)) . ' </span>' . PHP_EOL;
      $this->clickpfad .= '<span class="trennzeichen"> ' . CleanOperations::cleanStringContainingHtml($this->toolsettings->trennzeichenKategorie) . ' </span>' . PHP_EOL;
    }
    $this->clickpfad .= '<span class="clickadrbold">' . CleanOperations::cleanStringForHtml($pName) . "</span>\n";

    return $this->clickpfad;
  }

  public function getdataarraybody()
  {
    $matOnCurrentPage = $this->blaettern->getItemsOnCurrentPage();
    $this->dataarraybody = $this->dbwMat->getMaterialienByIdsKeepOrder($matOnCurrentPage);
  }
}