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


class Aussenstelle extends Datamodul
{
  public const WEBANMELD_ZENTRAL = 0;
  public const WEBANMELD_ONLINE = 1;
  public const WEBANMELD_EMAIL_ZENTRAL = 2;
  public const WEBANMELD_EMAIL_AN = 3;

  
  public $bezeichner;
  
  
  public $zwebene;

  
  public $name;

  
  public $link;

  
  public $webaktiv;

  
  public $info;

  
  public $strasse;
  
  public $ort;
  
  public $leiter;
  
  public $laufendenr;
  
  public $internet;

  
  public $email;
  public $tel;
  public $fax;

  
  public $linkhomepage;
  
  public $webanmeld;
  
  public $webanmeldemail;
  
  public $webbestaetigas;
  
  public $webbestaetigasemail;
  
  public $webbestaetigtn;
  
  public $webnichtkurse;
  
  public $webnichtsuchbegriff;
  
  public $webnichtuebersicht;
  
  public $webanmeldunverb;
  
  public $bezeichner_bf;
  
  public $wegbeschreibung;
  
  public $anfahrtlink;
  
  public $kennz_as;
  
  public $oeffnungszeiten;

  
  public function setValue2Var($var, $val)
  {
    switch ($var) {
     case 'email':
       $this->email->wert = $val;
       $this->email->nr = $this->id;
       if (!isset($this->email->art) || $this->email->art == '') {
         $this->email->art = 'E';
       } 
       if (!isset($this->email->bezeichner) || $this->email->bezeichner == '') {
         $this->email->bezeichner = 'EMail';
       }
       break;
     case 'tel':
       $this->tel->wert = $val;
       $this->tel->nr = $this->id;
       if (!isset($this->tel->art) || $this->tel->art == '') {
         $this->tel->art = 'T';
       }
       if (!isset($this->tel->bezeichner) || $this->tel->bezeichner == '') {
         $this->tel->bezeichner = 'Telefon';
       }
       break;
     case 'fax':
       $this->fax->wert = $val;
       $this->fax->nr = $this->id;
       if (!isset($this->fax->art) || $this->fax->art == '') {
         $this->fax->art = 'F';
       }
       if (!isset($this->fax->bezeichner) || $this->fax->bezeichner == '') {
         $this->fax->bezeichner = 'Fax';
       }
       break;
     default: parent::setValue2Var($var, $val);
    }
  }

  public function getVarValueEx($name, $datamodulname)
  {
    if (StringOperations::strtolower($datamodulname) == 'kommunikation') {
      $ary = get_object_vars($this);

      return $ary[$name]->wert;
    }

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

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'laufendenr':
      case 'webanmeld':
      case 'webbestaetigas':
      case 'webbestaetigtn':
      case 'kennz_as':
        return \DatamodulVarType::TYPE_INT;
    }
  }

  public function getFotoTyp(): ?string
  {
    return \Foto::TYP_AUSSENSTELLEN;
  }
}