<?php
namespace App\Entity;
use DateTime;
use App\Model\AppConstant;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\UsersQualification;
use App\Exception\CustomException;
use App\Repository\UsersRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
/**
* Users
*
* @ORM\Table(name="users")
* @ORM\Entity
*/
#[ORM\Entity(repositoryClass: UsersRepository::class)]
#[UniqueEntity(fields: ["username"], message: "Cet identifiant d'utilisateur est déjà en cours d'utilisation")]
#[UniqueEntity(fields: ["email"], message: "Cet email est déjà en cours d'utilisation")]
#[UniqueEntity(fields: ["phone"], message: "Ce numéro est déjà en cours d'utilisation")]
class Users implements UserInterface, PasswordAuthenticatedUserInterface, \JsonSerializable, \Serializable
{
public const GAUCHE = 1;
public const DROITE = 2;
public const ACTIVE = 0;
public const INACTIVE = -1;
public const SUSPENDED = -2;
public const CREATED = 1;
public const USERS_PROFIL_PICTURE_DIRECTORY = "files/users/img/";
public const COTE_FORM = [
'Gauche' => self::GAUCHE,
'Droite' => self::DROITE,
];
public const TYPE_USER_FORM = [
'Particulier' => self::TYPE_USER_PARTICULIER,
'Entreprise' => self::TYPE_USER_ENTREPRISE,
];
public const TYPE_USER_PARTICULIER = 1;
public const TYPE_USER_ENTREPRISE = 2;
public const KYC_CREATED = 1;
public const KYC_VALIDATED = 2;
public const KYC_DENIED = -1;
public const KYC_EMPTY = 0;
public const CONTRAT_APPORTEUR_AFFAIRE_NOT_GIVEN = 0;
public const CONTRAT_APPORTEUR_NEED_TO_SEND_MAIL = 1;
public const CONTRAT_APPORTEUR_AFFAIRE_WAITING_SIGNATURE = 2;
public const CONTRAT_APPORTEUR_AFFAIRE_SUBMITTED_WITH_SIGNATURE = 3;
public const CONTRAT_APPORTEUR_AFFAIRE_VALIDATED = 4;
public const CONTRAT_APPORTEUR_AFFAIRE_REJECTED = -1;
public const ROLE_ADMIN_STAT = 'ROLE_ADMIN_STAT';
public const ROLE_ADMIN_VALIDATION = 'ROLE_ADMIN_VALIDATION';
public const ROLE_ADMIN_CLIENT_ACCESS = 'ROLE_ADMIN_CLIENT_ACCESS' ;
public const ADMIN_ROLES_ARRAY = [
self::ROLE_ADMIN_STAT,
self::ROLE_ADMIN_VALIDATION,
self::ROLE_ADMIN_CLIENT_ACCESS
];
public const BO_FIRST_LEVEL = 1;
public const BO_SECOND_LEVEL = 2;
public const BO_THIRD_LEVEL = 3;
public const BO_MAX_LEVEL = 99;
/**
* @var int
*
* @ORM\Column(name="ID", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: Users::class)]
#[ORM\JoinColumn(name: "parent_id", referencedColumnName:"id", nullable:true)]
private $parent;
#[ORM\ManyToOne(targetEntity: Users::class)]
#[ORM\JoinColumn(name: "upline_id", referencedColumnName:"id", nullable:true)]
private $upline;
/**
* @var int|null
*
* @ORM\Column(name="lado", type="integer", nullable=true, options={"default"="1"})
*/
#[ORM\Column(type: 'integer',name:'lado',nullable:true,options: ['default' => 1])]
private $side = 1;
/**
* @var string|null
*
* @ORM\Column(name="name", type="string", length=200, nullable=true)
*/
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $name;
/**
* @var string|null
*
* @ORM\Column(name="surname", type="string", length=200, nullable=true)
*/
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $surname;
/**
* @var string|null
*
* @ORM\Column(name="username", type="string", length=200, nullable=true)
*/
#[ORM\Column(type: 'string',length:200,nullable:false,unique:true)]
private $username;
/**
* @var string|null
*
* @ORM\Column(name="email", type="string", length=300, nullable=true)
*/
#[ORM\Column(type: 'string',length:300,nullable:true)]
private $email;
/**
* @var string|null
*
* @ORM\Column(name="password", type="string", length=300, nullable=true)
*/
#[ORM\Column(type: 'string',length:300,nullable:true)]
private $password;
/**
* @var string|null
*
* @ORM\Column(name="phone", type="string", length=200, nullable=true)
*/
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $phone;
/**
* @var string|null
*
* @ORM\Column(name="address", type="string", length=300, nullable=true)
*/
#[ORM\Column(type: 'string',length:300,nullable:true)]
private $address;
#[ORM\ManyToOne(targetEntity: Country::class)]
#[ORM\JoinColumn(name: "country", nullable: false)]
private $country;
/**
* @var string
*
* @ORM\Column(name="pic", type="string", length=300, nullable=false, options={"default"="assets/img/users/default.webp"})
*/
#[ORM\Column(type: 'string',length:300,nullable:false,options:['default'=>"default.webp"])]
private $pic = 'default.webp';
/**
* @var int|null
*
* @ORM\Column(name="rango", type="integer", nullable=true)
*/
#[ORM\Column(type: 'integer',nullable:true)]
private $rango;
/**
* @var int|null
*
* @ORM\Column(name="star", type="integer", nullable=true)
*/
#[ORM\Column(type: 'integer',nullable:true)]
private $star = '0';
/**
* @var int|null
*
* @ORM\Column(name="derrame", type="integer", nullable=true, options={"default"="1"})
*/
#[ORM\Column(type: 'integer',nullable:true,options:['default'=>1])]
private $derrame = 1;
/**
* @var int|null
*
* @ORM\Column(name="permisos", type="integer", nullable=true, options={"default"="2"})
*/
#[ORM\Column(type: 'integer',nullable:true,options:['default'=>2])]
private $permisos = 2;
/**
* @var int|null
*
* @ORM\Column(name="verificado", type="integer", nullable=true)
*/
#[ORM\Column(type: 'integer',nullable:true)]
private $verificado = '0';
/**
* @var int|null
*
* @ORM\Column(name="activo", type="integer", nullable=true)
*/
#[ORM\Column(type: 'integer',nullable:true)]
private $activo = '0';
#[ORM\Column(type: 'json', nullable:true)]
private $roles = [];
#[ORM\Column(type: 'date',options: ['default' => '2000-01-01'])]
private $birthdate;
#[ORM\Column(type: 'string', length: 20, nullable:true)]
private $postalCode;
#[ORM\Column(type: 'string', length: 255, nullable:true)]
private $city;
#[ORM\Column(type: 'integer', nullable:true)]
private $type = 1;
#[ORM\Column(type: 'string', length: 255, nullable:true)]
private $nomSociete;
#[ORM\Column(type: 'string', length: 255, nullable:true)]
private $siret;
private $plainPassword;
#[ORM\Column(type: 'integer',nullable: true,options: ['default' => '0'])]
private $countLeftSideUser = 0;
#[ORM\Column(type: 'integer',nullable: true,options: ['default' => '0'])]
private $countRightSideUser = 0;
#[ORM\Column(type: 'integer',nullable:true,options: ['default' => '0'])]
private $kycVerification = 0;
#[ORM\OneToMany(targetEntity: UsersDocs::class, mappedBy: 'user')]
private $docs;
#[ORM\OneToOne(targetEntity: UsersQualification::class, mappedBy: 'user')]
private $qualification;
#[ORM\Column(type: 'datetime',options: ['default' => '2000-01-01'])]
private $createdAt;
#[ORM\Column(type: 'string',length:200, nullable:true,options: ['default' => '0'])]
private $numero = 0;
#[ORM\Column(type: 'string',length:200,unique:false,nullable:true)]
private $pieceIdentite;
#[ORM\Column(type: 'integer',nullable:true,options: ['default' => '0'])]
private $typePieceIdentite = 0;
#[ORM\Column(type: 'integer',nullable:true,options:['default'=>self::CREATED])]
private $state = self::CREATED;
public $oldPassword;
public $newPassword;
public $retypePassword;
#[ORM\ManyToOne]
private ?Country $nationality = null;
#[ORM\ManyToOne]
private ?TypeIdentityDoc $typeIdentityDoc = null;
#[ORM\ManyToOne]
private ?Country $documentIssueCountry = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $docIdRecto = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $docIdVerso = null;
#[ORM\ManyToOne]
private ?KycVerificationStatus $kycVerificationStatus = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateLastVerification = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $rejectionReason = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $identity_photo = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $statutSociete = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $pieceJustificativeDomicile = null;
#[ORM\Column(nullable: true)]
private ?bool $originKyc = null;
#[ORM\Column(type: 'integer',nullable:true,options: ['default' => '0'])]
private $contratApporteurAffaireState = 0;
#[ORM\Column(type: 'string',length:200,unique:false,nullable:true)]
private $signature;
#[ORM\Column(type: 'string',length:200,unique:false,nullable:true)]
private $cz;
#[ORM\Column(type: 'string',length:200,unique:false,nullable:true)]
private $aml;
#[ORM\Column(type: 'string',length:200,unique:false,nullable:true)]
private $qualifiedInvestisorDocument;
#[ORM\Column(type: 'string',length:200,unique:false,nullable:true)]
private $contrat;
#[ORM\Column(type: 'string',length:200,unique:false,nullable:true)]
private $termeEtCondition;
#[ORM\Column(nullable: true,options: ['default' => false])]
private ?bool $waitingUserRankingRewardChoice = false;
#[ORM\Column(type: 'datetime',nullable:true)]
private $endOfSuspension;
private ?int $countryId = null;
private ?int $uplineId = null;
private ?int $parentId = null;
#[ORM\Column(nullable: true)]
private ?int $teamParentPosition = null;
#[ORM\Column(nullable: true)]
private ?bool $dataProtectionChecked = null;
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $numeroPieceIdentite;
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $sexe;
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $lieuDeNaissance;
#[ORM\Column(type: 'date',nullable:true)]
private $validiteDocument;
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $siege;
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $registre;
#[ORM\Column(type: 'string',length:200,nullable:true)]
private $numeroDeRegistre;
#[ORM\Column(type: 'string',length:255,unique:false,nullable:true)]
private $structureSociete;
#[ORM\ManyToOne(targetEntity: Users::class)]
#[ORM\JoinColumn( nullable: true)]
private $adminThatValidateKyc;
#[ORM\Column(type: 'string',length:255,unique:false,nullable:true)]
private $nextStepKyc;
#[ORM\Column(type: 'integer',nullable:true,options: ['default' => self::BO_FIRST_LEVEL])]
private $backOfficeLevel = self::BO_FIRST_LEVEL;
#[ORM\Column(type: 'string',length:5,options: ['default' => 'fr'])]
private $lang = 'fr';
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $refusalReasonAdmin = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateKycValidation = null;
#[ORM\Column(nullable: true)]
private ?bool $hasSubmittedKycDocument = false;
public function setUplineId($uplineId) { $this->uplineId = $uplineId; return $this; }
public function getUplineId() { return $this->uplineId; }
public function setParentId($parentId) { $this->parentId = $parentId; return $this; }
public function getParentId() { return $this->parentId; }
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'name' => $this->getName(),
'surname' => $this->getSurname(),
'email' => $this->getEmail(),
'address' => $this->getAddress(),
'postalCode' => $this->getPostalCode(),
'city' => $this->getCity(),
'country' => $this->getCountry(),
'phone' => $this->getPhone(),
'name' => $this->getName(),
'nomSociete' => $this->getNomSociete(),
'pieceIdentite' => $this->getPieceIdentite(),
'type' => $this->getType(),
'siret' => $this->getSiret(),
'birthdate' => $this->getBirthdate()->format('Y-m-d')
];
}
public function __construct()
{
$this->docs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCountryId(): ?int
{
return $this->countryId;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
UsefulEntity::NotNull($name,"nom");
$this->name = $name;
return $this;
}
public function getSurname(): ?string
{
return $this->surname;
}
public function setSurname(?string $surname): static
{
UsefulEntity::NotNull($surname,"prénom");
$this->surname = $surname;
return $this;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(?string $username): static
{
UsefulEntity::NotNull($username,"nom d'utilisateur");
$this->username = $username;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): static
{
UsefulEntity::NotNull($email,"E-mail");
$this->email = $email;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(?string $password): static
{
UsefulEntity::NotNull($password,"Mot de passe");
$this->password = $password;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): static
{
$this->phone = $phone;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): static
{
$this->address = $address;
return $this;
}
/**
* Get the value of country
*/
public function getCountry()
{
return $this->country;
}
/**
* Set the value of country
*
* @return self
*/
public function setCountry($country)
{
UsefulEntity::NotNull($country,"pays");
$this->country = $country;
return $this;
}
public function getPic(): ?string
{
return $this->pic;
}
public function setPic(string $pic): static
{
$this->pic = $pic;
return $this;
}
public function getRango(): ?int
{
return $this->rango;
}
public function setRango(?int $rango): static
{
$this->rango = $rango;
return $this;
}
public function getStar(): ?int
{
return $this->star;
}
public function setStar(?int $star): static
{
$this->star = $star;
return $this;
}
public function getDerrame(): ?int
{
return $this->derrame;
}
public function setDerrame(?int $derrame): static
{
$this->derrame = $derrame;
return $this;
}
public function getPermisos(): ?int
{
return $this->permisos;
}
public function setPermisos(?int $permisos): static
{
$this->permisos = $permisos;
return $this;
}
public function getVerificado(): ?int
{
return $this->verificado;
}
public function setVerificado(?int $verificado): static
{
$this->verificado = $verificado;
return $this;
}
public function getActivo(): ?int
{
return $this->activo;
}
public function setActivo(?int $activo): static
{
$this->activo = $activo;
return $this;
}
public function getUserIdentifier(): string
{
return (string) $this->username;
}
public function getSalt(): ?string
{
return null;
}
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function setParent(?Users $parent): self
{
$this->parent = $parent;
return $this;
}
public function getParent(): ?Users
{
return $this->parent;
}
/**
* Get the value of birthdate
*/
public function getBirthdate()
{
return $this->birthdate;
}
/**
* Set the value of birthdate
*
* @return self
*/
public function setBirthdate($birthdate)
{
UsefulEntity::getDate($birthdate,"Date d'anniversaire");
// Format of the date string
$format = 'Y-m-d';
// Create a DateTime object from the string and format
$date = $birthdate;
if (!($birthdate instanceof DateTime)){
$date = DateTime::createFromFormat($format, $birthdate);
}
$this->birthdate =$date;
return $this;
}
/**
* Get the value of postalCode
*/
public function getPostalCode()
{
return $this->postalCode;
}
/**
* Set the value of postalCode
*
* @return self
*/
public function setPostalCode($postalCode)
{
$this->postalCode = $postalCode;
return $this;
}
public function getPlainPassword()
{
return $this->plainPassword;
}
/**
* Set the value of plainPassword
*
* @return self
*/
public function setPlainPassword($plainPassword)
{
$this->plainPassword = $plainPassword;
return $this;
}
public function getSide()
{
return $this->side;
}
/**
* Set the value of side
*
* @return self
*/
public function setSide($side)
{
$this->side = $side;
return $this;
}
public function getCity()
{
return $this->city;
}
/**
* Set the value of city
*
* @return self
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* Get the value of type
*/
public function getType()
{
return $this->type;
}
/**
* Set the value of type
*
* @return self
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
public function setCountryId($countryId)
{
$this->countryId = $countryId;
return $this;
}
public function getFullName(){
return ($this->getName() ? $this->getName(): '') . ' ' . ($this->getSurname() ? $this->getSurname() : '');
}
/**
* Get the value of upline
*/
public function getUpline()
{
return $this->upline;
}
/**
* Set the value of upline
*
* @return self
*/
public function setUpline($upline)
{
$this->upline = $upline;
return $this;
}
public function isDescendantOf(Users $ancestor): bool
{
if ($this->getUpline() === null) {
return false;
}
if ($this->getUpline()->getId() === $ancestor->getId()) {
return true;
}
return $this->getUpline()->isDescendantOf($ancestor);
}
/**
* Get the value of countLeftSideUser
*/
public function getCountLeftSideUser()
{
return $this->countLeftSideUser;
}
/**
* Set the value of countLeftSideUser
*
* @return self
*/
public function setCountLeftSideUser($countLeftSideUser)
{
$this->countLeftSideUser = $countLeftSideUser;
return $this;
}
/**
* Get the value of countRightSideUser
*/
public function getCountRightSideUser()
{
return $this->countRightSideUser;
}
/**
* Set the value of countRightSideUser
*
* @return self
*/
public function setCountRightSideUser($countRightSideUser)
{
$this->countRightSideUser = $countRightSideUser;
return $this;
}
/**
* Get the value of siret
*/
public function getSiret()
{
return $this->siret;
}
/**
* Set the value of siret
*
* @return self
*/
public function setSiret($siret)
{
$this->siret = $siret;
return $this;
}
/**
* Get the value of nomSociete
*/
public function getNomSociete()
{
return $this->nomSociete;
}
/**
* Set the value of nomSociete
*
* @return self
*/
public function setNomSociete($nomSociete)
{
$this->nomSociete = $nomSociete;
return $this;
}
/**
* Get the value of kycVerification
*/
public function getKycVerification()
{
return $this->kycVerification;
}
/**
* Set the value of kycVerification
*
* @return self
*/
public function setKycVerification($kycVerification)
{
$this->kycVerification = $kycVerification;
return $this;
}
/**
* Get the value of docs
*/
public function getDocs()
{
return $this->docs;
}
/**
* Set the value of docs
*
* @return self
*/
public function setDocs($docs)
{
$this->docs = $docs;
return $this;
}
public function getStringSide(){
foreach (self::COTE_FORM as $key => $value) {
if($this->getSide() == $value) return $key;
}
throw new CustomException ('Côté de l\'équipe invalide');
}
/**
* Get the value of createdAt
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set the value of createdAt
*
* @return self
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function getTabUsersData(){
$rep=[];
$rep[]=$this->getId()!=null?$this->getId():"";
$rep[]=$this->getName()!=null?$this->getName():"";
$rep[]=$this->getSurname()!=null?$this->getSurname():"";
$rep[]=$this->getUsername()!=null?$this->getUsername():"";
$rep[]=$this->getBirthdate()!=null?$this->getBirthdate()->format('Y-m-d'):"";
$rep[]=$this->getEmail()!=null?$this->getEmail():"";
$rep[]=$this->getType()!=null?$this->getTypeLabel():"";
$rep[]=($this->getType() == Users::TYPE_USER_ENTREPRISE)? $this->getNomSociete() :"";
$rep[]=$this->getRango()!=null? AppConstant::getRankName($this->getRango()):"Aucune";
$rep[]=$this->getPhone()!=null?$this->getPhone():"";
$rep[]=$this->getAddress()!=null?$this->getAddress():"";
$rep[]=$this->getCountry()!=null?$this->getCountry()->getValue():"";
$rep[]=$this->getPostalCode()!=null?$this->getPostalCode():"";
return $rep;
}
public function addDoc(UsersDocs $doc): static
{
if (!$this->docs->contains($doc)) {
$this->docs->add($doc);
$doc->setUser($this);
}
return $this;
}
public function removeDoc(UsersDocs $doc): static
{
if ($this->docs->removeElement($doc)) {
// set the owning side to null (unless already changed)
if ($doc->getUser() === $this) {
$doc->setUser(null);
}
}
return $this;
}
/**
* Get the value of numero
*/
public function getNumero()
{
return $this->numero;
}
/**
* Set the value of numero
*
* @return self
*/
public function setNumero($numero)
{
$this->numero = $numero;
return $this;
}
/**
* Get the value of qualification
*/
public function getQualification()
{
return $this->qualification;
}
/**
* Set the value of qualification
*
* @return self
*/
public function setQualification($qualification)
{
$this->qualification = $qualification;
return $this;
}
public function checkString(string $input): bool
{
// Vérifie la présence d'au moins un caractère spécial, un chiffre et une majuscule
$specialCharRegex = '/[!@#$%^&*(),.?":{}|<>]/';
$digitRegex = '/\d/';
$uppercaseRegex = '/[A-Z]/';
$lowercaseRegex = '/[a-z]/';
// Vérifie si le string contient au moins un caractère spécial, un chiffre et une majuscule
$containsSpecialChar = preg_match($specialCharRegex, $input);
$containsDigit = preg_match($digitRegex, $input);
$containsUppercase = preg_match($uppercaseRegex, $input);
$containsLowercase = preg_match($lowercaseRegex, $input);
return $containsSpecialChar && $containsDigit && $containsUppercase&&$containsLowercase;
}
//reset password
public function verificationResetPassword($oldPassword,$newPassword,$confirmPassword){
UsefulEntity::NotNull($oldPassword,"l'ancien mot de passe");
$this->oldPassword=$oldPassword;
UsefulEntity::NotNull($newPassword,"le nouveau mot de passe");
$this->newPassword=$newPassword;
UsefulEntity::NotNull($confirmPassword,"la confirmation du mot de passe");
$this->retypePassword=$confirmPassword;
if($newPassword!=$confirmPassword)
throw new CustomException("le nouveau mot de passe et la confirmation doit être les mêmes");
if(!$this->checkString($newPassword)){
throw new CustomException("Le mot de passe doit contenir une majuscule, des minuscules, des nombres et un symbole");
}
}
public function resetLabel(){
$this->oldPassword="";
$this->newPassword="";
$this->retypePassword="";
}
public function getKycStringStatus(){
switch ($this->getKycVerification()) {
case self::KYC_CREATED:
return "En attente de validation";
case self::KYC_VALIDATED :
return "Validé";
case self::KYC_DENIED :
return "Refusé";
default :
return "Documents non fournis";
}
}
public function getPieceIdentite(): ?string
{
return $this->pieceIdentite;
}
public function setPieceIdentite($pieceIdentite): static
{
$this->pieceIdentite = $pieceIdentite;
return $this;
}
public function getTypePieceIdentite()
{
return $this->typePieceIdentite;
}
public function setTypePieceIdentite($typePieceIdentite): static
{
$this->typePieceIdentite = $typePieceIdentite;
return $this;
}
//fonction aidant à l'affichage
public function getKycStringStatusColor(){
switch ($this->getKycVerification()) {
case self::KYC_CREATED:
return "on_hold";
case self::KYC_VALIDATED :
return "completed";
case self::KYC_DENIED :
return "un_paid";
default :
return "paid";
}
}
public function isDisabledForm(){
if($this->isValidatedKYC()){
return 'disabled';
}
else return '';
}
public function isValidatedKYC(){
return $this->getKycVerification()==self::KYC_VALIDATED;
}
/**
* Get the value of state
*/
public function getState()
{
return $this->state;
}
/**
* Set the value of state
*
* @return self
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
public function getUserStringStatus(){
switch ($this->getState()) {
case self::INACTIVE:
return "Désactivé";
default :
return "Activé";
}
}
public function getNationality(): ?Country
{
return $this->nationality;
}
public function setNationality(?Country $nationality): static
{
$this->nationality = $nationality;
return $this;
}
public function getTypeIdentityDoc(): ?TypeIdentityDoc
{
return $this->typeIdentityDoc;
}
public function setTypeIdentityDoc(?TypeIdentityDoc $typeIdentityDoc): static
{
$this->typeIdentityDoc = $typeIdentityDoc;
return $this;
}
public function getDocumentIssueCountry(): ?Country
{
return $this->documentIssueCountry;
}
public function setDocumentIssueCountry(?Country $documentIssueCountry): static
{
$this->documentIssueCountry = $documentIssueCountry;
return $this;
}
public function getDocIdRecto(): ?string
{
return $this->docIdRecto;
}
public function setDocIdRecto(?string $docIdRecto): static
{
$this->docIdRecto = $docIdRecto;
return $this;
}
public function getDocIdVerso(): ?string
{
return $this->docIdVerso;
}
public function setDocIdVerso(?string $docIdVerso): static
{
$this->docIdVerso = $docIdVerso;
return $this;
}
public function checkKycStatus(KycVerificationStatus $kycVerificationStatus, bool $ignoreNull = true){
if($this->getKycVerificationStatus()?->getId() !== KycVerificationStatus::NOT_VERIFIED || (($this->getKycVerificationStatus()?->getId() == null || $this->getKycVerificationStatus()?->getId() == KycVerificationStatus::NOT_VERIFIED) && !$ignoreNull)){
$this->setKycVerificationStatus($kycVerificationStatus);
}
}
public function getKycVerificationStatus(): ?KycVerificationStatus
{
return $this->kycVerificationStatus;
}
public function setKycVerificationStatus(?KycVerificationStatus $kycVerificationStatus): static
{
$this->kycVerificationStatus = $kycVerificationStatus;
return $this;
}
public function getDateLastVerification(): ?\DateTimeInterface
{
return $this->dateLastVerification;
}
public function setDateLastVerification(?\DateTimeInterface $dateLastVerification): static
{
$this->dateLastVerification = $dateLastVerification;
return $this;
}
public function getRejectionReason(): ?string
{
return $this->rejectionReason;
}
public function setRejectionReason(?string $rejectionReason): static
{
$this->rejectionReason = $rejectionReason;
return $this;
}
public function getIdentityPhoto(): ?string
{
return $this->identity_photo;
}
public function setIdentityPhoto(?string $identity_photo): static
{
$this->identity_photo = $identity_photo;
return $this;
}
public function getStatutSociete(): ?string
{
return $this->statutSociete;
}
public function setStatutSociete(?string $statutSociete): static
{
$this->statutSociete = $statutSociete;
return $this;
}
public function getPieceJustificativeDomicile(): ?string
{
return $this->pieceJustificativeDomicile;
}
public function setPieceJustificativeDomicile(?string $pieceJustificativeDomicile): static
{
$this->pieceJustificativeDomicile = $pieceJustificativeDomicile;
return $this;
}
public function getTypeLabel(){
return $this->getType() === self::TYPE_USER_ENTREPRISE ? 'Entreprise' : 'Particulier';
}
public function isOriginKyc(): ?bool
{
return $this->originKyc;
}
public function setOriginKyc(?bool $originKyc): static
{
$this->originKyc = $originKyc;
return $this;
}
public function serialize()
{
return serialize([
'id' => $this->getId(),
'name' => $this->getName(),
'surname' => $this->getSurname(),
'email' => $this->getEmail(),
'address' => $this->getAddress(),
'postalCode' => $this->getPostalCode(),
'city' => $this->getCity(),
'countryId' => $this->getCountry()?->getId(),
'phone' => $this->getPhone(),
'name' => $this->getName(),
'nomSociete' => $this->getNomSociete(),
'pieceIdentite' => $this->getPieceIdentite(),
'type' => $this->getType(),
'siret' => $this->getSiret(),
'birthdate' => $this->getBirthdate()->format('Y-m-d'),
'side' => $this->getSide(),
'username' => $this->getUsername(),
'password' => $this->getPassword(),
'uplineId' => $this->getUpline()?->getId(),
'parentId' => $this->getParent()?->getId(),
'roles' => $this->getRoles(),
'plainPassword' => $this->getPlainPassword(),
'sexe' => $this->getSexe(),
'lieuDeNaissance' => $this->getLieuDeNaissance(),
'validiteDocument' => $this->getValiditeDocument(),
'typePieceIdentite' => $this->getTypePieceIdentite()
]);
}
public function unserialize($serialized)
{
$data = unserialize($serialized);
$this->id = $data['id'];
$this->setName($data['name']);
$this->setSurname($data['surname']);
$this->setEmail($data['email']);
$this->setAddress($data['address']);
$this->setPostalCode($data['postalCode']);
$this->setCity($data['city']);
$this->setCountryId($data['countryId']);
$this->setPhone($data['phone']);
$this->setName($data['name']);
$this->setNomSociete($data['nomSociete']);
$this->setPieceIdentite($data['pieceIdentite']);
$this->setType($data['type']);
$this->setSiret($data['siret']);
$this->setBirthdate($data['birthdate']);
$this->setSide($data['side']);
$this->setUsername($data['username']);
$this->setPassword($data['password']);
$this->setUplineId($data['uplineId']);
$this->setParentId($data['parentId']);
$this->setRoles($data['roles']);
$this->setPlainPassword($data['plainPassword']);
$this->setTypePieceIdentite($data['typePieceIdentite']);
$this->setSexe($data['sexe']);
$this->setLieuDeNaissance($data['lieuDeNaissance']);
$this->setValiditeDocument($data['validiteDocument']);
}
public function getStringTeamParentPosition(): ?string{
if($this->getTeamParentPosition() !== null){
foreach (self::COTE_FORM as $key => $value) {
if($this->getTeamParentPosition() == $value) return $key;
}
}
return null;
}
public function getTeamParentPosition(): ?int
{
return $this->teamParentPosition;
}
public function setTeamParentPosition(?int $teamParentPosition): static
{
$this->teamParentPosition = $teamParentPosition;
return $this;
}
public function isDataProtectionChecked(): ?bool
{
return $this->dataProtectionChecked;
}
public function setDataProtectionChecked(?bool $dataProtectionChecked): static
{
$this->dataProtectionChecked = $dataProtectionChecked;
return $this;
}
/**
* Get the value of contratApporteurAffaireState
*/
public function getContratApporteurAffaireState() {
return $this->contratApporteurAffaireState;
}
/**
* Set the value of contratApporteurAffaireState
*/
public function setContratApporteurAffaireState($contratApporteurAffaireState): self {
$this->contratApporteurAffaireState = $contratApporteurAffaireState;
return $this;
}
public function getSignature(): ?string
{
return $this->signature;
}
public function setSignature(?string $signature): static
{
$this->signature = $signature;
return $this;
}
public function getContratStringStatus(){
switch ($this->getContratApporteurAffaireState()) {
case self::CONTRAT_APPORTEUR_AFFAIRE_VALIDATED:
return "Validé";
case self::CONTRAT_APPORTEUR_AFFAIRE_REJECTED :
return "Refusé";
case self::CONTRAT_APPORTEUR_AFFAIRE_SUBMITTED_WITH_SIGNATURE:
return "En attente de validation";
case self::CONTRAT_APPORTEUR_AFFAIRE_WAITING_SIGNATURE :
return "En attente de signature";
case self::CONTRAT_APPORTEUR_NEED_TO_SEND_MAIL :
return "En attente de signature";
default :
return "Aucun";
}
}
public function getContratStringStatusColor(){
switch ($this->getContratApporteurAffaireState()) {
case self::CONTRAT_APPORTEUR_AFFAIRE_VALIDATED:
return "completed";
case self::CONTRAT_APPORTEUR_AFFAIRE_REJECTED :
return "un_paid";
default :
return "on_hold";
}
}
/**
* Get the value of contrat
*/
public function getContrat()
{
return $this->contrat;
}
/**
* Set the value of contrat
*/
public function setContrat($contrat): self
{
$this->contrat = $contrat;
return $this;
}
/**
* Get the value of termeEtCondition
*/
public function getTermeEtCondition()
{
return $this->termeEtCondition;
}
/**
* Set the value of termeEtCondition
*/
public function setTermeEtCondition($termeEtCondition): self
{
$this->termeEtCondition = $termeEtCondition;
return $this;
}
/**
* Get the value of waitingUserRankingRewardChoice
*/
public function getWaitingUserRankingRewardChoice()
{
return $this->waitingUserRankingRewardChoice;
}
/**
* Set the value of waitingUserRankingRewardChoice
*
* @return self
*/
public function setWaitingUserRankingRewardChoice($waitingUserRankingRewardChoice)
{
$this->waitingUserRankingRewardChoice = $waitingUserRankingRewardChoice;
return $this;
}
/**
* Get the value of endOfSuspension
*/
public function getEndOfSuspension()
{
return $this->endOfSuspension;
}
/**
* Set the value of endOfSuspension
*
* @return self
*/
public function setEndOfSuspension($endOfSuspension)
{
$this->endOfSuspension = $endOfSuspension;
return $this;
}
/**
* Get the value of numeroPieceIdentite
*/
public function getNumeroPieceIdentite()
{
return $this->numeroPieceIdentite;
}
/**
* Set the value of numeroPieceIdentite
*
* @return self
*/
public function setNumeroPieceIdentite($numeroPieceIdentite)
{
$this->numeroPieceIdentite = $numeroPieceIdentite;
return $this;
}
/**
* Get the value of sexe
*/
public function getSexe()
{
return $this->sexe;
}
/**
* Set the value of sexe
*
* @return self
*/
public function setSexe($sexe)
{
$this->sexe = $sexe;
return $this;
}
/**
* Get the value of lieuDeNaissance
*/
public function getLieuDeNaissance()
{
return $this->lieuDeNaissance;
}
/**
* Set the value of lieuDeNaissance
*
* @return self
*/
public function setLieuDeNaissance($lieuDeNaissance)
{
$this->lieuDeNaissance = $lieuDeNaissance;
return $this;
}
/**
* Get the value of validiteDocument
*/
public function getValiditeDocument()
{
return $this->validiteDocument;
}
/**
* Set the value of validiteDocument
*
* @return self
*/
public function setValiditeDocument($validiteDocument)
{
$this->validiteDocument = $validiteDocument;
return $this;
}
/**
* Get the value of cz
*/
public function getCz()
{
return $this->cz;
}
/**
* Set the value of cz
*
* @return self
*/
public function setCz($cz)
{
$this->cz = $cz;
return $this;
}
/**
* Get the value of aml
*/
public function getAml()
{
return $this->aml;
}
/**
* Set the value of aml
*
* @return self
*/
public function setAml($aml)
{
$this->aml = $aml;
return $this;
}
/**
* Get the value of siege
*/
public function getSiege()
{
return $this->siege;
}
/**
* Set the value of siege
*
* @return self
*/
public function setSiege($siege)
{
$this->siege = $siege;
return $this;
}
/**
* Get the value of registre
*/
public function getRegistre()
{
return $this->registre;
}
/**
* Set the value of registre
*
* @return self
*/
public function setRegistre($registre)
{
$this->registre = $registre;
return $this;
}
/**
* Get the value of numeroDeRegistre
*/
public function getNumeroDeRegistre()
{
return $this->numeroDeRegistre;
}
/**
* Set the value of numeroDeRegistre
*
* @return self
*/
public function setNumeroDeRegistre($numeroDeRegistre)
{
$this->numeroDeRegistre = $numeroDeRegistre;
return $this;
}
/**
* Get the value of structureSociete
*/
public function getStructureSociete()
{
return $this->structureSociete;
}
/**
* Set the value of structureSociete
*
* @return self
*/
public function setStructureSociete($structureSociete)
{
$this->structureSociete = $structureSociete;
return $this;
}
/**
* Get the value of qualifiedInvestisorDocument
*/
public function getQualifiedInvestisorDocument()
{
return $this->qualifiedInvestisorDocument;
}
/**
* Set the value of qualifiedInvestisorDocument
*
* @return self
*/
public function setQualifiedInvestisorDocument($qualifiedInvestisorDocument)
{
$this->qualifiedInvestisorDocument = $qualifiedInvestisorDocument;
return $this;
}
/**
* Get the value of adminThatValidateKyc
*/
public function getAdminThatValidateKyc()
{
return $this->adminThatValidateKyc;
}
/**
* Set the value of adminThatValidateKyc
*
* @return self
*/
public function setAdminThatValidateKyc($adminThatValidateKyc)
{
$this->adminThatValidateKyc = $adminThatValidateKyc;
return $this;
}
/**
* Get the value of nextStepKyc
*/
public function getNextStepKyc()
{
return $this->nextStepKyc;
}
/**
* Set the value of nextStepKycj
*
* @return self
*/
public function setNextStepKyc($nextStepKyc)
{
$this->nextStepKyc = $nextStepKyc;
return $this;
}
public function getFullAddress(){
$lieu = $this->getAddress()." ,".$this->getCity()." ".$this->getPostalCode();
if($this->getCountry()){
$lieu = $lieu.",".$this->getCountry()->getValue();
}
return $lieu;
}
public function getCurrentBackOfficeLevel(){
if(in_array("ROLE_ADMIN", $this->getRoles())){
return self::BO_MAX_LEVEL;
}
return $this->getBackOfficeLevel();
}
/**
* Get the value of backOfficeLevel
*/
public function getBackOfficeLevel()
{
return $this->backOfficeLevel;
}
/**
* Set the value of backOfficeLevel
*
* @return self
*/
public function setBackOfficeLevel($backOfficeLevel)
{
$this->backOfficeLevel = $backOfficeLevel;
return $this;
}
public function updateBackOfficeLevelBasedOnRank($rank){
$currentBackOfficeLevel = $this->getCurrentBackOfficeLevel();
$newBackOfficeLevel = self::BO_FIRST_LEVEL;
$consultantRank = 2;
$seniorConsultantRank = 4;
if($rank >= $consultantRank){
$newBackOfficeLevel = self::BO_SECOND_LEVEL;
}
if($rank >= $seniorConsultantRank){
$newBackOfficeLevel = self::BO_THIRD_LEVEL;
}
if($newBackOfficeLevel <= $currentBackOfficeLevel ){
return false;
}
$this->setBackOfficeLevel($newBackOfficeLevel);
return true;
}
/**
* Get the value of lang
*/
public function getLang()
{
return $this->lang;
}
/**
* Set the value of lang
*
* @return self
*/
public function setLang($lang)
{
$this->lang = $lang;
return $this;
}
public function getRefusalReasonAdmin(): ?string
{
return $this->refusalReasonAdmin;
}
public function setRefusalReasonAdmin(?string $refusalReasonAdmin): static
{
$this->refusalReasonAdmin = $refusalReasonAdmin;
return $this;
}
/**
* Get the value of dateKycValidation
*
* @return ?\DateTimeInterface
*/
public function getDateKycValidation(): ?\DateTimeInterface
{
return $this->dateKycValidation;
}
/**
* Set the value of dateKycValidation
*
* @param ?\DateTimeInterface $dateKycValidation
*
* @return self
*/
public function setDateKycValidation(?\DateTimeInterface $dateKycValidation): self
{
$this->dateKycValidation = $dateKycValidation;
return $this;
}
/**
* Get the value of hasSubmittedKycDocument
*
* @return ?bool
*/
public function hasSubmittedKycDocument(): ?bool
{
return $this->hasSubmittedKycDocument;
}
/**
* Set the value of hasSubmittedKycDocument
*
* @param ?bool $hasSubmittedKycDocument
*
* @return self
*/
public function setHasSubmittedKycDocument(?bool $hasSubmittedKycDocument): self
{
$this->hasSubmittedKycDocument = $hasSubmittedKycDocument;
return $this;
}
}