EducationalProject.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Booking;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Access\Access;
  6. use App\Entity\Billing\BillLine;
  7. use App\Entity\Billing\EducationalProjectIntangible;
  8. use App\Entity\Billing\EducationalProjectPayer;
  9. use App\Entity\Core\File;
  10. use App\Entity\Core\Tagg;
  11. use App\Entity\Organization\Organization;
  12. use App\Entity\Place\AbstractPlace;
  13. use App\Entity\Place\Room;
  14. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\Common\Collections\Collection;
  17. use Doctrine\ORM\Mapping as ORM;
  18. /**
  19. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table EducationalProject, et supprimer l'attribut discr.
  20. * @todo : migration table tag_booking
  21. * Classe ... qui ...
  22. */
  23. #[ApiResource(operations: [])]
  24. // #[Auditable]
  25. #[ORM\Table(name: 'Booking')]
  26. #[ORM\Entity]
  27. class EducationalProject extends AbstractBooking
  28. {
  29. #[ORM\Column(length: 255, nullable: false)]
  30. protected string $discr = 'educationalproject';
  31. #[ORM\OneToMany(mappedBy: 'event', targetEntity: EducationalProjectRecur::class, cascade: ['persist'], orphanRemoval: true)]
  32. protected Collection $eventRecur;
  33. #[ORM\OneToMany(mappedBy: 'parent', targetEntity: EducationalProject::class, orphanRemoval: true)]
  34. protected Collection $timeline;
  35. #[ORM\ManyToOne(inversedBy: 'timeline')]
  36. protected EducationalProject $parent;
  37. #[ORM\ManyToOne(inversedBy: 'educationalProjects')]
  38. #[ORM\JoinColumn(nullable: false)]
  39. protected Organization $organization;
  40. #[ORM\ManyToOne(inversedBy: 'silentPartners')]
  41. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  42. protected Access $silentPartner;
  43. #[ORM\ManyToOne(inversedBy: 'educationalProjects')]
  44. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  45. protected EducationalProjectPublic $public;
  46. #[ORM\ManyToOne(inversedBy: 'operationalPartners')]
  47. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  48. protected Access $operationalPartner;
  49. #[ORM\ManyToMany(targetEntity: Access::class)]
  50. #[ORM\JoinTable(name: 'educationalproject_financier')]
  51. protected Collection $financiers;
  52. #[ORM\ManyToMany(targetEntity: File::class)]
  53. protected Collection $files;
  54. #[ORM\OneToMany(mappedBy: 'educationalProject', targetEntity: EducationalProjectIntangible::class, cascade: ['persist'], orphanRemoval: true)]
  55. protected Collection $educationalProjectIntangibles;
  56. #[ORM\OneToMany(mappedBy: 'educationalProjectReceiver', targetEntity: EducationalProjectPayer::class, cascade: ['persist'], orphanRemoval: true)]
  57. protected Collection $billingReceivers;
  58. #[ORM\OneToMany(mappedBy: 'educationalProject', targetEntity: BillLine::class, orphanRemoval: true)]
  59. protected Collection $billLines;
  60. #[ORM\OneToMany(mappedBy: 'educationalProject', targetEntity: AttendanceBooking::class, cascade: ['persist'], orphanRemoval: true)]
  61. #[ORM\JoinColumn(nullable: false)]
  62. protected Collection $attendanceBooking;
  63. #[ORM\ManyToOne(inversedBy: 'educationalProjects')]
  64. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  65. protected AbstractPlace $place;
  66. #[ORM\ManyToOne(inversedBy: 'educationalProjects')]
  67. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  68. protected Room $room;
  69. #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'educationalProjectOrganizers')]
  70. #[ORM\JoinTable(name: 'booking_organizer')]
  71. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  72. #[ORM\InverseJoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
  73. protected Collection $organizer;
  74. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'educationalProjects', cascade: ['persist'])]
  75. #[ORM\JoinTable(name: 'tag_booking')]
  76. #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
  77. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  78. protected Collection $tags;
  79. #[ORM\OneToOne(targetEntity: EducationalProjectAge::class, cascade: ['persist'])]
  80. protected EducationalProjectAge $ageDistribution;
  81. public function __construct()
  82. {
  83. $this->eventRecur = new ArrayCollection();
  84. $this->timeline = new ArrayCollection();
  85. $this->financiers = new ArrayCollection();
  86. $this->files = new ArrayCollection();
  87. $this->educationalProjectIntangibles = new ArrayCollection();
  88. $this->billingReceivers = new ArrayCollection();
  89. $this->billLines = new ArrayCollection();
  90. $this->attendanceBooking = new ArrayCollection();
  91. $this->organizer = new ArrayCollection();
  92. $this->tags = new ArrayCollection();
  93. $this->equipments = new ArrayCollection();
  94. parent::__construct();
  95. }
  96. public function getDiscr(): ?string
  97. {
  98. return $this->discr;
  99. }
  100. public function setDiscr(string $discr): self
  101. {
  102. $this->discr = $discr;
  103. return $this;
  104. }
  105. /**
  106. * @return Collection<int, EducationalProjectRecur>
  107. */
  108. public function getEventRecur(): Collection
  109. {
  110. return $this->eventRecur;
  111. }
  112. public function addEventRecur(EducationalProjectRecur $eventRecur): self
  113. {
  114. if (!$this->eventRecur->contains($eventRecur)) {
  115. $this->eventRecur[] = $eventRecur;
  116. $eventRecur->setEvent($this);
  117. }
  118. return $this;
  119. }
  120. public function removeEventRecur(EducationalProjectRecur $eventRecur): self
  121. {
  122. if ($this->eventRecur->removeElement($eventRecur)) {
  123. // set the owning side to null (unless already changed)
  124. if ($eventRecur->getEvent() === $this) {
  125. $eventRecur->setEvent(null);
  126. }
  127. }
  128. return $this;
  129. }
  130. /**
  131. * @return Collection<int, EducationalProject>
  132. */
  133. public function getTimeline(): Collection
  134. {
  135. return $this->timeline;
  136. }
  137. public function addTimeline(EducationalProject $timeline): self
  138. {
  139. if (!$this->timeline->contains($timeline)) {
  140. $this->timeline[] = $timeline;
  141. $timeline->setParent($this);
  142. }
  143. return $this;
  144. }
  145. public function removeTimeline(EducationalProject $timeline): self
  146. {
  147. if ($this->timeline->removeElement($timeline)) {
  148. // set the owning side to null (unless already changed)
  149. if ($timeline->getParent() === $this) {
  150. $timeline->setParent(null);
  151. }
  152. }
  153. return $this;
  154. }
  155. public function getParent(): ?self
  156. {
  157. return $this->parent;
  158. }
  159. public function setParent(?self $parent): self
  160. {
  161. $this->parent = $parent;
  162. return $this;
  163. }
  164. public function getOrganization(): ?Organization
  165. {
  166. return $this->organization;
  167. }
  168. public function setOrganization(?Organization $organization): self
  169. {
  170. $this->organization = $organization;
  171. return $this;
  172. }
  173. public function getSilentPartner(): ?Access
  174. {
  175. return $this->silentPartner;
  176. }
  177. public function setSilentPartner(?Access $silentPartner): self
  178. {
  179. $this->silentPartner = $silentPartner;
  180. return $this;
  181. }
  182. public function getPublic(): ?EducationalProjectPublic
  183. {
  184. return $this->public;
  185. }
  186. public function setPublic(?EducationalProjectPublic $public): self
  187. {
  188. $this->public = $public;
  189. return $this;
  190. }
  191. public function getOperationalPartner(): ?Access
  192. {
  193. return $this->operationalPartner;
  194. }
  195. public function setOperationalPartner(?Access $operationalPartner): self
  196. {
  197. $this->operationalPartner = $operationalPartner;
  198. return $this;
  199. }
  200. /**
  201. * @return Collection<int, Access>
  202. */
  203. public function getFinanciers(): Collection
  204. {
  205. return $this->financiers;
  206. }
  207. public function addFinancier(Access $financier): self
  208. {
  209. if (!$this->financiers->contains($financier)) {
  210. $this->financiers[] = $financier;
  211. }
  212. return $this;
  213. }
  214. public function removeFinancier(Access $financier): self
  215. {
  216. $this->financiers->removeElement($financier);
  217. return $this;
  218. }
  219. /**
  220. * @return Collection<int, File>
  221. */
  222. public function getFiles(): Collection
  223. {
  224. return $this->files;
  225. }
  226. public function addFile(File $file): self
  227. {
  228. if (!$this->files->contains($file)) {
  229. $this->files[] = $file;
  230. }
  231. return $this;
  232. }
  233. public function removeFile(File $file): self
  234. {
  235. $this->files->removeElement($file);
  236. return $this;
  237. }
  238. /**
  239. * @return Collection<int, EducationalProjectIntangible>
  240. */
  241. public function getEducationalProjectIntangibles(): Collection
  242. {
  243. return $this->educationalProjectIntangibles;
  244. }
  245. public function addEducationalProjectIntangible(EducationalProjectIntangible $educationalProjectIntangible): self
  246. {
  247. if (!$this->educationalProjectIntangibles->contains($educationalProjectIntangible)) {
  248. $this->educationalProjectIntangibles[] = $educationalProjectIntangible;
  249. $educationalProjectIntangible->setEducationalProject($this);
  250. }
  251. return $this;
  252. }
  253. public function removeEducationalProjectIntangible(EducationalProjectIntangible $educationalProjectIntangible): self
  254. {
  255. if ($this->educationalProjectIntangibles->removeElement($educationalProjectIntangible)) {
  256. // set the owning side to null (unless already changed)
  257. if ($educationalProjectIntangible->getEducationalProject() === $this) {
  258. $educationalProjectIntangible->setEducationalProject(null);
  259. }
  260. }
  261. return $this;
  262. }
  263. /**
  264. * @return Collection<int, EducationalProjectPayer>
  265. */
  266. public function getBillingReceivers(): Collection
  267. {
  268. return $this->billingReceivers;
  269. }
  270. public function addBillingReceiver(EducationalProjectPayer $billingReceiver): self
  271. {
  272. if (!$this->billingReceivers->contains($billingReceiver)) {
  273. $this->billingReceivers[] = $billingReceiver;
  274. $billingReceiver->setEducationalProjectReceiver($this);
  275. }
  276. return $this;
  277. }
  278. public function removeBillingReceiver(EducationalProjectPayer $billingReceiver): self
  279. {
  280. if ($this->billingReceivers->removeElement($billingReceiver)) {
  281. // set the owning side to null (unless already changed)
  282. if ($billingReceiver->getEducationalProjectReceiver() === $this) {
  283. $billingReceiver->setEducationalProjectReceiver(null);
  284. }
  285. }
  286. return $this;
  287. }
  288. /**
  289. * @return Collection<int, BillLine>
  290. */
  291. public function getBillLines(): Collection
  292. {
  293. return $this->billLines;
  294. }
  295. public function addBillLine(BillLine $billLine): self
  296. {
  297. if (!$this->billLines->contains($billLine)) {
  298. $this->billLines[] = $billLine;
  299. $billLine->setEducationalProject($this);
  300. }
  301. return $this;
  302. }
  303. public function removeBillLine(BillLine $billLine): self
  304. {
  305. if ($this->billLines->removeElement($billLine)) {
  306. // set the owning side to null (unless already changed)
  307. if ($billLine->getEducationalProject() === $this) {
  308. $billLine->setEducationalProject(null);
  309. }
  310. }
  311. return $this;
  312. }
  313. /**
  314. * @return Collection<int, AttendanceBooking>
  315. */
  316. public function getAttendanceBooking(): Collection
  317. {
  318. return $this->attendanceBooking;
  319. }
  320. public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
  321. {
  322. if (!$this->attendanceBooking->contains($attendanceBooking)) {
  323. $this->attendanceBooking[] = $attendanceBooking;
  324. $attendanceBooking->setEducationalProject($this);
  325. }
  326. return $this;
  327. }
  328. public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
  329. {
  330. if ($this->attendanceBooking->removeElement($attendanceBooking)) {
  331. // set the owning side to null (unless already changed)
  332. if ($attendanceBooking->getEducationalProject() === $this) {
  333. $attendanceBooking->setEducationalProject(null);
  334. }
  335. }
  336. return $this;
  337. }
  338. public function getPlace(): ?AbstractPlace
  339. {
  340. return $this->place;
  341. }
  342. public function setPlace(?AbstractPlace $place): self
  343. {
  344. $this->place = $place;
  345. return $this;
  346. }
  347. public function getRoom(): ?Room
  348. {
  349. return $this->room;
  350. }
  351. public function setRoom(?Room $room): self
  352. {
  353. $this->room = $room;
  354. return $this;
  355. }
  356. /**
  357. * @return Collection<int, Access>
  358. */
  359. public function getOrganizer(): Collection
  360. {
  361. return $this->organizer;
  362. }
  363. public function addOrganizer(Access $organizer): self
  364. {
  365. if (!$this->organizer->contains($organizer)) {
  366. $this->organizer[] = $organizer;
  367. }
  368. return $this;
  369. }
  370. public function removeOrganizer(Access $organizer): self
  371. {
  372. $this->organizer->removeElement($organizer);
  373. return $this;
  374. }
  375. /**
  376. * @return Collection<int, Tagg>
  377. */
  378. public function getTags(): Collection
  379. {
  380. return $this->tags;
  381. }
  382. public function addTag(Tagg $tag): self
  383. {
  384. if (!$this->tags->contains($tag)) {
  385. $this->tags[] = $tag;
  386. }
  387. return $this;
  388. }
  389. public function removeTag(Tagg $tag): self
  390. {
  391. $this->tags->removeElement($tag);
  392. return $this;
  393. }
  394. public function getAgeDistribution(): EducationalProjectAge
  395. {
  396. return $this->ageDistribution;
  397. }
  398. public function setAgeDistribution(EducationalProjectAge $ageDistribution): self
  399. {
  400. $this->ageDistribution = $ageDistribution;
  401. return $this;
  402. }
  403. }