<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use APY\DataGridBundle\Grid\Mapping as GRID;
use App\Entity\RecTypePopulation;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Type;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Client
*
* @ORM\Table(name="rec_poste")
* @ORM\HasLifecycleCallbacks
* @ORM\Entity(repositoryClass="App\Repository\RecPosteRepository")
* @GRID\Source(columns="id, typepopulation.identifiant, idInterne, openDate, closeDate")
*/
class RecPoste
{
/**
* @var integer
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @GRID\Column(title="Id", size="100", type="text",visible=false)
*/
private $id;
/**
* @ORM\Column(type= "string", length=150)
* @Assert\NotBlank()
* @GRID\Column(title="Intitulé", size="150", type="text")
*/
protected $title;
/**
* @var \DateTime
* @ORM\Column(name="open_date", type="datetime")
* @GRID\Column(title="Date d'ouverture", size="150", type="date", format="d/m/Y à h:i"),
*/
private $openDate;
/**
* @var \DateTime
* @ORM\Column(name="close_date", type="datetime")
* @GRID\Column(title="Date de fermeture", size="150", type="date", format="d/m/Y à h:i"),
*/
private $closeDate;
/**
* @var string
* @ORM\Column(name="audition", type="text", nullable=true)
*/
private $audition;
/**
* @var \DateTime
* @ORM\Column(name="audition_date", type="datetime", nullable=true)
*/
private $auditionDate;
/**
* @var \DateTime
* @ORM\Column(name="convocation_date", type="datetime", nullable=true)
*/
private $convocationDate;
/**
* @var \DateTime
* @ORM\Column(name="response_date", type="datetime", nullable=true)
*/
private $responseDate;
/**
*
* @ORM\ManyToOne(targetEntity="RecTypePopulation", inversedBy="postes")
* @ORM\JoinColumn(name="typepopulation_id", referencedColumnName="id")
* @GRID\Column(field="typepopulation.identifiant", title="Type de Population",size="150", type="text")
*/
protected $typepopulation;
/**
* @var string
* @ORM\Column(name="id_interne", type="string", length=50)
* @GRID\Column(title="Numéro interne", size="150", type="text")
*/
private $idInterne;
/**
* @var string
* @ORM\Column(name="id_externe", type="string", length=50,nullable=true)
* @GRID\Column(title="Numéro externe", size="150", type="text")
*/
private $idExterne;
/**
* @var string
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var string
* @ORM\Column(name="information", type="text", nullable=true)
*/
private $information;
/**
* @var string
* @ORM\Column(name="comments", type="text", nullable=true)
*/
private $comments;
/**
* @var string
* @ORM\Column(name="usernotaccess", type="text", nullable=true)
*/
private $usernotaccess;
/**
* @ORM\OneToMany(targetEntity="App\Entity\RecCandidature", mappedBy="poste",cascade={"persist"})
*/
private $candidatures;
/**
* @ORM\Column(name="is_spontane", type="boolean")
*/
private $isSpontane;
/**
* @ORM\Column(name="archive", type="boolean", nullable=true)
*/
private $archive;
/**
* @ORM\Column(name="pdf", type="boolean", nullable=true)
*/
private $pdf;
/**
*
* @ORM\OneToOne(targetEntity="App\Entity\RecDocument", cascade={"persist"})
**/
protected $fiche;
/**
*
* @ORM\OneToOne(targetEntity="App\Entity\RecDocument", cascade={"persist"})
**/
protected $annexe;
/**
* @ORM\OneToMany(targetEntity="RecDocumentPoste", mappedBy="poste", cascade={"remove"})
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity="RecEmail", mappedBy="poste", cascade={"remove"})
*/
private $emails;
private $nbStatusRH;
function __construct()
{
$this->openDate = new \DateTime('now');
$this->openDate->setTime(0, 0, 0);
$this->closeDate = new \DateTime('now');
$this->closeDate->setTime(23, 59, 59);
$this->candidatures = new ArrayCollection();
$this->isSpontane = false;
$this->documents = new ArrayCollection();
$this->emails = new ArrayCollection();
$this->pdf=false;
$this->archive=false;
$this->isSpontane=false;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set openDate
*
* @param \DateTime $openDate
* @return RecPoste
*/
public function setOpenDate($openDate)
{
$this->openDate = $openDate;
return $this;
}
/**
* Get openDate
*
* @return \DateTime
*/
public function getOpenDate()
{
return $this->openDate;
}
/**
* Set closeDate
*
* @param \DateTime $closeDate
* @return RecPoste
*/
public function setCloseDate($closeDate)
{
$this->closeDate = $closeDate;
return $this;
}
/**
* Get closeDate
*
* @return \DateTime
*/
public function getCloseDate()
{
return $this->closeDate;
}
/**
* Set id_interne
*
* @param string $idInterne
* @return RecPoste
*/
public function setIdInterne($idInterne)
{
$this->idInterne = $idInterne;
return $this;
}
/**
* Get id_interne
*
* @return string
*/
public function getIdInterne()
{
return $this->idInterne;
}
/**
* Set id_externe
*
* @param string $idExterne
* @return RecPoste
*/
public function setIdExterne($idExterne)
{
$this->idExterne = $idExterne;
return $this;
}
/**
* Get id_externe
*
* @return string
*/
public function getIdExterne()
{
return $this->idExterne;
}
/**
* Set typepopulation
*
* @param \App\Entity\RecTypePopulation $typepopulation
* @return RecPoste
*/
public function setTypepopulation(\App\Entity\RecTypePopulation $typepopulation = null)
{
$this->typepopulation = $typepopulation;
return $this;
}
/**
* Get typepopulation
*
* @return \Dosi\RecrutementBundle\Entity\RecTypePopulation
*/
public function getTypepopulation()
{
return $this->typepopulation;
}
/**
* Add candidatures
*
* @param \App\Entity\RecCandidature $candidatures
* @return RecPoste
*/
public function addCandidature(\App\Entity\RecCandidature $candidatures)
{
$this->candidatures[] = $candidatures;
return $this;
}
/**
* Remove candidatures
*
* @param \App\Entity\RecCandidature $candidatures
*/
public function removeCandidature(\App\Entity\RecCandidature $candidatures)
{
$this->candidatures->removeElement($candidatures);
}
/**
* Get candidatures
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCandidatures()
{
return $this->candidatures;
}
public function getNbCandidatures()
{
return count($this->candidatures);
}
/**
* Set title
*
* @param string $title
* @return RecPoste
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description
*
* @param string $description
* @return RecPoste
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set fiche
*
* @param \App\Entity\RecDocument $fiche
* @return RecPoste
*/
public function setFiche(\App\Entity\RecDocument $fiche = null)
{
$this->fiche = $fiche;
return $this;
}
/**
* Get fiche
*
* @return \Dosi\RecrutementBundle\Entity\RecDocument
*/
public function getFiche()
{
return $this->fiche;
}
/**
* Set isSpontane
*
* @param boolean $isSpontane
* @return RecPoste
*/
public function setIsSpontane($isSpontane)
{
$this->isSpontane = $isSpontane;
return $this;
}
/**
* Get isSpontane
*
* @return boolean
*/
public function getIsSpontane()
{
return $this->isSpontane;
}
/**
* Set annexe
*
* @param \App\Entity\RecDocument $annexe
* @return RecPoste
*/
public function setAnnexe(\App\Entity\RecDocument $annexe = null)
{
$this->annexe = $annexe;
return $this;
}
/**
* Get annexe
*
* @return \Dosi\RecrutementBundle\Entity\RecDocument
*/
public function getAnnexe()
{
return $this->annexe;
}
/**
* Set archive
*
* @param boolean $archive
* @return RecPoste
*/
public function setArchive($archive)
{
$this->archive = $archive;
return $this;
}
/**
* Get archive
*
* @return boolean
*/
public function getArchive()
{
return $this->archive;
}
/**
* Set usernotaccess
*
* @param string $usernotaccess
* @return RecPoste
*/
public function setUsernotaccess($usernotaccess)
{
$this->usernotaccess = $usernotaccess;
return $this;
}
/**
* Get usernotaccess
*
* @return string
*/
public function getUsernotaccess()
{
return $this->usernotaccess;
}
/**
* Add documents
*
* @param \App\Entity\RecDocumentPoste $documents
* @return RecPoste
*/
public function addDocument(\App\Entity\RecDocumentPoste $documents)
{
$this->documents[] = $documents;
return $this;
}
/**
* Remove documents
*
* @param \App\Entity\RecDocumentPoste $documents
*/
public function removeDocument(\App\Entity\RecDocumentPoste $documents)
{
$this->documents->removeElement($documents);
}
/**
* Get documents
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getDocuments()
{
return $this->documents;
}
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;
}
/**
* Add emails
*
* @param \App\Entity\RecEmail $emails
* @return RecPoste
*/
public function addEmail(\App\Entity\RecEmail $emails)
{
$this->emails[] = $emails;
return $this;
}
/**
* Remove emails
*
* @param \App\Entity\RecEmail $emails
*/
public function removeEmail(\App\Entity\RecEmail $emails)
{
$this->emails->removeElement($emails);
}
/**
* Get emails
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getEmails()
{
return $this->emails;
}
/**
* Set audition
*
* @param string $audition
* @return RecPoste
*/
public function setAudition($audition)
{
$this->audition = $audition;
return $this;
}
/**
* Get audition
*
* @return string
*/
public function getAudition()
{
return $this->audition;
}
/**
* Set auditionDate
*
* @param \DateTime $auditionDate
* @return RecPoste
*/
public function setAuditionDate($auditionDate)
{
$this->auditionDate = $auditionDate;
return $this;
}
/**
* Get auditionDate
*
* @return \DateTime
*/
public function getAuditionDate()
{
return $this->auditionDate;
}
/**
* Set convocationDate
*
* @param \DateTime $convocationDate
* @return RecPoste
*/
public function setConvocationDate($convocationDate)
{
$this->convocationDate = $convocationDate;
return $this;
}
/**
* Get convocationDate
*
* @return \DateTime
*/
public function getConvocationDate()
{
return $this->convocationDate;
}
/**
* Set responseDate
*
* @param \DateTime $responseDate
* @return RecPoste
*/
public function setResponseDate($responseDate)
{
$this->responseDate = $responseDate;
return $this;
}
/**
* Get responseDate
*
* @return \DateTime
*/
public function getResponseDate()
{
return $this->responseDate;
}
/**
* Set comments.
*
* @param string|null $comments
*
* @return RecPoste
*/
public function setComments($comments = null)
{
$this->comments = $comments;
return $this;
}
/**
* Get comments.
*
* @return string|null
*/
public function getComments()
{
return $this->comments;
}
public function setStatusNbRH($nb)
{
$this->nbStatusRH = $nb;
return $this;
}
public function getStatusNbRH()
{
return $this->nbStatusRH;
}
public function isCandidat($email)
{
foreach($this->candidatures as $candidature)
{
if($candidature->getCandidat()->getEmail()==$email)
return $candidature;
}
return false;
}
public function isIsSpontane(): ?bool
{
return $this->isSpontane;
}
public function isArchive(): ?bool
{
return $this->archive;
}
public function isAuthorized($login): ?bool
{
if(in_array($login,$this->getTypepopulation()->getUids(true)))
return true;
else
return false;
}
public function getInformation(): ?string
{
return $this->information;
}
public function setInformation(?string $information): static
{
$this->information = $information;
return $this;
}
public function isPdf(): ?bool
{
return $this->pdf;
}
public function setPdf(?bool $pdf): static
{
$this->pdf = $pdf;
return $this;
}
}