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

class DataMenuLoginMerkliste extends DataMenuMainTopLeft
{
  public function __construct($urlparameter)
  {
    parent::__construct($urlparameter);
    $this->exportadapter = new ExpKurse();
  }

  public function mainmenu()
  {
    $this->prepareMainmenu();
    if ($this->toolsettings->showClickpfad) {
      echo $this->getClickPath();
    }
    echo '<div class="hauptseite">' . "\n" . $this->getContentAnker();
    $this->statusmenu();

    if (SessionOperations::isStammhoererLoggedIn()) {
      $mlapi = new MerklisteAPI();
      if ($mlapi->countMerklisteNurAnzuzeigendeKurse(SessionOperations::getCurrentStammhoererTnr()) > 0) {

        $this->showheader();
        $this->showbody();
        $this->showfooter();
      } else {
        $this->shownodata();
      }
    } else { 
      $this->shownocolumn();
    }
    echo "</div>\n\n";
  }

  

  public function getsight($pSightId = 503)
  {
    parent::getsight($pSightId);
  }

  public function getAnzahlBodyElements()
  {
    $dbwml = new DBWorkWebMerkliste();
    $mlkurse = $dbwml->getWebMerklisteByTnr(SessionOperations::getCurrentStammhoererTnr());

    return count($mlkurse);
  }

  public function getdataarraybody()
  {
    $dbwml = new DBWorkWebMerkliste();
    $mlapi = new MerklisteAPI();
    $dbwml->orderby = $this->urlparameter->orderby;
    $dbwml->orderbyasc = $this->urlparameter->orderbyasc;
    $dbwml->setOrderByValues($this->urlparameter);
    $mlkurse = $dbwml->getWebMerklisteByTnr(SessionOperations::getCurrentStammhoererTnr());
    $dbwkurse = new DBWorkKurse();
    $this->dataarraybody = array();
    for ($i = 0;$i < count($mlkurse);$i++) {  
      if ($mlapi->isAufMerklisteNurAnzuzeigendeKurse($mlkurse[$i]->knr)) {
        array_push($this->dataarraybody, $dbwkurse->getKurs($mlkurse[$i]->knr));
      }
    }
  }

  public function _getClickPath($pName = 'Teilnehmer-Login - Merkliste')
  {
    $this->_setStdClickPath($pName, 'clickKundenLoginMerkliste');

    return $this->clickpfad;
  }
}