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


class BASysBenutzer extends Personn
{
  public $kennung = '';
  public $aussenstelle = '';
  public $www = '';
  public $tel3 = '';
  public $rechtber_d = '';
  public $rechtber_t = '';
  public $rechtber_k = '';
  public $gruppe = '';
  public $gruppe1 = '';
  public $gruppe2 = '';
  public $gruppe3 = '';
  public $webnichtuebersicht = '';
  public $stelle = '';
  
  public $zimmer = '';
  public $agb_bestaetigen;
  public $vorschlagknr;

  
  public $adr1 = '';
  public $adr2 = '';
  public $adr3 = '';
  public $adr4 = '';

  
  public $email2;
  
  public $email3;

  public function getVarValueEx($name, $datamodulname)
  {
    
    return Datamodul::getVarValueEx($name, $datamodulname);
  }

  public function getVarValue($pName)
  {
    switch ($pName) {
      
      case 'titel_name_vorname': return $this->getVarValue('name_vorname_ohne_komma');
      case 'titel_vorname_name': return $this->getVarValue('vorname_name_ohne_komma');
      case 'namevorname': return trim($this->getVarValue('name') . ', ' . $this->getVarValue('vorname'), ' ,');
      default: return parent::getVarValue($pName);
    }
  }

  public function setValue2Var($var, $val)
  {
    Datamodul::setValue2Var($var, $val);
  }

  
  public function getGruppen()
  {
    $gruppen = array();
    
    $anzahlGruppen = 3;
    
    for ($i = 1; $i <= $anzahlGruppen; $i++) {
      $gruppe = parent::getVarValue('gruppe' . $i);
      if ($gruppe != '') {
        array_push($gruppen, $gruppe);
      }
    }

    return $gruppen;
  }

  
  public function getVarName4EmailSenderSetting($pEmpfaenger)
  {
    return 'absenderMitarbeiterAn' . $pEmpfaenger;
  }

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'id':
        return \DatamodulVarType::TYPE_INT;
      case 'webnichtuebersicht':
        return \DatamodulVarType::TYPE_BOOL_WF;
      case 'agb_bestaetigen':
        return \DatamodulVarType::TYPE_DATETIME;
    }
  }

  public function getEMailName(): string
  {
    return $this->getVarValue('name_vorname_ohne_komma');
  }

  public function getEMailAddress(): ?string
  {
    return $this->email;
  }
}