Organization.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Organization;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Annotation\ApiSubresource;
  6. use App\Entity\Core\BankAccount;
  7. use App\Entity\Core\ContactPoint;
  8. use App\Entity\Network\NetworkOrganization;
  9. use App\Repository\Organization\OrganizationRepository;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use JetBrains\PhpStorm\Pure;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. /**
  16. * Structure, organisation
  17. */
  18. #[ApiResource(
  19. itemOperations: [
  20. 'get' => [
  21. 'security' => '(is_granted("ROLE_ORGANIZATION_VIEW") or is_granted("ROLE_ORGANIZATION")) and object.getId() == user.getOrganization().getId()'
  22. ],
  23. 'put' => [
  24. 'security' => 'is_granted("ROLE_ORGANIZATION") and object.getId() == user.getOrganization()s.getId()'
  25. ]
  26. ]
  27. )]
  28. #[ORM\Entity(repositoryClass: OrganizationRepository::class)]
  29. class Organization
  30. {
  31. #[ORM\Id]
  32. #[ORM\Column]
  33. #[ORM\GeneratedValue]
  34. private ?int $id = null;
  35. #[ORM\Column(length: 128)]
  36. public string $name;
  37. #[ORM\Column(length: 128)]
  38. private string $identifier;
  39. #[ORM\Column(length: 255, nullable: true)]
  40. #[Assert\Choice(callback: ['\App\Enum\Organization\LegalEnum', 'toArray'], message: 'invalid-legal-status')]
  41. private ?string $legalStatus = null;
  42. #[ORM\Column(length: 255, nullable: true)]
  43. #[Assert\Choice(callback: ['\App\Enum\Organization\PrincipalTypeEnum', 'toArray'], message: 'invalid-principal-type')]
  44. private ?string $principalType = null;
  45. #[ORM\OneToOne(mappedBy: 'organization', cascade: ['persist', 'remove'])]
  46. private Settings $settings;
  47. #[ORM\OneToMany(mappedBy: 'organization', targetEntity: NetworkOrganization::class, orphanRemoval: true)]
  48. private Collection $networkOrganizations;
  49. #[ORM\OneToMany(mappedBy: 'parent', targetEntity: NetworkOrganization::class, orphanRemoval: true)]
  50. private Collection $networkOrganizationChildren;
  51. #[ORM\OneToOne(cascade: ['persist', 'remove'])]
  52. #[ORM\JoinColumn(nullable: false)]
  53. private Parameters $parameters;
  54. #[ORM\Column(length: 255, nullable: true)]
  55. private ?string $description = null;
  56. #[ORM\Column(type: 'date', nullable: true)]
  57. private ?\DateTimeInterface $creationDate = null;
  58. #[ORM\Column(type: 'date', nullable: true)]
  59. private ?\DateTimeInterface $declarationDate = null;
  60. #[ORM\Column(length: 14, nullable: true)]
  61. private ?string $siretNumber = null;
  62. #[ORM\Column(length: 10, nullable: true)]
  63. private ?string $waldecNumber = null;
  64. #[ORM\Column(length: 5, nullable: true)]
  65. private ?string $apeNumber = null;
  66. #[ORM\Column(length: 50, nullable: true)]
  67. private ?string $tvaNumber = null;
  68. #[ORM\Column(length: 40, nullable: true)]
  69. private ?string $otherType = null;
  70. #[ORM\Column(length: 80, nullable: true)]
  71. private ?string $acronym = null;
  72. #[ORM\Column(length: 255, nullable: true)]
  73. private ?string $facebook = null;
  74. #[ORM\Column(length: 255, nullable: true)]
  75. private ?string $twitter = null;
  76. #[ORM\Column(length: 255, nullable: true)]
  77. private ?string $instagram = null;
  78. #[ORM\Column(length: 35, nullable: true)]
  79. private ?string $collectiveAgreement = null;
  80. #[ORM\Column(length: 255, nullable: true)]
  81. #[Assert\Choice(callback: ['\App\Enum\Organization\OpcaEnum', 'toArray'], message: 'invalid-opca')]
  82. private ?string $opca = null;
  83. #[ORM\Column(length: 35, nullable: true)]
  84. private ?string $icomNumber = null;
  85. #[ORM\Column(length: 35, nullable: true)]
  86. private ?string $urssafNumber = null;
  87. #[ORM\Column(length: 20, nullable: true)]
  88. private ?string $youngApproval = null;
  89. #[ORM\Column(length: 20, nullable: true)]
  90. private ?string $trainingApproval = null;
  91. #[ORM\Column(length: 50, nullable: true)]
  92. private ?string $otherApproval = null;
  93. #[ORM\Column(length: 35, nullable: true)]
  94. private ?string $prefectureName = null;
  95. #[ORM\Column(length: 20, nullable: true)]
  96. private ?string $prefectureNumber = null;
  97. #[ORM\Column(length: 255, nullable: true)]
  98. #[Assert\Choice(callback: ['\App\Enum\Organization\CategoryEnum', 'toArray'], message: 'invalid-category')]
  99. private ?string $category = null;
  100. #[ORM\Column(length: 255, nullable: true)]
  101. #[Assert\Choice(callback: ['\App\Enum\Organization\SchoolCategoryEnum', 'toArray'], message: 'invalid-school-category')]
  102. private ?string $schoolCategory = null;
  103. #[ORM\Column(length: 255, nullable: true)]
  104. #[Assert\Choice(callback: ['\App\Enum\Organization\TypeEstablishmentEnum', 'toArray'], message: 'invalid-type-establishment')]
  105. private ?string $typeEstablishment = null;
  106. #[ORM\Column(length: 255, nullable: true)]
  107. #[Assert\Choice(callback: ['\App\Enum\Organization\TypeEstablishmentDetailEnum', 'toArray'], message: 'invalid-type-establishment-detail')]
  108. private ?string $typeEstablishmentDetail = null;
  109. #[ORM\Column(nullable: true)]
  110. private ?float $budget = null;
  111. #[ORM\Column(nullable: true)]
  112. private ?bool $isPedagogicIsPrincipalActivity = null;
  113. #[ORM\Column(nullable: true)]
  114. private ?float $pedagogicBudget = null;
  115. #[ORM\Column(nullable: true)]
  116. private ?bool $isPerformanceContractor = null;
  117. #[ORM\Column(length:20, nullable: true)]
  118. private ?string $ffecApproval = null;
  119. #[ORM\Column]
  120. private bool $portailVisibility;
  121. #[ORM\Column(nullable: true)]
  122. private ?int $cmsId = null;
  123. #[ORM\Column(nullable: true)]
  124. private ?string $otherPractice = null;
  125. #[ORM\ManyToMany(targetEntity: ContactPoint::class, mappedBy: 'organization')]
  126. #[ApiSubresource]
  127. private Collection $contactPoints;
  128. #[ORM\ManyToMany(targetEntity: BankAccount::class, mappedBy: 'organization')]
  129. #[ApiSubresource]
  130. private Collection $bankAccounts;
  131. #[ORM\OneToMany( mappedBy: 'organization', targetEntity: OrganizationAddressPostal::class, orphanRemoval: true)]
  132. #[ApiSubresource]
  133. private Collection $organizationAddressPostals;
  134. #[ORM\OneToMany(mappedBy: 'organization', targetEntity: OrganizationLicence::class, orphanRemoval: true)]
  135. private Collection $organizationLicences;
  136. #[Pure] public function __construct()
  137. {
  138. $this->networkOrganizations = new ArrayCollection();
  139. $this->networkOrganizationChildren = new ArrayCollection();
  140. $this->contactPoints = new ArrayCollection();
  141. $this->bankAccounts = new ArrayCollection();
  142. $this->organizationAddressPostals = new ArrayCollection();
  143. $this->organizationLicences = new ArrayCollection();
  144. }
  145. public function getId(): ?int
  146. {
  147. return $this->id;
  148. }
  149. public function getName(): string
  150. {
  151. return $this->name;
  152. }
  153. public function setName(string $name): self
  154. {
  155. $this->name = $name;
  156. return $this;
  157. }
  158. public function getIdentifier(): string
  159. {
  160. return $this->identifier;
  161. }
  162. public function setIdentifier(string $identifier): self
  163. {
  164. $this->identifier = $identifier;
  165. return $this;
  166. }
  167. public function getLegalStatus(): ?string
  168. {
  169. return $this->legalStatus;
  170. }
  171. public function setLegalStatus(?string $legalStatus): self
  172. {
  173. $this->legalStatus = $legalStatus;
  174. return $this;
  175. }
  176. public function getPrincipalType(): ?string
  177. {
  178. return $this->principalType;
  179. }
  180. public function setPrincipalType(?string $principalType): self
  181. {
  182. $this->principalType = $principalType;
  183. return $this;
  184. }
  185. public function getSettings(): Settings
  186. {
  187. return $this->settings;
  188. }
  189. public function setSettings(Settings $settings): self
  190. {
  191. // set the owning side of the relation if necessary
  192. if ($settings->getOrganization() !== $this) {
  193. $settings->setOrganization($this);
  194. }
  195. $this->settings = $settings;
  196. return $this;
  197. }
  198. public function getNetworkOrganizations(): Collection
  199. {
  200. return $this->networkOrganizations;
  201. }
  202. public function addNetworkOrganization(NetworkOrganization $networkOrganization): self
  203. {
  204. if (!$this->networkOrganizations->contains($networkOrganization)) {
  205. $this->networkOrganizations[] = $networkOrganization;
  206. $networkOrganization->setOrganization($this);
  207. }
  208. return $this;
  209. }
  210. public function removeNetworkOrganization(NetworkOrganization $networkOrganization): self
  211. {
  212. if ($this->networkOrganizations->removeElement($networkOrganization)) {
  213. // set the owning side to null (unless already changed)
  214. if ($networkOrganization->getOrganization() === $this) {
  215. $networkOrganization->setOrganization(null);
  216. }
  217. }
  218. return $this;
  219. }
  220. public function getNetworkOrganizationChildren(): Collection
  221. {
  222. return $this->networkOrganizationChildren;
  223. }
  224. public function addNetworkOrganizationChild(NetworkOrganization $networkOrganizationChild): self
  225. {
  226. if (!$this->networkOrganizationChildren->contains($networkOrganizationChild)) {
  227. $this->networkOrganizationChildren[] = $networkOrganizationChild;
  228. $networkOrganizationChild->setParent($this);
  229. }
  230. return $this;
  231. }
  232. public function removeNetworkOrganizationChild(NetworkOrganization $networkOrganizationChild): self
  233. {
  234. if ($this->networkOrganizationChildren->removeElement($networkOrganizationChild)) {
  235. // set the owning side to null (unless already changed)
  236. if ($networkOrganizationChild->getParent() === $this) {
  237. $networkOrganizationChild->setParent(null);
  238. }
  239. }
  240. return $this;
  241. }
  242. public function getParameters(): Parameters
  243. {
  244. return $this->parameters;
  245. }
  246. public function setParameters(Parameters $parameters): self
  247. {
  248. $this->parameters = $parameters;
  249. return $this;
  250. }
  251. public function getDescription(): ?string
  252. {
  253. return $this->description;
  254. }
  255. public function setDescription(?string $description): self
  256. {
  257. $this->description = $description;
  258. return $this;
  259. }
  260. public function getCreationDate(): ?\DateTimeInterface
  261. {
  262. return $this->creationDate;
  263. }
  264. public function setCreationDate(?\DateTimeInterface $creationDate): self
  265. {
  266. $this->creationDate = $creationDate;
  267. return $this;
  268. }
  269. public function getDeclarationDate(): ?\DateTimeInterface
  270. {
  271. return $this->declarationDate;
  272. }
  273. public function setDeclarationDate(?\DateTimeInterface $declarationDate): self
  274. {
  275. $this->declarationDate = $declarationDate;
  276. return $this;
  277. }
  278. public function getSiretNumber(): ?string
  279. {
  280. return $this->siretNumber;
  281. }
  282. public function setSiretNumber(?string $siretNumber): self
  283. {
  284. $this->siretNumber = $siretNumber;
  285. return $this;
  286. }
  287. public function getWaldecNumber(): ?string
  288. {
  289. return $this->waldecNumber;
  290. }
  291. public function setWaldecNumber(?string $waldecNumber): self
  292. {
  293. $this->waldecNumber = $waldecNumber;
  294. return $this;
  295. }
  296. public function getApeNumber(): ?string
  297. {
  298. return $this->apeNumber;
  299. }
  300. public function setApeNumber(?string $apeNumber): self
  301. {
  302. $this->apeNumber = $apeNumber;
  303. return $this;
  304. }
  305. public function getTvaNumber(): ?string
  306. {
  307. return $this->tvaNumber;
  308. }
  309. public function setTvaNumber(?string $tvaNumber): self
  310. {
  311. $this->tvaNumber = $tvaNumber;
  312. return $this;
  313. }
  314. public function getOtherType(): ?string
  315. {
  316. return $this->otherType;
  317. }
  318. public function setOtherType(?string $otherType): self
  319. {
  320. $this->otherType = $otherType;
  321. return $this;
  322. }
  323. public function getAcronym(): ?string
  324. {
  325. return $this->acronym;
  326. }
  327. public function setAcronym(?string $acronym): self
  328. {
  329. $this->acronym = $acronym;
  330. return $this;
  331. }
  332. public function getFacebook(): ?string
  333. {
  334. return $this->facebook;
  335. }
  336. public function setFacebook(?string $facebook): self
  337. {
  338. $this->facebook = $facebook;
  339. return $this;
  340. }
  341. public function getTwitter(): ?string
  342. {
  343. return $this->twitter;
  344. }
  345. public function setTwitter(?string $twitter): self
  346. {
  347. $this->twitter = $twitter;
  348. return $this;
  349. }
  350. public function getInstagram(): ?string
  351. {
  352. return $this->instagram;
  353. }
  354. public function setInstagram(?string $instagram): self
  355. {
  356. $this->instagram = $instagram;
  357. return $this;
  358. }
  359. public function getCollectiveAgreement(): ?string
  360. {
  361. return $this->collectiveAgreement;
  362. }
  363. public function setCollectiveAgreement(?string $collectiveAgreement): self
  364. {
  365. $this->collectiveAgreement = $collectiveAgreement;
  366. return $this;
  367. }
  368. public function getOpca(): ?string
  369. {
  370. return $this->opca;
  371. }
  372. public function setOpca(?string $opca): self
  373. {
  374. $this->opca = $opca;
  375. return $this;
  376. }
  377. public function getIcomNumber(): ?string
  378. {
  379. return $this->icomNumber;
  380. }
  381. public function setIcomNumber(?string $icomNumber): self
  382. {
  383. $this->icomNumber = $icomNumber;
  384. return $this;
  385. }
  386. public function getUrssafNumber(): ?string
  387. {
  388. return $this->urssafNumber;
  389. }
  390. public function setUrssafNumber(?string $urssafNumber): self
  391. {
  392. $this->urssafNumber = $urssafNumber;
  393. return $this;
  394. }
  395. public function getYoungApproval(): ?string
  396. {
  397. return $this->youngApproval;
  398. }
  399. public function setYoungApproval(?string $youngApproval): self
  400. {
  401. $this->youngApproval = $youngApproval;
  402. return $this;
  403. }
  404. public function getTrainingApproval(): ?string
  405. {
  406. return $this->trainingApproval;
  407. }
  408. public function setTrainingApproval(?string $trainingApproval): self
  409. {
  410. $this->trainingApproval = $trainingApproval;
  411. return $this;
  412. }
  413. public function getOtherApproval(): ?string
  414. {
  415. return $this->otherApproval;
  416. }
  417. public function setOtherApproval(?string $otherApproval): self
  418. {
  419. $this->otherApproval = $otherApproval;
  420. return $this;
  421. }
  422. public function getPrefectureName(): ?string
  423. {
  424. return $this->prefectureName;
  425. }
  426. public function setPrefectureName(?string $prefectureName): self
  427. {
  428. $this->prefectureName = $prefectureName;
  429. return $this;
  430. }
  431. public function getPrefectureNumber(): ?string
  432. {
  433. return $this->prefectureNumber;
  434. }
  435. public function setPrefectureNumber(?string $prefectureNumber): self
  436. {
  437. $this->prefectureNumber = $prefectureNumber;
  438. return $this;
  439. }
  440. public function getCategory(): ?string
  441. {
  442. return $this->category;
  443. }
  444. public function setCategory(?string $category): self
  445. {
  446. $this->category = $category;
  447. return $this;
  448. }
  449. public function getSchoolCategory(): ?string
  450. {
  451. return $this->schoolCategory;
  452. }
  453. public function setSchoolCategory(?string $schoolCategory): self
  454. {
  455. $this->schoolCategory = $schoolCategory;
  456. return $this;
  457. }
  458. public function getTypeEstablishment(): ?string
  459. {
  460. return $this->typeEstablishment;
  461. }
  462. public function setTypeEstablishment(?string $typeEstablishment): self
  463. {
  464. $this->typeEstablishment = $typeEstablishment;
  465. return $this;
  466. }
  467. public function getTypeEstablishmentDetail(): ?string
  468. {
  469. return $this->typeEstablishmentDetail;
  470. }
  471. public function setTypeEstablishmentDetail(?string $typeEstablishmentDetail): self
  472. {
  473. $this->typeEstablishmentDetail = $typeEstablishmentDetail;
  474. return $this;
  475. }
  476. public function getBudget(): ?float
  477. {
  478. return $this->budget;
  479. }
  480. public function setBudget(?float $budget): self
  481. {
  482. $this->budget = $budget;
  483. return $this;
  484. }
  485. public function getIsPedagogicIsPrincipalActivity(): ?bool
  486. {
  487. return $this->isPedagogicIsPrincipalActivity;
  488. }
  489. public function setIsPedagogicIsPrincipalActivity(?bool $isPedagogicIsPrincipalActivity): self
  490. {
  491. $this->isPedagogicIsPrincipalActivity = $isPedagogicIsPrincipalActivity;
  492. return $this;
  493. }
  494. public function getPedagogicBudget(): ?float
  495. {
  496. return $this->pedagogicBudget;
  497. }
  498. public function setPedagogicBudget(?float $pedagogicBudget): self
  499. {
  500. $this->pedagogicBudget = $pedagogicBudget;
  501. return $this;
  502. }
  503. public function getIsPerformanceContractor(): ?bool
  504. {
  505. return $this->isPerformanceContractor;
  506. }
  507. public function setIsPerformanceContractor(?bool $isPerformanceContractor): self
  508. {
  509. $this->isPerformanceContractor = $isPerformanceContractor;
  510. return $this;
  511. }
  512. public function getFfecApproval(): ?string
  513. {
  514. return $this->ffecApproval;
  515. }
  516. public function setFfecApproval(?string $ffecApproval): self
  517. {
  518. $this->ffecApproval = $ffecApproval;
  519. return $this;
  520. }
  521. public function getPortailVisibility(): bool
  522. {
  523. return $this->portailVisibility;
  524. }
  525. public function setPortailVisibility(bool $portailVisibility): self
  526. {
  527. $this->portailVisibility = $portailVisibility;
  528. return $this;
  529. }
  530. public function getCmsId(): ?int
  531. {
  532. return $this->cmsId;
  533. }
  534. public function setCmsId(?int $cmsId): self
  535. {
  536. $this->cmsId = $cmsId;
  537. return $this;
  538. }
  539. public function getOtherPractice(): ?string
  540. {
  541. return $this->otherPractice;
  542. }
  543. public function setOtherPractice(?string $otherPractice): self
  544. {
  545. $this->otherPractice = $otherPractice;
  546. return $this;
  547. }
  548. public function getContactPoints(): Collection
  549. {
  550. return $this->contactPoints;
  551. }
  552. public function addContactPoint(ContactPoint $contactPoint): self
  553. {
  554. if (!$this->contactPoints->contains($contactPoint)) {
  555. $this->contactPoints[] = $contactPoint;
  556. $contactPoint->addOrganization($this);
  557. }
  558. return $this;
  559. }
  560. public function removeContactPoint(ContactPoint $contactPoint): self
  561. {
  562. if ($this->contactPoints->removeElement($contactPoint)) {
  563. $contactPoint->removeOrganization($this);
  564. }
  565. return $this;
  566. }
  567. public function getBankAccounts(): Collection
  568. {
  569. return $this->bankAccounts;
  570. }
  571. public function addBankAccount(BankAccount $bankAccount): self
  572. {
  573. if (!$this->bankAccounts->contains($bankAccount)) {
  574. $this->bankAccounts[] = $bankAccount;
  575. $bankAccount->addOrganization($this);
  576. }
  577. return $this;
  578. }
  579. public function removeBankAccount(BankAccount $bankAccount): self
  580. {
  581. if ($this->bankAccounts->removeElement($bankAccount)) {
  582. $bankAccount->removeOrganization($this);
  583. }
  584. return $this;
  585. }
  586. public function getOrganizationAddressPostals(): Collection
  587. {
  588. return $this->organizationAddressPostals;
  589. }
  590. public function addOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
  591. {
  592. if (!$this->organizationAddressPostals->contains($organizationAddressPostal)) {
  593. $this->organizationAddressPostals[] = $organizationAddressPostal;
  594. $organizationAddressPostal->setOrganization($this);
  595. }
  596. return $this;
  597. }
  598. public function removeOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
  599. {
  600. if ($this->organizationAddressPostals->removeElement($organizationAddressPostal)) {
  601. // set the owning side to null (unless already changed)
  602. if ($organizationAddressPostal->getOrganization() === $this) {
  603. $organizationAddressPostal->setOrganization(null);
  604. }
  605. }
  606. return $this;
  607. }
  608. public function getOrganizationLicences(): Collection
  609. {
  610. return $this->organizationLicences;
  611. }
  612. public function addOrganizationLicence(OrganizationLicence $organizationLicence): self
  613. {
  614. if (!$this->organizationLicences->contains($organizationLicence)) {
  615. $this->organizationLicences[] = $organizationLicence;
  616. $organizationLicence->setOrganization($this);
  617. }
  618. return $this;
  619. }
  620. public function removeOrganizationLicence(OrganizationLicence $organizationLicence): self
  621. {
  622. if ($this->organizationLicences->removeElement($organizationLicence)) {
  623. // set the owning side to null (unless already changed)
  624. if ($organizationLicence->getOrganization() === $this) {
  625. $organizationLicence->setOrganization(null);
  626. }
  627. }
  628. return $this;
  629. }
  630. }