<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Teilnehmer\Visitenkarten\NeueVisitenkarteErstellen;

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

  public static function getToolSectionId()
  {
    return 496;
  }

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

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

  protected function getResponse()
  {
    $this->handleResponseStrategies();
    $this->response->ueberschrift = $this->getUeberschrift();
    $buttonleiste = new \Kufer\Web\KuferTools\Basis\Button\Buttonleiste();
    $this->response->buttons = $buttonleiste->getHtmlButtonleiste($this->getButtons());
    $this->response->statusCode = $this->request->statusCode;
    $this->response->visitenkarte = $this->getVisitenkarte();

    return $this->response;
  }

  protected function getResponseStrategies()
  {
    return array(
      new \Kufer\Web\KuferTools\Utils\ResponseStrategies\ResponseMitRahmen($this),
      new \Kufer\Web\KuferTools\Utils\ResponseStrategies\ResponseWss($this),
      new \Kufer\Web\KuferTools\Utils\ResponseStrategies\ResponseWithToolSettings($this)
    );
  }

  protected function getUeberschrift()
  {
    return 'Neue Visitenkarte anlegen';
  }

  protected function getButtons()
  {
    $buttons = array();
    $buttonFactory = new \Kufer\Web\KuferTools\Basis\Button\ButtonFactory();
    $buttons[] = array($buttonFactory->getAutomatischAusfuellenVisitenkartenButton());
    $buttons[] = array($buttonFactory->getErstellteVisitenkarteAbsendenButton());
    $buttons[] = array($buttonFactory->getZurueckZurVisitenkartenUebersichtButton($this->getToolId()));

    return $buttons;
  }

  private function getDbwVisitenkartenWeb()
  {
    return \DBWorkVisitenkartenWeb::getDefaultInstance(1, true);
  }

  protected function getVisitenkarte()
  {
    $dbWorkVisitenkartenWeb = $this->getDbwVisitenkartenWeb();

    return $dbWorkVisitenkartenWeb->getNewObject();
  }
}

class NeueVisitenkarteErstellenRequest
{
  public $statusCode;
  public $visitenkarteId;
}

class NeueVisitenkarteErstellenResponse
{
  public $ueberschrift;
  public $visitenkarte;
  public $columns;
  public $buttons;
  public $statusCode;
}