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

class EmailXMLWeitere extends Datamodul
{
  public $emailkursID;
  public $emailstammID;
  public $typ;
  public $kursgebuehr;
  public $belegID;
  public $emailxml; 
  public $zahlplan;
  public $guthabenverwenden;

  public $hotelAnm; 

  
  public $beleghistorie1;
  public $beleghistorie2;
  public $beleghistorie3;
  public $beleghistorie4;
  public $beleghistorie5;
  public $beleghistorie6;
  public $beleghistorie7;
  public $beleghistorie8;
  public $beleghistorie9;
  public $beleghistorie10;
  public $beleghistorie11;
  public $beleghistorie12;
  public $beleghistorie13;
  public $beleghistorie14;
  public $beleghistorie15;
  public $beleghistorie16;

  public function getXMLNode($pNodeTag = 'WEITERANM')
  {
    $exceptions = array('emailxml', 'hotelAnm');
    
    $rootNode = new XMLNode($pNodeTag);
    for ($i = 0; $i < $this->getVarCount(); $i++) {
      $varname = $this->getVarname($i);
      if (in_array($varname, $exceptions)) {
        continue;
      }
      $value = $this->getVarValue($varname);
      if ($value != '') {
        $rootNode->addChild(new XMLNode(StringOperations::strtoupper($varname), $this->getVarValue($varname)));
      }
    }

    if ($this->emailxml != null && !$this->emailxml->isEmpty() && (!isset($this->emailxml->istanonym) || $this->emailxml->istanonym != 1)) {
      
      $rootNode->addChild($this->emailxml->getXMLNode('WEITERSTAMM'));
    }
    if ($this->hotelAnm != '' && !$this->hotelAnm->isEmpty()) {
      $rootNode->addChild($this->hotelAnm->getXMLNode());
    }

    return $rootNode;
  }

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'zahlplan':
      case 'belegID':
      case 'emailstammID':
      case 'emailkursID':
        return \DatamodulVarType::TYPE_INT;
      case 'kursgebuehr':
        return \DatamodulVarType::TYPE_FLOAT;
      case 'guthabenverwenden':
        return \DatamodulVarType::TYPE_WF_EMPTY;
    }
  }
}