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

use Kufer\Web\Classes\Identifier\Identifier;

class WebToolsUsers extends Datamodul
{
  public $tool_id;
  public $user_id;
  public $user_id_guid;
  public $template_id;
  public $validfrom;
  public $validuntil;

  public function getTyp($pFieldName)
  {
    switch ($pFieldName) {
      default:
        return parent::getTyp($pFieldName);
      case 'validfrom':
      case 'validuntil':
        return \DatamodulVarType::TYPE_DATE;
      case 'tool_id':
      case 'user_id':
      case 'template_id':
        return \DatamodulVarType::TYPE_INT;
      case 'user_id_guid':
        return \DatamodulVarType::TYPE_GUID;
    }
  }

  public function setValue2VarFromDmzJson($var, $value)
  {
    $varLower = StringOperations::strtolower($var);
    switch ($varLower) {
      default: $this->setValue2Var($varLower, $value);
        break;
    }
  }

  public function setUserIdentifier(Identifier $identifier): void
  {
    $this->user_id = $identifier->getId();
    $this->user_id_guid = $identifier->getGuid();
  }
}