<?php

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

namespace Kufer\KuferTools\Basis\KursUebersicht\Terminplan;

abstract class TerminplanUseCase extends \Kufer\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\KuferTools\Basis\UseCase\ToolResponse
{
  public $belegIds;
  public $ktIds;
  public $vonDat;
  public $bisDat;
}