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

namespace Kufer\KuferTools\Veranstalter\KursUebersichtAndererVeranstalter\KursDetails;

class KursDetailsPresenter extends \Kufer\KuferTools\Basis\Kursdetails\KursDetailsPresenter
{
  protected function getJsFilesSrcAryWeitere()
  {
    $js = parent::getJsFilesSrcAryWeitere();
    $js[] = $this->getJsFileFromSys('doz_kursplanung.js');
    $js[] = $this->getJsFileFromOldTools('medienhandler.js');
    $js[] = $this->getJsFileFromSys('nachlass.js');
    $js[] = $this->getJsFileFromSys('weitermelden.js');

    return $js;
  }

  protected function getJSDeclarations()
  {
    $result = parent::getJSDeclarations();
    $kurs = $this->useCaseResponse->kurs;
    $gebuehr = \APIGebuehren::getGebuehren($this->useCaseResponse->user->tnr, $kurs->id);
    $gebuehrErgaenzText = \StringOperations::htmlentities($kurs->gebuehrergaenztext, ENT_QUOTES);
    $toBeReplaced = array("\r\n", "\n\r", "\r", "\n");
    $gebuehrErgaenzText = trim(str_replace($toBeReplaced, ' ', $gebuehrErgaenzText));
    $result .= " registerNamespace('KuferTools.KursDetails.Kurs');\n"
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Knr', \StringOperations::htmlentities($kurs->id, ENT_QUOTES))
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Titel', \StringOperations::htmlentities($kurs->getVarValue('titel_zeile1'), ENT_QUOTES))
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Zeitraum', \StringOperations::htmlentities($kurs->getVarValue('beginn_ende_komplett'), ENT_QUOTES))
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Ort', \StringOperations::htmlentities($kurs->ort, ENT_QUOTES))
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Gebuehr', \StringOperations::htmlentities($gebuehr . ' ' . CURRENCY, ENT_QUOTES))
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.GebuehrenErgaenzText', $gebuehrErgaenzText)
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Folgekurs', \StringOperations::htmlentities($kurs->folgekurs, ENT_QUOTES));

    
    $result .= \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Zeitbeg', \StringOperations::htmlentities($kurs->beginn, ENT_QUOTES))
              . \JsOperations::getDeclarationString('KuferTools.KursDetails.Kurs.Zeitende', \StringOperations::htmlentities($kurs->ende, ENT_QUOTES))
              . \JsOperations::getDeclarationFloatMitKomma('KuferTools.KursDetails.Kurs.Ue', \StringOperations::htmlentities($kurs->stundenanz, ENT_QUOTES));

    return $result;
  }
}