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

namespace Kufer\Web\Classes\Dbfilter;

use Kufer\Web\Classes\Identifier\Identifier;


class WunschtermineSQLFilter extends BasicSQLFilter
{
  protected function __construct()
  {
    parent::__construct();

    $this->registerDb('Id', 'id', static::TYPE_INTEGER);
    $this->registerDb('PersonId', 'nr', static::TYPE_INTEGER);
    $this->registerDb('Typ', 'typ', static::TYPE_STRING);
    $this->registerDb('DatumVon', 'datvon', static::TYPE_DATE);
    $this->registerDb('DatumBis', 'datbis', static::TYPE_DATE);
    $this->registerDb('DatumText', 'dattxt', static::TYPE_STRING);
    $this->registerDb('WochenTag', 'wotag', static::TYPE_WO_TAGE);
    $this->registerDb('ZeitBeginn', 'zeit_beg', static::TYPE_TIME_NO_DATETIME);
    $this->registerDb('ZeitEnde', 'zeit_ende', static::TYPE_TIME_NO_DATETIME);
    $this->registerDb('ZeitText', 'zeittxt', static::TYPE_STRING);
    $this->registerDb('Bemerkung', 'bemerkung', static::TYPE_STRING);
  }

  public function getTablePraeffix(): string
  {
    return 'wunschtermine';
  }

  
  public function equalsId($id): IFilter
  {
    $this->applyFilterCurrent(
      static::FILTER_OPTION_ID,
      SQLFilterUtils::filterEqualsIdInt('id', $id)
    );

    return $this;
  }

  
  public function inId(iterable $ids): IFilter
  {
    $this->applyFilterCurrent(
      static::FILTER_OPTION_ID,
      SQLFilterUtils::filterInIdInt('id', $ids)
    );

    return $this;
  }

  
  public function equalsDozent(Identifier $id): IFilter
  {
    assert(!$id->isIdEmpty());
    $this->equalsTyp('D');
    $this->equalsPersonId($id->getId());

    return $this;
  }
}