Parameters.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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\Access\Access;
  7. use App\Entity\Core\File;
  8. use App\Repository\Organization\ParametersRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use JetBrains\PhpStorm\Pure;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. use App\Validator\Organization\Parameters as OpentalentAssert;
  15. #[ApiResource(
  16. collectionOperations: [],
  17. itemOperations: [
  18. 'get' => [
  19. 'security' => '(is_granted("ROLE_ORGANIZATION_VIEW") or is_granted("ROLE_ORGANIZATION")) and object.getOrganization().getId() == user.getOrganization().getId()'
  20. ],
  21. 'put' => [
  22. 'security' => 'is_granted("ROLE_ORGANIZATION") and object.getOrganization().getId() == user.getOrganization().getId()'
  23. ]
  24. ]
  25. )]
  26. #[ORM\Entity(repositoryClass: ParametersRepository::class)]
  27. #[OpentalentAssert\MobytCredentials]
  28. class Parameters
  29. {
  30. #[ORM\Id]
  31. #[ORM\Column]
  32. #[ORM\GeneratedValue]
  33. private ?int $id = null;
  34. #[ORM\OneToOne(mappedBy: 'parameters', targetEntity: Organization::class)]
  35. private Organization $organization;
  36. #[ORM\Column(type: 'date', nullable: true)]
  37. private ?\DateTimeInterface $financialDate = null;
  38. #[ORM\Column(type: 'date', nullable: true)]
  39. private ?\DateTimeInterface $musicalDate = null;
  40. #[ORM\Column(type: 'date', nullable: true)]
  41. private ?\DateTimeInterface $startCourseDate = null;
  42. #[ORM\Column(type: 'date', nullable: true)]
  43. private ?\DateTimeInterface $endCourseDate = null;
  44. #[ORM\Column(options: ['default' => false])]
  45. private bool $trackingValidation = false;
  46. #[ORM\Column(options: ['default' => 20])]
  47. #[Assert\Range(
  48. notInRangeMessage: 'between_{{ min }}_and_{{ max }}',
  49. min: 0,
  50. max: 100
  51. )]
  52. private int $average = 20;
  53. #[ORM\Column(options: ['default' => true])]
  54. private bool $editCriteriaNotationByAdminOnly = true;
  55. #[ORM\Column(length: 255, nullable: true)]
  56. #[Assert\Regex('/^[a-z0-9]+$/i', message: 'smsSenderName_error')]
  57. private ?string $smsSenderName = null;
  58. #[ORM\Column(options: ['default' => false])]
  59. private bool $logoDonorsMove = false;
  60. #[ORM\Column(length: 60, nullable: true)]
  61. private ?string $subDomain = null;
  62. #[ORM\Column(length: 100, nullable: true)]
  63. private ?string $website = null;
  64. #[ORM\Column(length: 150, nullable: true)]
  65. private ?string $otherWebsite = null;
  66. #[ORM\Column(options: ['default' => false])]
  67. private bool $desactivateOpentalentSiteWeb = false;
  68. #[ORM\OneToMany( mappedBy: 'publicationDirector', targetEntity: Access::class)]
  69. #[ApiSubresource]
  70. private Collection $publicationDirectors;
  71. #[ORM\Column(length: 255, nullable: true)]
  72. #[Assert\Choice(callback: ['\App\Enum\Organization\BulletinPeriodEnum', 'toArray'], message: 'invalid-bulletin-period')]
  73. private ?string $bulletinPeriod = null;
  74. #[ORM\Column(options: ['default' => false])]
  75. private bool $bulletinWithTeacher = false;
  76. #[ORM\Column(options: ['default' => false])]
  77. private bool $bulletinPrintAddress = false;
  78. #[ORM\Column(options: ['default' => true])]
  79. private bool $bulletinSignatureDirector = true;
  80. #[ORM\Column(options: ['default' => true])]
  81. private bool $bulletinDisplayLevelAcquired = true;
  82. #[ORM\Column(options: ['default' => false])]
  83. private bool $bulletinShowEducationWithoutEvaluation = false;
  84. #[ORM\Column(options: ['default' => false])]
  85. private bool $bulletinViewTestResults = false;
  86. #[ORM\Column(options: ['default' => false])]
  87. private bool $bulletinShowAbsences = false;
  88. #[ORM\Column(options: ['default' => true])]
  89. private bool $bulletinShowAverages = true;
  90. #[ORM\Column(length: 255, nullable: true)]
  91. #[Assert\Choice(callback: ['\App\Enum\Organization\BulletinOutputEnum', 'toArray'], message: 'invalid-bulletin-output')]
  92. private ?string $bulletinOutput = null;
  93. #[ORM\Column(options: ['default' => true])]
  94. private bool $bulletinEditWithoutEvaluation = true;
  95. #[ORM\Column(length: 255, nullable: true, options: ['default' => 'STUDENTS_AND_THEIR_GUARDIANS'])]
  96. #[Assert\Choice(callback: ['\App\Enum\Organization\SendToBulletinEnum', 'toArray'], message: 'invalid-send-to-bulletin')]
  97. private ?string $bulletinReceiver = null;
  98. #[ORM\Column(length: 255, nullable: true)]
  99. private ?string $usernameSMS = null;
  100. #[ORM\Column(length: 255, nullable: true)]
  101. private ?string $passwordSMS = null;
  102. #[ORM\Column(options: ['default' => true])]
  103. private bool $showAdherentList = true;
  104. #[ORM\Column(options: ['default' => false])]
  105. private bool $studentsAreAdherents = false;
  106. #[ORM\OneToOne(inversedBy: 'qrCode', targetEntity: File::class, cascade: ['persist'], fetch: 'EAGER')]
  107. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  108. private ?File $qrCode = null;
  109. #[ORM\Column(length: 255, options: ['default' => 'Europe/Paris'])]
  110. #[Assert\Choice(callback: ['\App\Enum\Core\TimeZoneEnum', 'toArray'], message: 'invalid-timezone')]
  111. private ?string $timezone = "Europe/Paris";
  112. #[ORM\Column(length: 255, nullable: true, options: ['default' => 'ANNUAL'])]
  113. #[Assert\Choice(callback: ['\App\Enum\Education\PeriodicityEnum', 'toArray'], message: 'invalid-periodicity')]
  114. private ?string $educationPeriodicity = null;
  115. #[ORM\Column(length: 255, nullable: true, options: ['default' => 'BY_EDUCATION'])]
  116. #[Assert\Choice(callback: ['\App\Enum\Education\AdvancedEducationNotationTypeEnum', 'toArray'], message: 'invalid-advanced-education-notation-type')]
  117. private ?string $advancedEducationNotationType = null;
  118. #[ORM\Column(options: ['default' => false])]
  119. private bool $sendAttendanceEmail = false;
  120. #[ORM\Column(options: ['default' => false])]
  121. private bool $sendAttendanceSms = false;
  122. #[ORM\OneToOne(targetEntity: Subdomain::class, cascade: ['persist'], fetch: 'EAGER')]
  123. private ?Subdomain $activeSubdomain = null;
  124. #[ORM\OneToMany( mappedBy: 'parameters', targetEntity: Subdomain::class)]
  125. #[ApiSubresource]
  126. private Collection $subdomains;
  127. #[Pure] public function __construct()
  128. {
  129. $this->publicationDirectors = new ArrayCollection();
  130. }
  131. public function getId(): ?int
  132. {
  133. return $this->id;
  134. }
  135. public function getOrganization(): Organization
  136. {
  137. return $this->organization;
  138. }
  139. public function setOrganization(Organization $organization): self
  140. {
  141. $this->organization = $organization;
  142. return $this;
  143. }
  144. public function getFinancialDate(): ?\DateTimeInterface
  145. {
  146. return $this->financialDate;
  147. }
  148. public function setFinancialDate(?\DateTimeInterface $financialDate): self
  149. {
  150. $this->financialDate = $financialDate;
  151. return $this;
  152. }
  153. public function getMusicalDate(): ?\DateTimeInterface
  154. {
  155. return $this->musicalDate;
  156. }
  157. public function setMusicalDate(?\DateTimeInterface $musicalDate): self
  158. {
  159. $this->musicalDate = $musicalDate;
  160. return $this;
  161. }
  162. public function getStartCourseDate(): ?\DateTimeInterface
  163. {
  164. return $this->startCourseDate;
  165. }
  166. public function setStartCourseDate(?\DateTimeInterface $startCourseDate): self
  167. {
  168. $this->startCourseDate = $startCourseDate;
  169. return $this;
  170. }
  171. public function getEndCourseDate(): ?\DateTimeInterface
  172. {
  173. return $this->endCourseDate;
  174. }
  175. public function setEndCourseDate(?\DateTimeInterface $endCourseDate): self
  176. {
  177. $this->endCourseDate = $endCourseDate;
  178. return $this;
  179. }
  180. public function getTrackingValidation(): bool
  181. {
  182. return $this->trackingValidation;
  183. }
  184. public function setTrackingValidation(bool $trackingValidation): self
  185. {
  186. $this->trackingValidation = $trackingValidation;
  187. return $this;
  188. }
  189. public function getAverage(): int
  190. {
  191. return $this->average;
  192. }
  193. public function setAverage(int $average)
  194. {
  195. $this->average = $average;
  196. return $this;
  197. }
  198. public function getEditCriteriaNotationByAdminOnly(): bool
  199. {
  200. return $this->editCriteriaNotationByAdminOnly;
  201. }
  202. public function setEditCriteriaNotationByAdminOnly(bool $editCriteriaNotationByAdminOnly): self
  203. {
  204. $this->editCriteriaNotationByAdminOnly = $editCriteriaNotationByAdminOnly;
  205. return $this;
  206. }
  207. public function getSmsSenderName(): ?string
  208. {
  209. return $this->smsSenderName;
  210. }
  211. public function setSmsSenderName(?string $smsSenderName): self
  212. {
  213. $this->smsSenderName = $smsSenderName;
  214. return $this;
  215. }
  216. public function getLogoDonorsMove(): bool
  217. {
  218. return $this->logoDonorsMove;
  219. }
  220. public function setLogoDonorsMove(bool $logoDonorsMove): self
  221. {
  222. $this->logoDonorsMove = $logoDonorsMove;
  223. return $this;
  224. }
  225. public function getSubDomain(): ?string
  226. {
  227. return $this->subDomain;
  228. }
  229. public function setSubDomain(?string $subDomain): self
  230. {
  231. $this->subDomain = $subDomain;
  232. return $this;
  233. }
  234. public function getWebsite(): ?string
  235. {
  236. return $this->website;
  237. }
  238. public function setWebsite(?string $website): self
  239. {
  240. $this->website = $website;
  241. return $this;
  242. }
  243. public function getOtherWebsite(): ?string
  244. {
  245. return $this->otherWebsite;
  246. }
  247. public function setOtherWebsite(?string $otherWebsite): self
  248. {
  249. $this->otherWebsite = $otherWebsite;
  250. return $this;
  251. }
  252. public function getDesactivateOpentalentSiteWeb(): bool
  253. {
  254. return $this->desactivateOpentalentSiteWeb;
  255. }
  256. public function setDesactivateOpentalentSiteWeb(bool $desactivateOpentalentSiteWeb): self
  257. {
  258. $this->desactivateOpentalentSiteWeb = $desactivateOpentalentSiteWeb;
  259. return $this;
  260. }
  261. public function getBulletinPeriod(): ?string
  262. {
  263. return $this->bulletinPeriod;
  264. }
  265. public function setBulletinPeriod(?string $bulletinPeriod): self
  266. {
  267. $this->bulletinPeriod = $bulletinPeriod;
  268. return $this;
  269. }
  270. public function getPublicationDirectors(): Collection
  271. {
  272. return $this->publicationDirectors;
  273. }
  274. public function addPublicationDirector(Access $access): self
  275. {
  276. if (!$this->publicationDirectors->contains($access)) {
  277. $this->publicationDirectors[] = $access;
  278. $access->setPublicationDirector($this);
  279. }
  280. return $this;
  281. }
  282. public function removePublicationDirector(Access $access): self
  283. {
  284. if ($this->publicationDirectors->removeElement($access)) {
  285. // set the owning side to null (unless already changed)
  286. if ($access->getPublicationDirector() === $this) {
  287. $access->setPublicationDirector(null);
  288. }
  289. }
  290. return $this;
  291. }
  292. public function getBulletinWithTeacher(): bool
  293. {
  294. return $this->bulletinWithTeacher;
  295. }
  296. public function setBulletinWithTeacher(bool $bulletinWithTeacher): self
  297. {
  298. $this->bulletinWithTeacher = $bulletinWithTeacher;
  299. return $this;
  300. }
  301. public function getBulletinPrintAddress(): bool
  302. {
  303. return $this->bulletinPrintAddress;
  304. }
  305. public function setBulletinPrintAddress(bool $bulletinPrintAddress): self
  306. {
  307. $this->bulletinPrintAddress = $bulletinPrintAddress;
  308. return $this;
  309. }
  310. public function getBulletinSignatureDirector(): bool
  311. {
  312. return $this->bulletinSignatureDirector;
  313. }
  314. public function setBulletinSignatureDirector(bool $bulletinSignatureDirector): self
  315. {
  316. $this->bulletinSignatureDirector = $bulletinSignatureDirector;
  317. return $this;
  318. }
  319. public function getBulletinDisplayLevelAcquired(): bool
  320. {
  321. return $this->bulletinDisplayLevelAcquired;
  322. }
  323. public function setBulletinDisplayLevelAcquired(bool $bulletinDisplayLevelAcquired): self
  324. {
  325. $this->bulletinDisplayLevelAcquired = $bulletinDisplayLevelAcquired;
  326. return $this;
  327. }
  328. public function getBulletinShowEducationWithoutEvaluation(): bool
  329. {
  330. return $this->bulletinShowEducationWithoutEvaluation;
  331. }
  332. public function setBulletinShowEducationWithoutEvaluation(bool $bulletinShowEducationWithoutEvaluation): self
  333. {
  334. $this->bulletinShowEducationWithoutEvaluation = $bulletinShowEducationWithoutEvaluation;
  335. return $this;
  336. }
  337. public function getBulletinViewTestResults(): bool
  338. {
  339. return $this->bulletinViewTestResults;
  340. }
  341. public function setBulletinViewTestResults(bool $bulletinViewTestResults): self
  342. {
  343. $this->bulletinViewTestResults = $bulletinViewTestResults;
  344. return $this;
  345. }
  346. public function getBulletinShowAbsences(): bool
  347. {
  348. return $this->bulletinShowAbsences;
  349. }
  350. public function setBulletinShowAbsences(bool $bulletinShowAbsences): self
  351. {
  352. $this->bulletinShowAbsences = $bulletinShowAbsences;
  353. return $this;
  354. }
  355. public function getBulletinShowAverages(): bool
  356. {
  357. return $this->bulletinShowAverages;
  358. }
  359. public function setBulletinShowAverages(bool $bulletinShowAverages): self
  360. {
  361. $this->bulletinShowAverages = $bulletinShowAverages;
  362. return $this;
  363. }
  364. public function getBulletinOutput(): ?string
  365. {
  366. return $this->bulletinOutput;
  367. }
  368. public function setBulletinOutput(?string $bulletinOutput): self
  369. {
  370. $this->bulletinOutput = $bulletinOutput;
  371. return $this;
  372. }
  373. public function getUsernameSMS(): ?string
  374. {
  375. return $this->usernameSMS;
  376. }
  377. public function setUsernameSMS(?string $usernameSMS): self
  378. {
  379. $this->usernameSMS = $usernameSMS;
  380. return $this;
  381. }
  382. public function getPasswordSMS(): ?string
  383. {
  384. return $this->passwordSMS;
  385. }
  386. public function setPasswordSMS(?string $passwordSMS): self
  387. {
  388. $this->passwordSMS = $passwordSMS;
  389. return $this;
  390. }
  391. public function getBulletinEditWithoutEvaluation(): bool
  392. {
  393. return $this->bulletinEditWithoutEvaluation;
  394. }
  395. public function setBulletinEditWithoutEvaluation(bool $bulletinEditWithoutEvaluation): self
  396. {
  397. $this->bulletinEditWithoutEvaluation = $bulletinEditWithoutEvaluation;
  398. return $this;
  399. }
  400. public function getBulletinReceiver(): ?string
  401. {
  402. return $this->bulletinReceiver;
  403. }
  404. public function setBulletinReceiver(?string $bulletinReceiver): self
  405. {
  406. $this->bulletinReceiver = $bulletinReceiver;
  407. return $this;
  408. }
  409. public function getShowAdherentList(): bool
  410. {
  411. return $this->showAdherentList;
  412. }
  413. public function setShowAdherentList(bool $showAdherentList): self
  414. {
  415. $this->showAdherentList = $showAdherentList;
  416. return $this;
  417. }
  418. public function getStudentsAreAdherents(): bool
  419. {
  420. return $this->studentsAreAdherents;
  421. }
  422. public function setStudentsAreAdherents(bool $studentsAreAdherents): self
  423. {
  424. $this->studentsAreAdherents = $studentsAreAdherents;
  425. return $this;
  426. }
  427. public function getTimezone(): string
  428. {
  429. return $this->timezone;
  430. }
  431. public function setTimezone(string $timezone): self
  432. {
  433. $this->timezone = $timezone;
  434. return $this;
  435. }
  436. public function getEducationPeriodicity(): ?string
  437. {
  438. return $this->educationPeriodicity;
  439. }
  440. public function setEducationPeriodicity(?string $educationPeriodicity): self
  441. {
  442. $this->educationPeriodicity = $educationPeriodicity;
  443. return $this;
  444. }
  445. public function getAdvancedEducationNotationType(): ?string
  446. {
  447. return $this->advancedEducationNotationType;
  448. }
  449. public function setAdvancedEducationNotationType(?string $advancedEducationNotationType): self
  450. {
  451. $this->advancedEducationNotationType = $advancedEducationNotationType;
  452. return $this;
  453. }
  454. public function getQrCode(): ?File
  455. {
  456. return $this->qrCode;
  457. }
  458. public function setQrCode(?File $qrCode): self
  459. {
  460. $this->qrCode = $qrCode;
  461. return $this;
  462. }
  463. public function getSendAttendanceSms(): bool
  464. {
  465. return $this->sendAttendanceSms;
  466. }
  467. public function setSendAttendanceSms(bool $sendAttendanceSms): self
  468. {
  469. $this->sendAttendanceSms = $sendAttendanceSms;
  470. return $this;
  471. }
  472. public function getSendAttendanceEmail(): bool
  473. {
  474. return $this->sendAttendanceEmail;
  475. }
  476. public function setSendAttendanceEmail(bool $sendAttendanceEmail): self
  477. {
  478. $this->sendAttendanceEmail = $sendAttendanceEmail;
  479. return $this;
  480. }
  481. public function getActiveSubdomain(): ?Subdomain
  482. {
  483. return $this->activeSubdomain;
  484. }
  485. public function setActiveSubdomain(?Subdomain $activeSubdomain): self
  486. {
  487. $this->activeSubdomain = $activeSubdomain;
  488. return $this;
  489. }
  490. public function getSubdomains(): Collection
  491. {
  492. return $this->subdomains;
  493. }
  494. public function addSubdomain($subdomain): self
  495. {
  496. $subdomain->setParameters($this);
  497. $this->subdomains[] = $subdomain;
  498. return $this;
  499. }
  500. public function removeSubdomain($subdomain): self
  501. {
  502. $subdomain->setParameters(null);
  503. $this->subdomains->removeElement($subdomain);
  504. return $this;
  505. }
  506. }