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

namespace Kufer\KuferTools\Firma\KursUebersicht\KursUebersicht\Detailsreiter\Journal;

class JournalPresenter extends \Kufer\KuferTools\Basis\Presenter\Presenter
{
  protected function getView()
  {
    return new JournalReiterView($this->getViewModel());
  }

  protected function getViewModel()
  {
    $viewModel = new JournalReiterViewModel();
    $viewModel->summeSoll = $this->useCaseResponse->summeSoll;
    $viewModel->summeHaben = $this->useCaseResponse->summeHaben;
    $viewModel->nochOffen = $this->useCaseResponse->nochOffen;
    $viewModel->saldoNegative = $this->useCaseResponse->saldoNegative;
    $viewModel->filter = $this->useCaseResponse->filter;

    return $viewModel;
  }

  public function present()
  {
    
    $dbwZahlung = new \DBWorkZahlung();
    $emptyZahlung = $dbwZahlung->getNewObject();
    $journal = \array_merge(array($emptyZahlung), $this->useCaseResponse->journal);

    return $this->getAnderenContentAlsBody($journal);
  }

  protected function isDatamodulAryEmpty($datamodulArray)
  {
    return count($datamodulArray) <= 1;
  }

  protected function getAnderenContent($datamodul, $key)
  {
    $viewModel = new JournalViewModel();
    $viewModel->columns = $this->useCaseResponse->columns;
    $viewModel->journal = $datamodul;
    $viewModel->index = $key;
    $terminView = new JournalView($viewModel);

    return $terminView->show();
  }
}