<?php

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

namespace Kufer\Webbasys\Includee\Pdf;


class KwPdfTermine implements KwPdfContent
{
  private $urlParam;

  
  public function setParams($pUrlparameter)
  {
    $this->urlParam = $pUrlparameter;
  }

  
  public function getContentTitle()
  {
    return 'Termine f&uuml;r Kurs ' . $this->urlParam->knr;
  }

  
  public function getStyleInfo()
  {
    return
            'td, tr { width: 170px; } td { padding-top: 20px; } hr { margin-top: 15px; }';
  }

  
  public function getContent()
  {
    $dmbasis = new \DataMenuBasis($this->urlParam);
    $dmbasis->getsight(543);
    $dmbasis->exportadapter = new \ExpKurse();

    $dbwkurstage = new \DBWorkKurseTageWB();

    $knr = $this->urlParam->knr;

    $kurstage = $dbwkurstage->getKurstagebyKursNROnlyDifferentLimit(\StringOperations::getfilledStr($knr, '-1'), null);
    $dmbasis->setExportSightInfo('ispdf', 1);

    $kurs = \WBKursStore::getKurs($knr);
    if (count($kurstage) === 0) {
      $dmbasis->dataarraynodata = array($kurs);
      $result = $dmbasis->getnodata();
    } else {
      $dmbasis->dataarrayheader = $dmbasis->dataarrayfooter = array($kurs);
      $header = $dmbasis->getheader();
      $footer = $dmbasis->getfooter();
      $dmbasis->exportadapter = new \ExpKurstageOnlyDifferent();
      $dmbasis->dataarraybody = $kurstage;
      $body = $dmbasis->getbody();
      $result = $header . $body . $footer;
    }

    return $result;
  }

  
  public function getFileName()
  {
    return 'Kurstage_Kurs_' . $this->urlParam->knr . '.pdf';
  }
}