<?php
namespace App\Entity;
use App\Repository\LigneRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=LigneRepository::class)
*/
class Ligne
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $lgn_nom;
/**
* @ORM\Column(type="boolean")
*/
private $lgn_actif;
/**
* @ORM\ManyToOne(targetEntity=CentreType::class, inversedBy="lignes", fetch="EAGER")
* @ORM\JoinColumn(nullable=true)
*/
private $centre_type;
/**
* @ORM\OneToMany(targetEntity=LigneBlocage::class, mappedBy="ligne")
*/
private $ligneBlocages;
/**
* @ORM\ManyToOne(targetEntity=CentreGroupe::class, inversedBy="lignes")
* @ORM\JoinColumn(nullable=false)
*/
private $centre_groupe;
/**
* @ORM\OneToMany(targetEntity=Rendezvous::class, mappedBy="ligne")
*/
private $rendezVouses;
/**
* @ORM\OneToMany(targetEntity=CentrePartenaire::class, mappedBy="ligne", orphanRemoval=true)
*/
private $centrePartenaires;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $id_old;
/**
* @ORM\OneToMany(targetEntity=LigneHoraire::class, mappedBy="ligne", orphanRemoval=true, fetch="EAGER")
*/
private $ligneHoraires;
/**
* @ORM\ManyToMany(targetEntity=CentrePrestation::class, inversedBy="lignes")
*/
private $prestations;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $lgn_vl;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $lgn_pl;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $lgn_cl;
/**
* @ORM\Column(type="string", length=15, nullable=true)
*/
private $color;
public function __construct()
{
$this->ligneBlocages = new ArrayCollection();
$this->rendezVouses = new ArrayCollection();
$this->centrePartenaires = new ArrayCollection();
$this->ligneHoraires = new ArrayCollection();
$this->prestations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLgnNom(): ?string
{
return $this->lgn_nom;
}
public function setLgnNom(string $lgn_nom): self
{
$this->lgn_nom = $lgn_nom;
return $this;
}
public function isLgnActif(): ?bool
{
return $this->lgn_actif;
}
public function setLgnActif(bool $lgn_actif): self
{
$this->lgn_actif = $lgn_actif;
return $this;
}
public function getCentreType(): ?CentreType
{
return $this->centre_type;
}
public function setCentreType(?CentreType $centre_type): self
{
$this->centre_type = $centre_type;
return $this;
}
/**
* @return Collection<int, LigneBlocage>
*/
public function getLigneBlocages(): Collection
{
return $this->ligneBlocages;
}
public function addLigneBlocage(LigneBlocage $ligneBlocage): self
{
if (!$this->ligneBlocages->contains($ligneBlocage)) {
$this->ligneBlocages[] = $ligneBlocage;
$ligneBlocage->setLigne($this);
}
return $this;
}
public function removeLigneBlocage(LigneBlocage $ligneBlocage): self
{
if ($this->ligneBlocages->removeElement($ligneBlocage)) {
// set the owning side to null (unless already changed)
if ($ligneBlocage->getLigne() === $this) {
$ligneBlocage->setLigne(null);
}
}
return $this;
}
public function getCentreGroupe(): ?CentreGroupe
{
return $this->centre_groupe;
}
public function setCentreGroupe(?CentreGroupe $centre_groupe): self
{
$this->centre_groupe = $centre_groupe;
return $this;
}
/**
* @return Collection<int, Rendezvous>
*/
public function getRendezVouses(): Collection
{
return $this->rendezVouses;
}
public function addRendezVouse(Rendezvous $rendezVouse): self
{
if (!$this->rendezVouses->contains($rendezVouse)) {
$this->rendezVouses[] = $rendezVouse;
$rendezVouse->setLigne($this);
}
return $this;
}
public function removeRendezVouse(Rendezvous $rendezVouse): self
{
if ($this->rendezVouses->removeElement($rendezVouse)) {
// set the owning side to null (unless already changed)
if ($rendezVouse->getLigne() === $this) {
$rendezVouse->setLigne(null);
}
}
return $this;
}
/**
* @return Collection<int, CentrePartenaire>
*/
public function getCentrePartenaires(): Collection
{
return $this->centrePartenaires;
}
public function addCentrePartenaire(CentrePartenaire $centrePartenaire): self
{
if (!$this->centrePartenaires->contains($centrePartenaire)) {
$this->centrePartenaires[] = $centrePartenaire;
$centrePartenaire->setLigne($this);
}
return $this;
}
public function removeCentrePartenaire(CentrePartenaire $centrePartenaire): self
{
if ($this->centrePartenaires->removeElement($centrePartenaire)) {
// set the owning side to null (unless already changed)
if ($centrePartenaire->getLigne() === $this) {
$centrePartenaire->setLigne(null);
}
}
return $this;
}
public function getIdOld(): ?int
{
return $this->id_old;
}
public function setIdOld(int $id_old): self
{
$this->id_old = $id_old;
return $this;
}
/**
* @return Collection<int, LigneHoraire>
*/
public function getLigneHoraires(): Collection
{
return $this->ligneHoraires;
}
public function getFormatLigneHoraire()
{
$groupesHoraireLigne = array();
foreach ($this->ligneHoraires as $numero => $demijournee) {
if (!array_key_exists($demijournee->getLgnHorListeJours(), $groupesHoraireLigne)) $groupesHoraireLigne[$demijournee->getLgnHorListeJours()] = array();
$groupesHoraireLigne[$demijournee->getLgnHorListeJours()][($numero % 2 == 0 ? 'am' : 'pm')] = array(
'ouverture' => $demijournee->isLgnHorOuvert() ? $demijournee->getLgnHorDebut()->format('Hi') : "",
'fermeture' => $demijournee->isLgnHorOuvert() ? $demijournee->getLgnHorFin()->format('Hi') : "",
);
}
return $groupesHoraireLigne;
}
public function addLigneHoraire(LigneHoraire $ligneHoraire): self
{
if (!$this->ligneHoraires->contains($ligneHoraire)) {
$this->ligneHoraires[] = $ligneHoraire;
$ligneHoraire->setLigne($this);
}
return $this;
}
public function removeLigneHoraire(LigneHoraire $ligneHoraire): self
{
if ($this->ligneHoraires->removeElement($ligneHoraire)) {
// set the owning side to null (unless already changed)
if ($ligneHoraire->getLigne() === $this) {
$ligneHoraire->setLigne(null);
}
}
return $this;
}
/**
* @return Collection<int, CentrePrestation>
*/
public function getPrestations(): Collection
{
return $this->prestations;
}
public function addPrestation(CentrePrestation $prestation): self
{
if (!$this->prestations->contains($prestation)) {
$this->prestations[] = $prestation;
}
return $this;
}
public function removePrestation(CentrePrestation $prestation): self
{
$this->prestations->removeElement($prestation);
return $this;
}
public function isLgnVl(): ?bool
{
return $this->lgn_vl;
}
public function setLgnVl(?bool $lgn_vl): self
{
$this->lgn_vl = $lgn_vl;
return $this;
}
public function isLgnPl(): ?bool
{
return $this->lgn_pl;
}
public function setLgnPl(?bool $lgn_pl): self
{
$this->lgn_pl = $lgn_pl;
return $this;
}
public function isLgnCl(): ?bool
{
return $this->lgn_cl;
}
public function setLgnCl(?bool $lgn_cl): self
{
$this->lgn_cl = $lgn_cl;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
}