<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\AgentRepository")
*/
class Agent
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $nomAg;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contactAg;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imageAg;
/**
* @ORM\Column(type="string", length=1000, nullable=true)
*/
private $tokenFlutter;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contactWhatsapp;
/**
* @ORM\Column(type="string", length=255)
*/
private $sexe;
/**
* @ORM\Column(type="boolean")
*/
private $typeClientAgent;
/**
* @var string|null
*/
private $picture_base64;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Bois", mappedBy="idAg")
*/
private $bois;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Commande", mappedBy="IdAg")
*/
private $agent;
/**
* @ORM\OneToMany(targetEntity="App\Entity\TransfertEnvoie", mappedBy="agent")
*/
private $transfertEnvoies;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contactAg1;
/**
* @ORM\OneToMany(targetEntity="App\Entity\RemarqueConteneur", mappedBy="agent")
*/
private $remarqueConteneurs;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Commande", mappedBy="IdCl")
*/
private $commande;
/**
* @ORM\OneToMany(targetEntity=AutrePaiement::class, mappedBy="agent")
*/
private $autrePaiements;
/**
* @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="agents")
*/
private $ville;
/**
* @ORM\OneToOne(targetEntity=Utilisateur::class, mappedBy="idAg", cascade={"persist", "remove"})
*/
private $utilisateur;
/**
* @ORM\Column(type="integer")
*/
private $code;
/**
* @ORM\Column(type="string", length=10)
*/
private $prefixcode;
/**
* @ORM\OneToMany(targetEntity=Reception::class, mappedBy="client")
*/
private $receptions;
/**
* @ORM\Column(type="string", length=5)
*/
private $langue;
/**
* @ORM\Column(type="boolean")
*/
private $mco;
/**
* @ORM\Column(type="boolean")
*/
private $cargoAgent;
/**
* @ORM\OneToMany(targetEntity=Reduction::class, mappedBy="IdAg")
*/
private $reductions;
/**
* @ORM\Column(type="boolean")
*/
private $ancien;
/**
* @ORM\Column(type="boolean")
*/
private $isVerifier;
/**
* @ORM\Column(type="string", length=25)
*/
private $codeverification;
/**
* @ORM\Column(type="string", length=3)
*/
private $clientblocker;
/**
* @ORM\Column(type="string", length=5)
*/
private $admin;
/**
* CHANGEMENT 2026 : Relation OneToMany pour gérer plusieurs conteneurs
* @ORM\OneToMany(targetEntity=ProgrammeContenaire::class, mappedBy="agentGestionnaire")
*/
private $programmeContenaireGestionnaire;
/**
* AJOUT 2026 : Signature faciale (Vecteur de reconnaissance)
* @ORM\Column(type="json", nullable=true)
*/
private $faceSignature;
/**
* AJOUT 2026 : Historique des pointages
* @ORM\OneToMany(targetEntity="App\Entity\Attendance", mappedBy="agent", orphanRemoval=true)
*/
private $attendances;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $dailyRate;
public function __construct()
{
$this->bois = new ArrayCollection();
$this->commande = new ArrayCollection();
$this->agent = new ArrayCollection();
$this->transfertEnvoies = new ArrayCollection();
$this->remarqueConteneurs = new ArrayCollection();
$this->autrePaiements = new ArrayCollection();
$this->receptions = new ArrayCollection();
$this->reductions = new ArrayCollection();
$this->programmeContenaireGestionnaire = new ArrayCollection();
$this->attendances = new ArrayCollection();
$this->mco = false;
$this->cargoAgent = false;
$this->ancien = false;
$this->isVerifier = false;
$this->contactAg = '0';
$this->contactAg1 = '0';
$this->contactWhatsapp = '0';
$this->langue = 'fr';
}
public function getId(): ?int
{
return $this->id;
}
public function getDailyRate(): ?float
{
// On retourne 10.0 par défaut si le taux n'est pas défini
return $this->dailyRate ?? 10.0;
}
public function setDailyRate(?float $dailyRate): self
{
$this->dailyRate = $dailyRate;
return $this;
}
public function getNomAg(): ?string
{
return $this->nomAg ? strtoupper($this->nomAg) : null;
}
public function setNomAg(string $nomAg): self
{
$this->nomAg = $nomAg;
return $this;
}
public function getContactAg(): ?string
{
return $this->contactAg;
}
public function setContactAg(?string $contactAg): self
{
$this->contactAg = $contactAg;
return $this;
}
public function getImageAg(): ?string
{
return $this->imageAg;
}
public function setImageAg(?string $imageAg): self
{
$this->imageAg = $imageAg;
return $this;
}
public function getSexe(): ?string
{
return $this->sexe;
}
public function setSexe(string $sexe): self
{
$this->sexe = $sexe;
return $this;
}
public function getTypeClientAgent(): ?bool
{
return $this->typeClientAgent;
}
public function setTypeClientAgent(bool $typeClientAgent): self
{
$this->typeClientAgent = $typeClientAgent;
return $this;
}
public function getPictureBase64(): ?string
{
return $this->picture_base64;
}
public function setPictureBase64(?string $picture_base64): self
{
$this->picture_base64 = $picture_base64;
return $this;
}
public function __toString()
{
return (string) $this->nomAg;
}
/** @return Collection|Bois[] */
public function getBois(): Collection { return $this->bois; }
public function addBois(Bois $bois): self
{
if (!$this->bois->contains($bois)) {
$this->bois[] = $bois;
$bois->setIdAg($this);
}
return $this;
}
/** @return Collection|TransfertEnvoie[] */
public function getTransfertEnvoies(): Collection { return $this->transfertEnvoies; }
/** @return Collection|Commande[] */
public function getCommande(): Collection { return $this->commande; }
/** @return Collection|Commande[] */
public function getAgent(): Collection { return $this->agent; }
public function getContactAg1(): ?string { return $this->contactAg1; }
public function setContactAg1(?string $contactAg1): self
{
$this->contactAg1 = $contactAg1;
return $this;
}
/** @return Collection|RemarqueConteneur[] */
public function getRemarqueConteneurs(): Collection { return $this->remarqueConteneurs; }
/** @return Collection|AutrePaiement[] */
public function getAutrePaiements(): Collection { return $this->autrePaiements; }
public function getTokenFlutter(): ?string { return $this->tokenFlutter; }
public function setTokenFlutter(?string $tokenFlutter): self { $this->tokenFlutter = $tokenFlutter; return $this; }
public function getContactWhatsapp(): ?string { return $this->contactWhatsapp; }
public function setContactWhatsapp(?string $contactWhatsapp): self { $this->contactWhatsapp = $contactWhatsapp; return $this; }
public function getVille(): ?Ville { return $this->ville; }
public function setVille(?Ville $ville): self { $this->ville = $ville; return $this; }
public function getUtilisateur(): ?Utilisateur { return $this->utilisateur; }
public function setUtilisateur(?Utilisateur $utilisateur): self
{
if ($utilisateur === null && $this->utilisateur !== null) {
$this->utilisateur->setIdAg(null);
}
if ($utilisateur !== null && $utilisateur->getIdAg() !== $this) {
$utilisateur->setIdAg($this);
}
$this->utilisateur = $utilisateur;
return $this;
}
public function getCode(): ?int { return $this->code; }
public function setCode(int $code): self { $this->code = $code; return $this; }
public function getPrefixcode(): ?string { return $this->prefixcode; }
public function setPrefixcode(string $prefixcode): self { $this->prefixcode = $prefixcode; return $this; }
public function getLangue(): ?string { return $this->langue; }
public function setLangue(string $langue): self { $this->langue = $langue; return $this; }
public function isMco(): ?bool { return $this->mco; }
public function setMco(bool $mco): self { $this->mco = $mco; return $this; }
public function isAncien(): ?bool { return $this->ancien; }
public function setAncien(bool $ancien): self { $this->ancien = $ancien; return $this; }
public function isCargoAgent(): ?bool { return $this->cargoAgent; }
public function setCargoAgent(bool $cargoAgent): self { $this->cargoAgent = $cargoAgent; return $this; }
public function isIsVerifier(): ?bool { return $this->isVerifier; }
public function setIsVerifier(bool $isVerifier): self { $this->isVerifier = $isVerifier; return $this; }
public function getCodeverification(): ?string { return $this->codeverification; }
public function setCodeverification(string $codeverification): self { $this->codeverification = $codeverification; return $this; }
public function getClientblocker(): ?string { return $this->clientblocker; }
public function setClientblocker(string $clientblocker): self { $this->clientblocker = $clientblocker; return $this; }
public function getAdmin(): ?string { return $this->admin; }
public function setAdmin(string $admin): self { $this->admin = $admin; return $this; }
/**
* @return Collection|ProgrammeContenaire[]
*/
public function getProgrammeContenaireGestionnaire(): Collection
{
return $this->programmeContenaireGestionnaire;
}
public function addProgrammeContenaireGestionnaire(ProgrammeContenaire $programme): self
{
if (!$this->programmeContenaireGestionnaire->contains($programme)) {
$this->programmeContenaireGestionnaire[] = $programme;
$programme->setAgentGestionnaire($this);
}
return $this;
}
public function removeProgrammeContenaireGestionnaire(ProgrammeContenaire $programme): self
{
if ($this->programmeContenaireGestionnaire->removeElement($programme)) {
if ($programme->getAgentGestionnaire() === $this) {
$programme->setAgentGestionnaire(null);
}
}
return $this;
}
/**
* NOUVEAUTÉ 2026 : GETTERS ET SETTERS RECONNAISSANCE FACIALE
*/
public function getFaceSignature(): ?array
{
return $this->faceSignature;
}
public function setFaceSignature(?array $faceSignature): self
{
$this->faceSignature = $faceSignature;
return $this;
}
/**
* NOUVEAUTÉ 2026 : GESTION DES POINTAGES
* @return Collection|Attendance[]
*/
public function getAttendances(): Collection
{
return $this->attendances;
}
public function addAttendance(Attendance $attendance): self
{
if (!$this->attendances->contains($attendance)) {
$this->attendances[] = $attendance;
$attendance->setAgent($this);
}
return $this;
}
public function removeAttendance(Attendance $attendance): self
{
if ($this->attendances->removeElement($attendance)) {
if ($attendance->getAgent() === $this) {
$attendance->setAgent(null);
}
}
return $this;
}
}