src/Entity/RecCandidat.php line 166

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\DBAL\Types\Types;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use APY\DataGridBundle\Grid\Mapping as GRID;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * Client
  14.  *
  15.  * @ORM\Table(name="rec_candidat")
  16.  * @ORM\HasLifecycleCallbacks
  17.  * @ORM\Entity(repositoryClass="App\Repository\RecCandidatRepository")
  18.  * @GRID\Source(columns="id, nom, prenom, genre, dateNaissance, email, tel, dateCreation,isActive")
  19.  */
  20. class RecCandidat implements UserInterfacePasswordAuthenticatedUserInterface
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\Column(type="integer")
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      * @GRID\Column(title="Id", type="text",visible=false)
  27.      */
  28.     protected $id;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      * @Assert\NotBlank()
  32.      * @Assert\Email()
  33.      * @GRID\Column(title="Email", size="150", type="text")
  34.      */
  35.     protected $email;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      * @Assert\NotBlank()
  39.      * @Assert\Length(
  40.      *     min = "7",
  41.      * )
  42.      */
  43.     protected $password;
  44.     /**
  45.      * @ORM\Column(type="string", length=55)
  46.      */
  47.     private $salt;
  48.     /**
  49.      * @ORM\Column(name="saltemail",type="string", length=55)
  50.      */
  51.     private $saltEmail;
  52.     /**
  53.      * @ORM\Column(name="is_active", type="boolean")
  54.      * @GRID\Column(title="Compte actif", size="100", type="boolean")
  55.      */
  56.     private $isActive;
  57.     /**
  58.      * @ORM\Column(type="string", length=55)
  59.      * @Assert\NotBlank()
  60.      * @GRID\Column(title="Nom", size="150", type="text")
  61.      */
  62.     protected $nom;
  63.     /**
  64.      * @ORM\Column(type="string", length=55)
  65.      * @Assert\NotBlank()
  66.      * @GRID\Column(title="Prénom", size="150", type="text")
  67.      */
  68.     protected $prenom;
  69.     /**
  70.      * @ORM\Column(type="string", length=1, nullable=true)
  71.      * @Assert\NotBlank()
  72.      * @GRID\Column(title="Genre", size="1", type="text")
  73.      */
  74.     protected $genre;
  75.     /**
  76.      * @ORM\Column(type="string", length=25, nullable=true)
  77.      * @Assert\NotBlank()
  78.      * @GRID\Column(title="Tel", size="100", type="text")
  79.      */
  80.     protected $tel;
  81.     /**
  82.      * @var string
  83.      * @ORM\Column(name="Adresse", type="text", nullable=true)
  84.      */
  85.     protected $adresse;
  86.     /**
  87.      * @var string
  88.      * @ORM\Column(name="num_individu", type="text", nullable=true)
  89.      */
  90.     protected $numIndividu;
  91.     /**
  92.      * @ORM\Column(type="string", length=55, nullable=true)
  93.      * @Assert\NotBlank()
  94.      * @GRID\Column(title="Ville", size="150", type="text")
  95.      */
  96.     protected $ville;
  97.     /**
  98.      * @ORM\Column(type="string", length=55, nullable=true)
  99.      * @Assert\NotBlank()
  100.      * @GRID\Column(title="Pays", size="150", type="text")
  101.      */
  102.     protected $pays;
  103.     /**
  104.      * @ORM\Column(type="string", length=12, nullable=true)
  105.      * @GRID\Column(title="CP", size="60", type="text")
  106.      */
  107.     protected $cp;
  108.     /**
  109.      * @var \DateTime
  110.      * @ORM\Column(name="date_naissance", type="datetime")
  111.      * @GRID\Column(title="Date de naissance", size="150", type="date", format="d/m/Y"),
  112.      */
  113.     protected $dateNaissance;
  114.     /**
  115.      * @var string
  116.      * @ORM\Column(name="lieu_naissance", type="string", length=150, nullable=true)
  117.      */
  118.     protected $lieuNaissance;
  119.     /**
  120.      * @var \DateTime
  121.      * @ORM\Column(name="date_création", type="datetime")
  122.      * @GRID\Column(title="Date de création", size="150", type="date", format="d/m/Y à H:i"),
  123.      */
  124.     protected $dateCreation;
  125.     /**
  126.      * @ORM\OneToMany(targetEntity="RecCandidature", mappedBy="candidat",cascade={"persist"})
  127.      */
  128.     private $candidatures;
  129.     /**
  130.      * @ORM\OneToMany(targetEntity="App\Entity\RecDossierVacataire", mappedBy="candidat",cascade={"persist"})
  131.      */
  132.     private $dossiers;
  133.     protected $termsAccepted;
  134.     public function __construct()
  135.     {
  136.         $this->salt md5(uniqid(nulltrue));
  137.         $this->saltEmail md5(uniqid(nulltrue));
  138.         $this->candidatures = new ArrayCollection();
  139.         $this->dossiers = new ArrayCollection();
  140.         $this->dateCreation = new \DateTime('now');
  141.         $this->isActive false;
  142.     }
  143.     public function getTermsAccepted()
  144.     {
  145.         return $this->termsAccepted;
  146.     }
  147.     public function setTermsAccepted($termsAccepted)
  148.     {
  149.         $this->termsAccepted = (Boolean) $termsAccepted;
  150.     }
  151.     public function isCandidat($id)
  152.     {
  153.         foreach($this->candidatures as $candidature)
  154.         {
  155.             if($candidature->getPoste()->getId()==$id)
  156.                 return $candidature;
  157.         }
  158.         return false;
  159.     }
  160.     public function addCandidature(RecCandidature $candidature)
  161.     {
  162.         $this->candidatures[] = $candidature;
  163.         return $this;
  164.     }
  165.     public function removeCandidature(RecCandidature $candidature)
  166.     {
  167.         $this->candidatures->removeElement($candidature);
  168.     }
  169.     public function getCandidatures()
  170.     {
  171.         return $this->candidatures;
  172.     }
  173.     public function getUserName()
  174.     {
  175.         return $this->email;
  176.     }
  177.     public function getRoles()
  178.     {
  179.         return array("ROLE_USER");
  180.     }
  181.     public function getSalt()
  182.     {
  183.         return $this->salt;
  184.     }
  185.     public function serialize()
  186.     {
  187.         return serialize(array(
  188.             $this->id,
  189.         ));
  190.     }
  191.     public function unserialize($serialized)
  192.     {
  193.         list (
  194.             $this->id,
  195.             ) = unserialize($serialized);
  196.     }
  197.     public function eraseCredentials()
  198.     {
  199.     }
  200.     public function isAccountNonExpired()
  201.     {
  202.         return true;
  203.     }
  204.     public function isAccountNonLocked()
  205.     {
  206.         return true;
  207.     }
  208.     public function isCredentialsNonExpired()
  209.     {
  210.         return true;
  211.     }
  212.     public function isEnabled()
  213.     {
  214.         return $this->isActive;
  215.     }
  216.     /**
  217.      * Get id
  218.      *
  219.      * @return integer 
  220.      */
  221.     public function getId()
  222.     {
  223.         return $this->id;
  224.     }
  225.     /**
  226.      * Set email
  227.      *
  228.      * @param string $email
  229.      * @return RecCandidat
  230.      */
  231.     public function setEmail($email)
  232.     {
  233.         $this->email $email;
  234.         return $this;
  235.     }
  236.     /**
  237.      * Get email
  238.      *
  239.      * @return string 
  240.      */
  241.     public function getEmail()
  242.     {
  243.         return $this->email;
  244.     }
  245.     /**
  246.      * Set password
  247.      *
  248.      * @param string $password
  249.      * @return RecCandidat
  250.      */
  251.     public function setPassword($password)
  252.     {
  253.         $this->password $password;
  254.         return $this;
  255.     }
  256.     /**
  257.      * Get password
  258.      *
  259.      * @return string 
  260.      */
  261.     public function getPassword(): ?string
  262.     {
  263.         return $this->password;
  264.     }
  265.     /**
  266.      * Set salt
  267.      *
  268.      * @param string $salt
  269.      * @return RecCandidat
  270.      */
  271.     public function setSalt($salt)
  272.     {
  273.         $this->salt $salt;
  274.         return $this;
  275.     }
  276.     /**
  277.      * Set isActive
  278.      *
  279.      * @param boolean $isActive
  280.      * @return RecCandidat
  281.      */
  282.     public function setIsActive($isActive)
  283.     {
  284.         $this->isActive $isActive;
  285.         return $this;
  286.     }
  287.     /**
  288.      * Get isActive
  289.      *
  290.      * @return boolean 
  291.      */
  292.     public function getIsActive()
  293.     {
  294.         return $this->isActive;
  295.     }
  296.     /**
  297.      * Set nom
  298.      *
  299.      * @param string $nom
  300.      * @return RecCandidat
  301.      */
  302.     public function setNom($nom)
  303.     {
  304.         $this->nom $nom;
  305.         return $this;
  306.     }
  307.     /**
  308.      * Get nom
  309.      *
  310.      * @return string 
  311.      */
  312.     public function getNom()
  313.     {
  314.         return $this->nom;
  315.     }
  316.     /**
  317.      * Set prenom
  318.      *
  319.      * @param string $prenom
  320.      * @return RecCandidat
  321.      */
  322.     public function setPrenom($prenom)
  323.     {
  324.         $this->prenom $prenom;
  325.         return $this;
  326.     }
  327.     /**
  328.      * Get prenom
  329.      *
  330.      * @return string 
  331.      */
  332.     public function getPrenom()
  333.     {
  334.         return $this->prenom;
  335.     }
  336.     /**
  337.      * Set date_naissance
  338.      *
  339.      * @param \DateTime $dateNaissance
  340.      * @return RecCandidat
  341.      */
  342.     public function setDateNaissance($dateNaissance)
  343.     {
  344.         $this->dateNaissance $dateNaissance;
  345.         return $this;
  346.     }
  347.     /**
  348.      * Get date_naissance
  349.      *
  350.      * @return \DateTime 
  351.      */
  352.     public function getDateNaissance()
  353.     {
  354.         return $this->dateNaissance;
  355.     }
  356.     /**
  357.      * Set dateCreation
  358.      *
  359.      * @param \DateTime $dateCreation
  360.      * @return RecCandidat
  361.      */
  362.     public function setDateCreation($dateCreation)
  363.     {
  364.         $this->dateCreation $dateCreation;
  365.         return $this;
  366.     }
  367.     /**
  368.      * Get dateCreation
  369.      *
  370.      * @return \DateTime 
  371.      */
  372.     public function getDateCreation()
  373.     {
  374.         return $this->dateCreation;
  375.     }
  376.     /**
  377.      * Set candidatures
  378.      *
  379.      * @param \App\Entity\RecCandidature $candidatures
  380.      * @return RecCandidat
  381.      */
  382.     public function setCandidatures(\App\Entity\RecCandidature $candidatures null)
  383.     {
  384.         $this->candidatures $candidatures;
  385.         return $this;
  386.     }
  387.     public function getCandidaturesInInit()
  388.     {
  389.         $candidatures = array();
  390.         foreach($this->candidatures as $c)
  391.         {
  392.             if(!$c->getInit())
  393.                 $candidatures[]=$c;
  394.         }
  395.         if(count($candidatures)>0)
  396.             return $candidatures;
  397.         else
  398.             return false;
  399.     }
  400.     /**
  401.      * Set saltEmail
  402.      *
  403.      * @param string $saltEmail
  404.      * @return RecCandidat
  405.      */
  406.     public function setSaltEmail($saltEmail)
  407.     {
  408.         $this->saltEmail $saltEmail;
  409.         return $this;
  410.     }
  411.     /**
  412.      * Get saltEmail
  413.      *
  414.      * @return string 
  415.      */
  416.     public function getSaltEmail()
  417.     {
  418.         return $this->saltEmail;
  419.     }
  420.     /**
  421.      * Set genre
  422.      *
  423.      * @param string $genre
  424.      * @return RecCandidat
  425.      */
  426.     public function setGenre($genre)
  427.     {
  428.         $this->genre $genre;
  429.         return $this;
  430.     }
  431.     /**
  432.      * Get genre
  433.      *
  434.      * @return string 
  435.      */
  436.     public function getGenre()
  437.     {
  438.         return $this->genre;
  439.     }
  440.     /**
  441.      * Set adresse
  442.      *
  443.      * @param string $adresse
  444.      * @return RecCandidat
  445.      */
  446.     public function setAdresse($adresse)
  447.     {
  448.         $this->adresse $adresse;
  449.         return $this;
  450.     }
  451.     /**
  452.      * Get adresse
  453.      *
  454.      * @return string 
  455.      */
  456.     public function getAdresse()
  457.     {
  458.         return $this->adresse;
  459.     }
  460.     /**
  461.      * Set tel
  462.      *
  463.      * @param string $tel
  464.      * @return RecCandidat
  465.      */
  466.     public function setTel($tel)
  467.     {
  468.         $this->tel $tel;
  469.         return $this;
  470.     }
  471.     /**
  472.      * Get tel
  473.      *
  474.      * @return string 
  475.      */
  476.     public function getTel()
  477.     {
  478.         return $this->tel;
  479.     }
  480.     /**
  481.      * Set ville
  482.      *
  483.      * @param string $ville
  484.      * @return RecCandidat
  485.      */
  486.     public function setVille($ville)
  487.     {
  488.         $this->ville $ville;
  489.         return $this;
  490.     }
  491.     /**
  492.      * Get ville
  493.      *
  494.      * @return string 
  495.      */
  496.     public function getVille()
  497.     {
  498.         return $this->ville;
  499.     }
  500.     /**
  501.      * Set cp
  502.      *
  503.      * @param string $cp
  504.      * @return RecCandidat
  505.      */
  506.     public function setCp($cp)
  507.     {
  508.         $this->cp $cp;
  509.         return $this;
  510.     }
  511.     /**
  512.      * Get cp
  513.      *
  514.      * @return string 
  515.      */
  516.     public function getCp()
  517.     {
  518.         return $this->cp;
  519.     }
  520.     /**
  521.      * Set pays
  522.      *
  523.      * @param string $pays
  524.      * @return RecCandidat
  525.      */
  526.     public function setPays($pays)
  527.     {
  528.         $this->pays $pays;
  529.         return $this;
  530.     }
  531.     /**
  532.      * Get pays
  533.      *
  534.      * @return string 
  535.      */
  536.     public function getPays()
  537.     {
  538.         return $this->pays;
  539.     }
  540.     /**
  541.      * Add dossiers
  542.      *
  543.      * @param \App\Entity\RecDossierVacataire $dossiers
  544.      * @return RecCandidat
  545.      */
  546.     public function addDossier(\App\Entity\RecDossierVacataire $dossiers)
  547.     {
  548.         $this->dossiers[] = $dossiers;
  549.         return $this;
  550.     }
  551.     /**
  552.      * Remove dossiers
  553.      *
  554.      * @param \App\Entity\RecDossierVacataire $dossiers
  555.      */
  556.     public function removeDossier(\App\Entity\RecDossierVacataire $dossiers)
  557.     {
  558.         $this->dossiers->removeElement($dossiers);
  559.     }
  560.     /**
  561.      * Get dossiers
  562.      *
  563.      * @return \Doctrine\Common\Collections\Collection 
  564.      */
  565.     public function getDossiers()
  566.     {
  567.         return $this->dossiers;
  568.     }
  569.     /**
  570.      * Set lieuNaissance.
  571.      *
  572.      * @param string|null $lieuNaissance
  573.      *
  574.      * @return RecCandidat
  575.      */
  576.     public function setLieuNaissance($lieuNaissance null)
  577.     {
  578.         $this->lieuNaissance $lieuNaissance;
  579.         return $this;
  580.     }
  581.     /**
  582.      * Get lieuNaissance.
  583.      *
  584.      * @return string|null
  585.      */
  586.     public function getLieuNaissance()
  587.     {
  588.         return $this->lieuNaissance;
  589.     }
  590.     public function isDeletable()
  591.     {
  592.         $count $this->dossiers->count();
  593.         $i=0;
  594.         foreach($this->dossiers as $d)
  595.         {
  596.             if($d->isDeletable())
  597.                $i++;
  598.         }
  599.         if($i==$count)
  600.             return true;
  601.         else
  602.             return false;
  603.     }
  604.     /**
  605.      * Set numIndividu.
  606.      *
  607.      * @param string|null $numIndividu
  608.      *
  609.      * @return RecCandidat
  610.      */
  611.     public function setNumIndividu($numIndividu null)
  612.     {
  613.         $this->numIndividu $numIndividu;
  614.         return $this;
  615.     }
  616.     /**
  617.      * Get numIndividu.
  618.      *
  619.      * @return string|null
  620.      */
  621.     public function getNumIndividu()
  622.     {
  623.         return $this->numIndividu;
  624.     }
  625.     public function isIsActive(): ?bool
  626.     {
  627.         return $this->isActive;
  628.     }
  629. }