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

 



class TabRaumDetailsKurse extends TabPageDefault
{
  protected $_sightId;
  
  protected $_kursIdAry4User;
  private $_setLink2OtherTool;
  
  private $_tabsAry;

  public function __construct($pTabName, $pData, $pSightId, $pTabsAry, $pKursIdAry4User = array(), $pSetLink2OtherTool = false)
  {
    parent::__construct($pTabName, $pData);
    $this->_sightId = $pSightId;
    $this->_kursIdAry4User = $pKursIdAry4User;
    $this->_setLink2OtherTool = $pSetLink2OtherTool;
    $this->_tabsAry = $pTabsAry;
    $this->setScroll(true);
  }

  
  public function _getContent()
  {
    if (isset($this->links['kursdetails']) && isset($this->links['kursdetails']) != '') {
      $linkKursdetails = $this->links['kursdetails'];
    } else {
      $linkKursdetails = '';
    }

    
    $vondatDefault = DateTimeOperations::getFirstDayOfCurrentWeek();
    $bisdatDefault = DateTimeOperations::getNextDate($vondatDefault, 6);

    
    $toolId = ToolsAPI::getCurrentToolId();
    $von_datum = SessionOperations::getVarValueWTIntern('KursDatumVon_' . $toolId, $vondatDefault);
    $bis_datum = SessionOperations::getVarValueWTIntern('KursDatumBis_' . $toolId, $bisdatDefault);

    $result = '<div id="kurse_table_div">';
    $result .= $this->getKursDetailsTable($linkKursdetails, $von_datum, $bis_datum);
    $result .= '</div>';

    
    if (isset($this->links['filter']) && $this->links['filter']) {
      $result .= '<div id="filter_kursezeitraum" >';
      $result .= '<label for="raumkurse_von_dat">Zeitraum vom: </label> ';
      $result .= '<input id="raumkurse_von_dat" class="hasDatePicker" name="von_dat" value="' . CleanOperations::cleanDateString($von_datum, '') . '">';
      $result .= '<label for="raumkurse_bis_dat">bis: </label>';
      $result .= '<input id="raumkurse_bis_dat" class="hasDatePicker" name="bis_dat" value="' . CleanOperations::cleanDateString($bis_datum, '') . '">';

      $result .= '<img src="layout/button_hinterlegung.gif" id="raumkurse_zeitbereich" title="Zeitbereich setzen" alt="Zeitbereich setzen" height="24" width="24">';

      $result .= '<span id="raumkurse_ControlSpan">' . "\n";
      $result .= '   <a id="filter_button_kurse" href="#"  title="Filter setzen"><img src="layout/button_filter_uebernehmen.gif" title="Filter setzen" alt="Filter setzen"></a>' . "\n";
      $result .= '</span>';

      $result .= '</div>';
    }

    
    if (isset($this->links['druckkurse']) && $this->links['druckkurse']) {
      $result .= '<a href="' . CleanOperations::cleanStringForHtml($this->links['druckkurse']) . '" id="raumdetails_kurseLinkDruck" title="Kurse drucken">'
                  . '<img src="layout/button_druck_small.gif" id="raumdetails_kurseImgDruck" alt="Kurse drucken"></a>' . "\n";
    }


    
    $result .= '<div class="zeilen4inhalt kurse">';
    $result .= '<ul>' . "\n"
                 . '<li>';
    $result .= HTMLOperations::CreateInputTag('raumkurse_zeilenauswahl', 'radio', 'raumkurse_einzeilig', 'raumkurse_zeilenauswahl', 'einezeile', '', false);
    $result .= 'einzeilig' . "\n"
                 . '</li>' . "\n"
                 . '<li>' . "\n";
    $result .= HTMLOperations::CreateInputTag('raumkurse_zeilenauswahl', 'radio', 'raumkurse_mehrzeilig', 'raumkurse_zeilenauswahl', 'mehrzeilen', '', true);
    $result .= 'mehrzeilig' . '
                  </li>' . "\n"
                 . '</ul>' . "\n";
    $result .= '</div>';

    return $result;
  }

  
  public function getKursDetailsTable($pLinkKursdetails = '', $pVonDat = '', $pBisDat = '')
  {
    $sicht = new KurseRaum4SightTab($this->_kursIdAry4User, false, $pLinkKursdetails, $this->_setLink2OtherTool, $this->_tabsAry);
    $sicht->tableId = 'tab_kurse';
    $sicht->tableClass = 'tab_kurse';
    $sicht->dbwkurse->newSearch();

    
    $sicht->dbwkurse->toobject->beginn_dat = $pBisDat;
    $sicht->dbwkurse->toobject->ende_dat = $pVonDat;

    $sicht->raumnr = $this->_data;
    $sicht->sightid = $this->_sightId;
    $sicht->userid = SessionOperations::getCurrentWebToolsUser()->id;
    $sicht->createSight();

    return $sicht->sight;
  }

  
  public function getSpecialJS()
  {
    return array('../jquery/plugins/jquery.dataTables.min.js',
                 'js/raumdetails.js');
  }

  
  public function getSpecialCSS()
  {
    return array('css/raumdetails.css');
  }

  
  public function getJSDeclarations()
  {
    $result = parent::getJSDeclarations();
    
    $result .= JsOperations::getDeclarationInt('KuferTools.RaumKurseSectionId', $this->_sightId);

    return $result;
  }
}