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

namespace Kufer\Web\KuferTools\Basis\KursUebersicht\Terminplan;

abstract class TerminplanUseCase extends \Kufer\Web\KuferTools\Basis\UseCase\ToolUseCase
{
  public function __construct($request, $response = null)
  {
    parent::__construct($request, $response ?? new TerminplanResponse());
  }

  protected function getKurse()
  {
    $dbwKurse = new \DBWorkKurseWT(1, true);

    return $dbwKurse->getKurseByKursnummern($this->request->belegIds);
  }

  protected function setzeZeitraum($pKurse)
  {
    
    if ($this->request->zeitbereich === 'ersterKurs') {
      $this->response->vonDat = $pKurse[0]->beginn_dat;
      $this->response->bisDat = $pKurse[0]->ende_dat;
    } else {
      $this->response->vonDat = \DateTimeOperations::getDateNow();
      $this->response->bisDat = \DateTimeOperations::addMonths($this->response->vonDat, 3);
    }
  }
}

class TerminplanRequest
{
  public $belegIds;
  public $ktIds;
  public $zeitbereich;
}

class TerminplanResponse extends \Kufer\Web\KuferTools\Basis\UseCase\ToolResponse
{
  public $belegIds;
  public $ktIds;
  public $vonDat;
  public $bisDat;
}