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

namespace Kufer\KuferTools\Veranstalter\DozentenInfo\Detailsreiter\Kurse\PdfListen\GrafikListen\ShowSettingsGrafikListen;


class ShowSettingsGrafikListenUseCase extends \Kufer\KuferTools\Veranstalter\DozentenInfo\Detailsreiter\Kurse\PdfListen\DruckListen\ShowSettingsDruckListen\ShowSettingsDruckListenUseCase
{
  
  protected function _getListSettingsResponseObj()
  {
    return new ShowSettingsGrafikListenResponse();
  }

  public static function getToolSectionId()
  {
    return 663;
  }

  
  protected function _getPdfDrucklistenObj()
  {
    $userId = $this->getUser()->getIdentifier();

    return new \Kufer\KuferTools\Basis\PdfListen\GrafikPdfListen(self::getToolId(), self::getToolSectionId(), $userId);
  }

  
  protected function getResponse($pDataModulList, $pGenerateList, $pKursNrStr, $pListObj)
  {
    
    

    $this->response = parent::getResponse($pDataModulList, $pGenerateList, $pKursNrStr, $pListObj);

    $this->response->show_endbemerkung = $this->showEndBemerkung();

    $this->getZeitBereich4Response($pListObj);
    
    $this->getWochenplan4Response($pListObj);
    
    $this->getMonatsplan4Response($pListObj);

    return $this->response;
  }

  

  
  protected function canShowKurstageFields()
  {
    return $this->response->name === 'Doz1grafik' || $this->response->name === 'Doz2grafik';
  }

  
  protected function canShowWochenplan()
  {
    return $this->response->name === 'Wochenplangrafik' || $this->response->name === 'Stundeplangrafik'
            || $this->response->name === 'Schuelerstundplangrafik';
  }

  protected function canShowZeitpunkte()
  {
    return $this->response->name === 'Wochenplangrafik';
  }

  protected function showEndBemerkung()
  {
    if ($this->response->name === 'Wochenplangrafik' || $this->response->name === 'Monatsplangrafik' || $this->response->name === 'Stundeplangrafik'
            || $this->response->name === 'Schuelerstundplangrafik') {
      return false;
    }

    return true;
  }

  
  protected function canShowMonatsplan()
  {
    return $this->response->name === 'Monatsplangrafik';
  }

  
  protected function getZeitBereich4Response($pListObj)
  {
    $this->response->useZeitbereich = false;
    $this->response->useZeitspanne = false;
    $this->response->zeitspanneOptions = '';

    if ($this->canShowKurstageFields()) {

      
      
      $this->response->useZeitbereich = true;
      
      $this->response->zeitbereichVon = $pListObj->settings->zeitbereich->zeitvon;
      $this->response->zeitbereichBis = $pListObj->settings->zeitbereich->zeitbis;

      
      
      
      



      
      if ($this->response->name === 'Doz1grafik') {
        $this->response->useZeitspanne = true;
        $this->response->zeitbereichSpanne = $pListObj->settings->zeitbereich->zeitspanne;
        
      }
    } 
  }

  

  
  protected function getWochenplan4Response($pListObj)
  {
    $this->response->useWochenplan = false;
    $this->response->useZeitpunkte = false;
    
    if ($this->canShowWochenplan()) {
      
      
      $this->response->useWochenplan = true;
      
      $this->response->kalwoMonat = $pListObj->settings->kalenderwoche->kwmonat;
      $this->response->kalwoJahr = $pListObj->settings->kalenderwoche->kwjahr;
      $this->response->kalwoNr = $pListObj->settings->kalenderwoche->kwnr;

      
      $datary = \KalenderwochenAPI::getKalenderWochebyNr($this->response->kalwoJahr, $this->response->kalwoNr);
      $this->response->datVon = $datary['Mo'];
      $this->response->datBis = $datary['So'];


      
      if ($this->canShowZeitpunkte()) {
        $this->response->useZeitpunkte = true;
        
        
        $this->response->zeitpunkte = $pListObj->settings->zeitpunkte;
      } 
    } 
  }

  

  
  protected function getMonatsplan4Response($pListObj)
  {
    $this->response->useMonatsplan = false;

    if ($this->canShowMonatsplan()) {
      $this->response->useMonatsplan = true;
      
      
      $this->response->kalwoMonat = $pListObj->settings->kalenderwoche->kwmonat;
      $this->response->kalwoJahr = $pListObj->settings->kalenderwoche->kwjahr;

      $this->response->kalwoNr = $pListObj->settings->kalenderwoche->kwnr;

      
      
      $this->response->kursTageVon = $pListObj->kurstage->von;
      $this->response->kursTageBis = $pListObj->kurstage->bis;
      
      
      
      
      $this->response->auswahl = $pListObj->settings->kalenderwoche->auswahl;
    } 
  }

  
} 


class ShowSettingsGrafikListenResponse extends \Kufer\KuferTools\Veranstalter\DozentenInfo\Detailsreiter\Kurse\PdfListen\DruckListen\ShowSettingsDruckListen\ShowSettingsDruckListenResponse
{
  public $useZeitbereich;
  public $useZeitspanne;
  
  
  public $useWochenplan;
  public $useZeitpunkte;
  public $useMonatsplan;
  public $zeitbereichVon;
  public $zeitbereichBis;
  public $zeitbereichSpanne;
  
  public $kalwoMonat;
  public $kalwoJahr;
  public $kalwoNr;
  
  public $datVon;
  public $datBis;
  
  public $zeitpunkte;
  
  
  public $auswahl;

  public $show_endbemerkung;
}