| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- <?php
- namespace AppBundle\Entity\Education;
- use AppBundle\Annotation\ExportSplitFields;
- use AppBundle\Entity\AccessAndFunction\Access;
- use AppBundle\Entity\Core\Tagg;
- use AppBundle\Entity\Traits\ActivityYearTrait;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use Finite\StatefulInterface;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- use AppBundle\Validator\Constraints\Education as OpentalentAssert;
- /**
- * EducationCurriculum suivi par un Access pendant une année scolaire
- *
- * @Iri("http://schema.org/EducationStudent")
- * @OpentalentAssert\EducationStudentAccessStudent
- * @OpentalentAssert\EducationStudentTiming
- */
- #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Education\Repository\EducationStudentRepository')]
- class EducationStudent implements StatefulInterface
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- use ActivityYearTrait;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['educationstudent', 'access_details', 'student_list', 'report_card', 'student_registration', 'educationnotation_list', 'examenconvocation_list_student', 'education_input_list', 'education_student_next_year', 'online_registration_access_details', 'accesses_no_reregistred_list'])]
- private $id;
- /**
- * @var Access
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'educationStudent', cascade: ['persist'])]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['educationstudent', 'my_student_list', 'educationstudent_reference', 'education_student_next_year', 'educationnotation_list_educationstudent', 'education_input_list', 'education_student_next_year', 'educationstudent_notation', 'education_student_next_year_edit'])]
- private $access;
- /**
- * @var EducationCurriculum
- *
- *
- */
- #[ORM\ManyToOne(targetEntity: 'EducationCurriculum', inversedBy: 'educationStudent')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- #[Groups(['educationstudent', 'access_details_educationstudent', 'my_student_list', 'report_card_educationstudent', 'student_registration_educationstudent', 'educationstudent_reference', 'educationnotation_list_educationstudent', 'examenconvocation_list_student', 'education_input_list', 'education_student_next_year', 'education_student_next_year_educationstudentlastyear', 'online_registration_access_details_educationstudent', 'educationstudent_notation', 'accesses_no_reregistred_list_educationstudent', 'student_list_educationstudent'])]
- private $educationCurriculum;
- /**
- * @var Access
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'educationStudentByTeacher')]
- #[ORM\JoinTable(name: 'educationstudent_teacher')]
- #[Groups(['educationstudent_teachers', 'report_card_educationstudent', 'access_details_educationstudent', 'student_registration_educationstudent', 'educationstudent_reference', 'student_list_educationstudent', 'educationnotation_list_educationstudent', 'education_student_next_year', 'education_student_next_year_educationstudentlastyear', 'education_input_list', 'accesses_no_reregistred_list_educationstudent'])]
- private $teachers;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string', length: 25, nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['educationstudent', 'report_card_educationstudent'])]
- private $graduation;
- /**
- * @var bool
- */
- #[ORM\Column(type: 'boolean', options: ['default' => false])]
- #[Assert\Type(type: 'boolean')]
- #[Assert\NotNull]
- #[Groups(['educationstudent', 'report_card_educationstudent', 'education_student_next_year', 'student_registration_educationstudent', 'education_student_next_year_educationstudentlastyear'])]
- private $acquired = false;
- /**
- * @var ArrayCollection<EducationNotation>
- */
- #[Assert\Valid]
- #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Education\EducationNotation', mappedBy: 'educationStudent', orphanRemoval: true, cascade: ['persist'])]
- #[Groups(['educationstudent_educationnotation', 'report_card_educationstudent', 'education_input_list', 'educationstudent_notation'])]
- private $educationNotations;
- /**
- * @var string
- */
- #[ORM\Column(type: 'text', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['educationstudent', 'report_card_educationstudent'])]
- private $annualAppreciation;
- /**
- * @var bool
- */
- #[ORM\Column(type: 'boolean', options: ['default' => false])]
- #[Assert\Type(type: 'boolean')]
- #[Assert\NotNull]
- #[Groups(['educationstudent', 'education_student_next_year', 'education_student_next_year_educationstudentlastyear', 'student_registration_educationstudent'])]
- private $registeredFollowingYear = false;
- /**
- * Finite State Status
- * @var
- */
- private $state;
- /**
- * @var bool
- */
- #[Groups(['template', 'education_student_next_year'])]
- private $stateTemplate;
- /**
- * Last year information
- * @var EducationStudent
- */
- #[ORM\ManyToOne(targetEntity: 'EducationStudent', inversedBy: 'referencedEducationStudent')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- #[Groups(['education_student_next_year'])]
- private $educationStudentLastYear;
- #[ORM\OneToMany(targetEntity: 'EducationStudent', mappedBy: 'educationStudentLastYear')]
- protected $referencedEducationStudent;
- /**
- * @var boolean
- */
- #[Groups(['educationstudent'])]
- private $allNotationsValid;
- /**
- * @var string
- * @ExportSplitFields({"educationCurriculum.education.educationCategory.label","educationCurriculum.education.educationComplementTemplate","educationCurriculum.cycle.label","educationCurriculum.year","educationCurriculum.level","teachersTemplate","educationTiming.timing"})
- */
- #[Groups(['intangible_list_educationcurriculums', 'educationcurriculum', 'student_list_educationstudent', 'accesses_no_reregistred_list_educationstudent'])]
- private $fullLabelTemplate;
- /**
- * @var string
- */
- #[Groups(['template', 'educationstudent_notation'])]
- private $educationCurriculumTemplate;
- /**
- * @var string
- */
- #[Groups(['template'])]
- private $teachersTemplate;
- /**
- * @var string
- */
- #[Groups(['educationstudent_placeroom', 'access_details_educationstudent'])]
- private $placeRoom;
- /**
- * @var array
- */
- #[ORM\Column(type: 'json_array', nullable: true)]
- #[Groups(['educationstudent', 'educationstudent_days', 'education_student_next_year', 'student_registration_educationstudent'])]
- private $days;
- private $days_export;
- /**
- * @var \DateTime
- */
- #[ORM\Column(type: 'time', nullable: true)]
- #[Assert\Time]
- #[Groups(['educationstudent', 'education_student_next_year', 'student_registration_educationstudent'])]
- private $time;
- /**
- * @var ArrayCollection<Tagg>
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'educationStudents')]
- #[Assert\Valid]
- #[ORM\JoinTable(name: 'tag_educationStudent', joinColumns: [], inverseJoinColumns: [])]
- #[ORM\JoinColumn(name: 'educationStudent_id', referencedColumnName: 'id')]
- #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- #[Groups(['eductionstudent_tags', 'manage_tags'])]
- private $tags;
- /**
- * @var EducationTiming
- */
- #[ORM\ManyToOne(targetEntity: 'EducationTiming', inversedBy: 'educationStudents')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- #[Groups(['educationstudent', 'student_registration_educationstudent', 'access_details_educationstudent', 'student_list_educationstudent', 'education_student_next_year', 'education_student_next_year_educationstudentlastyear'])]
- private $educationTiming;
- /**
- * Constructor
- */
- public function __construct()
- {
- $this->educationNotations = new ArrayCollection();
- $this->referencedEducationStudent = new ArrayCollection();
- $this->teachers = new ArrayCollection();
- $this->tags = new ArrayCollection();
- }
- /**
- * Gets allNotationsValid.
- *
- * @return boolean
- */
- public function getAllNotationsValid()
- {
- $allNotationsValid = true;
- $notations = $this->getEducationNotations();
- if(count($notations) == 0) $allNotationsValid = false;
- foreach ($notations as $notation) {
- if(!$notation->getIsValid()){
- $allNotationsValid = false;
- break;
- }
- }
- return $allNotationsValid;
- }
- /**
- * Sets id.
- *
- * @param int $id
- *
- * @return $this
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * Gets id.
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Sets access.
- *
- * @param Access $access
- *
- * @return $this
- */
- public function setAccess(\AppBundle\Entity\AccessAndFunction\Access $access)
- {
- $this->access = $access;
- return $this;
- }
- /**
- * Gets access.
- *
- * @return Access
- */
- public function getAccess()
- {
- return $this->access;
- }
- /**
- * Sets education Curriculum.
- *
- * @param EducationCurriculum $educationCurriculum
- *
- * @return $this
- */
- public function setEducationCurriculum(EducationCurriculum $educationCurriculum = null)
- {
- $this->educationCurriculum = $educationCurriculum;
- return $this;
- }
- /**
- * Gets education Curriculum.
- *
- * @return EducationCurriculum
- */
- public function getEducationCurriculum()
- {
- return $this->educationCurriculum;
- }
- /**
- * Sets graduation.
- *
- * @param string $graduation
- *
- * @return $this
- */
- public function setGraduation($graduation)
- {
- $this->graduation = $graduation;
- return $this;
- }
- /**
- * Gets graduation.
- *
- * @return string
- */
- public function getGraduation()
- {
- return $this->graduation;
- }
- /**
- * Sets Acquired.
- *
- * @param bool $acquired
- *
- * @return $this
- */
- public function setAcquired($acquired)
- {
- $this->acquired = $acquired;
- return $this;
- }
- /**
- * Gets Acquired.
- *
- * @return bool
- */
- public function getAcquired()
- {
- return $this->acquired;
- }
- /**
- * Gets the object state.
- *
- * @return string
- */
- public function getFiniteState()
- {
- return $this->state;
- }
- /**
- * @param string $state
- * @return $this
- */
- public function setFiniteState($state)
- {
- $this->state = $state;
- return $this;
- }
- /**
- * Set annualAppreciation
- *
- * @param string $annualAppreciation
- *
- * @return EducationStudent
- */
- public function setAnnualAppreciation($annualAppreciation)
- {
- $this->annualAppreciation = $annualAppreciation;
- return $this;
- }
- /**
- * Get annualAppreciation
- *
- * @return string
- */
- public function getAnnualAppreciation()
- {
- return $this->annualAppreciation;
- }
- /**
- * Add educationNotation
- *
- * @param \AppBundle\Entity\Education\EducationNotation $educationNotation
- *
- * @return EducationStudent
- */
- public function addEducationNotation(\AppBundle\Entity\Education\EducationNotation $educationNotation)
- {
- $educationNotation->setEducationStudent($this);
- $this->educationNotations[] = $educationNotation;
- return $this;
- }
- /**
- * Remove educationNotation
- *
- * @param \AppBundle\Entity\Education\EducationNotation $educationNotation
- */
- public function removeEducationNotation(\AppBundle\Entity\Education\EducationNotation $educationNotation)
- {
- $this->educationNotations->removeElement($educationNotation);
- }
- /**
- * Get educationNotations
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getEducationNotations()
- {
- return $this->educationNotations;
- }
- /**
- * Add teacher
- *
- * @param \AppBundle\Entity\AccessAndFunction\Access $teacher
- *
- * @return EducationStudent
- */
- public function addTeacher(\AppBundle\Entity\AccessAndFunction\Access $teacher)
- {
- $this->teachers[] = $teacher;
- return $this;
- }
- /**
- * Remove teacher
- *
- * @param \AppBundle\Entity\AccessAndFunction\Access $teacher
- */
- public function removeTeacher(\AppBundle\Entity\AccessAndFunction\Access $teacher)
- {
- $this->teachers->removeElement($teacher);
- }
- /**
- * Get teachers
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getTeachers()
- {
- return $this->teachers;
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelTemplate()
- {
- return array_merge($this->getEducationCurriculumTemplate(), $this->getTeachersTemplate(), [$this->getEducationTiming() ? $this->getEducationTiming()->getTiming() : '']);
- }
- /**
- * @return array
- */
- public function getEducationCurriculumTemplate()
- {
- $educationCurriculumTemplate = [];
- if($this->getEducationCurriculum())
- $educationCurriculumTemplate = $this->getEducationCurriculum()->getFullLabelTemplate();
- return $educationCurriculumTemplate;
- }
- /**
- * @return array
- */
- public function getTeachersTemplate()
- {
- $teachers = [];
- foreach($this->getTeachers() as $teacher){
- $teachers[] = $teacher->getPerson()->getFullNameTemplate();
- }
- return [implode(", ", $teachers)];
- }
- /**
- * Gets full label.
- *
- * @return string
- */
- public function getPlaceRoom()
- {
- $placeRoom = '';
- $student = $this->getAccess();
- foreach ($student->getCourses() as $course){
- foreach ($course->getEducationCurriculum() as $educationCurri)
- if (!is_null($educationCurri) && !is_null($this->getEducationCurriculum()) &&
- $educationCurri->getId() === $this->getEducationCurriculum()->getId()
- && $course->getStartYear() === $this->getStartYear()){
- $place = $course->getPlace() ? $course->getPlace()->getName().' ' : '';
- $room = $course->getRoom() ? $course->getRoom()->getName() : '';
- $placeRoom = $place.$room;
- }
- }
- return $placeRoom;
- }
- /**
- * Set registeredFollowingYear
- *
- * @param boolean $registeredFollowingYear
- *
- * @return EducationStudent
- */
- public function setRegisteredFollowingYear($registeredFollowingYear)
- {
- $this->registeredFollowingYear = $registeredFollowingYear;
- return $this;
- }
- /**
- * Get registeredFollowingYear
- *
- * @return boolean
- */
- public function getRegisteredFollowingYear()
- {
- return $this->registeredFollowingYear;
- }
- /**
- * Sets Education Student Last Year information.
- *
- * @param EducationStudent $access
- *
- * @return $this
- */
- public function setEducationStudentLastYear(EducationStudent $educationStudentLastYear)
- {
- $this->educationStudentLastYear = $educationStudentLastYear;
- return $this;
- }
- /**
- * Gets Education Student Last Year information.
- *
- * @return EducationStudent
- */
- public function getEducationStudentLastYear()
- {
- return $this->educationStudentLastYear;
- }
- /**
- * Set days
- *
- * @param array $days
- *
- * @return EducationStudent
- */
- public function setDays($days)
- {
- $this->days = $days;
- return $this;
- }
- /**
- * Get days
- *
- * @return array
- */
- public function getDays()
- {
- return $this->days;
- }
- /**
- * Set time
- *
- * @param \DateTime $time
- *
- * @return EducationStudent
- */
- public function setTime($time)
- {
- $this->time = $time;
- return $this;
- }
- /**
- * Get time
- *
- */
- public function getTime()
- {
- if($this->time){
- $this->time->setTime($this->time->format("H"), $this->time->format("i"), 0);
- return $this->time->format('H:i');
- }
- return null;
- }
- /**
- * Add tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- *
- * @return EducationStudent
- */
- public function addTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags[] = $tag;
- return $this;
- }
- /**
- * Remove tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- */
- public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags->removeElement($tag);
- }
- /**
- * Get tags
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getTags()
- {
- return $this->tags;
- }
- /**
- * Gets full label.
- *
- * @return bool
- */
- public function getStateTemplate()
- {
- $year = date("Y");
- $lastYear = $year - 1;
- return $this->getStartYear() != $lastYear;
- }
- /**
- * Sets EducationTiming
- *
- * @param EducationTiming $educationTiming
- *
- * @return $this
- */
- public function setEducationTiming(EducationTiming $educationTiming = null)
- {
- $this->educationTiming = $educationTiming;
- return $this;
- }
- /**
- * Gets EducationTiming
- *
- * @return EducationTiming
- */
- public function getEducationTiming()
- {
- return $this->educationTiming;
- }
- }
|