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

namespace Kufer\Web\Classes\Datamodul;

class TerminAnfrage extends \Datamodul
{
  
  public $wunschdatvon;
  
  public $wunschdatbis;
  
  public $wunschuhrvon;
  
  public $wunschuhrbis;
  
  public $wunschort;
  
  public $wunschwebinar;
  
  public $wunschknr;
  
  public $bemerkung;
  
  public $geschlecht = '';
  
  public $einrichtung;
  
  public $name;
  
  public $vorname;
  
  public $email;
  
  public $tel;
  
  public $knr;

  public $captcha;
  public $dse = false;

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'wunschdatvon':
      case 'wunschdatbis':
        return \DatamodulVarType::TYPE_DATE;
    }
  }

  public function toTeilnehmerPflicht()
  {
    $tn = new \TeilnehmerPflicht();
    $myAttrs = $this->getAttributeNames();
    foreach ($myAttrs as $attr) {
      if ($tn->VarExist($attr)) {
        $tn->setValue2Var($attr, $this->getVarValue($attr));
      }
    }

    
    
    if (isset($this->einrichtung) && $this->einrichtung != '') {
      $tn->vorname = '';
      $tn->name = $this->einrichtung;
      $tn->zusatz = $this->name;
      $tn->zusatz2 = $this->vorname;
      $tn->geschlecht = 'F';
    }

    return $tn;
  }
}