src/Entity/Utilisateur.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Serializable;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\UtilisateurRepository")
  12.  * @UniqueEntity("UserName",message="Cette email est déjà utilisé")
  13.  * @UniqueEntity("idAg",message="Un agent ne peut avoir qu'un compte")
  14.  * @method string getUserIdentifier()*/
  15. class Utilisateur implements UserInterfaceSerializable
  16. {
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue()
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="boolean")
  25.      */
  26.     private $Etat;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $Role;
  31.     /**
  32.      * @ORM\Column(type="date")
  33.      */
  34.     private $date_created;
  35.     /**
  36.      * @ORM\Column(type="date")
  37.      */
  38.     private $date_connected;
  39.     /**
  40.      * @ORM\Column(type="boolean")
  41.      */
  42.     private $status;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $UserName;
  47.     /**
  48.      * @ORM\Column(type="string", length=255)
  49.      * @Assert\Length(
  50.      *     min=8,
  51.      *     minMessage="Mot de passe courte, au moins 8 caractères"
  52.      * )
  53.      */
  54.     private $Password;
  55.     /**
  56.      * @var
  57.      */
  58.     private $ancienPassWord;
  59.     /**
  60.      * @var
  61.      * @Assert\EqualTo(propertyPath="NouveauPassWord",message="Ne correspond pas au mot de passe")
  62.      */
  63.     private $NouveauPassWord;
  64.     /**
  65.      * @Assert\EqualTo(propertyPath="password",message="Ne correspond pas au passe word")
  66.      */
  67.     private $confirmerPassword;
  68.     private $oldPassword;
  69.     /**
  70.      * @Assert\Length(min = "8", minMessage = "Minimum 8 caracteurs")
  71.      */
  72.     private $newPassword;
  73.     /**
  74.      * @Assert\EqualTo(propertyPath="newPassword",message="Ne correspond pas au nouveau passe word")
  75.      */
  76.     private $confPassword;
  77.     /**
  78.      * @ORM\Column(type="string", length=255)
  79.      */
  80.     private $langue;
  81.     /**
  82.      * @ORM\Column(type="boolean")
  83.      */
  84.     private $flag_sms;
  85.     /**
  86.      * @ORM\Column(type="boolean")
  87.      */
  88.     private $flag_voice_sms;
  89.     /**
  90.      * @ORM\Column(type="boolean")
  91.      */
  92.     private $flag_voice_whatsapp;
  93.     /**
  94.      * @ORM\OneToMany(targetEntity=Paiement::class, mappedBy="IdAg")
  95.      */
  96.     private $paiements;
  97.     /**
  98.      * @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="utilisateurs")
  99.      */
  100.     private $ville;
  101.     /**
  102.      * @ORM\OneToMany(targetEntity=DepensesContenaire::class, mappedBy="IdAg")
  103.      */
  104.     private $depensesContenaires;
  105.     /**
  106.      * @ORM\OneToMany(targetEntity=TransfertEnvoie::class, mappedBy="userValidated")
  107.      */
  108.     private $transfertEnvoies;
  109.     /**
  110.      * @ORM\OneToOne(targetEntity=Agent::class, inversedBy="utilisateur", cascade={"persist", "remove"})
  111.      */
  112.     private $idAg;
  113.     /**
  114.      * @ORM\Column(type="boolean", nullable=true)
  115.      */
  116.     private $isMco;
  117.     /**
  118.      * @ORM\OneToMany(targetEntity=Depot::class, mappedBy="user")
  119.      */
  120.     private $depots;
  121.     /**
  122.      * @ORM\OneToMany(targetEntity=Finance::class, mappedBy="userReceipt")
  123.      */
  124.     private $finances;
  125.     /**
  126.      * @ORM\OneToMany(targetEntity=Finance::class, mappedBy="userCaisse")
  127.      */
  128.     private $financeCaisses;
  129.     private $totalCaisse;
  130.     /**
  131.      * @ORM\Column(type="boolean")
  132.      */
  133.     private $iSflagCalacul;
  134.     /**
  135.      * @ORM\Column(type="string", length=255, nullable=true)
  136.      */
  137.     private $caisse_localite;
  138.     /**
  139.      * @ORM\OneToMany(targetEntity=Reception::class, mappedBy="user")
  140.      */
  141.     private $receptions;
  142.     /**
  143.      * @ORM\OneToMany(targetEntity=TmpConteneurReception::class, mappedBy="user")
  144.      */
  145.     private $tmpConteneurReceptions;
  146.     /**
  147.      * @ORM\OneToMany(targetEntity=TmpReception::class, mappedBy="user")
  148.      */
  149.     private $tmpReceptions;
  150.     public function __construct()
  151.     {
  152.         $this->date_connected = new \DateTime();
  153.         $this->date_created = new \DateTime();
  154.         $this->status false;
  155.         $this->Etat false;
  156.         $this->paiements = new ArrayCollection();
  157.         $this->depensesContenaires = new ArrayCollection();
  158.         $this->transfertEnvoies = new ArrayCollection();
  159.         $this->depots = new ArrayCollection();
  160.         $this->finances = new ArrayCollection();
  161.         $this->financeCaisses = new ArrayCollection();
  162.         $this->rapportClotures = new ArrayCollection();
  163.         $this->receptions = new ArrayCollection();
  164.         $this->tmpConteneurReceptions = new ArrayCollection();
  165.         $this->tmpReceptions = new ArrayCollection();
  166.     }
  167.     public function getId(): ?int
  168.     {
  169.         return $this->id;
  170.     }
  171.     public function getEtat(): ?bool
  172.     {
  173.         return $this->Etat;
  174.     }
  175.     public function setEtat(bool $Etat): self
  176.     {
  177.         $this->Etat $Etat;
  178.         return $this;
  179.     }
  180.     public function getRole(): ?string
  181.     {
  182.         return $this->Role;
  183.     }
  184.     public function setRole(string $Role): self
  185.     {
  186.         $this->Role $Role;
  187.         return $this;
  188.     }
  189.     public function getDateCreated(): ?\DateTimeInterface
  190.     {
  191.         return $this->date_created;
  192.     }
  193.     public function setDateCreated(\DateTimeInterface $date_created): self
  194.     {
  195.         $this->date_created $date_created;
  196.         return $this;
  197.     }
  198.     public function getDateConnected(): ?\DateTimeInterface
  199.     {
  200.         return $this->date_connected;
  201.     }
  202.     public function setDateConnected(\DateTimeInterface $date_connected): self
  203.     {
  204.         $this->date_connected $date_connected;
  205.         return $this;
  206.     }
  207.     public function getStatus(): ?bool
  208.     {
  209.         return $this->status;
  210.     }
  211.     public function setStatus(bool $status): self
  212.     {
  213.         $this->status $status;
  214.         return $this;
  215.     }
  216.     public function getUserName(): ?string
  217.     {
  218.         return $this->UserName;
  219.     }
  220.     public function setUserName(string $UserName): self
  221.     {
  222.         $this->UserName $UserName;
  223.         return $this;
  224.     }
  225.     public function getPassword(): ?string
  226.     {
  227.         return $this->Password;
  228.     }
  229.     public function setPassword(string $Password): self
  230.     {
  231.         $this->Password $Password;
  232.         return $this;
  233.     }
  234.     /**
  235.      * String representation of object
  236.      * @link http://php.net/manual/en/serializable.serialize.php
  237.      * @return string the string representation of the object or null
  238.      * @since 5.1.0
  239.      */
  240.     public function serialize()
  241.     {
  242.         return serialize([
  243.             $this->id,
  244.             $this->UserName,
  245.             $this->idAg,
  246.             $this->Password,
  247.             $this->date_connected,
  248.         ]);
  249.     }
  250.     /**
  251.      * Constructs the object
  252.      * @link http://php.net/manual/en/serializable.unserialize.php
  253.      * @param string $serialized <p>
  254.      * The string representation of the object.
  255.      * </p>
  256.      * @return void
  257.      * @since 5.1.0
  258.      */
  259.     public function unserialize($serialized)
  260.     {
  261.         list(
  262.             $this->id,
  263.             $this->UserName,
  264.             $this->idAg,
  265.             $this->Password,
  266.             $this->date_connected
  267.             ) = unserialize($serialized,['allowed_classes' => false]);
  268.     }
  269.     /**
  270.      * Returns the roles granted to the user.
  271.      *
  272.      *     public function getRoles()
  273.      *     {
  274.      *         return ['ROLE_USER'];
  275.      *     }
  276.      *
  277.      * Alternatively, the roles might be stored on a ``roles`` property,
  278.      * and populated in any number of different ways when the user object
  279.      * is created.
  280.      *
  281.      * @return string[] The user roles
  282.      */
  283.     public function getRoles()
  284.     {
  285.         return [$this->getRole()];
  286.     }
  287.     /**
  288.      * Returns the salt that was originally used to encode the password.
  289.      *
  290.      * This can return null if the password was not encoded using a salt.
  291.      *
  292.      * @return string|null The salt
  293.      */
  294.     public function getSalt()
  295.     {
  296.         // TODO: Implement getSalt() method.
  297.     }
  298.     /**
  299.      * Removes sensitive data from the user.
  300.      *
  301.      * This is important if, at any given point, sensitive information like
  302.      * the plain-text password is stored on this object.
  303.      */
  304.     public function eraseCredentials()
  305.     {
  306.         // TODO: Implement eraseCredentials() method.
  307.     }
  308.     /**
  309.      * @return mixed
  310.      */
  311.     public function getAncienPassWord()
  312.     {
  313.         return $this->ancienPassWord;
  314.     }
  315.     /**
  316.      * @param mixed $ancienPassWord
  317.      */
  318.     public function setAncienPassWord($ancienPassWord)
  319.     {
  320.         $this->ancienPassWord $ancienPassWord;
  321.     }
  322.     /**
  323.      * @return mixed
  324.      */
  325.     public function getNouveauPassWord()
  326.     {
  327.         return $this->NouveauPassWord;
  328.     }
  329.     /**
  330.      * @param mixed $NouveauPassWord
  331.      */
  332.     public function setNouveauPassWord($NouveauPassWord)
  333.     {
  334.         $this->NouveauPassWord $NouveauPassWord;
  335.     }
  336.     /**
  337.      * @return mixed
  338.      */
  339.     public function getConfirmerPassword()
  340.     {
  341.         return $this->confirmerPassword;
  342.     }
  343.     /**
  344.      * @param mixed $confirmerPassword
  345.      */
  346.     public function setConfirmerPassword($confirmerPassword)
  347.     {
  348.         $this->confirmerPassword $confirmerPassword;
  349.     }
  350.     /**
  351.      * @return mixed
  352.      */
  353.     public function getOldPassword()
  354.     {
  355.         return $this->oldPassword;
  356.     }
  357.     /**
  358.      * @param mixed $oldPassword
  359.      */
  360.     public function setOldPassword($oldPassword)
  361.     {
  362.         $this->oldPassword $oldPassword;
  363.     }
  364.     /**
  365.      * @return mixed
  366.      */
  367.     public function getNewPassword()
  368.     {
  369.         return $this->newPassword;
  370.     }
  371.     /**
  372.      * @param mixed $newPassword
  373.      */
  374.     public function setNewPassword($newPassword)
  375.     {
  376.         $this->newPassword $newPassword;
  377.     }
  378.     /**
  379.      * @return mixed
  380.      */
  381.     public function getConfPassword()
  382.     {
  383.         return $this->confPassword;
  384.     }
  385.     /**
  386.      * @param mixed $confPassword
  387.      */
  388.     public function setConfPassword($confPassword)
  389.     {
  390.         $this->confPassword $confPassword;
  391.     }
  392.     public function getLangue(): ?string
  393.     {
  394.         return $this->langue;
  395.     }
  396.     public function setLangue(string $langue): self
  397.     {
  398.         $this->langue $langue;
  399.         return $this;
  400.     }
  401.     public function getFlagSms(): ?bool
  402.     {
  403.         return $this->flag_sms;
  404.     }
  405.     public function setFlagSms(bool $flag_sms): self
  406.     {
  407.         $this->flag_sms $flag_sms;
  408.         return $this;
  409.     }
  410.     public function getFlagVoiceSms(): ?bool
  411.     {
  412.         return $this->flag_voice_sms;
  413.     }
  414.     public function setFlagVoiceSms(bool $flag_voice_sms): self
  415.     {
  416.         $this->flag_voice_sms $flag_voice_sms;
  417.         return $this;
  418.     }
  419.     /**
  420.      * @return mixed
  421.      */
  422.     public function getFlagVoiceWhatsapp()
  423.     {
  424.         return $this->flag_voice_whatsapp;
  425.     }
  426.     /**
  427.      * @param mixed $flag_voice_whatsapp
  428.      */
  429.     public function setFlagVoiceWhatsapp($flag_voice_whatsapp)
  430.     {
  431.         $this->flag_voice_whatsapp $flag_voice_whatsapp;
  432.     }
  433.     public function __call($name$arguments)
  434.     {
  435.         // TODO: Implement @method string getUserIdentifier()
  436.     }
  437.     /**
  438.      * @return Collection<int, Paiement>
  439.      */
  440.     public function getPaiements(): Collection
  441.     {
  442.         return $this->paiements;
  443.     }
  444.     public function addPaiement(Paiement $paiement): self
  445.     {
  446.         if (!$this->paiements->contains($paiement)) {
  447.             $this->paiements[] = $paiement;
  448.             $paiement->setIdAg($this);
  449.         }
  450.         return $this;
  451.     }
  452.     public function removePaiement(Paiement $paiement): self
  453.     {
  454.         if ($this->paiements->removeElement($paiement)) {
  455.             // set the owning side to null (unless already changed)
  456.             if ($paiement->getIdAg() === $this) {
  457.                 $paiement->setIdAg(null);
  458.             }
  459.         }
  460.         return $this;
  461.     }
  462.     public function getVille(): ?Ville
  463.     {
  464.         return $this->ville;
  465.     }
  466.     public function setVille(?Ville $ville): self
  467.     {
  468.         $this->ville $ville;
  469.         return $this;
  470.     }
  471.     /**
  472.      * @return Collection<int, DepensesContenaire>
  473.      */
  474.     public function getDepensesContenaires(): Collection
  475.     {
  476.         return $this->depensesContenaires;
  477.     }
  478.     public function addDepensesContenaire(DepensesContenaire $depensesContenaire): self
  479.     {
  480.         if (!$this->depensesContenaires->contains($depensesContenaire)) {
  481.             $this->depensesContenaires[] = $depensesContenaire;
  482.             $depensesContenaire->setIdAg($this);
  483.         }
  484.         return $this;
  485.     }
  486.     public function removeDepensesContenaire(DepensesContenaire $depensesContenaire): self
  487.     {
  488.         if ($this->depensesContenaires->removeElement($depensesContenaire)) {
  489.             // set the owning side to null (unless already changed)
  490.             if ($depensesContenaire->getIdAg() === $this) {
  491.                 $depensesContenaire->setIdAg(null);
  492.             }
  493.         }
  494.         return $this;
  495.     }
  496.     /**
  497.      * @return Collection<int, TransfertEnvoie>
  498.      */
  499.     public function getTransfertEnvoies(): Collection
  500.     {
  501.         return $this->transfertEnvoies;
  502.     }
  503.     public function addTransfertEnvoie(TransfertEnvoie $transfertEnvoie): self
  504.     {
  505.         if (!$this->transfertEnvoies->contains($transfertEnvoie)) {
  506.             $this->transfertEnvoies[] = $transfertEnvoie;
  507.             $transfertEnvoie->setUserValidated($this);
  508.         }
  509.         return $this;
  510.     }
  511.     public function removeTransfertEnvoie(TransfertEnvoie $transfertEnvoie): self
  512.     {
  513.         if ($this->transfertEnvoies->removeElement($transfertEnvoie)) {
  514.             // set the owning side to null (unless already changed)
  515.             if ($transfertEnvoie->getUserValidated() === $this) {
  516.                 $transfertEnvoie->setUserValidated(null);
  517.             }
  518.         }
  519.         return $this;
  520.     }
  521.     public function getIdAg(): ?Agent
  522.     {
  523.         return $this->idAg;
  524.     }
  525.     public function setIdAg(?Agent $idAg): self
  526.     {
  527.         $this->idAg $idAg;
  528.         return $this;
  529.     }
  530.     public function isIsMco(): ?bool
  531.     {
  532.         return $this->isMco;
  533.     }
  534.     public function setIsMco(?bool $isMco): self
  535.     {
  536.         $this->isMco $isMco;
  537.         return $this;
  538.     }
  539.     /**
  540.      * @return Collection<int, Depot>
  541.      */
  542.     public function getDepots(): Collection
  543.     {
  544.         return $this->depots;
  545.     }
  546.     public function addDepot(Depot $depot): self
  547.     {
  548.         if (!$this->depots->contains($depot)) {
  549.             $this->depots[] = $depot;
  550.             $depot->setUser($this);
  551.         }
  552.         return $this;
  553.     }
  554.     public function removeDepot(Depot $depot): self
  555.     {
  556.         if ($this->depots->removeElement($depot)) {
  557.             // set the owning side to null (unless already changed)
  558.             if ($depot->getUser() === $this) {
  559.                 $depot->setUser(null);
  560.             }
  561.         }
  562.         return $this;
  563.     }
  564.     /**
  565.      * @return Collection<int, Finance>
  566.      */
  567.     public function getFinances(): Collection
  568.     {
  569.         return $this->finances;
  570.     }
  571.     public function addFinance(Finance $finance): self
  572.     {
  573.         if (!$this->finances->contains($finance)) {
  574.             $this->finances[] = $finance;
  575.             $finance->setUserReceipt($this);
  576.         }
  577.         return $this;
  578.     }
  579.     public function removeFinance(Finance $finance): self
  580.     {
  581.         if ($this->finances->removeElement($finance)) {
  582.             // set the owning side to null (unless already changed)
  583.             if ($finance->getUserReceipt() === $this) {
  584.                 $finance->setUserReceipt(null);
  585.             }
  586.         }
  587.         return $this;
  588.     }
  589.     /**
  590.      * @return Collection<int, Finance>
  591.      */
  592.     public function getFinanceCaisses(): Collection
  593.     {
  594.         return $this->financeCaisses;
  595.     }
  596.     public function addFinanceCaiss(Finance $financeCaiss): self
  597.     {
  598.         if (!$this->financeCaisses->contains($financeCaiss)) {
  599.             $this->financeCaisses[] = $financeCaiss;
  600.             $financeCaiss->setUserCaisse($this);
  601.         }
  602.         return $this;
  603.     }
  604.     public function removeFinanceCaiss(Finance $financeCaiss): self
  605.     {
  606.         if ($this->financeCaisses->removeElement($financeCaiss)) {
  607.             // set the owning side to null (unless already changed)
  608.             if ($financeCaiss->getUserCaisse() === $this) {
  609.                 $financeCaiss->setUserCaisse(null);
  610.             }
  611.         }
  612.         return $this;
  613.     }
  614.     public function getTotalCaissse()
  615.     {
  616.     }
  617.     /**
  618.      * @return mixed
  619.      */
  620.     public function getTotalCaisse()
  621.     {
  622.         $total 0;
  623.         foreach($this->getFinanceCaisses() as $v){
  624.             $total $total $v->getMontant();
  625.         }
  626.         return $this->totalCaisse $total;
  627.     }
  628.     public function isISflagCalacul(): ?bool
  629.     {
  630.         return $this->iSflagCalacul;
  631.     }
  632.     public function setISflagCalacul(bool $iSflagCalacul): self
  633.     {
  634.         $this->iSflagCalacul $iSflagCalacul;
  635.         return $this;
  636.     }
  637. public function __toString()
  638. {
  639.     return $this->getIdAg()->getNomAg();
  640. }
  641. public function getCaisseLocalite(): ?string
  642. {
  643.     return $this->caisse_localite;
  644. }
  645. public function setCaisseLocalite(?string $caisse_localite): self
  646. {
  647.     $this->caisse_localite $caisse_localite;
  648.     return $this;
  649. }
  650. /**
  651.  * @return Collection<int, Reception>
  652.  */
  653. public function getReceptions(): Collection
  654. {
  655.     return $this->receptions;
  656. }
  657. public function addReception(Reception $reception): self
  658. {
  659.     if (!$this->receptions->contains($reception)) {
  660.         $this->receptions[] = $reception;
  661.         $reception->setUser($this);
  662.     }
  663.     return $this;
  664. }
  665. public function removeReception(Reception $reception): self
  666. {
  667.     if ($this->receptions->removeElement($reception)) {
  668.         // set the owning side to null (unless already changed)
  669.         if ($reception->getUser() === $this) {
  670.             $reception->setUser(null);
  671.         }
  672.     }
  673.     return $this;
  674. }
  675. /**
  676.  * @return Collection<int, TmpConteneurReception>
  677.  */
  678. public function getTmpConteneurReceptions(): Collection
  679. {
  680.     return $this->tmpConteneurReceptions;
  681. }
  682. public function addTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
  683. {
  684.     if (!$this->tmpConteneurReceptions->contains($tmpConteneurReception)) {
  685.         $this->tmpConteneurReceptions[] = $tmpConteneurReception;
  686.         $tmpConteneurReception->setUser($this);
  687.     }
  688.     return $this;
  689. }
  690. public function removeTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
  691. {
  692.     if ($this->tmpConteneurReceptions->removeElement($tmpConteneurReception)) {
  693.         // set the owning side to null (unless already changed)
  694.         if ($tmpConteneurReception->getUser() === $this) {
  695.             $tmpConteneurReception->setUser(null);
  696.         }
  697.     }
  698.     return $this;
  699. }
  700. /**
  701.  * @return Collection<int, TmpReception>
  702.  */
  703. public function getTmpReceptions(): Collection
  704. {
  705.     return $this->tmpReceptions;
  706. }
  707. public function addTmpReception(TmpReception $tmpReception): self
  708. {
  709.     if (!$this->tmpReceptions->contains($tmpReception)) {
  710.         $this->tmpReceptions[] = $tmpReception;
  711.         $tmpReception->setUser($this);
  712.     }
  713.     return $this;
  714. }
  715. public function removeTmpReception(TmpReception $tmpReception): self
  716. {
  717.     if ($this->tmpReceptions->removeElement($tmpReception)) {
  718.         // set the owning side to null (unless already changed)
  719.         if ($tmpReception->getUser() === $this) {
  720.             $tmpReception->setUser(null);
  721.         }
  722.     }
  723.     return $this;
  724. }
  725. }