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


namespace Kufer\KuferTools\Mitarbeiter\KursUebersicht\Detailsreiter\Honorar\DozentenHonorar;

use Kufer\KuferTools\Utils\DozKursHandler\DozKursUpdater as DozKursUpdater;




class DozHonorarAbsendenUseCase extends \Kufer\KuferTools\Mitarbeiter\KursUebersicht\Tool8UseCase
{
  public function __construct($request)
  {
    parent::__construct($request, new DozHonorarAbsendenResponse());
  }

  public static function getToolSectionId()
  {
    return 29; 
  }

  public function hasAccess($pToolSectionId = null)
  {
    if (!parent::hasAccess()) {
      
      return false;
    }
    
    elseif (!$this->request->isXsrfOk && !$this->request->isRefresh) {
      return false;
    }
    
    
    
    
    
    return true;
  }

  public function action()
  {
    $allgSettings = \AllgSettingsAPI::getAllgSettings();
    $dmzBetrieb = $this->session->isReplikat() && $allgSettings->dmzEnabled;
    

    $statusMessageContainer = null;

    
    $dozKursUpdateHandler = new DozKursUpdater($this->request, 'Honorar');
    $dozKursUpdateHandler->setDmzBetrieb($dmzBetrieb);

    
    if (!$this->request->isRefresh) {
      $dozKursUpdateHandler->doUpdate($this->request->dozHonId);
      $statusMessageContainer = $dozKursUpdateHandler->getStatusMessageContainer();
    }

    return $this->getResponse($statusMessageContainer);
  }

  protected function getResponse($pStatusMessageContainer)
  {
    $this->handleResponseStrategies();
    
    $this->response->statusMessageContainer = $pStatusMessageContainer;
    $this->response->dozHonId = $this->request->dozHonId;
    $this->response->knr = $this->request->knr;

    return $this->response;
  }

  protected function getResponseStrategies()
  {
    return array();
  }
} 

class DozHonorarAbsendenRequest
{
  public $isRefresh;
  public $isXsrfOk;
  public $dozHonId;
  public $knr;
  
  public $dozHonObj;
}

class DozHonorarAbsendenResponse extends \Kufer\KuferTools\Basis\UseCase\ToolResponse
{
  public $statusMessageContainer;
  public $dozHonId;
  public $knr;
}