Parameters.php 20 KB

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