<?php
// src/Entity/User.php
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\Table(name="69pixl_user")
* @UniqueEntity(fields="email", message="Email already taken")
* @UniqueEntity(fields="username", message="Username already taken")
* @ORM\HasLifecycleCallbacks()
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\PrePersist
*/
public function prePersist()
{
$this->dateCreated = new \DateTime();
}
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var datetime
* @ORM\Column(name="date_created", type="datetime", nullable=true)
*/
protected $dateCreated;
/**
* @ORM\Column(type="string", length=190, unique=true)
* @Assert\NotBlank()
* @Assert\Email()
*/
private $email;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $username;
/**
* @Assert\Length(max=4096)
*/
private $plainPassword;
/**
* The below length depends on the "algorithm" you use for encoding
* the password, but this works well with bcrypt.
*
* @ORM\Column(type="string", length=64)
*/
private $password;
/**
* @ORM\Column(type="string", length=190, nullable=true)
* @Assert\NotBlank()
*/
private $lastName;
/**
* @ORM\Column(type="string", length=190, nullable=true)
* @Assert\NotBlank()
*/
private $firstName;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $codeConseiller;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $numeroSiren;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phonePrefix;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $sex;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateDeNaissance;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $numeroDeVoie;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $codePostal;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $ville;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $pays;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $tokenReset;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $status;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $adherentDistributeur;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $dicIsFile;
/**
* @ORM\Column(type="array")
*/
private $roles;
/**
* @ORM\Column(type="integer", length=30, nullable=true)
*/
private $currentSign;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $tokenSignupContinue;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $stepSignup;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isAutoSignup;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
private $autoSignFolderNumber;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $adresseFiscaleFrance;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $acceptConditionsGeneralesUtilisation;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $connaissanceProtectionDonneesPersonnelles;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $accepteRecevoirPropositionCommercialMailTelephone;
/**
* @var Memberships[]
* @ORM\OneToMany(targetEntity="App\Entity\Membership", mappedBy="user")
*/
protected $memberships;
/**
* @var Customers[]
* @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="seller")
*/
protected $customers;
/**
* @var seller
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="memberships")
*/
protected $seller;
/**
* @var LoginLogs[]
* @ORM\OneToMany(targetEntity="App\Entity\LoginLog", mappedBy="user")
*/
protected $loginLogs;
/**
* @var cps[]
* @ORM\OneToMany(targetEntity="App\Entity\Cp", mappedBy="createdBy")
*/
protected $cps;
/**
* @var cpSignatory[]
* @ORM\OneToMany(targetEntity="App\Entity\Cp", mappedBy="signatoryUser")
*/
protected $cpSignatory;
/**
* @var listDocType[]
* @ORM\OneToMany(targetEntity="App\Entity\SignatoryDocType", mappedBy="signatory")
*/
protected $listDocType;
public function __construct()
{
$this->roles = array('ROLE_USER');
$this->memberShips = new ArrayCollection();
$this->memberships = new ArrayCollection();
$this->customers = new ArrayCollection();
$this->loginLogs = new ArrayCollection();
$this->cps = new ArrayCollection();
$this->cpSignatory = new ArrayCollection();
$this->listDocType = new ArrayCollection();
}
// other properties and methods
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
}
public function getUsername()
{
return $this->username;
}
public function setUsername($username)
{
$this->username = $username;
}
public function getPlainPassword()
{
return $this->plainPassword;
}
public function setPlainPassword($password)
{
$this->plainPassword = $password;
}
public function getPassword(): string
{
return $this->password;
}
public function setPassword($password)
{
$this->password = $password;
}
public function getSalt()
{
// The bcrypt and argon2i algorithms don't require a separate salt.
// You *may* need a real salt if you choose a different encoder.
return null;
}
public function getRoles()
{
return $this->roles;
}
public function eraseCredentials()
{
}
public function getId(): ?int
{
return $this->id;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* Get roleTranslate
*
* @return integer
*/
public function getRoleMain()
{
$main = "";
foreach ($this->getRoles() as $role) {
if($role != "ROLE_USER"){
$main .= $role;
}
}
return $main;
}
public function getFullNameSignatory(): ?string
{
$lastName = '';
$firstName = '';
$fullName = '';
foreach ($this->getRoles() as $role) {
if($role === "ROLE_SIGNATORY"){
$lastName = $this->getLastName();
$firstName = $this->getFirstName();
$fullName = $firstName .' '. $lastName;
}
}
return $fullName;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getTokenReset(): ?string
{
return $this->tokenReset;
}
public function setTokenReset(?string $tokenReset): self
{
$this->tokenReset = $tokenReset;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function addRole($role)
{
$role = strtoupper($role);
if ($role === "ROLE_DEFAULT") {
return $this;
}
if (!in_array($role, $this->roles, true)) {
$this->roles[] = $role;
}
return $this;
}
public function getCurrentMemberships()
{
$currentMemberships = null;
if(count($this->memberships) > 0){
$currentMemberships = $this->memberships[count($this->memberships) -1];
}
return $currentMemberships;
}
/**
* @return Collection|Membership[]
*/
public function getMemberships(): Collection
{
return $this->memberships;
}
public function addMembership(Membership $membership): self
{
if (!$this->memberships->contains($membership)) {
$this->memberships[] = $membership;
$membership->setUser($this);
}
return $this;
}
public function removeMembership(Membership $membership): self
{
if ($this->memberships->contains($membership)) {
$this->memberships->removeElement($membership);
// set the owning side to null (unless already changed)
if ($membership->getUser() === $this) {
$membership->setUser(null);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function addCustomer(User $customer): self
{
if (!$this->customers->contains($customer)) {
$this->customers[] = $customer;
$customer->setSeller($this);
}
return $this;
}
public function removeCustomer(User $customer): self
{
if ($this->customers->contains($customer)) {
$this->customers->removeElement($customer);
// set the owning side to null (unless already changed)
if ($customer->getSeller() === $this) {
$customer->setSeller(null);
}
}
return $this;
}
public function getSeller(): ?self
{
return $this->seller;
}
public function setSeller(?self $seller): self
{
$this->seller = $seller;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->dateCreated;
}
public function setDateCreated(\DateTimeInterface $dateCreated): self
{
$this->dateCreated = $dateCreated;
return $this;
}
public function getCodeConseiller(): ?string
{
return $this->codeConseiller;
}
public function setCodeConseiller(?string $codeConseiller): self
{
$this->codeConseiller = $codeConseiller;
return $this;
}
public function getNumeroSiren(): ?string
{
return $this->numeroSiren;
}
public function setNumeroSiren(?string $numeroSiren): self
{
$this->numeroSiren = $numeroSiren;
return $this;
}
public function getSexTranslate(): ?string
{
$trans = "";
if($this->sex == 0){
$trans = "M";
}
else{
$trans = "Mme";
}
return $trans;
}
public function getSex(): ?string
{
return $this->sex;
}
public function setSex(?string $sex): self
{
$this->sex = $sex;
return $this;
}
public function getDateDeNaissance()
{
return $this->dateDeNaissance;
}
public function setDateDeNaissance($dateDeNaissance): self
{
$this->dateDeNaissance = $dateDeNaissance;
return $this;
}
public function getNumeroDeVoie(): ?string
{
return $this->numeroDeVoie;
}
public function setNumeroDeVoie(?string $numeroDeVoie): self
{
$this->numeroDeVoie = $numeroDeVoie;
return $this;
}
public function getCodePostal(): ?string
{
return $this->codePostal;
}
public function setCodePostal(?string $codePostal): self
{
$this->codePostal = $codePostal;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(?string $ville): self
{
$this->ville = $ville;
return $this;
}
public function getPays(): ?string
{
return $this->pays;
}
public function setPays(?string $pays): self
{
$this->pays = $pays;
return $this;
}
public function getAdherentDistributeur(): ?string
{
return $this->adherentDistributeur;
}
public function setAdherentDistributeur(?string $adherentDistributeur): self
{
$this->adherentDistributeur = $adherentDistributeur;
return $this;
}
public function getDicIsFile(): ?bool
{
return $this->dicIsFile;
}
public function setDicIsFile(?bool $dicIsFile): self
{
$this->dicIsFile = $dicIsFile;
return $this;
}
/**
* @return Collection|LoginLog[]
*/
public function getLoginLogs(): Collection
{
return $this->loginLogs;
}
public function addLoginLog(LoginLog $loginLog): self
{
if (!$this->loginLogs->contains($loginLog)) {
$this->loginLogs[] = $loginLog;
$loginLog->setUser($this);
}
return $this;
}
public function removeLoginLog(LoginLog $loginLog): self
{
if ($this->loginLogs->contains($loginLog)) {
$this->loginLogs->removeElement($loginLog);
// set the owning side to null (unless already changed)
if ($loginLog->getUser() === $this) {
$loginLog->setUser(null);
}
}
return $this;
}
public function getPhonePrefix(): ?string
{
return $this->phonePrefix;
}
public function setPhonePrefix(?string $phonePrefix): self
{
$this->phonePrefix = $phonePrefix;
return $this;
}
/**
* @return Collection|Cp[]
*/
public function getCps(): Collection
{
return $this->cps;
}
public function addCp(Cp $cp): self
{
if (!$this->cps->contains($cp)) {
$this->cps[] = $cp;
$cp->setCreatedBy($this);
}
return $this;
}
public function removeCp(Cp $cp): self
{
if ($this->cps->removeElement($cp)) {
// set the owning side to null (unless already changed)
if ($cp->getCreatedBy() === $this) {
$cp->setCreatedBy(null);
}
}
return $this;
}
public function getCpSignatory(): Collection
{
return $this->cpSignatory;
}
public function addCpSignatory(Cp $cp): self
{
if (!$this->CpSignatory->contains($cp)) {
$this->CpSignatory[] = $cp;
$cp->setSignatoryUser($this);
}
return $this;
}
public function removeCpSignatory(Cp $cp): self
{
if ($this->CpSignatory->removeElement($cp)) {
// set the owning side to null (unless already changed)
if ($cp->getSignatoryUser() === $this) {
$cp->setSignatoryUser(null);
}
}
return $this;
}
public function getListDocType(): Collection
{
return $this->listDocType;
}
public function addListDocType(SignatoryDocType $file): self
{
if (!$this->listDocType->contains($file)) {
$this->listDocType[] = $file;
$file->setSignatory($this);
}
return $this;
}
public function removeListDocType(SignatoryDocType $file): self
{
if ($this->listDocType->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getSignatory() === $this) {
$file->setSignatory(null);
}
}
return $this;
}
public function isDicIsFile(): ?bool
{
return $this->dicIsFile;
}
public function getCurrentSign(): ?int
{
return $this->currentSign;
}
public function setCurrentSign(?int $currentSign): self
{
$this->currentSign = $currentSign;
return $this;
}
public function getTokenSignupContinue(): ?string
{
return $this->tokenSignupContinue;
}
public function setTokenSignupContinue(?string $tokenSignupContinue): static
{
$this->tokenSignupContinue = $tokenSignupContinue;
return $this;
}
public function isIsAutoSignup(): ?bool
{
return $this->isAutoSignup;
}
public function setIsAutoSignup(?bool $isAutoSignup): static
{
$this->isAutoSignup = $isAutoSignup;
return $this;
}
public function isAcceptConditionsGeneralesUtilisation(): ?bool
{
return $this->acceptConditionsGeneralesUtilisation;
}
public function setAcceptConditionsGeneralesUtilisation(?bool $acceptConditionsGeneralesUtilisation): static
{
$this->acceptConditionsGeneralesUtilisation = $acceptConditionsGeneralesUtilisation;
return $this;
}
public function isConnaissanceProtectionDonneesPersonnelles(): ?bool
{
return $this->connaissanceProtectionDonneesPersonnelles;
}
public function setConnaissanceProtectionDonneesPersonnelles(?bool $connaissanceProtectionDonneesPersonnelles): static
{
$this->connaissanceProtectionDonneesPersonnelles = $connaissanceProtectionDonneesPersonnelles;
return $this;
}
public function isAccepteRecevoirPropositionCommercialMailTelephone(): ?bool
{
return $this->accepteRecevoirPropositionCommercialMailTelephone;
}
public function setAccepteRecevoirPropositionCommercialMailTelephone(?bool $accepteRecevoirPropositionCommercialMailTelephone): static
{
$this->accepteRecevoirPropositionCommercialMailTelephone = $accepteRecevoirPropositionCommercialMailTelephone;
return $this;
}
public function getStepSignup(): ?string
{
return $this->stepSignup;
}
public function setStepSignup(?string $stepSignup): static
{
$this->stepSignup = $stepSignup;
return $this;
}
public function isAdresseFiscaleFrance(): ?bool
{
return $this->adresseFiscaleFrance;
}
public function setAdresseFiscaleFrance(?bool $adresseFiscaleFrance): static
{
$this->adresseFiscaleFrance = $adresseFiscaleFrance;
return $this;
}
public function getAutoSignFolderNumber(): ?string
{
return $this->autoSignFolderNumber;
}
public function setAutoSignFolderNumber(?string $autoSignFolderNumber): static
{
$this->autoSignFolderNumber = $autoSignFolderNumber;
return $this;
}
}