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

namespace Kufer\Web\KuferTools\Dozent\KursUebersicht\Detailsreiter\Termine\BerichtAbgeben\Dozenten;

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

  public static function getToolSectionId()
  {
    return 812;
  }

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

  private function getSuchFelder()
  {
    return  '<label for="tn_search_name">Name:</label> '
            . '<input id="tn_search_name" name="s_name" class="tn_search_name dataTableSearch form-control"> '
            . '<label for="tn_search_vorname">Vorname:</label> '
            . '<input id="tn_search_vorname" name="s_vorname" class="tn_search_vorname dataTableSearch form-control"> '
            . '<label for="tn_search_nr">Nr:</label> '
            . '<input id="tn_search_nr" name="s_doznr" size="4" class="tn_search_nr dataTableSearch form-control">';
  }

  
  private function getDozUebersichtDialog($pClass = 'tn_uebersicht_dialog')
  {
    $columns = $this->getColumns($this->toolSettings);
    $result = '<div class="' . \CleanOperations::cleanStringForHtml($pClass) . '">';
    $result
              .= '<div class="tn_search form-inline">'
              . $this->getSuchFelder()
              . '<span class="tn_search_start dataTableSearchButton"><button style="margin-right:5px; margin-left:10px;" type="button" class="btn btn-default collapse-button" title="suchen" >'
       . '<i class="fa fa-search" aria-hidden="true"></i>'
              . '</button></span>'
              . '<span class="tn_search_back dataTablePrevious"><button style="margin-right:5px;" type="button" class="btn btn-default collapse-button" title="vorherig" >'
       . '<i class="fa fa-arrow-left" aria-hidden="true"></i>'
              . '</button></span>'
              . '<span class="tn_search_vor dataTableNext"><button type="button" class="btn btn-default collapse-button" title="nächste" >'
       . '<i class="fa fa-arrow-right" aria-hidden="true"></i>'
              . '</button></span>'
              . '</div>';
    $result .= '<table class="dataTable_dozUebersicht display"><thead><tr>';
    $result .= '<th width="20px"></th>'; 
    foreach ($columns as $column) {
      $result .= '<th width="' . \CleanOperations::cleanInt($column->width) . '">' . \CleanOperations::cleanStringForHtml($column->title) . '</th>';
    }
    $columnsCount = count($columns);
    $result .= '</tr></thead><tbody><tr><td colspan="' . $columnsCount . '">Daten werden geladen</td></tr></tbody></table></div>';

    return $result;
  }

  private function getClassName()
  {
    return 'tn_uebersicht_dialog';
    
  }

  public function action()
  {
    $class = $this->getClassName();
    $dialog = $this->getDozUebersichtDialog($class);

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

  protected function getResponse($dialog)
  {
    $this->response->dialog = $dialog;

    return $this->response;
  }
}