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

namespace Kufer\KuferTools\Basis\PdfListen\PrintPdfListen;


abstract class PrintPdfListenBySettingsController extends PrintPdfListenController
{
  protected $listName;

  abstract protected function getToolId();

  protected function getRequestObj()
  {
    $requestObj = new PrintPdfListenBySettingsRequest();
    
    $requestObj->id = $this->getId(); 
    $requestObj->listName = \RequestOperations::getVarValue('liste', ''); 
    
    $this->listName = $requestObj->listName;

    
    
    $requestObj->dnr = \RequestOperations::getVarValue('dnr', \SessionOperations::getCurrentWebToolsUser()->dnr);
    
    

    
    $requestObj->postSettings = $this->_getPostSettings();

    return $requestObj;
  }

  protected function getPresenter($pUseCaseResponse)
  {
    return new PrintPdfListenBySettingsPresenter($pUseCaseResponse);
  }

  

  
  protected function _getPostSettings()
  {
    
    $settingsObj = $this->_getDruckSettingsObject();
    
    $settingsObj->title1 = '';
    if (\PostOperations::isDefined('ueberschrift')) {
      $settingsObj->title1 = \PostOperations::getVarValue('ueberschrift');
    }
    
    $settingsObj->title2 = '';
    if (\PostOperations::isDefined('subtitle')) {
      $settingsObj->title2 = \PostOperations::getVarValue('subtitle');
    }
    
    $settingsObj->endbem = '';
    if (\PostOperations::isDefined('endbemerkung')) {
      $settingsObj->endbem = \PostOperations::getVarValue('endbemerkung');
    }

    
    
    if (\PostOperations::isDefined('format')) {
      
      $settingsObj->druckbereich->hochformat = \PostOperations::getVarValue('format') == 'H';
    }

    
    $settingsObj->kurstage->von = \PostOperations::getVarValue('kt_von');
    $settingsObj->kurstage->bis = \PostOperations::getVarValue('kt_bis');

    if ($this->listName == 'Einsatzplanliste') {
      $settingsObj->einstellDarstellung = new \EinstellDarstellung();
      $settingsObj->einstellDarstellung->option1 = \PostOperations::isDefined('ausgefTage');
      $settingsObj->einstellDarstellung->option2 = \PostOperations::isDefined('ktstatus');
    }

    return $settingsObj;
  }

  

  protected function getId()
  {
    return \RequestOperations::getVarValue('nr');
  }

  
  abstract protected function _getDruckSettingsObject();
}