AbstractBooking.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <?php
  2. namespace AppBundle\Entity\Booking;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use AppBundle\Entity\Core\Tagg;
  5. use AppBundle\Entity\Place\Place;
  6. use AppBundle\Entity\Place\Room;
  7. use AppBundle\Entity\Product\Equipment;
  8. use AppBundle\Entity\Traits\ActivityYearTrait;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Dunglas\ApiBundle\Annotation\Iri;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. use AppBundle\Annotation\DefaultField;
  15. use AppBundle\Entity\Person\Person;
  16. use AppBundle\Entity\Organization\Organization;
  17. use AppBundle\Entity\Traits\TimestampableEntity;
  18. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  19. /**
  20. * Données d'un évènement générique, classe de base des évènements
  21. * Classe de base de @see Event, Course, EducationalProject, Examen, OrganizationHoliday, PersonHoliday
  22. *
  23. *
  24. */
  25. #[ORM\Entity]
  26. #[ORM\Table(name: 'Booking')]
  27. #[ORM\Index(name: 'viewIndex', columns: ['discr', 'datetimeEnd', 'visibility', 'isCanceled'])]
  28. #[ORM\InheritanceType('SINGLE_TABLE')]
  29. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  30. #[ORM\DiscriminatorMap(['event' => 'Event', 'course' => 'Course', 'educationalproject' => 'EducationalProject', 'examen' => 'Examen', 'organizationholiday' => 'OrganizationHoliday', 'personholiday' => 'PersonHoliday'])]
  31. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Booking\Repository\BookingRepository')]
  32. abstract class AbstractBooking implements IBooking
  33. {
  34. use TimestampableEntity;
  35. use CreatorUpdaterEntity;
  36. use ActivityYearTrait;
  37. /**
  38. * @var int
  39. */
  40. #[ORM\Column(type: 'integer')]
  41. #[ORM\Id]
  42. #[ORM\GeneratedValue(strategy: 'AUTO')]
  43. #[Groups(['booking', 'student_list', 'attendancebooking_list', 'examenconvocation_list', 'invitations_list', 'my_attendance_list', 'generate_attendance', 'access_details', 'presence_attendance', 'event_details', 'examen_details', 'course_details', 'educationalproject_details', 'edu_stu_courses', 'student_registration', 'planning_detail', 'booking_event', 'accesses_courseteacher_show', 'course_informations_edit', 'examen_informations_edit', 'educationalproject_informations_edit', 'booking_event_documents', 'accessholidays_list'])]
  44. private $id;
  45. /**
  46. * @var string
  47. */
  48. #[ORM\Column(type: 'string', length: 100, nullable: true)]
  49. #[Assert\Type(type: 'string')]
  50. #[Groups(['booking', 'attendancebooking_list_course', 'attendancebooking_list_educationalproject', 'attendancebooking_list_event', 'attendancebooking_list_examen', 'access_details_attendancebookings', 'access_details_attendancebookingsfiltered', 'invitations_list_event', 'my_attendance_list_course', 'my_attendance_list_educationalproject', 'my_attendance_list_event', 'my_attendance_list_examen', 'planning_list', 'generate_attendance', 'access_details_practicalcourses', 'presence_attendance', 'event_details', 'examen_details', 'course_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'planning_detail', 'booking_event', 'examenconvocation_list_examen', 'report_card_examenconvocations', 'report_card_attendancebookings', 'accesses_courseteacher_show_practicalcourses', 'course_informations_edit', 'examen_informations_edit', 'educationalproject_informations_edit', 'accessbilling_edit_billingeducationalprojectpayers', 'accesses_courseteacher_show_practicalcourses', 'education_input_list_access', 'activity_report', 'worksbyusers_db_work', 'access_attendance_detail_attendancebookings', 'accessholidays_list', 'build_bills_billlines'])]
  51. private $name;
  52. /**
  53. * @var Organization
  54. *
  55. * @DefaultField
  56. */
  57. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Organization\Organization')]
  58. #[ORM\JoinColumn(nullable: false)]
  59. #[Assert\NotNull]
  60. #[Groups(['booking'])]
  61. private $organization;
  62. /**
  63. * @var ArrayCollection<Person>
  64. */
  65. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'practicalCourses')]
  66. #[ORM\JoinTable(name: 'booking_organizer', joinColumns: [], inverseJoinColumns: [])]
  67. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  68. #[ORM\JoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
  69. #[Groups(['booking_access', 'booking', 'planning_list', 'event_details', 'course_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'planning_detail', 'booking_event', 'course_informations_edit', 'educationalproject_informations_edit', 'booking_event', 'presence_attendance', 'education_input_list_access', 'worksbyusers_db_work', 'attendancebooking_list_course'])]
  70. private $organizer;
  71. /**
  72. * @var string
  73. */
  74. #[Assert\Type(type: 'string')]
  75. #[Groups(['booking', 'planning_list'])]
  76. private $color;
  77. /**
  78. * @var boolean
  79. */
  80. #[Assert\Type(type: 'boolean')]
  81. private $hasReplacement;
  82. /**
  83. * @var \DateTime
  84. */
  85. #[ORM\Column(type: 'datetime', nullable: true)]
  86. #[Assert\DateTime]
  87. #[Groups(['booking', 'examenconvocation_list_examen', 'planning_list', 'generate_attendance', 'report_card_examenconvocations', 'access_details_practicalcourses', 'event_details', 'examen_details', 'course_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'planning_detail', 'booking_event', 'accesses_courseteacher_show_practicalcourses', 'course_informations_edit', 'examen_informations_edit', 'educationalproject_informations_edit', 'activity_report', 'education_input_list_access', 'accessholidays_list'])]
  88. private $datetimeStart;
  89. /**
  90. * @var \DateTime
  91. */
  92. #[ORM\Column(type: 'datetime', nullable: true)]
  93. #[Assert\DateTime]
  94. #[Groups(['booking', 'planning_list', 'generate_attendance', 'access_details_practicalcourses', 'event_details', 'examen_details', 'course_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'planning_detail', 'booking_event', 'examenconvocation_list_examen', 'accesses_courseteacher_show_practicalcourses', 'activity_report', 'course_informations_edit', 'examen_informations_edit', 'educationalproject_informations_edit', 'accessholidays_list'])]
  95. private $datetimeEnd;
  96. /**
  97. * @var ArrayCollection<IBookingRecur>
  98. * !!!! Please define the ORM\OneToMany to the child class !!!
  99. * ORM\OneToMany(targetEntity="Xxxx", mappedBy="event", cascade={"persist"}, orphanRemoval=true)
  100. */
  101. #[Assert\Valid]
  102. #[Groups(['booking_recur', 'planning_list', 'planning_detail', 'booking_event', 'educationalproject_informations_edit', 'accesses_courseteacher_show_practicalcourses', 'student_list_courses'])]
  103. protected $eventRecur;
  104. /**
  105. * @var string A short description of the item.
  106. *
  107. * @Iri("https://schema.org/description")
  108. */
  109. #[ORM\Column(type: 'text', nullable: true)]
  110. #[Assert\Type(type: 'string')]
  111. #[Groups(['booking', 'event_details', 'course_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'booking_event', 'planning_detail', 'course_informations_edit', 'examen_informations_edit', 'examen_details', 'educationalproject_informations_edit', 'planning_detail', 'activity_report'])]
  112. private $description;
  113. /**
  114. * @var Place
  115. */
  116. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Place\Place')]
  117. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  118. #[Groups(['booking', 'examenconvocation_list_examen', 'planning_list', 'event_details', 'examen_details', 'course_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'invitations_list_event', 'planning_detail', 'booking_event', 'course_informations_edit', 'course_informations_edit', 'examen_informations_edit', 'educationalproject_informations_edit', 'activity_report'])]
  119. private $place;
  120. /**
  121. * @var Room
  122. */
  123. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Place\Room')]
  124. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  125. #[Groups(['booking', 'examenconvocation_list_examen', 'planning_list', 'examen_details', 'course_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'planning_detail', 'course_informations_edit', 'examen_informations_edit', 'educationalproject_informations_edit', 'booking_event', 'event_details'])]
  126. private $room;
  127. /**
  128. * @var ArrayCollection<Equipment>
  129. */
  130. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Product\Equipment')]
  131. #[ORM\JoinTable(name: 'booking_equipment', joinColumns: [], inverseJoinColumns: [])]
  132. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  133. #[ORM\JoinColumn(name: 'equipment_id', referencedColumnName: 'id')]
  134. #[Groups(['booking_equipment', 'event_details', 'course_details', 'planning_detail', 'examen_details', 'educationalproject_details', 'edu_stu_courses_courses', 'student_registration_courses', 'booking_event'])]
  135. private $equipments;
  136. /**
  137. * @var ArrayCollection<Tagg>
  138. */
  139. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'bookings')]
  140. #[Assert\Valid]
  141. #[ORM\JoinTable(name: 'tag_booking', joinColumns: [], inverseJoinColumns: [])]
  142. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  143. #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  144. #[Groups(['booking_tags', 'manage_tags', 'booking_event', 'event_details', 'course_informations_edit', 'course_details', 'educationalproject_informations_edit', 'educationalproject_details', 'examen_informations_edit', 'examen_details', 'planning_list'])]
  145. private $tags;
  146. /**
  147. * The constructor
  148. */
  149. public function __construct() {
  150. $this->eventRecur = new ArrayCollection();
  151. $this->organizer = new ArrayCollection();
  152. $this->equipments = new ArrayCollection();
  153. $this->tags = new ArrayCollection();
  154. }
  155. /**
  156. * Sets id.
  157. *
  158. * @param int $id
  159. *
  160. * @return $this
  161. */
  162. public function setId($id)
  163. {
  164. $this->id = $id;
  165. return $this;
  166. }
  167. /**
  168. * Gets id.
  169. *
  170. * @return int
  171. */
  172. public function getId()
  173. {
  174. return $this->id;
  175. }
  176. /**
  177. * Sets name.
  178. *
  179. * @param string $name
  180. *
  181. * @return $this
  182. */
  183. public function setName($name)
  184. {
  185. $this->name = $name;
  186. return $this;
  187. }
  188. /**
  189. * Gets name.
  190. *
  191. * @return string
  192. */
  193. public function getName()
  194. {
  195. return $this->name;
  196. }
  197. /**
  198. * Sets color.
  199. *
  200. * @param string $color
  201. *
  202. * @return $this
  203. */
  204. public function setColor($color)
  205. {
  206. $this->color = $color;
  207. return $this;
  208. }
  209. /**
  210. * Gets color.
  211. *
  212. * @return string
  213. */
  214. public function getColor()
  215. {
  216. return $this->color;
  217. }
  218. /**
  219. * Sets hasReplacement.
  220. *
  221. * @param boolean $hasReplacement
  222. *
  223. * @return $this
  224. */
  225. public function setHasReplacement($hasReplacement)
  226. {
  227. $this->hasReplacement = $hasReplacement;
  228. return $this;
  229. }
  230. /**
  231. * Gets hasReplacement.
  232. *
  233. * @return boolean
  234. */
  235. public function getHasReplacement()
  236. {
  237. return $this->hasReplacement;
  238. }
  239. /**
  240. * Sets organization.
  241. *
  242. * @param Organization $organization
  243. *
  244. * @return $this
  245. */
  246. public function setOrganization(Organization $organization = null)
  247. {
  248. $this->organization = $organization;
  249. return $this;
  250. }
  251. /**
  252. * Gets organization.
  253. *
  254. * @return Organization
  255. */
  256. public function getOrganization()
  257. {
  258. return $this->organization;
  259. }
  260. /**
  261. * Adds organizer.
  262. *
  263. * @param Access $organizer
  264. *
  265. * @return $this
  266. */
  267. public function addOrganizer(Access $organizer)
  268. {
  269. $this->organizer[] = $organizer;
  270. return $this;
  271. }
  272. /**
  273. * Removes organizer.
  274. *
  275. * @param Access $organizer
  276. *
  277. * @return $this
  278. */
  279. public function removeOrganizer(Access $organizer)
  280. {
  281. $this->organizer->removeElement($organizer);
  282. return $this;
  283. }
  284. /**
  285. * Gets organizer.
  286. *
  287. * @return ArrayCollection<Access>
  288. */
  289. public function getOrganizer()
  290. {
  291. return $this->organizer;
  292. }
  293. /**
  294. * Sets datetimeStart.
  295. *
  296. * @param \DateTime $datetimeStart
  297. *
  298. * @return $this
  299. */
  300. public function setDatetimeStart(\DateTime $datetimeStart = null)
  301. {
  302. $this->datetimeStart = $datetimeStart;
  303. return $this;
  304. }
  305. /**
  306. * Gets datetimeStart.
  307. *
  308. * @return \DateTime
  309. */
  310. public function getDatetimeStart()
  311. {
  312. return $this->datetimeStart;
  313. }
  314. /**
  315. * Sets datetimeEnd.
  316. *
  317. * @param \DateTime $datetimeEnd
  318. *
  319. * @return $this
  320. */
  321. public function setDatetimeEnd(\DateTime $datetimeEnd = null)
  322. {
  323. $this->datetimeEnd = $datetimeEnd;
  324. return $this;
  325. }
  326. /**
  327. * Gets datetimeEnd.
  328. *
  329. * @return \DateTime
  330. */
  331. public function getDatetimeEnd()
  332. {
  333. return $this->datetimeEnd;
  334. }
  335. /**
  336. * Add eventRecur
  337. *
  338. * @param IBookingRecur $eventRecur
  339. *
  340. * @return $this
  341. */
  342. public function addEventRecur(IBookingRecur $eventRecur)
  343. {
  344. $eventRecur->setEvent($this);
  345. $this->eventRecur->add($eventRecur);
  346. return $this;
  347. }
  348. /**
  349. * Remove eventRecur
  350. *
  351. * @param IBookingRecur $eventRecur
  352. */
  353. public function removeEventRecur(IBookingRecur $eventRecur)
  354. {
  355. $eventRecur->setEvent(null);
  356. $this->eventRecur->removeElement($eventRecur);
  357. }
  358. /**
  359. * Remove eventRecur
  360. *
  361. * @param IBookingRecur $eventRecur
  362. */
  363. public function resetEventRecur()
  364. {
  365. foreach($this->getEventRecur() as $eventRecur){
  366. $eventRecur->setEvent(null);
  367. $this->eventRecur->removeElement($eventRecur);
  368. }
  369. $this->eventRecur->clear();
  370. }
  371. /**
  372. * Get eventRecur
  373. *
  374. * @return \Doctrine\Common\Collections\Collection
  375. */
  376. public function getEventRecur()
  377. {
  378. return $this->eventRecur;
  379. }
  380. /**
  381. * Set description
  382. *
  383. * @param string $description
  384. *
  385. * @return AbstractBooking
  386. */
  387. public function setDescription($description)
  388. {
  389. $this->description = $description;
  390. return $this;
  391. }
  392. /**
  393. * Get description
  394. *
  395. * @return string
  396. */
  397. public function getDescription()
  398. {
  399. return $this->description;
  400. }
  401. /**
  402. * Set place
  403. *
  404. * @param \AppBundle\Entity\Place\Place $place
  405. *
  406. * @return AbstractBooking
  407. */
  408. public function setPlace(\AppBundle\Entity\Place\Place $place = null)
  409. {
  410. $this->place = $place;
  411. return $this;
  412. }
  413. /**
  414. * Get place
  415. *
  416. * @return \AppBundle\Entity\Place\Place
  417. */
  418. public function getPlace()
  419. {
  420. return $this->place;
  421. }
  422. /**
  423. * Set room
  424. *
  425. * @param \AppBundle\Entity\Place\Room $room
  426. *
  427. * @return AbstractBooking
  428. */
  429. public function setRoom(\AppBundle\Entity\Place\Room $room = null)
  430. {
  431. $this->room = $room;
  432. return $this;
  433. }
  434. /**
  435. * Get room
  436. *
  437. * @return \AppBundle\Entity\Place\Room
  438. */
  439. public function getRoom()
  440. {
  441. return $this->room;
  442. }
  443. /**
  444. * {@inheritdoc}
  445. */
  446. public function getParticipants() {
  447. throw new \Exception('This method must be implemented by children');
  448. }
  449. /**
  450. * Add equipment
  451. *
  452. * @param \AppBundle\Entity\Product\Equipment $equipment
  453. *
  454. * @return AbstractBooking
  455. */
  456. public function addEquipment(\AppBundle\Entity\Product\Equipment $equipment)
  457. {
  458. $this->equipments[] = $equipment;
  459. return $this;
  460. }
  461. /**
  462. * Remove equipment
  463. *
  464. * @param \AppBundle\Entity\Product\Equipment $equipment
  465. */
  466. public function removeEquipment(\AppBundle\Entity\Product\Equipment $equipment)
  467. {
  468. $this->equipments->removeElement($equipment);
  469. }
  470. /**
  471. * Get equipments
  472. *
  473. * @return \Doctrine\Common\Collections\Collection
  474. */
  475. public function getEquipments()
  476. {
  477. return $this->equipments;
  478. }
  479. /**
  480. * Add tag
  481. *
  482. * @param \AppBundle\Entity\Core\Tagg $tag
  483. *
  484. * @return AbstractBooking
  485. */
  486. public function addTag(\AppBundle\Entity\Core\Tagg $tag)
  487. {
  488. $this->tags[] = $tag;
  489. return $this;
  490. }
  491. /**
  492. * Remove tag
  493. *
  494. * @param \AppBundle\Entity\Core\Tagg $tag
  495. */
  496. public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
  497. {
  498. $this->tags->removeElement($tag);
  499. }
  500. /**
  501. * Get tags
  502. *
  503. * @return \Doctrine\Common\Collections\Collection
  504. */
  505. public function getTags()
  506. {
  507. return $this->tags;
  508. }
  509. }