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

namespace Kufer\Web\KuferTools\Utils\FilterSearch;

use Kufer\Web\KuferTools\Utils\FilterSearch\Method\BetweenTimeMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\ContainsStringMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\EqualsDateMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\EqualsIntMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\EqualsTimeMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\GreaterEqualsDateMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\GreaterGreaterEqualsDateMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\LessEqualsDateMethod;
use Kufer\Web\KuferTools\Utils\FilterSearch\Method\LessLessEqualsDateMethod;

class WunschtermineSearchFilter extends ToolSearchFilter
{
  public function __construct()
  {
    parent::__construct();

    $this->addSearch(
      'datum_von',
      new GreaterGreaterEqualsDateMethod('DatumBis', 'DatumVon')
    );
    $this->addAliasFor('DatumVon', 'datum_von');

    $this->addSearch(
      'datum_bis',
      new LessLessEqualsDateMethod('DatumBis', 'DatumVon')
    );
    $this->addAliasFor('DatumBis', 'datum_bis');

    $this->addSearch( 
      'zeit_von',
      new BetweenTimeMethod('ZeitBeginn', 'ZeitEnde')
    );
    $this->addAliasFor('UhrzeitVon', 'zeit_von');

    $this->addSearch( 
      'zeit_bis',
      new BetweenTimeMethod('ZeitBeginn', 'ZeitEnde')
    );
    $this->addAliasFor('UhrzeitBis', 'zeit_bis');

    $this->addSearch(
      'Bemerkung',
      new ContainsStringMethod('Bemerkung')
    );
  }

  public function createRequestKey(string $searchMapKey): string
  {
    return 'wunschtermine' . $searchMapKey;
  }
}