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

  

class PageDozKursplanungUebersicht extends BrowseableObjectsPageBaseWT
{
  private $_data;
  private $_searchkurs;
  private $_vonDate;
  private $_bisDate;

  public function __construct($pTool, $pData, $pVonDate, $pBisDate, $pAnzahlAllerKurseDesDozenten, $pAnzahlKurseProSeite)
  {
    $sprachsettings = new SprachSettingsObject();

    parent::__construct($sprachsettings->Kurs['Singular']['Nominativ'] . 'planung', 9, $pTool, $pAnzahlAllerKurseDesDozenten, $pAnzahlKurseProSeite);
    $this->_data = $pData;
    $this->_vonDate = $pVonDate;
    $this->_bisDate = $pBisDate;
    $this->_searchkurs = ((GetOperations::getVarValue('searchkurs', false)) ? '&amp;searchkurs=1' : '');
  }

  
  public function getContentHeader()
  {
    $sprachsettings = new SprachSettingsObject();
    if ($this->_vonDate == '' || $this->_bisDate == '') {
      return $sprachsettings->KursZusammengesetzt['Singular']['Nominativ'] . 'planungen';
    } else {
      return $sprachsettings->KursZusammengesetzt['Singular']['Nominativ'] . 'planungen im Zeitraum von ' . $this->_vonDate . ' bis ' . $this->_bisDate;
    }
  }

  
  public function getContent()
  {
    $sprachsettings = new SprachSettingsObject();

    $menu = new Menu();
    $allowDetails = (isset($this->links['kursdetails']) && $this->links['kursdetails'] ? 2 : 0);
    $result = '';

    
    $searchAPI = new KurssuchAPIwSearch(false);
    $result .= $searchAPI->getSearchDiv($searchAPI->getKursSearchLink());

    $result .= '<div id="main_content">' . "\n";

    if (!(count($this->_data) == 0 && $this->allgSettings->buttonleite_position == BUTTONBAR_BOTH)
       && ($this->allgSettings->buttonleite_position == BUTTONBAR_TOP || $this->allgSettings->buttonleite_position == BUTTONBAR_BOTH)) {
      $result .= $this->_getMainButtons();
    }


    $counter = 0;
    if (count($this->_data) > 0) {
      foreach ($this->_data as $kurs) {
        $builder = new SightBuilderUebersicht($this->tool->getToolId(), 9, $kurs, true);
        $builder->weitereKlasseFuerSightDiv = 'termine';
        $evenClass = ($counter % 2 == 0) ? ' farbe_sicht_erstezeile' : '';
        $result .= '<div class="content_zeile' . $evenClass . '">';
        $result .= '<div class="steuerelemente">';

        $result .= $menu->getUserLink(
          '<img src="images/edit.gif" alt="Details bearbeiten" title="' . CleanOperations::cleanStringForHtml($sprachsettings->KursZusammengesetzt['Singular']['Nominativ']) . 'details bearbeiten">' . BR_WT,
          'usertools.php?tool_id=3&toolsection_id=11&nr=' . $kurs->id,
          $allowDetails,
          false,
          false,
          'details_link'
        );

        $result .= $menu->getUserLink(
          '<img src="images/kurstage.gif" alt="Termine" title="Termine">',
          'usertools.php?tool_id=3&toolsection_id=10&nr=' . $kurs->id . '&markerAction=loescheMarkierungen',
          $allowDetails,
          false
        );
        $result .= '</div>';
        $result .= $builder->buildSight();
        $result .= '</div>' . "\n";
        $counter++;
      }
    } else { 
      if ($this->_searchkurs == '') {
        $result .= $this->getNoDataMessageDefault(1);
      } else {
        $result .= $this->getNoDataMessageDefault(2);
      }
    }
    $result .= '</div>' . "\n";
    if ($this->allgSettings->buttonleite_position != BUTTONBAR_TOP) {
      $result .= $this->_getMainButtons();
    }

    return $result;
  }

  
  private function _getMainButtons()
  {
    $result = '';

    
    $showDiv = false;

    if (count($this->_data) > 0 || (isset($this->links['kursplanung']) && $this->links['kursplanung'] != '')) {
      $showDiv = true;
    }


    
    if ($showDiv) {
      $result .= '<div class="main_buttons doz">';
    }

    if (isset($this->links['kursplanung']) && $this->links['kursplanung'] != '') {
      $sprachSettings = new SprachSettingsObject();
      $result .= '<a href="' . CleanOperations::cleanStringForHtml($this->links['kursplanung']) . '" title="neuer ' . CleanOperations::cleanStringForHtml($sprachSettings->KursZusammengesetzt['Singular']['Nominativ']) . 'vorschlag">';
      $result .= '<img class="ButtonKursvorschlag" src="layout/button_kursvorschlag.gif" alt="neuer ' . CleanOperations::cleanStringForHtml($sprachSettings->KursZusammengesetzt['Singular']['Nominativ']) . 'vorschlag">';
      $result .= '</a>';
    }

    
    if (count($this->_data) > 0 || $this->_searchkurs != '') {
      if (isset($this->links['filter'])) {
        
        
        $imgText = '<img src="layout/button_search_small24.gif" title="Suchfilter" alt="Suchfilter">';
        $result .= $this->getLinkButton4JS($imgText, '', 'Suchfilter', $this->links['filter'], '#ui-dialog-title-kurssuche', false, 'smallmargin_right suchen_button');
      }
    }


    $result .= $this->getNavigaton();

    if ($showDiv) {
      $result .= "\n" . '</div>' . "\n";
    }

    return $result;
  }

  
  public function getSpecialCSS()
  {
    $cssAry = parent::getSpecialCss();
    $cssAry[] = './css/kursuebersicht.css';
    $cssAry[] = './css/doztool.css';

    return $cssAry;
  }

  public function getSpecialJS()
  {
    return parent::getSpecialJS();

    
    
    
  }

  public function getJSDeclarations()
  {
    $result = parent::getJSDeclarations();
    $result .= 'registerNamespace("KuferTools");';

    
    $result .= $this->getSelektorKursFelderToDetails();

    return $result;
  }
}