Parameters.php 20 KB

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