<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Serializable;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\UtilisateurRepository")
* @UniqueEntity("UserName",message="Cette email est déjà utilisé")
* @UniqueEntity("idAg",message="Un agent ne peut avoir qu'un compte")
* @method string getUserIdentifier()*/
class Utilisateur implements UserInterface, Serializable
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="boolean")
*/
private $Etat;
/**
* @ORM\Column(type="string", length=255)
*/
private $Role;
/**
* @ORM\Column(type="date")
*/
private $date_created;
/**
* @ORM\Column(type="date")
*/
private $date_connected;
/**
* @ORM\Column(type="boolean")
*/
private $status;
/**
* @ORM\Column(type="string", length=255)
*/
private $UserName;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Length(
* min=8,
* minMessage="Mot de passe courte, au moins 8 caractères"
* )
*/
private $Password;
/**
* @var
*/
private $ancienPassWord;
/**
* @var
* @Assert\EqualTo(propertyPath="NouveauPassWord",message="Ne correspond pas au mot de passe")
*/
private $NouveauPassWord;
/**
* @Assert\EqualTo(propertyPath="password",message="Ne correspond pas au passe word")
*/
private $confirmerPassword;
private $oldPassword;
/**
* @Assert\Length(min = "8", minMessage = "Minimum 8 caracteurs")
*/
private $newPassword;
/**
* @Assert\EqualTo(propertyPath="newPassword",message="Ne correspond pas au nouveau passe word")
*/
private $confPassword;
/**
* @ORM\Column(type="string", length=255)
*/
private $langue;
/**
* @ORM\Column(type="boolean")
*/
private $flag_sms;
/**
* @ORM\Column(type="boolean")
*/
private $flag_voice_sms;
/**
* @ORM\Column(type="boolean")
*/
private $flag_voice_whatsapp;
/**
* @ORM\OneToMany(targetEntity=Paiement::class, mappedBy="IdAg")
*/
private $paiements;
/**
* @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="utilisateurs")
*/
private $ville;
/**
* @ORM\OneToMany(targetEntity=DepensesContenaire::class, mappedBy="IdAg")
*/
private $depensesContenaires;
/**
* @ORM\OneToMany(targetEntity=TransfertEnvoie::class, mappedBy="userValidated")
*/
private $transfertEnvoies;
/**
* @ORM\OneToOne(targetEntity=Agent::class, inversedBy="utilisateur", cascade={"persist", "remove"})
*/
private $idAg;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isMco;
/**
* @ORM\OneToMany(targetEntity=Depot::class, mappedBy="user")
*/
private $depots;
/**
* @ORM\OneToMany(targetEntity=Finance::class, mappedBy="userReceipt")
*/
private $finances;
/**
* @ORM\OneToMany(targetEntity=Finance::class, mappedBy="userCaisse")
*/
private $financeCaisses;
private $totalCaisse;
/**
* @ORM\Column(type="boolean")
*/
private $iSflagCalacul;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $caisse_localite;
/**
* @ORM\OneToMany(targetEntity=Reception::class, mappedBy="user")
*/
private $receptions;
/**
* @ORM\OneToMany(targetEntity=TmpConteneurReception::class, mappedBy="user")
*/
private $tmpConteneurReceptions;
/**
* @ORM\OneToMany(targetEntity=TmpReception::class, mappedBy="user")
*/
private $tmpReceptions;
public function __construct()
{
$this->date_connected = new \DateTime();
$this->date_created = new \DateTime();
$this->status = false;
$this->Etat = false;
$this->paiements = new ArrayCollection();
$this->depensesContenaires = new ArrayCollection();
$this->transfertEnvoies = new ArrayCollection();
$this->depots = new ArrayCollection();
$this->finances = new ArrayCollection();
$this->financeCaisses = new ArrayCollection();
$this->rapportClotures = new ArrayCollection();
$this->receptions = new ArrayCollection();
$this->tmpConteneurReceptions = new ArrayCollection();
$this->tmpReceptions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEtat(): ?bool
{
return $this->Etat;
}
public function setEtat(bool $Etat): self
{
$this->Etat = $Etat;
return $this;
}
public function getRole(): ?string
{
return $this->Role;
}
public function setRole(string $Role): self
{
$this->Role = $Role;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->date_created;
}
public function setDateCreated(\DateTimeInterface $date_created): self
{
$this->date_created = $date_created;
return $this;
}
public function getDateConnected(): ?\DateTimeInterface
{
return $this->date_connected;
}
public function setDateConnected(\DateTimeInterface $date_connected): self
{
$this->date_connected = $date_connected;
return $this;
}
public function getStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
public function getUserName(): ?string
{
return $this->UserName;
}
public function setUserName(string $UserName): self
{
$this->UserName = $UserName;
return $this;
}
public function getPassword(): ?string
{
return $this->Password;
}
public function setPassword(string $Password): self
{
$this->Password = $Password;
return $this;
}
/**
* String representation of object
* @link http://php.net/manual/en/serializable.serialize.php
* @return string the string representation of the object or null
* @since 5.1.0
*/
public function serialize()
{
return serialize([
$this->id,
$this->UserName,
$this->idAg,
$this->Password,
$this->date_connected,
]);
}
/**
* Constructs the object
* @link http://php.net/manual/en/serializable.unserialize.php
* @param string $serialized <p>
* The string representation of the object.
* </p>
* @return void
* @since 5.1.0
*/
public function unserialize($serialized)
{
list(
$this->id,
$this->UserName,
$this->idAg,
$this->Password,
$this->date_connected
) = unserialize($serialized,['allowed_classes' => false]);
}
/**
* Returns the roles granted to the user.
*
* public function getRoles()
* {
* return ['ROLE_USER'];
* }
*
* Alternatively, the roles might be stored on a ``roles`` property,
* and populated in any number of different ways when the user object
* is created.
*
* @return string[] The user roles
*/
public function getRoles()
{
return [$this->getRole()];
}
/**
* Returns the salt that was originally used to encode the password.
*
* This can return null if the password was not encoded using a salt.
*
* @return string|null The salt
*/
public function getSalt()
{
// TODO: Implement getSalt() method.
}
/**
* Removes sensitive data from the user.
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*/
public function eraseCredentials()
{
// TODO: Implement eraseCredentials() method.
}
/**
* @return mixed
*/
public function getAncienPassWord()
{
return $this->ancienPassWord;
}
/**
* @param mixed $ancienPassWord
*/
public function setAncienPassWord($ancienPassWord)
{
$this->ancienPassWord = $ancienPassWord;
}
/**
* @return mixed
*/
public function getNouveauPassWord()
{
return $this->NouveauPassWord;
}
/**
* @param mixed $NouveauPassWord
*/
public function setNouveauPassWord($NouveauPassWord)
{
$this->NouveauPassWord = $NouveauPassWord;
}
/**
* @return mixed
*/
public function getConfirmerPassword()
{
return $this->confirmerPassword;
}
/**
* @param mixed $confirmerPassword
*/
public function setConfirmerPassword($confirmerPassword)
{
$this->confirmerPassword = $confirmerPassword;
}
/**
* @return mixed
*/
public function getOldPassword()
{
return $this->oldPassword;
}
/**
* @param mixed $oldPassword
*/
public function setOldPassword($oldPassword)
{
$this->oldPassword = $oldPassword;
}
/**
* @return mixed
*/
public function getNewPassword()
{
return $this->newPassword;
}
/**
* @param mixed $newPassword
*/
public function setNewPassword($newPassword)
{
$this->newPassword = $newPassword;
}
/**
* @return mixed
*/
public function getConfPassword()
{
return $this->confPassword;
}
/**
* @param mixed $confPassword
*/
public function setConfPassword($confPassword)
{
$this->confPassword = $confPassword;
}
public function getLangue(): ?string
{
return $this->langue;
}
public function setLangue(string $langue): self
{
$this->langue = $langue;
return $this;
}
public function getFlagSms(): ?bool
{
return $this->flag_sms;
}
public function setFlagSms(bool $flag_sms): self
{
$this->flag_sms = $flag_sms;
return $this;
}
public function getFlagVoiceSms(): ?bool
{
return $this->flag_voice_sms;
}
public function setFlagVoiceSms(bool $flag_voice_sms): self
{
$this->flag_voice_sms = $flag_voice_sms;
return $this;
}
/**
* @return mixed
*/
public function getFlagVoiceWhatsapp()
{
return $this->flag_voice_whatsapp;
}
/**
* @param mixed $flag_voice_whatsapp
*/
public function setFlagVoiceWhatsapp($flag_voice_whatsapp)
{
$this->flag_voice_whatsapp = $flag_voice_whatsapp;
}
public function __call($name, $arguments)
{
// TODO: Implement @method string getUserIdentifier()
}
/**
* @return Collection<int, Paiement>
*/
public function getPaiements(): Collection
{
return $this->paiements;
}
public function addPaiement(Paiement $paiement): self
{
if (!$this->paiements->contains($paiement)) {
$this->paiements[] = $paiement;
$paiement->setIdAg($this);
}
return $this;
}
public function removePaiement(Paiement $paiement): self
{
if ($this->paiements->removeElement($paiement)) {
// set the owning side to null (unless already changed)
if ($paiement->getIdAg() === $this) {
$paiement->setIdAg(null);
}
}
return $this;
}
public function getVille(): ?Ville
{
return $this->ville;
}
public function setVille(?Ville $ville): self
{
$this->ville = $ville;
return $this;
}
/**
* @return Collection<int, DepensesContenaire>
*/
public function getDepensesContenaires(): Collection
{
return $this->depensesContenaires;
}
public function addDepensesContenaire(DepensesContenaire $depensesContenaire): self
{
if (!$this->depensesContenaires->contains($depensesContenaire)) {
$this->depensesContenaires[] = $depensesContenaire;
$depensesContenaire->setIdAg($this);
}
return $this;
}
public function removeDepensesContenaire(DepensesContenaire $depensesContenaire): self
{
if ($this->depensesContenaires->removeElement($depensesContenaire)) {
// set the owning side to null (unless already changed)
if ($depensesContenaire->getIdAg() === $this) {
$depensesContenaire->setIdAg(null);
}
}
return $this;
}
/**
* @return Collection<int, TransfertEnvoie>
*/
public function getTransfertEnvoies(): Collection
{
return $this->transfertEnvoies;
}
public function addTransfertEnvoie(TransfertEnvoie $transfertEnvoie): self
{
if (!$this->transfertEnvoies->contains($transfertEnvoie)) {
$this->transfertEnvoies[] = $transfertEnvoie;
$transfertEnvoie->setUserValidated($this);
}
return $this;
}
public function removeTransfertEnvoie(TransfertEnvoie $transfertEnvoie): self
{
if ($this->transfertEnvoies->removeElement($transfertEnvoie)) {
// set the owning side to null (unless already changed)
if ($transfertEnvoie->getUserValidated() === $this) {
$transfertEnvoie->setUserValidated(null);
}
}
return $this;
}
public function getIdAg(): ?Agent
{
return $this->idAg;
}
public function setIdAg(?Agent $idAg): self
{
$this->idAg = $idAg;
return $this;
}
public function isIsMco(): ?bool
{
return $this->isMco;
}
public function setIsMco(?bool $isMco): self
{
$this->isMco = $isMco;
return $this;
}
/**
* @return Collection<int, Depot>
*/
public function getDepots(): Collection
{
return $this->depots;
}
public function addDepot(Depot $depot): self
{
if (!$this->depots->contains($depot)) {
$this->depots[] = $depot;
$depot->setUser($this);
}
return $this;
}
public function removeDepot(Depot $depot): self
{
if ($this->depots->removeElement($depot)) {
// set the owning side to null (unless already changed)
if ($depot->getUser() === $this) {
$depot->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Finance>
*/
public function getFinances(): Collection
{
return $this->finances;
}
public function addFinance(Finance $finance): self
{
if (!$this->finances->contains($finance)) {
$this->finances[] = $finance;
$finance->setUserReceipt($this);
}
return $this;
}
public function removeFinance(Finance $finance): self
{
if ($this->finances->removeElement($finance)) {
// set the owning side to null (unless already changed)
if ($finance->getUserReceipt() === $this) {
$finance->setUserReceipt(null);
}
}
return $this;
}
/**
* @return Collection<int, Finance>
*/
public function getFinanceCaisses(): Collection
{
return $this->financeCaisses;
}
public function addFinanceCaiss(Finance $financeCaiss): self
{
if (!$this->financeCaisses->contains($financeCaiss)) {
$this->financeCaisses[] = $financeCaiss;
$financeCaiss->setUserCaisse($this);
}
return $this;
}
public function removeFinanceCaiss(Finance $financeCaiss): self
{
if ($this->financeCaisses->removeElement($financeCaiss)) {
// set the owning side to null (unless already changed)
if ($financeCaiss->getUserCaisse() === $this) {
$financeCaiss->setUserCaisse(null);
}
}
return $this;
}
public function getTotalCaissse()
{
}
/**
* @return mixed
*/
public function getTotalCaisse()
{
$total = 0;
foreach($this->getFinanceCaisses() as $v){
$total = $total + $v->getMontant();
}
return $this->totalCaisse = $total;
}
public function isISflagCalacul(): ?bool
{
return $this->iSflagCalacul;
}
public function setISflagCalacul(bool $iSflagCalacul): self
{
$this->iSflagCalacul = $iSflagCalacul;
return $this;
}
public function __toString()
{
return $this->getIdAg()->getNomAg();
}
public function getCaisseLocalite(): ?string
{
return $this->caisse_localite;
}
public function setCaisseLocalite(?string $caisse_localite): self
{
$this->caisse_localite = $caisse_localite;
return $this;
}
/**
* @return Collection<int, Reception>
*/
public function getReceptions(): Collection
{
return $this->receptions;
}
public function addReception(Reception $reception): self
{
if (!$this->receptions->contains($reception)) {
$this->receptions[] = $reception;
$reception->setUser($this);
}
return $this;
}
public function removeReception(Reception $reception): self
{
if ($this->receptions->removeElement($reception)) {
// set the owning side to null (unless already changed)
if ($reception->getUser() === $this) {
$reception->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, TmpConteneurReception>
*/
public function getTmpConteneurReceptions(): Collection
{
return $this->tmpConteneurReceptions;
}
public function addTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
{
if (!$this->tmpConteneurReceptions->contains($tmpConteneurReception)) {
$this->tmpConteneurReceptions[] = $tmpConteneurReception;
$tmpConteneurReception->setUser($this);
}
return $this;
}
public function removeTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
{
if ($this->tmpConteneurReceptions->removeElement($tmpConteneurReception)) {
// set the owning side to null (unless already changed)
if ($tmpConteneurReception->getUser() === $this) {
$tmpConteneurReception->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, TmpReception>
*/
public function getTmpReceptions(): Collection
{
return $this->tmpReceptions;
}
public function addTmpReception(TmpReception $tmpReception): self
{
if (!$this->tmpReceptions->contains($tmpReception)) {
$this->tmpReceptions[] = $tmpReception;
$tmpReception->setUser($this);
}
return $this;
}
public function removeTmpReception(TmpReception $tmpReception): self
{
if ($this->tmpReceptions->removeElement($tmpReception)) {
// set the owning side to null (unless already changed)
if ($tmpReception->getUser() === $this) {
$tmpReception->setUser(null);
}
}
return $this;
}
}