Parameters.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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: true, 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: true)]
  98. private ?string $usernameSMS = null;
  99. #[ORM\Column(length: 255, nullable: true)]
  100. private ?string $passwordSMS = null;
  101. #[ORM\Column(options: ['default' => true])]
  102. private bool $showAdherentList = true;
  103. #[ORM\Column(options: ['default' => false])]
  104. private bool $studentsAreAdherents = false;
  105. #[ORM\OneToOne(inversedBy: 'qrCode', targetEntity: File::class, cascade: ['persist'], fetch: 'EAGER')]
  106. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  107. private ?File $qrCode = null;
  108. #[ORM\Column(length: 255, options: ['default' => 'Europe/Paris'])]
  109. #[Assert\Choice(callback: ['\\App\\Enum\\Core\\TimeZoneEnum', 'toArray'], message: 'invalid-timezone')]
  110. private ?string $timezone = "Europe/Paris";
  111. #[ORM\Column(length: 255, nullable: false, options: ['default' => 'ANNUAL'])]
  112. #[Assert\Choice(callback: ['\\App\\Enum\\Education\\PeriodicityEnum', 'toArray'], message: 'invalid-periodicity')]
  113. private ?string $educationPeriodicity = 'ANNUAL';
  114. #[ORM\Column(length: 255, nullable: true, options: ['default' => 'BY_EDUCATION'])]
  115. #[Assert\Choice(callback: ['\\App\\Enum\\Education\\AdvancedEducationNotationTypeEnum', 'toArray'], message: 'invalid-advanced-education-notation-type')]
  116. private ?string $advancedEducationNotationType = null;
  117. #[ORM\Column(options: ['default' => false])]
  118. private bool $sendAttendanceEmail = false;
  119. #[ORM\Column(options: ['default' => false])]
  120. private bool $sendAttendanceSms = false;
  121. #[Pure]
  122. public function __construct()
  123. {
  124. $this->publicationDirectors = new ArrayCollection();
  125. }
  126. public function getId(): ?int
  127. {
  128. return $this->id;
  129. }
  130. public function getOrganization(): Organization
  131. {
  132. return $this->organization;
  133. }
  134. public function setOrganization(Organization $organization): self
  135. {
  136. $this->organization = $organization;
  137. return $this;
  138. }
  139. public function getFinancialDate(): ?\DateTimeInterface
  140. {
  141. return $this->financialDate;
  142. }
  143. public function setFinancialDate(?\DateTimeInterface $financialDate): self
  144. {
  145. $this->financialDate = $financialDate;
  146. return $this;
  147. }
  148. public function getMusicalDate(): ?\DateTimeInterface
  149. {
  150. return $this->musicalDate;
  151. }
  152. public function setMusicalDate(?\DateTimeInterface $musicalDate): self
  153. {
  154. $this->musicalDate = $musicalDate;
  155. return $this;
  156. }
  157. public function getStartCourseDate(): ?\DateTimeInterface
  158. {
  159. return $this->startCourseDate;
  160. }
  161. public function setStartCourseDate(?\DateTimeInterface $startCourseDate): self
  162. {
  163. $this->startCourseDate = $startCourseDate;
  164. return $this;
  165. }
  166. public function getEndCourseDate(): ?\DateTimeInterface
  167. {
  168. return $this->endCourseDate;
  169. }
  170. public function setEndCourseDate(?\DateTimeInterface $endCourseDate): self
  171. {
  172. $this->endCourseDate = $endCourseDate;
  173. return $this;
  174. }
  175. public function getAverage(): int
  176. {
  177. return $this->average;
  178. }
  179. public function setAverage(int $average): self
  180. {
  181. $this->average = $average;
  182. return $this;
  183. }
  184. public function getEditCriteriaNotationByAdminOnly(): bool
  185. {
  186. return $this->editCriteriaNotationByAdminOnly;
  187. }
  188. public function setEditCriteriaNotationByAdminOnly(bool $editCriteriaNotationByAdminOnly): self
  189. {
  190. $this->editCriteriaNotationByAdminOnly = $editCriteriaNotationByAdminOnly;
  191. return $this;
  192. }
  193. public function getSmsSenderName(): ?string
  194. {
  195. return $this->smsSenderName;
  196. }
  197. public function setSmsSenderName(?string $smsSenderName): self
  198. {
  199. $this->smsSenderName = $smsSenderName;
  200. return $this;
  201. }
  202. public function getLogoDonorsMove(): bool
  203. {
  204. return $this->logoDonorsMove;
  205. }
  206. public function setLogoDonorsMove(bool $logoDonorsMove): self
  207. {
  208. $this->logoDonorsMove = $logoDonorsMove;
  209. return $this;
  210. }
  211. public function getOtherWebsite(): ?string
  212. {
  213. return $this->otherWebsite;
  214. }
  215. public function setOtherWebsite(?string $otherWebsite): self
  216. {
  217. $this->otherWebsite = $otherWebsite;
  218. return $this;
  219. }
  220. /**
  221. * @return string|null
  222. */
  223. public function getCustomDomain(): ?string
  224. {
  225. return $this->customDomain;
  226. }
  227. /**
  228. * @param string|null $customDomain
  229. */
  230. public function setCustomDomain(?string $customDomain): void
  231. {
  232. $this->customDomain = $customDomain;
  233. }
  234. public function getDesactivateOpentalentSiteWeb(): bool
  235. {
  236. return $this->desactivateOpentalentSiteWeb;
  237. }
  238. public function setDesactivateOpentalentSiteWeb(bool $desactivateOpentalentSiteWeb): self
  239. {
  240. $this->desactivateOpentalentSiteWeb = $desactivateOpentalentSiteWeb;
  241. return $this;
  242. }
  243. public function getBulletinPeriod(): ?string
  244. {
  245. return $this->bulletinPeriod;
  246. }
  247. public function setBulletinPeriod(?string $bulletinPeriod): self
  248. {
  249. $this->bulletinPeriod = $bulletinPeriod;
  250. return $this;
  251. }
  252. public function getPublicationDirectors(): Collection
  253. {
  254. return $this->publicationDirectors;
  255. }
  256. public function addPublicationDirector(Access $access): self
  257. {
  258. if (!$this->publicationDirectors->contains($access)) {
  259. $this->publicationDirectors[] = $access;
  260. $access->setPublicationDirector($this);
  261. }
  262. return $this;
  263. }
  264. public function removePublicationDirector(Access $access): self
  265. {
  266. if ($this->publicationDirectors->removeElement($access)) {
  267. // set the owning side to null (unless already changed)
  268. if ($access->getPublicationDirector() === $this) {
  269. $access->setPublicationDirector(null);
  270. }
  271. }
  272. return $this;
  273. }
  274. public function getBulletinWithTeacher(): bool
  275. {
  276. return $this->bulletinWithTeacher;
  277. }
  278. public function setBulletinWithTeacher(bool $bulletinWithTeacher): self
  279. {
  280. $this->bulletinWithTeacher = $bulletinWithTeacher;
  281. return $this;
  282. }
  283. public function getBulletinPrintAddress(): bool
  284. {
  285. return $this->bulletinPrintAddress;
  286. }
  287. public function setBulletinPrintAddress(bool $bulletinPrintAddress): self
  288. {
  289. $this->bulletinPrintAddress = $bulletinPrintAddress;
  290. return $this;
  291. }
  292. public function getBulletinSignatureDirector(): bool
  293. {
  294. return $this->bulletinSignatureDirector;
  295. }
  296. public function setBulletinSignatureDirector(bool $bulletinSignatureDirector): self
  297. {
  298. $this->bulletinSignatureDirector = $bulletinSignatureDirector;
  299. return $this;
  300. }
  301. public function getBulletinDisplayLevelAcquired(): bool
  302. {
  303. return $this->bulletinDisplayLevelAcquired;
  304. }
  305. public function setBulletinDisplayLevelAcquired(bool $bulletinDisplayLevelAcquired): self
  306. {
  307. $this->bulletinDisplayLevelAcquired = $bulletinDisplayLevelAcquired;
  308. return $this;
  309. }
  310. public function getBulletinShowEducationWithoutEvaluation(): bool
  311. {
  312. return $this->bulletinShowEducationWithoutEvaluation;
  313. }
  314. public function setBulletinShowEducationWithoutEvaluation(bool $bulletinShowEducationWithoutEvaluation): self
  315. {
  316. $this->bulletinShowEducationWithoutEvaluation = $bulletinShowEducationWithoutEvaluation;
  317. return $this;
  318. }
  319. public function getBulletinViewTestResults(): bool
  320. {
  321. return $this->bulletinViewTestResults;
  322. }
  323. public function setBulletinViewTestResults(bool $bulletinViewTestResults): self
  324. {
  325. $this->bulletinViewTestResults = $bulletinViewTestResults;
  326. return $this;
  327. }
  328. public function getBulletinShowAbsences(): bool
  329. {
  330. return $this->bulletinShowAbsences;
  331. }
  332. public function setBulletinShowAbsences(bool $bulletinShowAbsences): self
  333. {
  334. $this->bulletinShowAbsences = $bulletinShowAbsences;
  335. return $this;
  336. }
  337. public function getBulletinShowAverages(): bool
  338. {
  339. return $this->bulletinShowAverages;
  340. }
  341. public function setBulletinShowAverages(bool $bulletinShowAverages): self
  342. {
  343. $this->bulletinShowAverages = $bulletinShowAverages;
  344. return $this;
  345. }
  346. public function getBulletinOutput(): ?string
  347. {
  348. return $this->bulletinOutput;
  349. }
  350. public function setBulletinOutput(?string $bulletinOutput): self
  351. {
  352. $this->bulletinOutput = $bulletinOutput;
  353. return $this;
  354. }
  355. public function getUsernameSMS(): ?string
  356. {
  357. return $this->usernameSMS;
  358. }
  359. public function setUsernameSMS(?string $usernameSMS): self
  360. {
  361. $this->usernameSMS = $usernameSMS;
  362. return $this;
  363. }
  364. public function getPasswordSMS(): ?string
  365. {
  366. return $this->passwordSMS;
  367. }
  368. public function setPasswordSMS(?string $passwordSMS): self
  369. {
  370. $this->passwordSMS = $passwordSMS;
  371. return $this;
  372. }
  373. public function getBulletinEditWithoutEvaluation(): bool
  374. {
  375. return $this->bulletinEditWithoutEvaluation;
  376. }
  377. public function setBulletinEditWithoutEvaluation(bool $bulletinEditWithoutEvaluation): self
  378. {
  379. $this->bulletinEditWithoutEvaluation = $bulletinEditWithoutEvaluation;
  380. return $this;
  381. }
  382. public function getBulletinReceiver(): ?string
  383. {
  384. return $this->bulletinReceiver;
  385. }
  386. public function setBulletinReceiver(?string $bulletinReceiver): self
  387. {
  388. $this->bulletinReceiver = $bulletinReceiver;
  389. return $this;
  390. }
  391. public function getShowAdherentList(): bool
  392. {
  393. return $this->showAdherentList;
  394. }
  395. public function setShowAdherentList(bool $showAdherentList): self
  396. {
  397. $this->showAdherentList = $showAdherentList;
  398. return $this;
  399. }
  400. public function getStudentsAreAdherents(): bool
  401. {
  402. return $this->studentsAreAdherents;
  403. }
  404. public function setStudentsAreAdherents(bool $studentsAreAdherents): self
  405. {
  406. $this->studentsAreAdherents = $studentsAreAdherents;
  407. return $this;
  408. }
  409. public function getTimezone(): string
  410. {
  411. return $this->timezone;
  412. }
  413. public function setTimezone(string $timezone): self
  414. {
  415. $this->timezone = $timezone;
  416. return $this;
  417. }
  418. public function getEducationPeriodicity(): ?string
  419. {
  420. return $this->educationPeriodicity;
  421. }
  422. public function setEducationPeriodicity(?string $educationPeriodicity): self
  423. {
  424. $this->educationPeriodicity = $educationPeriodicity;
  425. return $this;
  426. }
  427. public function getAdvancedEducationNotationType(): ?string
  428. {
  429. return $this->advancedEducationNotationType;
  430. }
  431. public function setAdvancedEducationNotationType(?string $advancedEducationNotationType): self
  432. {
  433. $this->advancedEducationNotationType = $advancedEducationNotationType;
  434. return $this;
  435. }
  436. public function getQrCode(): ?File
  437. {
  438. return $this->qrCode;
  439. }
  440. public function setQrCode(?File $qrCode): self
  441. {
  442. $this->qrCode = $qrCode;
  443. return $this;
  444. }
  445. public function getSendAttendanceSms(): bool
  446. {
  447. return $this->sendAttendanceSms;
  448. }
  449. public function setSendAttendanceSms(bool $sendAttendanceSms): self
  450. {
  451. $this->sendAttendanceSms = $sendAttendanceSms;
  452. return $this;
  453. }
  454. public function getSendAttendanceEmail(): bool
  455. {
  456. return $this->sendAttendanceEmail;
  457. }
  458. public function setSendAttendanceEmail(bool $sendAttendanceEmail): self
  459. {
  460. $this->sendAttendanceEmail = $sendAttendanceEmail;
  461. return $this;
  462. }
  463. }