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

  if (!defined('BASEDIR')) {
    include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'constants.php';
  }



  if (session_id() === '') {
    SecurityOperations::setCookieDomainFromSettings();

    session_start();
  }

  function getWarenkorb()
  {
    ob_start();



    
    
    $urlparam = new URLParameterAnmeldungArt();
    if (isset($urlparam->kathaupt) && ($urlparam->kathaupt == 5)
        && isset($urlparam->anmart, $urlparam->schritt)) {
      switch ($urlparam->anmart) {
        case 1:
          if ($urlparam->schritt == 4) {
            $content = ob_get_contents();
            ob_end_clean();

            return '';
          }
          break;
        default: 
          if ($urlparam->schritt == 5) {
            $content = ob_get_contents();
            ob_end_clean();

            return '';
          }
          break;
      }
    }

    




    $dbwwarenkorb = new DBWorkWarenkorbKurseWB();
    $urlparam = new URLParameterWarenkorb();

    $rueckFrage = false;
    if (isset($urlparam->askWarenkorb) && $urlparam->askWarenkorb == true
       ) {
      $toolsettings = ToolSettingsAPI::getToolSettings(4);
      if (!(($toolsettings->addKurs2WarenkorbAction == ADDKURS2WARENKORBACTIONEMPTY)
          || $toolsettings->hotel)) {
        $urlparam = new URLParameterWKNachfrage();
        if ($dbwwarenkorb->EntryCount() > 0) {
          $rueckFrage = true;
        }
      }
    }


    
    if (isset($urlparam->warenkorbclear) && $urlparam->warenkorbclear == 'true') {
      WarenkorbAPI::clear();
    }
    
    if (isset($urlparam->knradd) && $urlparam->knradd != '') {
      WarenkorbAPI::add($urlparam->knradd);
    }
    
    if (isset($urlparam->knrdel) && $urlparam->knrdel != '') {
      WarenkorbAPI::del($urlparam->knrdel);
    }

    $warenkorb = $dbwwarenkorb->getEntries();

    $dmWarenkorbMenu = new DataMenuBasis(new URLParameterNavigation());

    if (!is_null($warenkorb) && count($warenkorb) > 0) {
      $ary = array();
      foreach ($warenkorb as $wEntry) {
        array_push($ary, $wEntry->kurs);
      }
      $dmWarenkorbMenu->dataarrayheader = array(new Datamodul());
      $dmWarenkorbMenu->dataarraybody = $ary;
      $dmWarenkorbMenu->dataarrayfooter = array(new Datamodul());
      $dmWarenkorbMenu->showsightcomplete(146, new ExpKursuebersicht());
    } else {
      $dmWarenkorbMenu->dataarraynodata = array(new Datamodul());
      $dmWarenkorbMenu->exportadapter = new ExpBasis();
      $dmWarenkorbMenu->getsight(146);
      $dmWarenkorbMenu->shownodata();
    }
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
  }