<?php
namespace App\Entity;
use App\Utility\DateUtils;
use DateTime;
use Symfony\Component\Security\Core\User\UserInterface;
class StbUser extends AbstractEntityBase implements UserInterface {
/**
* @var string
*/
private $username;
/**
* @var string
*/
private $password;
private $currentPassword;
/**
* @var string
*/
private $fullName;
/**
* @var DateTime
*/
private $lastAccessDatetime;
private $mainRole;
private $flagPasswordExpiring;
private $roles = [];
private $keyGroup;
private $userCode;
private $profileDb;
private $codMdep;
/**
* @var DateTime
*/
private $passwordEndtime;
private $codLang;
/**
* @var DateTime
*/
private $creationDatetime;
private $ctrlState;
private $details;
private $eMail;
private $lastPasswords;
private $passwordExpiresDays;
private $urlCss;
private $insertStbUser;
/**
* @var DateTime
*/
private $destructionDatetime;
private $wtbClie;
private $wtbFavoriteArt;
private $stbUser;
private $wrlUsersFasi;
/**
* @var string
*/
private $codCal = null;
/**
* @var string
*/
private $companyname = null;
/**
* @var string
*/
private $flagAttivo = null;
/**
* @var string
*/
private $flagDba = null;
/**
* @var string
*/
private $flagExtraUser = null;
/**
* @var string
*/
private $flagIntraUser = null;
/**
* @var DateTime
*/
private $lastDownload = null;
/**
* @var DateTime
*/
private $lastUpgDb = null;
/**
* @var DateTime
*/
private $lastUpgSp = null;
/**
* @var string
*/
private $logoUser = null;
/**
* @var string
*/
private $precode = null;
/**
* @var string
*/
private $userId = null;
/**
* @var string
*/
private $userNameRif = null;
/**
* @var boolean
*/
private $cryptPassword = true;
/**
* @var string
*/
private $credentials;
/**
* @return mixed
*/
public function getFullName() {
return $this->fullName;
}
/**
* @param mixed $fullName
*/
public function setFullName($fullName): void {
$this->fullName = $fullName;
}
/**
* @return mixed
*/
public function getLastAccessDatetime() {
return $this->lastAccessDatetime;
}
/**
* @param mixed $lastAccessDatetime
*/
public function setLastAccessDatetime($lastAccessDatetime): void {
$this->lastAccessDatetime = $lastAccessDatetime;
}
/**
* @return mixed
*/
public function getFlagPasswordExpiring() {
return $this->flagPasswordExpiring;
}
/**
* @param mixed $flagPasswordExpiring
*/
public function setFlagPasswordExpiring($flagPasswordExpiring): void {
$this->flagPasswordExpiring = $flagPasswordExpiring;
}
/**
* @return mixed
*/
public function getKeyGroup() {
return $this->keyGroup;
}
/**
* @param mixed $keyGroup
*/
public function setKeyGroup($keyGroup): void {
$this->keyGroup = $keyGroup;
}
/**
* @return string
*/
public function getCodCal(): ?string {
return $this->codCal;
}
/**
* @param string $codCal
*/
public function setCodCal(?string $codCal): void {
$this->codCal = $codCal;
}
/**
* @return string
*/
public function getCompanyname(): ?string {
return $this->companyname;
}
/**
* @param string $companyname
*/
public function setCompanyname(?string $companyname): void {
$this->companyname = $companyname;
}
/**
* @return string
*/
public function getFlagDba(): ?string {
return $this->flagDba;
}
/**
* @param string $flagDba
*/
public function setFlagDba(?string $flagDba): void {
$this->flagDba = $flagDba;
}
/**
* @return string
*/
public function getFlagExtraUser(): ?string {
return $this->flagExtraUser;
}
/**
* @param string $flagExtraUser
*/
public function setFlagExtraUser(?string $flagExtraUser): void {
$this->flagExtraUser = $flagExtraUser;
}
/**
* @return string
*/
public function getFlagIntraUser(): ?string {
return $this->flagIntraUser;
}
/**
* @param string $flagIntraUser
*/
public function setFlagIntraUser(?string $flagIntraUser): void {
$this->flagIntraUser = $flagIntraUser;
}
/**
* @return DateTime
*/
public function getLastDownload(): ?DateTime {
return $this->lastDownload;
}
/**
* @param DateTime $lastDownload
*/
public function setLastDownload(?DateTime $lastDownload): void {
$this->lastDownload = $lastDownload;
}
/**
* @return DateTime
*/
public function getLastUpgDb(): ?DateTime {
return $this->lastUpgDb;
}
/**
* @param DateTime $lastUpgDb
*/
public function setLastUpgDb(?DateTime $lastUpgDb): void {
$this->lastUpgDb = $lastUpgDb;
}
/**
* @return DateTime
*/
public function getLastUpgSp(): ?DateTime {
return $this->lastUpgSp;
}
/**
* @param DateTime $lastUpgSp
*/
public function setLastUpgSp(?DateTime $lastUpgSp): void {
$this->lastUpgSp = $lastUpgSp;
}
/**
* @return string
*/
public function getLogoUser(): ?string {
return $this->logoUser;
}
/**
* @param string $logoUser
*/
public function setLogoUser(?string $logoUser): void {
$this->logoUser = $logoUser;
}
/**
* @return string
*/
public function getPrecode(): ?string {
return $this->precode;
}
/**
* @param string $precode
*/
public function setPrecode(?string $precode): void {
$this->precode = $precode;
}
/**
* @return string
*/
public function getUserId(): ?string {
return $this->userId;
}
/**
* @param string $userId
*/
public function setUserId(?string $userId): void {
$this->userId = $userId;
}
/**
* @return string
*/
public function getUserNameRif(): ?string {
return $this->userNameRif;
}
/**
* @param string $userNameRif
*/
public function setUserNameRif(?string $userNameRif): void {
$this->userNameRif = $userNameRif;
}
/**
* @return bool
*/
public function isCryptPassword(): bool {
return $this->cryptPassword;
}
/**
* @param bool $cryptPassword
*/
public function setCryptPassword(bool $cryptPassword): void {
$this->cryptPassword = $cryptPassword;
}
public function getRoles() {
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
switch ($this->keyGroup) {
case 1:
$roles[] = 'ROLE_SUPER_ADMIN';
break;
case 2:
$roles[] = 'ROLE_USER_ADV';
break;
case 3:
$roles[] = 'ROLE_CUSTOMER';
break;
case 4:
$roles[] = 'ROLE_SUPPLIER';
break;
case 5:
$roles[] = 'ROLE_AGENT';
break;
case 6:
$roles[] = 'ROLE_INSPECTOR';
break;
case 7:
$roles[] = 'ROLE_EXTERNAL_DEPOSIT_MANAGER';
break;
case 8:
$roles[] = 'ROLE_WORK_TEAM';
break;
case 9:
$roles[] = 'ROLE_ADMIN';
break;
case 10:
$roles[] = 'ROLE_PV';
break;
case 11:
$roles[] = 'ROLE_PRODUCTION_MANAGER';
break;
case 12:
$roles[] = 'ROLE_COMMERCIAL_MANAGER';
break;
case 20:
$roles[] = 'ROLE_PV_MANAGER';
break;
case 21:
$roles[] = 'ROLE_DETECTOR';
break;
case 22:
$roles[] = 'ROLE_TECHNICAL';
break;
case 23:
$roles[] = 'ROLE_DEPARTMENT_MANAGER';
break;
case 24:
$roles[] = 'ROLE_PURCHASING_MANAGER';
break;
case 25:
$roles[] = 'ROLE_EDP';
break;
case 26:
$roles[] = 'ROLE_SUBSCRIBER';
break;
case 27:
$roles[] = 'ROLE_GUEST';
break;
default:
$roles[] = 'ROLE_USER';
break;
}
return array_unique($roles);
}
public function isFlagAttivo() {
return $this->flagAttivo;
}
/**
* @param $flagAttivo
*/
public function setFlagAttivo($flagAttivo): void {
$this->flagAttivo = $flagAttivo;
}
/**
* @return mixed
*/
public function getUserCode() {
return $this->userCode;
}
/**
* @param mixed $userCode
*/
public function setUserCode($userCode): void {
$this->userCode = $userCode;
}
/**
* @return mixed
*/
public function getProfileDb() {
return $this->profileDb;
}
/**
* @param mixed $profileDb
*/
public function setProfileDb($profileDb): void {
$this->profileDb = $profileDb;
}
/**
* @return mixed
*/
public function getCodMdep() {
return $this->codMdep;
}
/**
* @param mixed $codMdep
*/
public function setCodMdep($codMdep): void {
$this->codMdep = $codMdep;
}
public function getPassword() {
return $this->password;
}
public function getSalt() {
// TODO: Implement getSalt() method.
}
public function getUsername() {
return $this->username;
}
public function eraseCredentials() {
// TODO: Implement eraseCredentials() method.
}
/**
* @param string $username
*/
public function setUsername($username): void {
$this->username = $username;
}
/**
* @param string|null $password
*/
public function setPassword(?string $password): void {
$this->password = $password;
}
/**
* @return mixed
*/
public function getPasswordEndtime() {
return $this->passwordEndtime;
}
/**
* @param mixed $passwordEndtime
*/
public function setPasswordEndtime($passwordEndtime): void {
$this->passwordEndtime = $passwordEndtime;
}
/**
* @return mixed
*/
public function getCodLang() {
return $this->codLang;
}
/**
* @param mixed $codLang
*/
public function setCodLang($codLang): void {
$this->codLang = $codLang;
}
/**
* @return mixed
*/
public function getCreationDatetime() {
return $this->creationDatetime;
}
/**
* @param mixed $creationDatetime
*/
public function setCreationDatetime($creationDatetime): void {
$this->creationDatetime = $creationDatetime;
}
/**
* @return mixed
*/
public function getCtrlState() {
return $this->ctrlState;
}
/**
* @param mixed $ctrlState
*/
public function setCtrlState($ctrlState): void {
$this->ctrlState = $ctrlState;
}
/**
* @return mixed
*/
public function getDetails() {
return $this->details;
}
/**
* @param mixed $details
*/
public function setDetails($details): void {
$this->details = $details;
}
/**
* @return mixed
*/
public function getEMail() {
return $this->eMail;
}
/**
* @param mixed $eMail
*/
public function setEMail($eMail): void {
$this->eMail = $eMail;
}
/**
* @return mixed
*/
public function getLastPasswords() {
return $this->lastPasswords;
}
/**
* @param mixed $lastPasswords
*/
public function setLastPasswords($lastPasswords): void {
$this->lastPasswords = $lastPasswords;
}
/**
* @return mixed
*/
public function getPasswordExpiresDays() {
return $this->passwordExpiresDays;
}
/**
* @param mixed $passwordExpiresDays
*/
public function setPasswordExpiresDays($passwordExpiresDays): void {
$this->passwordExpiresDays = $passwordExpiresDays;
}
/**
* @return mixed
*/
public function getUrlCss() {
return $this->urlCss;
}
/**
* @param mixed $urlCss
*/
public function setUrlCss($urlCss): void {
$this->urlCss = $urlCss;
}
/**
* @return mixed
*/
public function getInsertStbUser() {
return $this->insertStbUser;
}
/**
* @param mixed $insertStbUser
*/
public function setInsertStbUser($insertStbUser): void {
$this->insertStbUser = $insertStbUser;
}
/**
* @return mixed
*/
public function getDestructionDatetime() {
return $this->destructionDatetime;
}
/**
* @param mixed $destructionDatetime
*/
public function setDestructionDatetime($destructionDatetime): void {
$this->destructionDatetime = $destructionDatetime;
}
/**
* @return mixed
*/
public function getWtbClie() {
return $this->wtbClie;
}
/**
* @param mixed $wtbClie
*/
public function setWtbClie($wtbClie): void {
$this->wtbClie = $wtbClie;
}
/**
* @return mixed
*/
public function getWtbFavoriteArt() {
return $this->wtbFavoriteArt;
}
/**
* @param mixed $wtbFavoriteArt
*/
public function setWtbFavoriteArt($wtbFavoriteArt): void {
$this->wtbFavoriteArt = $wtbFavoriteArt;
}
/**
* @return mixed
*/
public function getStbUser() {
return $this->stbUser;
}
/**
* @param mixed $stbUser
*/
public function setStbUser($stbUser): void {
$this->stbUser = $stbUser;
}
/**
* @return mixed
*/
public function getWrlUsersFasi() {
return $this->wrlUsersFasi;
}
/**
* @param mixed $wrlUsersFasi
*/
public function setWrlUsersFasi($wrlUsersFasi): void {
$this->wrlUsersFasi = $wrlUsersFasi;
}
/**
* @return mixed
*/
public function getCurrentPassword() {
return $this->currentPassword;
}
/**
* @param mixed $currentPassword
*/
public function setCurrentPassword($currentPassword): void {
$this->currentPassword = $currentPassword;
}
public function jsonSerialize() {
return [
"operation" => $this->getOperation(),
"type" => $this->getType(),
'userName' => $this->getUsername(),
'fullName' => $this->getFullName(),
'password' => $this->getPassword(),
'lastAccessDatetime' => $this->getLastAccessDatetime() ? $this->getLastAccessDatetime()->format(DateUtils::FORMAT_DATETIME_FOR_REST) : null,
'flagPasswordExpiring' => $this->getFlagPasswordExpiring() ? "S" : "N",
"codMdep" => $this->getCodMdep(),
"profileDb" => $this->getProfileDb(),
"passwordEndtime" => $this->getPasswordEndtime() ? $this->getPasswordEndtime()->format(DateUtils::FORMAT_DATETIME_FOR_REST) : null,
"userCode" => $this->getUserCode(),
"username" => $this->getUsername(),
"keyGroup" => $this->getKeyGroup(),
"codLang" => $this->getcodLang(),
"creationDatetime" => $this->getCreationDatetime() ? $this->getCreationDatetime()->format(DateUtils::FORMAT_DATETIME_FOR_REST) : null,
"ctrlState" => $this->getCtrlState() ? "S" : "N",
"details" => $this->getDetails(),
"eMail" => $this->getEMail(),
"lastPasswords" => $this->getLastPasswords(),
"passwordExpiresDays" => $this->getPasswordExpiresDays(),
"urlCss" => $this->getUrlCss(),
"codCal" => $this->getCodCal(),
"companyname" => $this->getCompanyname(),
"flagAttivo" => $this->isflagAttivo(),
"flagDba" => $this->getFlagDba(),
"flagExtraUser" => $this->getFlagExtraUser(),
"flagIntraUser" => $this->getFlagIntraUser(),
"lastDownload" => $this->getLastDownload(),
"lastUpgDb" => $this->getLastUpgDb(),
"lastUpgSp" => $this->getLastUpgSp(),
"logoUser" => $this->getLogoUser(),
"precode" => $this->getPrecode(),
"userId" => $this->getUserId(),
"userNameRif" => $this->getUserNameRif(),
"cryptPassword" => $this->isCryptPassword(),
];
}
public function fromDto($dto) {
$this->fullName = $dto["full_name"];
$this->codMdep = $dto["cod_mdep"];
$this->profileDb = $dto["profile_db"];
$this->passwordEndtime = $dto["password_endtime"] ? DateUtils::fromDatestring($dto["password_endtime"]) : null;
$this->userCode = $dto["user_code"];
// $this->flagAttivo = $dto["flag_attivo"] === "S";
$this->username = $dto["user_name"];
$this->flagPasswordExpiring = $dto["flag_password_expiring"] === "S";
$this->lastAccessDatetime = DateUtils::fromDatestring($dto["Last_access_datetime"]);
$this->keyGroup = $dto["key_group"];
$this->codLang = $dto["cod_lang"];
$this->creationDatetime = array_key_exists("creation_datetime", $dto) && $dto["creation_datetime"] ? $dto["creation_datetime"] : null;
$this->ctrlState = !(array_key_exists("ctrl_state", $dto) && $dto["ctrl_state"]) || $dto["ctrl_state"] == "S";
$this->details = array_key_exists("details", $dto) && $dto["details"] ? $dto["details"] : null;
$this->eMail = array_key_exists("e_mail", $dto) && $dto["e_mail"] ? $dto["e_mail"] : null;
$this->lastPasswords = array_key_exists("lastPasswords", $dto) && $dto["lastPasswords"] ? $dto["lastPasswords"] : null;
$this->passwordExpiresDays = array_key_exists("passwordExpiresDays", $dto) && $dto["passwordExpiresDays"] ? $dto["passwordExpiresDays"] : null;
$this->urlCss = array_key_exists("urlCss", $dto) && $dto["urlCss"] ? $dto["urlCss"] : null;
$this->codCal = array_key_exists("codCal", $dto) && $dto["codCal"] ? $dto["codCal"] : null;
$this->companyname = array_key_exists("companyname", $dto) && $dto["companyname"] ? $dto["companyname"] : null;
$this->flagAttivo = array_key_exists("flagAttivo", $dto) && $dto["flagAttivo"] ? $dto["flagAttivo"] : null;
$this->flagDba = array_key_exists("flagDba", $dto) && $dto["flagDba"] ? $dto["flagDba"] : null;
$this->flagExtraUser = array_key_exists("flagExtraUser", $dto) && $dto["flagExtraUser"] ? $dto["flagExtraUser"] : null;
$this->flagIntraUser = array_key_exists("flagIntraUser", $dto) && $dto["flagIntraUser"] ? $dto["flagIntraUser"] : null;
$this->lastDownload = array_key_exists("lastDownload", $dto) && $dto["lastDownload"] ? $dto["lastDownload"] : null;
$this->lastUpgDb = array_key_exists("lastUpgDb", $dto) && $dto["lastUpgDb"] ? $dto["lastUpgDb"] : null;
$this->lastUpgSp = array_key_exists("lastUpgSp", $dto) && $dto["lastUpgSp"] ? $dto["lastUpgSp"] : null;
$this->logoUser = array_key_exists("logoUser", $dto) && $dto["logoUser"] ? $dto["logoUser"] : null;
$this->precode = array_key_exists("precode", $dto) && $dto["precode"] ? $dto["precode"] : null;
$this->userId = array_key_exists("userId", $dto) && $dto["userId"] ? $dto["userId"] : null;
$this->userNameRif = array_key_exists("userNameRif", $dto) && $dto["userNameRif"] ? $dto["userNameRif"] : null;
$this->cryptPassword = array_key_exists("cryptPassword", $dto) && $dto["cryptPassword"] && boolval($dto["cryptPassword"]);
}
public function getLocale() {
return $this->getCodLang() ? strtolower($this->getCodLang()) : "en";
}
public function getType() {
return "stb_user";
}
/**
* @return mixed
*/
public function getMainRole() {
$role = "Utente";
switch ($this->keyGroup) {
case 1:
$role = 'Super amministratore';
break;
case 2:
$role = 'Utente aziendale';
break;
case 3:
$role = 'Cliente';
break;
case 4:
$role = 'Fornitore';
break;
case 5:
$role = 'Agente';
break;
case 6:
$role = 'Ispettore';
break;
case 7:
$role = 'Gestore deposito esterno';
break;
case 8:
$role = 'Squadra lavoro';
break;
case 9:
$role = 'Amministratore';
break;
case 10:
$role = 'Punto vendita';
break;
case 11:
$role = 'Responsabile produzione';
break;
case 12:
$role = 'Responsabile commerciale';
break;
case 20:
$role = 'Responsabile magazzino';
break;
case 21:
$role = 'Rilevatore';
break;
case 22:
$role = 'Tecnico';
break;
case 23:
$role = 'Responsabile Reparto';
break;
case 24:
$role = 'Responsabile acquisti';
break;
case 25:
$role = 'EDP';
break;
case 26:
$role = 'Iscritto';
break;
case 27:
$role = 'Osipte';
break;
default:
$role = 'Utente';
break;
}
return $role;
}
/**
* @return mixed
*/
public function getCredentials() {
return $this->credentials;
}
/**
* @param mixed $credentials
*/
public function setCredentials($credentials): void {
$this->credentials = $credentials;
}
public function getAuthCredentials() {
return base64_encode($this->getUsername()) . "::" . $this->getCredentials();
}
}