<?php
namespace App\Entity;
use Serializable;
use App\Repository\UtilisateurRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Persistence\ObjectManagerAware;
use Doctrine\Persistence\Mapping\ClassMetadata;
/**
* @ORM\Entity(repositoryClass=UtilisateurRepository::class)
*/
class Utilisateur implements UserInterface, ObjectManagerAware, \Serializable
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="string", length=255)
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $prenom;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $path_image;
/**
* @ORM\Column(type="integer",nullable=true, options={"default" : 0, "comment":"1 for connected user 0 for not connected "})
*/
private $enligne;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $extension;
/**
* @ORM\OneToMany(targetEntity=Actualite::class, mappedBy="createur")
*/
private $actualites;
/**
* @ORM\OneToMany(targetEntity=Appel::class, mappedBy="agent")
*/
private $appels;
/**
* @ORM\OneToMany(targetEntity=Communication::class, mappedBy="sup")
*/
private $communications;
/**
* @ORM\OneToMany(targetEntity=Compagne::class, mappedBy="createur")
*/
private $compagnes;
/**
* @ORM\OneToMany(targetEntity=Demande::class, mappedBy="createur")
*/
private $demandes;
/**
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="agent")
*/
private $messages;
/**
* @ORM\OneToMany(targetEntity=Priorite::class, mappedBy="agent")
*/
private $priorites;
/**
* @ORM\OneToMany(targetEntity=Projet::class, mappedBy="idCP")
*/
private $projets;
/**
* @ORM\OneToMany(targetEntity=Rdv::class, mappedBy="agentEmetteur")
*/
private $rdvs;
/**
* @ORM\OneToMany(targetEntity=Seance::class, mappedBy="agent")
*/
private $seances;
/**
* @ORM\OneToMany(targetEntity=Suivi::class, mappedBy="user")
*/
private $suivis;
/**
* @ORM\OneToMany(targetEntity=Tache::class, mappedBy="agent")
*/
private $taches;
/**
* @ORM\OneToMany(targetEntity=UcmCdr::class, mappedBy="agent")
*/
private $ucmCdrs;
/**
* @ORM\Column(name="crmServeraddress",type="string", length=255, nullable=true)
*/
private $crmServeraddress;
/**
* @ORM\Column(name="crmUsername",type="string", length=255, nullable=true)
*/
private $crmUsername;
/**
* @ORM\Column(name="crmPassword",type="string", length=255, nullable=true)
*/
private $crmPassword;
/**
* @ORM\ManyToOne(targetEntity=Departement::class, inversedBy="utilisateurs")
* @ORM\JoinColumn(name="id_departement",referencedColumnName="id")
*/
private $departement;
/**
* @ORM\Column(name="agentMission",type="integer", nullable=true,options={"default" : 0,"comment":"(1=Emission) (2=Réception)"})
*/
private $agentMission;
/**
* @ORM\OneToMany(targetEntity=Client::class, mappedBy="idUser")
*/
private $clients;
/**
* @ORM\ManyToMany(targetEntity=Compagne::class, mappedBy="collaborateurs")
*/
private $campagnes;
/**
* @ORM\Column(type="string", length=255)
*/
private $username;
/**
* @ORM\Column(name="lastAccess",type="string", length=255, nullable=true)
*/
private $lastAccess;
/**
* @ORM\Column(name="calendarId",type="string", length=255, nullable=true,options={"comment":"id google calendar sur le compte elearning@ideolearning.com"})
*/
private $calendarId;
/**
* @ORM\Column(type="integer",nullable=true, options={"default" : 1,"comment":"(0=inactive) (1=active) (2=deleted)"})
*/
private $status;
/**
* @ORM\ManyToMany(targetEntity="Projet", mappedBy="coaches")
* @ORM\JoinTable(name="projet_coach")
*/
private $coachProjects;
/**
* Init Object Manager
*/
private $em;
/**
* Initialiser ObjectManager pour qu'on puisse utiliser Reporistory dans l'entity
*
* @param ObjectManager $objectManager
* @param ClassMetadata $classMetadata
* @return void
*/
public function injectObjectManager(\Doctrine\Persistence\ObjectManager $objectManager, ClassMetadata $classMetadata = null)
{
$this->em = $objectManager;
}
public function __construct()
{
$this->actualites = new ArrayCollection();
$this->appels = new ArrayCollection();
$this->communications = new ArrayCollection();
$this->compagnes = new ArrayCollection();
$this->demandes = new ArrayCollection();
$this->messages = new ArrayCollection();
$this->priorites = new ArrayCollection();
$this->projets = new ArrayCollection();
$this->rdvs = new ArrayCollection();
$this->seances = new ArrayCollection();
$this->suivis = new ArrayCollection();
$this->taches = new ArrayCollection();
$this->ucmCdrs = new ArrayCollection();
$this->clients = new ArrayCollection();
$this->campagnes = new ArrayCollection();
$this->coachProjects = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function getPathImage(): ?string
{
return $this->path_image;
}
public function setPathImage(?string $path_image): self
{
$this->path_image = $path_image;
return $this;
}
public function getEnligne(): ?int
{
return $this->enligne;
}
public function setEnligne(int $enligne): self
{
$this->enligne = $enligne;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getExtension(): ?int
{
return $this->extension;
}
public function setExtension(?int $extension): self
{
$this->extension = $extension;
return $this;
}
/**
* @return Collection|Actualite[]
*/
public function getActualites(): Collection
{
return $this->actualites;
}
public function addActualite(Actualite $actualite): self
{
if (!$this->actualites->contains($actualite)) {
$this->actualites[] = $actualite;
$actualite->setCreateur($this);
}
return $this;
}
public function removeActualite(Actualite $actualite): self
{
if ($this->actualites->contains($actualite)) {
$this->actualites->removeElement($actualite);
// set the owning side to null (unless already changed)
if ($actualite->getCreateur() === $this) {
$actualite->setCreateur(null);
}
}
return $this;
}
/**
* @return Collection|Appel[]
*/
public function getAppels(): Collection
{
return $this->appels;
}
public function addAppel(Appel $appel): self
{
if (!$this->appels->contains($appel)) {
$this->appels[] = $appel;
$appel->setAgent($this);
}
return $this;
}
public function removeAppel(Appel $appel): self
{
if ($this->appels->contains($appel)) {
$this->appels->removeElement($appel);
// set the owning side to null (unless already changed)
if ($appel->getAgent() === $this) {
$appel->setAgent(null);
}
}
return $this;
}
/**
* @return Collection|Communication[]
*/
public function getCommunications(): Collection
{
return $this->communications;
}
public function addCommunication(Communication $communication): self
{
if (!$this->communications->contains($communication)) {
$this->communications[] = $communication;
$communication->setSup($this);
}
return $this;
}
public function removeCommunication(Communication $communication): self
{
if ($this->communications->contains($communication)) {
$this->communications->removeElement($communication);
// set the owning side to null (unless already changed)
if ($communication->getSup() === $this) {
$communication->setSup(null);
}
}
return $this;
}
/**
* @return Collection|Compagne[]
*/
public function getCompagnes(): Collection
{
return $this->compagnes;
}
public function addCompagne(Compagne $compagne): self
{
if (!$this->compagnes->contains($compagne)) {
$this->compagnes[] = $compagne;
$compagne->setCreateur($this);
}
return $this;
}
public function removeCompagne(Compagne $compagne): self
{
if ($this->compagnes->contains($compagne)) {
$this->compagnes->removeElement($compagne);
// set the owning side to null (unless already changed)
if ($compagne->getCreateur() === $this) {
$compagne->setCreateur(null);
}
}
return $this;
}
/**
* @return Collection|Demande[]
*/
public function getDemandes(): Collection
{
return $this->demandes;
}
public function addDemande(Demande $demande): self
{
if (!$this->demandes->contains($demande)) {
$this->demandes[] = $demande;
$demande->setCreateur($this);
}
return $this;
}
public function removeDemande(Demande $demande): self
{
if ($this->demandes->contains($demande)) {
$this->demandes->removeElement($demande);
// set the owning side to null (unless already changed)
if ($demande->getCreateur() === $this) {
$demande->setCreateur(null);
}
}
return $this;
}
/**
* @return Collection|Message[]
*/
public function getMessages(): Collection
{
return $this->messages;
}
public function addMessage(Message $message): self
{
if (!$this->messages->contains($message)) {
$this->messages[] = $message;
$message->setAgent($this);
}
return $this;
}
public function removeMessage(Message $message): self
{
if ($this->messages->contains($message)) {
$this->messages->removeElement($message);
// set the owning side to null (unless already changed)
if ($message->getAgent() === $this) {
$message->setAgent(null);
}
}
return $this;
}
/**
* @return Collection|Priorite[]
*/
public function getPriorites(): Collection
{
return $this->priorites;
}
public function addPriorite(Priorite $priorite): self
{
if (!$this->priorites->contains($priorite)) {
$this->priorites[] = $priorite;
$priorite->setAgent($this);
}
return $this;
}
public function removePriorite(Priorite $priorite): self
{
if ($this->priorites->contains($priorite)) {
$this->priorites->removeElement($priorite);
// set the owning side to null (unless already changed)
if ($priorite->getAgent() === $this) {
$priorite->setAgent(null);
}
}
return $this;
}
/**
* @return Collection|Projet[]
*/
public function getProjets(): Collection
{
return $this->projets;
}
public function addProjet(Projet $projet): self
{
if (!$this->projets->contains($projet)) {
$this->projets[] = $projet;
$projet->setIdCP($this);
}
return $this;
}
public function removeProjet(Projet $projet): self
{
if ($this->projets->contains($projet)) {
$this->projets->removeElement($projet);
// set the owning side to null (unless already changed)
if ($projet->getIdCP() === $this) {
$projet->setIdCP(null);
}
}
return $this;
}
/**
* @return Collection|Rdv[]
*/
public function getRdvs(): Collection
{
return $this->rdvs;
}
public function addRdv(Rdv $rdv): self
{
if (!$this->rdvs->contains($rdv)) {
$this->rdvs[] = $rdv;
$rdv->setAgentEmetteur($this);
}
return $this;
}
public function removeRdv(Rdv $rdv): self
{
if ($this->rdvs->contains($rdv)) {
$this->rdvs->removeElement($rdv);
// set the owning side to null (unless already changed)
if ($rdv->getAgentEmetteur() === $this) {
$rdv->setAgentEmetteur(null);
}
}
return $this;
}
/**
* @return Collection|Seance[]
*/
public function getSeances(): Collection
{
return $this->seances;
}
public function addSeance(Seance $seance): self
{
if (!$this->seances->contains($seance)) {
$this->seances[] = $seance;
$seance->setAgent($this);
}
return $this;
}
public function removeSeance(Seance $seance): self
{
if ($this->seances->contains($seance)) {
$this->seances->removeElement($seance);
// set the owning side to null (unless already changed)
if ($seance->getAgent() === $this) {
$seance->setAgent(null);
}
}
return $this;
}
/**
* @return Collection|Suivi[]
*/
public function getSuivis(): Collection
{
return $this->suivis;
}
public function addSuivi(Suivi $suivi): self
{
if (!$this->suivis->contains($suivi)) {
$this->suivis[] = $suivi;
$suivi->setUser($this);
}
return $this;
}
public function removeSuivi(Suivi $suivi): self
{
if ($this->suivis->contains($suivi)) {
$this->suivis->removeElement($suivi);
// set the owning side to null (unless already changed)
if ($suivi->getUser() === $this) {
$suivi->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Tache[]
*/
public function getTaches(): Collection
{
return $this->taches;
}
public function addTach(Tache $tach): self
{
if (!$this->taches->contains($tach)) {
$this->taches[] = $tach;
$tach->setAgent($this);
}
return $this;
}
public function removeTach(Tache $tach): self
{
if ($this->taches->contains($tach)) {
$this->taches->removeElement($tach);
// set the owning side to null (unless already changed)
if ($tach->getAgent() === $this) {
$tach->setAgent(null);
}
}
return $this;
}
/**
* @return Collection|UcmCdr[]
*/
public function getUcmCdrs(): Collection
{
return $this->ucmCdrs;
}
public function addUcmCdr(UcmCdr $ucmCdr): self
{
if (!$this->ucmCdrs->contains($ucmCdr)) {
$this->ucmCdrs[] = $ucmCdr;
$ucmCdr->setAgent($this);
}
return $this;
}
public function removeUcmCdr(UcmCdr $ucmCdr): self
{
if ($this->ucmCdrs->contains($ucmCdr)) {
$this->ucmCdrs->removeElement($ucmCdr);
// set the owning side to null (unless already changed)
if ($ucmCdr->getAgent() === $this) {
$ucmCdr->setAgent(null);
}
}
return $this;
}
public function getCrmServeraddress(): ?string
{
return $this->crmServeraddress;
}
public function setCrmServeraddress(?string $crmServeraddress): self
{
$this->crmServeraddress = $crmServeraddress;
return $this;
}
public function getCrmUsername(): ?string
{
return $this->crmUsername;
}
public function setCrmUsername(?string $crmUsername): self
{
$this->crmUsername = $crmUsername;
return $this;
}
public function getCrmPassword(): ?string
{
return $this->crmPassword;
}
public function setCrmPassword(?string $crmPassword): self
{
$this->crmPassword = $crmPassword;
return $this;
}
public function getDepartement(): ?Departement
{
return $this->departement;
}
public function setDepartement(?Departement $departement): self
{
$this->departement = $departement;
return $this;
}
public function getAgentMission(): ?int
{
return $this->agentMission;
}
public function setAgentMission(?int $agentMission): self
{
$this->agentMission = $agentMission;
return $this;
}
/**
* @return Collection|Client[]
*/
public function getClients(): Collection
{
return $this->clients;
}
public function addClients(Client $clients): self
{
if (!$this->clients->contains($clients)) {
$this->clients[] = $clients;
$clients->setIdUser($this);
}
return $this;
}
public function removeClients(Client $clients): self
{
if ($this->clients->contains($clients)) {
$this->clients->removeElement($clients);
// set the owning side to null (unless already changed)
if ($clients->getIdUser() === $this) {
$clients->setIdUser(null);
}
}
return $this;
}
public function addClient(Client $client): self
{
if (!$this->clients->contains($client)) {
$this->clients[] = $client;
$client->setIdUser($this);
}
return $this;
}
public function removeClient(Client $client): self
{
if ($this->clients->contains($client)) {
$this->clients->removeElement($client);
// set the owning side to null (unless already changed)
if ($client->getIdUser() === $this) {
$client->setIdUser(null);
}
}
return $this;
}
/**
* @return Collection|Compagne[]
*/
public function getCampagnes(): Collection
{
return $this->campagnes;
}
public function addCampagne(Compagne $campagne): self
{
if (!$this->campagnes->contains($campagne)) {
$this->campagnes[] = $campagne;
$campagne->addCollaborateur($this);
}
return $this;
}
public function removeCampagne(Compagne $campagne): self
{
if ($this->campagnes->contains($campagne)) {
$this->campagnes->removeElement($campagne);
$campagne->removeCollaborateur($this);
}
return $this;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getLastAccess(): ?string
{
return $this->lastAccess;
}
public function setLastAccess(?string $lastAccess): self
{
$this->lastAccess = $lastAccess;
return $this;
}
public function getCalendarId(): ?string
{
return $this->calendarId;
}
public function setCalendarId(?string $calendarId): self
{
$this->calendarId = $calendarId;
return $this;
}
/**
* @return Collection|Projet[]
*/
public function getCoachProjects(): Collection
{
return $this->coachProjects;
}
public function addCoachProject(Projet $coachProject): self
{
if (!$this->coachProjects->contains($coachProject)) {
$this->coachProjects[] = $coachProject;
$coachProject->addCoach($this);
}
return $this;
}
public function removeCoachProject(Projet $coachProject): self
{
if ($this->coachProjects->removeElement($coachProject)) {
$coachProject->removeCoach($this);
}
return $this;
}
/**
* Get cdrs Inbound par date
*
* @param string $startDate
* @param string $endDate
* @param boolean $answered
* @return void
*/
public function getCdrsInbound($startDate = '', $endDate = '', $answered = false)
{
$cdrRepo = $this->em->getRepository(UcmCdr::class);
$filters = [];
$filters['start'] = $startDate;
$filters['end'] = $endDate;
$filters['idUtilisateur'] = $this->id;
$filters['answered'] = $answered;
$InboundCdrs = $cdrRepo->FindByInbound($filters);
return $InboundCdrs;
}
/**
* Get cdrs Outbound par date
*
* @param string $startDate
* @param string $endDate
* @param boolean $answered
* @return void
*/
public function getCdrsOutbound($startDate = '', $endDate = '', $answered = false)
{
$cdrRepo = $this->em->getRepository(UcmCdr::class);
$filters = [];
$filters['start'] = $startDate;
$filters['end'] = $endDate;
$filters['idUtilisateur'] = $this->id;
$filters['answered'] = $answered;
$OutboundCdrs = $cdrRepo->FindByOutbound($filters);
return $OutboundCdrs;
}
/**
* Get cdr occupation time (appel avec reponses et sans réponse)
*
* @param string $startDate
* @param string $endDate
* @param boolean $answered
* @return void
*/
public function getCdrsOccupationTime($startDate = '', $endDate = '', $inbound = 3)
{
$cdrRepo = $this->em->getRepository(UcmCdr::class);
$filters = [];
$filters['start'] = $startDate;
$filters['end'] = $endDate;
$filters['idUtilisateur'] = $this->id;
$filters['inbound'] = $inbound;
$occupationTime = $cdrRepo->FindByOccupationTime($filters);
return $occupationTime;
}
/**
* Get cdr occupation time (appel avec reponses et sans réponse)
*
* @param string $startDate
* @param string $endDate
* @param boolean $answered
* @return void
*/
public function getCdrsCommunicationTime($startDate = '', $endDate = '', $inbound = 3)
{
$cdrRepo = $this->em->getRepository(UcmCdr::class);
$filters = [];
$filters['start'] = $startDate;
$filters['end'] = $endDate;
$filters['idUtilisateur'] = $this->id;
$filters['inbound'] = $inbound;
$communicationTime = $cdrRepo->FindByCommunicationTime($filters);
return $communicationTime;
}
/**
* =============== implementer la class \Serializable pour regler le probleme : ==========
* =============== Serialization of 'Closure' is not allowed ==========
* =======================================================================================
*/
public function serialize()
{
return serialize([
$this->id,
$this->email,
$this->password,
]);
}
public function unserialize($data)
{
list(
$this->id,
$this->email,
$this->password
) = unserialize($data);
}
}