EducationalProject.php 14 KB

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