src/Entity/Gestiform/Formations/Catalogue/Theme/Theme.php line 20

  1. <?php
  2. namespace App\Entity\Gestiform\Formations\Catalogue\Theme;
  3. use DateTime;
  4. use App\Entity\AbstractEntity;
  5. use App\Entity\Common\Upload;
  6. use App\Entity\Gestiform\Admin\Tarifs\TarifVenteTheme;
  7. use App\Entity\Gestiform\Admin\Tarifs\TarifVenteThemeIntra;
  8. use App\Entity\Gestiform\Formations\Catalogue\Certification;
  9. use App\Entity\Gestiform\Formations\Catalogue\Parcours\Parcours;
  10. use App\Repository\Gestiform\Formations\Catalogue\Theme\ThemeRepository;
  11. use App\Entity\Trait\SortableEntity;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. #[ORM\Entity(repositoryClassThemeRepository::class)]
  16. class Theme extends AbstractEntity
  17. {
  18.     use SortableEntity;
  19.     #[ORM\Column(type'string'length255nullablefalse)]
  20.     private string $intitule;
  21.     #[ORM\Column(type'string'length255nullabletrue)]
  22.      private ?string $code null;
  23.     #[ORM\Column(type'string'length255nullabletrue)]
  24.     private ?string $altBanniere null;
  25.     #[ORM\Column(type'string'length255nullabletrue)]
  26.     private ?string $altVignette null;
  27.     #[ORM\Column(type'string'length255nullabletrue)]
  28.     private ?string $couleur null;
  29.     #[ORM\Column(type'string'length255nullabletrue)]
  30.     private ?string $commentaire null;
  31.     #[ORM\Column(type'string'length255nullabletrue)]
  32.     private ?string $seotitre null;
  33.     #[ORM\Column(type'string'length255nullabletrue)]
  34.     private ?string $seodescription null;
  35.     #[ORM\Column(type'string'length255nullabletrue)]
  36.     private ?string $path null;
  37.     #[ORM\Column(type'boolean')]
  38.     private ?bool $publication true;
  39.     #[ORM\JoinColumn(nullabletrue)]
  40.     #[ORM\OneToOne(targetEntityUpload::class, cascade: ['persist''remove'])]
  41.     private ?Upload $vignette null;
  42.     #[ORM\JoinColumn(nullabletrue)]
  43.     #[ORM\OneToOne(targetEntityUpload::class, cascade: ['persist''remove'])]
  44.     private ?Upload $banniere null;
  45.     #[ORM\OneToMany(mappedBy'theme'targetEntitySousThemeTheme::class)]
  46.     private Collection $sousThemeThemes;
  47.     #[ORM\OneToMany(mappedBy'theme'targetEntityCertification::class)]
  48.     private Collection $certifications;
  49.     #[ORM\ManyToMany(targetEntityParcours::class, mappedBy'themes')]
  50.     private Collection $parcours;
  51.     #[ORM\OneToMany(mappedBy'theme'targetEntityTarifVenteTheme::class, cascade: ['persist''remove'])]
  52.     private Collection $tarifsVentes;
  53.     #[ORM\OneToMany(mappedBy'theme'targetEntityTarifVenteThemeIntra::class, cascade: ['persist''remove'])]
  54.     private Collection $tarifsVenteIntras;
  55.     #[ORM\ManyToOne(targetEntityTarifVenteTheme::class)]
  56.     private ?TarifVenteTheme $tarifVenteDefaut null;
  57.     #[ORM\ManyToOne(targetEntityTarifVenteThemeIntra::class)]
  58.     private ?TarifVenteThemeIntra $tarifventeintradefaut null;
  59.     #[ORM\OneToMany(mappedBy'theme'targetEntityParcours::class)]
  60.     private Collection $defaultParcours;
  61.     public function __construct()
  62.     {
  63.         $this->sousThemeThemes = new ArrayCollection();
  64.         $this->certifications = new ArrayCollection();
  65.         $this->parcours = new ArrayCollection();
  66.         $this->tarifsVentes = new ArrayCollection();
  67.         $this->tarifsVenteIntras = new ArrayCollection();
  68.         $this->defaultParcours = new ArrayCollection();
  69.     }
  70.     public function getIntitule(): ?string
  71.     {
  72.         return $this->intitule;
  73.     }
  74.     public function getTarifVenteActuel()
  75.     {
  76.         if (count($this->getTarifsVentes()) === 0) {
  77.             return $this->getTarifVenteDefaut();
  78.         }
  79.         $datedujour = new DateTime();
  80.         $datedujour->setTime(00);
  81.         // retourne le tarif dans les dates actuelles
  82.         foreach ($this->getTarifsVentes() as $tarif) {
  83.             if ($tarif->getStart() <= $datedujour &&
  84.                 ($tarif->getEnd() >= $datedujour || is_null($tarif->getEnd()))) {
  85.                 return $tarif;
  86.             }
  87.         }
  88.         return $this->getTarifVenteDefaut();
  89.     }
  90.     public function getTarifVenteIntraActuel()
  91.     {
  92.         $datedujour = new DateTime();
  93.         $datedujour->setTime(00);
  94.         // retourne le tarif dans les dates actuelles
  95.         foreach ($this->getTarifsVenteIntras() as $tarif) {
  96.             if ($tarif->getStart() <= $datedujour && ($tarif->getEnd() >= $datedujour || is_null($tarif->getEnd()))) {
  97.                 return $tarif;
  98.             }
  99.         }
  100.         return $this->getTarifVenteDefaut();
  101.     }
  102.     public function setIntitule(string $intitule): self
  103.     {
  104.         $this->intitule $intitule;
  105.         return $this;
  106.     }
  107.     public function getCode(): ?string
  108.     {
  109.         return $this->code;
  110.     }
  111.     public function setCode(?string $code): self
  112.     {
  113.         $this->code $code;
  114.         return $this;
  115.     }
  116.     public function getAltBanniere(): ?string
  117.     {
  118.         return $this->altBanniere;
  119.     }
  120.     public function setAltBanniere(?string $altBanniere): self
  121.     {
  122.         $this->altBanniere $altBanniere;
  123.         return $this;
  124.     }
  125.     public function getAltVignette(): ?string
  126.     {
  127.         return $this->altVignette;
  128.     }
  129.     public function setAltVignette(?string $altVignette): self
  130.     {
  131.         $this->altVignette $altVignette;
  132.         return $this;
  133.     }
  134.     public function getCouleur(): ?string
  135.     {
  136.         return $this->couleur;
  137.     }
  138.     public function setCouleur(?string $couleur): self
  139.     {
  140.         $this->couleur $couleur;
  141.         return $this;
  142.     }
  143.     public function getCommentaire(): ?string
  144.     {
  145.         return $this->commentaire;
  146.     }
  147.     public function setCommentaire(?string $commentaire): self
  148.     {
  149.         $this->commentaire $commentaire;
  150.         return $this;
  151.     }
  152.     public function getSeotitre(): ?string
  153.     {
  154.         return $this->seotitre;
  155.     }
  156.     public function setSeotitre(?string $seotitre): self
  157.     {
  158.         $this->seotitre $seotitre;
  159.         return $this;
  160.     }
  161.     public function getSeodescription(): ?string
  162.     {
  163.         return $this->seodescription;
  164.     }
  165.     public function setSeodescription(?string $seodescription): self
  166.     {
  167.         $this->seodescription $seodescription;
  168.         return $this;
  169.     }
  170.     public function getPublication(): ?bool
  171.     {
  172.         return $this->publication;
  173.     }
  174.     public function setPublication(?bool $publication): self
  175.     {
  176.         $this->publication $publication;
  177.         return $this;
  178.     }
  179.     public function getVignette(): ?Upload
  180.     {
  181.         return $this->vignette;
  182.     }
  183.     public function setVignette(?Upload $vignette): self
  184.     {
  185.         $this->vignette $vignette;
  186.         return $this;
  187.     }
  188.     public function getBanniere(): ?Upload
  189.     {
  190.         return $this->banniere;
  191.     }
  192.     public function setBanniere(?Upload $banniere): self
  193.     {
  194.         $this->banniere $banniere;
  195.         return $this;
  196.     }
  197.     public function getPath(): ?string
  198.     {
  199.         return $this->path;
  200.     }
  201.     public function setPath(?string $path): self
  202.     {
  203.         $this->path $path;
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return Collection<int, SousThemeTheme>
  208.      */
  209.     public function getSousThemeThemes(): Collection
  210.     {
  211.         return $this->sousThemeThemes;
  212.     }
  213.     public function addSousThemeTheme(SousThemeTheme $sousThemeTheme): self
  214.     {
  215.         if (!$this->sousThemeThemes->contains($sousThemeTheme)) {
  216.             $this->sousThemeThemes->add($sousThemeTheme);
  217.             $sousThemeTheme->setTheme($this);
  218.         }
  219.         return $this;
  220.     }
  221.     public function removeSousThemeTheme(SousThemeTheme $sousThemeTheme): self
  222.     {
  223.         // set the owning side to null (unless already changed)
  224.         if ($this->sousThemeThemes->removeElement($sousThemeTheme) && $sousThemeTheme->getTheme() === $this) {
  225.             $sousThemeTheme->setTheme(null);
  226.         }
  227.         return $this;
  228.     }
  229.     /**
  230.      * @return Collection<int, Parcours>
  231.      */
  232.     public function getParcours(): Collection
  233.     {
  234.         return $this->parcours;
  235.     }
  236.     public function addParcour(Parcours $parcours): self
  237.     {
  238.         if (!$this->parcours->contains($parcours)) {
  239.             $this->parcours->add($parcours);
  240.         }
  241.         return $this;
  242.     }
  243.     public function removeParcour(Parcours $parcours): self
  244.     {
  245.         $this->parcours->removeElement($parcours);
  246.         return $this;
  247.     }
  248.     /**
  249.      * @return Collection<int, Certification>
  250.      */
  251.     public function getCertifications(): Collection
  252.     {
  253.         return $this->certifications;
  254.     }
  255.     public function addCertification(Certification $certification): self
  256.     {
  257.         if (!$this->certifications->contains($certification)) {
  258.             $this->certifications->add($certification);
  259.             $certification->setTheme($this);
  260.         }
  261.         return $this;
  262.     }
  263.     public function removeCertification(Certification $certification): self
  264.     {
  265.         // set the owning side to null (unless already changed)
  266.         if ($this->certifications->removeElement($certification) && $certification->getTheme() === $this) {
  267.             $certification->setTheme(null);
  268.         }
  269.         return $this;
  270.     }
  271.     public function isPublication(): ?bool
  272.     {
  273.         return $this->publication;
  274.     }
  275.     /**
  276.      * @return Collection<int, TarifVenteTheme>
  277.      */
  278.     public function getTarifsVentes(): Collection
  279.     {
  280.         return $this->tarifsVentes;
  281.     }
  282.     public function addTarifsVente(TarifVenteTheme $tarifsVente): self
  283.     {
  284.         if (!$this->tarifsVentes->contains($tarifsVente)) {
  285.             $this->tarifsVentes->add($tarifsVente);
  286.             $tarifsVente->setTheme($this);
  287.         }
  288.         return $this;
  289.     }
  290.     public function removeTarifsVente(TarifVenteTheme $tarifsVente): self
  291.     {
  292.         // set the owning side to null (unless already changed)
  293.         if ($this->tarifsVentes->removeElement($tarifsVente) && $tarifsVente->getTheme() === $this) {
  294.             $tarifsVente->setTheme(null);
  295.         }
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection<int, TarifVenteThemeIntra>
  300.      */
  301.     public function getTarifsVenteIntras(): Collection
  302.     {
  303.         return $this->tarifsVenteIntras;
  304.     }
  305.     public function addTarifsVenteIntra(TarifVenteThemeIntra $tarifsVenteIntra): self
  306.     {
  307.         if (!$this->tarifsVenteIntras->contains($tarifsVenteIntra)) {
  308.             $this->tarifsVenteIntras->add($tarifsVenteIntra);
  309.             $tarifsVenteIntra->setTheme($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeTarifsVenteIntra(TarifVenteThemeIntra $tarifsVenteIntra): self
  314.     {
  315.         // set the owning side to null (unless already changed)
  316.         if ($this->tarifsVenteIntras->removeElement($tarifsVenteIntra) && $tarifsVenteIntra->getTheme() === $this) {
  317.             $tarifsVenteIntra->setTheme(null);
  318.         }
  319.         return $this;
  320.     }
  321.     public function getTarifVenteDefaut(): ?TarifVenteTheme
  322.     {
  323.         return $this->tarifVenteDefaut;
  324.     }
  325.     public function setTarifVenteDefaut(?TarifVenteTheme $tarifVenteDefaut): self
  326.     {
  327.         $this->tarifVenteDefaut $tarifVenteDefaut;
  328.         return $this;
  329.     }
  330.     public function getTarifventeintradefaut(): ?TarifVenteThemeIntra
  331.     {
  332.         return $this->tarifventeintradefaut;
  333.     }
  334.     public function setTarifventeintradefaut(?TarifVenteThemeIntra $tarifventeintradefaut): self
  335.     {
  336.         $this->tarifventeintradefaut $tarifventeintradefaut;
  337.         return $this;
  338.     }
  339.     /**
  340.      * @return Collection<int, Parcours>
  341.      */
  342.     public function getDefaultParcours(): Collection
  343.     {
  344.         return $this->defaultParcours;
  345.     }
  346.     public function addDefaultParcour(Parcours $defaultParcour): self
  347.     {
  348.         if (!$this->defaultParcours->contains($defaultParcour)) {
  349.             $this->defaultParcours->add($defaultParcour);
  350.             $defaultParcour->setTheme($this);
  351.         }
  352.         return $this;
  353.     }
  354.     public function removeDefaultParcour(Parcours $defaultParcour): self
  355.     {
  356.         // set the owning side to null (unless already changed)
  357.         if ($this->defaultParcours->removeElement($defaultParcour) && $defaultParcour->getTheme() === $this) {
  358.             $defaultParcour->setTheme(null);
  359.         }
  360.         return $this;
  361.     }
  362. }