<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

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

class JournalPresenter extends \Kufer\Web\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(array $datamodulArray): bool
  {
    return count($datamodulArray) <= 1;
  }

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

    return $terminView->show();
  }
}