<?php

namespace Kufer\Web\KuferTools\Dozent\HonorarBfi\Honorardruck;

class HonorardruckUseCase extends \Kufer\Web\KuferTools\Basis\UseCase\ToolUseCase
{
  public function __construct($request)
  {
    parent::__construct($request, new HonorardruckResponse());
  }

  public static function getToolSectionId()
  {
    return 487;
  }

  public function hasAccess($pToolSectionId = null)
  {
    if (!parent::hasAccess()) {
      return false;
    }

    
    

    return true;
  }

  public function action()
  {
    $honorarDokument = $this->getHonorardokument();
    return $this->getResponse($honorarDokument);
  }

  protected function getHonorardokument()
  {
    $user = \SessionOperations::getCurrentWebToolsUser();
    try {
      return \DatDocAPI::getDeputatsHonorarAbrechnungenFromDmz4BFI($user->dnr, $this->request->monatAb, $this->request->zahlnummer);
    } catch (\Exception $e) {
      \Logger::logg('Fehler beim Druck der Honorarabrechnung: ' . $e->getMessage(), 200);

      return false;
    }
  }

  protected function getResponse($honorarDokument)
  {
    $this->handleResponseStrategies();

    $this->response->honorarDokument = $honorarDokument;

    return $this->response;
  }

  public static function getToolId()
  {
    return \ToolsAPI::TOOL_HONORAR_DOZ;
  }
}

class HonorardruckRequest
{
  public $monatAb;
  public $zahlnummer;
}

class HonorardruckResponse extends \Kufer\Web\KuferTools\Basis\UseCase\ToolResponse
{
  public $honorarDokument;
}