Room.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <?php
  2. namespace AppBundle\Entity\Place;
  3. use AppBundle\Annotation\ExportSplitFields;
  4. use AppBundle\Entity\Booking\Course;
  5. use AppBundle\Entity\Booking\EducationalProject;
  6. use AppBundle\Entity\Booking\Event;
  7. use AppBundle\Entity\Booking\Examen;
  8. use AppBundle\Entity\Core\File;
  9. use AppBundle\Entity\Core\ContactPoint;
  10. use AppBundle\Entity\Product\Equipment;
  11. use AppBundle\Entity\Traits\ContactPointType;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use AppBundle\Entity\Traits\TimestampableEntity;
  17. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  18. use AppBundle\Entity\Core\ContactInterface;
  19. /**
  20. * Salle d'une Place
  21. */
  22. #[ORM\Entity]
  23. class Room implements ContactInterface
  24. {
  25. use TimestampableEntity;
  26. use CreatorUpdaterEntity;
  27. use ContactPointType;
  28. /**
  29. * @var int
  30. */
  31. #[ORM\Column(type: 'integer')]
  32. #[ORM\Id]
  33. #[ORM\GeneratedValue(strategy: 'AUTO')]
  34. #[Groups(['room', 'equipment_list', 'equipmentrepair_list_equipment', 'equipmentaccounting_list', 'equipmentmediatheque_list', 'equipmentcostume_list', 'place_list', 'examenconvocation_list_examen', 'planning_list', 'examen_details', 'course_details', 'educationalproject_details', 'planning_detail', 'event_details'])]
  35. private $id;
  36. /**
  37. * @var Place
  38. */
  39. #[Assert\NotNull]
  40. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Place\Place', inversedBy: 'rooms')]
  41. private $place;
  42. /**
  43. * @var string
  44. */
  45. #[Assert\Type(type: 'string')]
  46. #[ORM\Column(type: 'string', nullable: true)]
  47. #[Groups(['room', 'room_reference', 'equipment_list_roomstorage', 'equipment_list_roomwhereisused', 'equipmentrent_list_equipment', 'equipmentloan_list_equipment', 'equipmentcontrol_list_equipment', 'equipmentrepair_list_equipment', 'equipmentaccounting_list_roomwhereisused', 'equipmentmediatheque_list_roomwhereisused', 'equipmentcostume_list_roomwhereisused', 'equipmentaccounting_list_roomstorage', 'equipmentmediatheque_list_roomstorage', 'equipmentcostume_list_roomstorage', 'place_list_rooms', 'examenconvocation_list_examen', 'planning_list', 'examen_details_room', 'course_details_room', 'educationalproject_details_room', 'reportmessage', 'planning_detail_room', 'student_list_courses', 'event_details_room'])]
  48. private $name;
  49. /**
  50. * @var string A short description of the item.
  51. */
  52. #[Assert\Type(type: 'string')]
  53. #[ORM\Column(type: 'text', nullable: true)]
  54. #[Groups(['room', 'place_list_rooms'])]
  55. private $description;
  56. /**
  57. * @var string
  58. */
  59. #[Assert\Type(type: 'string')]
  60. #[ORM\Column(type: 'string', nullable: true)]
  61. #[Groups(['room', 'place_list_rooms'])]
  62. private $localisation;
  63. /**
  64. * @var int
  65. */
  66. #[Assert\Type(type: 'integer', message: 'invalid-integer')]
  67. #[ORM\Column(type: 'integer', nullable: true)]
  68. #[Groups(['room', 'place_list_rooms', 'room_reference'])]
  69. private $capacity;
  70. /**
  71. * @var int
  72. */
  73. #[Assert\Type(type: 'integer', message: 'invalid-integer')]
  74. #[ORM\Column(type: 'integer', nullable: true)]
  75. #[Groups(['room', 'place_list_rooms', 'room_reference'])]
  76. private $floorSize;
  77. /**
  78. * @var ArrayCollection<OpeningHoursSpecification>
  79. */
  80. #[Assert\Valid]
  81. #[ORM\ManyToMany(targetEntity: 'OpeningHoursSpecification', cascade: ['persist'], orphanRemoval: true)]
  82. #[ORM\JoinTable(joinColumns: [], inverseJoinColumns: [])]
  83. #[ORM\JoinColumn(name: 'room_id', referencedColumnName: 'id')]
  84. #[ORM\JoinColumn(name: 'openinghoursspecification_id', referencedColumnName: 'id', unique: true)]
  85. #[Groups(['room_openinghoursspecification'])]
  86. private $openingHoursSpecification;
  87. // /**
  88. // * @var ArrayCollection<ContactPoint>
  89. // */
  90. // #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\ContactPoint')]
  91. // #[Groups(['room_contactpoint'])]
  92. // // private $contactpoint;
  93. // /**
  94. // * @var ArrayCollection<Equipment>
  95. // */
  96. // #[Assert\Valid]
  97. // #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', cascade: ['persist'])]
  98. // #[ORM\JoinTable(joinColumns: [], inverseJoinColumns: [])]
  99. // #[ORM\JoinColumn(name: 'room_id', referencedColumnName: 'id')]
  100. // #[ORM\JoinColumn(name: 'equipment_id', referencedColumnName: 'id', unique: true)]
  101. // #[Groups(['room_equipment'])]
  102. // private $equipments;
  103. /**
  104. * @var ArrayCollection<RoomControl>
  105. */
  106. #[Assert\Valid]
  107. #[ORM\OneToMany(targetEntity: 'RoomControl', mappedBy: 'room', cascade: ['persist'], orphanRemoval: true)]
  108. #[ORM\JoinColumn(nullable: false)]
  109. #[Groups(['room_control'])]
  110. private $controls;
  111. /**
  112. * @var ArrayCollection<AppBundle\Entity\Place\RoomRepair>
  113. */
  114. #[Assert\Valid]
  115. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Place\RoomRepair', mappedBy: 'room', cascade: ['persist'], orphanRemoval: true)]
  116. #[ORM\JoinColumn(nullable: false)]
  117. #[Groups(['room_repair'])]
  118. private $repairs;
  119. /**
  120. * @var ArrayCollection<Course>
  121. */
  122. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Course', mappedBy: 'room')]
  123. #[Groups(['room_booking'])]
  124. private $courses;
  125. /**
  126. * @var ArrayCollection<EducationalProject>
  127. */
  128. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\EducationalProject', mappedBy: 'room')]
  129. #[Groups(['room_booking'])]
  130. private $educationalProjects;
  131. /**
  132. * @var ArrayCollection<Event>
  133. */
  134. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Event', mappedBy: 'room')]
  135. #[Groups(['room_booking'])]
  136. private $events;
  137. /**
  138. * @var ArrayCollection<Examen>
  139. */
  140. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Booking\Examen', mappedBy: 'room')]
  141. #[Groups(['room_booking'])]
  142. private $examens;
  143. /**
  144. * @var ArrayCollection<Equipment>
  145. */
  146. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', mappedBy: 'roomStorage')]
  147. #[Groups(['room_equipment'])]
  148. private $equipmentStorages;
  149. /**
  150. * @var ArrayCollection<Equipment>
  151. */
  152. #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Product\Equipment', mappedBy: 'roomWhereIsUsed')]
  153. #[Groups(['room_equipment'])]
  154. private $equipmentUseds;
  155. /**
  156. * @var array
  157. * @ExportSplitFields({"name","description","localisation","floorSize","capacity"})
  158. *
  159. */
  160. #[Groups(['template'])]
  161. private $fullLabelTemplate;
  162. public function __construct()
  163. {
  164. $this->openingHoursSpecification = new ArrayCollection();
  165. // $this->contactpoint = new ArrayCollection();
  166. // $this->equipments = new ArrayCollection();
  167. $this->repairs = new ArrayCollection();
  168. $this->controls = new ArrayCollection();
  169. $this->courses = new ArrayCollection();
  170. $this->educationalProjects = new ArrayCollection();
  171. $this->events = new ArrayCollection();
  172. $this->examens = new ArrayCollection();
  173. $this->equipmentStorages = new ArrayCollection();
  174. $this->equipmentUseds = new ArrayCollection();
  175. }
  176. /**
  177. * Sets id.
  178. *
  179. * @param int $id
  180. *
  181. * @return $this
  182. */
  183. public function setId($id)
  184. {
  185. $this->id = $id;
  186. return $this;
  187. }
  188. /**
  189. * Gets id.
  190. *
  191. * @return int
  192. */
  193. public function getId()
  194. {
  195. return $this->id;
  196. }
  197. /**
  198. * Sets place.
  199. *
  200. * @param Place $place
  201. *
  202. * @return $this
  203. */
  204. public function setPlace(Place $place)
  205. {
  206. $this->place = $place;
  207. return $this;
  208. }
  209. /**
  210. * Gets place.
  211. *
  212. * @return Place
  213. */
  214. public function getPlace()
  215. {
  216. return $this->place;
  217. }
  218. /**
  219. * Sets name.
  220. *
  221. * @param string $name
  222. *
  223. * @return $this
  224. */
  225. public function setName($name)
  226. {
  227. $this->name = $name;
  228. return $this;
  229. }
  230. /**
  231. * Gets name.
  232. *
  233. * @return string
  234. */
  235. public function getName()
  236. {
  237. return $this->name;
  238. }
  239. /**
  240. * Sets floorSize.
  241. *
  242. * @param int $floorSize
  243. *
  244. * @return $this
  245. */
  246. public function setFloorSize($floorSize)
  247. {
  248. $this->floorSize = $floorSize;
  249. return $this;
  250. }
  251. /**
  252. * Gets floorSize.
  253. *
  254. * @return int
  255. */
  256. public function getFloorSize()
  257. {
  258. return $this->floorSize;
  259. }
  260. /**
  261. * Sets description.
  262. *
  263. * @param string $description
  264. *
  265. * @return $this
  266. */
  267. public function setDescription($description)
  268. {
  269. $this->description = $description;
  270. return $this;
  271. }
  272. /**
  273. * Gets description.
  274. *
  275. * @return string
  276. */
  277. public function getDescription()
  278. {
  279. return $this->description;
  280. }
  281. /**
  282. * Sets localisation.
  283. *
  284. * @param string $localisation
  285. *
  286. * @return $this
  287. */
  288. public function setLocalisation($localisation)
  289. {
  290. $this->localisation = $localisation;
  291. return $this;
  292. }
  293. /**
  294. * Gets localisation.
  295. *
  296. * @return string
  297. */
  298. public function getLocalisation()
  299. {
  300. return $this->localisation;
  301. }
  302. /**
  303. * Sets capacity.
  304. *
  305. * @param int $capacity
  306. *
  307. * @return $this
  308. */
  309. public function setCapacity($capacity)
  310. {
  311. $this->capacity = $capacity;
  312. return $this;
  313. }
  314. /**
  315. * Gets capacity.
  316. *
  317. * @return int
  318. */
  319. public function getCapacity()
  320. {
  321. return $this->capacity;
  322. }
  323. /**
  324. * Adds openingHoursSpecification.
  325. *
  326. * @param OpeningHoursSpecification $openingHoursSpecification
  327. *
  328. * @return $this
  329. */
  330. public function addOpeningHoursSpecification(OpeningHoursSpecification $openingHoursSpecification)
  331. {
  332. $this->openingHoursSpecification[] = $openingHoursSpecification;
  333. return $this;
  334. }
  335. /**
  336. * Removes openingHoursSpecification.
  337. *
  338. * @param OpeningHoursSpecification $openingHoursSpecification
  339. *
  340. * @return $this
  341. */
  342. public function removeOpeningHoursSpecification(OpeningHoursSpecification $openingHoursSpecification)
  343. {
  344. $this->openingHoursSpecification->removeElement($openingHoursSpecification);
  345. return $this;
  346. }
  347. /**
  348. * Gets openingHoursSpecification.
  349. *
  350. * @return ArrayCollection<OpeningHoursSpecification>
  351. */
  352. public function getOpeningHoursSpecification()
  353. {
  354. return $this->openingHoursSpecification;
  355. }
  356. // /**
  357. // * Adds contactpoint.
  358. // *
  359. // * @param ContactPoint $contactpoint
  360. // *
  361. // * @return $this
  362. // */
  363. // public function addContactpoint(ContactPoint $contactpoint)
  364. // {
  365. // $this->contactpoint[] = $contactpoint;
  366. // return $this;
  367. // }
  368. // /**
  369. // * Removes contactpoint.
  370. // *
  371. // * @param ContactPoint $contactpoint
  372. // *
  373. // * @return $this
  374. // */
  375. // public function removeContactpoint(ContactPoint $contactpoint)
  376. // {
  377. // $this->contactpoint->removeElement($contactpoint);
  378. // return $this;
  379. // }
  380. // /**
  381. // * Gets contactpoint.
  382. // *
  383. // * @return ArrayCollection<ContactPoint>
  384. // */
  385. // public function getContactpoint()
  386. // {
  387. // return $this->contactpoint;
  388. // }
  389. /**
  390. * Adds control.
  391. *
  392. * @param RoomControl $control
  393. *
  394. * @return $this
  395. */
  396. public function addControl(RoomControl $control)
  397. {
  398. $control->setRoom($this);
  399. $this->controls[] = $control;
  400. return $this;
  401. }
  402. /**
  403. * Removes control.
  404. *
  405. * @param RoomControl $control
  406. *
  407. * @return $this
  408. */
  409. public function removeControl(RoomControl $control)
  410. {
  411. $this->controls->removeElement($control);
  412. return $this;
  413. }
  414. /**
  415. * Gets control.
  416. *
  417. * @return ArrayCollection<RoomControl>
  418. */
  419. public function getControls()
  420. {
  421. return $this->controls;
  422. }
  423. /**
  424. * Adds repair.
  425. *
  426. * @param RoomRepair $repair
  427. *
  428. * @return $this
  429. */
  430. public function addRepair(RoomRepair $repair)
  431. {
  432. $repair->setRoom($this);
  433. $this->repairs[] = $repair;
  434. return $this;
  435. }
  436. /**
  437. * Removes repair.
  438. *
  439. * @param RoomRepair $repair
  440. *
  441. * @return $this
  442. */
  443. public function removeRepair(RoomRepair $repair)
  444. {
  445. $this->repairs->removeElement($repair);
  446. return $this;
  447. }
  448. /**
  449. * Gets repairs.
  450. *
  451. * @return ArrayCollection<RoomRepair>
  452. */
  453. public function getRepairs()
  454. {
  455. return $this->repairs;
  456. }
  457. // /**
  458. // * Add equipment
  459. // *
  460. // * @param \AppBundle\Entity\Product\Equipment $equipment
  461. // *
  462. // * @return Room
  463. // */
  464. // public function addEquipment(\AppBundle\Entity\Product\Equipment $equipment)
  465. // {
  466. // $this->equipments[] = $equipment;
  467. // return $this;
  468. // }
  469. // /**
  470. // * Remove equipment
  471. // *
  472. // * @param \AppBundle\Entity\Product\Equipment $equipment
  473. // */
  474. // public function removeEquipment(\AppBundle\Entity\Product\Equipment $equipment)
  475. // {
  476. // $this->equipments->removeElement($equipment);
  477. // }
  478. // /**
  479. // * Get equipments
  480. // *
  481. // * @return \Doctrine\Common\Collections\Collection
  482. // */
  483. // public function getEquipments()
  484. // {
  485. // return $this->equipments;
  486. // }
  487. /**
  488. * Add course
  489. *
  490. * @param \AppBundle\Entity\Booking\Course $course
  491. *
  492. * @return Room
  493. */
  494. public function addCourse(\AppBundle\Entity\Booking\Course $course)
  495. {
  496. $this->courses[] = $course;
  497. return $this;
  498. }
  499. /**
  500. * Remove course
  501. *
  502. * @param \AppBundle\Entity\Booking\Course $course
  503. */
  504. public function removeCourse(\AppBundle\Entity\Booking\Course $course)
  505. {
  506. $this->courses->removeElement($course);
  507. }
  508. /**
  509. * Get courses
  510. *
  511. * @return \Doctrine\Common\Collections\Collection
  512. */
  513. public function getCourses()
  514. {
  515. return $this->courses;
  516. }
  517. /**
  518. * Add educationalProject
  519. *
  520. * @param \AppBundle\Entity\Booking\EducationalProject $educationalProject
  521. *
  522. * @return Room
  523. */
  524. public function addEducationalProject(\AppBundle\Entity\Booking\EducationalProject $educationalProject)
  525. {
  526. $this->educationalProjects[] = $educationalProject;
  527. return $this;
  528. }
  529. /**
  530. * Remove educationalProject
  531. *
  532. * @param \AppBundle\Entity\Booking\EducationalProject $educationalProject
  533. */
  534. public function removeEducationalProject(\AppBundle\Entity\Booking\EducationalProject $educationalProject)
  535. {
  536. $this->educationalProjects->removeElement($educationalProject);
  537. }
  538. /**
  539. * Get educationalProjects
  540. *
  541. * @return \Doctrine\Common\Collections\Collection
  542. */
  543. public function getEducationalProjects()
  544. {
  545. return $this->educationalProjects;
  546. }
  547. /**
  548. * Add event
  549. *
  550. * @param \AppBundle\Entity\Booking\Event $event
  551. *
  552. * @return Room
  553. */
  554. public function addEvent(\AppBundle\Entity\Booking\Event $event)
  555. {
  556. $this->events[] = $event;
  557. return $this;
  558. }
  559. /**
  560. * Remove event
  561. *
  562. * @param \AppBundle\Entity\Booking\Event $event
  563. */
  564. public function removeEvent(\AppBundle\Entity\Booking\Event $event)
  565. {
  566. $this->events->removeElement($event);
  567. }
  568. /**
  569. * Get events
  570. *
  571. * @return \Doctrine\Common\Collections\Collection
  572. */
  573. public function getEvents()
  574. {
  575. return $this->events;
  576. }
  577. /**
  578. * Add examen
  579. *
  580. * @param \AppBundle\Entity\Booking\Examen $examen
  581. *
  582. * @return Room
  583. */
  584. public function addExamen(\AppBundle\Entity\Booking\Examen $examen)
  585. {
  586. $this->examens[] = $examen;
  587. return $this;
  588. }
  589. /**
  590. * Remove examen
  591. *
  592. * @param \AppBundle\Entity\Booking\Examen $examen
  593. */
  594. public function removeExamen(\AppBundle\Entity\Booking\Examen $examen)
  595. {
  596. $this->examens->removeElement($examen);
  597. }
  598. /**
  599. * Get examens
  600. *
  601. * @return \Doctrine\Common\Collections\Collection
  602. */
  603. public function getExamens()
  604. {
  605. return $this->examens;
  606. }
  607. /**
  608. * Add equipmentStorage
  609. *
  610. * @param \AppBundle\Entity\Product\Equipment $equipmentStorage
  611. *
  612. * @return Room
  613. */
  614. public function addEquipmentStorage(\AppBundle\Entity\Product\Equipment $equipmentStorage)
  615. {
  616. $this->equipmentStorages[] = $equipmentStorage;
  617. return $this;
  618. }
  619. /**
  620. * Remove equipmentStorage
  621. *
  622. * @param \AppBundle\Entity\Product\Equipment $equipmentStorage
  623. */
  624. public function removeEquipmentStorage(\AppBundle\Entity\Product\Equipment $equipmentStorage)
  625. {
  626. $this->equipmentStorages->removeElement($equipmentStorage);
  627. }
  628. /**
  629. * Get equipmentStorages
  630. *
  631. * @return \Doctrine\Common\Collections\Collection
  632. */
  633. public function getEquipmentStorages()
  634. {
  635. return $this->equipmentStorages;
  636. }
  637. /**
  638. * Add equipmentUsed
  639. *
  640. * @param \AppBundle\Entity\Product\Equipment $equipmentUsed
  641. *
  642. * @return Room
  643. */
  644. public function addEquipmentUsed(\AppBundle\Entity\Product\Equipment $equipmentUsed)
  645. {
  646. $equipmentUsed->setRoomWhereIsUsed($this);
  647. $this->equipmentUseds[] = $equipmentUsed;
  648. return $this;
  649. }
  650. /**
  651. * Remove equipmentUsed
  652. *
  653. * @param \AppBundle\Entity\Product\Equipment $equipmentUsed
  654. */
  655. public function removeEquipmentUsed(\AppBundle\Entity\Product\Equipment $equipmentUsed)
  656. {
  657. $equipmentUsed->setRoomWhereIsUsed(null);
  658. $this->equipmentUseds->removeElement($equipmentUsed);
  659. }
  660. /**
  661. * Get equipmentUseds
  662. *
  663. * @return \Doctrine\Common\Collections\Collection
  664. */
  665. public function getEquipmentUseds()
  666. {
  667. return $this->equipmentUseds;
  668. }
  669. /**
  670. *
  671. * {@inheritdoc}
  672. */
  673. public function getContact() {
  674. return $this;
  675. }
  676. /**
  677. *
  678. * {@inheritdoc}
  679. */
  680. public function getContactAddress() {
  681. return $this->getPlace()->getContactAddress();
  682. }
  683. /**
  684. *
  685. * {@inheritdoc}
  686. */
  687. public function getContactName() {
  688. return $this->getName();
  689. }
  690. /**
  691. *
  692. * {@inheritdoc}
  693. */
  694. public function getContactContactPoint() {
  695. return $this->getContactPointPrincipal();
  696. }
  697. /**
  698. * Gets full label.
  699. *
  700. * @return array
  701. */
  702. public function getFullLabelTemplate()
  703. {
  704. return [
  705. $this->getName(),
  706. $this->getDescription(),
  707. $this->getLocalisation(),
  708. $this->getFloorSize(),
  709. $this->getCapacity()
  710. ];
  711. }
  712. }