src/Entity/User.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. #[ORM\Entity(repositoryClassUserRepository::class)]
  10. class User implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length180uniquetrue)]
  17.     private ?string $email null;
  18.     
  19.     #[ORM\Column]
  20.     private array $roles = [];
  21.     /**
  22.      * @var string The hashed password
  23.      */
  24.     #[ORM\Column]
  25.     private ?string $password null;
  26.     #[ORM\Column(length50)]
  27.     private ?string $prenom null;
  28.     #[ORM\Column(length50)]
  29.     private ?string $nom null;
  30.     #[ORM\ManyToOne]
  31.     private ?VilleFrance $ville null;
  32.     #[ORM\Column(length50)]
  33.     private ?string $initiales null;
  34.     #[ORM\OneToMany(mappedBy'user'targetEntityCamion::class)]
  35.     private Collection $camions;
  36.     #[ORM\OneToMany(mappedBy'user'targetEntityCamionUser::class)]
  37.     private Collection $camionUsers;
  38.     #[ORM\ManyToOne]
  39.     private ?VilleFrance $villeAttache null;
  40.     #[ORM\OneToMany(mappedBy'user'targetEntityDocumentation::class)]
  41.     private Collection $documentations;
  42.     #[ORM\OneToMany(mappedBy'user'targetEntityCartePaiement::class)]
  43.     private Collection $cartePaiements;
  44.     #[ORM\Column(length10nullabletrue)]
  45.     private ?string $matricule null;
  46.     #[ORM\Column]
  47.     private ?int $actif null;
  48.     #[ORM\ManyToOne(inversedBy'users')]
  49.     private ?SystemeClient $systemeClient null;
  50.     #[ORM\OneToMany(mappedBy'user'targetEntityAbsence::class)]
  51.     private Collection $absences;
  52.     #[ORM\OneToMany(mappedBy'user'targetEntityPlanningReccurence::class)]
  53.     private Collection $planningReccurences;
  54.     #[ORM\Column]
  55.     private ?int $carteClefRendu null;
  56.     #[ORM\Column]
  57.     private ?int $rappelSms null;
  58.     #[ORM\Column(length255)]
  59.     private ?string $telephone null;
  60.     #[ORM\OneToMany(mappedBy'user'targetEntityInfoChauffeur::class)]
  61.     private Collection $infoChauffeurs;
  62.     #[ORM\OneToMany(mappedBy'user'targetEntityInfoChauffeurDate::class)]
  63.     private Collection $infoChauffeurDates;
  64.     #[ORM\OneToMany(mappedBy'userUpdate'targetEntityPlanningUpdateDateTime::class)]
  65.     private Collection $planningUpdateDateTimes;
  66.     #[ORM\OneToMany(mappedBy'user'targetEntityHoraireExploit::class)]
  67.     private Collection $no;
  68.     #[ORM\Column(length20)]
  69.     private ?string $telephonePro null;
  70.     //const MDPINFO = "8RLHJCl32uDf";
  71.     const MDPINFO "Cont@ctSolu555$";
  72.     const USERINFO "contact@solubac.fr";
  73.     const HOSTINFO "smtp.office365.com";
  74.     //const HOSTINFO = "mail.infomaniak.ch";
  75.     const PORTINFO 587;
  76.     const APIKEYGOOGLE 'AIzaSyCyY3op2G-PX5ZD-UDY58jPKTJic1_y-rI';
  77.     //const PORTINFO = 465;
  78.     /**
  79.      * User constructor.
  80.      */
  81.     public function __construct()
  82.     {
  83.         $this->camions = new ArrayCollection();
  84.         $this->camionUsers = new ArrayCollection();
  85.         $this->documentations = new ArrayCollection();
  86.         $this->cartePaiements = new ArrayCollection();
  87.         $this->absences = new ArrayCollection();
  88.         $this->planningReccurences = new ArrayCollection();
  89.         $this->infoChauffeurs = new ArrayCollection();
  90.         $this->infoChauffeurDates = new ArrayCollection();
  91.         $this->planningUpdateDateTimes = new ArrayCollection();
  92.         $this->no = new ArrayCollection();
  93.     }
  94.     public function getId(): ?int
  95.     {
  96.         return $this->id;
  97.     }
  98.     public function getEmail(): ?string
  99.     {
  100.         return $this->email;
  101.     }
  102.     public function setEmail(string $email): self
  103.     {
  104.         $this->email $email;
  105.         return $this;
  106.     }
  107.     /**
  108.      * A visual identifier that represents this user.
  109.      *
  110.      * @see UserInterface
  111.      */
  112.     public function getUserIdentifier(): string
  113.     {
  114.         return (string) $this->email;
  115.     }
  116.     /**
  117.      * @see UserInterface
  118.      */
  119.     public function getRoles(): array
  120.     {
  121.         $roles $this->roles;
  122.         // guarantee every user at least has ROLE_USER
  123.         $roles[] = 'ROLE_USER';
  124.         return array_unique($roles);
  125.     }
  126.     /**
  127.      * @see UserInterface
  128.      */
  129.     public function getRoleAdmin()
  130.     {
  131.         $admin false;
  132.         foreach($this->roles as $role)
  133.         {
  134.             if($role=="ROLE_ADMIN")
  135.             {
  136.                 $admin true;
  137.             }
  138.         }
  139.         return $admin;
  140.     }
  141.     /**
  142.      * @see UserInterface
  143.      */
  144.     public function getRoleNotif()
  145.     {
  146.         $admin false;
  147.         foreach($this->roles as $role)
  148.         {
  149.             if($role=="ROLE_NOTIF")
  150.             {
  151.                 $admin true;
  152.             }
  153.         }
  154.         return $admin;
  155.     }
  156.     /**
  157.      * @see UserInterface
  158.      */
  159.     public function getRoleChauffeur()
  160.     {
  161.         $admin false;
  162.         foreach($this->roles as $role)
  163.         {
  164.             if($role=="ROLE_CHAUFFEUR")
  165.             {
  166.                 $admin true;
  167.             }
  168.         }
  169.         return $admin;
  170.     }
  171.     /**
  172.      * @see UserInterface
  173.      */
  174.     public function getRoleAnal()
  175.     {
  176.         $admin false;
  177.         foreach($this->roles as $role)
  178.         {
  179.             if($role=="ROLE_ANAL")
  180.             {
  181.                 $admin true;
  182.             }
  183.         }
  184.         return $admin;
  185.     }
  186.     /**
  187.      * @see UserInterface
  188.      */
  189.     public function getRoleTech()
  190.     {
  191.         $admin false;
  192.         foreach($this->roles as $role)
  193.         {
  194.             if($role=="ROLE_TECH")
  195.             {
  196.                 $admin true;
  197.             }
  198.         }
  199.         return $admin;
  200.     }
  201.     /**
  202.      * @see UserInterface
  203.      */
  204.     public function getRoleExpl()
  205.     {
  206.         $admin false;
  207.         foreach($this->roles as $role)
  208.         {
  209.             if($role=="ROLE_EXPL")
  210.             {
  211.                 $admin true;
  212.             }
  213.         }
  214.         return $admin;
  215.     }
  216.     public function setRoles(array $roles): self
  217.     {
  218.         $this->roles $roles;
  219.         return $this;
  220.     }
  221.     /**
  222.      * @see PasswordAuthenticatedUserInterface
  223.      */
  224.     public function getPassword(): string
  225.     {
  226.         return $this->password;
  227.     }
  228.     public function setPassword(string $password): self
  229.     {
  230.         $this->password $password;
  231.         return $this;
  232.     }
  233.     /**
  234.      * @see UserInterface
  235.      */
  236.     public function eraseCredentials()
  237.     {
  238.         // If you store any temporary, sensitive data on the user, clear it here
  239.         // $this->plainPassword = null;
  240.     }
  241.     public function getPrenom(): ?string
  242.     {
  243.         return $this->prenom;
  244.     }
  245.     public function setPrenom(string $prenom): self
  246.     {
  247.         $this->prenom $prenom;
  248.         return $this;
  249.     }
  250.     public function getNom(): ?string
  251.     {
  252.         return $this->nom;
  253.     }
  254.     public function setNom(string $nom): self
  255.     {
  256.         $this->nom $nom;
  257.         return $this;
  258.     }
  259.     public function getVille(): ?VilleFrance
  260.     {
  261.         return $this->ville;
  262.     }
  263.     public function setVille(VilleFrance $ville): self
  264.     {
  265.         $this->ville $ville;
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return Collection<int, Camion>
  270.      */
  271.     public function getCamions(): Collection
  272.     {
  273.         return $this->camions;
  274.     }
  275.     public function addCamion(Camion $camion): self
  276.     {
  277.         if (!$this->camions->contains($camion)) {
  278.             $this->camions->add($camion);
  279.             $camion->setUser($this);
  280.         }
  281.         return $this;
  282.     }
  283.     public function removeCamion(Camion $camion): self
  284.     {
  285.         if ($this->camions->removeElement($camion)) {
  286.             // set the owning side to null (unless already changed)
  287.             if ($camion->getUser() === $this) {
  288.                 $camion->setUser(null);
  289.             }
  290.         }
  291.         return $this;
  292.     }
  293.     /**
  294.      * @return Collection<int, CamionUser>
  295.      */
  296.     public function getCamionUsers(): Collection
  297.     {
  298.         return $this->camionUsers;
  299.     }
  300.     public function addCamionUser(CamionUser $camionUser): self
  301.     {
  302.         if (!$this->camionUsers->contains($camionUser)) {
  303.             $this->camionUsers->add($camionUser);
  304.             $camionUser->setUser($this);
  305.         }
  306.         return $this;
  307.     }
  308.     public function removeCamionUser(CamionUser $camionUser): self
  309.     {
  310.         if ($this->camionUsers->removeElement($camionUser)) {
  311.             // set the owning side to null (unless already changed)
  312.             if ($camionUser->getUser() === $this) {
  313.                 $camionUser->setUser(null);
  314.             }
  315.         }
  316.         return $this;
  317.     }
  318.     public function __toString()
  319.     {
  320.         return $this->getPrenom().' '.$this->getNom();
  321.     }
  322.     public function getInitiales(): ?string
  323.     {
  324.         return $this->initiales;
  325.     }
  326.     public function setInitiales(string $initiales): self
  327.     {
  328.         $this->initiales $initiales;
  329.         return $this;
  330.     }
  331.     public function getVilleAttache(): ?VilleFrance
  332.     {
  333.         return $this->villeAttache;
  334.     }
  335.     public function setVilleAttache(VilleFrance $villeAttache): self
  336.     {
  337.         $this->villeAttache $villeAttache;
  338.         return $this;
  339.     }
  340.     /**
  341.      * @return Collection<int, Documentation>
  342.      */
  343.     public function getDocumentations(): Collection
  344.     {
  345.         return $this->documentations;
  346.     }
  347.     public function addDocumentation(Documentation $documentation): self
  348.     {
  349.         if (!$this->documentations->contains($documentation)) {
  350.             $this->documentations->add($documentation);
  351.             $documentation->setUser($this);
  352.         }
  353.         return $this;
  354.     }
  355.     public function removeDocumentation(Documentation $documentation): self
  356.     {
  357.         if ($this->documentations->removeElement($documentation)) {
  358.             // set the owning side to null (unless already changed)
  359.             if ($documentation->getUser() === $this) {
  360.                 $documentation->setUser(null);
  361.             }
  362.         }
  363.         return $this;
  364.     }
  365.     public function getMatricule(): ?string
  366.     {
  367.         return $this->matricule;
  368.     }
  369.     public function setMatricule(?string $matricule): self
  370.     {
  371.         $this->matricule $matricule;
  372.         return $this;
  373.     }
  374.     public function getActif(): ?int
  375.     {
  376.         return $this->actif;
  377.     }
  378.     public function setActif(int $actif): self
  379.     {
  380.         $this->actif $actif;
  381.         return $this;
  382.     }
  383.     public function getSystemeClient(): ?SystemeClient
  384.     {
  385.         return $this->systemeClient;
  386.     }
  387.     public function setSystemeClient(?SystemeClient $systemeClient): self
  388.     {
  389.         $this->systemeClient $systemeClient;
  390.         return $this;
  391.     }
  392.     /**
  393.      * @return Collection<int, Absence>
  394.      */
  395.     public function getAbsences(): Collection
  396.     {
  397.         return $this->absences;
  398.     }
  399.     public function addAbsence(Absence $absence): self
  400.     {
  401.         if (!$this->absences->contains($absence)) {
  402.             $this->absences->add($absence);
  403.             $absence->setUser($this);
  404.         }
  405.         return $this;
  406.     }
  407.     public function removeAbsence(Absence $absence): self
  408.     {
  409.         if ($this->absences->removeElement($absence)) {
  410.             // set the owning side to null (unless already changed)
  411.             if ($absence->getUser() === $this) {
  412.                 $absence->setUser(null);
  413.             }
  414.         }
  415.         return $this;
  416.     }
  417.     /**
  418.      * @return Collection<int, PlanningReccurence>
  419.      */
  420.     public function getPlanningReccurences(): Collection
  421.     {
  422.         return $this->planningReccurences;
  423.     }
  424.     public function addPlanningReccurence(PlanningReccurence $planningReccurence): self
  425.     {
  426.         if (!$this->planningReccurences->contains($planningReccurence)) {
  427.             $this->planningReccurences->add($planningReccurence);
  428.             $planningReccurence->setUser($this);
  429.         }
  430.         return $this;
  431.     }
  432.     public function removePlanningReccurence(PlanningReccurence $planningReccurence): self
  433.     {
  434.         if ($this->planningReccurences->removeElement($planningReccurence)) {
  435.             // set the owning side to null (unless already changed)
  436.             if ($planningReccurence->getUser() === $this) {
  437.                 $planningReccurence->setUser(null);
  438.             }
  439.         }
  440.         return $this;
  441.     }
  442.     public function getCarteClefRendu(): ?int
  443.     {
  444.         return $this->carteClefRendu;
  445.     }
  446.     public function setCarteClefRendu(int $carteClefRendu): self
  447.     {
  448.         $this->carteClefRendu $carteClefRendu;
  449.         return $this;
  450.     }
  451.     public function getRappelSms(): ?int
  452.     {
  453.         return $this->rappelSms;
  454.     }
  455.     public function setRappelSms(int $rappelSms): self
  456.     {
  457.         $this->rappelSms $rappelSms;
  458.         return $this;
  459.     }
  460.     public function getTelephone(): ?string
  461.     {
  462.         return $this->telephone;
  463.     }
  464.     public function setTelephone(string $telephone): self
  465.     {
  466.         $this->telephone $telephone;
  467.         return $this;
  468.     }
  469.     /**
  470.      * @return Collection<int, InfoChauffeur>
  471.      */
  472.     public function getInfoChauffeurs(): Collection
  473.     {
  474.         return $this->infoChauffeurs;
  475.     }
  476.     public function addInfoChauffeur(InfoChauffeur $infoChauffeur): self
  477.     {
  478.         if (!$this->infoChauffeurs->contains($infoChauffeur)) {
  479.             $this->infoChauffeurs->add($infoChauffeur);
  480.             $infoChauffeur->setUser($this);
  481.         }
  482.         return $this;
  483.     }
  484.     public function removeInfoChauffeur(InfoChauffeur $infoChauffeur): self
  485.     {
  486.         if ($this->infoChauffeurs->removeElement($infoChauffeur)) {
  487.             // set the owning side to null (unless already changed)
  488.             if ($infoChauffeur->getUser() === $this) {
  489.                 $infoChauffeur->setUser(null);
  490.             }
  491.         }
  492.         return $this;
  493.     }
  494.     public function getInfoChauffeur()
  495.     {
  496.         $return null;
  497.         if(!empty($this->infoChauffeurs))
  498.         {
  499.             foreach($this->infoChauffeurs as $infoChauffeur)
  500.             {
  501.                 $return $infoChauffeur;
  502.             }
  503.         }
  504.         return $return;
  505.     }
  506.     /**
  507.      * @return Collection<int, InfoChauffeurDate>
  508.      */
  509.     public function getInfoChauffeurDates(): Collection
  510.     {
  511.         return $this->infoChauffeurDates;
  512.     }
  513.     public function addInfoChauffeurDate(InfoChauffeurDate $infoChauffeurDate): self
  514.     {
  515.         if (!$this->infoChauffeurDates->contains($infoChauffeurDate)) {
  516.             $this->infoChauffeurDates->add($infoChauffeurDate);
  517.             $infoChauffeurDate->setUser($this);
  518.         }
  519.         return $this;
  520.     }
  521.     public function removeInfoChauffeurDate(InfoChauffeurDate $infoChauffeurDate): self
  522.     {
  523.         if ($this->infoChauffeurDates->removeElement($infoChauffeurDate)) {
  524.             // set the owning side to null (unless already changed)
  525.             if ($infoChauffeurDate->getUser() === $this) {
  526.                 $infoChauffeurDate->setUser(null);
  527.             }
  528.         }
  529.         return $this;
  530.     }
  531.     /**
  532.      * @return Collection<int, PlanningUpdateDateTime>
  533.      */
  534.     public function getPlanningUpdateDateTimes(): Collection
  535.     {
  536.         return $this->planningUpdateDateTimes;
  537.     }
  538.     public function addPlanningUpdateDateTime(PlanningUpdateDateTime $planningUpdateDateTime): static
  539.     {
  540.         if (!$this->planningUpdateDateTimes->contains($planningUpdateDateTime)) {
  541.             $this->planningUpdateDateTimes->add($planningUpdateDateTime);
  542.             $planningUpdateDateTime->setUserUpdate($this);
  543.         }
  544.         return $this;
  545.     }
  546.     public function removePlanningUpdateDateTime(PlanningUpdateDateTime $planningUpdateDateTime): static
  547.     {
  548.         if ($this->planningUpdateDateTimes->removeElement($planningUpdateDateTime)) {
  549.             // set the owning side to null (unless already changed)
  550.             if ($planningUpdateDateTime->getUserUpdate() === $this) {
  551.                 $planningUpdateDateTime->setUserUpdate(null);
  552.             }
  553.         }
  554.         return $this;
  555.     }
  556.     /**
  557.      * @return Collection<int, HoraireExploit>
  558.      */
  559.     public function getNo(): Collection
  560.     {
  561.         return $this->no;
  562.     }
  563.     public function addNo(HoraireExploit $no): static
  564.     {
  565.         if (!$this->no->contains($no)) {
  566.             $this->no->add($no);
  567.             $no->setUser($this);
  568.         }
  569.         return $this;
  570.     }
  571.     public function removeNo(HoraireExploit $no): static
  572.     {
  573.         if ($this->no->removeElement($no)) {
  574.             // set the owning side to null (unless already changed)
  575.             if ($no->getUser() === $this) {
  576.                 $no->setUser(null);
  577.             }
  578.         }
  579.         return $this;
  580.     }
  581.     public function getTelephonePro(): ?string
  582.     {
  583.         return $this->telephonePro;
  584.     }
  585.     public function setTelephonePro(string $telephonePro): static
  586.     {
  587.         $this->telephonePro $telephonePro;
  588.         return $this;
  589.     }
  590. }