src/Entity/usr.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;            // pour les relations OneToMany
  5. use Doctrine\Common\Collections\Collection;                // pour les relations OneToMany
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use App\Repository\usrRepository;
  11. #[ORM\Entity(repositoryClassusrRepository::class)]
  12. #[UniqueEntity(fields: ["username"], message"Cet identifiant (login) ne peut pas être accepté (dbl)")]
  13. #[UniqueEntity(fields: ["usremail"], ignoreNull"usremail"message"Cet E-mail ne peut pas être accepté (red)")]
  14. #[ORM\Table(name"usr"options: ["comment" => "Les utilisateurs"])]
  15. class usr implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     public $daterange;                 // période dans rec
  18.     public $daterangeactif;           // prise en compte période dans rec
  19.     public $usrpwdajo;                // pour saisie pwd ajo
  20.     public $usrpwdmaj;               // pour saisie pwd maj
  21.     public $usrpwdconf;              // pour saisie pwd confirmation
  22.     public $usracccgu;                // pour accept CGU ajo
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column(name"usrid"type"integer"options: ["comment" => "Id utilisateur"])]
  26.     private ?int $usrid null;
  27.     #[Assert\Length(
  28.             min10,
  29.             max20,
  30.             minMessage"Votre identifiant (login) doit être composé de {{ limit }} caractères au minimum",
  31.             maxMessage"Votre identifiant (login) doit être composé de {{ limit }} caractères au maximum"
  32.         )
  33.     ]
  34.     #[ORM\Column(name"username"type"string"length20uniquefalseoptions: ["comment" => "Login utilisateur"])]
  35.     private $username null;
  36.     #[ORM\Column(options: ["comment"=> "Les rôles du user"])]
  37.     private array $roles = [];
  38.     #[ORM\Column(name"password"type"string"length255nullabletrueoptions: ["comment"=> "Mot de passe"])]
  39.     private $password null;
  40.     #[Assert\NotBlank(message"Le nom doit être obligatoirement renseigné")]
  41.     #[Assert\NotNull(message"Le nom doit être obligatoirement renseigné")]
  42.     #[ORM\Column(name"usrnom"type"string"length50nullablefalseoptions: ["comment"=> "Nom"])]
  43.     private $usrnom null;
  44.     #[ORM\Column(name"usrpre"type"string"length30nullablefalseoptions: ["comment"=> "Prénom"])]
  45.     private $usrpre null;
  46.     #[ORM\Column(name"usrorg"type"string"length100nullablefalseoptions: ["comment"=> "Organisme"])]
  47.     private $usrorg null;
  48.     #[Assert\Email(message"Cet e-mail n'est pas un e-mail valide")]
  49.     #[ORM\Column(name"usremail"type"string"length255nullablefalseoptions: ["comment"=> "E-mail unique"])]
  50.     private $usremail null;
  51.     #[Assert\Length(
  52.             exactly5,
  53.             exactMessage"Le code postal doit être composé de {{ limit }} caractères numériques"
  54.         )
  55.     ]
  56.     #[ORM\Column(name"usrcodpos"type"string"length5nullablefalseoptions: ["comment"=> "Code postal"])]
  57.     private $usrcodpos null;
  58.     #[ORM\Column(name"usrstatut"type"smallint"options: ["default" => 0"comment"=> "Statut (0=attente, 1=validé, 2=bloqué)"])]
  59.     private $usrstatut 0;
  60.     #[ORM\Column(name"usrdatcre"type"datetime"nullabletrueoptions: ["comment"=> "Date création du compte"])]
  61.     private $usrdatcre;
  62.     // ouverture de compte, vérif e-mail
  63.     #[ORM\Column(name"usrmaictltok"type"string"length255nullabletrueoptions: ["comment"=> "CSRF token vérification e-mail ok"])]
  64.     private $usrmaictltok;
  65.     
  66.     // ouverture de compte, temps (date) limite de vérification e-mail
  67.     #[ORM\Column(name"usrmaictllim"type"integer"nullabletrueoptions: ["comment"=> "Timestamp limite de vérification e-mail"])]
  68.     private $usrmaictllim;
  69.     
  70.     // suivi login
  71.     #[ORM\Column(name"usrdatlog"type"datetime"nullabletrueoptions: ["comment"=> "Date dernière connexion (login)"])]
  72.     private $usrdatlog;
  73.     #[ORM\Column(name"usrdatenvlog"type"datetime"nullabletrueoptions: ["comment"=> "Date dernier renvoi identifiant (login)"])]
  74.     private $usrdatenvlog;
  75.     #[ORM\Column(name"usrnbenvlog"type"smallint"nullablefalseoptions: ["default"=>"0","comment"=> "Nb ddes renvoi de l'identifiant (login)"])]
  76.     private $usrnbenvlog "0";
  77.     // demande changement de pwd (et création compte)
  78.     #[ORM\Column(name"usrdatchgpwd"type"datetime"nullabletrueoptions: ["comment"=> "Date dernier chgt PWD"])]
  79.     private $usrdatchgpwd;
  80.     #[ORM\Column(name"usrdatenvchgpwd"type"datetime"nullabletrueoptions: ["comment"=> "Date envoi mail dde chgt PWD"])]
  81.     private $usrdatenvchgpwd;
  82.     #[ORM\Column(name"usrchgpwdtok"type"string"length255nullabletrueoptions: ["comment"=> "CSRF token dde chgt PWD"])]
  83.     private $usrchgpwdtok;    // ex USRMAICTLTOK
  84.     #[ORM\Column(name"usrdatddechgpwd"type"integer"nullabletrueoptions: ["comment"=> "Timestamp dde chgt PWD"])]
  85.     private $usrdatddechgpwd;
  86.     #[ORM\Column(name"usrnbenvpwd"type"smallint"nullablefalseoptions: ["default"=>"0","comment"=> "Nb ddes changement de PWD"])]
  87.     private $usrnbenvpwd "0";
  88.     // MANY TO ONE ======================
  89.     /** Catégorie d'appartenance du usr */
  90.     #[ORM\ManyToOne(targetEntity:"cat"inversedBy:"usrids"cascade:["persist"])]
  91.     #[ORM\JoinColumn(name:"catid"referencedColumnName:"catid"nullable:false)]
  92.     private $catid;
  93.     
  94.     /** Profil du usr */
  95.     #[ORM\ManyToOne(targetEntity:"prf"inversedBy:"usrids"cascade:["persist"])]
  96.     #[ORM\JoinColumn(name:"prfid"referencedColumnName:"prfid"nullable:false)]
  97.     private $prfid;
  98.     
  99.     // ONE TO MANY ======================
  100.     // PPI de l'utilisateur (version 2022)
  101.     #[ORM\OneToMany(mappedBy'usrid'targetEntityPPI::class, orphanRemovaltrue)]
  102.     private $ppiids;
  103.     // les CFPPI de l'utilisateur (version 2024)
  104.     #[ORM\OneToMany(mappedBy'usrid'targetEntityCFPPI::class, orphanRemovaltrue)]
  105.     private $CFPPIIDS;
  106.     // les CFPLA de l'utilisateur (Plan ou Programmation pluriannuelle d'investissement)
  107.     #[ORM\OneToMany(mappedBy'usrid'targetEntityCFPLA::class, orphanRemovaltrue)]
  108.     private $PLAIDS;
  109.     public function __construct()
  110.     {
  111.         //parent::__construct();
  112.         $this->ppiids = new ArrayCollection();
  113.         $this->CFPPIIDS = new ArrayCollection();
  114.         $this->PLAIDS = new ArrayCollection();
  115.     }
  116.     // ============== usr security & so ==========================
  117.     /**
  118.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  119.      */
  120.     public function getUsername(): string
  121.     {
  122.         return (string) $this->username;
  123.     }
  124.     public function setUsername(string $username): static
  125.     {
  126.         $this->username $username;
  127.         return $this;
  128.     }
  129.     /**
  130.      * A visual identifier that represents this user.
  131.      *
  132.      * @see UserInterface
  133.      */
  134.     public function getUserIdentifier(): string
  135.     {
  136.         return (string) $this->username;
  137.     }
  138.     /**
  139.      * @see UserInterface
  140.      */
  141.     public function getRoles(): array
  142.     {
  143.         $roles $this->roles;
  144.         // guarantee every user at least has ROLE_USER
  145.         $roles[] = 'ROLE_USER';
  146.         return array_unique($roles);
  147.     }
  148.     public function setRoles(array $roles): static
  149.     {
  150.         $this->roles $roles;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @see PasswordAuthenticatedUserInterface
  155.      */
  156.     public function getPassword(): string
  157.     {
  158.         return $this->password;
  159.     }
  160.     public function setPassword(string $password): static
  161.     {
  162.         $this->password $password;
  163.         return $this;
  164.     }
  165.     /**
  166.      * Returning a salt is only needed, if you are not using a modern
  167.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  168.      *
  169.      * @see UserInterface
  170.      */
  171.     public function getSalt(): ?string
  172.     {
  173.         return null;
  174.     }
  175.     /**
  176.      * @see UserInterface
  177.      */
  178.     public function eraseCredentials(): void
  179.     {
  180.         // If you store any temporary, sensitive data on the user, clear it here
  181.         // $this->plainPassword = null;
  182.     }
  183.     // ============== FIN usr ELT ID ==========================
  184.     public function getUsrid(): ?int
  185.     {
  186.         return $this->usrid;
  187.     }
  188.     public function getUsrnom(): ?string
  189.     {
  190.         return $this->usrnom;
  191.     }
  192.     public function setUsrnom(string $usrnom): static
  193.     {
  194.         $this->usrnom $usrnom;
  195.         return $this;
  196.     }
  197.     public function getUsrpre(): ?string
  198.     {
  199.         return $this->usrpre;
  200.     }
  201.     public function setUsrpre(?string $usrpre): static
  202.     {
  203.         $this->usrpre $usrpre;
  204.         return $this;
  205.     }
  206.     public function getUsrorg(): ?string
  207.     {
  208.         return $this->usrorg;
  209.     }
  210.     public function setUsrorg(?string $usrorg): static
  211.     {
  212.         $this->usrorg $usrorg;
  213.         return $this;
  214.     }
  215.     public function getUsremail(): ?string
  216.     {
  217.         return $this->usremail;
  218.     }
  219.     public function setUsremail(?string $usremail): static
  220.     {
  221.         $this->usremail $usremail;
  222.         return $this;
  223.     }
  224.     
  225.     public function getUsrcodpos(): ?string
  226.     {
  227.         return $this->usrcodpos;
  228.     }
  229.     public function setUsrcodpos(?string $usrcodpos): static
  230.     {
  231.         $this->usrcodpos $usrcodpos;
  232.         return $this;
  233.     }
  234.     
  235.     public function getUsrstatut(): ?int
  236.     {
  237.         return $this->usrstatut;
  238.     }
  239.     public function setUsrstatut(?int $usrstatut): static
  240.     {
  241.         $this->usrstatut $usrstatut;
  242.         return $this;
  243.     }
  244.     public function getUsrdatcre(): ?\DateTimeInterface
  245.     {
  246.         return $this->usrdatcre;
  247.     }
  248.     public function setUsrdatcre(?\DateTimeInterface $usrdatcre): self
  249.     {
  250.         $this->usrdatcre $usrdatcre;
  251.         return $this;
  252.     }
  253.     // lien de vérification e-mail suite ouverture de compte
  254.     public function getUsrmaictltok(): ?string
  255.     {
  256.         return $this->usrmaictltok;
  257.     }
  258.     public function setUsrmaictltok(?string $usrmaictltok): static
  259.     {
  260.         $this->usrmaictltok $usrmaictltok;
  261.         return $this;
  262.     }
  263.     // Temps (timestamp) limite de vérification e-mail suite ouverture de compte
  264.     public function getUsrmaictllim(): ?int
  265.     {
  266.         return $this->usrmaictllim;
  267.     }
  268.     public function setUsrmaictllim(?int $usrmaictllim): static
  269.     {
  270.         $this->usrmaictllim $usrmaictllim;
  271.         return $this;
  272.     }
  273.     // suivi login
  274.     public function getUsrdatlog(): ?\DateTimeInterface
  275.     {
  276.         return $this->usrdatlog;
  277.     }
  278.     public function setUsrdatlog(?\DateTimeInterface $usrdatlog): self
  279.     {
  280.         $this->usrdatlog $usrdatlog;
  281.         return $this;
  282.     }
  283.     public function getUsrdatenvlog(): ?\DateTimeInterface
  284.     {
  285.         return $this->usrdatenvlog;
  286.     }
  287.     public function setUsrdatenvlog(?\DateTimeInterface $usrdatenvlog): self
  288.     {
  289.         $this->usrdatenvlog $usrdatenvlog;
  290.         return $this;
  291.     }
  292.     public function getUsrnbenvlog(): ?int
  293.     {
  294.         return $this->usrnbenvlog;
  295.     }
  296.     public function setUsrnbenvlog(?int $usrnbenvlog): self
  297.     {
  298.         $this->usrnbenvlog $usrnbenvlog;
  299.         return $this;
  300.     }
  301.     // demande changement de pwd
  302.     public function getUsrdatchgpwd(): ?\DateTimeInterface
  303.     {
  304.         return $this->usrdatchgpwd;
  305.     }
  306.     public function setUsrdatchgpwd(?\DateTimeInterface $usrdatchgpwd): self
  307.     {
  308.         $this->usrdatchgpwd $usrdatchgpwd;
  309.         return $this;
  310.     }
  311.     public function getUsrdatenvchgpwd(): ?\DateTimeInterface
  312.     {
  313.         return $this->usrdatenvchgpwd;
  314.     }
  315.     public function setUsrdatenvchgpwd(?\DateTimeInterface $usrdatenvchgpwd): self
  316.     {
  317.         $this->usrdatenvchgpwd $usrdatenvchgpwd;
  318.         return $this;
  319.     }
  320.     public function getUsrchgpwdtok(): ?string
  321.     {
  322.         return $this->usrchgpwdtok;
  323.     }
  324.     public function setUsrchgpwdtok(?string $usrchgpwdtok): static
  325.     {
  326.         $this->usrchgpwdtok $usrchgpwdtok;
  327.         return $this;
  328.     }
  329.     public function getUsrdatddechgpwd(): ?int
  330.     {
  331.         return $this->usrdatddechgpwd;
  332.     }
  333.     public function setUsrdatddechgpwd(?int $usrdatddechgpwd): static
  334.     {
  335.         $this->usrdatddechgpwd $usrdatddechgpwd;
  336.         return $this;
  337.     }
  338.     public function getUsrnbenvpwd(): ?int
  339.     {
  340.         return $this->usrnbenvpwd;
  341.     }
  342.     public function setUsrnbenvpwd(?int $usrnbenvpwd): static
  343.     {
  344.         $this->usrnbenvpwd $usrnbenvpwd;
  345.         return $this;
  346.     }
  347.     /*
  348.         ManyToOne catégorie
  349.     */
  350.     public function getCatid(): ?cat
  351.     {
  352.         return $this->catid;
  353.     }
  354.     public function setCatid(?cat $catid): static
  355.     {
  356.         $this->catid $catid;
  357.         return $this;
  358.     }
  359.     /*
  360.         ManyToOne profil
  361.     */
  362.     public function getPrfid(): ?prf
  363.     {
  364.         return $this->prfid;
  365.     }
  366.     public function setPrfid(?prf $prfid): static
  367.     {
  368.         $this->prfid $prfid;
  369.         return $this;
  370.     }
  371.     /*
  372.         OneToMany ppi (validé!)
  373.     */
  374.     public function getPpiids(): Collection
  375.     {
  376.         return $this->ppiids;
  377.     }
  378.     public function addPpiid(PPI $ppi): static
  379.     {
  380.         if(!$this->ppiids->contains($ppi)) {
  381.             $this->ppiids->add($ppi);
  382.             $ppi->setusrid($this);
  383.         }
  384.         return $this;
  385.     }
  386.     public function removePpiid(PPI $ppi): static
  387.     {
  388.         if ($this->ppiids->removeElement($ppi)) {
  389.             $this->ppiids->removeElement($ppi);
  390.         }
  391.         return $this;
  392.     }
  393.     /*
  394.         OneToMany CFPPI (validé!)
  395.     */
  396.     public function getCFPPIIDS(): Collection
  397.     {
  398.         return $this->CFPPIIDS;
  399.     }
  400.     public function addCFPPID(CFPPI $cfppi): static
  401.     {
  402.         if(!$this->CFPPIIDS->contains($cfppi)) {
  403.             $this->CFPPIIDS->add($cfppi);
  404.             $cfppi->setusrid($this);
  405.         }
  406.         return $this;
  407.     }
  408.     public function removeCFPPIID(CFPPI $cfppi): static
  409.     {
  410.         if ($this->CFPPIIDS->removeElement($cfppi)) {
  411.             $this->CFPPIIDS->removeElement($cfppi);
  412.         }
  413.         return $this;
  414.     }
  415.     /*
  416.         OneToMany CFPLA (validé!)
  417.     */
  418.     public function getPLAIDS(): Collection
  419.     {
  420.         return $this->PLAIDS;
  421.     }
  422.     public function addPLAID(CFPLA $cfpla): static
  423.     {
  424.         if(!$this->PLAIDS->contains($cfpla)) {
  425.             $this->PLAIDS->add($cfpla);
  426.             $cfpla->setusrid($this);
  427.         }
  428.         return $this;
  429.     }
  430.     public function removePLAID(CFPLA $cfpla): static
  431.     {
  432.         if ($this->PLAIDS->removeElement($cfpla)) {
  433.             $this->PLAIDS->removeElement($cfpla);
  434.         }
  435.         return $this;
  436.     }
  437. }