<?php
namespace App\Entity;
use App\Entity\RecCandidat;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use APY\DataGridBundle\Grid\Mapping as GRID;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Client
*
* @ORM\Table(name="rec_candidature")
* @ORM\HasLifecycleCallbacks
* @ORM\Entity(repositoryClass="App\Repository\RecCandidatureRepository")
* @GRID\Source(columns="id, poste.idInterne, candidat.nom, candidat.prenom, candidat.genre, dateCandidature, dateValidate, init, validate, recevable, candidatureStatut.name,candidatureSuivie.name, candidatureAudition.name,candidatureSituation.name")
*/
class RecCandidature
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @GRID\Column(title="Id", size="100", type="text",visible=false)
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="RecCandidat", inversedBy="candidatures")
* @ORM\JoinColumn(name="candidat_id", referencedColumnName="id")
* @ORM\OrderBy({"candidat.nom" = "ASC"})
* @GRID\Column(field="candidat.nom", title="Nom", type="textpopupcandidature",size="150")
* @GRID\Column(field="candidat.prenom", title="Prénom",size="150", type="text")
*/
protected $candidat;
/**
*
* @ORM\ManyToOne(targetEntity="RecPoste", inversedBy="candidatures")
* @ORM\JoinColumn(name="poste_id", referencedColumnName="id")
* @GRID\Column(field="poste.idInterne", title="Poste",size="150", type="text")
**/
protected $poste;
/**
* @var \DateTime
* @ORM\Column(name="date_candidature", type="datetime", nullable=true))
* @GRID\Column(title="Date de candidature", size="150", type="date", format="d/m/Y"),
*/
protected $dateCandidature;
/**
* @var \DateTime
* @ORM\Column(name="date_validate", type="datetime", nullable=true))
* @GRID\Column(title="Date de validation", size="150", type="date", format="d/m/Y"),
*/
protected $dateValidate;
/**
* @var \DateTime
* @ORM\Column(name="date_init", type="datetime")
* @GRID\Column(title="Date de création", size="150", type="date", format="d/m/Y"),
*/
protected $dateInit;
/**
* @ORM\Column(name="popup", type="boolean")
*/
protected $popup;
/**
* @ORM\Column(name="validate", type="boolean")
* @GRID\Column(title="Candidature finalisée",size="50")
*/
protected $validate;
/**
* @ORM\Column(name="recevable", type="boolean")
*/
protected $recevable;
/**
* @ORM\Column(name="sended", type="boolean", nullable=true)
*/
protected $sended;
/**
* @ORM\Column(name="origine_autres", type="text", nullable=true)
*/
protected $origineAutres;
/**
* @ORM\Column(name="commentaire", type="text", nullable=true)
*/
protected $commentaire;
/**
* @ORM\Column(name="select_comm_json", type="text", nullable=true)
*/
protected $selectCommisionJSON;
/**
* @ORM\Column(name="commentaire_commission", type="text", nullable=true)
*/
protected $commentaireCommission;
/**
* @ORM\Column(name="init", type="boolean")
* @GRID\Column(title="Candidature en cours",size="50")
*/
protected $init;
/**
*
* @ORM\ManyToOne(targetEntity="RecCandidatureStatut", inversedBy="candidature")
* @ORM\JoinColumn(name="candidature_statut_id", referencedColumnName="id")
* @GRID\Column(field="candidatureStatut.name", type="statutcandidature", title="Statut", size="150", filter="select", selectFrom="source", operatorsVisible=false)
*/
protected $candidatureStatut;
/**
*
* @ORM\ManyToOne(targetEntity="RecCandidatureSuivie", inversedBy="candidature")
* @ORM\JoinColumn(name="candidature_suivie_id", referencedColumnName="id")
* @GRID\Column(field="candidatureSuivie.name", type="suiviecandidature", title="Suivie", size="150", filter="select", selectFrom="source", operatorsVisible=false)
*/
protected $candidatureSuivie;
/**
*
* @ORM\ManyToOne(targetEntity="RecCandidatureAudition", inversedBy="candidature")
* @ORM\JoinColumn(name="candidature_audition_id", referencedColumnName="id")
* @GRID\Column(field="candidatureAudition.name", type="auditioncandidature", title="Audition", size="150", filter="select", selectFrom="source", operatorsVisible=false)
*/
protected $candidatureAudition;
/**
*
* @ORM\ManyToOne(targetEntity="RecCandidatureSituation", inversedBy="candidature")
* @ORM\JoinColumn(name="candidature_situation_id", referencedColumnName="id")
* @GRID\Column(field="candidatureSituation.name", type="situationcandidature", title="Situation", size="150", filter="select", selectFrom="source", operatorsVisible=false)
*/
protected $candidatureSituation;
/**
*
* @ORM\ManyToOne(targetEntity="RecCandidatureOrigine", inversedBy="candidature")
* @ORM\JoinColumn(name="candidature_origine_id", referencedColumnName="id")
* @GRID\Column(field="candidatureOrigine.name", type="originecandidature", title="Origine", size="150", filter="select", selectFrom="source", operatorsVisible=false)
*/
protected $candidatureOrigine;
/**
* @ORM\OneToMany(targetEntity="RecDocument", mappedBy="candidature", cascade={"remove"})
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity="RecRapport", mappedBy="candidature", cascade={"remove"})
*/
private $rapports;
/**
* @ORM\OneToMany(targetEntity="RecAvisMembre", mappedBy="candidature", cascade={"remove"})
*/
private $avisMembre;
/**
*
* @ORM\ManyToOne(targetEntity="RecSecteur", inversedBy="candidature")
* @ORM\JoinColumn(name="secteur_id", referencedColumnName="id")
*/
protected $secteur;
protected $rapporteurs;
public function __construct()
{
$this->init = false;
$this->popup = true;
$this->validate = false;
$this->sended = false;
$this->recevable = false;
$this->dateInit = new \DateTime('now');
$this->documents = new ArrayCollection();
$this->rapporteurs = new ArrayCollection();
$this->rapports = new ArrayCollection();
$this->avisMembre = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set date_candidature
*
* @param \DateTime $dateCandidature
* @return RecCandidature
*/
public function setDateCandidature($dateCandidature)
{
$this->dateCandidature = $dateCandidature;
return $this;
}
/**
* Get date_candidature
*
* @return \DateTime
*/
public function getDateCandidature()
{
return $this->dateCandidature;
}
/**
* Set validate
*
* @param boolean $validate
* @return RecCandidature
*/
public function setValidate($validate)
{
$this->validate = $validate;
return $this;
}
/**
* Get validate
*
* @return boolean
*/
public function getValidate()
{
return $this->validate;
}
/**
* Set candidat
*
* @param \App\Entity\RecCandidat $candidat
* @return RecCandidature
*/
public function setCandidat(\App\Entity\RecCandidat $candidat = null)
{
$this->candidat = $candidat;
return $this;
}
/**
* Get candidat
*
* @return \Dosi\RecrutementBundle\Entity\RecCandidat
*/
public function getCandidat()
{
return $this->candidat;
}
/**
* Set poste
*
* @param \App\Entity\RecPoste $poste
* @return RecCandidature
*/
public function setPoste(\App\Entity\RecPoste $poste = null)
{
$this->poste = $poste;
return $this;
}
/**
* Get poste
*
* @return \Dosi\RecrutementBundle\Entity\RecPoste
*/
public function getPoste()
{
return $this->poste;
}
/**
* Set candidature_statut
*
* @param \App\Entity\RecCandidatureStatut $candidatureStatut
* @return RecCandidature
*/
public function setCandidatureStatut(\App\Entity\RecCandidatureStatut $candidatureStatut = null)
{
$this->candidatureStatut = $candidatureStatut;
return $this;
}
/**
* Get candidature_statut
*
* @return \Dosi\RecrutementBundle\Entity\RecCandidatureStatut
*/
public function getCandidatureStatut()
{
return $this->candidatureStatut;
}
/**
* Set init
*
* @param boolean $init
* @return RecCandidature
*/
public function setInit($init)
{
$this->init = $init;
return $this;
}
/**
* Get init
*
* @return boolean
*/
public function getInit()
{
return $this->init;
}
/**
* Set dateInit
*
* @param \DateTime $dateInit
* @return RecCandidature
*/
public function setDateInit($dateInit)
{
$this->dateInit = $dateInit;
return $this;
}
/**
* Get dateInit
*
* @return \DateTime
*/
public function getDateInit()
{
return $this->dateInit;
}
/**
* Add documents
*
* @param \App\Entity\RecDocument $documents
* @return RecCandidature
*/
public function addDocument(\App\Entity\RecDocument $documents)
{
$this->documents[] = $documents;
return $this;
}
/**
* Remove documents
*
* @param \App\Entity\RecDocument $documents
*/
public function removeDocument(\App\Entity\RecDocument $documents)
{
$this->documents->removeElement($documents);
}
/**
* Get documents
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getDocuments()
{
return $this->documents;
}
/**
* Set dateValidate
*
* @param \DateTime $dateValidate
* @return RecCandidature
*/
public function setDateValidate($dateValidate)
{
$this->dateValidate = $dateValidate;
return $this;
}
/**
* Get dateValidate
*
* @return \DateTime
*/
public function getDateValidate()
{
return $this->dateValidate;
}
/**
* Set popup
*
* @param boolean $popup
* @return RecCandidature
*/
public function setPopup($popup)
{
$this->popup = $popup;
return $this;
}
/**
* Get popup
*
* @return boolean
*/
public function getPopup()
{
return $this->popup;
}
public function isQuotaExcedeed($size)
{
$ratio = "50";
$bytes = 0;
$ratioBytes = $ratio*1048576;
foreach($this->documents as $document)
{
if(file_exists($document->getAbsolutePath().'/'.$document->getHiddenName()))
$bytes+= filesize($document->getAbsolutePath().'/'.$document->getHiddenName());
}
if(($bytes+$size)>$ratioBytes)
return true;
else
return false;
}
public function getStockageRatio()
{
$bytes = 0;
$ratio = "50";
foreach($this->documents as $document)
{
if(file_exists($document->getAbsolutePath().'/'.$document->getHiddenName()))
$bytes+= filesize($document->getAbsolutePath().'/'.$document->getHiddenName());
}
$ratioBytes = $ratio*1048576;
return number_format($bytes / $ratioBytes,2);
}
public function getStockage()
{
$bytes = 0;
foreach($this->documents as $document)
{
if(file_exists($document->getAbsolutePath().'/'.$document->getHiddenName()))
$bytes+= filesize($document->getAbsolutePath().'/'.$document->getHiddenName());
}
if ($bytes >= 1073741824)
{
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
}
elseif ($bytes >= 1048576)
{
$bytes = number_format($bytes / 1048576, 2) . ' MB';
}
elseif ($bytes >= 1024)
{
$bytes = number_format($bytes / 1024, 2) . ' KB';
}
elseif ($bytes > 1)
{
$bytes = $bytes . ' bytes';
}
elseif ($bytes == 1)
{
$bytes = $bytes . ' byte';
}
else
{
$bytes = '0 bytes';
}
return $bytes;
}
/**
* Set secteur
*
* @param \App\Entity\RecSecteur $secteur
* @return RecCandidature
*/
public function setSecteur(\App\Entity\RecSecteur $secteur = null)
{
$this->secteur = $secteur;
return $this;
}
/**
* Get secteur
*
* @return \Dosi\RecrutementBundle\Entity\RecSecteur
*/
public function getSecteur()
{
return $this->secteur;
}
/**
* Set recevable
*
* @param boolean $recevable
* @return RecCandidature
*/
public function setRecevable($recevable)
{
$this->recevable = $recevable;
return $this;
}
/**
* Get recevable
*
* @return boolean
*/
public function getRecevable()
{
return $this->recevable;
}
/**
* Set commentaire
*
* @param string $commentaire
* @return RecCandidature
*/
public function setCommentaire($commentaire)
{
$this->commentaire = $commentaire;
return $this;
}
/**
* Get commentaire
*
* @return string
*/
public function getCommentaire()
{
return $this->commentaire;
}
/**
* Set candidatureSuivie
*
* @param \App\Entity\RecCandidatureSuivie $candidatureSuivie
* @return RecCandidature
*/
public function setCandidatureSuivie(\App\Entity\RecCandidatureSuivie $candidatureSuivie = null)
{
$this->candidatureSuivie = $candidatureSuivie;
return $this;
}
/**
* Get candidatureSuivie
*
* @return \Dosi\RecrutementBundle\Entity\RecCandidatureSuivie
*/
public function getCandidatureSuivie()
{
return $this->candidatureSuivie;
}
public function cleanDocuments()
{
$this->documents = new ArrayCollection();
return $this;
}
/**
* Add rapports
*
* @param \App\Entity\RecRapport $rapports
* @return RecCandidature
*/
public function addRapport(\App\Entity\RecRapport $rapports)
{
$this->rapports[] = $rapports;
return $this;
}
/**
* Remove rapports
*
* @param \App\Entity\RecRapport $rapports
*/
public function removeRapport(\App\Entity\RecRapport $rapports)
{
$this->rapports->removeElement($rapports);
}
/**
* Get rapports
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRapports()
{
return $this->rapports;
}
public function addRapporteur(\App\Entity\RecMembre $membre)
{
$this->rapporteurs[] = $membre;
return $this;
}
public function removeRapporteur(\App\Entity\RecMembre $membre)
{
$this->rapporteurs->removeElement($membre);
}
/**
* Get documents
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRapporteurs()
{
return $this->rapporteurs;
}
/**
* Set candidatureAudition
*
* @param \App\Entity\RecCandidatureAudition $candidatureAudition
* @return RecCandidature
*/
public function setCandidatureAudition(\App\Entity\RecCandidatureAudition $candidatureAudition = null)
{
$this->candidatureAudition = $candidatureAudition;
return $this;
}
/**
* Get candidatureAudition
*
* @return \Dosi\RecrutementBundle\Entity\RecCandidatureAudition
*/
public function getCandidatureAudition()
{
return $this->candidatureAudition;
}
/**
* Set candidatureSituation
*
* @param \App\Entity\RecCandidatureSituation $candidatureSituation
* @return RecCandidature
*/
public function setCandidatureSituation(\App\Entity\RecCandidatureSituation $candidatureSituation = null)
{
$this->candidatureSituation = $candidatureSituation;
return $this;
}
/**
* Get candidatureSituation
*
* @return \Dosi\RecrutementBundle\Entity\RecCandidatureSituation
*/
public function getCandidatureSituation()
{
return $this->candidatureSituation;
}
/**
* Set sended
*
* @param boolean $sended
* @return RecCandidature
*/
public function setSended($sended)
{
$this->sended = $sended;
return $this;
}
/**
* Get sended
*
* @return boolean
*/
public function getSended()
{
return $this->sended;
}
/**
* Set commentaireCommission.
*
* @param string|null $commentaireCommission
*
* @return RecCandidature
*/
public function setCommentaireCommission($commentaireCommission = null)
{
$this->commentaireCommission = $commentaireCommission;
return $this;
}
/**
* Get commentaireCommission.
*
* @return string|null
*/
public function getCommentaireCommission()
{
return $this->commentaireCommission;
}
/**
* Set origineAutres.
*
* @param string|null $origineAutres
*
* @return RecCandidature
*/
public function setOrigineAutres($origineAutres = null)
{
$this->origineAutres = $origineAutres;
return $this;
}
/**
* Get origineAutres.
*
* @return string|null
*/
public function getOrigineAutres()
{
return $this->origineAutres;
}
/**
* Set candidatureOrigine.
*
* @param \App\Entity\RecCandidatureOrigine|null $candidatureOrigine
*
* @return RecCandidature
*/
public function setCandidatureOrigine(\App\Entity\RecCandidatureOrigine $candidatureOrigine = null)
{
$this->candidatureOrigine = $candidatureOrigine;
return $this;
}
/**
* Get candidatureOrigine.
*
* @return \Dosi\RecrutementBundle\Entity\RecCandidatureOrigine|null
*/
public function getCandidatureOrigine()
{
return $this->candidatureOrigine;
}
/**
* Set selectCommisionJSON.
*
* @param string|null $selectCommisionJSON
*
* @return RecCandidature
*/
public function setSelectCommisionJSON($selectCommisionJSON = null)
{
$this->selectCommisionJSON = $selectCommisionJSON;
return $this;
}
/**
* Get selectCommisionJSON.
*
* @return string|null
*/
public function getSelectCommisionJSON()
{
return $this->selectCommisionJSON;
}
public function getStateAudition($id)
{
$states = json_decode($this->selectCommisionJSON,true);
if(is_array($states))
{
if(isset($states[$id]))
return $states[$id];
else
return 0;
}
else
return 0;
}
public function isPopup(): ?bool
{
return $this->popup;
}
public function isValidate(): ?bool
{
return $this->validate;
}
public function isRecevable(): ?bool
{
return $this->recevable;
}
public function isSended(): ?bool
{
return $this->sended;
}
public function isInit(): ?bool
{
return $this->init;
}
/**
* @return Collection<int, RecAvisMembre>
*/
public function getAvisMembre(): Collection
{
return $this->avisMembre;
}
public function addAvisMembre(RecAvisMembre $avisMembre): static
{
if (!$this->avisMembre->contains($avisMembre)) {
$this->avisMembre->add($avisMembre);
$avisMembre->setCandidature($this);
}
return $this;
}
public function removeAvisMembre(RecAvisMembre $avisMembre): static
{
if ($this->avisMembre->removeElement($avisMembre)) {
// set the owning side to null (unless already changed)
if ($avisMembre->getCandidature() === $this) {
$avisMembre->setCandidature(null);
}
}
return $this;
}
}