Event.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. <?php
  2. namespace AppBundle\Entity\Booking;
  3. use AppBundle\Entity\Message\Message;
  4. use AppBundle\Entity\Place\PlaceSystem;
  5. use AppBundle\Enum\Booking\ParticipationStatusEnum;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Dunglas\ApiBundle\Annotation\Iri;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use AppBundle\Entity\Core\File;
  12. use AppBundle\Validator\Constraints\Delete as OpentalentDelete;
  13. use AppBundle\Validator\Constraints\Booking as OpentalentEvent;
  14. use AppBundle\Entity\Place\Place;
  15. /**
  16. * Evènement, rencontre
  17. *
  18. * @Iri("http://schema.org/Event")
  19. * @OpentalentDelete\EntityDelete()
  20. * @OpentalentEvent\Event()
  21. */
  22. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Booking\Repository\EventRepository')]
  23. class Event extends AbstractBooking
  24. {
  25. /**
  26. * @var ArrayCollection<EventRecur>
  27. */
  28. #[Assert\Valid]
  29. #[ORM\OneToMany(targetEntity: 'EventRecur', mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  30. #[Groups(['event_bookingrecur', 'planning_detail', 'booking_event'])]
  31. protected $eventRecur;
  32. /**
  33. * @var ArrayCollection<Event>
  34. */
  35. #[ORM\OneToMany(targetEntity: 'Event', mappedBy: 'parent', orphanRemoval: true)]
  36. #[Groups(['event_timeline'])]
  37. private $timeline;
  38. /**
  39. * @var \AppBundle\Entity\Booking\Event
  40. */
  41. #[ORM\ManyToOne(targetEntity: 'Event', inversedBy: 'timeline')]
  42. #[Groups(['event'])]
  43. private $parent;
  44. /**
  45. * @var string
  46. */
  47. #[Assert\Type(type: 'string')]
  48. #[Assert\Choice(callback: ['\AppBundle\Enum\Booking\EventTimelineTypeEnum', 'toArray'], multiple: false, min: 1)]
  49. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  50. #[Groups(['event', 'booking_event'])]
  51. private $type;
  52. /**
  53. * @var File An image of the item. This can be a [URL](http://schema.org/URL) or a fully described [ImageObject](http://schema.org/ImageObject).
  54. * @Iri("https://schema.org/image")
  55. */
  56. #[Assert\Valid]
  57. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\File', inversedBy: 'events', cascade: ['persist'])]
  58. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  59. #[Groups(['event', 'booking_event', 'planning_detail', 'invitations_list_event', 'event_details', 'activity_reports'])]
  60. private $image;
  61. /**
  62. * @var string URL of the item.
  63. *
  64. * @Iri("https://schema.org/url")
  65. */
  66. #[ORM\Column(type: 'string', nullable: true)]
  67. #[Assert\Url]
  68. #[Assert\Regex(pattern: '/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/', message: 'url-error')]
  69. #[Groups(['event', 'planning_detail', 'event_details', 'booking_event'])]
  70. private $url;
  71. /**
  72. * @var string
  73. */
  74. #[ORM\Column(type: 'text', nullable: true)]
  75. #[Assert\Type(type: 'string')]
  76. #[Groups(['event', 'event_details', 'booking_event', 'planning_detail'])]
  77. private $additionalInformation;
  78. /**
  79. * @var string
  80. */
  81. #[ORM\Column(type: 'string', nullable: false)]
  82. #[Assert\Type(type: 'string')]
  83. #[Assert\NotNull]
  84. #[Assert\Choice(callback: ['\AppBundle\Enum\Booking\VisibilityEnum', 'toArray'])]
  85. #[Groups(['event', 'planning_detail', 'event_details', 'booking_event'])]
  86. private $visibility;
  87. /**
  88. * @var string
  89. */
  90. #[ORM\Column(type: 'text', nullable: true)]
  91. #[Assert\Type(type: 'string')]
  92. #[Groups(['event', 'planning_detail'])]
  93. private $report;
  94. /**
  95. * @var string
  96. */
  97. #[ORM\Column(type: 'text', nullable: true)]
  98. #[Assert\Type(type: 'string')]
  99. #[Groups(['event', 'planning_detail'])]
  100. private $comment;
  101. /**
  102. * @var EventGender
  103. */
  104. #[ORM\ManyToOne(targetEntity: 'EventGender')]
  105. #[Groups(['event', 'booking_event', 'activity_report', 'planning_detail'])]
  106. private $gender;
  107. /**
  108. * @var ArrayCollection<EventUser>
  109. */
  110. #[Assert\Valid]
  111. #[ORM\OneToMany(targetEntity: 'EventUser', mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
  112. #[Groups(['event_eventuser', 'planning_detail', 'presence_attendance', 'event_details'])]
  113. private $eventUser;
  114. /**
  115. * @var ArrayCollection<Medal>
  116. */
  117. #[Assert\Valid]
  118. #[ORM\OneToMany(targetEntity: 'EventUser', mappedBy: 'event', cascade: ['persist'], orphanRemoval: true, fetch: 'EXTRA_LAZY')]
  119. #[Groups(['event_details'])]
  120. #[ORM\OrderBy(['id' => 'DESC'])]
  121. private $eventUserFiltered;
  122. /**
  123. * @var array
  124. */
  125. #[ORM\Column(type: 'text', nullable: true)]
  126. #[Groups(['event', 'event_details', 'planning_detail', 'booking_event'])]
  127. private $rule = array();
  128. /**
  129. * @var ArrayCollection<Categories>
  130. */
  131. #[Assert\Valid]
  132. #[ORM\ManyToMany(targetEntity: '\AppBundle\Entity\Core\Categories', cascade: ['persist'])]
  133. #[Groups(['event_categories', 'planning_detail', 'event_details', 'booking_event'])]
  134. private $categories;
  135. /**
  136. * @var ArrayCollection<EventReport>
  137. */
  138. #[ORM\OneToMany(targetEntity: '\AppBundle\Entity\Booking\EventReport', mappedBy: 'event', orphanRemoval: true)]
  139. #[Groups(['event_eventreport', 'planning_detail', 'event_details'])]
  140. private $eventReports;
  141. /**
  142. * @var ArrayCollection<AppBundle\Entity\Core\File>.
  143. */
  144. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\File', cascade: ['persist'], orphanRemoval: true)]
  145. #[ORM\JoinTable(name: 'event_files', joinColumns: [], inverseJoinColumns: [])]
  146. #[ORM\JoinColumn(name: 'event_id', referencedColumnName: 'id', onDelete: 'cascade')]
  147. #[ORM\JoinColumn(name: 'file_id', referencedColumnName: 'id', onDelete: 'cascade')]
  148. #[Groups(['booking_event', 'booking_event_documents', 'event_details'])]
  149. private $files;
  150. /**
  151. * var ArrayCollection<AttendanceBooking>
  152. */
  153. #[Assert\Valid]
  154. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\AttendanceBooking', cascade: ['persist'], mappedBy: 'event', orphanRemoval: true)]
  155. #[ORM\JoinColumn(nullable: false)]
  156. #[Groups(['event_attendancebooking', 'presence_attendance', 'planning_detail', 'booking_event', 'event_details'])]
  157. private $attendanceBooking;
  158. /**
  159. * @var array
  160. */
  161. #[Groups(['planning_list', 'activity_report'])]
  162. private $scoreParticipation;
  163. /**
  164. * @var PlaceSystem
  165. */
  166. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Place\PlaceSystem')]
  167. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  168. #[Groups(['booking', 'event_details', 'invitations_list_event', 'planning_detail', 'booking_event'])]
  169. private $placeSystem;
  170. /**
  171. * @var int
  172. */
  173. #[ORM\Column(type: 'integer')]
  174. private $openAgendaId;
  175. /**
  176. * @var string URL of the tickets.
  177. *
  178. * @Iri("https://schema.org/url")
  179. */
  180. #[ORM\Column(type: 'string', nullable: true)]
  181. #[Assert\Url]
  182. #[Assert\Regex(pattern: '/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/', message: 'url-error')]
  183. #[Groups(['event', 'planning_detail', 'event_details', 'booking_event'])]
  184. private $urlTicket;
  185. public function __construct() {
  186. parent::__construct();
  187. $this->eventUser = new ArrayCollection();
  188. $this->eventUserFiltered = new ArrayCollection();
  189. $this->categories = new ArrayCollection();
  190. $this->eventReport = new ArrayCollection();
  191. $this->files = new ArrayCollection();
  192. $this->attendanceBooking = new ArrayCollection();
  193. }
  194. /**
  195. * Sets image.
  196. *
  197. * @param string $image
  198. *
  199. * @return $this
  200. */
  201. public function setImage($image)
  202. {
  203. $this->image = $image;
  204. return $this;
  205. }
  206. /**
  207. * Gets image.
  208. *
  209. * @return string
  210. */
  211. public function getImage()
  212. {
  213. return $this->image;
  214. }
  215. /**
  216. * Sets url.
  217. *
  218. * @param string $url
  219. *
  220. * @return $this
  221. */
  222. public function setUrl($url)
  223. {
  224. $this->url = $url;
  225. return $this;
  226. }
  227. /**
  228. * Gets url.
  229. *
  230. * @return string
  231. */
  232. public function getUrl()
  233. {
  234. return $this->url;
  235. }
  236. /**
  237. * Sets additionalInformation.
  238. *
  239. * @param string $additionalInformation
  240. *
  241. * @return $this
  242. */
  243. public function setAdditionalInformation($additionalInformation)
  244. {
  245. $this->additionalInformation = $additionalInformation;
  246. return $this;
  247. }
  248. /**
  249. * Gets additionalInformation.
  250. *
  251. * @return string
  252. */
  253. public function getAdditionalInformation()
  254. {
  255. return $this->additionalInformation;
  256. }
  257. /**
  258. * Sets visibility.
  259. *
  260. * @param string $visibility
  261. *
  262. * @return $this
  263. */
  264. public function setVisibility($visibility)
  265. {
  266. $this->visibility = $visibility;
  267. return $this;
  268. }
  269. /**
  270. * Gets visibility.
  271. *
  272. * @return string
  273. */
  274. public function getVisibility()
  275. {
  276. return $this->visibility;
  277. }
  278. /**
  279. * Sets gender.
  280. *
  281. * @param EventGender $gender
  282. *
  283. * @return $this
  284. */
  285. public function setGender(EventGender $gender = null)
  286. {
  287. $this->gender = $gender;
  288. return $this;
  289. }
  290. /**
  291. * Gets gender.
  292. *
  293. * @return EventGender
  294. */
  295. public function getGender()
  296. {
  297. return $this->gender;
  298. }
  299. /**
  300. * @param EventUser $eventUser
  301. * @return $this
  302. */
  303. public function addEventUser(EventUser $eventUser)
  304. {
  305. $eventUser->setEvent($this);
  306. $this->eventUser[] = $eventUser;
  307. return $this;
  308. }
  309. /**
  310. * @param ArrayCollection $eventUsers
  311. * @return $this
  312. */
  313. public function setEventUser(ArrayCollection $eventUsers)
  314. {
  315. $this->eventUser = $eventUsers;
  316. return $this;
  317. }
  318. /**
  319. * @param EventUser $eventUser
  320. * @return $this
  321. */
  322. public function removeEventUser(EventUser $eventUser)
  323. {
  324. $this->eventUser->removeElement($eventUser);
  325. return $this;
  326. }
  327. /**
  328. * @return mixed
  329. */
  330. public function getEventUser()
  331. {
  332. return ($this->eventUser) ? array_values($this->eventUser->toArray()) : new ArrayCollection();
  333. }
  334. /**
  335. * Get donors
  336. *3
  337. * @return \Doctrine\Common\Collections\Collection
  338. */
  339. public function getEventUserFiltered()
  340. {
  341. $users = new ArrayCollection();
  342. $usersIds = array();
  343. foreach ($this->eventUserFiltered as $eventU){
  344. if(!in_array($eventU->getGuest()->getId(), $usersIds) && count($usersIds) < 3){
  345. $users->add($eventU);
  346. $usersIds[] = $eventU->getGuest()->getId();
  347. }
  348. }
  349. return $users;
  350. }
  351. /**
  352. * @param string $rule
  353. * @return $this
  354. */
  355. public function setRule($rule)
  356. {
  357. $this->rule = $rule;
  358. return $this;
  359. }
  360. /**
  361. * @return array
  362. */
  363. public function getRule()
  364. {
  365. return $this->rule;
  366. }
  367. /**
  368. * Add category
  369. *
  370. * @param \AppBundle\Entity\Core\Categories $category
  371. *
  372. * @return Event
  373. */
  374. public function addCategory(\AppBundle\Entity\Core\Categories $category)
  375. {
  376. $this->categories[] = $category;
  377. return $this;
  378. }
  379. /**
  380. * Remove category
  381. *
  382. * @param \AppBundle\Entity\Core\Categories $category
  383. */
  384. public function removeCategory(\AppBundle\Entity\Core\Categories $category)
  385. {
  386. $this->categories->removeElement($category);
  387. }
  388. /**
  389. * Get categories
  390. *
  391. * @return \Doctrine\Common\Collections\Collection
  392. */
  393. public function getCategories()
  394. {
  395. return $this->categories;
  396. }
  397. /**
  398. * Add eventReport
  399. *
  400. * @param \AppBundle\Entity\Booking\EventReport $eventReport
  401. *
  402. * @return Event
  403. */
  404. public function addEventReport(\AppBundle\Entity\Booking\EventReport $eventReport)
  405. {
  406. $this->eventReports[] = $eventReport;
  407. return $this;
  408. }
  409. /**
  410. * Remove eventReport
  411. *
  412. * @param \AppBundle\Entity\Booking\EventReport $eventReport
  413. */
  414. public function removeEventReport(\AppBundle\Entity\Booking\EventReport $eventReport)
  415. {
  416. $this->eventReports->removeElement($eventReport);
  417. }
  418. /**
  419. * Get eventReports
  420. *
  421. * @return \Doctrine\Common\Collections\Collection
  422. */
  423. public function getEventReports()
  424. {
  425. return $this->eventReports;
  426. }
  427. /**
  428. * {@inheritdoc}
  429. */
  430. public function getParticipants() {
  431. $participants = new ArrayCollection();
  432. array_map(function (EventUser $eu) use ($participants) { $participants->add($eu->getGuest()->getPerson());}, $this->getEventUser());
  433. return $participants;
  434. }
  435. /**
  436. * Set type
  437. *
  438. * @param string $type
  439. *
  440. * @return Event
  441. */
  442. public function setType($type)
  443. {
  444. $this->type = $type;
  445. return $this;
  446. }
  447. /**
  448. * Get type
  449. *
  450. * @return string
  451. */
  452. public function getType()
  453. {
  454. return $this->type;
  455. }
  456. /**
  457. * Set report
  458. *
  459. * @param string $report
  460. *
  461. * @return Event
  462. */
  463. public function setReport($report)
  464. {
  465. $this->report = $report;
  466. return $this;
  467. }
  468. /**
  469. * Get report
  470. *
  471. * @return string
  472. */
  473. public function getReport()
  474. {
  475. return $this->report;
  476. }
  477. /**
  478. * Set comment
  479. *
  480. * @param string $comment
  481. *
  482. * @return Event
  483. */
  484. public function setComment($comment)
  485. {
  486. $this->comment = $comment;
  487. return $this;
  488. }
  489. /**
  490. * Get comment
  491. *
  492. * @return string
  493. */
  494. public function getComment()
  495. {
  496. return $this->comment;
  497. }
  498. /**
  499. * Add timeline
  500. *
  501. * @param \AppBundle\Entity\Booking\Event $timeline
  502. *
  503. * @return Event
  504. */
  505. public function addTimeline(\AppBundle\Entity\Booking\Event $timeline)
  506. {
  507. $this->timeline[] = $timeline;
  508. return $this;
  509. }
  510. /**
  511. * Remove timeline
  512. *
  513. * @param \AppBundle\Entity\Booking\Event $timeline
  514. */
  515. public function removeTimeline(\AppBundle\Entity\Booking\Event $timeline)
  516. {
  517. $this->timeline->removeElement($timeline);
  518. }
  519. /**
  520. * Get timeline
  521. *
  522. * @return \Doctrine\Common\Collections\Collection
  523. */
  524. public function getTimeline()
  525. {
  526. return $this->timeline;
  527. }
  528. /**
  529. * Set parent
  530. *
  531. * @param \AppBundle\Entity\Booking\Event $parent
  532. *
  533. * @return Event
  534. */
  535. public function setParent(\AppBundle\Entity\Booking\Event $parent = null)
  536. {
  537. $this->parent = $parent;
  538. return $this;
  539. }
  540. /**
  541. * Get parent
  542. *
  543. * @return \AppBundle\Entity\Booking\Event
  544. */
  545. public function getParent()
  546. {
  547. return $this->parent;
  548. }
  549. /**
  550. * Add attendanceBooking
  551. *
  552. * @param \AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking
  553. *
  554. * @return AbstractBooking
  555. */
  556. public function addAttendanceBooking(\AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking)
  557. {
  558. $attendanceBooking->setEvent($this);
  559. $this->attendanceBooking[] = $attendanceBooking;
  560. return $this;
  561. }
  562. /**
  563. * Remove attendanceBooking
  564. *
  565. * @param \AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking
  566. */
  567. public function removeAttendanceBooking(\AppBundle\Entity\Booking\AttendanceBooking $attendanceBooking)
  568. {
  569. $this->attendanceBooking->removeElement($attendanceBooking);
  570. }
  571. /**
  572. * Get attendanceBooking
  573. *
  574. * @return \Doctrine\Common\Collections\Collection
  575. */
  576. public function getAttendanceBooking()
  577. {
  578. return $this->attendanceBooking;
  579. }
  580. /**
  581. * @return array
  582. */
  583. public function getScoreParticipation()
  584. {
  585. return $this->scoreParticipation;
  586. }
  587. /**
  588. * @param array $scoreParticipation
  589. */
  590. public function setScoreParticipation(array $scoreParticipation)
  591. {
  592. $this->scoreParticipation = $scoreParticipation;
  593. }
  594. /**
  595. * Set place system
  596. *
  597. * @param \AppBundle\Entity\Place\PlaceSystem $placeSytem
  598. *
  599. * @return AbstractBooking
  600. */
  601. public function setPlaceSystem(\AppBundle\Entity\Place\PlaceSystem $placeSystem = null)
  602. {
  603. $this->placeSystem = $placeSystem;
  604. return $this;
  605. }
  606. /**
  607. * Get place
  608. *
  609. * @return \AppBundle\Entity\Place\PlaceSystem
  610. */
  611. public function getPlaceSystem()
  612. {
  613. return $this->placeSystem;
  614. }
  615. /**
  616. * Add file
  617. *
  618. * @param \AppBundle\Entity\Core\File $file
  619. *
  620. * @return Message
  621. */
  622. public function addFile(\AppBundle\Entity\Core\File $file)
  623. {
  624. $this->files[] = $file;
  625. return $this;
  626. }
  627. /**
  628. * Remove file
  629. *
  630. * @param \AppBundle\Entity\Core\File $file
  631. */
  632. public function removeFile(\AppBundle\Entity\Core\File $file)
  633. {
  634. $this->files->removeElement($file);
  635. }
  636. /**
  637. * Get files
  638. *
  639. * @return \Doctrine\Common\Collections\Collection
  640. */
  641. public function getFiles()
  642. {
  643. return $this->files;
  644. }
  645. /**
  646. * Sets open agenda ID.
  647. *
  648. * @param string $openAgendaId
  649. *
  650. * @return $this
  651. */
  652. public function setOpenagendaId($openAgendaId)
  653. {
  654. $this->openAgendaId = $openAgendaId;
  655. return $this;
  656. }
  657. /**
  658. * Gets open agenda Id.
  659. *
  660. * @return string
  661. */
  662. public function getOpenAgendaId()
  663. {
  664. return $this->openAgendaId;
  665. }
  666. /**
  667. * Sets url ticket.
  668. *
  669. * @param string $urlTicket
  670. *
  671. * @return $this
  672. */
  673. public function setUrlTicket($urlTicket)
  674. {
  675. $this->urlTicket = $urlTicket;
  676. return $this;
  677. }
  678. /**
  679. * Gets url ticket.
  680. *
  681. * @return string
  682. */
  683. public function getUrlTicket()
  684. {
  685. return $this->urlTicket;
  686. }
  687. }