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

namespace Kufer\KuferTools\Basis\Raumbelegung\Raumdetails;

abstract class RaumDetailsPresenter extends \Kufer\KuferTools\Basis\Presenter\MitRahmenPresenter
{
  abstract protected function getReiterView($pViewModel);

  protected function getButtonHtml()
  {
    $buttonleiste = new \Kufer\KuferTools\Basis\Button\Buttonleiste();

    return $buttonleiste->getHtmlButtonleiste($this->useCaseResponse->reiterButtons, 'raumdetails_buttons');
  }

  protected function getViewModel()
  {
    $viewModel = new RaumDetailsViewModel();
    $viewModel->kursort = $this->useCaseResponse->kursort;
    $viewModel->kursort->nextRaum = $this->useCaseResponse->nextRaum;
    $viewModel->kursort->previousRaum = $this->useCaseResponse->previousRaum;

    $viewModel->kursort->reiterButtons = $this->getButtonHtml();
    $viewModel->reiter = $this->getReiter();

    return $viewModel;
  }

  private function getReiter()
  {
    $viewModel = new ReiterViewModel();
    $viewModel->kursort = $this->useCaseResponse->kursort;
    $viewModel->reiter = $this->useCaseResponse->reiter;
    $view = $this->getReiterView($viewModel);

    return $view->show();
  }

  protected function getJSDeclarations()
  {
    $result = parent::getJSDeclarations();
    $result .= 'registerNamespace("KuferTools.Raumuebersicht");' . "\n";
    
    $result .= \JsOperations::getDeclarationString('KuferTools.OeffneReiter', $this->useCaseResponse->oeffneReiter);
    
    $result .= \JsOperations::getDeclarationString('KuferTools.ActionMerkeReiter', 'merkeRaumDetailsReiter');
    $result .= \JsOperations::getDeclarationInt('KuferTools.raumNr', $this->useCaseResponse->raumNr);
    $result .= \JsOperations::getDeclarationJson('KuferTools.Raumuebersicht.RaumartDialog', $this->useCaseResponse->hlRaumartDialog);

    return $result;
  }

  protected function getJsFilesSrcAryWeitere()
  {
    return array($this->getJsFileFromSys('kursdetails.js'),
        $this->getJsFileFromOldTools('pdfdruck.js'),
        $this->getJsFileFromSys('pdfdruck.js'),
        
        $this->getJsFileFromSys('hm_raumbelegung.js')
        );
  }
}