src/Entity/Evenement.php line 21

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EvenementRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\DBAL\Types\Types;
  6. use DateTime;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\Mapping\InverseJoinColumn;
  9. use Doctrine\ORM\Mapping\JoinColumn;
  10. use Doctrine\ORM\Mapping\JoinTable;
  11. use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface;
  12. use Sulu\Bundle\ContactBundle\Entity\ContactInterface;
  13. use Sulu\Bundle\MediaBundle\Entity\MediaInterface;
  14. use Sulu\Component\Persistence\Model\AuditableInterface;
  15. use Sulu\Component\Persistence\Model\AuditableTrait;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. #[ORM\Entity(repositoryClassEvenementRepository::class)]
  18. class Evenement implements AuditableInterface
  19. {
  20.     /**
  21.      * Constructor.
  22.      */
  23.     public function __construct()
  24.     {
  25.         $this->categories = new ArrayCollection();
  26.         //$this->statistics = new StatsEvenement();
  27.     }
  28.     final public const RESOURCE_KEY 'evenement';
  29.     //j'ai l'impression que si je rajoute ce sujet sans le sauvegarder dans la bdd ça ne marche pas bien
  30.     /*private ?StatsEvenement $statistics;
  31.     public function getStatistics(): ?StatsEvenement
  32.     {
  33.         return $this->statistics;
  34.     }
  35.     public function setStatistics(StatsEvenement $statistics): self
  36.     {
  37.         $this->statistics = $statistics;
  38.         return $this;
  39.     }*/
  40.     use AuditableTrait;
  41.     #[ORM\Id]
  42.     #[ORM\GeneratedValue]
  43.     #[ORM\Column]
  44.     private ?int $id null;
  45.     #[ORM\Column(length1024)]
  46.     #[Assert\NotBlank]
  47.     private ?string $title null;
  48.     #[ORM\Column(typeTypes::TEXT)]
  49.     private ?string $description null;
  50.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  51.     private ?\DateTimeInterface $startDate null;
  52.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  53.     private ?\DateTimeInterface $endDate null;
  54.     #[ORM\Column]
  55.     private ?float $minAge null;
  56.     #[ORM\Column]
  57.     private ?float $maxAge null;
  58.     #[ORM\Column(length1024)]
  59.     private ?string $organisators_display null;
  60.     #[ORM\Column(length50)]
  61.     private ?string $organisators_id null;
  62.     #[ORM\Column]
  63.     private ?bool $isPartner null;
  64.     #[ORM\Column]
  65.     private ?int $nbPlace null;
  66.     #[ORM\Column(typeTypes::TEXT)]
  67.     private ?string $location null;
  68.     #[ORM\ManyToOne(targetEntity"Sulu\Bundle\MediaBundle\Entity\MediaInterface")]
  69.     #[JoinColumn(name"mediaId"referencedColumnName"id"onDelete"SET NULL"nullabletrue)]
  70.     private ?MediaInterface $illustration null;
  71.     #[ORM\Column]
  72.     private ?bool $isExternalInscription null;
  73.     #[ORM\Column]
  74.     private ?bool $isOpen null;
  75.     #[ORM\Column]
  76.     private ?bool $isFull null;
  77.     #[ORM\Column]
  78.     private ?bool $isVisible null;
  79.     #[ORM\Column]
  80.     private ?float $price null;
  81.     #[ORM\Column(length255nullabletrue)]
  82.     private ?string $priceCurrency null;
  83.     #[ORM\Column(length255)]
  84.     private ?string $contactEmail null;
  85.     #[ORM\Column(length1024nullabletrue)]
  86.     private ?string $externalUrl null;
  87.     #[ORM\Column]
  88.     private ?bool $hasCentralPayement null;
  89.     #[ORM\Column(length1024nullabletrue)]
  90.     private ?string $paymentInfo null;
  91.     #[ORM\Column]
  92.     private ?bool $hasPayementBefore null;
  93.     #[ORM\Column]
  94.     private ?bool $hasPayementInEuro null;
  95.     #[ORM\Column]
  96.     private ?bool $hasPayementInCHF null;
  97.     #[ORM\Column]
  98.     private ?bool $hasPayementInCash null;
  99.     #[ORM\Column(typeTypes::TEXT)]
  100.     private ?string $infoInscription null;
  101.     #[ORM\Column("camper_age_management")]
  102.     private bool $camper_age_management false;
  103.     
  104.     #[ORM\Column("automatic_campeur_document_management")]
  105.     private bool $automatic_campeur_document_management false;
  106.     
  107.     /**
  108.      * Return yes if the loggued user is authorized for managing the given event.
  109.      *
  110.      * @return bool
  111.      */
  112.     public function amIOrganisator(int $id_user): ?bool
  113.     {
  114.         //est-ce le bon endroit pour implémenter cette fonction ? je pense que oui
  115.         //reste à savoir d'où je vais appeler cette fonction pour afficher ou nom le camp en question
  116.         //depuis le evenementController.php ?
  117.         ///il faut récupérer les autorisations de l'utilisateur, vérifier si l'evenement sur lequel on est est bien autorisé pour l'utilisateur concerné
  118.         //récupération des autorisations de l'utilisateur (ça ne marche pas)
  119.         $liste_autorisations $this->organisators_id;
  120.         //dump $liste_autorisations;
  121.         //ensuite on sépare le champ avec les ;
  122.         $liste_autorisations_explose explode(";",$liste_autorisations);
  123.         //On regarde si l'id fourni est bien dans la liste récupérée
  124.         $id_autorise in_array($id_user$liste_autorisations_explose);
  125.         
  126.         if ($id_autorise) {
  127.             //"L'ID $id_user est autorisé.";
  128.             return true;
  129.         }
  130.         else {
  131.             //echo "L'ID $id_user n'est pas autorisé.";
  132.             return false;
  133.         }
  134.         
  135.         //return true;
  136.     }
  137.     
  138.     /**
  139.      * @var DoctrineCollection<int, CategoryInterface>
  140.      */
  141.     #[ORM\ManyToMany(targetEntity"Sulu\Bundle\CategoryBundle\Entity\CategoryInterface")]
  142.     #[JoinTable(
  143.         name"app_evenement_categories",
  144.         joinColumns: [new JoinColumn(name"evenement_id"referencedColumnName"id")],
  145.         inverseJoinColumns: [new InverseJoinColumn(name"category_id"referencedColumnName"id")]
  146.     )]
  147.     private $categories;
  148.     /**
  149.      * Add categories.
  150.      *
  151.      * @return self
  152.      */
  153.     
  154.     public function addCategory(CategoryInterface $categories)
  155.     {
  156.         $this->categories[] = $categories;
  157.         return $this;
  158.     }
  159.     /**
  160.      * Remove categories.
  161.      */
  162.     public function removeCategories()
  163.     {
  164.         $this->categories->clear();
  165.     }
  166.     /**
  167.      * Get categories.
  168.      *
  169.      * @return DoctrineCollection<int, CategoryInterface>
  170.      */
  171.     public function getCategories()
  172.     {
  173.         return $this->categories;
  174.     }
  175.     
  176.     
  177.     public function getId(): ?int
  178.     {
  179.         return $this->id;
  180.     }
  181.     public function getTitle(): ?string
  182.     {
  183.         return $this->title;
  184.     }
  185.     public function setTitle(string $title): self
  186.     {
  187.         $this->title $title;
  188.         return $this;
  189.     }
  190.     public function getDescription(): ?string
  191.     {
  192.         return $this->description;
  193.     }
  194.     public function setDescription(string $description): self
  195.     {
  196.         $this->description $description;
  197.         return $this;
  198.     }
  199.     public function getStartDate(): ?\DateTimeInterface
  200.     {
  201.         return $this->startDate;
  202.     }
  203.     public function setStartDate(\DateTimeInterface $startDate): self
  204.     {
  205.         $this->startDate $startDate;
  206.         return $this;
  207.     }
  208.     public function getEndDate(): ?\DateTimeInterface
  209.     {
  210.         return $this->endDate;
  211.     }
  212.     public function setEndDate(\DateTimeInterface $endDate): self
  213.     {
  214.         $this->endDate $endDate;
  215.         return $this;
  216.     }
  217.     public function getMinAge(): ?float
  218.     {
  219.         return $this->minAge;
  220.     }
  221.     public function setMinAge(float $minAge): self
  222.     {
  223.         $this->minAge $minAge;
  224.         return $this;
  225.     }
  226.     public function getMaxAge(): ?float
  227.     {
  228.         return $this->maxAge;
  229.     }
  230.     public function setMaxAge(float $maxAge): self
  231.     {
  232.         $this->maxAge $maxAge;
  233.         return $this;
  234.     }
  235.     public function getOrganisatorsDisplay(): ?string
  236.     {
  237.         return $this->organisators_display;
  238.     }
  239.     public function setOrganisatorsDisplay(string $organisators_display): self
  240.     {
  241.         $this->organisators_display $organisators_display;
  242.         return $this;
  243.     }
  244.     public function getOrganisatorsId(): ?string
  245.     {
  246.         return $this->organisators_id;
  247.     }
  248.     public function setOrganisatorsId(string $organisators_id): self
  249.     {
  250.         $this->organisators_id $organisators_id;
  251.         return $this;
  252.     }
  253.     
  254.     public function isPartner(): ?bool
  255.     {
  256.         return $this->isPartner;
  257.     }
  258.     public function setIsPartner(bool $isPartner): self
  259.     {
  260.         $this->isPartner $isPartner;
  261.         return $this;
  262.     }
  263.     public function getPriceCurrency(): ?string
  264.     {
  265.         return $this->priceCurrency;
  266.     }
  267.     public function setPriceCurrency(?string $priceCurrency): self
  268.     {
  269.         $this->priceCurrency $priceCurrency;
  270.         return $this;
  271.     }
  272.     public function getNbPlace(): ?int
  273.     {
  274.         return $this->nbPlace;
  275.     }
  276.     public function setNbPlace(int $nbPlace): self
  277.     {
  278.         $this->nbPlace $nbPlace;
  279.         return $this;
  280.     }
  281.     public function getLocation(): ?string
  282.     {
  283.         return $this->location;
  284.     }
  285.     public function setLocation(string $location): self
  286.     {
  287.         $this->location $location;
  288.         return $this;
  289.     }
  290.     public function getIllustration(): ?MediaInterface
  291.     {
  292.         return $this->illustration;
  293.     }
  294.     public function setIllustration(?MediaInterface $illustration): self
  295.     {
  296.         $this->illustration $illustration;
  297.         return $this;
  298.     }
  299.     public function isExternalInscription(): ?bool
  300.     {
  301.         return $this->isExternalInscription;
  302.     }
  303.     public function setIsExternalInscription(bool $isExternalInscription): self
  304.     {
  305.         $this->isExternalInscription $isExternalInscription;
  306.         return $this;
  307.     }
  308.     public function isOpen(): ?bool
  309.     {
  310.         return $this->isOpen;
  311.     }
  312.     public function setIsOpen(bool $isOpen): self
  313.     {
  314.         $this->isOpen $isOpen;
  315.         return $this;
  316.     }
  317.     public function isFull(): ?bool
  318.     {
  319.         return $this->isFull;
  320.     }
  321.     public function setFull(bool $isFull): self
  322.     {
  323.         $this->isFull $isFull;
  324.         return $this;
  325.     }
  326.     public function isVisible(): ?bool
  327.     {
  328.         return $this->isVisible;
  329.     }
  330.     public function setVisible(bool $isVisible): self
  331.     {
  332.         $this->isVisible $isVisible;
  333.         return $this;
  334.     }
  335.     public function getPrice(): ?float
  336.     {
  337.         return $this->price;
  338.     }
  339.     public function setPrice(float $price): self
  340.     {
  341.         $this->price $price;
  342.         return $this;
  343.     }
  344.     public function getContactEmail(): ?string
  345.     {
  346.         return $this->contactEmail;
  347.     }
  348.     public function setContactEmail(string $contactEmail): self
  349.     {
  350.         $this->contactEmail $contactEmail;
  351.         return $this;
  352.     }
  353.     public function getExternalUrl(): ?string
  354.     {
  355.         return $this->externalUrl;
  356.     }
  357.     public function setExternalUrl(?string $externalUrl): self
  358.     {
  359.         $this->externalUrl $externalUrl;
  360.         return $this;
  361.     }
  362.     public function getHasCentralPayement(): ?bool
  363.     {
  364.         return $this->hasCentralPayement;
  365.     }
  366.     public function setHasCentralPayement(bool $hasCentralPayement): self
  367.     {
  368.         $this->hasCentralPayement $hasCentralPayement;
  369.         return $this;
  370.     }
  371.     public function getPaymentInfo(): ?string
  372.     {
  373.         return $this->paymentInfo;
  374.     }
  375.     public function setPaymentInfo(?string $paymentInfo): self
  376.     {
  377.         $this->paymentInfo $paymentInfo;
  378.         return $this;
  379.     }
  380.     public function getHasPayementBefore(): ?bool {
  381.         return $this->hasPayementBefore;
  382.     }
  383.     
  384.     public function setHasPayementBefore(?bool $hasPayementBefore): self {
  385.         $this->hasPayementBefore $hasPayementBefore;
  386.         return $this;
  387.     }
  388.     /**
  389.      * @return 
  390.      */
  391.     public function getHasPayementInEuro(): ?bool {
  392.         return $this->hasPayementInEuro;
  393.     }
  394.     
  395.     /**
  396.      * @param  $hasPayementInEuro 
  397.      * @return self
  398.      */
  399.     public function setHasPayementInEuro(?bool $hasPayementInEuro): self {
  400.         $this->hasPayementInEuro $hasPayementInEuro;
  401.         return $this;
  402.     }
  403.     /**
  404.      * @return 
  405.      */
  406.     public function getHasPayementInCHF(): ?bool {
  407.         return $this->hasPayementInCHF;
  408.     }
  409.     
  410.     /**
  411.      * @param  $hasPayementInCHF 
  412.      * @return self
  413.      */
  414.     public function setHasPayementInCHF(?bool $hasPayementInCHF): self {
  415.         $this->hasPayementInCHF $hasPayementInCHF;
  416.         return $this;
  417.     }
  418.     /**
  419.      * @return 
  420.      */
  421.     public function getHasPayementInCash(): ?bool {
  422.         return $this->hasPayementInCash;
  423.     }
  424.     
  425.     /**
  426.      * @param  $hasPayementInCash 
  427.      * @return self
  428.      */
  429.     public function setHasPayementInCash(?bool $hasPayementInCash): self {
  430.         $this->hasPayementInCash $hasPayementInCash;
  431.         return $this;
  432.     }
  433.     /**
  434.      * @return 
  435.      */
  436.     public function getInfoInscription(): ?string {
  437.         return $this->infoInscription;
  438.     }
  439.     
  440.     /**
  441.      * @param  $infoInscription 
  442.      * @return self
  443.      */
  444.     public function setInfoInscription(?string $infoInscription): self {
  445.         $this->infoInscription $infoInscription;
  446.         return $this;
  447.     }
  448. //j'ai changé : de string j'ai passé à bool
  449.     public function getCamperAgeManagement(): ?bool {
  450.         return $this->camper_age_management;
  451.     }
  452.     
  453.     /**
  454.      * @param  $camper_age_management 
  455.      * @return self
  456.      */
  457.      public function setCamperAgeManagement(?bool $camper_age_management): self {
  458.         $this->camper_age_management $camper_age_management;
  459.         return $this;
  460.     }
  461.     public function getAutomaticCampeurDocumentManagement(): ?bool {
  462.         return $this->automatic_campeur_document_management;
  463.     }
  464.     
  465.     /**
  466.      * @param  $automatic_campeur_document_management 
  467.      * @return self
  468.      */
  469.     public function setAutomaticCampeurDocumentManagement(?bool $automatic_campeur_document_management): self {
  470.         $this->automatic_campeur_document_management $automatic_campeur_document_management;
  471.         return $this;
  472.     }
  473.     public function getDaysBeforeCamp(): int
  474.     {
  475.       
  476.         $today = new DateTime();
  477.         $interval $this->getStartDate()->diff($today);
  478.         return $interval->days;
  479.     }
  480. }