<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Doctrine\ORM\Mapping as ORM;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Client
*
* @ORM\Table(name="rec_candidat")
* @ORM\HasLifecycleCallbacks
* @ORM\Entity(repositoryClass="App\Repository\RecCandidatRepository")
* @GRID\Source(columns="id, nom, prenom, genre, dateNaissance, email, tel, dateCreation,isActive")
*/
class RecCandidat implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @GRID\Column(title="Id", type="text",visible=false)
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Assert\Email()
* @GRID\Column(title="Email", size="150", type="text")
*/
protected $email;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Assert\Length(
* min = "7",
* )
*/
protected $password;
/**
* @ORM\Column(type="string", length=55)
*/
private $salt;
/**
* @ORM\Column(name="saltemail",type="string", length=55)
*/
private $saltEmail;
/**
* @ORM\Column(name="is_active", type="boolean")
* @GRID\Column(title="Compte actif", size="100", type="boolean")
*/
private $isActive;
/**
* @ORM\Column(type="string", length=55)
* @Assert\NotBlank()
* @GRID\Column(title="Nom", size="150", type="text")
*/
protected $nom;
/**
* @ORM\Column(type="string", length=55)
* @Assert\NotBlank()
* @GRID\Column(title="Prénom", size="150", type="text")
*/
protected $prenom;
/**
* @ORM\Column(type="string", length=1, nullable=true)
* @Assert\NotBlank()
* @GRID\Column(title="Genre", size="1", type="text")
*/
protected $genre;
/**
* @ORM\Column(type="string", length=25, nullable=true)
* @Assert\NotBlank()
* @GRID\Column(title="Tel", size="100", type="text")
*/
protected $tel;
/**
* @var string
* @ORM\Column(name="Adresse", type="text", nullable=true)
*/
protected $adresse;
/**
* @var string
* @ORM\Column(name="num_individu", type="text", nullable=true)
*/
protected $numIndividu;
/**
* @ORM\Column(type="string", length=55, nullable=true)
* @Assert\NotBlank()
* @GRID\Column(title="Ville", size="150", type="text")
*/
protected $ville;
/**
* @ORM\Column(type="string", length=55, nullable=true)
* @Assert\NotBlank()
* @GRID\Column(title="Pays", size="150", type="text")
*/
protected $pays;
/**
* @ORM\Column(type="string", length=12, nullable=true)
* @GRID\Column(title="CP", size="60", type="text")
*/
protected $cp;
/**
* @var \DateTime
* @ORM\Column(name="date_naissance", type="datetime")
* @GRID\Column(title="Date de naissance", size="150", type="date", format="d/m/Y"),
*/
protected $dateNaissance;
/**
* @var string
* @ORM\Column(name="lieu_naissance", type="string", length=150, nullable=true)
*/
protected $lieuNaissance;
/**
* @var \DateTime
* @ORM\Column(name="date_création", type="datetime")
* @GRID\Column(title="Date de création", size="150", type="date", format="d/m/Y à H:i"),
*/
protected $dateCreation;
/**
* @ORM\OneToMany(targetEntity="RecCandidature", mappedBy="candidat",cascade={"persist"})
*/
private $candidatures;
/**
* @ORM\OneToMany(targetEntity="App\Entity\RecDossierVacataire", mappedBy="candidat",cascade={"persist"})
*/
private $dossiers;
protected $termsAccepted;
public function __construct()
{
$this->salt = md5(uniqid(null, true));
$this->saltEmail = md5(uniqid(null, true));
$this->candidatures = new ArrayCollection();
$this->dossiers = new ArrayCollection();
$this->dateCreation = new \DateTime('now');
$this->isActive = false;
}
public function getTermsAccepted()
{
return $this->termsAccepted;
}
public function setTermsAccepted($termsAccepted)
{
$this->termsAccepted = (Boolean) $termsAccepted;
}
public function isCandidat($id)
{
foreach($this->candidatures as $candidature)
{
if($candidature->getPoste()->getId()==$id)
return $candidature;
}
return false;
}
public function addCandidature(RecCandidature $candidature)
{
$this->candidatures[] = $candidature;
return $this;
}
public function removeCandidature(RecCandidature $candidature)
{
$this->candidatures->removeElement($candidature);
}
public function getCandidatures()
{
return $this->candidatures;
}
public function getUserName()
{
return $this->email;
}
public function getRoles()
{
return array("ROLE_USER");
}
public function getSalt()
{
return $this->salt;
}
public function serialize()
{
return serialize(array(
$this->id,
));
}
public function unserialize($serialized)
{
list (
$this->id,
) = unserialize($serialized);
}
public function eraseCredentials()
{
}
public function isAccountNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function isEnabled()
{
return $this->isActive;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set email
*
* @param string $email
* @return RecCandidat
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set password
*
* @param string $password
* @return RecCandidat
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* @return string
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* Set salt
*
* @param string $salt
* @return RecCandidat
*/
public function setSalt($salt)
{
$this->salt = $salt;
return $this;
}
/**
* Set isActive
*
* @param boolean $isActive
* @return RecCandidat
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set nom
*
* @param string $nom
* @return RecCandidat
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Get nom
*
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* Set prenom
*
* @param string $prenom
* @return RecCandidat
*/
public function setPrenom($prenom)
{
$this->prenom = $prenom;
return $this;
}
/**
* Get prenom
*
* @return string
*/
public function getPrenom()
{
return $this->prenom;
}
/**
* Set date_naissance
*
* @param \DateTime $dateNaissance
* @return RecCandidat
*/
public function setDateNaissance($dateNaissance)
{
$this->dateNaissance = $dateNaissance;
return $this;
}
/**
* Get date_naissance
*
* @return \DateTime
*/
public function getDateNaissance()
{
return $this->dateNaissance;
}
/**
* Set dateCreation
*
* @param \DateTime $dateCreation
* @return RecCandidat
*/
public function setDateCreation($dateCreation)
{
$this->dateCreation = $dateCreation;
return $this;
}
/**
* Get dateCreation
*
* @return \DateTime
*/
public function getDateCreation()
{
return $this->dateCreation;
}
/**
* Set candidatures
*
* @param \App\Entity\RecCandidature $candidatures
* @return RecCandidat
*/
public function setCandidatures(\App\Entity\RecCandidature $candidatures = null)
{
$this->candidatures = $candidatures;
return $this;
}
public function getCandidaturesInInit()
{
$candidatures = array();
foreach($this->candidatures as $c)
{
if(!$c->getInit())
$candidatures[]=$c;
}
if(count($candidatures)>0)
return $candidatures;
else
return false;
}
/**
* Set saltEmail
*
* @param string $saltEmail
* @return RecCandidat
*/
public function setSaltEmail($saltEmail)
{
$this->saltEmail = $saltEmail;
return $this;
}
/**
* Get saltEmail
*
* @return string
*/
public function getSaltEmail()
{
return $this->saltEmail;
}
/**
* Set genre
*
* @param string $genre
* @return RecCandidat
*/
public function setGenre($genre)
{
$this->genre = $genre;
return $this;
}
/**
* Get genre
*
* @return string
*/
public function getGenre()
{
return $this->genre;
}
/**
* Set adresse
*
* @param string $adresse
* @return RecCandidat
*/
public function setAdresse($adresse)
{
$this->adresse = $adresse;
return $this;
}
/**
* Get adresse
*
* @return string
*/
public function getAdresse()
{
return $this->adresse;
}
/**
* Set tel
*
* @param string $tel
* @return RecCandidat
*/
public function setTel($tel)
{
$this->tel = $tel;
return $this;
}
/**
* Get tel
*
* @return string
*/
public function getTel()
{
return $this->tel;
}
/**
* Set ville
*
* @param string $ville
* @return RecCandidat
*/
public function setVille($ville)
{
$this->ville = $ville;
return $this;
}
/**
* Get ville
*
* @return string
*/
public function getVille()
{
return $this->ville;
}
/**
* Set cp
*
* @param string $cp
* @return RecCandidat
*/
public function setCp($cp)
{
$this->cp = $cp;
return $this;
}
/**
* Get cp
*
* @return string
*/
public function getCp()
{
return $this->cp;
}
/**
* Set pays
*
* @param string $pays
* @return RecCandidat
*/
public function setPays($pays)
{
$this->pays = $pays;
return $this;
}
/**
* Get pays
*
* @return string
*/
public function getPays()
{
return $this->pays;
}
/**
* Add dossiers
*
* @param \App\Entity\RecDossierVacataire $dossiers
* @return RecCandidat
*/
public function addDossier(\App\Entity\RecDossierVacataire $dossiers)
{
$this->dossiers[] = $dossiers;
return $this;
}
/**
* Remove dossiers
*
* @param \App\Entity\RecDossierVacataire $dossiers
*/
public function removeDossier(\App\Entity\RecDossierVacataire $dossiers)
{
$this->dossiers->removeElement($dossiers);
}
/**
* Get dossiers
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getDossiers()
{
return $this->dossiers;
}
/**
* Set lieuNaissance.
*
* @param string|null $lieuNaissance
*
* @return RecCandidat
*/
public function setLieuNaissance($lieuNaissance = null)
{
$this->lieuNaissance = $lieuNaissance;
return $this;
}
/**
* Get lieuNaissance.
*
* @return string|null
*/
public function getLieuNaissance()
{
return $this->lieuNaissance;
}
public function isDeletable()
{
$count = $this->dossiers->count();
$i=0;
foreach($this->dossiers as $d)
{
if($d->isDeletable())
$i++;
}
if($i==$count)
return true;
else
return false;
}
/**
* Set numIndividu.
*
* @param string|null $numIndividu
*
* @return RecCandidat
*/
public function setNumIndividu($numIndividu = null)
{
$this->numIndividu = $numIndividu;
return $this;
}
/**
* Get numIndividu.
*
* @return string|null
*/
public function getNumIndividu()
{
return $this->numIndividu;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
}